summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2018-02-27 12:35:19 -0500
committerraveit65 <[email protected]>2018-03-13 08:57:26 +0100
commit77fdffd8d8f7fd8e9f650c1c3ec869205fe84400 (patch)
tree0f2b82725a5ef097b62de3c1920053f6179aa07b
parent06c84c7c7b037ce6093d2970115de9c5d2f9f422 (diff)
downloadmate-panel-77fdffd8d8f7fd8e9f650c1c3ec869205fe84400.tar.bz2
mate-panel-77fdffd8d8f7fd8e9f650c1c3ec869205fe84400.tar.xz
Fix strut sizes for HiDPI multi-monitors
-rw-r--r--mate-panel/panel-struts.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/mate-panel/panel-struts.c b/mate-panel/panel-struts.c
index f702f565..d5adccc4 100644
--- a/mate-panel/panel-struts.c
+++ b/mate-panel/panel-struts.c
@@ -75,17 +75,10 @@ panel_struts_get_monitor_geometry (GdkScreen *screen,
int *width,
int *height)
{
- GdkDisplay *display;
- int scale;
-
- /* Use scale factor to bring strut dimensions up to application pixels to support HiDPI displays */
- display = gdk_screen_get_display (screen);
- scale = gdk_monitor_get_scale_factor (gdk_display_get_monitor (display, monitor));
-
- *x = panel_multiscreen_x (screen, monitor) * scale;
- *y = panel_multiscreen_y (screen, monitor) * scale;
- *width = panel_multiscreen_width (screen, monitor) * scale;
- *height = panel_multiscreen_height (screen, monitor) * scale;
+ *x = panel_multiscreen_x (screen, monitor);
+ *y = panel_multiscreen_y (screen, monitor);
+ *width = panel_multiscreen_width (screen, monitor);
+ *height = panel_multiscreen_height (screen, monitor);
}
static PanelStrut *
@@ -263,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);
@@ -274,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,
@@ -322,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
@@ -449,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;
}