diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-02-26 11:26:03 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-02-26 11:26:03 +0000 |
| commit | 135ca0884d3ae5ee8e0a9f9f72b78b6b52b14ded (patch) | |
| tree | 66ea312b93957190937bddff633fad7ac0b50d12 | |
| parent | wayland: instantiate sub-surfaces on-demand (diff) | |
wayland: configure: adjust configured size when using CSDs
The size (width, height) arguments provided by the compositor in the
XDG toplevel configure event *include* the surrounding CSDs.
Since our code assumes the size is for the main surface only (and then
positions the sub-surfaces *outside* the main surface), adjust the
provided size when using CSDs.
This ensures our actual window size ends up being what the compositor
wants it to be, and it fixes resize-glitches when resizing using CSDs.
| -rw-r--r-- | wayland.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -426,6 +426,7 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height, struct wl_array *states) { bool is_activated = false; + bool is_resizing = false; #if defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG char state_str[2048]; @@ -450,9 +451,12 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel, is_activated = true; break; + case XDG_TOPLEVEL_STATE_RESIZING: + is_resizing = true; + break; + case XDG_TOPLEVEL_STATE_MAXIMIZED: case XDG_TOPLEVEL_STATE_FULLSCREEN: - case XDG_TOPLEVEL_STATE_RESIZING: case XDG_TOPLEVEL_STATE_TILED_LEFT: case XDG_TOPLEVEL_STATE_TILED_RIGHT: case XDG_TOPLEVEL_STATE_TILED_TOP: @@ -490,6 +494,20 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel, * xdg_surface_configure() after we've ack:ed the event. */ struct wl_window *win = data; + + if (win->use_csd == CSD_YES && width != 0 && height != 0) { + /* + * The size received here is the *total* window size. + * + * This *includes* the (negatively positioned) CSD + * sub-surfaces. Thus, since our resize code assumes the size + * to resize to is the main window only, adjust the size here, + * to account for the CSDs. + */ + width -= 2 * csd_border_size * win->term->scale; + height -= (2 * csd_border_size + csd_title_size) * win->term->scale; + } + win->configure.is_activated = is_activated; win->configure.width = width; win->configure.height = height; |
