[Nautilus-list] Bad Hack (tm) for detecting kdesktop
- From: Havoc Pennington <hp redhat com>
- To: nautilus-list eazel com
- Subject: [Nautilus-list] Bad Hack (tm) for detecting kdesktop
- Date: 22 Aug 2001 15:25:18 -0400
Hi,
This makes me cringe a bit, but.
Havoc
Index: src/nautilus-application.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-application.c,v
retrieving revision 1.155.2.2
diff -u -p -u -r1.155.2.2 nautilus-application.c
--- src/nautilus-application.c 2001/08/14 20:22:31 1.155.2.2
+++ src/nautilus-application.c 2001/08/22 19:10:45
@@ -97,6 +97,7 @@ static void volume_unmounted_ca
NautilusApplication *application);
static void update_session (gpointer callback_data);
static void init_session (void);
+static gboolean check_for_kdesktop (void);
EEL_DEFINE_CLASS_BOILERPLATE (NautilusApplication, nautilus_application, BONOBO_OBJECT_TYPE)
@@ -605,6 +606,10 @@ nautilus_application_startup (NautilusAp
} else if (restart_shell) {
Nautilus_Shell_restart (shell, &ev);
} else {
+ /* If KDE desktop is running, then force no_desktop */
+ if (check_for_kdesktop ())
+ no_desktop = TRUE;
+
if (!no_desktop && eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_DESKTOP)) {
Nautilus_Shell_start_desktop (shell, &ev);
}
@@ -996,4 +1001,137 @@ init_session (void)
update_session, client);
update_session (client);
+}
+
+static gboolean
+get_self_typed_prop (Window xwindow,
+ Atom atom,
+ gulong *val)
+{
+ Atom type;
+ int format;
+ gulong nitems;
+ gulong bytes_after;
+ gulong *num;
+ int err;
+
+ gdk_error_trap_push ();
+ type = None;
+ XGetWindowProperty (gdk_display,
+ xwindow,
+ atom,
+ 0, G_MAXLONG,
+ False, atom, &type, &format, &nitems,
+ &bytes_after, (guchar **)&num);
+
+ err = gdk_error_trap_pop ();
+ if (err != Success)
+ {
+ return FALSE;
+ }
+
+ if (type != atom)
+ {
+ return FALSE;
+ }
+
+ if (val)
+ *val = *num;
+
+ XFree (num);
+
+ return TRUE;
+}
+
+static gboolean
+has_wm_state (Window xwindow)
+{
+ return get_self_typed_prop (xwindow,
+ XInternAtom (gdk_display, "WM_STATE", False),
+ NULL);
+}
+
+static gboolean
+look_for_kdesktop_recursive (Window xwindow)
+{
+
+ Window ignored1, ignored2;
+ Window *children;
+ unsigned int n_children;
+ 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]