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 static char *BUTTON_ARROW
[] = {
101 "..................",
102 "....##....#### ...",
103 "...#.%....#... ...",
104 "..#..%#####... ...",
105 ".#............ ...",
106 "#............. ...",
107 ".#............ ...",
109 "...#. ............",
113 #define BUTTON_ARROW_WIDTH 18
114 #define BUTTON_ARROW_HEIGHT 10
116 static char *BUTTON_ARROW2
[] = {
129 #define BUTTON_ARROW2_WIDTH 18
130 #define BUTTON_ARROW2_HEIGHT 10
132 static char *SCROLLER_DIMPLE
[] = {
141 #define SCROLLER_DIMPLE_WIDTH 6
142 #define SCROLLER_DIMPLE_HEIGHT 6
144 static char *SCROLLER_ARROW_UP
[] = {
156 static char *HI_SCROLLER_ARROW_UP
[] = {
168 #define SCROLLER_ARROW_UP_WIDTH 9
169 #define SCROLLER_ARROW_UP_HEIGHT 9
171 static char *SCROLLER_ARROW_DOWN
[] = {
183 static char *HI_SCROLLER_ARROW_DOWN
[] = {
195 #define SCROLLER_ARROW_DOWN_WIDTH 9
196 #define SCROLLER_ARROW_DOWN_HEIGHT 9
198 static char *SCROLLER_ARROW_LEFT
[] = {
210 static char *HI_SCROLLER_ARROW_LEFT
[] = {
222 #define SCROLLER_ARROW_LEFT_WIDTH 9
223 #define SCROLLER_ARROW_LEFT_HEIGHT 9
225 static char *SCROLLER_ARROW_RIGHT
[] = {
237 static char *HI_SCROLLER_ARROW_RIGHT
[] = {
249 #define SCROLLER_ARROW_RIGHT_WIDTH 9
250 #define SCROLLER_ARROW_RIGHT_HEIGHT 9
252 static char *POPUP_INDICATOR
[] = {
263 #define POPUP_INDICATOR_WIDTH 11
264 #define POPUP_INDICATOR_HEIGHT 8
266 static char *PULLDOWN_INDICATOR
[] = {
276 #define PULLDOWN_INDICATOR_WIDTH 9
277 #define PULLDOWN_INDICATOR_HEIGHT 7
279 #define CHECK_MARK_WIDTH 8
280 #define CHECK_MARK_HEIGHT 10
282 static char *CHECK_MARK
[] = {
295 #define STIPPLE_WIDTH 8
296 #define STIPPLE_HEIGHT 8
297 static char STIPPLE_BITS
[] = {
298 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55
301 static int userWidgetCount
= 0;
303 /***** end data ******/
305 static void renderPixmap(W_Screen
* screen
, Pixmap d
, Pixmap mask
, char **data
, int width
, int height
)
308 GC whiteGC
= WMColorGC(screen
->white
);
309 GC blackGC
= WMColorGC(screen
->black
);
310 GC lightGC
= WMColorGC(screen
->gray
);
311 GC darkGC
= WMColorGC(screen
->darkGray
);
314 XSetForeground(screen
->display
, screen
->monoGC
, 0);
316 for (y
= 0; y
< height
; y
++) {
317 for (x
= 0; x
< width
; x
++) {
318 switch (data
[y
][x
]) {
321 XDrawPoint(screen
->display
, d
, whiteGC
, x
, y
);
326 XDrawPoint(screen
->display
, mask
, screen
->monoGC
, x
, y
);
330 XDrawPoint(screen
->display
, d
, lightGC
, x
, y
);
335 XDrawPoint(screen
->display
, d
, darkGC
, x
, y
);
341 XDrawPoint(screen
->display
, d
, blackGC
, x
, y
);
348 static WMPixmap
*makePixmap(W_Screen
* sPtr
, char **data
, int width
, int height
, int masked
)
350 Pixmap pixmap
, mask
= None
;
352 pixmap
= XCreatePixmap(sPtr
->display
, W_DRAWABLE(sPtr
), width
, height
, sPtr
->depth
);
355 mask
= XCreatePixmap(sPtr
->display
, W_DRAWABLE(sPtr
), width
, height
, 1);
356 XSetForeground(sPtr
->display
, sPtr
->monoGC
, 1);
357 XFillRectangle(sPtr
->display
, mask
, sPtr
->monoGC
, 0, 0, width
, height
);
360 renderPixmap(sPtr
, pixmap
, mask
, data
, width
, height
);
362 return WMCreatePixmapFromXPixmaps(sPtr
, pixmap
, mask
, width
, height
, sPtr
->depth
);
365 #define T_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.tiff"
366 #define T_DEFAULT_OBJECT_ICON_FILE RESOURCE_PATH"/defaultIcon.tiff"
368 #define X_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.xpm"
369 #define X_DEFAULT_OBJECT_ICON_FILE RESOURCE_PATH"/defaultIcon.xpm"
371 static Bool
loadPixmaps(WMScreen
* scr
)
385 image
= RLoadImage(scr
->rcontext
, T_WINGS_IMAGES_FILE
, 0);
387 image
= RLoadImage(scr
->rcontext
, X_WINGS_IMAGES_FILE
, 0);
389 wwarning(_("WINGs: could not load widget images file: %s"), RMessageForError(RErrorCode
));
393 /* make it have a gray background */
394 tmp
= RGetSubImage(image
, 0, 0, 24, 24);
395 RCombineImageWithColor(tmp
, &gray
);
396 scr
->homeIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
398 /* make it have a white background */
399 tmp
= RGetSubImage(image
, 0, 0, 24, 24);
400 RCombineImageWithColor(tmp
, &white
);
401 scr
->altHomeIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
405 tmp
= RGetSubImage(image
, 104, 0, 24, 24);
406 RCombineImageWithColor(tmp
, &white
);
407 scr
->trashcanIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
409 tmp
= RGetSubImage(image
, 104, 0, 24, 24);
410 RCombineImageWithColor(tmp
, &white
);
411 scr
->altTrashcanIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
414 tmp
= RGetSubImage(image
, 104, 24, 24, 24);
415 RCombineImageWithColor(tmp
, &white
);
416 scr
->createDirIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
418 tmp
= RGetSubImage(image
, 104, 24, 24, 24);
419 RCombineImageWithColor(tmp
, &white
);
420 scr
->altCreateDirIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
423 tmp
= RGetSubImage(image
, 24, 80, 24, 24);
424 RCombineImageWithColor(tmp
, &white
);
425 scr
->disketteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
427 tmp
= RGetSubImage(image
, 24, 80, 24, 24);
428 RCombineImageWithColor(tmp
, &white
);
429 scr
->altDisketteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
432 tmp
= RGetSubImage(image
, 0, 80, 24, 24);
433 RCombineImageWithColor(tmp
, &white
);
434 scr
->unmountIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
436 tmp
= RGetSubImage(image
, 0, 80, 24, 24);
437 RCombineImageWithColor(tmp
, &white
);
438 scr
->altUnmountIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
441 /* Magnifying Glass Icon for ColorPanel */
442 tmp
= RGetSubImage(image
, 24, 0, 40, 32);
443 RCombineImageWithColor(tmp
, &gray
);
444 scr
->magnifyIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
446 /* ColorWheel Icon for ColorPanel */
447 tmp
= RGetSubImage(image
, 0, 25, 24, 24);
448 scr
->wheelIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
450 /* GrayScale Icon for ColorPanel */
451 tmp
= RGetSubImage(image
, 65, 0, 40, 24);
452 scr
->grayIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
454 /* RGB Icon for ColorPanel */
455 tmp
= RGetSubImage(image
, 25, 33, 40, 24);
456 scr
->rgbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
458 /* CMYK Icon for ColorPanel */
459 tmp
= RGetSubImage(image
, 65, 25, 40, 24);
460 scr
->cmykIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
462 /* HSB Icon for ColorPanel */
463 tmp
= RGetSubImage(image
, 0, 57, 40, 24);
464 scr
->hsbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
466 /* CustomColorPalette Icon for ColorPanel */
467 tmp
= RGetSubImage(image
, 81, 57, 40, 24);
468 scr
->customPaletteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
470 /* ColorList Icon for ColorPanel */
471 tmp
= RGetSubImage(image
, 41, 57, 40, 24);
472 scr
->colorListIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
475 RReleaseImage(image
);
478 scr
->defaultObjectIcon
= WMCreatePixmapFromFile(scr
, T_DEFAULT_OBJECT_ICON_FILE
);
479 if (!scr
->defaultObjectIcon
) {
480 scr
->defaultObjectIcon
= WMCreatePixmapFromFile(scr
, X_DEFAULT_OBJECT_ICON_FILE
);
482 if (!scr
->defaultObjectIcon
) {
483 wwarning("WINGs: could not load default icon file");
490 WMScreen
*WMOpenScreen(const char *display
)
492 Display
*dpy
= XOpenDisplay(display
);
495 wwarning("WINGs: could not open display %s", XDisplayName(display
));
499 return WMCreateSimpleApplicationScreen(dpy
);
502 WMScreen
*WMCreateSimpleApplicationScreen(Display
* display
)
506 scr
= WMCreateScreen(display
, DefaultScreen(display
));
508 scr
->aflags
.hasAppIcon
= 0;
509 scr
->aflags
.simpleApplication
= 1;
514 WMScreen
*WMCreateScreen(Display
* display
, int screen
)
516 return WMCreateScreenWithRContext(display
, screen
, RCreateContext(display
, screen
, NULL
));
519 WMScreen
*WMCreateScreenWithRContext(Display
* display
, int screen
, RContext
* context
)
524 static int initialized
= 0;
525 static char *atomNames
[] = {
539 "XdndActionDescription",
546 "_WINGS_DND_MOUSE_OFFSET",
553 Atom atoms
[wlengthof(atomNames
)];
560 W_ReadConfigurations();
562 assert(W_ApplicationInitialized());
565 scrPtr
= malloc(sizeof(W_Screen
));
568 memset(scrPtr
, 0, sizeof(W_Screen
));
570 scrPtr
->aflags
.hasAppIcon
= 1;
572 scrPtr
->display
= display
;
573 scrPtr
->screen
= screen
;
574 scrPtr
->rcontext
= context
;
576 scrPtr
->depth
= context
->depth
;
578 scrPtr
->visual
= context
->visual
;
579 scrPtr
->lastEventTime
= 0;
581 scrPtr
->colormap
= context
->cmap
;
583 scrPtr
->rootWin
= RootWindow(display
, screen
);
585 scrPtr
->fontCache
= WMCreateHashTable(WMStringPointerHashCallbacks
);
587 scrPtr
->xftdraw
= XftDrawCreate(scrPtr
->display
, W_DRAWABLE(scrPtr
), scrPtr
->visual
, scrPtr
->colormap
);
589 /* Create missing CUT_BUFFERs */
592 int exists
[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
595 rootWinProps
= XListProperties(display
, scrPtr
->rootWin
, &count
);
596 for (i
= 0; i
< count
; i
++) {
597 switch (rootWinProps
[i
]) {
629 for (i
= 0; i
< 8; i
++) {
631 XStoreBuffer(display
, "", 0, i
);
636 scrPtr
->ignoredModifierMask
= 0;
639 XModifierKeymap
*modmap
;
640 KeyCode nlock
, slock
;
641 static int mask_table
[8] = {
642 ShiftMask
, LockMask
, ControlMask
, Mod1Mask
,
643 Mod2Mask
, Mod3Mask
, Mod4Mask
, Mod5Mask
645 unsigned int numLockMask
= 0, scrollLockMask
= 0;
647 nlock
= XKeysymToKeycode(display
, XK_Num_Lock
);
648 slock
= XKeysymToKeycode(display
, XK_Scroll_Lock
);
651 * Find out the masks for the NumLock and ScrollLock modifiers,
652 * so that we can bind the grabs for when they are enabled too.
654 modmap
= XGetModifierMapping(display
);
656 if (modmap
!= NULL
&& modmap
->max_keypermod
> 0) {
657 for (i
= 0; i
< 8 * modmap
->max_keypermod
; i
++) {
658 if (modmap
->modifiermap
[i
] == nlock
&& nlock
!= 0)
659 numLockMask
= mask_table
[i
/ modmap
->max_keypermod
];
660 else if (modmap
->modifiermap
[i
] == slock
&& slock
!= 0)
661 scrollLockMask
= mask_table
[i
/ modmap
->max_keypermod
];
666 XFreeModifiermap(modmap
);
668 scrPtr
->ignoredModifierMask
= numLockMask
| scrollLockMask
| LockMask
;
671 /* initially allocate some colors */
672 WMWhiteColor(scrPtr
);
673 WMBlackColor(scrPtr
);
675 WMDarkGrayColor(scrPtr
);
677 gcv
.graphics_exposures
= False
;
679 gcv
.function
= GXxor
;
680 gcv
.foreground
= W_PIXEL(scrPtr
->white
);
681 if (gcv
.foreground
== 0)
683 scrPtr
->xorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
684 | GCGraphicsExposures
| GCForeground
, &gcv
);
686 gcv
.function
= GXxor
;
687 gcv
.foreground
= W_PIXEL(scrPtr
->gray
);
688 gcv
.subwindow_mode
= IncludeInferiors
;
689 scrPtr
->ixorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
690 | GCGraphicsExposures
| GCForeground
| GCSubwindowMode
, &gcv
);
692 gcv
.function
= GXcopy
;
693 scrPtr
->copyGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
| GCGraphicsExposures
, &gcv
);
695 scrPtr
->clipGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
| GCGraphicsExposures
, &gcv
);
697 stipple
= XCreateBitmapFromData(display
, W_DRAWABLE(scrPtr
), STIPPLE_BITS
, STIPPLE_WIDTH
, STIPPLE_HEIGHT
);
698 gcv
.foreground
= W_PIXEL(scrPtr
->darkGray
);
699 gcv
.background
= W_PIXEL(scrPtr
->gray
);
700 gcv
.fill_style
= FillStippled
;
701 gcv
.stipple
= stipple
;
702 scrPtr
->stippleGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
),
703 GCForeground
| GCBackground
| GCStipple
704 | GCFillStyle
| GCGraphicsExposures
, &gcv
);
706 scrPtr
->drawStringGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCGraphicsExposures
, &gcv
);
707 scrPtr
->drawImStringGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCGraphicsExposures
, &gcv
);
709 /* we need a 1bpp drawable for the monoGC, so borrow this one */
710 scrPtr
->monoGC
= XCreateGC(display
, stipple
, 0, NULL
);
712 scrPtr
->stipple
= stipple
;
714 scrPtr
->antialiasedText
= WINGsConfiguration
.antialiasedText
;
716 scrPtr
->normalFont
= WMSystemFontOfSize(scrPtr
, 0);
718 scrPtr
->boldFont
= WMBoldSystemFontOfSize(scrPtr
, 0);
720 if (!scrPtr
->boldFont
)
721 scrPtr
->boldFont
= scrPtr
->normalFont
;
723 if (!scrPtr
->normalFont
) {
724 wwarning(_("could not load any fonts. Make sure your font installation"
725 " and locale settings are correct."));
730 /* create input method stuff */
733 scrPtr
->checkButtonImageOn
= makePixmap(scrPtr
, CHECK_BUTTON_ON
,
734 CHECK_BUTTON_ON_WIDTH
, CHECK_BUTTON_ON_HEIGHT
, False
);
736 scrPtr
->checkButtonImageOff
= makePixmap(scrPtr
, CHECK_BUTTON_OFF
,
737 CHECK_BUTTON_OFF_WIDTH
, CHECK_BUTTON_OFF_HEIGHT
, False
);
739 scrPtr
->radioButtonImageOn
= makePixmap(scrPtr
, RADIO_BUTTON_ON
,
740 RADIO_BUTTON_ON_WIDTH
, RADIO_BUTTON_ON_HEIGHT
, False
);
742 scrPtr
->radioButtonImageOff
= makePixmap(scrPtr
, RADIO_BUTTON_OFF
,
743 RADIO_BUTTON_OFF_WIDTH
, RADIO_BUTTON_OFF_HEIGHT
, False
);
745 scrPtr
->buttonArrow
= makePixmap(scrPtr
, BUTTON_ARROW
, BUTTON_ARROW_WIDTH
, BUTTON_ARROW_HEIGHT
, False
);
747 scrPtr
->pushedButtonArrow
= makePixmap(scrPtr
, BUTTON_ARROW2
,
748 BUTTON_ARROW2_WIDTH
, BUTTON_ARROW2_HEIGHT
, False
);
750 scrPtr
->scrollerDimple
= makePixmap(scrPtr
, SCROLLER_DIMPLE
,
751 SCROLLER_DIMPLE_WIDTH
, SCROLLER_DIMPLE_HEIGHT
, False
);
753 scrPtr
->upArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_UP
,
754 SCROLLER_ARROW_UP_WIDTH
, SCROLLER_ARROW_UP_HEIGHT
, True
);
756 scrPtr
->downArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_DOWN
,
757 SCROLLER_ARROW_DOWN_WIDTH
, SCROLLER_ARROW_DOWN_HEIGHT
, True
);
759 scrPtr
->leftArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_LEFT
,
760 SCROLLER_ARROW_LEFT_WIDTH
, SCROLLER_ARROW_LEFT_HEIGHT
, True
);
762 scrPtr
->rightArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_RIGHT
,
763 SCROLLER_ARROW_RIGHT_WIDTH
, SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
765 scrPtr
->hiUpArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_UP
,
766 SCROLLER_ARROW_UP_WIDTH
, SCROLLER_ARROW_UP_HEIGHT
, True
);
768 scrPtr
->hiDownArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_DOWN
,
769 SCROLLER_ARROW_DOWN_WIDTH
, SCROLLER_ARROW_DOWN_HEIGHT
, True
);
771 scrPtr
->hiLeftArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_LEFT
,
772 SCROLLER_ARROW_LEFT_WIDTH
, SCROLLER_ARROW_LEFT_HEIGHT
, True
);
774 scrPtr
->hiRightArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_RIGHT
,
775 SCROLLER_ARROW_RIGHT_WIDTH
, SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
777 scrPtr
->popUpIndicator
= makePixmap(scrPtr
, POPUP_INDICATOR
,
778 POPUP_INDICATOR_WIDTH
, POPUP_INDICATOR_HEIGHT
, True
);
780 scrPtr
->pullDownIndicator
= makePixmap(scrPtr
, PULLDOWN_INDICATOR
,
781 PULLDOWN_INDICATOR_WIDTH
, PULLDOWN_INDICATOR_HEIGHT
, True
);
783 scrPtr
->checkMark
= makePixmap(scrPtr
, CHECK_MARK
, CHECK_MARK_WIDTH
, CHECK_MARK_HEIGHT
, True
);
787 scrPtr
->defaultCursor
= XCreateFontCursor(display
, XC_left_ptr
);
789 scrPtr
->textCursor
= XCreateFontCursor(display
, XC_xterm
);
795 blank
= XCreatePixmap(display
, scrPtr
->stipple
, 1, 1, 1);
796 XSetForeground(display
, scrPtr
->monoGC
, 0);
797 XFillRectangle(display
, blank
, scrPtr
->monoGC
, 0, 0, 1, 1);
799 scrPtr
->invisibleCursor
= XCreatePixmapCursor(display
, blank
, blank
, &bla
, &bla
, 0, 0);
800 XFreePixmap(display
, blank
);
803 #ifdef HAVE_XINTERNATOMS
804 XInternAtoms(display
, atomNames
, wlengthof(atomNames
), False
, atoms
);
806 for (i
= 0; i
< wlengthof(atomNames
); i
++) {
807 atoms
[i
] = XInternAtom(display
, atomNames
[i
], False
);
812 scrPtr
->attribsAtom
= atoms
[i
++];
814 scrPtr
->deleteWindowAtom
= atoms
[i
++];
816 scrPtr
->protocolsAtom
= atoms
[i
++];
818 scrPtr
->clipboardAtom
= atoms
[i
++];
820 scrPtr
->xdndAwareAtom
= atoms
[i
++];
821 scrPtr
->xdndSelectionAtom
= atoms
[i
++];
822 scrPtr
->xdndEnterAtom
= atoms
[i
++];
823 scrPtr
->xdndLeaveAtom
= atoms
[i
++];
824 scrPtr
->xdndPositionAtom
= atoms
[i
++];
825 scrPtr
->xdndDropAtom
= atoms
[i
++];
826 scrPtr
->xdndFinishedAtom
= atoms
[i
++];
827 scrPtr
->xdndTypeListAtom
= atoms
[i
++];
828 scrPtr
->xdndActionListAtom
= atoms
[i
++];
829 scrPtr
->xdndActionDescriptionAtom
= atoms
[i
++];
830 scrPtr
->xdndStatusAtom
= atoms
[i
++];
832 scrPtr
->xdndActionCopy
= atoms
[i
++];
833 scrPtr
->xdndActionMove
= atoms
[i
++];
834 scrPtr
->xdndActionLink
= atoms
[i
++];
835 scrPtr
->xdndActionAsk
= atoms
[i
++];
836 scrPtr
->xdndActionPrivate
= atoms
[i
++];
838 scrPtr
->wmIconDragOffsetAtom
= atoms
[i
++];
840 scrPtr
->wmStateAtom
= atoms
[i
++];
842 scrPtr
->utf8String
= atoms
[i
++];
843 scrPtr
->netwmName
= atoms
[i
++];
844 scrPtr
->netwmIconName
= atoms
[i
++];
845 scrPtr
->netwmIcon
= atoms
[i
++];
847 scrPtr
->rootView
= W_CreateRootView(scrPtr
);
849 scrPtr
->balloon
= W_CreateBalloon(scrPtr
);
851 W_InitApplication(scrPtr
);
856 void WMSetWidgetDefaultFont(WMScreen
* scr
, WMFont
* font
)
858 WMReleaseFont(scr
->normalFont
);
859 scr
->normalFont
= WMRetainFont(font
);
862 void WMSetWidgetDefaultBoldFont(WMScreen
* scr
, WMFont
* font
)
864 WMReleaseFont(scr
->boldFont
);
865 scr
->boldFont
= WMRetainFont(font
);
868 void WMHangData(WMWidget
* widget
, void *data
)
870 W_VIEW(widget
)->hangedData
= data
;
873 void *WMGetHangedData(WMWidget
* widget
)
875 return W_VIEW(widget
)->hangedData
;
878 void WMDestroyWidget(WMWidget
* widget
)
880 W_UnmapView(W_VIEW(widget
));
881 W_DestroyView(W_VIEW(widget
));
884 void WMSetFocusToWidget(WMWidget
* widget
)
886 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget
)), W_VIEW(widget
));
891 * Realizes the widget and all it's children.
894 void WMRealizeWidget(WMWidget
* w
)
896 W_RealizeView(W_VIEW(w
));
899 void WMMapWidget(WMWidget
* w
)
901 W_MapView(W_VIEW(w
));
904 void WMReparentWidget(WMWidget
* w
, WMWidget
* newParent
, int x
, int y
)
906 W_ReparentView(W_VIEW(w
), W_VIEW(newParent
), x
, y
);
909 static void makeChildrenAutomap(W_View
* view
, int flag
)
911 view
= view
->childrenList
;
914 view
->flags
.mapWhenRealized
= flag
;
915 makeChildrenAutomap(view
, flag
);
917 view
= view
->nextSister
;
921 void WMMapSubwidgets(WMWidget
* w
)
923 /* make sure that subwidgets created after the parent was realized
925 if (!W_VIEW(w
)->flags
.realized
) {
926 makeChildrenAutomap(W_VIEW(w
), True
);
928 W_MapSubviews(W_VIEW(w
));
932 void WMUnmapSubwidgets(WMWidget
* w
)
934 if (!W_VIEW(w
)->flags
.realized
) {
935 makeChildrenAutomap(W_VIEW(w
), False
);
937 W_UnmapSubviews(W_VIEW(w
));
941 void WMUnmapWidget(WMWidget
* w
)
943 W_UnmapView(W_VIEW(w
));
946 Bool
WMWidgetIsMapped(WMWidget
* w
)
948 return W_VIEW(w
)->flags
.mapped
;
951 void WMSetWidgetBackgroundColor(WMWidget
* w
, WMColor
* color
)
953 W_SetViewBackgroundColor(W_VIEW(w
), color
);
954 if (W_VIEW(w
)->flags
.mapped
)
955 WMRedisplayWidget(w
);
958 WMColor
*WMGetWidgetBackgroundColor(WMWidget
* w
)
960 return W_VIEW(w
)->backColor
;
963 void WMRaiseWidget(WMWidget
* w
)
965 W_RaiseView(W_VIEW(w
));
968 void WMLowerWidget(WMWidget
* w
)
970 W_LowerView(W_VIEW(w
));
973 void WMMoveWidget(WMWidget
* w
, int x
, int y
)
975 W_MoveView(W_VIEW(w
), x
, y
);
978 void WMResizeWidget(WMWidget
* w
, unsigned int width
, unsigned int height
)
980 W_ResizeView(W_VIEW(w
), width
, height
);
983 W_Class
W_RegisterUserWidget(void)
987 return userWidgetCount
+ WC_UserWidget
- 1;
990 RContext
*WMScreenRContext(WMScreen
* scr
)
992 return scr
->rcontext
;
995 unsigned int WMWidgetWidth(WMWidget
* w
)
997 return W_VIEW(w
)->size
.width
;
1000 unsigned int WMWidgetHeight(WMWidget
* w
)
1002 return W_VIEW(w
)->size
.height
;
1005 Window
WMWidgetXID(WMWidget
* w
)
1007 return W_VIEW(w
)->window
;
1010 WMScreen
*WMWidgetScreen(WMWidget
* w
)
1012 return W_VIEW(w
)->screen
;
1015 void WMScreenMainLoop(WMScreen
* scr
)
1020 WMNextEvent(scr
->display
, &event
);
1021 WMHandleEvent(&event
);
1025 void WMBreakModalLoop(WMScreen
* scr
)
1030 void WMRunModalLoop(WMScreen
* scr
, WMView
* view
)
1032 /* why is scr passed if is determined from the view? */
1033 /*WMScreen *scr = view->screen; */
1034 int oldModalLoop
= scr
->modalLoop
;
1035 WMView
*oldModalView
= scr
->modalView
;
1037 scr
->modalView
= view
;
1040 while (scr
->modalLoop
) {
1043 WMNextEvent(scr
->display
, &event
);
1044 WMHandleEvent(&event
);
1047 scr
->modalView
= oldModalView
;
1048 scr
->modalLoop
= oldModalLoop
;
1051 Display
*WMScreenDisplay(WMScreen
* scr
)
1053 return scr
->display
;
1056 int WMScreenDepth(WMScreen
* scr
)
1061 unsigned int WMScreenWidth(WMScreen
* scr
)
1063 return scr
->rootView
->size
.width
;
1066 unsigned int WMScreenHeight(WMScreen
* scr
)
1068 return scr
->rootView
->size
.height
;
1071 void WMRedisplayWidget(WMWidget
* w
)
1073 W_RedisplayView(W_VIEW(w
));