Prevent X11 clients from changing the size of windows in some cases.
Limit when client can change window size to when not maximized/fullscreen
or when the compositor is not resizing the window.
Bug: 825463
Change-Id: Ia52c688a69ac39bf964ad15e84938dd99188e541
Reviewed-on: https://chromium-review.googlesource.com/986263
Reviewed-by: David Reveman <reveman@chromium.org>
Tested-by: David Reveman <reveman@chromium.org>
diff --git a/sommelier.c b/sommelier.c
index 4fe71fc..875b7e3 100644
--- a/sommelier.c
+++ b/sommelier.c
@@ -412,6 +412,7 @@
int managed;
int realized;
int activated;
+ int allow_resize;
xcb_window_t transient_for;
int decorated;
char *name;
@@ -940,12 +941,15 @@
window->next_config.values[i++] = 0;
}
+ window->allow_resize = 1;
wl_array_for_each(state, states) {
if (*state == ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN) {
+ window->allow_resize = 0;
window->next_config.states[i++] =
window->xwl->atoms[ATOM_NET_WM_STATE_FULLSCREEN].value;
}
if (*state == ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED) {
+ window->allow_resize = 0;
window->next_config.states[i++] =
window->xwl->atoms[ATOM_NET_WM_STATE_MAXIMIZED_VERT].value;
window->next_config.states[i++] =
@@ -953,6 +957,8 @@
}
if (*state == ZXDG_TOPLEVEL_V6_STATE_ACTIVATED)
activated = 1;
+ if (*state == ZXDG_TOPLEVEL_V6_STATE_RESIZING)
+ window->allow_resize = 0;
}
if (activated != window->activated) {
@@ -4282,6 +4288,7 @@
window->managed = 0;
window->realized = 0;
window->activated = 0;
+ window->allow_resize = 1;
window->transient_for = XCB_WINDOW_NONE;
window->decorated = 0;
window->name = NULL;
@@ -4709,10 +4716,13 @@
window->x = event->x;
if (event->value_mask & XCB_CONFIG_WINDOW_Y)
window->y = event->y;
- if (event->value_mask & XCB_CONFIG_WINDOW_WIDTH)
- window->width = event->width;
- if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT)
- window->height = event->height;
+
+ if (window->allow_resize) {
+ if (event->value_mask & XCB_CONFIG_WINDOW_WIDTH)
+ window->width = event->width;
+ if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT)
+ window->height = event->height;
+ }
xwl_adjust_window_size_for_screen_size(window);
if (window->size_flags & (US_POSITION | P_POSITION))