mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
seat: use focus_change event to update focused/active view
- Connect to wlr_seat_keyboard_state's focus_change event. - Add view_from_wlr_surface(), which does what the name says. - Use focus_change event along with view_from_wlr_surface() to update server->focused_view and set SSD states via view_set_activated(). - Eliminate desktop_focused_view() since server->focused_view should be reliably up-to-date now. - Eliminate view_focus/defocus() since we can now just call seat_focus_surface() directly.
This commit is contained in:
parent
bb5d272dc9
commit
4028a9482f
9 changed files with 77 additions and 100 deletions
26
src/seat.c
26
src/seat.c
|
|
@ -11,6 +11,7 @@
|
|||
#include "common/mem.h"
|
||||
#include "key-state.h"
|
||||
#include "labwc.h"
|
||||
#include "view.h"
|
||||
|
||||
static void
|
||||
input_device_destroy(struct wl_listener *listener, void *data)
|
||||
|
|
@ -335,6 +336,26 @@ new_virtual_keyboard(struct wl_listener *listener, void *data)
|
|||
seat_add_device(seat, input);
|
||||
}
|
||||
|
||||
static void
|
||||
focus_change_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct seat *seat = wl_container_of(listener, seat, focus_change);
|
||||
struct wlr_seat_keyboard_focus_change_event *event = data;
|
||||
struct server *server = seat->server;
|
||||
struct view *view = event->new_surface ?
|
||||
view_from_wlr_surface(event->new_surface) : NULL;
|
||||
|
||||
if (view != server->focused_view) {
|
||||
if (server->focused_view) {
|
||||
view_set_activated(server->focused_view, false);
|
||||
}
|
||||
if (view) {
|
||||
view_set_activated(view, true);
|
||||
}
|
||||
server->focused_view = view;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
seat_init(struct server *server)
|
||||
{
|
||||
|
|
@ -353,6 +374,10 @@ seat_init(struct server *server)
|
|||
seat->new_input.notify = new_input_notify;
|
||||
wl_signal_add(&server->backend->events.new_input, &seat->new_input);
|
||||
|
||||
seat->focus_change.notify = focus_change_notify;
|
||||
wl_signal_add(&seat->seat->keyboard_state.events.focus_change,
|
||||
&seat->focus_change);
|
||||
|
||||
seat->virtual_pointer = wlr_virtual_pointer_manager_v1_create(
|
||||
server->wl_display);
|
||||
wl_signal_add(&seat->virtual_pointer->events.new_virtual_pointer,
|
||||
|
|
@ -382,6 +407,7 @@ seat_finish(struct server *server)
|
|||
{
|
||||
struct seat *seat = &server->seat;
|
||||
wl_list_remove(&seat->new_input.link);
|
||||
wl_list_remove(&seat->focus_change.link);
|
||||
|
||||
struct input *input, *next;
|
||||
wl_list_for_each_safe(input, next, &seat->inputs, link) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue