aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-18 21:20:00 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-20 13:11:43 +1000
commitc006717910e5f30ca65645f701541dfa176c1392 (patch)
treec64452b7f2fe6ab481ad90c424cb14bcb0328eda /sway/input/cursor.c
parentMerge pull request #2872 from RyanDwyer/cursor-rebase (diff)
downloadsway-c006717910e5f30ca65645f701541dfa176c1392.tar.gz
sway-c006717910e5f30ca65645f701541dfa176c1392.tar.zst
sway-c006717910e5f30ca65645f701541dfa176c1392.zip
Minor refactor of input manager
The input manager is a singleton object. Passing the sway_input_manager argument to each of its functions is unnecessary, while removing the argument makes it obvious to the caller that it's a singleton. This patch removes the argument and makes the input manager use server.input instead. On a similar note: * sway_input_manager.server is removed in favour of using the server global. * seat.input is removed because it can get it from server.input. Due to a circular dependency, creating seat0 is now done directly in server_init rather than in input_manager_create. This is because creating seats must be done after server.input is set. Lastly, it now stores the default seat name using a constant and removes a second reference to seat0 (in input_manager_get_default_seat).
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 756f2f8c..a07bc53b 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -680,7 +680,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor,
680 680
681static void handle_cursor_motion(struct wl_listener *listener, void *data) { 681static void handle_cursor_motion(struct wl_listener *listener, void *data) {
682 struct sway_cursor *cursor = wl_container_of(listener, cursor, motion); 682 struct sway_cursor *cursor = wl_container_of(listener, cursor, motion);
683 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 683 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
684 struct wlr_event_pointer_motion *event = data; 684 struct wlr_event_pointer_motion *event = data;
685 wlr_cursor_move(cursor->cursor, event->device, 685 wlr_cursor_move(cursor->cursor, event->device,
686 event->delta_x, event->delta_y); 686 event->delta_x, event->delta_y);
@@ -692,7 +692,7 @@ static void handle_cursor_motion_absolute(
692 struct wl_listener *listener, void *data) { 692 struct wl_listener *listener, void *data) {
693 struct sway_cursor *cursor = 693 struct sway_cursor *cursor =
694 wl_container_of(listener, cursor, motion_absolute); 694 wl_container_of(listener, cursor, motion_absolute);
695 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 695 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
696 struct wlr_event_pointer_motion_absolute *event = data; 696 struct wlr_event_pointer_motion_absolute *event = data;
697 wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y); 697 wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
698 cursor_send_pointer_motion(cursor, event->time_msec); 698 cursor_send_pointer_motion(cursor, event->time_msec);
@@ -970,7 +970,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
970 970
971static void handle_cursor_button(struct wl_listener *listener, void *data) { 971static void handle_cursor_button(struct wl_listener *listener, void *data) {
972 struct sway_cursor *cursor = wl_container_of(listener, cursor, button); 972 struct sway_cursor *cursor = wl_container_of(listener, cursor, button);
973 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 973 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
974 struct wlr_event_pointer_button *event = data; 974 struct wlr_event_pointer_button *event = data;
975 dispatch_cursor_button(cursor, event->device, 975 dispatch_cursor_button(cursor, event->device,
976 event->time_msec, event->button, event->state); 976 event->time_msec, event->button, event->state);
@@ -1019,7 +1019,7 @@ static void dispatch_cursor_axis(struct sway_cursor *cursor,
1019 1019
1020static void handle_cursor_axis(struct wl_listener *listener, void *data) { 1020static void handle_cursor_axis(struct wl_listener *listener, void *data) {
1021 struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); 1021 struct sway_cursor *cursor = wl_container_of(listener, cursor, axis);
1022 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1022 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1023 struct wlr_event_pointer_axis *event = data; 1023 struct wlr_event_pointer_axis *event = data;
1024 dispatch_cursor_axis(cursor, event); 1024 dispatch_cursor_axis(cursor, event);
1025 transaction_commit_dirty(); 1025 transaction_commit_dirty();
@@ -1027,7 +1027,7 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) {
1027 1027
1028static void handle_touch_down(struct wl_listener *listener, void *data) { 1028static void handle_touch_down(struct wl_listener *listener, void *data) {
1029 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down); 1029 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down);
1030 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1030 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1031 struct wlr_event_touch_down *event = data; 1031 struct wlr_event_touch_down *event = data;
1032 1032
1033 struct sway_seat *seat = cursor->seat; 1033 struct sway_seat *seat = cursor->seat;
@@ -1058,7 +1058,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
1058 1058
1059static void handle_touch_up(struct wl_listener *listener, void *data) { 1059static void handle_touch_up(struct wl_listener *listener, void *data) {
1060 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up); 1060 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up);
1061 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1061 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1062 struct wlr_event_touch_up *event = data; 1062 struct wlr_event_touch_up *event = data;
1063 struct wlr_seat *seat = cursor->seat->wlr_seat; 1063 struct wlr_seat *seat = cursor->seat->wlr_seat;
1064 // TODO: fall back to cursor simulation if client has not bound to touch 1064 // TODO: fall back to cursor simulation if client has not bound to touch
@@ -1068,7 +1068,7 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
1068static void handle_touch_motion(struct wl_listener *listener, void *data) { 1068static void handle_touch_motion(struct wl_listener *listener, void *data) {
1069 struct sway_cursor *cursor = 1069 struct sway_cursor *cursor =
1070 wl_container_of(listener, cursor, touch_motion); 1070 wl_container_of(listener, cursor, touch_motion);
1071 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1071 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1072 struct wlr_event_touch_motion *event = data; 1072 struct wlr_event_touch_motion *event = data;
1073 1073
1074 struct sway_seat *seat = cursor->seat; 1074 struct sway_seat *seat = cursor->seat;
@@ -1132,7 +1132,7 @@ static void apply_mapping_from_region(struct wlr_input_device *device,
1132 1132
1133static void handle_tool_axis(struct wl_listener *listener, void *data) { 1133static void handle_tool_axis(struct wl_listener *listener, void *data) {
1134 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); 1134 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis);
1135 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1135 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1136 struct wlr_event_tablet_tool_axis *event = data; 1136 struct wlr_event_tablet_tool_axis *event = data;
1137 struct sway_input_device *input_device = event->device->data; 1137 struct sway_input_device *input_device = event->device->data;
1138 1138
@@ -1156,7 +1156,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
1156 1156
1157static void handle_tool_tip(struct wl_listener *listener, void *data) { 1157static void handle_tool_tip(struct wl_listener *listener, void *data) {
1158 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); 1158 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip);
1159 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1159 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1160 struct wlr_event_tablet_tool_tip *event = data; 1160 struct wlr_event_tablet_tool_tip *event = data;
1161 dispatch_cursor_button(cursor, event->device, event->time_msec, 1161 dispatch_cursor_button(cursor, event->device, event->time_msec,
1162 BTN_LEFT, event->state == WLR_TABLET_TOOL_TIP_DOWN ? 1162 BTN_LEFT, event->state == WLR_TABLET_TOOL_TIP_DOWN ?
@@ -1166,7 +1166,7 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) {
1166 1166
1167static void handle_tool_button(struct wl_listener *listener, void *data) { 1167static void handle_tool_button(struct wl_listener *listener, void *data) {
1168 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button); 1168 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button);
1169 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1169 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1170 struct wlr_event_tablet_tool_button *event = data; 1170 struct wlr_event_tablet_tool_button *event = data;
1171 // TODO: the user may want to configure which tool buttons are mapped to 1171 // TODO: the user may want to configure which tool buttons are mapped to
1172 // which simulated pointer buttons 1172 // which simulated pointer buttons