cursor.h (2269B)
1 /* Copyright (c), Niclas Meyer <niclas@countingsort.com> 2 * 3 * This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at https://mozilla.org/MPL/2.0/. 6 */ 7 8 #ifndef KIWMI_INPUT_CURSOR_H 9 #define KIWMI_INPUT_CURSOR_H 10 11 #include <wayland-server.h> 12 #include <wlr/types/wlr_output_layout.h> 13 14 #include "desktop/view.h" 15 16 enum kiwmi_cursor_mode { 17 KIWMI_CURSOR_PASSTHROUGH, 18 KIWMI_CURSOR_MOVE, 19 KIWMI_CURSOR_RESIZE, 20 }; 21 22 struct kiwmi_cursor { 23 struct kiwmi_server *server; 24 struct wlr_cursor *cursor; 25 struct wlr_xcursor_manager *xcursor_manager; 26 27 enum kiwmi_cursor_mode cursor_mode; 28 29 struct { 30 struct kiwmi_view *view; 31 int orig_x; 32 int orig_y; 33 struct wlr_box orig_geom; 34 uint32_t resize_edges; 35 } grabbed; 36 37 struct wl_listener cursor_motion; 38 struct wl_listener cursor_motion_absolute; 39 struct wl_listener cursor_button; 40 struct wl_listener cursor_axis; 41 struct wl_listener cursor_frame; 42 struct wl_listener cursor_touch_up; 43 struct wl_listener cursor_touch_down; 44 struct wl_listener cursor_touch_motion; 45 struct wl_listener cursor_touch_frame; 46 47 struct { 48 struct wl_signal button_down; 49 struct wl_signal button_up; 50 struct wl_signal destroy; 51 struct wl_signal motion; 52 struct wl_signal scroll; 53 struct wl_signal touch; 54 } events; 55 }; 56 57 struct kiwmi_cursor_button_event { 58 struct wlr_event_pointer_button *wlr_event; 59 bool handled; 60 }; 61 62 struct kiwmi_cursor_motion_event { 63 double oldx; 64 double oldy; 65 double newx; 66 double newy; 67 }; 68 69 struct kiwmi_cursor_touch_event { 70 char *event; 71 int id; 72 double x; 73 double y; 74 bool handled; 75 }; 76 77 struct kiwmi_cursor_scroll_event { 78 const char *device_name; 79 bool is_vertical; 80 double length; 81 bool handled; 82 }; 83 84 void cursor_refresh_focus( 85 struct kiwmi_cursor *cursor, 86 struct wlr_surface **new_surface, 87 double *cursor_sx, 88 double *cursor_sy); 89 90 struct kiwmi_cursor *cursor_create( 91 struct kiwmi_server *server, 92 struct wlr_output_layout *output_layout); 93 void cursor_destroy(struct kiwmi_cursor *cursor); 94 95 #endif /* KIWMI_INPUT_CURSOR_H */