]> Dogcows Code - chaz/openbox/blobdiff - openbox/window.c
Merge branch 'master' into chaz
[chaz/openbox] / openbox / window.c
index 28b08571375be05152be7a4ac8d308962611b5ed..51806f9c325f346c2dbbf40730b50245054bdc77 100644 (file)
 #include "client.h"
 #include "frame.h"
 #include "openbox.h"
+#include "prompt.h"
 #include "debug.h"
 #include "grab.h"
+#include "obt/prop.h"
+#include "obt/xqueue.h"
 
 static GHashTable *window_map;
 
@@ -57,6 +60,8 @@ Window window_top(ObWindow *self)
         return WINDOW_AS_CLIENT(self)->frame->window;
     case OB_WINDOW_CLASS_INTERNAL:
         return WINDOW_AS_INTERNAL(self)->window;
+    case OB_WINDOW_CLASS_PROMPT:
+        return WINDOW_AS_PROMPT(self)->super.window;
     }
     g_assert_not_reached();
     return None;
@@ -72,6 +77,10 @@ ObStackingLayer window_layer(ObWindow *self)
     case OB_WINDOW_CLASS_MENUFRAME:
     case OB_WINDOW_CLASS_INTERNAL:
         return OB_STACKING_LAYER_INTERNAL;
+    case OB_WINDOW_CLASS_PROMPT:
+        /* not used directly for stacking, prompts are managed as clients */
+        g_assert_not_reached();
+        break;
     }
     g_assert_not_reached();
     return None;
@@ -139,9 +148,15 @@ void window_manage_all(void)
     if (children) XFree(children);
 }
 
+static gboolean check_unmap(XEvent *e, gpointer data)
+{
+    const Window win = *(Window*)data;
+    return ((e->type == DestroyNotify && e->xdestroywindow.window == win) ||
+            (e->type == UnmapNotify && e->xunmap.window == win));
+}
+
 void window_manage(Window win)
 {
-    XEvent e;
     XWindowAttributes attrib;
     gboolean no_manage = FALSE;
     gboolean is_dockapp = FALSE;
@@ -151,15 +166,11 @@ void window_manage(Window win)
 
     /* check if it has already been unmapped by the time we started
        mapping. the grab does a sync so we don't have to here */
-    if (XCheckTypedWindowEvent(obt_display, win, DestroyNotify, &e) ||
-        XCheckTypedWindowEvent(obt_display, win, UnmapNotify, &e))
-    {
-        XPutBackEvent(obt_display, &e);
-        ob_debug("Trying to manage unmapped window. Aborting that.\n");
+    if (xqueue_exists_local(check_unmap, &win)) {
+        ob_debug("Trying to manage unmapped window. Aborting that.");
         no_manage = TRUE;
     }
-
-    if (!XGetWindowAttributes(obt_display, win, &attrib))
+    else if (!XGetWindowAttributes(obt_display, win, &attrib))
         no_manage = TRUE;
     else {
         XWMHints *wmhints;
@@ -176,11 +187,25 @@ void window_manage(Window win)
             }
             XFree(wmhints);
         }
+        /* This is a new method to declare that a window is a dockapp, being
+           implemented by Windowmaker, to alleviate pain in writing GTK+
+           dock apps.
+           http://thread.gmane.org/gmane.comp.window-managers.openbox/4881
+        */
+        if (!is_dockapp) {
+            gchar **ss;
+            if (OBT_PROP_GETSS_TYPE(win, WM_CLASS, STRING_NO_CC, &ss))
+            {
+                if (ss[0] && ss[1] && strcmp(ss[1], "DockApp") == 0)
+                    is_dockapp = TRUE;
+                g_strfreev(ss);
+            }
+        }
     }
 
     if (!no_manage) {
         if (attrib.override_redirect) {
-            ob_debug("not managing override redirect window 0x%x\n", win);
+            ob_debug("not managing override redirect window 0x%x", win);
             grab_server(FALSE);
         }
         else if (is_dockapp) {
@@ -189,11 +214,11 @@ void window_manage(Window win)
             dock_manage(icon_win, win);
         }
         else
-            client_manage(win);
+            client_manage(win, NULL);
     }
     else {
         grab_server(FALSE);
-        ob_debug("FAILED to manage window 0x%x\n", win);
+        ob_debug("FAILED to manage window 0x%x", win);
     }
 }
 
This page took 0.023017 seconds and 4 git commands to generate.