5 #include <X11/Xft/Xft.h>
9 #include <X11/keysym.h>
10 #include <X11/cursorfont.h>
12 #include <X11/Xlocale.h>
14 /********** data ************/
16 #define CHECK_BUTTON_ON_WIDTH 16
17 #define CHECK_BUTTON_ON_HEIGHT 16
19 static char *CHECK_BUTTON_ON
[] = {
38 #define CHECK_BUTTON_OFF_WIDTH 16
39 #define CHECK_BUTTON_OFF_HEIGHT 16
41 static char *CHECK_BUTTON_OFF
[] = {
60 #define RADIO_BUTTON_ON_WIDTH 15
61 #define RADIO_BUTTON_ON_HEIGHT 15
62 static char *RADIO_BUTTON_ON
[] = {
80 #define RADIO_BUTTON_OFF_WIDTH 15
81 #define RADIO_BUTTON_OFF_HEIGHT 15
82 static char *RADIO_BUTTON_OFF
[] = {
100 #define TRISTATE_BUTTON_ON_WIDTH 15
101 #define TRISTATE_BUTTON_ON_HEIGHT 15
102 static char *TRISTATE_BUTTON_ON
[] = {
120 #define TRISTATE_BUTTON_OFF_WIDTH 15
121 #define TRISTATE_BUTTON_OFF_HEIGHT 15
122 static char *TRISTATE_BUTTON_OFF
[] = {
140 #define TRISTATE_BUTTON_TRI_WIDTH 15
141 #define TRISTATE_BUTTON_TRI_HEIGHT 15
142 static char *TRISTATE_BUTTON_TRI
[] = {
160 static char *BUTTON_ARROW
[] = {
161 "..................",
162 "....##....#### ...",
163 "...#.%....#... ...",
164 "..#..%#####... ...",
165 ".#............ ...",
166 "#............. ...",
167 ".#............ ...",
169 "...#. ............",
173 #define BUTTON_ARROW_WIDTH 18
174 #define BUTTON_ARROW_HEIGHT 10
176 static char *BUTTON_ARROW2
[] = {
189 #define BUTTON_ARROW2_WIDTH 18
190 #define BUTTON_ARROW2_HEIGHT 10
192 static char *SCROLLER_DIMPLE
[] = {
201 #define SCROLLER_DIMPLE_WIDTH 6
202 #define SCROLLER_DIMPLE_HEIGHT 6
204 static char *SCROLLER_ARROW_UP
[] = {
216 static char *HI_SCROLLER_ARROW_UP
[] = {
228 #define SCROLLER_ARROW_UP_WIDTH 9
229 #define SCROLLER_ARROW_UP_HEIGHT 9
231 static char *SCROLLER_ARROW_DOWN
[] = {
243 static char *HI_SCROLLER_ARROW_DOWN
[] = {
255 #define SCROLLER_ARROW_DOWN_WIDTH 9
256 #define SCROLLER_ARROW_DOWN_HEIGHT 9
258 static char *SCROLLER_ARROW_LEFT
[] = {
270 static char *HI_SCROLLER_ARROW_LEFT
[] = {
282 #define SCROLLER_ARROW_LEFT_WIDTH 9
283 #define SCROLLER_ARROW_LEFT_HEIGHT 9
285 static char *SCROLLER_ARROW_RIGHT
[] = {
297 static char *HI_SCROLLER_ARROW_RIGHT
[] = {
309 #define SCROLLER_ARROW_RIGHT_WIDTH 9
310 #define SCROLLER_ARROW_RIGHT_HEIGHT 9
312 static char *POPUP_INDICATOR
[] = {
323 #define POPUP_INDICATOR_WIDTH 11
324 #define POPUP_INDICATOR_HEIGHT 8
326 static char *PULLDOWN_INDICATOR
[] = {
336 #define PULLDOWN_INDICATOR_WIDTH 9
337 #define PULLDOWN_INDICATOR_HEIGHT 7
339 #define CHECK_MARK_WIDTH 8
340 #define CHECK_MARK_HEIGHT 10
342 static char *CHECK_MARK
[] = {
355 #define STIPPLE_WIDTH 8
356 #define STIPPLE_HEIGHT 8
357 static char STIPPLE_BITS
[] = {
358 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55
361 static int userWidgetCount
= 0;
363 /***** end data ******/
365 static void renderPixmap(W_Screen
* screen
, Pixmap d
, Pixmap mask
, char **data
, int width
, int height
)
368 GC whiteGC
= WMColorGC(screen
->white
);
369 GC blackGC
= WMColorGC(screen
->black
);
370 GC lightGC
= WMColorGC(screen
->gray
);
371 GC darkGC
= WMColorGC(screen
->darkGray
);
374 XSetForeground(screen
->display
, screen
->monoGC
, 0);
376 for (y
= 0; y
< height
; y
++) {
377 for (x
= 0; x
< width
; x
++) {
378 switch (data
[y
][x
]) {
381 XDrawPoint(screen
->display
, d
, whiteGC
, x
, y
);
386 XDrawPoint(screen
->display
, mask
, screen
->monoGC
, x
, y
);
391 XDrawPoint(screen
->display
, d
, lightGC
, x
, y
);
396 XDrawPoint(screen
->display
, d
, darkGC
, x
, y
);
402 XDrawPoint(screen
->display
, d
, blackGC
, x
, y
);
409 static WMPixmap
*makePixmap(W_Screen
* sPtr
, char **data
, int width
, int height
, int masked
)
411 Pixmap pixmap
, mask
= None
;
413 pixmap
= XCreatePixmap(sPtr
->display
, W_DRAWABLE(sPtr
), width
, height
, sPtr
->depth
);
416 mask
= XCreatePixmap(sPtr
->display
, W_DRAWABLE(sPtr
), width
, height
, 1);
417 XSetForeground(sPtr
->display
, sPtr
->monoGC
, 1);
418 XFillRectangle(sPtr
->display
, mask
, sPtr
->monoGC
, 0, 0, width
, height
);
421 renderPixmap(sPtr
, pixmap
, mask
, data
, width
, height
);
423 return WMCreatePixmapFromXPixmaps(sPtr
, pixmap
, mask
, width
, height
, sPtr
->depth
);
426 #define T_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.tiff"
427 #define X_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.xpm"
429 static Bool
loadPixmaps(WMScreen
* scr
)
443 image
= RLoadImage(scr
->rcontext
, T_WINGS_IMAGES_FILE
, 0);
445 image
= RLoadImage(scr
->rcontext
, X_WINGS_IMAGES_FILE
, 0);
447 wwarning(_("WINGs: could not load widget images file: %s"), RMessageForError(RErrorCode
));
451 /* make it have a gray background */
452 tmp
= RGetSubImage(image
, 0, 0, 24, 24);
453 RCombineImageWithColor(tmp
, &gray
);
454 scr
->homeIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
456 /* make it have a white background */
457 tmp
= RGetSubImage(image
, 0, 0, 24, 24);
458 RCombineImageWithColor(tmp
, &white
);
459 scr
->altHomeIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
463 tmp
= RGetSubImage(image
, 104, 0, 24, 24);
464 RCombineImageWithColor(tmp
, &white
);
465 scr
->trashcanIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
467 tmp
= RGetSubImage(image
, 104, 0, 24, 24);
468 RCombineImageWithColor(tmp
, &white
);
469 scr
->altTrashcanIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
472 tmp
= RGetSubImage(image
, 104, 24, 24, 24);
473 RCombineImageWithColor(tmp
, &white
);
474 scr
->createDirIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
476 tmp
= RGetSubImage(image
, 104, 24, 24, 24);
477 RCombineImageWithColor(tmp
, &white
);
478 scr
->altCreateDirIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
481 tmp
= RGetSubImage(image
, 24, 80, 24, 24);
482 RCombineImageWithColor(tmp
, &white
);
483 scr
->disketteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
485 tmp
= RGetSubImage(image
, 24, 80, 24, 24);
486 RCombineImageWithColor(tmp
, &white
);
487 scr
->altDisketteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
490 tmp
= RGetSubImage(image
, 0, 80, 24, 24);
491 RCombineImageWithColor(tmp
, &white
);
492 scr
->unmountIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
494 tmp
= RGetSubImage(image
, 0, 80, 24, 24);
495 RCombineImageWithColor(tmp
, &white
);
496 scr
->altUnmountIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
499 /* Magnifying Glass Icon for ColorPanel */
500 tmp
= RGetSubImage(image
, 24, 0, 40, 32);
501 RCombineImageWithColor(tmp
, &gray
);
502 scr
->magnifyIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
504 /* ColorWheel Icon for ColorPanel */
505 tmp
= RGetSubImage(image
, 0, 25, 24, 24);
506 scr
->wheelIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
508 /* GrayScale Icon for ColorPanel */
509 tmp
= RGetSubImage(image
, 65, 0, 40, 24);
510 scr
->grayIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
512 /* RGB Icon for ColorPanel */
513 tmp
= RGetSubImage(image
, 25, 33, 40, 24);
514 scr
->rgbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
516 /* CMYK Icon for ColorPanel */
517 tmp
= RGetSubImage(image
, 65, 25, 40, 24);
518 scr
->cmykIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
520 /* HSB Icon for ColorPanel */
521 tmp
= RGetSubImage(image
, 0, 57, 40, 24);
522 scr
->hsbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
524 /* CustomColorPalette Icon for ColorPanel */
525 tmp
= RGetSubImage(image
, 81, 57, 40, 24);
526 scr
->customPaletteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
528 /* ColorList Icon for ColorPanel */
529 tmp
= RGetSubImage(image
, 41, 57, 40, 24);
530 scr
->colorListIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
533 RReleaseImage(image
);
538 WMScreen
*WMOpenScreen(const char *display
)
540 Display
*dpy
= XOpenDisplay(display
);
543 wwarning(_("WINGs: could not open display %s"), XDisplayName(display
));
547 return WMCreateSimpleApplicationScreen(dpy
);
550 WMScreen
*WMCreateSimpleApplicationScreen(Display
* display
)
554 scr
= WMCreateScreen(display
, DefaultScreen(display
));
556 scr
->aflags
.hasAppIcon
= 0;
557 scr
->aflags
.simpleApplication
= 1;
562 WMScreen
*WMCreateScreen(Display
* display
, int screen
)
564 return WMCreateScreenWithRContext(display
, screen
, RCreateContext(display
, screen
, NULL
));
567 WMScreen
*WMCreateScreenWithRContext(Display
* display
, int screen
, RContext
* context
)
572 static int initialized
= 0;
573 static char *atomNames
[] = {
587 "XdndActionDescription",
594 "_WINGS_DND_MOUSE_OFFSET",
601 Atom atoms
[wlengthof(atomNames
)];
608 W_ReadConfigurations();
610 assert(W_ApplicationInitialized());
613 scrPtr
= malloc(sizeof(W_Screen
));
616 memset(scrPtr
, 0, sizeof(W_Screen
));
618 scrPtr
->aflags
.hasAppIcon
= 1;
620 scrPtr
->display
= display
;
621 scrPtr
->screen
= screen
;
622 scrPtr
->rcontext
= context
;
624 scrPtr
->depth
= context
->depth
;
626 scrPtr
->visual
= context
->visual
;
627 scrPtr
->lastEventTime
= 0;
629 scrPtr
->colormap
= context
->cmap
;
631 scrPtr
->rootWin
= RootWindow(display
, screen
);
633 scrPtr
->fontCache
= WMCreateHashTable(WMStringPointerHashCallbacks
);
635 scrPtr
->xftdraw
= XftDrawCreate(scrPtr
->display
, W_DRAWABLE(scrPtr
), scrPtr
->visual
, scrPtr
->colormap
);
637 /* Create missing CUT_BUFFERs */
640 int exists
[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
643 rootWinProps
= XListProperties(display
, scrPtr
->rootWin
, &count
);
644 for (i
= 0; i
< count
; i
++) {
645 switch (rootWinProps
[i
]) {
677 for (i
= 0; i
< 8; i
++) {
679 XStoreBuffer(display
, "", 0, i
);
684 scrPtr
->ignoredModifierMask
= 0;
687 XModifierKeymap
*modmap
;
688 KeyCode nlock
, slock
;
689 static int mask_table
[8] = {
690 ShiftMask
, LockMask
, ControlMask
, Mod1Mask
,
691 Mod2Mask
, Mod3Mask
, Mod4Mask
, Mod5Mask
693 unsigned int numLockMask
= 0, scrollLockMask
= 0;
695 nlock
= XKeysymToKeycode(display
, XK_Num_Lock
);
696 slock
= XKeysymToKeycode(display
, XK_Scroll_Lock
);
699 * Find out the masks for the NumLock and ScrollLock modifiers,
700 * so that we can bind the grabs for when they are enabled too.
702 modmap
= XGetModifierMapping(display
);
704 if (modmap
!= NULL
&& modmap
->max_keypermod
> 0) {
705 for (i
= 0; i
< 8 * modmap
->max_keypermod
; i
++) {
706 if (modmap
->modifiermap
[i
] == nlock
&& nlock
!= 0)
707 numLockMask
= mask_table
[i
/ modmap
->max_keypermod
];
708 else if (modmap
->modifiermap
[i
] == slock
&& slock
!= 0)
709 scrollLockMask
= mask_table
[i
/ modmap
->max_keypermod
];
714 XFreeModifiermap(modmap
);
716 scrPtr
->ignoredModifierMask
= numLockMask
| scrollLockMask
| LockMask
;
719 /* initially allocate some colors */
720 WMWhiteColor(scrPtr
);
721 WMBlackColor(scrPtr
);
723 WMDarkGrayColor(scrPtr
);
725 gcv
.graphics_exposures
= False
;
727 gcv
.function
= GXxor
;
728 gcv
.foreground
= W_PIXEL(scrPtr
->white
);
729 if (gcv
.foreground
== 0)
731 scrPtr
->xorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
732 | GCGraphicsExposures
| GCForeground
, &gcv
);
734 gcv
.function
= GXxor
;
735 gcv
.foreground
= W_PIXEL(scrPtr
->gray
);
736 gcv
.subwindow_mode
= IncludeInferiors
;
737 scrPtr
->ixorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
738 | GCGraphicsExposures
| GCForeground
| GCSubwindowMode
, &gcv
);
740 gcv
.function
= GXcopy
;
741 scrPtr
->copyGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
| GCGraphicsExposures
, &gcv
);
743 scrPtr
->clipGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
| GCGraphicsExposures
, &gcv
);
745 stipple
= XCreateBitmapFromData(display
, W_DRAWABLE(scrPtr
), STIPPLE_BITS
, STIPPLE_WIDTH
, STIPPLE_HEIGHT
);
746 gcv
.foreground
= W_PIXEL(scrPtr
->darkGray
);
747 gcv
.background
= W_PIXEL(scrPtr
->gray
);
748 gcv
.fill_style
= FillStippled
;
749 gcv
.stipple
= stipple
;
750 scrPtr
->stippleGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
),
751 GCForeground
| GCBackground
| GCStipple
752 | GCFillStyle
| GCGraphicsExposures
, &gcv
);
754 scrPtr
->drawStringGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCGraphicsExposures
, &gcv
);
755 scrPtr
->drawImStringGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCGraphicsExposures
, &gcv
);
757 /* we need a 1bpp drawable for the monoGC, so borrow this one */
758 scrPtr
->monoGC
= XCreateGC(display
, stipple
, 0, NULL
);
760 scrPtr
->stipple
= stipple
;
762 scrPtr
->antialiasedText
= WINGsConfiguration
.antialiasedText
;
764 scrPtr
->normalFont
= WMSystemFontOfSize(scrPtr
, 0);
766 scrPtr
->boldFont
= WMBoldSystemFontOfSize(scrPtr
, 0);
768 if (!scrPtr
->boldFont
)
769 scrPtr
->boldFont
= scrPtr
->normalFont
;
771 if (!scrPtr
->normalFont
) {
772 wwarning(_("could not load any fonts. Make sure your font installation"
773 " and locale settings are correct."));
778 /* create input method stuff */
781 scrPtr
->checkButtonImageOn
= makePixmap(scrPtr
, CHECK_BUTTON_ON
,
782 CHECK_BUTTON_ON_WIDTH
, CHECK_BUTTON_ON_HEIGHT
, False
);
784 scrPtr
->checkButtonImageOff
= makePixmap(scrPtr
, CHECK_BUTTON_OFF
,
785 CHECK_BUTTON_OFF_WIDTH
, CHECK_BUTTON_OFF_HEIGHT
, False
);
787 scrPtr
->radioButtonImageOn
= makePixmap(scrPtr
, RADIO_BUTTON_ON
,
788 RADIO_BUTTON_ON_WIDTH
, RADIO_BUTTON_ON_HEIGHT
, False
);
790 scrPtr
->radioButtonImageOff
= makePixmap(scrPtr
, RADIO_BUTTON_OFF
,
791 RADIO_BUTTON_OFF_WIDTH
, RADIO_BUTTON_OFF_HEIGHT
, False
);
793 scrPtr
->tristateButtonImageOn
= makePixmap(scrPtr
, TRISTATE_BUTTON_ON
,
794 TRISTATE_BUTTON_ON_WIDTH
, TRISTATE_BUTTON_ON_HEIGHT
, False
);
796 scrPtr
->tristateButtonImageOff
= makePixmap(scrPtr
, TRISTATE_BUTTON_OFF
,
797 TRISTATE_BUTTON_OFF_WIDTH
, TRISTATE_BUTTON_OFF_HEIGHT
, False
);
799 scrPtr
->tristateButtonImageTri
= makePixmap(scrPtr
, TRISTATE_BUTTON_TRI
,
800 TRISTATE_BUTTON_TRI_WIDTH
, TRISTATE_BUTTON_TRI_HEIGHT
, False
);
802 scrPtr
->buttonArrow
= makePixmap(scrPtr
, BUTTON_ARROW
, BUTTON_ARROW_WIDTH
, BUTTON_ARROW_HEIGHT
, False
);
804 scrPtr
->pushedButtonArrow
= makePixmap(scrPtr
, BUTTON_ARROW2
,
805 BUTTON_ARROW2_WIDTH
, BUTTON_ARROW2_HEIGHT
, False
);
807 scrPtr
->scrollerDimple
= makePixmap(scrPtr
, SCROLLER_DIMPLE
,
808 SCROLLER_DIMPLE_WIDTH
, SCROLLER_DIMPLE_HEIGHT
, False
);
810 scrPtr
->upArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_UP
,
811 SCROLLER_ARROW_UP_WIDTH
, SCROLLER_ARROW_UP_HEIGHT
, True
);
813 scrPtr
->downArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_DOWN
,
814 SCROLLER_ARROW_DOWN_WIDTH
, SCROLLER_ARROW_DOWN_HEIGHT
, True
);
816 scrPtr
->leftArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_LEFT
,
817 SCROLLER_ARROW_LEFT_WIDTH
, SCROLLER_ARROW_LEFT_HEIGHT
, True
);
819 scrPtr
->rightArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_RIGHT
,
820 SCROLLER_ARROW_RIGHT_WIDTH
, SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
822 scrPtr
->hiUpArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_UP
,
823 SCROLLER_ARROW_UP_WIDTH
, SCROLLER_ARROW_UP_HEIGHT
, True
);
825 scrPtr
->hiDownArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_DOWN
,
826 SCROLLER_ARROW_DOWN_WIDTH
, SCROLLER_ARROW_DOWN_HEIGHT
, True
);
828 scrPtr
->hiLeftArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_LEFT
,
829 SCROLLER_ARROW_LEFT_WIDTH
, SCROLLER_ARROW_LEFT_HEIGHT
, True
);
831 scrPtr
->hiRightArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_RIGHT
,
832 SCROLLER_ARROW_RIGHT_WIDTH
, SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
834 scrPtr
->popUpIndicator
= makePixmap(scrPtr
, POPUP_INDICATOR
,
835 POPUP_INDICATOR_WIDTH
, POPUP_INDICATOR_HEIGHT
, True
);
837 scrPtr
->pullDownIndicator
= makePixmap(scrPtr
, PULLDOWN_INDICATOR
,
838 PULLDOWN_INDICATOR_WIDTH
, PULLDOWN_INDICATOR_HEIGHT
, True
);
840 scrPtr
->checkMark
= makePixmap(scrPtr
, CHECK_MARK
, CHECK_MARK_WIDTH
, CHECK_MARK_HEIGHT
, True
);
844 scrPtr
->defaultCursor
= XCreateFontCursor(display
, XC_left_ptr
);
846 scrPtr
->textCursor
= XCreateFontCursor(display
, XC_xterm
);
852 blank
= XCreatePixmap(display
, scrPtr
->stipple
, 1, 1, 1);
853 XSetForeground(display
, scrPtr
->monoGC
, 0);
854 XFillRectangle(display
, blank
, scrPtr
->monoGC
, 0, 0, 1, 1);
856 scrPtr
->invisibleCursor
= XCreatePixmapCursor(display
, blank
, blank
, &bla
, &bla
, 0, 0);
857 XFreePixmap(display
, blank
);
860 #ifdef HAVE_XINTERNATOMS
861 XInternAtoms(display
, atomNames
, wlengthof(atomNames
), False
, atoms
);
863 for (i
= 0; i
< wlengthof(atomNames
); i
++) {
864 atoms
[i
] = XInternAtom(display
, atomNames
[i
], False
);
869 scrPtr
->attribsAtom
= atoms
[i
++];
871 scrPtr
->deleteWindowAtom
= atoms
[i
++];
873 scrPtr
->protocolsAtom
= atoms
[i
++];
875 scrPtr
->clipboardAtom
= atoms
[i
++];
877 scrPtr
->xdndAwareAtom
= atoms
[i
++];
878 scrPtr
->xdndSelectionAtom
= atoms
[i
++];
879 scrPtr
->xdndEnterAtom
= atoms
[i
++];
880 scrPtr
->xdndLeaveAtom
= atoms
[i
++];
881 scrPtr
->xdndPositionAtom
= atoms
[i
++];
882 scrPtr
->xdndDropAtom
= atoms
[i
++];
883 scrPtr
->xdndFinishedAtom
= atoms
[i
++];
884 scrPtr
->xdndTypeListAtom
= atoms
[i
++];
885 scrPtr
->xdndActionListAtom
= atoms
[i
++];
886 scrPtr
->xdndActionDescriptionAtom
= atoms
[i
++];
887 scrPtr
->xdndStatusAtom
= atoms
[i
++];
889 scrPtr
->xdndActionCopy
= atoms
[i
++];
890 scrPtr
->xdndActionMove
= atoms
[i
++];
891 scrPtr
->xdndActionLink
= atoms
[i
++];
892 scrPtr
->xdndActionAsk
= atoms
[i
++];
893 scrPtr
->xdndActionPrivate
= atoms
[i
++];
895 scrPtr
->wmIconDragOffsetAtom
= atoms
[i
++];
897 scrPtr
->wmStateAtom
= atoms
[i
++];
899 scrPtr
->utf8String
= atoms
[i
++];
900 scrPtr
->netwmName
= atoms
[i
++];
901 scrPtr
->netwmIconName
= atoms
[i
++];
902 scrPtr
->netwmIcon
= atoms
[i
++];
904 scrPtr
->rootView
= W_CreateRootView(scrPtr
);
906 scrPtr
->balloon
= W_CreateBalloon(scrPtr
);
908 W_InitApplication(scrPtr
);
913 void WMSetWidgetDefaultFont(WMScreen
* scr
, WMFont
* font
)
915 WMReleaseFont(scr
->normalFont
);
916 scr
->normalFont
= WMRetainFont(font
);
919 void WMSetWidgetDefaultBoldFont(WMScreen
* scr
, WMFont
* font
)
921 WMReleaseFont(scr
->boldFont
);
922 scr
->boldFont
= WMRetainFont(font
);
925 void WMHangData(WMWidget
* widget
, void *data
)
927 W_VIEW(widget
)->hangedData
= data
;
930 void *WMGetHangedData(WMWidget
* widget
)
932 return W_VIEW(widget
)->hangedData
;
935 void WMDestroyWidget(WMWidget
* widget
)
937 W_UnmapView(W_VIEW(widget
));
938 W_DestroyView(W_VIEW(widget
));
941 void WMSetFocusToWidget(WMWidget
* widget
)
943 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget
)), W_VIEW(widget
));
948 * Realizes the widget and all it's children.
951 void WMRealizeWidget(WMWidget
* w
)
953 W_RealizeView(W_VIEW(w
));
956 void WMMapWidget(WMWidget
* w
)
958 W_MapView(W_VIEW(w
));
961 void WMReparentWidget(WMWidget
* w
, WMWidget
* newParent
, int x
, int y
)
963 W_ReparentView(W_VIEW(w
), W_VIEW(newParent
), x
, y
);
966 static void makeChildrenAutomap(W_View
* view
, int flag
)
968 view
= view
->childrenList
;
971 view
->flags
.mapWhenRealized
= flag
;
972 makeChildrenAutomap(view
, flag
);
974 view
= view
->nextSister
;
978 void WMMapSubwidgets(WMWidget
* w
)
980 /* make sure that subwidgets created after the parent was realized
982 if (!W_VIEW(w
)->flags
.realized
) {
983 makeChildrenAutomap(W_VIEW(w
), True
);
985 W_MapSubviews(W_VIEW(w
));
989 void WMUnmapSubwidgets(WMWidget
* w
)
991 if (!W_VIEW(w
)->flags
.realized
) {
992 makeChildrenAutomap(W_VIEW(w
), False
);
994 W_UnmapSubviews(W_VIEW(w
));
998 void WMUnmapWidget(WMWidget
* w
)
1000 W_UnmapView(W_VIEW(w
));
1003 Bool
WMWidgetIsMapped(WMWidget
* w
)
1005 return W_VIEW(w
)->flags
.mapped
;
1008 void WMSetWidgetBackgroundColor(WMWidget
* w
, WMColor
* color
)
1010 W_SetViewBackgroundColor(W_VIEW(w
), color
);
1011 if (W_VIEW(w
)->flags
.mapped
)
1012 WMRedisplayWidget(w
);
1015 WMColor
*WMGetWidgetBackgroundColor(WMWidget
* w
)
1017 return W_VIEW(w
)->backColor
;
1020 void WMSetWidgetBackgroundPixmap(WMWidget
*w
, WMPixmap
*pix
)
1025 W_SetViewBackgroundPixmap(W_VIEW(w
), pix
);
1026 if (W_VIEW(w
)->flags
.mapped
)
1027 WMRedisplayWidget(w
);
1030 WMPixmap
*WMGetWidgetBackgroundPixmap(WMWidget
*w
)
1032 return W_VIEW(w
)->backImage
;
1035 void WMRaiseWidget(WMWidget
* w
)
1037 W_RaiseView(W_VIEW(w
));
1040 void WMLowerWidget(WMWidget
* w
)
1042 W_LowerView(W_VIEW(w
));
1045 void WMMoveWidget(WMWidget
* w
, int x
, int y
)
1047 W_MoveView(W_VIEW(w
), x
, y
);
1050 void WMResizeWidget(WMWidget
* w
, unsigned int width
, unsigned int height
)
1052 W_ResizeView(W_VIEW(w
), width
, height
);
1055 W_Class
W_RegisterUserWidget(void)
1059 return userWidgetCount
+ WC_UserWidget
- 1;
1062 RContext
*WMScreenRContext(WMScreen
* scr
)
1064 return scr
->rcontext
;
1067 unsigned int WMWidgetWidth(WMWidget
* w
)
1069 return W_VIEW(w
)->size
.width
;
1072 unsigned int WMWidgetHeight(WMWidget
* w
)
1074 return W_VIEW(w
)->size
.height
;
1077 Window
WMWidgetXID(WMWidget
* w
)
1079 return W_VIEW(w
)->window
;
1082 WMScreen
*WMWidgetScreen(WMWidget
* w
)
1084 return W_VIEW(w
)->screen
;
1087 void WMScreenMainLoop(WMScreen
* scr
)
1092 WMNextEvent(scr
->display
, &event
);
1093 WMHandleEvent(&event
);
1097 void WMBreakModalLoop(WMScreen
* scr
)
1102 void WMRunModalLoop(WMScreen
* scr
, WMView
* view
)
1104 /* why is scr passed if is determined from the view? */
1105 /*WMScreen *scr = view->screen; */
1106 int oldModalLoop
= scr
->modalLoop
;
1107 WMView
*oldModalView
= scr
->modalView
;
1109 scr
->modalView
= view
;
1112 while (scr
->modalLoop
) {
1115 WMNextEvent(scr
->display
, &event
);
1116 WMHandleEvent(&event
);
1119 scr
->modalView
= oldModalView
;
1120 scr
->modalLoop
= oldModalLoop
;
1123 Display
*WMScreenDisplay(WMScreen
* scr
)
1125 return scr
->display
;
1128 int WMScreenDepth(WMScreen
* scr
)
1133 unsigned int WMScreenWidth(WMScreen
* scr
)
1135 return scr
->rootView
->size
.width
;
1138 unsigned int WMScreenHeight(WMScreen
* scr
)
1140 return scr
->rootView
->size
.height
;
1143 void WMRedisplayWidget(WMWidget
* w
)
1145 W_RedisplayView(W_VIEW(w
));