mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-27 07:58:07 -04:00
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.
This commit is contained in:
parent
ea97a0dc87
commit
135ca0884d
1 changed files with 19 additions and 1 deletions
20
wayland.c
20
wayland.c
|
|
@ -426,6 +426,7 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
|
||||||
int32_t width, int32_t height, struct wl_array *states)
|
int32_t width, int32_t height, struct wl_array *states)
|
||||||
{
|
{
|
||||||
bool is_activated = false;
|
bool is_activated = false;
|
||||||
|
bool is_resizing = false;
|
||||||
|
|
||||||
#if defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG
|
#if defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG
|
||||||
char state_str[2048];
|
char state_str[2048];
|
||||||
|
|
@ -450,9 +451,12 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
|
||||||
is_activated = true;
|
is_activated = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case XDG_TOPLEVEL_STATE_RESIZING:
|
||||||
|
is_resizing = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case XDG_TOPLEVEL_STATE_MAXIMIZED:
|
case XDG_TOPLEVEL_STATE_MAXIMIZED:
|
||||||
case XDG_TOPLEVEL_STATE_FULLSCREEN:
|
case XDG_TOPLEVEL_STATE_FULLSCREEN:
|
||||||
case XDG_TOPLEVEL_STATE_RESIZING:
|
|
||||||
case XDG_TOPLEVEL_STATE_TILED_LEFT:
|
case XDG_TOPLEVEL_STATE_TILED_LEFT:
|
||||||
case XDG_TOPLEVEL_STATE_TILED_RIGHT:
|
case XDG_TOPLEVEL_STATE_TILED_RIGHT:
|
||||||
case XDG_TOPLEVEL_STATE_TILED_TOP:
|
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.
|
* xdg_surface_configure() after we've ack:ed the event.
|
||||||
*/
|
*/
|
||||||
struct wl_window *win = data;
|
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.is_activated = is_activated;
|
||||||
win->configure.width = width;
|
win->configure.width = width;
|
||||||
win->configure.height = height;
|
win->configure.height = height;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue