Inform compositor of visible window geometry
The numbers dont make logical sense, but they do what is expected on GNOME and since only GNOME is stupid enough to insist on CSD, that's all we care about.
This commit is contained in:
parent
abf515ece9
commit
3e2b626107
16
glfw/wl_client_side_decorations.c
vendored
16
glfw/wl_client_side_decorations.c
vendored
@ -392,3 +392,19 @@ change_csd_title(_GLFWwindow *window) {
|
||||
damage_csd(top, decs.top.buffer.front);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
set_csd_window_geometry(_GLFWwindow *window, int32_t *width, int32_t *height) {
|
||||
bool has_csd = window->decorated && !window->wl.decorations.serverSide && window->wl.decorations.left.surface && !window->wl.fullscreened;
|
||||
bool size_specified_by_compositor = *width > 0 && *height > 0;
|
||||
if (!size_specified_by_compositor) { *width = window->wl.width; *height = window->wl.height; }
|
||||
struct { int32_t x, y, width, height; } geometry = {.x = 0, .y = 0, .width = *width, .height = *height};
|
||||
int scale = window->wl.scale >= 1 ? window->wl.scale : 1;
|
||||
if (has_csd) {
|
||||
int32_t visible_titlebar_height = decs.metrics.top - decs.metrics.width;
|
||||
geometry.y = -decs.metrics.top + decs.metrics.width / scale;
|
||||
geometry.height = *height;
|
||||
*height -= visible_titlebar_height;
|
||||
}
|
||||
xdg_surface_set_window_geometry(window->wl.xdg.surface, geometry.x, geometry.y, geometry.width, geometry.height);
|
||||
}
|
||||
|
||||
1
glfw/wl_client_side_decorations.h
vendored
1
glfw/wl_client_side_decorations.h
vendored
@ -13,3 +13,4 @@ void free_csd_surfaces(_GLFWwindow *window);
|
||||
void resize_csd(_GLFWwindow *window);
|
||||
void change_csd_title(_GLFWwindow *window);
|
||||
bool ensure_csd_resources(_GLFWwindow *window);
|
||||
void set_csd_window_geometry(_GLFWwindow *window, int32_t *width, int32_t *height);
|
||||
|
||||
10
glfw/wl_window.c
vendored
10
glfw/wl_window.c
vendored
@ -237,8 +237,6 @@ clipboard_mime(void) {
|
||||
}
|
||||
|
||||
static void dispatchChangesAfterConfigure(_GLFWwindow *window, int32_t width, int32_t height) {
|
||||
if (width <= 0) width = window->wl.width;
|
||||
if (height <= 0) height = window->wl.height;
|
||||
bool size_changed = width != window->wl.width || height != window->wl.height;
|
||||
bool scale_changed = checkScaleChange(window);
|
||||
|
||||
@ -444,12 +442,8 @@ static void xdgToplevelHandleConfigure(void* data,
|
||||
}
|
||||
}
|
||||
window->wl.fullscreened = fullscreen;
|
||||
if (!fullscreen) {
|
||||
if (window->decorated && !window->wl.decorations.serverSide && window->wl.decorations.left.surface) {
|
||||
width -= window->wl.decorations.metrics.horizontal;
|
||||
height -= window->wl.decorations.metrics.vertical;
|
||||
}
|
||||
}
|
||||
set_csd_window_geometry(window, &width, &height);
|
||||
wl_surface_commit(window->wl.surface);
|
||||
dispatchChangesAfterConfigure(window, width, height);
|
||||
_glfwInputWindowFocus(window, activated);
|
||||
ensure_csd_resources(window);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user