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.
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.
*** Bug 14567 has been marked as a duplicate of this bug. ***
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 :)
Created attachment 8156 New patch which fixes all comments, and one more style change. Thank you for the review.
Created attachment 8160 New patch which fixes all comments, and one more style change. Try 3. :)
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
Pushed, thanks :)