Skip to content

api: make input focus global state #1913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2023
Merged

api: make input focus global state #1913

merged 1 commit into from
Sep 29, 2023

Conversation

ammen99
Copy link
Member

@ammen99 ammen99 commented Sep 28, 2023

The keyboard input focus has always been a global state (to be precise, per-seat, but Wayfire has only one seat anyway). However, previously the focused view has been managed per-output, which makes little sense and does not reflect reality, nor the desired behavior. This commit moves all keyboard-focus functionality out of wf::output_t and into wf::seat_t.

Fixes #1892

@ammen99
Copy link
Member Author

ammen99 commented Sep 28, 2023

Breaking changes for plugins: focus is no longer per-output, hence:

  1. wf::get_core().get_active_output() and wf::get_core().focus_output() have been moved to wf::seat_t (so for example use wf::get_core().seat->focus_output() to focus an output).
  2. output->refocus() becomes wf::get_core().seat->refocus().
  3. output->get_active_view() can be replaced with wf::get_active_view_for_output(output) or wf::get_core().seat->get_active_view(). The latter returns the globally focused view, the former checks whether the output is focused, if not, it returns null, otherwise the same as the seat's get_active_view().
  4. output->focus_view() is not a very well defined function, because it does a ton of things. There are multiple alternatives available, depending on what one wants to do:
    • wf::get_core().seat->focus_view(): this is a very basic function and just focuses the view, no unminimizing, raising the view, etc. This is a rather low-level function.
    • wf::get_core().default_wm->focus_raise_view(): this is pretty much calling output->focus_view(view, true): focus the view, raise to the top, unminimize, etc.
    • wf::get_core().default_wm->focus_request(): this is the same as focus_raise_view(), but it emits a focus_request signal, which gives plugins a chance to deny the focus request. This is used for example when a new view is mapped, so that focus stealing prevention can work.
    • There is no output-specific view-focused signal, instead, plugins can use the global keyboard focus changed in core to figure out what is going on with focus. Also, the pre-focus signal has been removed in favor of the focus-request as explained in the previous point.

@ammen99 ammen99 added the api-breaking API breaking change label Sep 28, 2023
@ammen99 ammen99 force-pushed the remove-per-output-focus branch from e9cb17a to 271195d Compare September 29, 2023 10:03
The keyboard input focus has always been a global state (to be precise,
per-seat, but Wayfire has only one seat anyway). However, previously the
focused view has been managed per-output, which makes little sense and
does not reflect reality, nor the desired behavior. This commit moves
all keyboard-focus functionality out of wf::output_t and into
wf::seat_t.

Should fix #1892
@ammen99 ammen99 force-pushed the remove-per-output-focus branch from 271195d to e92133a Compare September 29, 2023 12:45
@ammen99 ammen99 merged commit 3ac0284 into master Sep 29, 2023
@ammen99 ammen99 deleted the remove-per-output-focus branch September 29, 2023 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-breaking API breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Moving view activates view on other display
1 participant