]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
when you focus a window, bring any modal children it has to that desktop
[chaz/openbox] / openbox / client.c
index 39cd27dca466f420d2cd101306622f055d0a72fb..477575a8cf9817717e33bd8ca395d5103c35a5f6 100644 (file)
@@ -277,7 +277,7 @@ void client_manage(Window window)
         XFree(wmhint);
     }
 
-    ob_debug("Managing window: %lx\n", window);
+    ob_debug("Managing window: 0x%lx\n", window);
 
     /* choose the events we want to receive on the CLIENT window */
     attrib_set.event_mask = CLIENT_EVENTMASK;
@@ -400,15 +400,17 @@ void client_manage(Window window)
             a.height -= self->frame->size.top + self->frame->size.bottom;
 
             /* fit the window inside the area */
-            self->area.width = MIN(self->area.width, a.width);
-            self->area.height = MIN(self->area.height, a.height);
+            if (self->area.width > a.width || self->area.height > a.height) {
+                self->area.width = MIN(self->area.width, a.width);
+                self->area.height = MIN(self->area.height, a.height);
 
-            ob_debug("setting window size to %dx%d\n",
-                     self->area.width, self->area.height);
+                ob_debug("setting window size to %dx%d\n",
+                         self->area.width, self->area.height);
 
-            /* adjust the frame to the client's new size */
-            frame_adjust_area(self->frame, FALSE, TRUE, FALSE);
-            frame_adjust_client_area(self->frame);
+                /* adjust the frame to the client's new size */
+                frame_adjust_area(self->frame, FALSE, TRUE, FALSE);
+                frame_adjust_client_area(self->frame);
+            }
         }
 
         /* make sure the window is visible. */
@@ -425,8 +427,7 @@ void client_manage(Window window)
                                 it is up to the placement routines to avoid
                                 the xinerama divides) */
                              transient ||
-                             (((self->positioned & PPosition) &&
-                               !(self->positioned & USPosition)) &&
+                             (!(self->positioned & USPosition) &&
                               client_normal(self) &&
                               !self->session));
     }
@@ -1108,8 +1109,8 @@ static void client_get_area(ObClient *self)
     POINT_SET(self->root_pos, wattrib.x, wattrib.y);
     self->border_width = wattrib.border_width;
 
-    ob_debug("client area: %d %d  %d %d\n", wattrib.x, wattrib.y,
-             wattrib.width, wattrib.height);
+    ob_debug("client area: %d %d  %d %d  bw %d\n", wattrib.x, wattrib.y,
+             wattrib.width, wattrib.height, wattrib.border_width);
 }
 
 static void client_get_desktop(ObClient *self)
@@ -1121,13 +1122,16 @@ static void client_get_desktop(ObClient *self)
             self->desktop = screen_num_desktops - 1;
         else
             self->desktop = d;
