]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
don't fallback when a window is hidden right away, it's redundant, we'll get a focuso...
[chaz/openbox] / openbox / client.c
index a51ecfd7c7ed54ce2ba0e094d394b9969cb6f885..24fc2647031d078cf7e0ef2857c91318fd5e715c 100644 (file)
@@ -272,7 +272,7 @@ void client_manage(Window window)
     self->wmstate = WithdrawnState; /* make sure it gets updated first time */
     self->layer = -1;
     self->desktop = screen_num_desktops; /* always an invalid value */
-    self->user_time = ~0; /* maximum value, always newer than the real time */
+    self->user_time = client_last_user_time;
 
     client_get_all(self);
     client_restore_session_state(self);
@@ -414,8 +414,11 @@ void client_manage(Window window)
         else
         {
             /* If time stamp is old, don't steal focus */
-            if (self->user_time && self->user_time < client_last_user_time)
+            if (self->user_time &&
+                !event_time_after(self->user_time, client_last_user_time))
+            {
                 activate = FALSE;
+            }
             /* Don't steal focus from globally active clients.
                I stole this idea from KWin. It seems nice.
              */
@@ -452,7 +455,7 @@ void client_manage(Window window)
     /* this has to happen before we try focus the window, but we want it to
        happen after the client's stacking has been determined or it looks bad
     */
-    client_showhide(self);
+    client_show(self);
 
     /* use client_focus instead of client_activate cuz client_activate does
        stuff like switch desktops etc and I'm not interested in all that when
@@ -2055,6 +2058,33 @@ gboolean client_should_show(ObClient *self)
     return FALSE;
 }
 
+void client_show(ObClient *self)
+{
+
+    if (client_should_show(self)) {
+        frame_show(self->frame);
+    }
+
+    /* According to the ICCCM (sec 4.1.3.1) when a window is not visible, it
+       needs to be in IconicState. This includes when it is on another
+       desktop!
+    */
+    client_change_wm_state(self);
+}
+
+void client_hide(ObClient *self)
+{
+    if (!client_should_show(self)) {
+        frame_hide(self->frame);
+    }
+
+    /* According to the ICCCM (sec 4.1.3.1) when a window is not visible, it
+       needs to be in IconicState. This includes when it is on another
+       desktop!
+    */
+    client_change_wm_state(self);
+}
+
 void client_showhide(ObClient *self)
 {
 
@@ -2063,10 +2093,6 @@ void client_showhide(ObClient *self)
     }
     else {
         frame_hide(self->frame);
-
-        /* Fall back focus since we're disappearing */
-        if (focus_client == self)
-            client_unfocus(self);
     }
 
     /* According to the ICCCM (sec 4.1.3.1) when a window is not visible, it
@@ -2131,8 +2157,12 @@ static void client_apply_startup_state(ObClient *self, gint x, gint y)
         pos = TRUE;
     }
 
-    /* if the client didn't get positioned yet, then do so now */
-    if (!pos && (ox != x || oy != y)) {
+    /* if the client didn't get positioned yet, then do so now
+       call client_move even if the window is not being moved anywhere, because
+       when we reparent it and decorate it, it is getting moved and we need to
+       be telling it so with a ConfigureNotify event.
+    */
+    if (!pos) {
         /* use the saved position */
         self->area.x = ox;
         self->area.y = oy;
@@ -2160,58 +2190,7 @@ void client_try_configure(ObClient *self, ObCorner anchor,
        the updated frame dimensions. */
     frame_adjust_area(self->frame, TRUE, TRUE, TRUE);
 
-    /* gets the frame's position */
-    frame_client_gravity(self->frame, x, y);
-
-    /* these positions are frame positions, not client positions */
-
-    /* set the size and position if fullscreen */
-    if (self->fullscreen) {
-        Rect *a;
-        guint i;
-
-        i = screen_find_monitor(&desired_area);
-        a = screen_physical_area_monitor(i);
-
-        *x = a->x;
-        *y = a->y;
-        *w = a->width;
-        *h = a->height;
-
-        user = FALSE; /* ignore that increment etc shit when in fullscreen */
-    } else {
-        Rect *a;
-        guint i;
-
-        i = screen_find_monitor(&desired_area);
-        a = screen_area_monitor(self->desktop, i);
-
-        /* set the size and position if maximized */
-        if (self->max_horz) {
-            *x = a->x;
-            *w = a->width - self->frame->size.left - self->frame->size.right;
-        }
-        if (self->max_vert) {
-            *y = a->y;
-            *h = a->height - self->frame->size.top - self->frame->size.bottom;
-        }
-    }
-
-    /* gets the client's position */
-    frame_frame_gravity(self->frame, x, y);
-
-    /* these override the above states! if you cant move you can't move! */
-    if (user) {
-        if (!(self->functions & OB_CLIENT_FUNC_MOVE)) {
-            *x = self->area.x;
-            *y = self->area.y;
-        }
-        if (!(self->functions & OB_CLIENT_FUNC_RESIZE)) {
-            *w = self->area.width;
-            *h = self->area.height;
-        }
-    }
-
+    /* work within the prefered sizes given by the window */
     if (!(*w == self->area.width && *h == self->area.height)) {
         gint basew, baseh, minw, minh;
 
@@ -2294,6 +2273,62 @@ void client_try_configure(ObClient *self, ObCorner anchor,
         *h += self->base_size.height;
     }
 
+    /* gets the frame's position */
+    frame_client_gravity(self->frame, x, y);
+
+    /* these positions are frame positions, not client positions */
+
+    /* set the size and position if fullscreen */
+    if (self->fullscreen) {
+        Rect *a;
+        guint i;
+
+        i = screen_find_monitor(&desired_area);
+        a = screen_physical_area_monitor(i);
+
+        *x = a->x;
+        *y = a->y;
+        *w = a->width;
+        *h = a->height;
+
+        user = FALSE; /* ignore if the client can't be moved/resized when it
+                         is entering fullscreen */
+    } else if (self->max_horz || self->max_vert) {
+        Rect *a;
+        guint i;
+
+        i = screen_find_monitor(&desired_area);
+        a = screen_area_monitor(self->desktop, i);
+
+        /* set the size and position if maximized */
+        if (self->max_horz) {
+            *x = a->x;
+            *w = a->width - self->frame->size.left - self->frame->size.right;
+        }
+        if (self->max_vert) {
+            *y = a->y;
+            *h = a->height - self->frame->size.top - self->frame->size.bottom;
+        }
+
+        /* maximizing is not allowed if the user can't move+resize the window
+         */
+    }
+
+    /* gets the client's position */
+    frame_frame_gravity(self->frame, x, y);
+
+    /* these override the above states! if you cant move you can't move! */
+    if (user) {
+        if (!(self->functions & OB_CLIENT_FUNC_MOVE)) {
+            *x = self->area.x;
+            *y = self->area.y;
+        }
+        if (!(self->functions & OB_CLIENT_FUNC_RESIZE)) {
+            *w = self->area.width;
+            *h = self->area.height;
+        }
+    }
+
     g_assert(*w > 0);
     g_assert(*h > 0);
 
@@ -2960,11 +2995,6 @@ gboolean client_focus(ObClient *self)
     /* choose the correct target */
     self = client_focus_target(self);
 
-#if 0
-    if (!client_validate(self))
-        return FALSE;
-#endif
-
     if (!client_can_focus(self)) {
         if (!self->frame->visible) {
             /* update the focus lists */
@@ -3031,9 +3061,11 @@ void client_activate(ObClient *self, gboolean here, gboolean user)
              "source=%s\n",
              self->window, event_curtime, client_last_user_time,
              (user ? "user" : "application"));
-    if (!user && event_curtime && event_curtime < client_last_user_time)
+    if (!user && event_curtime &&
+        !event_time_after(event_curtime, client_last_user_time))
+    {
         client_hilite(self, TRUE);
-    else {
+    else {
         if (client_normal(self) && screen_showing_desktop)
             screen_show_desktop(FALSE);
         if (self->iconic)
This page took 0.025504 seconds and 4 git commands to generate.