From b83b3224297f2f586ebb4366f220df5138ff8080 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 2 Jun 2016 11:36:48 -0700 Subject: [PATCH] Force application win_gravity to NorthWestGravity LibreOffice incorrectly sets its top level windows win_gravity field to StaticGravity. Resizing these windows to the left or upwards results in a corrupted application with the application window moved within the parent by the parent window resize. Metacity forces window gravity for all application windows to NorthWest, masking this application bug. xfwm4 should do the same. A bug has been filed against LibreOffice as well. Signed-off-by: Keith Packard --- src/client.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/client.c b/src/client.c index 652a75e..d072683 100644 --- a/src/client.c +++ b/src/client.c @@ -1890,8 +1890,21 @@ clientFrame (DisplayInfo *display_info, Window w, gboolean recapture) XUnmapWindow (display_info->dpy, c->window); } XReparentWindow (display_info->dpy, c->window, c->frame, frameLeft (c), frameTop (c)); - valuemask = CWEventMask; + valuemask = CWEventMask|CWWinGravity; + + /* Force win_gravity to NorthWest. Any other gravity has the + * window move relative to its parent when the parent resizes. + * + * There are many bug reports related to libreoffice using + * StaticGravity, including: + * + * http://www.linuxquestions.org/questions/linux-desktop-74/strange-libreoffice-problem-on-debian-with-xfce-4175469847/ + * https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers/+bug/889212 + * https://bbs.archlinux.org/viewtopic.php?id=133137 + * http://forums.debian.net/viewtopic.php?f=6&t=105757 + */ attributes.event_mask = (CLIENT_EVENT_MASK); + attributes.win_gravity = NorthWestGravity; XChangeWindowAttributes (display_info->dpy, c->window, valuemask, &attributes); if (display_info->have_shape) { -- 2.8.1