]> git.mdlowis.com Git - proto/labwc.git/commit
view: try to reduce confusion in focused_view tracking
authorJohn Lindgren <john@jlindgren.net>
Tue, 26 Sep 2023 05:35:36 +0000 (01:35 -0400)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 27 Sep 2023 16:13:08 +0000 (17:13 +0100)
commit3022985ba797a061df8c8ac33b2dfb77bf20dcb3
treee6af7322f62c7ae88ef75baeb3adcfd5cafdf667
parent003d1fd494eed927ca2205a6dd3776c12ea4c9e9
view: try to reduce confusion in focused_view tracking

Our current approach to handling the focused/active view is a bit
confusing. In particular, it's hard to be sure when server->focused_view
is or isn't in sync with the real wlroots keyboard focus.

Try to clean things up a bit. In particular:

- Add comments to server->focused_view and desktop_focused_view() to
  clarify that they should match, but it's not guaranteed.

- desktop_focused_view() now prints a warning if it detects that
  server->focused_view is out of sync. We should keep an eye out for
  this warning, and if we see it, try to figure out why it happened.

- For consistency, use only "focus/defocus" as the verbs in function
  names rather than "activate". This is a bit arbitrary, but the idea is
  that focus is the primary action while the active/inactive state is a
  side effect.

- view_focus/defocus() replace view_set_activated() and now update both
  focus and active/inactive state, to try to keep them in sync.

- Add comments at view_focus/defocus() to warn against calling them
  directly (we should generally call the desktop.c functions).

- desktop_focus_view(NULL) is now forbidden and is no longer handled as
  a special case to clear the focus. This was (at least to me) a
  surprising behavior and caused trouble when working on another change.

- To maintain existing behavior, desktop_focus_topmost_mapped_view() now
  explicitly clears the focus if there are no mapped views.

There should be no behavioral change here.
include/labwc.h
include/view.h
src/action.c
src/cursor.c
src/desktop.c
src/foreign.c
src/keyboard.c
src/view-impl-common.c
src/view.c
src/xdg.c
src/xwayland.c