]> git.mdlowis.com Git - proto/labwc.git/commitdiff
seat: refactor seat_focus_surface()
authorJohan Malm <jgm323@gmail.com>
Thu, 8 Oct 2020 19:22:52 +0000 (20:22 +0100)
committerJohan Malm <jgm323@gmail.com>
Thu, 8 Oct 2020 19:22:52 +0000 (20:22 +0100)
include/labwc.h
src/desktop.c
src/seat.c
src/xwayland-unmanaged.c

index df9e80121eada5e38b506e863512505327700915..974381d172ba9441a935f4e056498be0f0849150 100644 (file)
@@ -240,7 +240,7 @@ void keyboard_init(struct seat *seat);
 
 void seat_init(struct server *server);
 void seat_finish(struct server *server);
-void seat_focus_surface(struct wlr_seat *seat, struct wlr_surface *surface);
+void seat_focus_surface(struct seat *seat, struct wlr_surface *surface);
 
 void interactive_begin(struct view *view, enum cursor_mode mode,
                       uint32_t edges);
index 371432f864daac8498bc0529da00112a7e3d1fd4..d818accc29056b7c9ba576d8805f39d016702ad8 100644 (file)
@@ -68,7 +68,7 @@ void
 desktop_focus_view(struct seat *seat, struct view *view)
 {
        if (!view) {
-               seat_focus_surface(seat->seat, NULL);
+               seat_focus_surface(seat, NULL);
                return;
        }
        if (view->minimized) {
@@ -87,7 +87,7 @@ desktop_focus_view(struct seat *seat, struct view *view)
                }
                move_to_front(view);
                set_activated(view->surface, true);
-               seat_focus_surface(seat->seat, view->surface);
+               seat_focus_surface(seat, view->surface);
                move_xwayland_sub_views_to_front(view);
        }
 }
index d9a09b495106add323339f821b0c7907fad83067..137a53181480d96b0730c46e0bdb4ac7b5c6c39c 100644 (file)
@@ -2,8 +2,6 @@
 #include <wlr/util/log.h>
 #include "labwc.h"
 
-static struct seat *current_seat;
-
 static void
 input_device_destroy(struct wl_listener *listener, void *data)
 {
@@ -80,7 +78,6 @@ seat_init(struct server *server)
                wlr_log(WLR_ERROR, "cannot allocate seat");
                exit(EXIT_FAILURE);
        }
-       current_seat = seat;
 
        wl_list_init(&seat->inputs);
        seat->new_input.notify = new_input_notify;
@@ -118,13 +115,13 @@ seat_finish(struct server *server)
 }
 
 void
-seat_focus_surface(struct wlr_seat *seat, struct wlr_surface *surface)
+seat_focus_surface(struct seat *seat, struct wlr_surface *surface)
 {
        if (!surface) {
-               wlr_seat_keyboard_notify_clear_focus(seat);
+               wlr_seat_keyboard_notify_clear_focus(seat->seat);
                return;
        }
-       struct wlr_keyboard *kb = &current_seat->keyboard_group->keyboard;
-       wlr_seat_keyboard_notify_enter(seat, surface, kb->keycodes,
+       struct wlr_keyboard *kb = &seat->keyboard_group->keyboard;
+       wlr_seat_keyboard_notify_enter(seat->seat, surface, kb->keycodes,
                kb->num_keycodes, &kb->modifiers);
 }
index 606f28b6ec209110d2289198257de6480fd4bf24..a9855d35dc8f27606c6b1370c837096198ce9d16 100644 (file)
@@ -38,8 +38,7 @@ unmanaged_handle_map(struct wl_listener *listener, void *data)
        unmanaged->ly = xsurface->y;
 
        if (wlr_xwayland_or_surface_wants_focus(xsurface)) {
-               struct wlr_seat *seat = unmanaged->server->seat.seat;
-               seat_focus_surface(seat, xsurface->surface);
+               seat_focus_surface(&unmanaged->server->seat, xsurface->surface);
        }
 }
 
@@ -52,8 +51,8 @@ unmanaged_handle_unmap(struct wl_listener *listener, void *data)
        wl_list_remove(&unmanaged->link);
        wl_list_remove(&unmanaged->commit.link);
 
-       struct wlr_seat *seat = unmanaged->server->seat.seat;
-       if (seat->keyboard_state.focused_surface == xsurface->surface) {
+       struct seat *seat = &unmanaged->server->seat;
+       if (seat->seat->keyboard_state.focused_surface == xsurface->surface) {
                struct xwayland_unmanaged *u;
                struct wl_list *list = &unmanaged->server->unmanaged_surfaces;
                wl_list_for_each (u, list, link) {