Skip to content

Commit 8017945

Browse files
committed
Wayland: Add support for the xdg-toplevel-tag protocol
Now you can use --name or its alias --os-window-tag to set the tag.
1 parent 1157777 commit 8017945

File tree

9 files changed

+29
-10
lines changed

9 files changed

+29
-10
lines changed

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ Detailed list of changes
123123

124124
- Panel kitten: A new ``center-sized`` value for :option:`--edge <kitty +kitten panel --edge>` to allow easily creating sized and centered panels
125125

126+
- Wayland: The `kitty --name` flag now sets the XDG *window tag* on compositors
127+
that support the `xdg-toplevel-tag <https://wayland.app/protocols/xdg-toplevel-tag-v1>`__ protocol.
128+
126129

127130
0.42.0 [2025-05-11]
128131
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

glfw/glfw3.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,7 @@ typedef enum {
10561056

10571057
#define GLFW_WAYLAND_APP_ID 0x00025001
10581058
#define GLFW_WAYLAND_BGCOLOR 0x00025002
1059+
#define GLFW_WAYLAND_WINDOW_TAG 0x00025003
10591060
/*! @} */
10601061

10611062
#define GLFW_NO_API 0

glfw/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ struct _GLFWwndconfig
331331
char instanceName[256];
332332
} x11;
333333
struct {
334-
char appId[256];
334+
char appId[256], windowTag[256];
335335
uint32_t bgcolor;
336336
} wl;
337337
};

glfw/source-info.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"unstable/idle-inhibit/idle-inhibit-unstable-v1.xml",
8787
"staging/xdg-toplevel-icon/xdg-toplevel-icon-v1.xml",
8888
"staging/xdg-system-bell/xdg-system-bell-v1.xml",
89+
"staging/xdg-toplevel-tag/xdg-toplevel-tag-v1.xml",
8990

9091
"kwin-blur-v1.xml",
9192
"wlr-layer-shell-unstable-v1.xml"

glfw/window.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,10 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value)
495495
strncpy(_glfw.hints.window.wl.appId, value,
496496
sizeof(_glfw.hints.window.wl.appId) - 1);
497497
return;
498+
case GLFW_WAYLAND_WINDOW_TAG:
499+
strncpy(_glfw.hints.window.wl.windowTag, value,
500+
sizeof(_glfw.hints.window.wl.windowTag) - 1);
501+
return;
498502
}
499503

500504
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint string 0x%08X", hint);

