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
26 extern void W_InitNotificationCenter(void);
29 typedef struct W_Application
{
30 char *applicationName
;
37 struct W_Application WMApplication
;
40 char *_WINGS_progname
= NULL
;
45 W_ApplicationInitialized(void)
47 return _WINGS_progname
!=NULL
;
52 WMInitializeApplication(char *applicationName
, int *argc
, char **argv
)
58 assert(applicationName
!=NULL
);
60 _WINGS_progname
= argv
[0];
62 WMApplication
.applicationName
= wstrdup(applicationName
);
63 WMApplication
.argc
= *argc
;
65 WMApplication
.argv
= wmalloc((*argc
+1)*sizeof(char*));
66 for (i
=0; i
<*argc
; i
++) {
67 WMApplication
.argv
[i
] = wstrdup(argv
[i
]);
69 WMApplication
.argv
[i
] = NULL
;
71 /* initialize notification center */
72 W_InitNotificationCenter();
77 WMSetResourcePath(char *path
)
79 if (WMApplication
.resourcePath
)
80 free(WMApplication
.resourcePath
);
81 WMApplication
.resourcePath
= wstrdup(path
);
86 WMGetApplicationName()
88 return WMApplication
.applicationName
;
93 checkFile(char *path
, char *folder
, char *ext
, char *resource
)
98 extralen
= (ext
? strlen(ext
) : 0) + (folder
? strlen(folder
) : 0) + 4;
99 ret
= wmalloc(strlen(path
)+strlen(resource
)+extralen
+8);
110 strcat(ret
, resource
);
112 if (access(ret
, F_OK
)!=0) {
122 WMPathForResourceOfType(char *resource
, char *ext
)
129 * Paths are searched in this order:
132 * - GNUSTEP_USER_ROOT/Apps/ApplicationName.app/ext
133 * - ~/GNUstep/Apps/ApplicationName.app/ext
134 * - GNUSTEP_LOCAL_ROOT/Apps/ApplicationName.app/ext
135 * - /usr/local/GNUstep/Apps/ApplicationName.app/ext
136 * - GNUSTEP_SYSTEM_ROOT/Apps/ApplicationName.app/ext
137 * - /usr/GNUstep/Apps/ApplicationName.app/ext
140 if (WMApplication
.resourcePath
) {
141 path
= checkFile(WMApplication
.resourcePath
, NULL
, ext
, resource
);
146 if (WMApplication
.argv
[0]) {
147 tmp
= wstrdup(WMApplication
.argv
[0]);
149 while (i
> 0 && tmp
[i
]!='/')
153 path
= checkFile(tmp
, NULL
, ext
, resource
);
162 appdir
= wmalloc(strlen(WMApplication
.applicationName
)+10);
163 sprintf(appdir
, "Apps/%s.app", WMApplication
.applicationName
);
165 if (getenv("GNUSTEP_USER_ROOT")) {
166 path
= checkFile(getenv("GNUSTEP_USER_ROOT"), appdir
, ext
, resource
);
173 tmp
= wusergnusteppath();
175 path
= checkFile(tmp
, appdir
, ext
, resource
);
182 if (getenv("GNUSTEP_LOCAL_ROOT")) {
183 path
= checkFile(getenv("GNUSTEP_LOCAL_ROOT"), appdir
, ext
, resource
);
190 path
= checkFile("/usr/local/GNUstep", appdir
, ext
, resource
);
197 if (getenv("GNUSTEP_SYSTEM_ROOT")) {
198 path
= checkFile(getenv("GNUSTEP_SYSTEM_ROOT"), appdir
, ext
, resource
);
205 path
= checkFile("/usr/GNUstep", appdir
, ext
, resource
);
215 /********************* WMScreen related stuff ********************/
219 WMSetApplicationIconImage(WMScreen
*scr
, WMPixmap
*icon
)
221 if (scr
->applicationIcon
)
222 WMReleasePixmap(scr
->applicationIcon
);
224 scr
->applicationIcon
= WMRetainPixmap(icon
);
226 if (scr
->groupLeader
) {
229 hints
= XGetWMHints(scr
->display
, scr
->groupLeader
);
230 hints
->flags
|= IconPixmapHint
|IconMaskHint
;
231 hints
->icon_pixmap
= icon
->pixmap
;
232 hints
->icon_mask
= icon
->mask
;
234 XSetWMHints(scr
->display
, scr
->groupLeader
, hints
);
241 WMGetApplicationIconImage(WMScreen
*scr
)
243 return scr
->applicationIcon
;
248 WMSetApplicationHasAppIcon(WMScreen
*scr
, Bool flag
)
250 scr
->aflags
.hasAppIcon
= flag
;
255 W_InitApplication(WMScreen
*scr
)
258 XClassHint
*classHint
;
261 leader
= XCreateSimpleWindow(scr
->display
, scr
->rootWin
, -1, -1,
264 if (!scr
->aflags
.simpleApplication
) {
265 classHint
= XAllocClassHint();
266 classHint
->res_name
= "groupLeader";
267 classHint
->res_class
= WMApplication
.applicationName
;
268 XSetClassHint(scr
->display
, leader
, classHint
);
271 XSetCommand(scr
->display
, leader
, WMApplication
.argv
,
274 hints
= XAllocWMHints();
276 hints
->flags
= WindowGroupHint
;
277 hints
->window_group
= leader
;
279 if (scr
->applicationIcon
) {
280 hints
->flags
|= IconPixmapHint
;
281 hints
->icon_pixmap
= scr
->applicationIcon
->pixmap
;
282 if (scr
->applicationIcon
->mask
) {
283 hints
->flags
|= IconMaskHint
;
284 hints
->icon_mask
= scr
->applicationIcon
->mask
;
288 XSetWMHints(scr
->display
, leader
, hints
);
292 scr
->groupLeader
= leader
;