]> Dogcows Code - chaz/openbox/blobdiff - openbox/screen.c
new least-intrusive focus stealing prevention
[chaz/openbox] / openbox / screen.c
index de3c9fb09b7430e6e527f36c9cfc404b499d488c..79008e75c2ecbe082f62c7cfb84682811ba050ef 100644 (file)
@@ -27,7 +27,6 @@
 #include "moveresize.h"
 #include "config.h"
 #include "screen.h"
-#include "composite.h"
 #include "client.h"
 #include "session.h"
 #include "frame.h"
@@ -108,22 +107,7 @@ static gboolean replace_wm()
             current_wm_sn_owner = None;
     }
 
-    {
-        /* Generate a timestamp */
-        XEvent event;
-
-        XSelectInput(ob_display, screen_support_win, PropertyChangeMask);
-
-        XChangeProperty(ob_display, screen_support_win,
-                        prop_atoms.wm_class, prop_atoms.string,
-                        8, PropModeAppend, NULL, 0);
-        XWindowEvent(ob_display, screen_support_win,
-                     PropertyChangeMask, &event);
-
-        XSelectInput(ob_display, screen_support_win, NoEventMask);
-
-        timestamp = event.xproperty.time;
-    }
+    timestamp = event_get_server_time();
 
     XSetSelectionOwner(ob_display, wm_sn_atom, screen_support_win,
                        timestamp);
@@ -173,12 +157,14 @@ gboolean screen_annex()
 
     /* create the netwm support window */
     attrib.override_redirect = TRUE;
+    attrib.event_mask = PropertyChangeMask;
     screen_support_win = XCreateWindow(ob_display,
                                        RootWindow(ob_display, ob_screen),
                                        -100, -100, 1, 1, 0,
                                        CopyFromParent, InputOutput,
                                        CopyFromParent,
-                                       CWOverrideRedirect, &attrib);
+                                       CWEventMask | CWOverrideRedirect,
+                                       &attrib);
     XMapWindow(ob_display, screen_support_win);
     XLowerWindow(ob_display, screen_support_win);
 
@@ -284,7 +270,9 @@ gboolean screen_annex()
     supported[i++] = prop_atoms.net_moveresize_window;
     supported[i++] = prop_atoms.net_wm_moveresize;
     supported[i++] = prop_atoms.net_wm_user_time;
+/*
     supported[i++] = prop_atoms.net_wm_user_time_window;
+*/
     supported[i++] = prop_atoms.net_frame_extents;
     supported[i++] = prop_atoms.net_request_frame_extents;
     supported[i++] = prop_atoms.net_restack_window;
@@ -491,9 +479,6 @@ void screen_resize()
 
     for (it = client_list; it; it = g_list_next(it))
         client_move_onscreen(it->data, FALSE);
-
-    /* this needs to be setup whenever the root window's size changes */
-    composite_setup_root_window();
 }
 
 void screen_set_num_desktops(guint num)
@@ -536,7 +521,7 @@ void screen_set_num_desktops(guint num)
                 stacking_raise(CLIENT_AS_WINDOW(c));
         }
     }
+
     /* change our struts/area to match (after moving windows) */
     screen_update_areas();
 
@@ -556,7 +541,7 @@ void screen_set_desktop(guint num, gboolean dofocus)
     guint old;
     gulong ignore_start;
     gboolean allow_omni;
-     
+
     g_assert(num < screen_num_desktops);
 
     old = screen_desktop;
@@ -645,8 +630,14 @@ void screen_add_desktop(gboolean current)
 
         for (it = client_list; it; it = g_list_next(it)) {
             ObClient *c = it->data;
-            if (c->desktop != DESKTOP_ALL && c->desktop >= screen_desktop)
+            if (c->desktop != DESKTOP_ALL && c->desktop >= screen_desktop &&
+                /* don't move direct children, they'll be moved with their
+                   parent - which will have to be on the same desktop */
+                !client_direct_parent(c))
+            {
+                ob_debug("moving window %s\n", c->title);
                 client_set_desktop(c, c->desktop+1, FALSE, TRUE);
+            }
         }
     }
 }
@@ -674,9 +665,13 @@ void screen_remove_desktop(gboolean current)
         if (WINDOW_IS_CLIENT(it->data)) {
             ObClient *c = it->data;
             guint d = c->desktop;
-            if (d != DESKTOP_ALL && d >= movedesktop) {
-                client_set_desktop(c, c->desktop - 1, TRUE, TRUE);
+            if (d != DESKTOP_ALL && d >= movedesktop &&
+                /* don't move direct children, they'll be moved with their
+                   parent - which will have to be on the same desktop */
+                !client_direct_parent(c))
+            {
                 ob_debug("moving window %s\n", c->title);
+                client_set_desktop(c, c->desktop - 1, TRUE, TRUE);
             }
             /* raise all the windows that are on the current desktop which
                is being merged */
@@ -1012,7 +1007,7 @@ void screen_update_layout()
     if (PROP_GETA32(RootWindow(ob_display, ob_screen),
                     net_desktop_layout, cardinal, &data, &num)) {
         if (num == 3 || num == 4) {
-            
+
             if (data[0] == prop_atoms.net_wm_orientation_vert)
                 l.orientation = OB_ORIENTATION_VERT;
             else if (data[0] == prop_atoms.net_wm_orientation_horz)
@@ -1094,7 +1089,7 @@ void screen_update_desktop_names()
 void screen_show_desktop(gboolean show, ObClient *show_only)
 {
     GList *it;
-     
+
     if (show == screen_showing_desktop) return; /* no change */
 
     screen_showing_desktop = show;
@@ -1357,7 +1352,7 @@ Rect* screen_area_all_monitors(guint desktop)
 
         g_free(m);
     }
-        
+
     return a;
 }
 #endif
@@ -1549,7 +1544,9 @@ Rect* screen_physical_area_active()
     Rect *a;
     gint x, y;
 
-    if (focus_client)
+    if (moveresize_client)
+        a = screen_physical_area_monitor(client_monitor(focus_client));
+    else if (focus_client)
         a = screen_physical_area_monitor(client_monitor(focus_client));
     else {
         Rect mon;
This page took 0.029659 seconds and 4 git commands to generate.