! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Tab Window placement wrong on scaled display
Status:
RESOLVED: FIXED

Comments

Description Jonas Zetterberg 2018-12-01 12:06:48 CET
Created attachment 8151 
Patch to move tabwin to scaled position

When using display scaling the resent change "be929b2a common: Convert monitor geometry to device geometry" changes the tabwin position to the bottom right corner. This because xfwm_get_monitor_geometry now returns the unscaled size.

Attached a patch to resolve this. Patch exports scale from the xfwm_get_monitor_geometry to allow clients to scale windows for gdk_window_move.
Comment 1 Jonas Zetterberg 2018-12-01 13:00:33 CET
Created attachment 8152 
Add scaled boolean to xfwm_get_monitor_geometry

New patch that lets caller choose if it wants the scaled and unscaled montor and let tabwin use the scaled output. A little smaller patch and keeps tabwin placement calculations.
Comment 2 Olivier Fourdan editbugs 2018-12-06 12:03:48 CET
*** Bug 14567 has been marked as a duplicate of this bug. ***
Comment 3 Olivier Fourdan editbugs 2018-12-06 12:13:31 CET
Comment on attachment 8152 
Add scaled boolean to xfwm_get_monitor_geometry

>From 8df07424851a01a525661971712757b8b66d5d97 Mon Sep 17 00:00:00 2001
>From: Jonas Zetterberg <jozz@jozz.se>
>Date: Sat, 1 Dec 2018 12:53:46 +0100
>Subject: [PATCH] tabwin: Place tabwin in center when display is scaled

Please add the bug number here, as done for other commit messages

Bug: 14931

>On scaled display the tabwin is using unscaled window coordinates to calculate
>its position. Let client choose scaled or unscaled display size and use scaled
>in tabwin.

"client" here is confusing, usually, for X11 and the window manager, a "client" is an application. I'd rather say "the caller" here.

>
>This bug was introduced in:
>	be929b2a common: Convert monitor geometry to device geometry

I'd rather use:

fixes: be929b2a common: Convert monitor geometry to device geometry

But actually, I reckon this fixes 9d5ac6a4 which introduced the bug 14566 in the first place, be929b2a was just an incomplete fix.

