aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/seat
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/commands/seat
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/commands/seat')
-rw-r--r--sway/commands/seat/cursor.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c
index 5dad97f1..929384b0 100644
--- a/sway/commands/seat/cursor.c
+++ b/sway/commands/seat/cursor.c
@@ -11,7 +11,7 @@
11#include "sway/input/cursor.h" 11#include "sway/input/cursor.h"
12 12
13static struct cmd_results *press_or_release(struct sway_cursor *cursor, 13static struct cmd_results *press_or_release(struct sway_cursor *cursor,
14 char *action, char *button_str, uint32_t time); 14 char *action, char *button_str);
15 15
16static const char *expected_syntax = "Expected 'cursor <move> <x> <y>' or " 16static const char *expected_syntax = "Expected 'cursor <move> <x> <y>' or "
17 "'cursor <set> <x> <y>' or " 17 "'cursor <set> <x> <y>' or "
@@ -29,10 +29,6 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
29 29
30 struct sway_cursor *cursor = seat->cursor; 30 struct sway_cursor *cursor = seat->cursor;
31 31
32 struct timespec now;
33 clock_gettime(CLOCK_MONOTONIC, &now);
34 uint32_t time = now.tv_nsec / 1000;
35
36 if (strcasecmp(argv[0], "move") == 0) { 32 if (strcasecmp(argv[0], "move") == 0) {
37 if (argc < 3) { 33 if (argc < 3) {
38 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); 34 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
@@ -40,7 +36,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
40 int delta_x = strtol(argv[1], NULL, 10); 36 int delta_x = strtol(argv[1], NULL, 10);
41 int delta_y = strtol(argv[2], NULL, 10); 37 int delta_y = strtol(argv[2], NULL, 10);
42 wlr_cursor_move(cursor->cursor, NULL, delta_x, delta_y); 38 wlr_cursor_move(cursor->cursor, NULL, delta_x, delta_y);
43 cursor_send_pointer_motion(cursor, time); 39 cursor_send_pointer_motion(cursor, 0);
44 } else if (strcasecmp(argv[0], "set") == 0) { 40 } else if (strcasecmp(argv[0], "set") == 0) {
45 if (argc < 3) { 41 if (argc < 3) {
46 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); 42 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
@@ -49,12 +45,12 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
49 float x = strtof(argv[1], NULL) / root_container.width; 45 float x = strtof(argv[1], NULL) / root_container.width;
50 float y = strtof(argv[2], NULL) / root_container.height; 46 float y = strtof(argv[2], NULL) / root_container.height;
51 wlr_cursor_warp_absolute(cursor->cursor, NULL, x, y); 47 wlr_cursor_warp_absolute(cursor->cursor, NULL, x, y);
52 cursor_send_pointer_motion(cursor, time); 48 cursor_send_pointer_motion(cursor, 0);
53 } else { 49 } else {
54 if (argc < 2) { 50 if (argc < 2) {
55 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); 51 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
56 } 52 }
57 if ((error = press_or_release(cursor, argv[0], argv[1], time))) { 53 if ((error = press_or_release(cursor, argv[0], argv[1]))) {
58 return error; 54 return error;
59 } 55 }
60 } 56 }
@@ -63,7 +59,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
63} 59}
64 60
65static struct cmd_results *press_or_release(struct sway_cursor *cursor, 61static struct cmd_results *press_or_release(struct sway_cursor *cursor,
66 char *action, char *button_str, uint32_t time) { 62 char *action, char *button_str) {
67 enum wlr_button_state state; 63 enum wlr_button_state state;
68 uint32_t button; 64 uint32_t button;
69 if (strcasecmp(action, "press") == 0) { 65 if (strcasecmp(action, "press") == 0) {
@@ -84,6 +80,6 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor,
84 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); 80 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
85 } 81 }
86 } 82 }
87 dispatch_cursor_button(cursor, time, button, state); 83 dispatch_cursor_button(cursor, 0, button, state);
88 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 84 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
89} 85}