Wayland: Fix remembering window size not accurate when client side decorations are present

This commit is contained in:
Kovid Goyal 2022-09-04 14:25:04 +05:30
parent 31fe35cd38
commit b60d9f73ce
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 25 additions and 5 deletions

View File

@ -54,6 +54,8 @@ Detailed list of changes
- Fix a regression in 0.26.0 that broke mapping of native keys who key codes did not fit in 21 bits (:iss:`5452`)
- Wayland: Fix remembering window size not accurate when client side decorations are present
0.26.1 [2022-08-30]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2
glfw/wl_window.c vendored
View File

@ -998,7 +998,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
if (window->decorated && !window->monitor && !window->wl.decorations.serverSide)
{
if (top)
*top = window->wl.decorations.metrics.top;
*top = window->wl.decorations.metrics.top - window->wl.decorations.metrics.visible_titlebar_height;
if (left)
*left = window->wl.decorations.metrics.width;
if (right)

View File

@ -974,7 +974,7 @@ process_pending_resizes(monotonic_t now) {
static void
close_os_window(ChildMonitor *self, OSWindow *os_window) {
int w = os_window->window_width, h = os_window->window_height;
int w = os_window->content_area_width, h = os_window->content_area_height;
if (os_window->before_fullscreen.is_set && is_os_window_fullscreen(os_window)) {
w = os_window->before_fullscreen.w; h = os_window->before_fullscreen.h;
}

View File

@ -97,6 +97,22 @@ min_size_for_os_window(OSWindow *window, int *min_width, int *min_height) {
}
static void
adjust_window_size_for_csd(OSWindow *w, int width, int height, int *adjusted_width, int *adjusted_height) {
*adjusted_width = width; *adjusted_height = height;
if (global_state.is_wayland) {
int left = -1, top, right, bottom;
glfwGetWindowFrameSize(w->handle, &left, &top, &right, &bottom);
if (left > -1) {
*adjusted_width -= left + right;
*adjusted_height -= top + bottom;
*adjusted_width = MAX(0, *adjusted_width);
*adjusted_height = MAX(0, *adjusted_height);
}
}
}
void
update_os_window_viewport(OSWindow *window, bool notify_boss) {
int w, h, fw, fh;
@ -135,6 +151,7 @@ update_os_window_viewport(OSWindow *window, bool notify_boss) {
window->viewport_height = MAX(window->viewport_height, min_height);
window->window_width = MAX(w, min_width);
window->window_height = MAX(h, min_height);
adjust_window_size_for_csd(window, window->window_width, window->window_height, &window->content_area_width, &window->content_area_height);
if (notify_boss) {
call_boss(on_window_resize, "KiiO", window->id, window->viewport_width, window->viewport_height, dpi_changed ? Py_True : Py_False);
}
@ -652,13 +669,14 @@ set_os_window_dpi(OSWindow *w) {
static bool
do_toggle_fullscreen(OSWindow *w, unsigned int flags, bool restore_sizes) {
int width, height, x, y;
int width, height, x, y, content_area_width, content_area_height;
glfwGetWindowSize(w->handle, &width, &height);
glfwGetWindowPos(w->handle, &x, &y);
adjust_window_size_for_csd(w, width, height, &content_area_width, &content_area_height);
bool was_maximized = glfwGetWindowAttrib(w->handle, GLFW_MAXIMIZED);
if (glfwToggleFullscreen(w->handle, flags)) {
w->before_fullscreen.is_set = true;
w->before_fullscreen.w = width; w->before_fullscreen.h = height; w->before_fullscreen.x = x; w->before_fullscreen.y = y;
w->before_fullscreen.w = content_area_width; w->before_fullscreen.h = content_area_height; w->before_fullscreen.x = x; w->before_fullscreen.y = y;
w->before_fullscreen.was_maximized = was_maximized;
return true;
}

View File

@ -188,7 +188,7 @@ typedef struct {
int x, y, w, h;
bool is_set, was_maximized;
} before_fullscreen;
int viewport_width, viewport_height, window_width, window_height;
int viewport_width, viewport_height, window_width, window_height, content_area_width, content_area_height;
double viewport_x_ratio, viewport_y_ratio;
Tab *tabs;
BackgroundImage *bgimage;