aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-04-21 14:07:22 +0100
committerLibravatar emersion <contact@emersion.fr>2018-04-21 14:07:22 +0100
commit4cf77e1de4b0be8b7d9374f04ff0e191ce22610a (patch)
tree21b52ebdf2de5dffa5177000626ae9ddd2a16f44 /sway/input
parentMerge pull request #1836 from emersion/workspace-focus-update-cursor (diff)
downloadsway-4cf77e1de4b0be8b7d9374f04ff0e191ce22610a.tar.gz
sway-4cf77e1de4b0be8b7d9374f04ff0e191ce22610a.tar.zst
sway-4cf77e1de4b0be8b7d9374f04ff0e191ce22610a.zip
Default to current time when triggering cursor events
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c18
-rw-r--r--sway/input/seat.c8
2 files changed, 18 insertions, 8 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 5ed4f1f7..831109dc 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -15,6 +15,12 @@
15#include "sway/tree/workspace.h" 15#include "sway/tree/workspace.h"
16#include "wlr-layer-shell-unstable-v1-protocol.h" 16#include "wlr-layer-shell-unstable-v1-protocol.h"
17 17
18static uint32_t get_current_time_msec() {
19 struct timespec now;
20 clock_gettime(CLOCK_MONOTONIC, &now);
21 return now.tv_nsec / 1000;
22}
23
18static struct wlr_surface *layer_surface_at(struct sway_output *output, 24static struct wlr_surface *layer_surface_at(struct sway_output *output,
19 struct wl_list *layer, double ox, double oy, double *sx, double *sy) { 25 struct wl_list *layer, double ox, double oy, double *sx, double *sy) {
20 struct sway_layer_surface *sway_layer; 26 struct sway_layer_surface *sway_layer;
@@ -128,7 +134,11 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor,
128 return output->swayc; 134 return output->swayc;
129} 135}
130 136
131void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time) { 137void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec) {
138 if (time_msec == 0) {
139 time_msec = get_current_time_msec();
140 }
141
132 struct wlr_seat *seat = cursor->seat->wlr_seat; 142 struct wlr_seat *seat = cursor->seat->wlr_seat;
133 struct wlr_surface *surface = NULL; 143 struct wlr_surface *surface = NULL;
134 double sx, sy; 144 double sx, sy;
@@ -152,7 +162,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time) {
152 if (surface != NULL) { 162 if (surface != NULL) {
153 if (seat_is_input_allowed(cursor->seat, surface)) { 163 if (seat_is_input_allowed(cursor->seat, surface)) {
154 wlr_seat_pointer_notify_enter(seat, surface, sx, sy); 164 wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
155 wlr_seat_pointer_notify_motion(seat, time, sx, sy); 165 wlr_seat_pointer_notify_motion(seat, time_msec, sx, sy);
156 } 166 }
157 } else { 167 } else {
158 wlr_seat_pointer_clear_focus(seat); 168 wlr_seat_pointer_clear_focus(seat);
@@ -178,6 +188,10 @@ static void handle_cursor_motion_absolute(
178 188
179void dispatch_cursor_button(struct sway_cursor *cursor, 189void dispatch_cursor_button(struct sway_cursor *cursor,
180 uint32_t time_msec, uint32_t button, enum wlr_button_state state) { 190 uint32_t time_msec, uint32_t button, enum wlr_button_state state) {
191 if (time_msec == 0) {
192 time_msec = get_current_time_msec();
193 }
194
181 struct wlr_surface *surface = NULL; 195 struct wlr_surface *surface = NULL;
182 double sx, sy; 196 double sx, sy;
183 struct sway_container *cont = 197 struct sway_container *cont =
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 631a273f..d1fc62c4 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -550,9 +550,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
550 wlr_output, seat->cursor->cursor->x, 550 wlr_output, seat->cursor->cursor->x,
551 seat->cursor->cursor->y)) { 551 seat->cursor->cursor->y)) {
552 wlr_cursor_warp(seat->cursor->cursor, NULL, x, y); 552 wlr_cursor_warp(seat->cursor->cursor, NULL, x, y);
553 struct timespec now; 553 cursor_send_pointer_motion(seat->cursor, 0);
554 clock_gettime(CLOCK_MONOTONIC, &now);
555 cursor_send_pointer_motion(seat->cursor, now.tv_nsec / 1000);
556 } 554 }
557 } 555 }
558 } 556 }
@@ -565,9 +563,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
565 } 563 }
566 564
567 if (last_workspace && last_workspace != new_workspace) { 565 if (last_workspace && last_workspace != new_workspace) {
568 struct timespec now; 566 cursor_send_pointer_motion(seat->cursor, 0);
569 clock_gettime(CLOCK_MONOTONIC, &now);
570 cursor_send_pointer_motion(seat->cursor, now.tv_nsec / 1000);
571 } 567 }
572 568
573 seat->has_focus = (container != NULL); 569 seat->has_focus = (container != NULL);