aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 186b4820..f2c91bab 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -241,11 +241,12 @@ int cursor_get_timeout(struct sway_cursor *cursor) {
241 return timeout; 241 return timeout;
242} 242}
243 243
244void cursor_handle_activity(struct sway_cursor *cursor) { 244void cursor_handle_activity(struct sway_cursor *cursor,
245 enum sway_input_idle_source idle_source) {
245 wl_event_source_timer_update( 246 wl_event_source_timer_update(
246 cursor->hide_source, cursor_get_timeout(cursor)); 247 cursor->hide_source, cursor_get_timeout(cursor));
247 248
248 seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_POINTER); 249 seat_idle_notify_activity(cursor->seat, idle_source);
249 if (cursor->hidden) { 250 if (cursor->hidden) {
250 cursor_unhide(cursor); 251 cursor_unhide(cursor);
251 } 252 }
@@ -270,7 +271,7 @@ void cursor_unhide(struct sway_cursor *cursor) {
270static void cursor_motion(struct sway_cursor *cursor, uint32_t time_msec, 271static void cursor_motion(struct sway_cursor *cursor, uint32_t time_msec,
271 struct wlr_input_device *device, double dx, double dy, 272 struct wlr_input_device *device, double dx, double dy,
272 double dx_unaccel, double dy_unaccel) { 273 double dx_unaccel, double dy_unaccel) {
273 cursor_handle_activity(cursor); 274 cursor_handle_activity(cursor, IDLE_SOURCE_POINTER);
274 275
275 wlr_relative_pointer_manager_v1_send_relative_motion( 276 wlr_relative_pointer_manager_v1_send_relative_motion(
276 server.relative_pointer_manager, 277 server.relative_pointer_manager,
@@ -353,7 +354,7 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
353 } 354 }
354 } 355 }
355 356
356 cursor_handle_activity(cursor); 357 cursor_handle_activity(cursor, IDLE_SOURCE_POINTER);
357 dispatch_cursor_button(cursor, event->device, 358 dispatch_cursor_button(cursor, event->device,
358 event->time_msec, event->button, event->state); 359 event->time_msec, event->button, event->state);
359 transaction_commit_dirty(); 360 transaction_commit_dirty();
@@ -367,20 +368,20 @@ void dispatch_cursor_axis(struct sway_cursor *cursor,
367static void handle_cursor_axis(struct wl_listener *listener, void *data) { 368static void handle_cursor_axis(struct wl_listener *listener, void *data) {
368 struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); 369 struct sway_cursor *cursor = wl_container_of(listener, cursor, axis);
369 struct wlr_event_pointer_axis *event = data; 370 struct wlr_event_pointer_axis *event = data;
370 cursor_handle_activity(cursor); 371 cursor_handle_activity(cursor, IDLE_SOURCE_POINTER);
371 dispatch_cursor_axis(cursor, event); 372 dispatch_cursor_axis(cursor, event);
372 transaction_commit_dirty(); 373 transaction_commit_dirty();
373} 374}
374 375
375static void handle_cursor_frame(struct wl_listener *listener, void *data) { 376static void handle_cursor_frame(struct wl_listener *listener, void *data) {
376 struct sway_cursor *cursor = wl_container_of(listener, cursor, frame); 377 struct sway_cursor *cursor = wl_container_of(listener, cursor, frame);
377 cursor_handle_activity(cursor); 378 cursor_handle_activity(cursor, IDLE_SOURCE_POINTER);
378 wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); 379 wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat);
379} 380}
380 381
381static void handle_touch_down(struct wl_listener *listener, void *data) { 382static void handle_touch_down(struct wl_listener *listener, void *data) {
382 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down); 383 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down);
383 seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TOUCH); 384 cursor_handle_activity(cursor, IDLE_SOURCE_TOUCH);
384 struct wlr_event_touch_down *event = data; 385 struct wlr_event_touch_down *event = data;
385 386
386 struct sway_seat *seat = cursor->seat; 387 struct sway_seat *seat = cursor->seat;
@@ -415,7 +416,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
415 416
416static void handle_touch_up(struct wl_listener *listener, void *data) { 417static void handle_touch_up(struct wl_listener *listener, void *data) {
417 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up); 418 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up);
418 seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TOUCH); 419 cursor_handle_activity(cursor, IDLE_SOURCE_TOUCH);
419 struct wlr_event_touch_up *event = data; 420 struct wlr_event_touch_up *event = data;
420 struct wlr_seat *seat = cursor->seat->wlr_seat; 421 struct wlr_seat *seat = cursor->seat->wlr_seat;
421 // TODO: fall back to cursor simulation if client has not bound to touch 422 // TODO: fall back to cursor simulation if client has not bound to touch
@@ -425,7 +426,7 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
425static void handle_touch_motion(struct wl_listener *listener, void *data) { 426static void handle_touch_motion(struct wl_listener *listener, void *data) {
426 struct sway_cursor *cursor = 427 struct sway_cursor *cursor =
427 wl_container_of(listener, cursor, touch_motion); 428 wl_container_of(listener, cursor, touch_motion);
428 seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TOUCH); 429 cursor_handle_activity(cursor, IDLE_SOURCE_TOUCH);
429 struct wlr_event_touch_motion *event = data; 430 struct wlr_event_touch_motion *event = data;
430 431
431 struct sway_seat *seat = cursor->seat; 432 struct sway_seat *seat = cursor->seat;
@@ -494,6 +495,8 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor,
494 bool change_x, bool change_y, 495 bool change_x, bool change_y,
495 double x, double y, double dx, double dy, 496 double x, double y, double dx, double dy,
496 int32_t time_msec) { 497 int32_t time_msec) {
498 cursor_handle_activity(cursor, IDLE_SOURCE_TABLET_TOOL);
499
497 if (!change_x && !change_y) { 500 if (!change_x && !change_y) {
498 return; 501 return;
499 } 502 }
@@ -536,7 +539,7 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor,
536 539
537static void handle_tool_axis(struct wl_listener *listener, void *data) { 540static void handle_tool_axis(struct wl_listener *listener, void *data) {
538 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); 541 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis);
539 seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TABLET_TOOL); 542 cursor_handle_activity(cursor, IDLE_SOURCE_TABLET_TOOL);
540 struct wlr_event_tablet_tool_axis *event = data; 543 struct wlr_event_tablet_tool_axis *event = data;
541 struct sway_tablet_tool *sway_tool = event->tool->data; 544 struct sway_tablet_tool *sway_tool = event->tool->data;
542 545
@@ -592,7 +595,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
592 595
593static void handle_tool_tip(struct wl_listener *listener, void *data) { 596static void handle_tool_tip(struct wl_listener *listener, void *data) {
594 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); 597 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip);
595 seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TABLET_TOOL); 598 cursor_handle_activity(cursor, IDLE_SOURCE_TABLET_TOOL);
596 struct wlr_event_tablet_tool_tip *event = data; 599 struct wlr_event_tablet_tool_tip *event = data;
597 struct sway_tablet_tool *sway_tool = event->tool->data; 600 struct sway_tablet_tool *sway_tool = event->tool->data;
598 struct wlr_tablet_v2_tablet *tablet_v2 = sway_tool->tablet->tablet_v2; 601 struct wlr_tablet_v2_tablet *tablet_v2 = sway_tool->tablet->tablet_v2;
@@ -640,7 +643,7 @@ static struct sway_tablet *get_tablet_for_device(struct sway_cursor *cursor,
640 643
641static void handle_tool_proximity(struct wl_listener *listener, void *data) { 644static void handle_tool_proximity(struct wl_listener *listener, void *data) {
642 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_proximity); 645 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_proximity);
643 seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TABLET_TOOL); 646 cursor_handle_activity(cursor, IDLE_SOURCE_TABLET_TOOL);
644 struct wlr_event_tablet_tool_proximity *event = data; 647 struct wlr_event_tablet_tool_proximity *event = data;
645 648
646 struct wlr_tablet_tool *tool = event->tool; 649 struct wlr_tablet_tool *tool = event->tool;
@@ -671,7 +674,7 @@ static void handle_tool_proximity(struct wl_listener *listener, void *data) {
671static void handle_tool_button(struct wl_listener *listener, void *data) { 674static void handle_tool_button(struct wl_listener *listener, void *data) {
672 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button); 675 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button);
673 struct sway_seat *seat = cursor->seat; 676 struct sway_seat *seat = cursor->seat;
674 seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TABLET_TOOL); 677 cursor_handle_activity(cursor, IDLE_SOURCE_TABLET_TOOL);
675 678
676 struct wlr_event_tablet_tool_button *event = data; 679 struct wlr_event_tablet_tool_button *event = data;
677 struct sway_tablet_tool *sway_tool = event->tool->data; 680 struct sway_tablet_tool *sway_tool = event->tool->data;