Fixed crashing bug in WPrefs.app's appereance section.
[wmaker-crm.git] / WINGs / wappresource.c
blob244bb3fdb4773d9acdb5de616879a6956832bb30
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 WMSetApplicationIconImage(WMScreen *scr, WMPixmap *icon)
31 if (scr->applicationIcon)
32 WMReleasePixmap(scr->applicationIcon);
34 scr->applicationIcon = WMRetainPixmap(icon);
36 if (scr->groupLeader) {
37 XWMHints *hints;
39 hints = XGetWMHints(scr->display, scr->groupLeader);
40 hints->flags |= IconPixmapHint|IconMaskHint;
41 hints->icon_pixmap = icon->pixmap;
42 hints->icon_mask = icon->mask;
44 XSetWMHints(scr->display, scr->groupLeader, hints);
45 XFree(hints);
50 WMPixmap*
51 WMGetApplicationIconImage(WMScreen *scr)
53 return scr->applicationIcon;
57 void
58 WMSetApplicationHasAppIcon(WMScreen *scr, Bool flag)
60 scr->aflags.hasAppIcon = flag;
64 void
65 W_InitApplication(WMScreen *scr)
67 Window leader;
68 XClassHint *classHint;
69 XWMHints *hints;
71 leader = XCreateSimpleWindow(scr->display, scr->rootWin, -1, -1,
72 1, 1, 0, 0, 0);
74 if (!scr->aflags.simpleApplication) {
75 classHint = XAllocClassHint();
76 classHint->res_name = "groupLeader";
77 classHint->res_class = WMApplication.applicationName;
78 XSetClassHint(scr->display, leader, classHint);
79 XFree(classHint);
81 XSetCommand(scr->display, leader, WMApplication.argv,
82 WMApplication.argc);
84 hints = XAllocWMHints();
86 hints->flags = WindowGroupHint;
87 hints->window_group = leader;
89 if (scr->applicationIcon) {
90 hints->flags |= IconPixmapHint;
91 hints->icon_pixmap = scr->applicationIcon->pixmap;
92 if (scr->applicationIcon->mask) {
93 hints->flags |= IconMaskHint;
94 hints->icon_mask = scr->applicationIcon->mask;
98 XSetWMHints(scr->display, leader, hints);
100 XFree(hints);
102 scr->groupLeader = leader;