Update Serbian translation from master branch
[wmaker-crm.git] / WINGs / wappresource.c
blob013049c013a1997a0197933dd90b4c35c2276e92
2 #include <unistd.h>
4 #include "WINGsP.h"
6 #include <X11/Xutil.h>
8 #include "GNUstep.h"
11 void WMSetApplicationIconWindow(WMScreen * scr, Window window)
13 scr->applicationIconWindow = window;
15 if (scr->groupLeader) {
16 XWMHints *hints;
18 hints = XGetWMHints(scr->display, scr->groupLeader);
19 hints->flags |= IconWindowHint;
20 hints->icon_window = window;
22 XSetWMHints(scr->display, scr->groupLeader, hints);
23 XFree(hints);
27 void WMSetApplicationIconImage(WMScreen * scr, RImage * image)
29 WMPixmap *icon;
31 if (scr->applicationIconImage == image)
32 return;
34 if (scr->applicationIconImage)
35 RReleaseImage(scr->applicationIconImage);
37 scr->applicationIconImage = RRetainImage(image);
39 /* TODO: check whether we should set the pixmap only if there's none yet */
40 if (image != NULL && (icon = WMCreatePixmapFromRImage(scr, image, 128)) != NULL) {
41 WMSetApplicationIconPixmap(scr, icon);
42 WMReleasePixmap(icon);
46 RImage *WMGetApplicationIconImage(WMScreen * scr)
48 return scr->applicationIconImage;
51 void WMSetApplicationIconPixmap(WMScreen * scr, WMPixmap * icon)
53 if (scr->applicationIconPixmap == icon)
54 return;
56 if (scr->applicationIconPixmap)
57 WMReleasePixmap(scr->applicationIconPixmap);
59 scr->applicationIconPixmap = WMRetainPixmap(icon);
61 if (scr->groupLeader) {
62 XWMHints *hints;
64 hints = XGetWMHints(scr->display, scr->groupLeader);
65 hints->flags |= IconPixmapHint | IconMaskHint;
66 hints->icon_pixmap = (icon != NULL ? icon->pixmap : None);
67 hints->icon_mask = (icon != NULL ? icon->mask : None);
69 XSetWMHints(scr->display, scr->groupLeader, hints);
70 XFree(hints);
74 WMPixmap *WMGetApplicationIconPixmap(WMScreen * scr)
76 return scr->applicationIconPixmap;
79 WMPixmap *WMCreateApplicationIconBlendedPixmap(WMScreen * scr, const RColor * color)
81 WMPixmap *pix;
83 if (scr->applicationIconImage) {
84 static const RColor gray = {
85 /* red */ 0xAE,
86 /* green */ 0xAA,
87 /* blue */ 0xAE,
88 /* alpha */ 0xFF
91 if (!color)
92 color = &gray;
94 pix = WMCreateBlendedPixmapFromRImage(scr, scr->applicationIconImage, color);
95 } else {
96 pix = NULL;
99 return pix;
102 void WMSetApplicationHasAppIcon(WMScreen * scr, Bool flag)
104 scr->aflags.hasAppIcon = ((flag == 0) ? 0 : 1);
107 void W_InitApplication(WMScreen * scr)
109 Window leader;
110 XClassHint *classHint;
111 XWMHints *hints;
113 leader = XCreateSimpleWindow(scr->display, scr->rootWin, -1, -1, 1, 1, 0, 0, 0);
115 if (!scr->aflags.simpleApplication) {
116 classHint = XAllocClassHint();
117 classHint->res_name = "groupLeader";
118 classHint->res_class = WMApplication.applicationName;
119 XSetClassHint(scr->display, leader, classHint);
120 XFree(classHint);
122 XSetCommand(scr->display, leader, WMApplication.argv, WMApplication.argc);
124 hints = XAllocWMHints();
126 hints->flags = WindowGroupHint;
127 hints->window_group = leader;
129 /* This code will never actually be reached, because to have
130 * scr->applicationIconPixmap set we need to have a screen first,
131 * but this function is called in the screen creation process.
132 * -Dan
134 if (scr->applicationIconPixmap) {
135 hints->flags |= IconPixmapHint;
136 hints->icon_pixmap = scr->applicationIconPixmap->pixmap;
137 if (scr->applicationIconPixmap->mask) {
138 hints->flags |= IconMaskHint;
139 hints->icon_mask = scr->applicationIconPixmap->mask;
143 XSetWMHints(scr->display, leader, hints);
145 XFree(hints);
147 scr->groupLeader = leader;