>
>Signed-off-by: Jonas Zetterberg <jozz@jozz.se>
>---
> common/xfwm-common.c | 8 +++++---
> common/xfwm-common.h | 3 ++-
> src/screen.c         | 8 ++++----
> src/tabwin.c         | 8 ++++----
> 4 files changed, 15 insertions(+), 12 deletions(-)
>
>diff --git a/common/xfwm-common.c b/common/xfwm-common.c
>index a991b355..e2040837 100644
>--- a/common/xfwm-common.c
>+++ b/common/xfwm-common.c
>@@ -78,19 +78,21 @@ xfwm_get_screen_dimensions (gint *width, gint *height)
> void
> xfwm_get_monitor_geometry (GdkScreen    *screen,
>                            gint          monitor_num,
>-                           GdkRectangle *geometry)
>+                           GdkRectangle *geometry,
>+                           gboolean scaled)
> {
> #if GTK_CHECK_VERSION(3, 22, 0)
>   GdkDisplay *display;
>   GdkMonitor *monitor;
>-  int scale;
>+  int scale = 1;
> 
>   display = gdk_screen_get_display (screen);
>   monitor = gdk_display_get_monitor (display, monitor_num);
>   gdk_monitor_get_geometry (monitor, geometry);
> 
>   /* Convert to device pixels */
>-  scale = gdk_monitor_get_scale_factor (monitor);
>+  if (scaled)
>+    scale = gdk_monitor_get_scale_factor (monitor);

Nitpicking, xfwm4 style is to use braces even for one-line (annoying, I know and agree...)

>   geometry->x *= scale;
>   geometry->y *= scale;
>   geometry->width *= scale;
>diff --git a/common/xfwm-common.h b/common/xfwm-common.h
>index e2e8c97b..3889103c 100644
>--- a/common/xfwm-common.h
>+++ b/common/xfwm-common.h
>@@ -31,7 +31,8 @@ void              xfwm_get_screen_dimensions            (gint         *width,
> 
> void              xfwm_get_monitor_geometry             (GdkScreen    *screen,
>                                                          gint          monitor_num,
>-                                                         GdkRectangle *geometry);
>+                                                         GdkRectangle *geometry,
>+                                                         gboolean scaled);

Nitpick: align the arguments.

> 
> void              xfwm_get_primary_monitor_geometry     (GdkScreen    *screen,
>                                                          GdkRectangle *geometry);
>diff --git a/src/screen.c b/src/screen.c
>index a40e3db6..f112432c 100644
>--- a/src/screen.c
>+++ b/src/screen.c
>@@ -642,7 +642,7 @@ myScreenComputeSize (ScreenInfo *screen_info)
> 
>     for (i = 0; i < num_monitors; i++)
>     {
>-        xfwm_get_monitor_geometry (screen_info->gscr, i, &monitor);
>+        xfwm_get_monitor_geometry (screen_info->gscr, i, &monitor, TRUE);
>         width = MAX (monitor.x + monitor.width, width);
>         height = MAX (monitor.y + monitor.height, height);
>     }
>@@ -717,11 +717,11 @@ myScreenRebuildMonitorIndex (ScreenInfo *screen_info)
>     num_monitors = xfwm_get_n_monitors (screen_info->gscr);
>     for (i = 0; i < num_monitors; i++)
>     {
>-        xfwm_get_monitor_geometry (screen_info->gscr, i, &monitor);
>+        xfwm_get_monitor_geometry (screen_info->gscr, i, &monitor, TRUE);
>         cloned = FALSE;
>         for (j = 0; j < (gint) screen_info->monitors_index->len; j++)
>         {
>-            xfwm_get_monitor_geometry (screen_info->gscr, j, &previous);
>+            xfwm_get_monitor_geometry (screen_info->gscr, j, &previous, TRUE);
>             if ((previous.x == monitor.x) && (previous.y == monitor.y))
>             {
>                 cloned = TRUE;
>@@ -784,7 +784,7 @@ myScreenFindMonitorAtPoint (ScreenInfo *screen_info, gint x, gint y, GdkRectangl
>         gint monitor_index;
> 
>         monitor_index = myScreenGetMonitorIndex (screen_info, i);
>-        xfwm_get_monitor_geometry (screen_info->gscr, monitor_index, &monitor);
>+        xfwm_get_monitor_geometry (screen_info->gscr, monitor_index, &monitor, TRUE);
> 
>         if ((x >= monitor.x) && (x < (monitor.x + monitor.width)) &&
>             (y >= monitor.y) && (y < (monitor.y + monitor.height)))
>diff --git a/src/tabwin.c b/src/tabwin.c
>index 4be61fbc..fe875de5 100644
>--- a/src/tabwin.c
>+++ b/src/tabwin.c
>@@ -329,7 +329,7 @@ getMinMonitorWidth (ScreenInfo *screen_info)
>     for (min_width = i = 0; i < num_monitors; i++)
>     {
>         GdkRectangle monitor;
>-        xfwm_get_monitor_geometry (screen_info->gscr, i, &monitor);
>+        xfwm_get_monitor_geometry (screen_info->gscr, i, &monitor, FALSE);
>         if (min_width == 0 || monitor.width < min_width)
>             min_width = monitor.width;
>     }
>@@ -343,7 +343,7 @@ getMinMonitorHeight (ScreenInfo *screen_info)
>     for (min_height = i = 0; i < num_monitors; i++)
>     {
>         GdkRectangle monitor;
>-        xfwm_get_monitor_geometry (screen_info->gscr, i, &monitor);
>+        xfwm_get_monitor_geometry (screen_info->gscr, i, &monitor, FALSE);
>         if (min_height == 0 || monitor.height < min_height)
>         {
>             min_height = monitor.height;
>@@ -573,7 +573,7 @@ tabwinConfigure (TabwinWidget *tabwin_widget, GdkEventConfigure *event)
>     }
> 
>     xfwm_get_monitor_geometry (gtk_widget_get_screen (GTK_WIDGET (tabwin_widget)),
>-                               tabwin_widget->monitor_num, &monitor);
>+                               tabwin_widget->monitor_num, &monitor, FALSE);
>     x = monitor.x + (monitor.width - event->width) / 2;
>     y = monitor.y + (monitor.height - event->height) / 2;
>     gtk_window_move (GTK_WINDOW (tabwin_widget), x, y);
>@@ -784,7 +784,7 @@ tabwinCreateWidget (Tabwin *tabwin, ScreenInfo *screen_info, gint monitor_num)
>                                     MAX (border.left, MAX (border.top, (MAX (border.right, border.bottom)))) +
>                                     MAX (padding.left, MAX (padding.top, (MAX (padding.right, padding.bottom)))));
>     gtk_window_set_position (GTK_WINDOW (tabwin_widget), GTK_WIN_POS_NONE);
>-    xfwm_get_monitor_geometry (screen_info->gscr, tabwin_widget->monitor_num, &monitor);
>+    xfwm_get_monitor_geometry (screen_info->gscr, tabwin_widget->monitor_num, &monitor, FALSE);
>     gtk_window_move (GTK_WINDOW (tabwin_widget), monitor.x + monitor.width / 2,
>                                       monitor.y + monitor.height / 2);
> 
>-- 
>2.20.0.rc1
>

I wonder if that's sufficient though, but anyhoiw a step in the good direction :)
Comment 4 Jonas Zetterberg 2018-12-06 18:40:33 CET
Created attachment 8156 
New patch which fixes all comments, and one more style change.

Thank you for the review.
Comment 5 Jonas Zetterberg 2018-12-07 11:10:37 CET
Created attachment 8160 
New patch which fixes all comments, and one more style change.

Try 3. :)
Comment 6 Git Bot editbugs 2018-12-09 17:13:58 CET
Jonas Zetterberg referenced this bugreport in commit 07773e608413a370932c5f2d59ed0b656240970a

tabwin: Place tabwin in center when display is scaled

https://git.xfce.org/xfce/xfwm4/commit?id=07773e608413a370932c5f2d59ed0b656240970a
Comment 7 Olivier Fourdan editbugs 2018-12-09 17:14:26 CET
Pushed, thanks :)

Bug #14931

Reported by:
Jonas Zetterberg
Reported on: 2018-12-01
Last modified on: 2018-12-09
Duplicates (1):
  • 14567 Window switcher incorrectly placed with 2x window scaling

People

Assignee:
Olivier Fourdan
CC List:
2 users

Version

Version:
unspecified

Attachments

Additional information