diff options
-rw-r--r-- | include/rootston/seat.h | 2 | ||||
-rw-r--r-- | include/wlr/types/wlr_seat.h | 3 | ||||
-rw-r--r-- | rootston/desktop.c | 15 | ||||
-rw-r--r-- | rootston/seat.c | 6 | ||||
-rw-r--r-- | types/wlr_seat.c | 6 |
5 files changed, 24 insertions, 8 deletions
diff --git a/include/rootston/seat.h b/include/rootston/seat.h index b5593651..bef515a4 100644 --- a/include/rootston/seat.h +++ b/include/rootston/seat.h @@ -1,8 +1,6 @@ #ifndef _ROOTSTON_SEAT_H #define _ROOTSTON_SEAT_H - #include <wayland-server.h> - #include "rootston/input.h" #include "rootston/keyboard.h" diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 09d3e282..a5f00402 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -1,6 +1,6 @@ #ifndef WLR_TYPES_WLR_SEAT_H #define WLR_TYPES_WLR_SEAT_H - +#include <time.h> #include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_keyboard.h> @@ -109,6 +109,7 @@ struct wlr_seat { struct wl_list clients; char *name; uint32_t capabilities; + struct timespec last_event; struct wlr_data_device *data_device; // TODO needed? struct wlr_data_source *selection_source; diff --git a/rootston/desktop.c b/rootston/desktop.c index 448171ec..75526bcb 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -165,9 +165,22 @@ bool view_center(struct roots_view *view) { view_get_box(view, &box); struct roots_desktop *desktop = view->desktop; + struct roots_input *input = desktop->server->input; + struct roots_seat *seat = NULL, *_seat; + wl_list_for_each(_seat, &input->seats, link) { + if (!seat || (seat->seat->last_event.tv_sec > _seat->seat->last_event.tv_sec && + seat->seat->last_event.tv_nsec > _seat->seat->last_event.tv_nsec)) { + seat = _seat; + } + } + if (!seat) { + return false; + } struct wlr_output *output = - wlr_output_layout_get_center_output(desktop->layout); + wlr_output_layout_output_at(desktop->layout, + seat->cursor->cursor->x, + seat->cursor->cursor->y); if (!output) { // empty layout return false; diff --git a/rootston/seat.c b/rootston/seat.c index 4602aad5..b0688156 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -1,10 +1,8 @@ -#include <wayland-server.h> +#include <assert.h> #include <stdlib.h> #include <string.h> -#include <assert.h> - +#include <wayland-server.h> #include <wlr/util/log.h> - #include "rootston/xcursor.h" #include "rootston/input.h" #include "rootston/seat.h" diff --git a/types/wlr_seat.c b/types/wlr_seat.c index 9de1b3a0..dad88354 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -2,6 +2,7 @@ #include <assert.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <wayland-server.h> #include <wlr/types/wlr_seat.h> #include <wlr/types/wlr_input_device.h> @@ -574,12 +575,14 @@ void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat, void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, uint32_t time, double sx, double sy) { + clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event); struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab; grab->interface->motion(grab, time, sx, sy); } uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat, uint32_t time, uint32_t button, uint32_t state) { + clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event); if (state == WL_POINTER_BUTTON_STATE_PRESSED) { if (wlr_seat->pointer_state.button_count == 0) { wlr_seat->pointer_state.grab_button = button; @@ -602,6 +605,7 @@ uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat, void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time, enum wlr_axis_orientation orientation, double value) { + clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event); struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab; grab->interface->axis(grab, time, orientation, value); } @@ -804,12 +808,14 @@ void wlr_seat_keyboard_clear_focus(struct wlr_seat *seat) { } void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat) { + clock_gettime(CLOCK_MONOTONIC, &seat->last_event); struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab; grab->interface->modifiers(grab); } void wlr_seat_keyboard_notify_key(struct wlr_seat *seat, uint32_t time, uint32_t key, uint32_t state) { + clock_gettime(CLOCK_MONOTONIC, &seat->last_event); struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab; grab->interface->key(grab, time, key, state); } |