summaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Scott Anderson <ascent12@hotmail.com>2017-07-12 16:39:14 +1200
committerLibravatar Scott Anderson <ascent12@hotmail.com>2017-07-12 16:39:14 +1200
commitc29e5bbde84260763eaece5b47c219fd1fff7883 (patch)
tree790e8df3d1e91f63fb719611032a05f42b54b53e /sway
parentMerge pull request #1271 from johalun/master-securityconf-freebsd (diff)
downloadsway-c29e5bbde84260763eaece5b47c219fd1fff7883.tar.gz
sway-c29e5bbde84260763eaece5b47c219fd1fff7883.tar.zst
sway-c29e5bbde84260763eaece5b47c219fd1fff7883.zip
Use WLC v2 pointer interface
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/move.c8
-rw-r--r--sway/container.c6
-rw-r--r--sway/handlers.c37
-rw-r--r--sway/input_state.c33
4 files changed, 41 insertions, 43 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c
index a38687c1..00b57103 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -161,11 +161,11 @@ struct cmd_results *cmd_move(int argc, char **argv) {
161 wlc_view_get_visible_geometry(view->handle, &g); 161 wlc_view_get_visible_geometry(view->handle, &g);
162 const struct wlc_size *size = wlc_output_get_resolution(output->handle); 162 const struct wlc_size *size = wlc_output_get_resolution(output->handle);
163 163
164 struct wlc_point origin; 164 double x_pos, y_pos;
165 wlc_pointer_get_position(&origin); 165 wlc_pointer_get_position_v2(&x_pos, &y_pos);
166 166
167 int32_t x = origin.x - g.size.w / 2; 167 int32_t x = x_pos - g.size.w / 2;
168 int32_t y = origin.y - g.size.h / 2; 168 int32_t y = y_pos - g.size.h / 2;
169 169
170 uint32_t w = size->w - g.size.w; 170 uint32_t w = size->w - g.size.w;
171 uint32_t h = size->h - g.size.h; 171 uint32_t h = size->h - g.size.h;
diff --git a/sway/container.c b/sway/container.c
index 358ba767..125e1e3d 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -707,8 +707,10 @@ swayc_t *container_under_pointer(void) {
707 if (lookup->children && !lookup->unmanaged) { 707 if (lookup->children && !lookup->unmanaged) {
708 return NULL; 708 return NULL;
709 } 709 }
710 struct wlc_point origin; 710 double x, y;
711 wlc_pointer_get_position(&origin); 711 wlc_pointer_get_position_v2(&x, &y);
712 struct wlc_point origin = { .x = x, .y = y };
713
712 while (lookup && lookup->type != C_VIEW) { 714 while (lookup && lookup->type != C_VIEW) {
713 int i; 715 int i;
714 int len; 716 int len;
diff --git a/sway/handlers.c b/sway/handlers.c
index 052789ca..5fae2f7a 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -842,12 +842,13 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
842 return EVENT_PASSTHROUGH; 842 return EVENT_PASSTHROUGH;
843} 843}
844 844
845static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_point *origin) { 845static bool handle_pointer_motion(wlc_handle handle, uint32_t time, double x, double y) {
846 if (desktop_shell.is_locked) { 846 if (desktop_shell.is_locked) {
847 return EVENT_PASSTHROUGH; 847 return EVENT_PASSTHROUGH;
848 } 848 }
849 849
850 struct wlc_point new_origin = *origin; 850 double new_x = x;
851 double new_y = y;
851 // Switch to adjacent output if touching output edge. 852 // Switch to adjacent output if touching output edge.
852 // 853 //
853 // Since this doesn't currently support moving windows between outputs we 854 // Since this doesn't currently support moving windows between outputs we
@@ -856,45 +857,43 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
856 !pointer_state.left.held && !pointer_state.right.held && !pointer_state.scroll.held) { 857 !pointer_state.left.held && !pointer_state.right.held && !pointer_state.scroll.held) {
857 858
858 swayc_t *output = swayc_active_output(), *adjacent = NULL; 859 swayc_t *output = swayc_active_output(), *adjacent = NULL;
859 struct wlc_point abs_pos = *origin; 860 struct wlc_point abs_pos = { .x = x + output->x, .y = y + output->y };
860 abs_pos.x += output->x; 861 if (x <= 0) { // Left edge
861 abs_pos.y += output->y;
862 if (origin->x == 0) { // Left edge
863 if ((adjacent = swayc_adjacent_output(output, MOVE_LEFT, &abs_pos, false))) { 862 if ((adjacent = swayc_adjacent_output(output, MOVE_LEFT, &abs_pos, false))) {
864 if (workspace_switch(swayc_active_workspace_for(adjacent))) { 863 if (workspace_switch(swayc_active_workspace_for(adjacent))) {
865 new_origin.x = adjacent->width; 864 new_x = adjacent->width;
866 // adjust for differently aligned outputs (well, this is 865 // adjust for differently aligned outputs (well, this is
867 // only correct when the two outputs have the same 866 // only correct when the two outputs have the same
868 // resolution or the same dpi I guess, it should take 867 // resolution or the same dpi I guess, it should take
869 // physical attributes into account) 868 // physical attributes into account)
870 new_origin.y += (output->y - adjacent->y); 869 new_y += (output->y - adjacent->y);
871 } 870 }
872 } 871 }
873 } else if ((double)origin->x == output->width) { // Right edge 872 } else if (x >= output->width) { // Right edge
874 if ((adjacent = swayc_adjacent_output(output, MOVE_RIGHT, &abs_pos, false))) { 873 if ((adjacent = swayc_adjacent_output(output, MOVE_RIGHT, &abs_pos, false))) {
875 if (workspace_switch(swayc_active_workspace_for(adjacent))) { 874 if (workspace_switch(swayc_active_workspace_for(adjacent))) {
876 new_origin.x = 0; 875 new_x = 0;
877 new_origin.y += (output->y - adjacent->y); 876 new_y += (output->y - adjacent->y);
878 } 877 }
879 } 878 }
880 } else if (origin->y == 0) { // Top edge 879 } else if (y <= 0) { // Top edge
881 if ((adjacent = swayc_adjacent_output(output, MOVE_UP, &abs_pos, false))) { 880 if ((adjacent = swayc_adjacent_output(output, MOVE_UP, &abs_pos, false))) {
882 if (workspace_switch(swayc_active_workspace_for(adjacent))) { 881 if (workspace_switch(swayc_active_workspace_for(adjacent))) {
883 new_origin.y = adjacent->height; 882 new_y = adjacent->height;
884 new_origin.x += (output->x - adjacent->x); 883 new_x += (output->x - adjacent->x);
885 } 884 }
886 } 885 }
887 } else if ((double)origin->y == output->height) { // Bottom edge 886 } else if (y >= output->height) { // Bottom edge
888 if ((adjacent = swayc_adjacent_output(output, MOVE_DOWN, &abs_pos, false))) { 887 if ((adjacent = swayc_adjacent_output(output, MOVE_DOWN, &abs_pos, false))) {
889 if (workspace_switch(swayc_active_workspace_for(adjacent))) { 888 if (workspace_switch(swayc_active_workspace_for(adjacent))) {
890 new_origin.y = 0; 889 new_y = 0;
891 new_origin.x += (output->x - adjacent->x); 890 new_x += (output->x - adjacent->x);
892 } 891 }
893 } 892 }
894 } 893 }
895 } 894 }
896 895
897 pointer_position_set(&new_origin, false); 896 pointer_position_set(new_x, new_y, false);
898 897
899 swayc_t *focused = get_focused_container(&root_container); 898 swayc_t *focused = get_focused_container(&root_container);
900 if (focused->type == C_VIEW) { 899 if (focused->type == C_VIEW) {
@@ -1122,7 +1121,7 @@ void register_wlc_handlers() {
1122 wlc_set_view_request_state_cb(handle_view_state_request); 1121 wlc_set_view_request_state_cb(handle_view_state_request);
1123 wlc_set_view_properties_updated_cb(handle_view_properties_updated); 1122 wlc_set_view_properties_updated_cb(handle_view_properties_updated);
1124 wlc_set_keyboard_key_cb(handle_key); 1123 wlc_set_keyboard_key_cb(handle_key);
1125 wlc_set_pointer_motion_cb(handle_pointer_motion); 1124 wlc_set_pointer_motion_cb_v2(handle_pointer_motion);
1126 wlc_set_pointer_button_cb(handle_pointer_button); 1125 wlc_set_pointer_button_cb(handle_pointer_button);
1127 wlc_set_pointer_scroll_cb(handle_pointer_scroll); 1126 wlc_set_pointer_scroll_cb(handle_pointer_scroll);
1128 wlc_set_compositor_ready_cb(handle_wlc_ready); 1127 wlc_set_compositor_ready_cb(handle_wlc_ready);
diff --git a/sway/input_state.c b/sway/input_state.c
index 68df17de..04aafd37 100644
--- a/sway/input_state.c
+++ b/sway/input_state.c
@@ -202,13 +202,13 @@ static void reset_initial_sibling(void) {
202 pointer_state.mode = 0; 202 pointer_state.mode = 0;
203} 203}
204 204
205void pointer_position_set(struct wlc_point *new_origin, bool force_focus) { 205void pointer_position_set(double new_x, double new_y, bool force_focus) {
206 struct wlc_point origin; 206 double x, y;
207 wlc_pointer_get_position(&origin); 207 wlc_pointer_get_position_v2(&x, &y);
208 pointer_state.delta.x = new_origin->x - origin.x; 208 pointer_state.delta.x = new_x - x;
209 pointer_state.delta.y = new_origin->y - origin.y; 209 pointer_state.delta.y = new_y - y;
210 210
211 wlc_pointer_set_position(new_origin); 211 wlc_pointer_set_position_v2(new_x, new_y);
212 212
213 // Update view under pointer 213 // Update view under pointer
214 swayc_t *prev_view = pointer_state.view; 214 swayc_t *prev_view = pointer_state.view;
@@ -226,10 +226,7 @@ void pointer_position_set(struct wlc_point *new_origin, bool force_focus) {
226} 226}
227 227
228void center_pointer_on(swayc_t *view) { 228void center_pointer_on(swayc_t *view) {
229 struct wlc_point new_origin; 229 pointer_position_set(view->x + view->width/2, view->y + view->height/2, true);
230 new_origin.x = view->x + view->width/2;
231 new_origin.y = view->y + view->height/2;
232 pointer_position_set(&new_origin, true);
233} 230}
234 231
235// Mode set left/right click 232// Mode set left/right click
@@ -269,10 +266,10 @@ static void pointer_mode_set_resizing(void) {
269 int midway_x = initial.ptr->x + initial.ptr->width/2; 266 int midway_x = initial.ptr->x + initial.ptr->width/2;
270 int midway_y = initial.ptr->y + initial.ptr->height/2; 267 int midway_y = initial.ptr->y + initial.ptr->height/2;
271 268
272 struct wlc_point origin; 269 double x, y;
273 wlc_pointer_get_position(&origin); 270 wlc_pointer_get_position_v2(&x, &y);
274 lock.left = origin.x > midway_x; 271 lock.left = x > midway_x;
275 lock.top = origin.y > midway_y; 272 lock.top = y > midway_y;
276 273
277 if (initial.ptr->is_floating) { 274 if (initial.ptr->is_floating) {
278 pointer_state.mode = M_RESIZING | M_FLOATING; 275 pointer_state.mode = M_RESIZING | M_FLOATING;
@@ -346,10 +343,10 @@ void pointer_mode_update(void) {
346 pointer_state.mode = 0; 343 pointer_state.mode = 0;
347 return; 344 return;
348 } 345 }
349 struct wlc_point origin; 346 double x, y;
350 wlc_pointer_get_position(&origin); 347 wlc_pointer_get_position_v2(&x, &y);
351 int dx = origin.x; 348 int dx = x;
352 int dy = origin.y; 349 int dy = y;
353 350
354 switch (pointer_state.mode) { 351 switch (pointer_state.mode) {
355 case M_FLOATING | M_DRAGGING: 352 case M_FLOATING | M_DRAGGING: