raveit65 cfa7aae
From b1898d7874377dd76f7321e9b3601bdd93fde00b Mon Sep 17 00:00:00 2001
raveit65 cfa7aae
From: Victor Kareh <vkareh@vkareh.net>
raveit65 cfa7aae
Date: Tue, 24 Apr 2018 15:09:08 -0400
raveit65 cfa7aae
Subject: [PATCH] Correct resize popup position on HiDPI displays
raveit65 cfa7aae
raveit65 cfa7aae
---
raveit65 cfa7aae
 src/core/window.c    | 7 +++++--
raveit65 cfa7aae
 src/ui/resizepopup.c | 8 ++++++++
raveit65 cfa7aae
 2 files changed, 13 insertions(+), 2 deletions(-)
raveit65 cfa7aae
raveit65 cfa7aae
diff --git a/src/core/window.c b/src/core/window.c
raveit65 cfa7aae
index abd5af4..44084a0 100644
raveit65 cfa7aae
--- a/src/core/window.c
raveit65 cfa7aae
+++ b/src/core/window.c
raveit65 cfa7aae
@@ -8073,8 +8073,11 @@ meta_window_refresh_resize_popup (MetaWindow *window)
raveit65 cfa7aae
 
raveit65 cfa7aae
   if (window->display->grab_resize_popup == NULL)
raveit65 cfa7aae
     {
raveit65 cfa7aae
-      if (window->size_hints.width_inc > 1 ||
raveit65 cfa7aae
-          window->size_hints.height_inc > 1)
raveit65 cfa7aae
+      gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
raveit65 cfa7aae
+      /* Display the resize popup only for windows that report an
raveit65 cfa7aae
+       * increment hint that's larger than the scale factor. */
raveit65 cfa7aae
+      if (window->size_hints.width_inc > scale ||
raveit65 cfa7aae
+          window->size_hints.height_inc > scale)
raveit65 cfa7aae
         window->display->grab_resize_popup =
raveit65 cfa7aae
           meta_ui_resize_popup_new (window->display->xdisplay,
raveit65 cfa7aae
                                     window->screen->number);
raveit65 cfa7aae
diff --git a/src/ui/resizepopup.c b/src/ui/resizepopup.c
raveit65 cfa7aae
index c60fcd6..0464636 100644
raveit65 cfa7aae
--- a/src/ui/resizepopup.c
raveit65 cfa7aae
+++ b/src/ui/resizepopup.c
raveit65 cfa7aae
@@ -106,9 +106,11 @@ update_size_window (MetaResizePopup *popup)
raveit65 cfa7aae
   char *str;
raveit65 cfa7aae
   int x, y;
raveit65 cfa7aae
   int width, height;
raveit65 cfa7aae
+  int scale;
raveit65 cfa7aae
 
raveit65 cfa7aae
   g_return_if_fail (popup->size_window != NULL);
raveit65 cfa7aae
 
raveit65 cfa7aae
+  scale = gtk_widget_get_scale_factor (GTK_WIDGET (popup->size_window));
raveit65 cfa7aae
   /* Translators: This represents the size of a window.  The first number is
raveit65 cfa7aae
    * the width of the window and the second is the height.
raveit65 cfa7aae
    */
raveit65 cfa7aae
@@ -125,6 +127,12 @@ update_size_window (MetaResizePopup *popup)
raveit65 cfa7aae
   x = popup->rect.x + (popup->rect.width - width) / 2;
raveit65 cfa7aae
   y = popup->rect.y + (popup->rect.height - height) / 2;
raveit65 cfa7aae
 
raveit65 cfa7aae
+  if (scale)
raveit65 cfa7aae
+    {
raveit65 cfa7aae
+      x = x / scale;
raveit65 cfa7aae
+      y = y / scale;
raveit65 cfa7aae
+    }
raveit65 cfa7aae
+
raveit65 cfa7aae
   if (gtk_widget_get_realized (popup->size_window))
raveit65 cfa7aae
     {
raveit65 cfa7aae
       /* using move_resize to avoid jumpiness */
raveit65 cfa7aae
-- 
raveit65 cfa7aae
2.13.6
raveit65 cfa7aae