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_ReadConfigurations(void);
28 extern void W_InitNotificationCenter(void);
31 typedef struct W_Application
{
32 char *applicationName
;
39 struct W_Application WMApplication
;
42 char *_WINGS_progname
= NULL
;
47 W_ApplicationInitialized(void)
49 return _WINGS_progname
!=NULL
;
54 WMInitializeApplication(char *applicationName
, int *argc
, char **argv
)
60 assert(applicationName
!=NULL
);
62 _WINGS_progname
= argv
[0];
64 WMApplication
.applicationName
= wstrdup(applicationName
);
65 WMApplication
.argc
= *argc
;
67 WMApplication
.argv
= wmalloc((*argc
+1)*sizeof(char*));
68 for (i
=0; i
<*argc
; i
++) {
69 WMApplication
.argv
[i
] = wstrdup(argv
[i
]);
71 WMApplication
.argv
[i
] = NULL
;
73 /* initialize notification center */
74 W_InitNotificationCenter();
76 /* read general configuration data for WINGs */
77 W_ReadConfigurations();
82 WMSetResourcePath(char *path
)
84 if (WMApplication
.resourcePath
)
85 free(WMApplication
.resourcePath
);
86 WMApplication
.resourcePath
= wstrdup(path
);
91 WMGetApplicationName()
93 return WMApplication
.applicationName
;
98 checkFile(char *path
, char *folder
, char *ext
, char *resource
)
103 extralen
= (ext
? strlen(ext
) : 0) + (folder
? strlen(folder
) : 0) + 4;
104 ret
= wmalloc(strlen(path
)+strlen(resource
)+extralen
+8);
115 strcat(ret
, resource
);
117 if (access(ret
, F_OK
)!=0) {
127 WMPathForResourceOfType(char *resource
, char *ext
)
134 * Paths are searched in this order:
137 * - GNUSTEP_USER_ROOT/Apps/ApplicationName.app/ext
138 * - ~/GNUstep/Apps/ApplicationName.app/ext
139 * - GNUSTEP_LOCAL_ROOT/Apps/ApplicationName.app/ext
140 * - /usr/local/GNUstep/Apps/ApplicationName.app/ext
141 * - GNUSTEP_SYSTEM_ROOT/Apps/ApplicationName.app/ext
142 * - /usr/GNUstep/Apps/ApplicationName.app/ext
145 if (WMApplication
.resourcePath
) {
146 path
= checkFile(WMApplication
.resourcePath
, NULL
, ext
, resource
);
151 if (WMApplication
.argv
[0]) {
152 tmp
= wstrdup(WMApplication
.argv
[0]);
154 while (i
> 0 && tmp
[i
]!='/')
158 path
= checkFile(tmp
, NULL
, ext
, resource
);
167 appdir
= wmalloc(strlen(WMApplication
.applicationName
)+8);
168 sprintf(appdir
, "Apps/%s.app", WMApplication
.applicationName
);
170 if (getenv("GNUSTEP_USER_ROOT")) {
171 path
= checkFile(getenv("GNUSTEP_USER_ROOT"), appdir
, ext
, resource
);
178 tmp
= wusergnusteppath();
180 path
= checkFile(tmp
, appdir
, ext
, resource
);
188 if (getenv("GNUSTEP_LOCAL_ROOT")) {
189 path
= checkFile(getenv("GNUSTEP_LOCAL_ROOT"), appdir
, ext
, resource
);
196 path
= checkFile("/usr/local/GNUstep", appdir
, ext
, resource
);
203 if (getenv("GNUSTEP_SYSTEM_ROOT")) {
204 path
= checkFile(getenv("GNUSTEP_SYSTEM_ROOT"), appdir
, ext
, resource
);
211 path
= checkFile("/usr/GNUstep", appdir
, ext
, resource
);
221 /********************* WMScreen related stuff ********************/
225 WMSetApplicationIconImage(WMScreen
*scr
, WMPixmap
*icon
)
227 if (scr
->applicationIcon
)
228 WMReleasePixmap(scr
->applicationIcon
);
230 scr
->applicationIcon
= WMRetainPixmap(icon
);
232 if (scr
->groupLeader
) {
235 hints
= XGetWMHints(scr
->display
, scr
->groupLeader
);
236 hints
->flags
|= IconPixmapHint
|IconMaskHint
;
237 hints
->icon_pixmap
= icon
->pixmap
;
238 hints
->icon_mask
= icon
->mask
;
240 XSetWMHints(scr
->display
, scr
->groupLeader
, hints
);
247 WMGetApplicationIconImage(WMScreen
*scr
)
249 return scr
->applicationIcon
;
254 WMSetApplicationHasAppIcon(WMScreen
*scr
, Bool flag
)
256 scr
->aflags
.hasAppIcon
= flag
;
261 W_InitApplication(WMScreen
*scr
)
264 XClassHint
*classHint
;
267 leader
= XCreateSimpleWindow(scr
->display
, scr
->rootWin
, -1, -1,
270 if (!scr
->aflags
.simpleApplication
) {
271 classHint
= XAllocClassHint();
272 classHint
->res_name
= "groupLeader";
273 classHint
->res_class
= WMApplication
.applicationName
;
274 XSetClassHint(scr
->display
, leader
, classHint
);
277 XSetCommand(scr
->display
, leader
, WMApplication
.argv
,
280 hints
= XAllocWMHints();
282 hints
->flags
= WindowGroupHint
;
283 hints
->window_group
= leader
;
285 if (scr
->applicationIcon
) {
286 hints
->flags
|= IconPixmapHint
;
287 hints
->icon_pixmap
= scr
->applicationIcon
->pixmap
;
288 if (scr
->applicationIcon
->mask
) {
289 hints
->flags
|= IconMaskHint
;
290 hints
->icon_mask
= scr
->applicationIcon
->mask
;
294 XSetWMHints(scr
->display
, leader
, hints
);
298 scr
->groupLeader
= leader
;