For libwraster:
[wmaker-crm.git] / WINGs / wappresource.c
blobb8f152686e5981ae35843a3b6d28b86406e34885
3 #include <unistd.h>
5 #include "WINGsP.h"
7 #include <X11/Xutil.h>
9 /* Xmd.h which is indirectly included by GNUstep.h defines BOOL,
10 * but libPropList also defines it. So we do this kluge to get rid of BOOL
11 * temporarily */
12 #ifdef BOOL
13 # define WINGS_BOOL
14 # undef BOOL
15 #endif
17 #include "GNUstep.h"
19 #ifdef WINGS_BOOL
20 # define BOOL
21 # undef WINGS_BOOL
22 #endif
25 extern struct W_Application WMApplication;
28 void
29 WMSetApplicationIconWindow(WMScreen *scr, Window window)
31 scr->applicationIconWindow = window;
33 if (scr->groupLeader) {
34 XWMHints *hints;
36 hints = XGetWMHints(scr->display, scr->groupLeader);
37 hints->flags |= IconWindowHint;
38 hints->icon_window = window;
40 XSetWMHints(scr->display, scr->groupLeader, hints);
41 XFree(hints);
46 void
47 WMSetApplicationIconImage(WMScreen *scr, RImage *image)
49 WMPixmap *icon;
51 if (scr->applicationIconImage == image)
52 return;
54 if (scr->applicationIconImage)
55 RReleaseImage(scr->applicationIconImage);
57 scr->applicationIconImage = RRetainImage(image);
59 /* TODO: check whether we should set the pixmap only if there's none yet */
60 if (image!=NULL && (icon=WMCreatePixmapFromRImage(scr, image, 128))!=NULL) {
61 WMSetApplicationIconPixmap(scr, icon);
62 WMReleasePixmap(icon);
67 RImage*
68 WMGetApplicationIconImage(WMScreen *scr)
70 return scr->applicationIconImage;
74 void
75 WMSetApplicationIconPixmap(WMScreen *scr, WMPixmap *icon)
77 if (scr->applicationIconPixmap == icon)
78 return;
80 if (scr->applicationIconPixmap)
81 WMReleasePixmap(scr->applicationIconPixmap);
83 scr->applicationIconPixmap = WMRetainPixmap(icon);
85 if (scr->groupLeader) {
86 XWMHints *hints;
88 hints = XGetWMHints(scr->display, scr->groupLeader);
89 hints->flags |= IconPixmapHint|IconMaskHint;
90 hints->icon_pixmap = (icon!=NULL ? icon->pixmap : None);
91 hints->icon_mask = (icon!=NULL ? icon->mask : None);
93 XSetWMHints(scr->display, scr->groupLeader, hints);
94 XFree(hints);
99 WMPixmap*
100 WMGetApplicationIconPixmap(WMScreen *scr)
102 return scr->applicationIconPixmap;
106 WMPixmap*
107 WMGetApplicationIconBlendedPixmap(WMScreen *scr, RColor *color)
109 WMPixmap *pix;
111 if (scr->applicationIconImage) {
112 RColor gray;
114 gray.red = 0xae;
115 gray.green = 0xaa;
116 gray.blue = 0xae;
117 gray.alpha = 0;
119 if (!color)
120 color = &gray;
122 pix = WMCreateBlendedPixmapFromRImage(scr, scr->applicationIconImage,
123 color);
124 } else {
125 pix = NULL;
128 return pix;
132 void
133 WMSetApplicationHasAppIcon(WMScreen *scr, Bool flag)
135 scr->aflags.hasAppIcon = flag;
139 void
140 W_InitApplication(WMScreen *scr)
142 Window leader;
143 XClassHint *classHint;
144 XWMHints *hints;
146 leader = XCreateSimpleWindow(scr->display, scr->rootWin, -1, -1,
147 1, 1, 0, 0, 0);
149 if (!scr->aflags.simpleApplication) {
150 classHint = XAllocClassHint();
151 classHint->res_name = "groupLeader";
152 classHint->res_class = WMApplication.applicationName;
153 XSetClassHint(scr->display, leader, classHint);
154 XFree(classHint);
156 XSetCommand(scr->display, leader, WMApplication.argv,
157 WMApplication.argc);
159 hints = XAllocWMHints();
161 hints->flags = WindowGroupHint;
162 hints->window_group = leader;
164 /* This code will never actually be reached, because to have
165 * scr->applicationIconPixmap set we need to have a screen first,
166 * but this function is called in the screen creation process.
167 * -Dan
169 if (scr->applicationIconPixmap) {
170 hints->flags |= IconPixmapHint;
171 hints->icon_pixmap = scr->applicationIconPixmap->pixmap;
172 if (scr->applicationIconPixmap->mask) {
173 hints->flags |= IconMaskHint;
174 hints->icon_mask = scr->applicationIconPixmap->mask;
178 XSetWMHints(scr->display, leader, hints);
180 XFree(hints);
182 scr->groupLeader = leader;