Change to the linux kernel coding style
[wmaker-crm.git] / WINGs / wappresource.c
blobcc5dd542b516da14675817bc03acebeec3209a9c
2 #include <unistd.h>
4 #include "WINGsP.h"
6 #include <X11/Xutil.h>
8 #include "GNUstep.h"
10 extern struct W_Application WMApplication;
12 void WMSetApplicationIconWindow(WMScreen * scr, Window window)
14 scr->applicationIconWindow = window;
16 if (scr->groupLeader) {
17 XWMHints *hints;
19 hints = XGetWMHints(scr->display, scr->groupLeader);
20 hints->flags |= IconWindowHint;
21 hints->icon_window = window;
23 XSetWMHints(scr->display, scr->groupLeader, hints);
24 XFree(hints);
28 void WMSetApplicationIconImage(WMScreen * scr, RImage * image)
30 WMPixmap *icon;
32 if (scr->applicationIconImage == image)
33 return;
35 if (scr->applicationIconImage)
36 RReleaseImage(scr->applicationIconImage);
38 scr->applicationIconImage = RRetainImage(image);
40 /* TODO: check whether we should set the pixmap only if there's none yet */
41 if (image != NULL && (icon = WMCreatePixmapFromRImage(scr, image, 128)) != NULL) {
42 WMSetApplicationIconPixmap(scr, icon);
43 WMReleasePixmap(icon);
47 RImage *WMGetApplicationIconImage(WMScreen * scr)
49 return scr->applicationIconImage;
52 void WMSetApplicationIconPixmap(WMScreen * scr, WMPixmap * icon)
54 if (scr->applicationIconPixmap == icon)
55 return;
57 if (scr->applicationIconPixmap)
58 WMReleasePixmap(scr->applicationIconPixmap);
60 scr->applicationIconPixmap = WMRetainPixmap(icon);
62 if (scr->groupLeader) {
63 XWMHints *hints;
65 hints = XGetWMHints(scr->display, scr->groupLeader);
66 hints->flags |= IconPixmapHint | IconMaskHint;
67 hints->icon_pixmap = (icon != NULL ? icon->pixmap : None);
68 hints->icon_mask = (icon != NULL ? icon->mask : None);
70 XSetWMHints(scr->display, scr->groupLeader, hints);
71 XFree(hints);
75 WMPixmap *WMGetApplicationIconPixmap(WMScreen * scr)
77 return scr->applicationIconPixmap;
80 WMPixmap *WMCreateApplicationIconBlendedPixmap(WMScreen * scr, RColor * color)
82 WMPixmap *pix;
84 if (scr->applicationIconImage) {
85 RColor gray;
87 gray.red = 0xae;
88 gray.green = 0xaa;
89 gray.blue = 0xae;
90 gray.alpha = 0xff;
92 if (!color)
93 color = &gray;
95 pix = WMCreateBlendedPixmapFromRImage(scr, scr->applicationIconImage, color);
96 } else {
97 pix = NULL;
100 return pix;
103 void WMSetApplicationHasAppIcon(WMScreen * scr, Bool flag)
105 scr->aflags.hasAppIcon = ((flag == 0) ? 0 : 1);
108 void W_InitApplication(WMScreen * scr)
110 Window leader;
111 XClassHint *classHint;
112 XWMHints *hints;
114 leader = XCreateSimpleWindow(scr->display, scr->rootWin, -1, -1, 1, 1, 0, 0, 0);
116 if (!scr->aflags.simpleApplication) {
117 classHint = XAllocClassHint();
118 classHint->res_name = "groupLeader";
119 classHint->res_class = WMApplication.applicationName;
120 XSetClassHint(scr->display, leader, classHint);
121 XFree(classHint);
123 XSetCommand(scr->display, leader, WMApplication.argv, WMApplication.argc);
125 hints = XAllocWMHints();
127 hints->flags = WindowGroupHint;
128 hints->window_group = leader;
130 /* This code will never actually be reached, because to have
131 * scr->applicationIconPixmap set we need to have a screen first,
132 * but this function is called in the screen creation process.
133 * -Dan
135 if (scr->applicationIconPixmap) {
136 hints->flags |= IconPixmapHint;
137 hints->icon_pixmap = scr->applicationIconPixmap->pixmap;
138 if (scr->applicationIconPixmap->mask) {
139 hints->flags |= IconMaskHint;
140 hints->icon_mask = scr->applicationIconPixmap->mask;
144 XSetWMHints(scr->display, leader, hints);
146 XFree(hints);
148 scr->groupLeader = leader;