Re: How to detect if gnome is running
- From: Havoc Pennington <hp redhat com>
- To: Ben Campbell <ben campbell ntlworld com>
- Cc: gnome-devel-list gnome org
- Subject: Re: How to detect if gnome is running
- Date: 17 Sep 2001 13:17:32 -0400
Ben Campbell <ben campbell ntlworld com> writes:
> Is there any good way to detect if the user is currently running a Gnome
> desktop?
People can do things like mix-and-match hunks of GNOME and KDE, so
it's not really possible, no. Your only real option is to try and
detect some specific GNOME program - the panel maybe?
But however you do that will be a scary hack.
A scary hack to check for kdesktop is attached, you could look for any
other toplevel window in the same way. It's pretty darn broken though,
so I would be reluctant to put it in an app if you can think of any
better UI.
Havoc
static gboolean
look_for_kdesktop_recursive (Window xwindow)
{
Window ignored1, ignored2;
Window *children;
unsigned int n_children;
unsigned int i;
gboolean retval;
/* If WM_STATE is set, this is a managed client, so look
* for the class hint and end recursion. Otherwise,
* this is probably just a WM frame, so keep recursing.
*/
if (has_wm_state (xwindow)) {
XClassHint ch;
gdk_error_trap_push ();
ch.res_name = NULL;
ch.res_class = NULL;
XGetClassHint (gdk_display, xwindow, &ch);
gdk_error_trap_pop ();
if (ch.res_name)
XFree (ch.res_name);
if (ch.res_class) {
if (strcmp (ch.res_class, "kdesktop") == 0) {
XFree (ch.res_class);
return TRUE;
}
else
XFree (ch.res_class);
}
return FALSE;
}
retval = FALSE;
gdk_error_trap_push ();
XQueryTree (gdk_display,
xwindow,
&ignored1, &ignored2, &children, &n_children);
if (gdk_error_trap_pop ()) {
return FALSE;
}
i = 0;
while (i < n_children) {
if (look_for_kdesktop_recursive (children[i])) {
retval = TRUE;
break;
}
++i;
}
if (children)
XFree (children);
return retval;
}
static gboolean
check_for_kdesktop (void)
{
/* FIXME this is a pretty lame hack, should be replaced
* eventually with e.g. a requirement that desktop managers
* support a manager selection, ICCCM sec 2.8
*/
return look_for_kdesktop_recursive (GDK_ROOT_WINDOW ());
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]