+        ob_debug("client requested desktop 0x%x\n", self->desktop); 
     } else {
         gboolean trdesk = FALSE;
 
         if (self->transient_for) {
             if (self->transient_for != OB_TRAN_GROUP) {
-                self->desktop = self->transient_for->desktop;
-                trdesk = TRUE;
+                if (self->transient_for->desktop != DESKTOP_ALL) {
+                    self->desktop = self->transient_for->desktop;
+                    trdesk = TRUE;
+                }
             } else {
                 /* if all the group is on one desktop, then open it on the
                    same desktop */
@@ -1533,7 +1537,16 @@ void client_get_colormap(ObClient *self)
 
 void client_update_colormap(ObClient *self, Colormap colormap)
 {
-    self->colormap = colormap;
+    if (colormap == self->colormap) return;
+
+    ob_debug("Setting client %s colormap: 0x%x\n", self->title, colormap);
+
+    if (client_focused(self)) {
+        screen_install_colormap(self, FALSE); /* uninstall old one */
+        self->colormap = colormap;
+        screen_install_colormap(self, FALSE); /* install new one */
+    } else
+        self->colormap = colormap;
 }
 
 void client_update_normal_hints(ObClient *self)
@@ -1800,9 +1813,6 @@ static void client_change_allowed_actions(ObClient *self)
 
 void client_reconfigure(ObClient *self)
 {
-    /* by making this pass FALSE for user, we avoid the emacs event storm where
-       every configurenotify causes an update in its normal hints, i think this
-       is generally what we want anyways... */
     client_configure(self, self->area.x, self->area.y,
                      self->area.width, self->area.height,
                      self->border_width, FALSE, TRUE);
@@ -2819,9 +2829,15 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h, gint b,
 
     /* if the client is enlarging, then resize the client before the frame */
     if (send_resize_client && (w > oldw || h > oldh)) {
-        XMoveResizeWindow(ob_display, self->window,
-                          -self->border_width, -self->border_width,
-                          MAX(w, oldw), MAX(h, oldh));
+        XWindowChanges changes;
+        changes.x = -self->border_width;
+        changes.y = -self->border_width;
+        changes.width = MAX(w, oldw);
+        changes.height = MAX(h, oldh);
+        changes.border_width = self->border_width;
+        XConfigureWindow(ob_display, self->window,
+                         CWX|CWY|CWWidth|CWHeight|CWBorderWidth,
+                         &changes);
         /* resize the plate to show the client padding color underneath */
         frame_adjust_client_area(self->frame);
     }
@@ -2867,21 +2883,28 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h, gint b,
         event.xconfigure.width = w;
         event.xconfigure.height = h;
         event.xconfigure.border_width = self->border_width;
-        event.xconfigure.above = self->frame->plate;
+        event.xconfigure.above = None;
         event.xconfigure.override_redirect = FALSE;
         XSendEvent(event.xconfigure.display, event.xconfigure.window,
                    FALSE, StructureNotifyMask, &event);
     }
 
     /* if the client is shrinking, then resize the frame before the client */
-    if (send_resize_client && (w <= oldw || h <= oldh)) {
+    if (send_resize_client && (w <= oldw && h <= oldh)) {
         /* resize the plate to show the client padding color underneath */
         frame_adjust_client_area(self->frame);
 
-        if (send_resize_client)
-            XMoveResizeWindow(ob_display, self->window,
-                              -self->border_width, -self->border_width,
-                              w, h);
+        if (send_resize_client) {
+            XWindowChanges changes;
+            changes.x = -self->border_width;
+            changes.y = -self->border_width;
+            changes.width = w;
+            changes.height = h;
+            changes.border_width = self->border_width;
+            XConfigureWindow(ob_display, self->window,
+                             CWX|CWY|CWWidth|CWHeight|CWBorderWidth,
+                             &changes);
+        }
     }
 
     XFlush(ob_display);
@@ -3440,6 +3463,8 @@ gboolean client_can_focus(ObClient *self)
 
 gboolean client_focus(ObClient *self)
 {
+    client_bring_modal_windows(self);
+
     /* choose the correct target */
     self = client_focus_target(self);
 
@@ -3452,8 +3477,8 @@ gboolean client_focus(ObClient *self)
     }
 
     ob_debug_type(OB_DEBUG_FOCUS,
-                  "Focusing client \"%s\" at time %u\n",
-                  self->title, event_curtime);
+                  "Focusing client \"%s\" (0x%x) at time %u\n",
+                  self->title, self->window, event_curtime);
 
     /* if there is a grab going on, then we need to cancel it. if we move
        focus during the grab, applications will get NotifyWhileGrabbed events
@@ -3491,6 +3516,7 @@ gboolean client_focus(ObClient *self)
 
     xerror_set_ignore(FALSE);
 
+    ob_debug_type(OB_DEBUG_FOCUS, "Error focusing? %d\n", xerror_occured);
     return !xerror_occured;
 }
 
@@ -3558,15 +3584,18 @@ void client_activate(ObClient *self, gboolean here, gboolean user)
         client_hilite(self, TRUE);
 }
 
-static void client_bring_helper_windows_recursive(ObClient *self,
-                                                  guint desktop)
+static void client_bring_windows_recursive(ObClient *self,
+                                           guint desktop,
+                                           gboolean helpers,
+                                           gboolean modals)
 {
     GSList *it;
 
     for (it = self->transients; it; it = g_slist_next(it))
-        client_bring_helper_windows_recursive(it->data, desktop);
+        client_bring_windows_recursive(it->data, desktop, helpers, modals);
 
-    if (client_helper(self) &&
+    if (((helpers && client_helper(self)) ||
+         (modals && self->modal))&&
         self->desktop != desktop && self->desktop != DESKTOP_ALL)
     {
         client_set_desktop(self, desktop, FALSE);
@@ -3575,7 +3604,12 @@ static void client_bring_helper_windows_recursive(ObClient *self,
 
 void client_bring_helper_windows(ObClient *self)
 {
-    client_bring_helper_windows_recursive(self, self->desktop);
+    client_bring_windows_recursive(self, self->desktop, TRUE, FALSE);
+}
+
+void client_bring_modal_windows(ObClient *self)
+{
+    client_bring_windows_recursive(self, self->desktop, FALSE, TRUE);
 }
 
 gboolean client_focused(ObClient *self)
This page took 0.028395 seconds and 4 git commands to generate.