]> Dogcows Code - chaz/openbox/commitdiff
add a function client_is_oldfullscreen() that determines if a window is an "oldschool...
authorDana Jansens <danakj@orodu.net>
Mon, 1 Mar 2010 21:30:06 +0000 (16:30 -0500)
committerDana Jansens <danakj@orodu.net>
Mon, 1 Mar 2010 21:32:27 +0000 (16:32 -0500)
openbox/client.c
openbox/client.h
openbox/event.c
openbox/screen.c
openbox/screen.h

index 83ea46f15d9a68402559f9002458d6496c4f72b9..e64fd49c2e0b4a890f852cca627f40e5fabeae85 100644 (file)
@@ -203,7 +203,6 @@ void client_manage(Window window, ObPrompt *prompt)
     ObAppSettings *settings;
     gboolean transient = FALSE;
     Rect place;
-    Rect const *monitor, *allmonitors;
     Time launch_time, map_time;
     guint32 user_time;
     gboolean obplaced;
@@ -312,8 +311,6 @@ void client_manage(Window window, ObPrompt *prompt)
 
     /* where the frame was placed is where the window was originally */
     place = self->area;
-    monitor = screen_physical_area_monitor(screen_find_monitor(&place));
-    allmonitors = screen_physical_area_all_monitors();
 
     /* figure out placement for the window if the window is new */
     if (ob_state() == OB_STATE_RUNNING) {
@@ -339,8 +336,7 @@ void client_manage(Window window, ObPrompt *prompt)
            a strut there */
         if (!obplaced && place.x == 0 && place.y == 0 &&
             /* oldschool fullscreen windows are allowed */
-            !(self->decorations == 0 && (RECT_EQUAL(place, *monitor) ||
-                                         RECT_EQUAL(place, *allmonitors))))
+            !client_is_oldfullscreen(self, &place))
         {
             Rect *r;
 
@@ -382,9 +378,7 @@ void client_manage(Window window, ObPrompt *prompt)
                                   fit inside the struts (fixes Acroread, which
                                   makes its fullscreen window fit the screen
                                   but it is not USSize'd or USPosition'd) */
-                               !(self->decorations == 0 &&
-                                 (RECT_EQUAL(place, *monitor) ||
-                                  RECT_EQUAL(place, *allmonitors))))));
+                               !client_is_oldfullscreen(self, &place))));
     }
 
     /* if the window isn't user-sized, then make it fit inside
@@ -404,8 +398,7 @@ void client_manage(Window window, ObPrompt *prompt)
           /* don't shrink oldschool fullscreen windows to fit inside the
              struts (fixes Acroread, which makes its fullscreen window
              fit the screen but it is not USSize'd or USPosition'd) */
