kitty/glfw/wl_client_side_decorations.h
Kovid Goyal 2b260d8d67
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Wayland CSD: Re-render on keyboard focus changes
The focus state of the decorations comes only from keyboard enter/leave
events, but the decorations were only re-rendered on configure events and
title changes. So they showed a stale focus state whenever focus changed
without a following configure, for example, when switching between tabbed
windows in niri, which keeps all tabs activated.

Re-render the decorations on keyboard enter/leave, looking up the window
again after the focus callbacks have run, since they can close it.

Also:
- Ignore the activated state in the change detection, as focus is tracked
  separately, to avoid rendering twice per focus change.
- Never create decoration surfaces in ensure_csd_resources() for windows
  that should not be decorated, such as fullscreen windows. Title changes
  while fullscreen could previously create them from a stale state.
- Recreate the decoration surfaces when they are missing even if the
  window state is unchanged, otherwise the resize borders were not
  restored after leaving fullscreen with hide_window_decorations
  titlebar-only.

Based on the patch by Ole Jørgen Brønner.

Closes #10873
2026-11-15 20:06:45 +05:30

25 lines
1.1 KiB
C
Vendored

/*
* Copyright (C) 2021 Kovid Goyal <kovid at kovidgoyal.net>
*
* Distributed under terms of the GPL3 license.
*/
#pragma once
#include "internal.h"
void csd_initialize_metrics(_GLFWwindow *window);
void csd_free_all_resources(_GLFWwindow *window);
bool csd_change_title(_GLFWwindow *window);
bool csd_handle_focus_change(_GLFWwindow *window);
void csd_set_window_geometry(_GLFWwindow *window, int32_t *width, int32_t *height);
bool csd_set_titlebar_color(_GLFWwindow *window, uint32_t color, bool use_system_color);
bool csd_should_window_be_decorated(_GLFWwindow *window);
void csd_set_visible(_GLFWwindow *window, bool visible);
void csd_handle_pointer_event(_GLFWwindow *window, int button, int state, struct wl_surface *surface);
bool csd_handle_touch_down(_GLFWwindow *window, struct wl_surface *surface, int32_t id, uint32_t serial, double sx, double sy);
void csd_drop_stale_touch(int32_t id);
bool csd_is_tracking_touch(int32_t id);
void csd_handle_touch_motion(int32_t id, double sx, double sy);
void csd_handle_touch_up(int32_t id);
void csd_handle_touch_cancel(void);