Skip to content

Fix bug on get_keyboard without surface#1067

Open
jgroboredo wants to merge 1 commit into
mahkoh:masterfrom
jgroboredo:master
Open

Fix bug on get_keyboard without surface#1067
jgroboredo wants to merge 1 commit into
mahkoh:masterfrom
jgroboredo:master

Conversation

@jgroboredo

@jgroboredo jgroboredo commented Jul 4, 2026

Copy link
Copy Markdown

Hello,

I was testing Jay for the first time and noticed that my terminal would hang when I tried to yank to clipboard in helix editor.

Launching wl-copy and wl-paste with wayland debug, I noticed the following:

WAYLAND_DEBUG=1 wl-copy output (truncated)

[ 593417.233] {Default Queue} wl_seat#10.capabilities(3)
[ 593417.241] {Default Queue} wl_seat#10.name("default")
[ 593417.262] {Default Queue} wl_callback#3.done(0)
[ 593417.269] {Default Queue}  -> wl_data_device_manager#6.get_data_device(new id wl_data_device#3, wl_seat#10)
[ 593568.306] {Default Queue}  -> wl_data_device_manager#6.create_data_source(new id wl_data_source#11)
[ 593568.327] {Default Queue}  -> wl_data_source#11.offer("text/plain")
[ 593568.334] {Default Queue}  -> wl_data_source#11.offer("text/plain")
[ 593568.339] {Default Queue}  -> wl_data_source#11.offer("text/plain;charset=utf-8")
[ 593568.346] {Default Queue}  -> wl_data_source#11.offer("TEXT")
[ 593568.370] {Default Queue}  -> wl_data_source#11.offer("STRING")
[ 593568.376] {Default Queue}  -> wl_data_source#11.offer("UTF8_STRING")
[ 593568.384] {Default Queue}  -> wl_seat#10.get_keyboard(new id wl_keyboard#12)

and then the process hangs.

Same with:

WAYLAND_DEBUG=1 wl-paste output (truncated)

[ 607809.706] {Default Queue} wl_seat#10.capabilities(3)
[ 607809.712] {Default Queue} wl_seat#10.name("default")
[ 607809.718] {Default Queue} wl_callback#3.done(0)
[ 607809.725] {Default Queue}  -> wl_data_device_manager#6.get_data_device(new id wl_data_device#3, wl_seat#10)
[ 607809.734] {Default Queue}  -> wl_seat#10.get_keyboard(new id wl_keyboard#11)

I have played a bit with compositor development in the past, and I remember I had to specifically handle wl-copy and wl-paste - they spawn a 1x1 surface. Right now, jay is actually tiling this surface and, after this fix, I see it being spawned for a split second when I launch wl-copy or wl-paste in a terminal. You might want to fix that in a separate PR.

I would also recommend taking a look at wlroots. They always send the keymap, as you can check there.

I am not too comfortable with jay or even wlroots. Feel free to propose some other solution to this specific problem if you are not happy with the fix, I'd be glad to help.

Cheers

Send keymap even when there isn't a focused surface
@Ktrompfl

Ktrompfl commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

wl-clipboard uses the data-control protocols which are privileged in jay. From the absence of ext_data_control messages in the wayland debug log I assume wl-clipboard does not have access to these protocols. You can give wl-copy / wl-paste the required capabilities in your config with

[[clients]]
match.any = [
    { comm = "wl-copy" },
    { comm = "wl-paste" },
]
capabilities = "data-control"

or by running them with jay run-privileged.

@jgroboredo

Copy link
Copy Markdown
Author

wl-clipboard uses the data-control protocols which are privileged in jay. From the absence of ext_data_control messages in the wayland debug log I assume wl-clipboard does not have access to these protocols. You can give wl-copy / wl-paste the required capabilities in your config with

[[clients]]
match.any = [
    { comm = "wl-copy" },
    { comm = "wl-paste" },
]
capabilities = "data-control"

or by running them with jay run-privileged.

Yup, this fixes it. Thank you.

Should I close the PR?

}

pub fn send_initial_keymap(self: &Rc<Self>, state: &KeyboardState) {
self.send_keymap(state);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.send_keymap(state);
self.kb_state_id.set(kb_state.id);
self.send_keymap(state);

@mahkoh

mahkoh commented Jul 8, 2026

Copy link
Copy Markdown
Owner

It might make sense to do this. Some debugging clients might want to get the keymap without creating a window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants