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 extern void W_ReadConfigurations(void);
303 static int userWidgetCount
= 0;
305 /***** end data ******/
307 static void renderPixmap(W_Screen
* screen
, Pixmap d
, Pixmap mask
, char **data
, int width
, int height
)
310 GC whiteGC
= WMColorGC(screen
->white
);
311 GC blackGC
= WMColorGC(screen
->black
);
312 GC lightGC
= WMColorGC(screen
->gray
);
313 GC darkGC
= WMColorGC(screen
->darkGray
);
316 XSetForeground(screen
->display
, screen
->monoGC
, 0);
318 for (y
= 0; y
< height
; y
++) {
319 for (x
= 0; x
< width
; x
++) {
320 switch (data
[y
][x
]) {
323 XDrawPoint(screen
->display
, d
, whiteGC
, x
, y
);
328 XDrawPoint(screen
->display
, mask
, screen
->monoGC
, x
, y
);
332 XDrawPoint(screen
->display
, d
, lightGC
, x
, y
);
337 XDrawPoint(screen
->display
, d
, darkGC
, x
, y
);
343 XDrawPoint(screen
->display
, d
, blackGC
, x
, y
);
350 static WMPixmap
*makePixmap(W_Screen
* sPtr
, char **data
, int width
, int height
, int masked
)
352 Pixmap pixmap
, mask
= None
;
354 pixmap
= XCreatePixmap(sPtr
->display
, W_DRAWABLE(sPtr
), width
, height
, sPtr
->depth
);
357 mask
= XCreatePixmap(sPtr
->display
, W_DRAWABLE(sPtr
), width
, height
, 1);
358 XSetForeground(sPtr
->display
, sPtr
->monoGC
, 1);
359 XFillRectangle(sPtr
->display
, mask
, sPtr
->monoGC
, 0, 0, width
, height
);
362 renderPixmap(sPtr
, pixmap
, mask
, data
, width
, height
);
364 return WMCreatePixmapFromXPixmaps(sPtr
, pixmap
, mask
, width
, height
, sPtr
->depth
);
367 #define T_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.tiff"
368 #define T_DEFAULT_OBJECT_ICON_FILE RESOURCE_PATH"/defaultIcon.tiff"
370 #define X_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.xpm"
371 #define X_DEFAULT_OBJECT_ICON_FILE RESOURCE_PATH"/defaultIcon.xpm"
373 static Bool
loadPixmaps(WMScreen
* scr
)
387 image
= RLoadImage(scr
->rcontext
, T_WINGS_IMAGES_FILE
, 0);
389 image
= RLoadImage(scr
->rcontext
, X_WINGS_IMAGES_FILE
, 0);
391 wwarning(_("WINGs: could not load widget images file: %s"), RMessageForError(RErrorCode
));
395 /* make it have a gray background */
396 tmp
= RGetSubImage(image
, 0, 0, 24, 24);
397 RCombineImageWithColor(tmp
, &gray
);
398 scr
->homeIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
400 /* make it have a white background */
401 tmp
= RGetSubImage(image
, 0, 0, 24, 24);
402 RCombineImageWithColor(tmp
, &white
);
403 scr
->altHomeIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
407 tmp
= RGetSubImage(image
, 104, 0, 24, 24);
408 RCombineImageWithColor(tmp
, &white
);
409 scr
->trashcanIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
411 tmp
= RGetSubImage(image
, 104, 0, 24, 24);
412 RCombineImageWithColor(tmp
, &white
);
413 scr
->altTrashcanIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
416 tmp
= RGetSubImage(image
, 104, 24, 24, 24);
417 RCombineImageWithColor(tmp
, &white
);
418 scr
->createDirIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
420 tmp
= RGetSubImage(image
, 104, 24, 24, 24);
421 RCombineImageWithColor(tmp
, &white
);
422 scr
->altCreateDirIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
425 tmp
= RGetSubImage(image
, 24, 80, 24, 24);
426 RCombineImageWithColor(tmp
, &white
);
427 scr
->disketteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
429 tmp
= RGetSubImage(image
, 24, 80, 24, 24);
430 RCombineImageWithColor(tmp
, &white
);
431 scr
->altDisketteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
434 tmp
= RGetSubImage(image
, 0, 80, 24, 24);
435 RCombineImageWithColor(tmp
, &white
);
436 scr
->unmountIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
438 tmp
= RGetSubImage(image
, 0, 80, 24, 24);
439 RCombineImageWithColor(tmp
, &white
);
440 scr
->altUnmountIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
443 /* Magnifying Glass Icon for ColorPanel */
444 tmp
= RGetSubImage(image
, 24, 0, 40, 32);
445 RCombineImageWithColor(tmp
, &gray
);
446 scr
->magnifyIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
448 /* ColorWheel Icon for ColorPanel */
449 tmp
= RGetSubImage(image
, 0, 25, 24, 24);
450 scr
->wheelIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
452 /* GrayScale Icon for ColorPanel */
453 tmp
= RGetSubImage(image
, 65, 0, 40, 24);
454 scr
->grayIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
456 /* RGB Icon for ColorPanel */
457 tmp
= RGetSubImage(image
, 25, 33, 40, 24);
458 scr
->rgbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
460 /* CMYK Icon for ColorPanel */
461 tmp
= RGetSubImage(image
, 65, 25, 40, 24);
462 scr
->cmykIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
464 /* HSB Icon for ColorPanel */
465 tmp
= RGetSubImage(image
, 0, 57, 40, 24);
466 scr
->hsbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
468 /* CustomColorPalette Icon for ColorPanel */
469 tmp
= RGetSubImage(image
, 81, 57, 40, 24);
470 scr
->customPaletteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
472 /* ColorList Icon for ColorPanel */
473 tmp
= RGetSubImage(image
, 41, 57, 40, 24);
474 scr
->colorListIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
477 RReleaseImage(image
);
480 scr
->defaultObjectIcon
= WMCreatePixmapFromFile(scr
, T_DEFAULT_OBJECT_ICON_FILE
);
481 if (!scr
->defaultObjectIcon
) {
482 scr
->defaultObjectIcon
= WMCreatePixmapFromFile(scr
, X_DEFAULT_OBJECT_ICON_FILE
);
484 if (!scr
->defaultObjectIcon
) {
485 wwarning("WINGs: could not load default icon file");
492 WMScreen
*WMOpenScreen(const char *display
)
494 Display
*dpy
= XOpenDisplay(display
);
497 wwarning("WINGs: could not open display %s", XDisplayName(display
));
501 return WMCreateSimpleApplicationScreen(dpy
);
504 WMScreen
*WMCreateSimpleApplicationScreen(Display
* display
)
508 scr
= WMCreateScreen(display
, DefaultScreen(display
));
510 scr
->aflags
.hasAppIcon
= 0;
511 scr
->aflags
.simpleApplication
= 1;
516 WMScreen
*WMCreateScreen(Display
* display
, int screen
)
518 return WMCreateScreenWithRContext(display
, screen
, RCreateContext(display
, screen
, NULL
));
521 WMScreen
*WMCreateScreenWithRContext(Display
* display
, int screen
, RContext
* context
)
526 static int initialized
= 0;
527 static char *atomNames
[] = {
541 "XdndActionDescription",
548 "_WINGS_DND_MOUSE_OFFSET",
555 Atom atoms
[sizeof(atomNames
) / sizeof(char *)];
562 W_ReadConfigurations();
564 assert(W_ApplicationInitialized());
567 scrPtr
= malloc(sizeof(W_Screen
));
570 memset(scrPtr
, 0, sizeof(W_Screen
));
572 scrPtr
->aflags
.hasAppIcon
= 1;
574 scrPtr
->display
= display
;
575 scrPtr
->screen
= screen
;
576 scrPtr
->rcontext
= context
;
578 scrPtr
->depth
= context
->depth
;
580 scrPtr
->visual
= context
->visual
;
581 scrPtr
->lastEventTime
= 0;
583 scrPtr
->colormap
= context
->cmap
;
585 scrPtr
->rootWin
= RootWindow(display
, screen
);
587 scrPtr
->fontCache
= WMCreateHashTable(WMStringPointerHashCallbacks
);
589 scrPtr
->xftdraw
= XftDrawCreate(scrPtr
->display
, W_DRAWABLE(scrPtr
), scrPtr
->visual
, scrPtr
->colormap
);
591 /* Create missing CUT_BUFFERs */
594 int exists
[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
597 rootWinProps
= XListProperties(display
, scrPtr
->rootWin
, &count
);
598 for (i
= 0; i
< count
; i
++) {
599 switch (rootWinProps
[i
]) {
631 for (i
= 0; i
< 8; i
++) {
633 XStoreBuffer(display
, "", 0, i
);
638 scrPtr
->ignoredModifierMask
= 0;
641 XModifierKeymap
*modmap
;
642 KeyCode nlock
, slock
;
643 static int mask_table
[8] = {
644 ShiftMask
, LockMask
, ControlMask
, Mod1Mask
,
645 Mod2Mask
, Mod3Mask
, Mod4Mask
, Mod5Mask
647 unsigned int numLockMask
= 0, scrollLockMask
= 0;
649 nlock
= XKeysymToKeycode(display
, XK_Num_Lock
);
650 slock
= XKeysymToKeycode(display
, XK_Scroll_Lock
);
653 * Find out the masks for the NumLock and ScrollLock modifiers,
654 * so that we can bind the grabs for when they are enabled too.
656 modmap
= XGetModifierMapping(display
);
658 if (modmap
!= NULL
&& modmap
->max_keypermod
> 0) {
659 for (i
= 0; i
< 8 * modmap
->max_keypermod
; i
++) {
660 if (modmap
->modifiermap
[i
] == nlock
&& nlock
!= 0)
661 numLockMask
= mask_table
[i
/ modmap
->max_keypermod
];
662 else if (modmap
->modifiermap
[i
] == slock
&& slock
!= 0)
663 scrollLockMask
= mask_table
[i
/ modmap
->max_keypermod
];
668 XFreeModifiermap(modmap
);
670 scrPtr
->ignoredModifierMask
= numLockMask
| scrollLockMask
| LockMask
;
673 /* initially allocate some colors */
674 WMWhiteColor(scrPtr
);
675 WMBlackColor(scrPtr
);
677 WMDarkGrayColor(scrPtr
);
679 gcv
.graphics_exposures
= False
;
681 gcv
.function
= GXxor
;
682 gcv
.foreground
= W_PIXEL(scrPtr
->white
);
683 if (gcv
.foreground
== 0)
685 scrPtr
->xorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
686 | GCGraphicsExposures
| GCForeground
, &gcv
);
688 gcv
.function
= GXxor
;
689 gcv
.foreground
= W_PIXEL(scrPtr
->gray
);
690 gcv
.subwindow_mode
= IncludeInferiors
;
691 scrPtr
->ixorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
692 | GCGraphicsExposures
| GCForeground
| GCSubwindowMode
, &gcv
);
694 gcv
.function
= GXcopy
;
695 scrPtr
->copyGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
| GCGraphicsExposures
, &gcv
);
697 scrPtr
->clipGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
| GCGraphicsExposures
, &gcv
);
699 stipple
= XCreateBitmapFromData(display
, W_DRAWABLE(scrPtr
), STIPPLE_BITS
, STIPPLE_WIDTH
, STIPPLE_HEIGHT
);
700 gcv
.foreground
= W_PIXEL(scrPtr
->darkGray
);
701 gcv
.background
= W_PIXEL(scrPtr
->gray
);
702 gcv
.fill_style
= FillStippled
;
703 gcv
.stipple
= stipple
;
704 scrPtr
->stippleGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
),
705 GCForeground
| GCBackground
| GCStipple
706 | GCFillStyle
| GCGraphicsExposures
, &gcv
);
708 scrPtr
->drawStringGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCGraphicsExposures
, &gcv
);
709 scrPtr
->drawImStringGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCGraphicsExposures
, &gcv
);
711 /* we need a 1bpp drawable for the monoGC, so borrow this one */
712 scrPtr
->monoGC
= XCreateGC(display
, stipple
, 0, NULL
);
714 scrPtr
->stipple
= stipple
;
716 scrPtr
->antialiasedText
= WINGsConfiguration
.antialiasedText
;
718 scrPtr
->normalFont
= WMSystemFontOfSize(scrPtr
, 0);
720 scrPtr
->boldFont
= WMBoldSystemFontOfSize(scrPtr
, 0);
722 if (!scrPtr
->boldFont
)
723 scrPtr
->boldFont
= scrPtr
->normalFont
;
725 if (!scrPtr
->normalFont
) {
726 wwarning(_("could not load any fonts. Make sure your font installation"
727 " and locale settings are correct."));
732 /* create input method stuff */
735 scrPtr
->checkButtonImageOn
= makePixmap(scrPtr
, CHECK_BUTTON_ON
,
736 CHECK_BUTTON_ON_WIDTH
, CHECK_BUTTON_ON_HEIGHT
, False
);
738 scrPtr
->checkButtonImageOff
= makePixmap(scrPtr
, CHECK_BUTTON_OFF
,
739 CHECK_BUTTON_OFF_WIDTH
, CHECK_BUTTON_OFF_HEIGHT
, False
);
741 scrPtr
->radioButtonImageOn
= makePixmap(scrPtr
, RADIO_BUTTON_ON
,
742 RADIO_BUTTON_ON_WIDTH
, RADIO_BUTTON_ON_HEIGHT
, False
);
744 scrPtr
->radioButtonImageOff
= makePixmap(scrPtr
, RADIO_BUTTON_OFF
,
745 RADIO_BUTTON_OFF_WIDTH
, RADIO_BUTTON_OFF_HEIGHT
, False
);
747 scrPtr
->buttonArrow
= makePixmap(scrPtr
, BUTTON_ARROW
, BUTTON_ARROW_WIDTH
, BUTTON_ARROW_HEIGHT
, False
);
749 scrPtr
->pushedButtonArrow
= makePixmap(scrPtr
, BUTTON_ARROW2
,
750 BUTTON_ARROW2_WIDTH
, BUTTON_ARROW2_HEIGHT
, False
);
752 scrPtr
->scrollerDimple
= makePixmap(scrPtr
, SCROLLER_DIMPLE
,
753 SCROLLER_DIMPLE_WIDTH
, SCROLLER_DIMPLE_HEIGHT
, False
);
755 scrPtr
->upArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_UP
,
756 SCROLLER_ARROW_UP_WIDTH
, SCROLLER_ARROW_UP_HEIGHT
, True
);
758 scrPtr
->downArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_DOWN
,
759 SCROLLER_ARROW_DOWN_WIDTH
, SCROLLER_ARROW_DOWN_HEIGHT
, True
);
761 scrPtr
->leftArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_LEFT
,
762 SCROLLER_ARROW_LEFT_WIDTH
, SCROLLER_ARROW_LEFT_HEIGHT
, True
);
764 scrPtr
->rightArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_RIGHT
,
765 SCROLLER_ARROW_RIGHT_WIDTH
, SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
767 scrPtr
->hiUpArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_UP
,
768 SCROLLER_ARROW_UP_WIDTH
, SCROLLER_ARROW_UP_HEIGHT
, True
);
770 scrPtr
->hiDownArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_DOWN
,
771 SCROLLER_ARROW_DOWN_WIDTH
, SCROLLER_ARROW_DOWN_HEIGHT
, True
);
773 scrPtr
->hiLeftArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_LEFT
,
774 SCROLLER_ARROW_LEFT_WIDTH
, SCROLLER_ARROW_LEFT_HEIGHT
, True
);
776 scrPtr
->hiRightArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_RIGHT
,
777 SCROLLER_ARROW_RIGHT_WIDTH
, SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
779 scrPtr
->popUpIndicator
= makePixmap(scrPtr
, POPUP_INDICATOR
,
780 POPUP_INDICATOR_WIDTH
, POPUP_INDICATOR_HEIGHT
, True
);
782 scrPtr
->pullDownIndicator
= makePixmap(scrPtr
, PULLDOWN_INDICATOR
,
783 PULLDOWN_INDICATOR_WIDTH
, PULLDOWN_INDICATOR_HEIGHT
, True
);
785 scrPtr
->checkMark
= makePixmap(scrPtr
, CHECK_MARK
, CHECK_MARK_WIDTH
, CHECK_MARK_HEIGHT
, True
);
789 scrPtr
->defaultCursor
= XCreateFontCursor(display
, XC_left_ptr
);
791 scrPtr
->textCursor
= XCreateFontCursor(display
, XC_xterm
);
797 blank
= XCreatePixmap(display
, scrPtr
->stipple
, 1, 1, 1);
798 XSetForeground(display
, scrPtr
->monoGC
, 0);
799 XFillRectangle(display
, blank
, scrPtr
->monoGC
, 0, 0, 1, 1);
801 scrPtr
->invisibleCursor
= XCreatePixmapCursor(display
, blank
, blank
, &bla
, &bla
, 0, 0);
802 XFreePixmap(display
, blank
);
805 #ifdef HAVE_XINTERNATOMS
806 XInternAtoms(display
, atomNames
, sizeof(atomNames
) / sizeof(char *), False
, atoms
);
808 for (i
= 0; i
< sizeof(atomNames
) / sizeof(char *); i
++) {
809 atoms
[i
] = XInternAtom(display
, atomNames
[i
], False
);
814 scrPtr
->attribsAtom
= atoms
[i
++];
816 scrPtr
->deleteWindowAtom
= atoms
[i
++];
818 scrPtr
->protocolsAtom
= atoms
[i
++];
820 scrPtr
->clipboardAtom
= atoms
[i
++];
822 scrPtr
->xdndAwareAtom
= atoms
[i
++];
823 scrPtr
->xdndSelectionAtom
= atoms
[i
++];
824 scrPtr
->xdndEnterAtom
= atoms
[i
++];
825 scrPtr
->xdndLeaveAtom
= atoms
[i
++];
826 scrPtr
->xdndPositionAtom
= atoms
[i
++];
827 scrPtr
->xdndDropAtom
= atoms
[i
++];
828 scrPtr
->xdndFinishedAtom
= atoms
[i
++];
829 scrPtr
->xdndTypeListAtom
= atoms
[i
++];
830 scrPtr
->xdndActionListAtom
= atoms
[i
++];
831 scrPtr
->xdndActionDescriptionAtom
= atoms
[i
++];
832 scrPtr
->xdndStatusAtom
= atoms
[i
++];
834 scrPtr
->xdndActionCopy
= atoms
[i
++];
835 scrPtr
->xdndActionMove
= atoms
[i
++];
836 scrPtr
->xdndActionLink
= atoms
[i
++];
837 scrPtr
->xdndActionAsk
= atoms
[i
++];
838 scrPtr
->xdndActionPrivate
= atoms
[i
++];
840 scrPtr
->wmIconDragOffsetAtom
= atoms
[i
++];
842 scrPtr
->wmStateAtom
= atoms
[i
++];
844 scrPtr
->utf8String
= atoms
[i
++];
845 scrPtr
->netwmName
= atoms
[i
++];
846 scrPtr
->netwmIconName
= atoms
[i
++];
847 scrPtr
->netwmIcon
= atoms
[i
++];
849 scrPtr
->rootView
= W_CreateRootView(scrPtr
);
851 scrPtr
->balloon
= W_CreateBalloon(scrPtr
);
853 W_InitApplication(scrPtr
);
858 void WMSetWidgetDefaultFont(WMScreen
* scr
, WMFont
* font
)
860 WMReleaseFont(scr
->normalFont
);
861 scr
->normalFont
= WMRetainFont(font
);
864 void WMSetWidgetDefaultBoldFont(WMScreen
* scr
, WMFont
* font
)
866 WMReleaseFont(scr
->boldFont
);
867 scr
->boldFont
= WMRetainFont(font
);
870 void WMHangData(WMWidget
* widget
, void *data
)
872 W_VIEW(widget
)->hangedData
= data
;
875 void *WMGetHangedData(WMWidget
* widget
)
877 return W_VIEW(widget
)->hangedData
;
880 void WMDestroyWidget(WMWidget
* widget
)
882 W_UnmapView(W_VIEW(widget
));
883 W_DestroyView(W_VIEW(widget
));
886 void WMSetFocusToWidget(WMWidget
* widget
)
888 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget
)), W_VIEW(widget
));
893 * Realizes the widget and all it's children.
896 void WMRealizeWidget(WMWidget
* w
)
898 W_RealizeView(W_VIEW(w
));
901 void WMMapWidget(WMWidget
* w
)
903 W_MapView(W_VIEW(w
));
906 void WMReparentWidget(WMWidget
* w
, WMWidget
* newParent
, int x
, int y
)
908 W_ReparentView(W_VIEW(w
), W_VIEW(newParent
), x
, y
);
911 static void makeChildrenAutomap(W_View
* view
, int flag
)
913 view
= view
->childrenList
;
916 view
->flags
.mapWhenRealized
= flag
;
917 makeChildrenAutomap(view
, flag
);
919 view
= view
->nextSister
;
923 void WMMapSubwidgets(WMWidget
* w
)
925 /* make sure that subwidgets created after the parent was realized
927 if (!W_VIEW(w
)->flags
.realized
) {
928 makeChildrenAutomap(W_VIEW(w
), True
);
930 W_MapSubviews(W_VIEW(w
));
934 void WMUnmapSubwidgets(WMWidget
* w
)
936 if (!W_VIEW(w
)->flags
.realized
) {
937 makeChildrenAutomap(W_VIEW(w
), False
);
939 W_UnmapSubviews(W_VIEW(w
));
943 void WMUnmapWidget(WMWidget
* w
)
945 W_UnmapView(W_VIEW(w
));
948 Bool
WMWidgetIsMapped(WMWidget
* w
)
950 return W_VIEW(w
)->flags
.mapped
;
953 void WMSetWidgetBackgroundColor(WMWidget
* w
, WMColor
* color
)
955 W_SetViewBackgroundColor(W_VIEW(w
), color
);
956 if (W_VIEW(w
)->flags
.mapped
)
957 WMRedisplayWidget(w
);
960 WMColor
*WMGetWidgetBackgroundColor(WMWidget
* w
)
962 return W_VIEW(w
)->backColor
;
965 void WMRaiseWidget(WMWidget
* w
)
967 W_RaiseView(W_VIEW(w
));
970 void WMLowerWidget(WMWidget
* w
)
972 W_LowerView(W_VIEW(w
));
975 void WMMoveWidget(WMWidget
* w
, int x
, int y
)
977 W_MoveView(W_VIEW(w
), x
, y
);
980 void WMResizeWidget(WMWidget
* w
, unsigned int width
, unsigned int height
)
982 W_ResizeView(W_VIEW(w
), width
, height
);
985 W_Class
W_RegisterUserWidget(void)
989 return userWidgetCount
+ WC_UserWidget
- 1;
992 RContext
*WMScreenRContext(WMScreen
* scr
)
994 return scr
->rcontext
;
997 unsigned int WMWidgetWidth(WMWidget
* w
)
999 return W_VIEW(w
)->size
.width
;
1002 unsigned int WMWidgetHeight(WMWidget
* w
)
1004 return W_VIEW(w
)->size
.height
;
1007 Window
WMWidgetXID(WMWidget
* w
)
1009 return W_VIEW(w
)->window
;
1012 WMScreen
*WMWidgetScreen(WMWidget
* w
)
1014 return W_VIEW(w
)->screen
;
1017 void WMScreenMainLoop(WMScreen
* scr
)
1022 WMNextEvent(scr
->display
, &event
);
1023 WMHandleEvent(&event
);
1027 void WMBreakModalLoop(WMScreen
* scr
)
1032 void WMRunModalLoop(WMScreen
* scr
, WMView
* view
)
1034 /* why is scr passed if is determined from the view? */
1035 /*WMScreen *scr = view->screen; */
1036 int oldModalLoop
= scr
->modalLoop
;
1037 WMView
*oldModalView
= scr
->modalView
;
1039 scr
->modalView
= view
;
1042 while (scr
->modalLoop
) {
1045 WMNextEvent(scr
->display
, &event
);
1046 WMHandleEvent(&event
);
1049 scr
->modalView
= oldModalView
;
1050 scr
->modalLoop
= oldModalLoop
;
1053 Display
*WMScreenDisplay(WMScreen
* scr
)
1055 return scr
->display
;
1058 int WMScreenDepth(WMScreen
* scr
)
1063 unsigned int WMScreenWidth(WMScreen
* scr
)
1065 return scr
->rootView
->size
.width
;
1068 unsigned int WMScreenHeight(WMScreen
* scr
)
1070 return scr
->rootView
->size
.height
;
1073 void WMRedisplayWidget(WMWidget
* w
)
1075 W_RedisplayView(W_VIEW(w
));