From 6fd1de226b6de3d9f8fd58066d233e940571a620 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 19 Aug 2014 13:54:30 -0400 Subject: [PATCH] window: Add a hack to correct dragging from the top panel in gnome-shell In gnome-shell, we have a feature where the user can unmaximize windows by dragging them from the panel above the window. With accurate anchoring, this looks really weird as the cursor is now "detached" from the window. Detect this case and put the cursor in the middle of the window titlebar instead. --- src/core/window.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/window.c b/src/core/window.c index 3ab453e7e..b626a5d9b 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -5604,6 +5604,16 @@ update_move (MetaWindow *window, display->grab_initial_window_pos.x = x - window->saved_rect.width * prop; + /* If we started dragging the window from above the top of the window, + * pretend like we started dragging from the middle of the titlebar + * instead, as the "correct" anchoring looks wrong. */ + if (display->grab_anchor_root_y < display->grab_initial_window_pos.y) + { + MetaRectangle titlebar_rect; + meta_window_get_titlebar_rect (window, &titlebar_rect); + display->grab_anchor_root_y = display->grab_initial_window_pos.y + titlebar_rect.height / 2; + } + window->saved_rect.x = display->grab_initial_window_pos.x; window->saved_rect.y = display->grab_initial_window_pos.y;