Don't override IME grab with popup keyboard grab
Browse files at this commit19e55a2df095d14f9490b79e38193ad4b4e87bb9Parent: 64722091 changed file +18 -10
- src/handlers/xdg_shell.rs +18 -10
src/handlers/xdg_shell.rsmodified+18 -10
| @@ -23,6 +23,7 @@ use smithay::wayland::compositor::{ | |||
| 23 | HookId, SurfaceAttributes, | 23 | HookId, SurfaceAttributes, |
| 24 | }; | 24 | }; |
| 25 | use smithay::wayland::dmabuf::get_dmabuf; | 25 | use smithay::wayland::dmabuf::get_dmabuf; |
| 26 | +use smithay::wayland::input_method::InputMethodSeat; | ||
| 26 | use smithay::wayland::shell::kde::decoration::{KdeDecorationHandler, KdeDecorationState}; | 27 | use smithay::wayland::shell::kde::decoration::{KdeDecorationHandler, KdeDecorationState}; |
| 27 | use smithay::wayland::shell::wlr_layer::{self, Layer}; | 28 | use smithay::wayland::shell::wlr_layer::{self, Layer}; |
| 28 | use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler; | 29 | use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler; |
| @@ -363,16 +364,23 @@ impl XdgShellHandler for State { | |||
| 363 | let keyboard = seat.get_keyboard().unwrap(); | 364 | let keyboard = seat.get_keyboard().unwrap(); |
| 364 | let pointer = seat.get_pointer().unwrap(); | 365 | let pointer = seat.get_pointer().unwrap(); |
| 365 | 366 | ||
| 366 | - let can_receive_keyboard_focus = self | 367 | + // Smithay cannot do overlapping grabs, so if we have an IME keyboard grab, don't overwrite |
| 367 | - .niri | 368 | + // it with a popup keyboard grab. This makes the popup menu work in Telegram while an IME |
| 368 | - .layout | 369 | + // is active (otherwise it hits the grab mismatch check below). |
| 369 | - .active_output() | 370 | + // |
| 370 | - .and_then(|output| { | 371 | + // The second check is for layer surfaces that can't receive keyboard focus, without it |
| 371 | - layer_map_for_output(output) | 372 | + // popups don't work properly in Waybar (GTK 3). |
| 372 | - .layer_for_surface(&root, WindowSurfaceType::TOPLEVEL) | 373 | + let can_receive_keyboard_focus = !self.niri.seat.input_method().keyboard_grabbed() |
| 373 | - .map(|layer_surface| layer_surface.can_receive_keyboard_focus()) | 374 | + && self |
| 374 | - }) | 375 | + .niri |
| 375 | - .unwrap_or(true); | 376 | + .layout |
| 377 | + .active_output() | ||
| 378 | + .and_then(|output| { | ||
| 379 | + layer_map_for_output(output) | ||
| 380 | + .layer_for_surface(&root, WindowSurfaceType::TOPLEVEL) | ||
| 381 | + .map(|layer_surface| layer_surface.can_receive_keyboard_focus()) | ||
| 382 | + }) | ||
| 383 | + .unwrap_or(true); | ||
| 376 | 384 | ||
| 377 | let keyboard_grab_mismatches = keyboard.is_grabbed() | 385 | let keyboard_grab_mismatches = keyboard.is_grabbed() |
| 378 | && !(keyboard.has_grab(serial) | 386 | && !(keyboard.has_grab(serial) |