[mate-panel] 01/02: debian/patches: Add 0001_scale_monitor_geometries.patch. Scale monitor geometries down to device pixels to support multiple monitors in HiDPI.

Martin Wimpress flexiondotorg-guest at moszumanska.debian.org
Mon Mar 5 10:01:51 UTC 2018


This is an automated email from the git hooks/post-receive script.

flexiondotorg-guest pushed a commit to branch master
in repository mate-panel.

commit 9c0c67075d943298c9edfedc8ef84827f5b911f6
Author: Martin Wimpress <martin.wimpress at ubuntu.com>
Date:   Mon Mar 5 09:59:12 2018 +0000

    debian/patches: Add 0001_scale_monitor_geometries.patch. Scale monitor geometries down to device pixels to support multiple monitors in HiDPI.
---
 debian/patches/0001_scale_monitor_geometries.patch | 186 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 2 files changed, 187 insertions(+)

diff --git a/debian/patches/0001_scale_monitor_geometries.patch b/debian/patches/0001_scale_monitor_geometries.patch
new file mode 100644
index 0000000..b7a34ec
--- /dev/null
+++ b/debian/patches/0001_scale_monitor_geometries.patch
@@ -0,0 +1,186 @@
+Author: Victor Kareh <vkareh at vkareh.net>
+Description: Scale monitor geometries down to device pixels to support multiple monitors in HiDPI
+
+diff --git a/mate-panel/panel-multiscreen.c b/mate-panel/panel-multiscreen.c
+index d2e43862..04f42666 100644
+--- a/mate-panel/panel-multiscreen.c
++++ b/mate-panel/panel-multiscreen.c
+@@ -88,11 +88,14 @@ panel_multiscreen_get_randr_monitors_for_screen (GdkScreen     *screen,
+ 						 GdkRectangle **geometries_ret)
+ {
+ #ifdef HAVE_RANDR
++	GdkDisplay         *display;
++	GdkMonitor         *monitor;
+ 	Display            *xdisplay;
+ 	Window              xroot;
+ 	XRRScreenResources *resources;
+ 	RROutput            primary;
+ 	GArray             *geometries;
++	int                 scale;
+ 	int                 i;
+ 
+ 	if (!have_randr)
+@@ -138,6 +141,11 @@ panel_multiscreen_get_randr_monitors_for_screen (GdkScreen     *screen,
+ 		return FALSE;
+ 
+ 	primary = XRRGetOutputPrimary (xdisplay, xroot);
++	display = gdk_screen_get_display (screen);
++	monitor = gdk_display_get_primary_monitor (display);
++
++	/* Use scale factor to bring geometries down to device pixels to support HiDPI displays */
++	scale = gdk_monitor_get_scale_factor (monitor);
+ 
+ 	geometries = g_array_sized_new (FALSE, FALSE,
+ 					sizeof (GdkRectangle),
+@@ -157,10 +165,10 @@ panel_multiscreen_get_randr_monitors_for_screen (GdkScreen     *screen,
+ 			crtc = XRRGetCrtcInfo (xdisplay, resources,
+ 					       output->crtc);
+ 
+-			rect.x	    = crtc->x;
+-			rect.y	    = crtc->y;
+-			rect.width  = crtc->width;
+-			rect.height = crtc->height;
++			rect.x      = crtc->x / scale;
++			rect.y      = crtc->y / scale;
++			rect.width  = crtc->width / scale;
++			rect.height = crtc->height / scale;
+ 
+ 			XRRFreeCrtcInfo (crtc);
+ 
+diff --git a/mate-panel/panel-run-dialog.c b/mate-panel/panel-run-dialog.c
+index 50098cb1..38edf5e0 100644
+--- a/mate-panel/panel-run-dialog.c
++++ b/mate-panel/panel-run-dialog.c
+@@ -1708,7 +1708,6 @@ panel_run_dialog_setup_entry (PanelRunDialog *dialog,
+ 	GdkScreen             *screen;
+ 	int                    width_request;
+ 	GtkWidget             *entry;
+-	gint                   scale;
+ 
+ 	dialog->combobox = PANEL_GTK_BUILDER_GET (gui, "comboboxentry");
+ 
+@@ -1721,10 +1720,9 @@ panel_run_dialog_setup_entry (PanelRunDialog *dialog,
+ 		(GTK_COMBO_BOX (dialog->combobox), 0);
+ 
+ 	screen = gtk_window_get_screen (GTK_WINDOW (dialog->run_dialog));
+-	scale = gtk_widget_get_scale_factor (GTK_WIDGET (dialog->run_dialog));
+ 
+         /* 1/4 the width of the first monitor should be a good value */
+-	width_request = panel_multiscreen_width (screen, 0) / (4 * scale);
++	width_request = panel_multiscreen_width (screen, 0) / 4;
+ 	g_object_set (G_OBJECT (dialog->combobox),
+ 		      "width_request", width_request,
+ 		      NULL);
+diff --git a/mate-panel/panel-struts.c b/mate-panel/panel-struts.c
+index d59587e5..d5adccc4 100644
+--- a/mate-panel/panel-struts.c
++++ b/mate-panel/panel-struts.c
+@@ -256,6 +256,7 @@ panel_struts_set_window_hint (PanelToplevel *toplevel)
+ 	int         monitor_x, monitor_y, monitor_width, monitor_height;
+ 	int         screen_width, screen_height;
+ 	int         leftmost, rightmost, topmost, bottommost;
++	int         scale;
+ 
+ 	widget = GTK_WIDGET (toplevel);
+ 
+@@ -267,10 +268,11 @@ panel_struts_set_window_hint (PanelToplevel *toplevel)
+ 		return;
+ 	}
+ 
++	scale = gtk_widget_get_scale_factor (widget);
+ 	strut_size = strut->allocated_strut_size;
+ 
+-	screen_width  = WidthOfScreen (gdk_x11_screen_get_xscreen (strut->screen));
+-	screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (strut->screen));
++	screen_width  = WidthOfScreen (gdk_x11_screen_get_xscreen (strut->screen)) / scale;
++	screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (strut->screen)) / scale;
+ 
+ 	panel_struts_get_monitor_geometry (strut->screen,
+ 					   strut->monitor,
+@@ -315,8 +317,8 @@ panel_struts_set_window_hint (PanelToplevel *toplevel)
+ 	panel_xutils_set_strut (gtk_widget_get_window (widget),
+ 				strut->orientation,
+ 				strut_size,
+-				strut->allocated_strut_start,
+-				strut->allocated_strut_end);
++				strut->allocated_strut_start * scale,
++				strut->allocated_strut_end * scale);
+ }
+ 
+ void
+@@ -442,24 +444,32 @@ panel_struts_register_strut (PanelToplevel    *toplevel,
+ 		strut->geometry.y      = monitor_y;
+ 		strut->geometry.width  = strut->strut_end - strut->strut_start + 1;
+ 		strut->geometry.height = strut->strut_size / scale;
++		if (scale > 1)
++			strut->geometry.width -= (strut->strut_size / scale);
+ 		break;
+ 	case PANEL_ORIENTATION_BOTTOM:
+ 		strut->geometry.x      = strut->strut_start;
+ 		strut->geometry.y      = monitor_y + monitor_height - strut->strut_size;
+ 		strut->geometry.width  = strut->strut_end - strut->strut_start + 1;
+ 		strut->geometry.height = strut->strut_size / scale;
++		if (scale > 1)
++			strut->geometry.width -= (strut->strut_size / scale);
+ 		break;
+ 	case PANEL_ORIENTATION_LEFT:
+ 		strut->geometry.x      = monitor_x;
+ 		strut->geometry.y      = strut->strut_start;
+ 		strut->geometry.width  = strut->strut_size / scale;
+ 		strut->geometry.height = strut->strut_end - strut->strut_start + 1;
++		if (scale > 1)
++			strut->geometry.height -= (strut->strut_size / scale);
+ 		break;
+ 	case PANEL_ORIENTATION_RIGHT:
+ 		strut->geometry.x      = monitor_x + monitor_width - strut->strut_size;
+ 		strut->geometry.y      = strut->strut_start;
+ 		strut->geometry.width  = strut->strut_size / scale;
+ 		strut->geometry.height = strut->strut_end - strut->strut_start + 1;
++		if (scale > 1)
++			strut->geometry.height -= (strut->strut_size / scale);
+ 		break;
+ 	}
+ 
+diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c
+index 19d14b3c..1737b381 100644
+--- a/mate-panel/panel-toplevel.c
++++ b/mate-panel/panel-toplevel.c
+@@ -290,8 +290,7 @@ static GdkScreen* panel_toplevel_get_screen_geometry(PanelToplevel* toplevel, in
+ 	 * sorts of awful misalignments and pretend it's all good. Or we can just
+ 	 * make this thing think that the screen is scaled down, and because GTK+
+ 	 * already scaled everything up without the panel knowing about it, the whole
+-	 * thing somehow works well... sigh.
+-	 * @see panel_toplevel_get_monitor_geometry() */
++	 * thing somehow works well... sigh. */
+ 	*width  = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / toplevel->priv->scale;
+ 	*height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / toplevel->priv->scale;
+ 
+@@ -307,24 +306,17 @@ static GdkScreen* panel_toplevel_get_monitor_geometry(PanelToplevel* toplevel, i
+ 
+ 	screen = gtk_window_get_screen(GTK_WINDOW(toplevel));
+ 
+-	if (x) *x = panel_multiscreen_x(screen, toplevel->priv->monitor) / toplevel->priv->scale;
+-	if (y) *y = panel_multiscreen_y(screen, toplevel->priv->monitor) / toplevel->priv->scale;
++	if (x) *x = panel_multiscreen_x(screen, toplevel->priv->monitor);
++	if (y) *y = panel_multiscreen_y(screen, toplevel->priv->monitor);
+ 
+-	/* To scale the panels up for HiDPI displays, we can either multiply a lot of
+-	 * toplevel geometry attributes by the scale factor, then correct for all
+-	 * sorts of awful misalignments and pretend it's all good. Or we can just
+-	 * make this thing think that the screen is scaled down, and because GTK+
+-	 * already scaled everything up without the panel knowing about it, the whole
+-	 * thing somehow works well... sigh.
+-	 * @see panel_toplevel_get_screen_geometry() */
+ 	if (width)
+ 	{
+-		*width  = panel_multiscreen_width(screen, toplevel->priv->monitor) / toplevel->priv->scale;
++		*width  = panel_multiscreen_width(screen, toplevel->priv->monitor);
+ 	}
+ 
+ 	if (height)
+ 	{
+-		*height = panel_multiscreen_height(screen, toplevel->priv->monitor) / toplevel->priv->scale;
++		*height = panel_multiscreen_height(screen, toplevel->priv->monitor);
+ 	}
+ 
+ 	return screen;
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..db90441
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+0001_scale_monitor_geometries.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mate/mate-panel.git



More information about the pkg-mate-commits mailing list