From 64adc0eeba598cb1469b2140777fba30e3053f0e Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 1 Mar 2010 16:30:06 -0500 Subject: [PATCH] add a function client_is_oldfullscreen() that determines if a window is an "oldschool fullscreen window" or not. use this throughout. and allow oldschool fullscreen windows to move to 0,0 even with a strut there. --- openbox/client.c | 63 ++++++++++++++++++++++++++---------------------- openbox/client.h | 5 ++++ openbox/event.c | 8 +----- openbox/screen.c | 2 +- openbox/screen.h | 2 +- 5 files changed, 42 insertions(+), 38 deletions(-) diff --git a/openbox/client.c b/openbox/client.c index 83ea46f1..e64fd49c 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -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); } diff --git a/openbox/client.h b/openbox/client.h index 5830066e..47da397a 100644 --- a/openbox/client.h +++ b/openbox/client.h @@ -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. diff --git a/openbox/event.c b/openbox/event.c index 7596fe3e..c4af7b23 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -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, diff --git a/openbox/screen.c b/openbox/screen.c index a3589108..d69b2447 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -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; diff --git a/openbox/screen.h b/openbox/screen.h index 0c1dc469..0f796871 100644 --- a/openbox/screen.h +++ b/openbox/screen.h @@ -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); -- 2.45.2