aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Florian Franzen <Florian.Franzen@gmail.com>2022-04-23 10:27:47 +0200
committerLibravatar Simon Ser <contact@emersion.fr>2022-05-30 12:20:43 +0200
commitcab2189aa64d04ba79dc2cbf19400435b47cdbd2 (patch)
tree450ac51fbc75c73ed1dc6728bc05b08366ace785 /sway/input/cursor.c
parentAdd a Hindi (हिन्दी) translation to the README (diff)
downloadsway-cab2189aa64d04ba79dc2cbf19400435b47cdbd2.tar.gz
sway-cab2189aa64d04ba79dc2cbf19400435b47cdbd2.tar.zst
sway-cab2189aa64d04ba79dc2cbf19400435b47cdbd2.zip
sway: add bindgesture command
Co-authored-by: Michael Weiser <michael.weiser@gmx.de>
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c89
1 files changed, 38 insertions, 51 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 0b2f03a2..e87594ee 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -928,14 +928,28 @@ static void handle_request_pointer_set_cursor(struct wl_listener *listener,
928 event->hotspot_y, focused_client); 928 event->hotspot_y, focused_client);
929} 929}
930 930
931static void handle_pointer_hold_begin(struct wl_listener *listener, void *data) {
932 struct sway_cursor *cursor = wl_container_of(
933 listener, cursor, hold_begin);
934 struct wlr_pointer_hold_begin_event *event = data;
935 cursor_handle_activity_from_device(cursor, &event->pointer->base);
936 seatop_hold_begin(cursor->seat, event);
937}
938
939static void handle_pointer_hold_end(struct wl_listener *listener, void *data) {
940 struct sway_cursor *cursor = wl_container_of(
941 listener, cursor, hold_end);
942 struct wlr_pointer_hold_end_event *event = data;
943 cursor_handle_activity_from_device(cursor, &event->pointer->base);
944 seatop_hold_end(cursor->seat, event);
945}
946
931static void handle_pointer_pinch_begin(struct wl_listener *listener, void *data) { 947static void handle_pointer_pinch_begin(struct wl_listener *listener, void *data) {
932 struct sway_cursor *cursor = wl_container_of( 948 struct sway_cursor *cursor = wl_container_of(
933 listener, cursor, pinch_begin); 949 listener, cursor, pinch_begin);
934 struct wlr_pointer_pinch_begin_event *event = data; 950 struct wlr_pointer_pinch_begin_event *event = data;
935 cursor_handle_activity_from_device(cursor, &event->pointer->base); 951 cursor_handle_activity_from_device(cursor, &event->pointer->base);
936 wlr_pointer_gestures_v1_send_pinch_begin( 952 seatop_pinch_begin(cursor->seat, event);
937 cursor->pointer_gestures, cursor->seat->wlr_seat,
938 event->time_msec, event->fingers);
939} 953}
940 954
941static void handle_pointer_pinch_update(struct wl_listener *listener, void *data) { 955static void handle_pointer_pinch_update(struct wl_listener *listener, void *data) {
@@ -943,10 +957,7 @@ static void handle_pointer_pinch_update(struct wl_listener *listener, void *data
943 listener, cursor, pinch_update); 957 listener, cursor, pinch_update);
944 struct wlr_pointer_pinch_update_event *event = data; 958 struct wlr_pointer_pinch_update_event *event = data;
945 cursor_handle_activity_from_device(cursor, &event->pointer->base); 959 cursor_handle_activity_from_device(cursor, &event->pointer->base);
946 wlr_pointer_gestures_v1_send_pinch_update( 960 seatop_pinch_update(cursor->seat, event);
947 cursor->pointer_gestures, cursor->seat->wlr_seat,
948 event->time_msec, event->dx, event->dy,
949 event->scale, event->rotation);
950} 961}
951 962
952static void handle_pointer_pinch_end(struct wl_listener *listener, void *data) { 963static void handle_pointer_pinch_end(struct wl_listener *listener, void *data) {
@@ -954,9 +965,7 @@ static void handle_pointer_pinch_end(struct wl_listener *listener, void *data) {
954 listener, cursor, pinch_end); 965 listener, cursor, pinch_end);
955 struct wlr_pointer_pinch_end_event *event = data; 966 struct wlr_pointer_pinch_end_event *event = data;
956 cursor_handle_activity_from_device(cursor, &event->pointer->base); 967 cursor_handle_activity_from_device(cursor, &event->pointer->base);
957 wlr_pointer_gestures_v1_send_pinch_end( 968 seatop_pinch_end(cursor->seat, event);
958 cursor->pointer_gestures, cursor->seat->wlr_seat,
959 event->time_msec, event->cancelled);
960} 969}
961 970
962static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data) { 971static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data) {
@@ -964,9 +973,7 @@ static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data)
964 listener, cursor, swipe_begin); 973 listener, cursor, swipe_begin);
965 struct wlr_pointer_swipe_begin_event *event = data; 974 struct wlr_pointer_swipe_begin_event *event = data;
966 cursor_handle_activity_from_device(cursor, &event->pointer->base); 975 cursor_handle_activity_from_device(cursor, &event->pointer->base);
967 wlr_pointer_gestures_v1_send_swipe_begin( 976 seatop_swipe_begin(cursor->seat, event);
968 cursor->pointer_gestures, cursor->seat->wlr_seat,
969 event->time_msec, event->fingers);
970} 977}
971 978
972static void handle_pointer_swipe_update(struct wl_listener *listener, void *data) { 979static void handle_pointer_swipe_update(struct wl_listener *listener, void *data) {
@@ -974,9 +981,7 @@ static void handle_pointer_swipe_update(struct wl_listener *listener, void *data
974 listener, cursor, swipe_update); 981 listener, cursor, swipe_update);
975 struct wlr_pointer_swipe_update_event *event = data; 982 struct wlr_pointer_swipe_update_event *event = data;
976 cursor_handle_activity_from_device(cursor, &event->pointer->base); 983 cursor_handle_activity_from_device(cursor, &event->pointer->base);
977 wlr_pointer_gestures_v1_send_swipe_update( 984 seatop_swipe_update(cursor->seat, event);
978 cursor->pointer_gestures, cursor->seat->wlr_seat,
979 event->time_msec, event->dx, event->dy);
980} 985}
981 986
982static void handle_pointer_swipe_end(struct wl_listener *listener, void *data) { 987static void handle_pointer_swipe_end(struct wl_listener *listener, void *data) {
@@ -984,29 +989,7 @@ static void handle_pointer_swipe_end(struct wl_listener *listener, void *data) {
984 listener, cursor, swipe_end); 989 listener, cursor, swipe_end);
985 struct wlr_pointer_swipe_end_event *event = data; 990 struct wlr_pointer_swipe_end_event *event = data;
986 cursor_handle_activity_from_device(cursor, &event->pointer->base); 991 cursor_handle_activity_from_device(cursor, &event->pointer->base);
987 wlr_pointer_gestures_v1_send_swipe_end( 992 seatop_swipe_end(cursor->seat, event);
988 cursor->pointer_gestures, cursor->seat->wlr_seat,
989 event->time_msec, event->cancelled);
990}
991
992static void handle_pointer_hold_begin(struct wl_listener *listener, void *data) {
993 struct sway_cursor *cursor = wl_container_of(
994 listener, cursor, hold_begin);
995 struct wlr_pointer_hold_begin_event *event = data;
996 cursor_handle_activity_from_device(cursor, &event->pointer->base);
997 wlr_pointer_gestures_v1_send_hold_begin(
998 cursor->pointer_gestures, cursor->seat->wlr_seat,
999 event->time_msec, event->fingers);
1000}
1001
1002static void handle_pointer_hold_end(struct wl_listener *listener, void *data) {
1003 struct sway_cursor *cursor = wl_container_of(
1004 listener, cursor, hold_end);
1005 struct wlr_pointer_hold_end_event *event = data;
1006 cursor_handle_activity_from_device(cursor, &event->pointer->base);
1007 wlr_pointer_gestures_v1_send_hold_end(
1008 cursor->pointer_gestures, cursor->seat->wlr_seat,
1009 event->time_msec, event->cancelled);
1010} 993}
1011 994
1012static void handle_image_surface_destroy(struct wl_listener *listener, 995static void handle_image_surface_destroy(struct wl_listener *listener,
@@ -1080,14 +1063,14 @@ void sway_cursor_destroy(struct sway_cursor *cursor) {
1080 wl_event_source_remove(cursor->hide_source); 1063 wl_event_source_remove(cursor->hide_source);
1081 1064
1082 wl_list_remove(&cursor->image_surface_destroy.link); 1065 wl_list_remove(&cursor->image_surface_destroy.link);
1066 wl_list_remove(&cursor->hold_begin.link);
1067 wl_list_remove(&cursor->hold_end.link);
1083 wl_list_remove(&cursor->pinch_begin.link); 1068 wl_list_remove(&cursor->pinch_begin.link);
1084 wl_list_remove(&cursor->pinch_update.link); 1069 wl_list_remove(&cursor->pinch_update.link);
1085 wl_list_remove(&cursor->pinch_end.link); 1070 wl_list_remove(&cursor->pinch_end.link);
1086 wl_list_remove(&cursor->swipe_begin.link); 1071 wl_list_remove(&cursor->swipe_begin.link);
1087 wl_list_remove(&cursor->swipe_update.link); 1072 wl_list_remove(&cursor->swipe_update.link);
1088 wl_list_remove(&cursor->swipe_end.link); 1073 wl_list_remove(&cursor->swipe_end.link);
1089 wl_list_remove(&cursor->hold_begin.link);
1090 wl_list_remove(&cursor->hold_end.link);
1091 wl_list_remove(&cursor->motion.link); 1074 wl_list_remove(&cursor->motion.link);
1092 wl_list_remove(&cursor->motion_absolute.link); 1075 wl_list_remove(&cursor->motion_absolute.link);
1093 wl_list_remove(&cursor->button.link); 1076 wl_list_remove(&cursor->button.link);
@@ -1131,23 +1114,27 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) {
1131 wl_list_init(&cursor->image_surface_destroy.link); 1114 wl_list_init(&cursor->image_surface_destroy.link);
1132 cursor->image_surface_destroy.notify = handle_image_surface_destroy; 1115 cursor->image_surface_destroy.notify = handle_image_surface_destroy;
1133 1116
1117 // gesture events
1134 cursor->pointer_gestures = wlr_pointer_gestures_v1_create(server.wl_display); 1118 cursor->pointer_gestures = wlr_pointer_gestures_v1_create(server.wl_display);
1135 cursor->pinch_begin.notify = handle_pointer_pinch_begin; 1119
1120 wl_signal_add(&wlr_cursor->events.hold_begin, &cursor->hold_begin);
1121 cursor->hold_begin.notify = handle_pointer_hold_begin;
1122 wl_signal_add(&wlr_cursor->events.hold_end, &cursor->hold_end);
1123 cursor->hold_end.notify = handle_pointer_hold_end;
1124
1136 wl_signal_add(&wlr_cursor->events.pinch_begin, &cursor->pinch_begin); 1125 wl_signal_add(&wlr_cursor->events.pinch_begin, &cursor->pinch_begin);
1137 cursor->pinch_update.notify = handle_pointer_pinch_update; 1126 cursor->pinch_begin.notify = handle_pointer_pinch_begin;
1138 wl_signal_add(&wlr_cursor->events.pinch_update, &cursor->pinch_update); 1127 wl_signal_add(&wlr_cursor->events.pinch_update, &cursor->pinch_update);
1139 cursor->pinch_end.notify = handle_pointer_pinch_end; 1128 cursor->pinch_update.notify = handle_pointer_pinch_update;
1140 wl_signal_add(&wlr_cursor->events.pinch_end, &cursor->pinch_end); 1129 wl_signal_add(&wlr_cursor->events.pinch_end, &cursor->pinch_end);
1141 cursor->swipe_begin.notify = handle_pointer_swipe_begin; 1130 cursor->pinch_end.notify = handle_pointer_pinch_end;
1131
1142 wl_signal_add(&wlr_cursor->events.swipe_begin, &cursor->swipe_begin); 1132 wl_signal_add(&wlr_cursor->events.swipe_begin, &cursor->swipe_begin);
1143 cursor->swipe_update.notify = handle_pointer_swipe_update; 1133 cursor->swipe_begin.notify = handle_pointer_swipe_begin;
1144 wl_signal_add(&wlr_cursor->events.swipe_update, &cursor->swipe_update); 1134 wl_signal_add(&wlr_cursor->events.swipe_update, &cursor->swipe_update);
1145 cursor->swipe_end.notify = handle_pointer_swipe_end; 1135 cursor->swipe_update.notify = handle_pointer_swipe_update;
1146 wl_signal_add(&wlr_cursor->events.swipe_end, &cursor->swipe_end); 1136 wl_signal_add(&wlr_cursor->events.swipe_end, &cursor->swipe_end);
1147 cursor->hold_begin.notify = handle_pointer_hold_begin; 1137 cursor->swipe_end.notify = handle_pointer_swipe_end;
1148 wl_signal_add(&wlr_cursor->events.hold_begin, &cursor->hold_begin);
1149 cursor->hold_end.notify = handle_pointer_hold_end;
1150 wl_signal_add(&wlr_cursor->events.hold_end, &cursor->hold_end);
1151 1138
1152 // input events 1139 // input events
1153 wl_signal_add(&wlr_cursor->events.motion, &cursor->motion); 1140 wl_signal_add(&wlr_cursor->events.motion, &cursor->motion);