-          !(self->decorations == 0 && (RECT_EQUAL(place, *monitor) ||
-                                       RECT_EQUAL(place, *allmonitors))))))
+          !client_is_oldfullscreen(self, &place))))
     {
         Rect *a = screen_area(self->desktop, SCREEN_AREA_ONE_MONITOR, &place);
 
@@ -443,9 +436,6 @@ void client_manage(Window window, ObPrompt *prompt)
     client_apply_startup_state(self, place.x, place.y,
                                place.width, place.height);
 
-    monitor = NULL;
-    allmonitors = NULL;
-
     ob_debug_type(OB_DEBUG_FOCUS, "Going to try activate new window? %s",
                   activate ? "yes" : "no");
     if (activate) {
@@ -2475,6 +2465,24 @@ gboolean client_has_parent(ObClient *self)
     return self->parents != NULL;
 }
 
+gboolean client_is_oldfullscreen(const ObClient const *self,
+                                 const Rect const *area)
+{
+    Rect const *monitor, *allmonitors;
+
+    /* No decorations and fills the monitor = oldskool fullscreen.
+       But not for maximized windows.
+    */
+
+    if (self->decorations || self->max_horz || self->max_vert) return FALSE;
+
+    monitor = screen_physical_area_monitor(screen_find_monitor(area));
+    allmonitors = screen_physical_area_all_monitors();
+
+    return (RECT_EQUAL(*area, *monitor) ||
+            RECT_EQUAL(*area, *allmonitors));
+}
+
 static ObStackingLayer calc_layer(ObClient *self)
 {
     ObStackingLayer l;
@@ -2490,13 +2498,7 @@ static ObStackingLayer calc_layer(ObClient *self)
         else l = OB_STACKING_LAYER_ABOVE;
     }
     else if ((self->fullscreen ||
-              /* No decorations and fills the monitor = oldskool fullscreen.
-                 But not for maximized windows.
-              */
-              (self->decorations == 0 &&
-               !(self->max_horz && self->max_vert) &&
-               (RECT_EQUAL(self->area, *monitor) ||
-                RECT_EQUAL(self->area, *allmonitors)))) &&
+              client_is_oldfullscreen(self, &self->area)) &&
              /* you are fullscreen while you or your children are focused.. */
              (client_focused(self) || client_search_focus_tree(self) ||
               /* you can be fullscreen if you're on another desktop */
@@ -2990,8 +2992,7 @@ void client_try_configure(ObClient *self, gint *x, gint *y, gint *w, gint *h,
 void client_configure(ObClient *self, gint x, gint y, gint w, gint h,
                       gboolean user, gboolean final, gboolean force_reply)
 {
-    Rect oldframe;
-    gint oldw, oldh;
+    Rect oldframe, oldclient;
     gboolean send_resize_client;
     gboolean moved = FALSE, resized = FALSE, rootmoved = FALSE;
     gboolean fmoved, fresized;
@@ -3011,9 +3012,8 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h,
     moved = (x != self->area.x || y != self->area.y);
     resized = (w != self->area.width || h != self->area.height);
 
-    oldw = self->area.width;
-    oldh = self->area.height;
     oldframe = self->frame->area;
+    oldclient = self->area;
     RECT_SET(self->area, x, y, w, h);
 
     /* for app-requested resizes, always resize if 'resized' is true.
@@ -3024,10 +3024,10 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h,
                                     (resized && config_resize_redraw))));
 
     /* if the client is enlarging, then resize the client before the frame */
-    if (send_resize_client && (w > oldw || h > oldh)) {
+    if (send_resize_client && (w > oldclient.width || h > oldclient.height)) {
         XMoveResizeWindow(obt_display, self->window,
                           self->frame->size.left, self->frame->size.top,
-                          MAX(w, oldw), MAX(h, oldh));
+                          MAX(w, oldclient.width), MAX(h, oldclient.height));
         frame_adjust_client_area(self->frame);
     }
 
@@ -3115,7 +3115,8 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h,
        both of these resize sections may run, because the top one only resizes
        in the direction that is growing
      */
-    if (send_resize_client && (w <= oldw || h <= oldh)) {
+    if (send_resize_client && (w <= oldclient.width || h <= oldclient.height))
+    {
         frame_adjust_client_area(self->frame);
         XMoveResizeWindow(obt_display, self->window,
                           self->frame->size.left, self->frame->size.top, w, h);
@@ -3124,9 +3125,13 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h,
     XFlush(obt_display);
 
     /* if it moved between monitors, then this can affect the stacking
-       layer of this window or others - for fullscreen windows */
+       layer of this window or others - for fullscreen windows.
+       also if it changed to/from oldschool fullscreen then its layer may
+       change */
     if (screen_find_monitor(&self->frame->area) !=
-        screen_find_monitor(&oldframe))
+        screen_find_monitor(&oldframe) ||
+        (final && (client_is_oldfullscreen(self, &oldclient) !=
+                   client_is_oldfullscreen(self, &self->area))))
     {
         client_calc_layer(self);
     }
index 5830066efd5c78508feda3864190052cb360fe05..47da397ada526e98aed8613580eda41a9a9a3010 100644 (file)
@@ -490,6 +490,11 @@ void client_find_resize_directional(ObClient *self, ObDirection side,
 */
 void client_fullscreen(ObClient *self, gboolean fs);
 
+/*! Determine if the window, using the given client-area, would be considered
+  as an "oldschool fullscreen" window, that is, if it is filling a whole
+  monitor. */
+gboolean client_is_oldfullscreen(const ObClient const *self, const Rect *area);
+
 /*! Iconifies or uniconifies the client window
   @param iconic true if the window should be iconified; false if it should be
                 restored.
index 7596fe3e4175b91548b9dcd862ae2c706a8d3acf..c4af7b232753df61f332c3b09772af24454aafcd 100644 (file)
@@ -1256,15 +1256,9 @@ static void event_handle_client(ObClient *client, XEvent *e)
         g_print("x %d y %d grav %d %d\n", x, y, client->gravity, NorthWestGravity);
         if (x == 0 && y == 0 && client->gravity == NorthWestGravity) {
             const Rect to = { x, y, w, h };
-            Rect const *monitor, *allmonitors;
-            monitor = screen_physical_area_monitor(client_monitor(client));
-            allmonitors = screen_physical_area_all_monitors();
 
             /* oldschool fullscreen windows are allowed */
-            if (!(client->decorations == 0 &&
-                  (RECT_EQUAL(to, *monitor) ||
-                   RECT_EQUAL(to, *allmonitors))))
-            {
+            if (!client_is_oldfullscreen(client, &to)) {
                 Rect *r;
 
                 r = screen_area(client->desktop, SCREEN_AREA_ALL_MONITORS,
index a3589108300ca8940a0f428e6d3228f903dd2d4f..d69b2447cec1499a99c329a50112076675c53b55 100644 (file)
@@ -1617,7 +1617,7 @@ Rect* screen_area(guint desktop, guint head, Rect *search)
     return a;
 }
 
-guint screen_find_monitor(Rect *search)
+guint screen_find_monitor(const Rect const *search)
 {
     guint i;
     guint most = screen_num_monitors;
index 0c1dc4692c578a7215dc3577ca381b3b298379a6..0f796871613ccba96f3bd3896c12bf96781c0ffa 100644 (file)
@@ -148,7 +148,7 @@ gboolean screen_physical_area_monitor_contains(guint head, Rect *search);
     area of the part of the rectable on each monitor.  The number of the
     monitor containing the greatest area of the rectangle is returned.
 */
-guint screen_find_monitor(Rect *search);
+guint screen_find_monitor(const Rect const *search);
 
 /*! Finds the monitor which contains the point @x, @y */
 guint screen_find_monitor_point(guint x, guint y);
This page took 0.041022 seconds and 4 git commands to generate.