[metacity/gnome-3-20] window: fix meta_window_get_titlebar_rect



commit 5f1f23666b5d0566cbb1174c90be0241ceb7d964
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Wed Jun 22 00:34:19 2016 +0300

    window: fix meta_window_get_titlebar_rect
    
    At least two places before 90b36abebdf69be0abaec4015d01e46296f6f5d6 commit
    used screen coordinates. Update meta_window_get_titlebar_rect function to
    return titlebar rectange in screen coordinates.
    
    This also reverts first change in place.c that did not make any sense. x and
    y in titlebar_rect always was 0 meaning that we always used CASCADE_FUZZ
    value while previously visible border size was used.
    
    https://bugs.launchpad.net/ubuntu/+source/metacity/+bugs/1509031

 src/core/place.c  |   16 ++++++++++++----
 src/core/window.c |    4 ----
 2 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/src/core/place.c b/src/core/place.c
index dc3ad1d..d85ee85 100644
--- a/src/core/place.c
+++ b/src/core/place.c
@@ -98,7 +98,6 @@ 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;
@@ -118,9 +117,16 @@ find_next_cascade (MetaWindow *window,
    * manually cascade.
    */
 #define CASCADE_FUZZ 15
-  meta_window_get_titlebar_rect (window, &titlebar_rect);
-  x_threshold = MAX (titlebar_rect.x, CASCADE_FUZZ);
-  y_threshold = MAX (titlebar_rect.y, CASCADE_FUZZ);
+  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;
+    }
 
   /* Find furthest-SE origin of all workspaces.
    * cascade_x, cascade_y are the target position
@@ -162,6 +168,8 @@ find_next_cascade (MetaWindow *window,
       if (ABS (wx - cascade_x) < x_threshold &&
           ABS (wy - cascade_y) < y_threshold)
         {
+          MetaRectangle titlebar_rect;
+
           meta_window_get_titlebar_rect (w, &titlebar_rect);
 
           /* Cascade the window evenly by the titlebar height; this isn't a typo. */
diff --git a/src/core/window.c b/src/core/window.c
index d76ff0a..2b79df9 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4226,10 +4226,6 @@ meta_window_get_titlebar_rect (MetaWindow    *window,
 {
   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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]