[Xfce4-commits] [xfce/xfce4-panel] 03/08: panel-window: set struts with monitor scaling
noreply at xfce.org
noreply at xfce.org
Fri May 4 00:47:33 CEST 2018
This is an automated email from the git hooks/post-receive script.
o c h o s i p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/xfce4-panel.
commit 354ebfb3dd226439b2d8bef8198217f0c82c150d
Author: Jason Zaman <jason at perfinion.com>
Date: Tue Apr 24 01:10:31 2018 +0800
panel-window: set struts with monitor scaling
---
panel/panel-window.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 9c5d0ac..84f1043 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -1655,48 +1655,56 @@ panel_window_screen_struts_set (PanelWindow *window)
{
gulong struts[N_STRUTS] = { 0, };
GdkRectangle *alloc = &window->alloc;
+ GdkMonitor *monitor;
+ GdkRectangle geometry;
guint i;
gboolean update_struts = FALSE;
gint n;
+ gint scale_factor;
const gchar *strut_border[] = { "left", "right", "top", "bottom" };
const gchar *strut_xy[] = { "y", "y", "x", "x" };
panel_return_if_fail (PANEL_IS_WINDOW (window));
panel_return_if_fail (cardinal_atom != 0 && net_wm_strut_partial_atom != 0);
panel_return_if_fail (GDK_IS_SCREEN (window->screen));
+ panel_return_if_fail (GDK_IS_DISPLAY (window->display));
if (!gtk_widget_get_realized (GTK_WIDGET (window)))
return;
+ monitor = gdk_display_get_monitor_at_point (window->display, window->base_x, window->base_y);
+ scale_factor = gdk_monitor_get_scale_factor(monitor);
+ gdk_monitor_get_geometry(monitor, &geometry);
+
/* set the struts */
/* note that struts are relative to the screen edge! */
if (window->struts_edge == STRUTS_EDGE_TOP)
{
/* the window is snapped on the top screen edge */
- struts[STRUT_TOP] = alloc->y + alloc->height;
- struts[STRUT_TOP_START_X] = alloc->x;
- struts[STRUT_TOP_END_X] = alloc->x + alloc->width - 1;
+ struts[STRUT_TOP] = (alloc->y + alloc->height) * scale_factor;
+ struts[STRUT_TOP_START_X] = alloc->x * scale_factor;
+ struts[STRUT_TOP_END_X] = (alloc->x + alloc->width - 1) * scale_factor;
}
else if (window->struts_edge == STRUTS_EDGE_BOTTOM)
{
/* the window is snapped on the bottom screen edge */
- struts[STRUT_BOTTOM] = gdk_screen_get_height (window->screen) - alloc->y;
- struts[STRUT_BOTTOM_START_X] = alloc->x;
- struts[STRUT_BOTTOM_END_X] = alloc->x + alloc->width - 1;
+ struts[STRUT_BOTTOM] = (geometry.height - alloc->y) * scale_factor;
+ struts[STRUT_BOTTOM_START_X] = alloc->x * scale_factor;
+ struts[STRUT_BOTTOM_END_X] = (alloc->x + alloc->width - 1) * scale_factor;
}
else if (window->struts_edge == STRUTS_EDGE_LEFT)
{
/* the window is snapped on the left screen edge */
- struts[STRUT_LEFT] = alloc->x + alloc->width;
- struts[STRUT_LEFT_START_Y] = alloc->y;
- struts[STRUT_LEFT_END_Y] = alloc->y + alloc->height - 1;
+ struts[STRUT_LEFT] = (alloc->x + alloc->width) * scale_factor;
+ struts[STRUT_LEFT_START_Y] = alloc->y * scale_factor;
+ struts[STRUT_LEFT_END_Y] = (alloc->y + alloc->height - 1) * scale_factor;
}
else if (window->struts_edge == STRUTS_EDGE_RIGHT)
{
/* the window is snapped on the right screen edge */
- struts[STRUT_RIGHT] = gdk_screen_get_width (window->screen) - alloc->x;
- struts[STRUT_RIGHT_START_Y] = alloc->y;
- struts[STRUT_RIGHT_END_Y] = alloc->y + alloc->height - 1;
+ struts[STRUT_RIGHT] = (geometry.width - alloc->x) * scale_factor;
+ struts[STRUT_RIGHT_START_Y] = alloc->y * scale_factor;
+ struts[STRUT_RIGHT_END_Y] = (alloc->y + alloc->height - 1) * scale_factor;
}
/* store the new struts */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list