[metacity] window: add a meta_window_get_titlebar_rect
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] window: add a meta_window_get_titlebar_rect
- Date: Fri, 3 Apr 2015 21:01:58 +0000 (UTC)
commit 90b36abebdf69be0abaec4015d01e46296f6f5d6
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Apr 3 23:30:20 2015 +0300
window: add a meta_window_get_titlebar_rect
Based on mutter commits:
https://git.gnome.org/browse/mutter/commit/?id=3a0af0faaebb1af75925c70ad98e73c61e57639b
https://git.gnome.org/browse/mutter/commit/?id=ac099343dab7b5048ce242958c454c55d1924902
src/core/constraints.c | 4 ++--
src/core/place.c | 26 +++++++++-----------------
src/core/window-private.h | 3 +++
src/core/window.c | 25 +++++++++++++++++++++++--
4 files changed, 37 insertions(+), 21 deletions(-)
---
diff --git a/src/core/constraints.c b/src/core/constraints.c
index cf1b9c9..167958c 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -673,8 +673,8 @@ update_onscreen_requirements (MetaWindow *window,
{
MetaRectangle titlebar_rect;
- titlebar_rect = info->current;
- titlebar_rect.height = info->borders->visible.top;
+ meta_window_get_titlebar_rect (window, &titlebar_rect);
+
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 8eb6f3a..d70cdd4 100644
--- a/src/core/place.c
+++ b/src/core/place.c
@@ -98,6 +98,7 @@ find_next_cascade (MetaWindow *window,
GList *tmp;
GList *sorted;
int cascade_x, cascade_y;
+ MetaRectangle titlebar_rect;
int x_threshold, y_threshold;
int window_width, window_height;
int cascade_stage;
@@ -117,16 +118,9 @@ find_next_cascade (MetaWindow *window,
* manually cascade.
*/
#define CASCADE_FUZZ 15
- if (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
@@ -168,13 +162,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 f76bf6e..1f201be 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -666,4 +666,7 @@ void meta_window_update_icon_now (MetaWindow *window);
gboolean meta_window_can_tile_side_by_side (MetaWindow *window);
gboolean meta_window_is_client_decorated (MetaWindow *window);
+void meta_window_get_titlebar_rect (MetaWindow *window,
+ MetaRectangle *titlebar_rect);
+
#endif
diff --git a/src/core/window.c b/src/core/window.c
index 3590627..128746d 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4201,6 +4201,28 @@ meta_window_end_wireframe (MetaWindow *window)
window->display->grab_wireframe_last_display_height);
}
+void
+meta_window_get_titlebar_rect (MetaWindow *window,
+ MetaRectangle *rect)
+{
+ meta_window_get_outer_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 = 50;
+ }
+}
+
const char*
meta_window_get_startup_id (MetaWindow *window)
{
@@ -6860,8 +6882,7 @@ meta_window_titlebar_is_onscreen (MetaWindow *window)
return FALSE;
/* Get the rectangle corresponding to the titlebar */
- meta_window_get_outer_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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]