changed indentation to use spaces only
[wmaker-crm.git] / WINGs / wappresource.c
blob878a12974813be3b048f8b320e6a9cc01538ec77
3 #include <unistd.h>
5 #include "WINGsP.h"
7 #include <X11/Xutil.h>
9 #include "GNUstep.h"
13 extern struct W_Application WMApplication;
16 void
17 WMSetApplicationIconWindow(WMScreen *scr, Window window)
19 scr->applicationIconWindow = window;
21 if (scr->groupLeader) {
22 XWMHints *hints;
24 hints = XGetWMHints(scr->display, scr->groupLeader);
25 hints->flags |= IconWindowHint;
26 hints->icon_window = window;
28 XSetWMHints(scr->display, scr->groupLeader, hints);
29 XFree(hints);
34 void
35 WMSetApplicationIconImage(WMScreen *scr, RImage *image)
37 WMPixmap *icon;
39 if (scr->applicationIconImage == image)
40 return;
42 if (scr->applicationIconImage)
43 RReleaseImage(scr->applicationIconImage);
45 scr->applicationIconImage = RRetainImage(image);
47 /* TODO: check whether we should set the pixmap only if there's none yet */
48 if (image!=NULL && (icon=WMCreatePixmapFromRImage(scr, image, 128))!=NULL) {
49 WMSetApplicationIconPixmap(scr, icon);
50 WMReleasePixmap(icon);
55 RImage*
56 WMGetApplicationIconImage(WMScreen *scr)
58 return scr->applicationIconImage;
62 void
63 WMSetApplicationIconPixmap(WMScreen *scr, WMPixmap *icon)
65 if (scr->applicationIconPixmap == icon)
66 return;
68 if (scr->applicationIconPixmap)
69 WMReleasePixmap(scr->applicationIconPixmap);
71 scr->applicationIconPixmap = WMRetainPixmap(icon);
73 if (scr->groupLeader) {
74 XWMHints *hints;
76 hints = XGetWMHints(scr->display, scr->groupLeader);
77 hints->flags |= IconPixmapHint|IconMaskHint;
78 hints->icon_pixmap = (icon!=NULL ? icon->pixmap : None);
79 hints->icon_mask = (icon!=NULL ? icon->mask : None);
81 XSetWMHints(scr->display, scr->groupLeader, hints);
82 XFree(hints);
87 WMPixmap*
88 WMGetApplicationIconPixmap(WMScreen *scr)
90 return scr->applicationIconPixmap;
94 WMPixmap*
95 WMCreateApplicationIconBlendedPixmap(WMScreen *scr, RColor *color)
97 WMPixmap *pix;
99 if (scr->applicationIconImage) {
100 RColor gray;
102 gray.red = 0xae;
103 gray.green = 0xaa;
104 gray.blue = 0xae;
105 gray.alpha = 0xff;
107 if (!color)
108 color = &gray;
110 pix = WMCreateBlendedPixmapFromRImage(scr, scr->applicationIconImage,
111 color);
112 } else {
113 pix = NULL;
116 return pix;
120 void
121 WMSetApplicationHasAppIcon(WMScreen *scr, Bool flag)
123 scr->aflags.hasAppIcon = ((flag==0) ? 0 : 1);
127 void
128 W_InitApplication(WMScreen *scr)
130 Window leader;
131 XClassHint *classHint;
132 XWMHints *hints;
134 leader = XCreateSimpleWindow(scr->display, scr->rootWin, -1, -1,
135 1, 1, 0, 0, 0);
137 if (!scr->aflags.simpleApplication) {
138 classHint = XAllocClassHint();
139 classHint->res_name = "groupLeader";
140 classHint->res_class = WMApplication.applicationName;
141 XSetClassHint(scr->display, leader, classHint);
142 XFree(classHint);
144 XSetCommand(scr->display, leader, WMApplication.argv,
145 WMApplication.argc);
147 hints = XAllocWMHints();
149 hints->flags = WindowGroupHint;
150 hints->window_group = leader;
152 /* This code will never actually be reached, because to have
153 * scr->applicationIconPixmap set we need to have a screen first,
154 * but this function is called in the screen creation process.
155 * -Dan
157 if (scr->applicationIconPixmap) {
158 hints->flags |= IconPixmapHint;
159 hints->icon_pixmap = scr->applicationIconPixmap->pixmap;
160 if (scr->applicationIconPixmap->mask) {
161 hints->flags |= IconMaskHint;
162 hints->icon_mask = scr->applicationIconPixmap->mask;
166 XSetWMHints(scr->display, leader, hints);
168 XFree(hints);
170 scr->groupLeader = leader;