glfw/wl_init.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ static void registryHandleGlobal(void* data UNUSED,
605605
}
606606
else if (is(xdg_system_bell_v1)) {
607607
_glfw.wl.xdg_system_bell_v1 = wl_registry_bind(registry, name, &xdg_system_bell_v1_interface, 1);
608+
} else if (is(xdg_toplevel_tag_manager_v1)) {
609+
_glfw.wl.xdg_toplevel_tag_manager_v1 = wl_registry_bind(registry, name, &xdg_toplevel_tag_manager_v1_interface, 1);
608610
}
609611
#undef is
610612
}
@@ -716,6 +718,7 @@ get_compositor_missing_capabilities(void) {
716718
C(cursor_shape, wp_cursor_shape_manager_v1); C(layer_shell, zwlr_layer_shell_v1);
717719
C(single_pixel_buffer, wp_single_pixel_buffer_manager_v1); C(preferred_scale, has_preferred_buffer_scale);
718720
C(idle_inhibit, idle_inhibit_manager); C(icon, xdg_toplevel_icon_manager_v1); C(bell, xdg_system_bell_v1);
721+
C(window-tag, xdg_toplevel_tag_manager_v1);
719722
if (_glfw.wl.xdg_wm_base_version < 6) p += snprintf(p, sizeof(buf) - (p - buf), "%s ", "window-state-suspended");
720723
if (_glfw.wl.xdg_wm_base_version < 5) p += snprintf(p, sizeof(buf) - (p - buf), "%s ", "window-capabilities");
721724
#undef C
@@ -894,6 +897,8 @@ void _glfwPlatformTerminate(void)
894897
xdg_toplevel_icon_manager_v1_destroy(_glfw.wl.xdg_toplevel_icon_manager_v1);
895898
if (_glfw.wl.xdg_system_bell_v1)
896899
xdg_system_bell_v1_destroy(_glfw.wl.xdg_system_bell_v1);
900+
if (_glfw.wl.xdg_toplevel_tag_manager_v1)
901+
xdg_toplevel_tag_manager_v1_destroy(_glfw.wl.xdg_toplevel_tag_manager_v1);
897902
if (_glfw.wl.wp_single_pixel_buffer_manager_v1)
898903
wp_single_pixel_buffer_manager_v1_destroy(_glfw.wl.wp_single_pixel_buffer_manager_v1);
899904
if (_glfw.wl.wp_cursor_shape_manager_v1)

glfw/wl_platform.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
6868
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
6969
#include "wayland-xdg-toplevel-icon-v1-client-protocol.h"
7070
#include "wayland-xdg-system-bell-v1-client-protocol.h"
71+
#include "wayland-xdg-toplevel-tag-v1-client-protocol.h"
7172

7273
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
7374
#define _glfw_dlclose(handle) dlclose(handle)
@@ -210,7 +211,7 @@ typedef struct _GLFWwindowWayland
210211
double cursorPosX, cursorPosY, allCursorPosX, allCursorPosY;
211212

212213
char* title;
213-
char appId[256];
214+
char appId[256], windowTag[256];
214215

215216
// We need to track the monitors the window spans on to calculate the
216217
// optimal scaling factor.
@@ -340,6 +341,7 @@ typedef struct _GLFWlibraryWayland
340341
struct xdg_activation_v1* xdg_activation_v1;
341342
struct xdg_toplevel_icon_manager_v1* xdg_toplevel_icon_manager_v1;
342343
struct xdg_system_bell_v1* xdg_system_bell_v1;
344+
struct xdg_toplevel_tag_manager_v1* xdg_toplevel_tag_manager_v1;
343345
struct wp_cursor_shape_manager_v1* wp_cursor_shape_manager_v1;
344346
struct wp_cursor_shape_device_v1* wp_cursor_shape_device_v1;
345347
struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1;

glfw/wl_window.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,8 +1198,10 @@ create_window_desktop_surface(_GLFWwindow* window)
11981198
zxdg_toplevel_decoration_v1_add_listener(window->wl.xdg.decoration, &xdgDecorationListener, window);
11991199
}
12001200

1201-
if (strlen(window->wl.appId))
1201+
if (window->wl.appId[0])
12021202
xdg_toplevel_set_app_id(window->wl.xdg.toplevel, window->wl.appId);
1203+
if (window->wl.windowTag[0] && _glfw.wl.xdg_toplevel_tag_manager_v1)
1204+
xdg_toplevel_tag_manager_v1_set_toplevel_tag(_glfw.wl.xdg_toplevel_tag_manager_v1, window->wl.xdg.toplevel, window->wl.windowTag);
12031205

12041206
if (window->wl.title)
12051207
xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title);

kitty/simple_cli_definitions.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,13 @@ def kitty_options_spec() -> str:
375375
dest=cls
376376
default={appname}
377377
condition=not is_macos
378-
Set the class part of the :italic:`WM_CLASS` window property. On Wayland, it
379-
sets the app id.
378+
Set the :italic:`application id` on Wayland. On X11 set the class part of the :italic:`WM_CLASS` window property.
380379
381380
382-
--name
381+
--name --os-window-tag
383382
condition=not is_macos
384-
Set the name part of the :italic:`WM_CLASS` property. Defaults to using the
383+
On Wayland, set the :italic:`window tag`.
384+
On X11, set the name part of the :italic:`WM_CLASS` property, when unset, defaults to using the
385385
value from :option:`{appname} --class`.
386386
387387
@@ -650,12 +650,13 @@ def build_panel_cli_spec(defaults: dict[str, str]) -> str:
650650
dest=cls
651651
default={cls}
652652
condition=not is_macos
653-
Set the class part of the :italic:`WM_CLASS` window property. On Wayland, it sets the app id.
653+
Set the :italic:`application id` on Wayland. On X11 set the class part of the :italic:`WM_CLASS` window property.
654654
655655
656-
--name
656+
--name --os-window-tag
657657
condition=not is_macos
658-
Set the name part of the :italic:`WM_CLASS` property (defaults to using the value from :option:`{appname} --class`)
658+
On X11 sets the name part of the :italic:`WM_CLASS` property on X11,
659+
when unspecified uses the value from :option:`{appname} --class` on X11.
659660
660661
661662
--focus-policy

0 commit comments

Comments
 (0)