aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Mattias Eriksson <snaggen@mayam.com>2018-04-17 09:54:02 +0200
committerLibravatar Mattias Eriksson <snaggen@mayam.com>2018-05-13 00:30:09 +0200
commit8fbafbfab5671d56dd469f2205b7906c4a7f7c7c (patch)
treeab4eab0020d97dc5091b72479c383989ccc84729 /sway/input/cursor.c
parentMerge pull request #1967 from emersion/remove-xdg-popup-unmap (diff)
downloadsway-8fbafbfab5671d56dd469f2205b7906c4a7f7c7c.tar.gz
sway-8fbafbfab5671d56dd469f2205b7906c4a7f7c7c.tar.zst
sway-8fbafbfab5671d56dd469f2205b7906c4a7f7c7c.zip
Idle handling for dpms/lockscreen et al
Swayidle handles idle events and allows for dpms and lockscreen handling. It also handles systemd sleep events, and can raise a lockscreen on sleep Fixes #541
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 51ce86e1..9259c475 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -7,6 +7,7 @@
7#endif 7#endif
8#include <wlr/types/wlr_cursor.h> 8#include <wlr/types/wlr_cursor.h>
9#include <wlr/types/wlr_xcursor_manager.h> 9#include <wlr/types/wlr_xcursor_manager.h>
10#include <wlr/types/wlr_idle.h>
10#include "list.h" 11#include "list.h"
11#include "log.h" 12#include "log.h"
12#include "sway/input/cursor.h" 13#include "sway/input/cursor.h"
@@ -172,6 +173,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec)
172 173
173static void handle_cursor_motion(struct wl_listener *listener, void *data) { 174static void handle_cursor_motion(struct wl_listener *listener, void *data) {
174 struct sway_cursor *cursor = wl_container_of(listener, cursor, motion); 175 struct sway_cursor *cursor = wl_container_of(listener, cursor, motion);
176 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
175 struct wlr_event_pointer_motion *event = data; 177 struct wlr_event_pointer_motion *event = data;
176 wlr_cursor_move(cursor->cursor, event->device, 178 wlr_cursor_move(cursor->cursor, event->device,
177 event->delta_x, event->delta_y); 179 event->delta_x, event->delta_y);
@@ -182,6 +184,7 @@ static void handle_cursor_motion_absolute(
182 struct wl_listener *listener, void *data) { 184 struct wl_listener *listener, void *data) {
183 struct sway_cursor *cursor = 185 struct sway_cursor *cursor =
184 wl_container_of(listener, cursor, motion_absolute); 186 wl_container_of(listener, cursor, motion_absolute);
187 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
185 struct wlr_event_pointer_motion_absolute *event = data; 188 struct wlr_event_pointer_motion_absolute *event = data;
186 wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y); 189 wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
187 cursor_send_pointer_motion(cursor, event->time_msec); 190 cursor_send_pointer_motion(cursor, event->time_msec);
@@ -231,6 +234,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
231 234
232static void handle_cursor_button(struct wl_listener *listener, void *data) { 235static void handle_cursor_button(struct wl_listener *listener, void *data) {
233 struct sway_cursor *cursor = wl_container_of(listener, cursor, button); 236 struct sway_cursor *cursor = wl_container_of(listener, cursor, button);
237 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
234 struct wlr_event_pointer_button *event = data; 238 struct wlr_event_pointer_button *event = data;
235 dispatch_cursor_button(cursor, 239 dispatch_cursor_button(cursor,
236 event->time_msec, event->button, event->state); 240 event->time_msec, event->button, event->state);
@@ -238,6 +242,7 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
238 242
239static void handle_cursor_axis(struct wl_listener *listener, void *data) { 243static void handle_cursor_axis(struct wl_listener *listener, void *data) {
240 struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); 244 struct sway_cursor *cursor = wl_container_of(listener, cursor, axis);
245 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
241 struct wlr_event_pointer_axis *event = data; 246 struct wlr_event_pointer_axis *event = data;
242 wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec, 247 wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec,
243 event->orientation, event->delta, event->delta_discrete, event->source); 248 event->orientation, event->delta, event->delta_discrete, event->source);
@@ -245,6 +250,7 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) {
245 250
246static void handle_touch_down(struct wl_listener *listener, void *data) { 251static void handle_touch_down(struct wl_listener *listener, void *data) {
247 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down); 252 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down);
253 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
248 struct wlr_event_touch_down *event = data; 254 struct wlr_event_touch_down *event = data;
249 255
250 struct wlr_seat *seat = cursor->seat->wlr_seat; 256 struct wlr_seat *seat = cursor->seat->wlr_seat;
@@ -271,6 +277,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
271 277
272static void handle_touch_up(struct wl_listener *listener, void *data) { 278static void handle_touch_up(struct wl_listener *listener, void *data) {
273 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up); 279 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up);
280 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
274 struct wlr_event_touch_up *event = data; 281 struct wlr_event_touch_up *event = data;
275 struct wlr_seat *seat = cursor->seat->wlr_seat; 282 struct wlr_seat *seat = cursor->seat->wlr_seat;
276 // TODO: fall back to cursor simulation if client has not bound to touch 283 // TODO: fall back to cursor simulation if client has not bound to touch
@@ -280,6 +287,7 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
280static void handle_touch_motion(struct wl_listener *listener, void *data) { 287static void handle_touch_motion(struct wl_listener *listener, void *data) {
281 struct sway_cursor *cursor = 288 struct sway_cursor *cursor =
282 wl_container_of(listener, cursor, touch_motion); 289 wl_container_of(listener, cursor, touch_motion);
290 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
283 struct wlr_event_touch_motion *event = data; 291 struct wlr_event_touch_motion *event = data;
284 292
285 struct wlr_seat *seat = cursor->seat->wlr_seat; 293 struct wlr_seat *seat = cursor->seat->wlr_seat;
@@ -331,6 +339,7 @@ static void apply_mapping_from_region(struct wlr_input_device *device,
331 339
332static void handle_tool_axis(struct wl_listener *listener, void *data) { 340static void handle_tool_axis(struct wl_listener *listener, void *data) {
333 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); 341 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis);
342 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
334 struct wlr_event_tablet_tool_axis *event = data; 343 struct wlr_event_tablet_tool_axis *event = data;
335 struct sway_input_device *input_device = event->device->data; 344 struct sway_input_device *input_device = event->device->data;
336 345
@@ -353,6 +362,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
353 362
354static void handle_tool_tip(struct wl_listener *listener, void *data) { 363static void handle_tool_tip(struct wl_listener *listener, void *data) {
355 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); 364 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip);
365 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
356 struct wlr_event_tablet_tool_tip *event = data; 366 struct wlr_event_tablet_tool_tip *event = data;
357 dispatch_cursor_button(cursor, event->time_msec, 367 dispatch_cursor_button(cursor, event->time_msec,
358 BTN_LEFT, event->state == WLR_TABLET_TOOL_TIP_DOWN ? 368 BTN_LEFT, event->state == WLR_TABLET_TOOL_TIP_DOWN ?
@@ -361,6 +371,7 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) {
361 371
362static void handle_tool_button(struct wl_listener *listener, void *data) { 372static void handle_tool_button(struct wl_listener *listener, void *data) {
363 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button); 373 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button);
374 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
364 struct wlr_event_tablet_tool_button *event = data; 375 struct wlr_event_tablet_tool_button *event = data;
365 // TODO: the user may want to configure which tool buttons are mapped to 376 // TODO: the user may want to configure which tool buttons are mapped to
366 // which simulated pointer buttons 377 // which simulated pointer buttons