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
);
183 if (getenv("GNUSTEP_LOCAL_ROOT")) {
184 path
= checkFile(getenv("GNUSTEP_LOCAL_ROOT"), appdir
, ext
, resource
);
191 path
= checkFile("/usr/local/GNUstep", appdir
, ext
, resource
);
198 if (getenv("GNUSTEP_SYSTEM_ROOT")) {
199 path
= checkFile(getenv("GNUSTEP_SYSTEM_ROOT"), appdir
, ext
, resource
);
206 path
= checkFile("/usr/GNUstep", appdir
, ext
, resource
);
216 /********************* WMScreen related stuff ********************/
220 WMSetApplicationIconImage(WMScreen
*scr
, WMPixmap
*icon
)
222 if (scr
->applicationIcon
)
223 WMReleasePixmap(scr
->applicationIcon
);
225 scr
->applicationIcon
= WMRetainPixmap(icon
);
227 if (scr
->groupLeader
) {
230 hints
= XGetWMHints(scr
->display
, scr
->groupLeader
);
231 hints
->flags
|= IconPixmapHint
|IconMaskHint
;
232 hints
->icon_pixmap
= icon
->pixmap
;
233 hints
->icon_mask
= icon
->mask
;
235 XSetWMHints(scr
->display
, scr
->groupLeader
, hints
);
242 WMGetApplicationIconImage(WMScreen
*scr
)
244 return scr
->applicationIcon
;
249 WMSetApplicationHasAppIcon(WMScreen
*scr
, Bool flag
)
251 scr
->aflags
.hasAppIcon
= flag
;
256 W_InitApplication(WMScreen
*scr
)
259 XClassHint
*classHint
;
262 leader
= XCreateSimpleWindow(scr
->display
, scr
->rootWin
, -1, -1,
265 if (!scr
->aflags
.simpleApplication
) {
266 classHint
= XAllocClassHint();
267 classHint
->res_name
= "groupLeader";
268 classHint
->res_class
= WMApplication
.applicationName
;
269 XSetClassHint(scr
->display
, leader
, classHint
);
272 XSetCommand(scr
->display
, leader
, WMApplication
.argv
,
275 hints
= XAllocWMHints();
277 hints
->flags
= WindowGroupHint
;
278 hints
->window_group
= leader
;
280 if (scr
->applicationIcon
) {
281 hints
->flags
|= IconPixmapHint
;
282 hints
->icon_pixmap
= scr
->applicationIcon
->pixmap
;
283 if (scr
->applicationIcon
->mask
) {
284 hints
->flags
|= IconMaskHint
;
285 hints
->icon_mask
= scr
->applicationIcon
->mask
;
289 XSetWMHints(scr
->display
, leader
, hints
);
293 scr
->groupLeader
= leader
;