mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
Clear keyboard/pointer focus on Move/Resize, window switcher and menu
The previous revert fixed the problem of stuck modifier keys with
keybinds in Blender, but made Firefox show its menu bar with Alt-*
keybinds. This is fundamentally inevitable due to the limitation of
wayland protocol, but at least for the default Alt-Tab keybind for
window switcher, we can mitigate this problem by clearing the keyboard
focus when the window switcher is activated. This is what KWin does, and
we decided to follow that.
So in this commit, keyboard and pointer focus are temporarily cleared
while Move/Resize, window switcher and menu interactions and restored
after them. We slightly deviate from KWin as KWin doesn't clear the
keyboard focus while Move/Resize, but it solves our existing problem
that Firefox shows its menu bar after dragging it with default Alt-Drag
mousebind, and this is what Mutter does.
We considered other solutions, but they don't work well:
1. Send wl_keyboard.{leave,enter} every time keybinds/mousebinds are
triggered. This solves the Firefox's menu bar problem, but that
sounds like a workaround and sending unnecessary events every time is
not desirable.
2. Send release events for both modifiers and keys even when they are
bound to keybinds. This is what Mutter is doing, but it looks like an
implementation issue and violates wayland protocol.
This commit is contained in:
parent
bd7a533dd6
commit
bad788ccdd
9 changed files with 139 additions and 54 deletions
|
|
@ -116,6 +116,16 @@ struct seat {
|
|||
double x, y;
|
||||
} smooth_scroll_offset;
|
||||
|
||||
/*
|
||||
* The surface whose keyboard focus is temporarily cleared with
|
||||
* seat_focus_override_begin() and restored with
|
||||
* seat_focus_override_end().
|
||||
*/
|
||||
struct {
|
||||
struct wlr_surface *surface;
|
||||
struct wl_listener surface_destroy;
|
||||
} focus_override;
|
||||
|
||||
struct wlr_pointer_constraint_v1 *current_constraint;
|
||||
|
||||
/* In support for ToggleKeybinds */
|
||||
|
|
@ -273,9 +283,13 @@ struct server {
|
|||
* 'active_view' is generally the view with keyboard-focus, updated with
|
||||
* each "focus change". This view is drawn with "active" SSD coloring.
|
||||
*
|
||||
* The exception is when a layer-shell client takes keyboard-focus in
|
||||
* which case the currently active view stays active. This is important
|
||||
* for foreign-toplevel protocol.
|
||||
* The exceptions are:
|
||||
* - when a layer-shell client takes keyboard-focus in which case the
|
||||
* currently active view stays active
|
||||
* - when keyboard focus is temporarily cleared for server-side
|
||||
* interactions like Move/Resize, window switcher and menus.
|
||||
*
|
||||
* Note that active_view is synced with foreign-toplevel clients.
|
||||
*/
|
||||
struct view *active_view;
|
||||
/*
|
||||
|
|
@ -503,6 +517,20 @@ void seat_set_pressed(struct seat *seat, struct cursor_context *ctx);
|
|||
void seat_reset_pressed(struct seat *seat);
|
||||
void seat_output_layout_changed(struct seat *seat);
|
||||
|
||||
/*
|
||||
* Temporarily clear the pointer/keyboard focus from the client at the
|
||||
* beginning of interactive move/resize, window switcher or menu interactions.
|
||||
* The focus is kept cleared until seat_focus_override_end() is called or
|
||||
* layer-shell/session-lock surfaces are mapped.
|
||||
*/
|
||||
void seat_focus_override_begin(struct seat *seat, enum input_mode input_mode,
|
||||
enum lab_cursors cursor_shape);
|
||||
/*
|
||||
* Restore the pointer/keyboard focus which was cleared in
|
||||
* seat_focus_override_begin().
|
||||
*/
|
||||
void seat_focus_override_end(struct seat *seat);
|
||||
|
||||
/**
|
||||
* interactive_anchor_to_cursor() - repositions the geometry to remain
|
||||
* underneath the cursor when its size changes during interactive move.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue