From 8a380c3e9af91a726b8ed45ccf9ef64911540595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= Date: Thu, 16 Dec 2021 13:18:12 +0100 Subject: struts: add support for _GNOME_WM_STRUT_AREA In addition to existing properties set also new _GNOME_WM_STRUT_AREA property that allows creating struts between monitors. https://mail.gnome.org/archives/wm-spec-list/2018-December/msg00000.html https://gitlab.freedesktop.org/xdg/xdg-specs/merge_requests/22 https://gitlab.gnome.org/GNOME/gnome-panel/merge_requests/3 Upscale area strut because of 73e025b0eab94fe06cdafee61c347fb5fe6f7545 --- mate-panel/panel-struts.c | 4 +++- mate-panel/panel-xutils.c | 33 +++++++++++++++++++++++++++++---- mate-panel/panel-xutils.h | 4 +++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/mate-panel/panel-struts.c b/mate-panel/panel-struts.c index b24707ca..00968ab7 100644 --- a/mate-panel/panel-struts.c +++ b/mate-panel/panel-struts.c @@ -320,7 +320,9 @@ panel_struts_set_window_hint (PanelToplevel *toplevel) strut->orientation, strut_size, strut->allocated_strut_start * scale, - strut->allocated_strut_end * scale); + strut->allocated_strut_end * scale, + &strut->allocated_geometry, + scale); } void diff --git a/mate-panel/panel-xutils.c b/mate-panel/panel-xutils.c index 4d8b32a2..eb887e71 100644 --- a/mate-panel/panel-xutils.c +++ b/mate-panel/panel-xutils.c @@ -39,6 +39,7 @@ static Atom net_wm_strut = None; static Atom net_wm_strut_partial = None; +static Atom gnome_wm_strut_area = None; enum { STRUT_LEFT = 0, @@ -55,16 +56,27 @@ enum { STRUT_BOTTOM_END = 11 }; +enum { + STRUT_AREA_X = 0, + STRUT_AREA_Y, + STRUT_AREA_WIDTH, + STRUT_AREA_HEIGHT, + STRUT_AREA_LAST +}; + void panel_xutils_set_strut (GdkWindow *gdk_window, PanelOrientation orientation, guint32 strut, guint32 strut_start, - guint32 strut_end) + guint32 strut_end, + GdkRectangle *rect, + int scale) { - Display *xdisplay; - Window window; - gulong struts [12] = { 0, }; + Display *xdisplay; + Window window; + gulong struts [12] = { 0, }; + gulong area [STRUT_AREA_LAST]; GdkDisplay *display; g_return_if_fail (GDK_IS_WINDOW (gdk_window)); @@ -77,6 +89,8 @@ panel_xutils_set_strut (GdkWindow *gdk_window, net_wm_strut = XInternAtom (xdisplay, "_NET_WM_STRUT", False); if (net_wm_strut_partial == None) net_wm_strut_partial = XInternAtom (xdisplay, "_NET_WM_STRUT_PARTIAL", False); + if (gnome_wm_strut_area == None) + gnome_wm_strut_area = XInternAtom (xdisplay, "_GNOME_WM_STRUT_AREA", False); switch (orientation) { case PANEL_ORIENTATION_LEFT: @@ -101,6 +115,11 @@ panel_xutils_set_strut (GdkWindow *gdk_window, break; } + area [STRUT_AREA_X] = rect->x * scale; + area [STRUT_AREA_Y] = rect->y * scale; + area [STRUT_AREA_WIDTH] = rect->width * scale; + area [STRUT_AREA_HEIGHT] = rect->height * scale; + display = gdk_window_get_display (gdk_window); gdk_x11_display_error_trap_push (display); XChangeProperty (xdisplay, window, net_wm_strut, @@ -109,6 +128,9 @@ panel_xutils_set_strut (GdkWindow *gdk_window, XChangeProperty (xdisplay, window, net_wm_strut_partial, XA_CARDINAL, 32, PropModeReplace, (guchar *) &struts, 12); + XChangeProperty (xdisplay, window, gnome_wm_strut_area, + XA_CARDINAL, 32, PropModeReplace, + (guchar *) &area, 4); gdk_x11_display_error_trap_pop_ignored (display); } @@ -127,11 +149,14 @@ panel_xutils_unset_strut (GdkWindow *gdk_window) net_wm_strut = XInternAtom (xdisplay, "_NET_WM_STRUT", False); if (net_wm_strut_partial == None) net_wm_strut_partial = XInternAtom (xdisplay, "_NET_WM_STRUT_PARTIAL", False); + if (gnome_wm_strut_area == None) + gnome_wm_strut_area = XInternAtom (xdisplay, "_GNOME_WM_STRUT_AREA", False); gdk_x11_display_error_trap_push (display); XDeleteProperty (xdisplay, xwindow, net_wm_strut); XDeleteProperty (xdisplay, xwindow, net_wm_strut_partial); + XDeleteProperty (xdisplay, xwindow, gnome_wm_strut_area); gdk_x11_display_error_trap_pop_ignored (display); } diff --git a/mate-panel/panel-xutils.h b/mate-panel/panel-xutils.h index 8310c052..988153d3 100644 --- a/mate-panel/panel-xutils.h +++ b/mate-panel/panel-xutils.h @@ -48,7 +48,9 @@ void panel_xutils_set_strut (GdkWindow *gdk_window, PanelOrientation orientation, guint32 strut, guint32 strut_start, - guint32 strut_end); + guint32 strut_end, + GdkRectangle *rect, + int scale); void panel_xutils_unset_strut (GdkWindow *gdk_window); -- cgit v1.2.1