summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2014-05-22 16:48:58 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2014-05-27 15:15:56 -0400
commit3a0af0faaebb1af75925c70ad98e73c61e57639b (patch)
tree71b34f809e7e89d5dd04b21f2a8db667f9b4c0f0
parent0890eaa3fe9fe07f847a2208b3bb895e21a2394f (diff)
downloadmutter-3a0af0faaebb1af75925c70ad98e73c61e57639b.tar.gz
window: Add a meta_window_get_titlebar_rect
-rw-r--r--src/core/constraints.c5
-rw-r--r--src/core/place.c29
-rw-r--r--src/core/window-private.h2
-rw-r--r--src/core/window.c25
4 files changed, 35 insertions, 26 deletions
diff --git a/src/core/constraints.c b/src/core/constraints.c
index 1a054a620..250de4159 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -637,13 +637,10 @@ update_onscreen_requirements (MetaWindow *window,
*/
if (window->frame && window->decorated)
{
- MetaFrameBorders borders;
MetaRectangle titlebar_rect;
- meta_frame_calc_borders (window->frame, &borders);
+ meta_window_get_titlebar_rect (window, &titlebar_rect);
- titlebar_rect = info->current;
- titlebar_rect.height = borders.visible.top;
old = window->require_titlebar_visible;
window->require_titlebar_visible =
meta_rectangle_overlaps_with_region (info->usable_screen_region,
diff --git a/src/core/place.c b/src/core/place.c
index 4533616d5..cf246f0b7 100644
--- a/src/core/place.c
+++ b/src/core/place.c
@@ -82,6 +82,7 @@ find_next_cascade (MetaWindow *window,
GList *tmp;
GList *sorted;
int cascade_x, cascade_y;
+ MetaRectangle titlebar_rect;
int x_threshold, y_threshold;
MetaRectangle frame_rect;
int window_width, window_height;
@@ -102,19 +103,9 @@ find_next_cascade (MetaWindow *window,
* manually cascade.
*/
#define CASCADE_FUZZ 15
- if (window->frame)
- {
- MetaFrameBorders borders;
-
- meta_frame_calc_borders (window->frame, &borders);
- x_threshold = MAX (borders.visible.left, CASCADE_FUZZ);
- y_threshold = MAX (borders.visible.top, CASCADE_FUZZ);
- }
- else
- {
- x_threshold = CASCADE_FUZZ;
- y_threshold = CASCADE_FUZZ;
- }
+ meta_window_get_titlebar_rect (window, &titlebar_rect);
+ x_threshold = MAX (titlebar_rect.x, CASCADE_FUZZ);
+ y_threshold = MAX (titlebar_rect.y, CASCADE_FUZZ);
/* Find furthest-SE origin of all workspaces.
* cascade_x, cascade_y are the target position
@@ -151,13 +142,11 @@ find_next_cascade (MetaWindow *window,
if (ABS (wx - cascade_x) < x_threshold &&
ABS (wy - cascade_y) < y_threshold)
{
- /* This window is "in the way", move to next cascade
- * point. The new window frame should go at the origin
- * of the client window we're stacking above.
- */
- meta_window_get_position (w, &wx, &wy);
- cascade_x = wx;
- cascade_y = wy;
+ meta_window_get_titlebar_rect (w, &titlebar_rect);
+
+ /* Cascade the window evenly by the titlebar height; this isn't a typo. */
+ cascade_x = wx + titlebar_rect.height;
+ cascade_y = wy + titlebar_rect.height;
/* If we go off the screen, start over with a new cascade */
if (((cascade_x + window_width) >
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 6c79bbdd0..a0c1283eb 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -703,6 +703,8 @@ Window meta_window_get_toplevel_xwindow (MetaWindow *window);
void meta_window_get_client_area_rect (const MetaWindow *window,
cairo_rectangle_int_t *rect);
+void meta_window_get_titlebar_rect (MetaWindow *window,
+ MetaRectangle *titlebar_rect);
void meta_window_activate_full (MetaWindow *window,
guint32 timestamp,
diff --git a/src/core/window.c b/src/core/window.c
index 6100640ee..44bcc4ab8 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4310,6 +4310,28 @@ meta_window_get_client_area_rect (const MetaWindow *window,
rect->height = window->rect.height;
}
+void
+meta_window_get_titlebar_rect (MetaWindow *window,
+ MetaRectangle *rect)
+{
+ meta_window_get_frame_rect (window, rect);
+
+ /* The returned rectangle is relative to the frame rect. */
+ rect->x = 0;
+ rect->y = 0;
+
+ if (window->frame)
+ {
+ rect->height = window->frame->child_y;
+ }
+ else
+ {
+ /* Pick an arbitrary height for a titlebar. We might want to
+ * eventually have CSD windows expose their borders to us. */
+ rect->height = 15;
+ }
+}
+
const char*
meta_window_get_startup_id (MetaWindow *window)
{
@@ -5381,8 +5403,7 @@ meta_window_titlebar_is_onscreen (MetaWindow *window)
return TRUE;
/* Get the rectangle corresponding to the titlebar */
- meta_window_get_frame_rect (window, &titlebar_rect);
- titlebar_rect.height = window->frame->child_y;
+ meta_window_get_titlebar_rect (window, &titlebar_rect);
/* Run through the spanning rectangles for the screen and see if one of
* them overlaps with the titlebar sufficiently to consider it onscreen.