diff options
author | 2018-04-08 12:47:56 -0400 | |
---|---|---|
committer | 2018-04-08 12:47:56 -0400 | |
commit | ae78f6fb9383392915421784cb97910bbbfb60f2 (patch) | |
tree | ec7daa6d31dfc6cbe3ff8e9db1bba2754077eedb /sway | |
parent | criteria match containers (diff) | |
parent | Merge pull request #1777 from emersion/unmanaged-cursor-input (diff) | |
download | sway-ae78f6fb9383392915421784cb97910bbbfb60f2.tar.gz sway-ae78f6fb9383392915421784cb97910bbbfb60f2.tar.zst sway-ae78f6fb9383392915421784cb97910bbbfb60f2.zip |
Merge branch 'wlroots' into focus-inactive-fixes
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 1 | ||||
-rw-r--r-- | sway/commands/ws_auto_back_and_forth.c | 12 | ||||
-rw-r--r-- | sway/input/cursor.c | 83 | ||||
-rw-r--r-- | sway/input/seat.c | 12 | ||||
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/server.c | 3 |
6 files changed, 90 insertions, 22 deletions
diff --git a/sway/commands.c b/sway/commands.c index 22decef3..20b8a2aa 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -106,6 +106,7 @@ static struct cmd_handler handlers[] = { | |||
106 | { "output", cmd_output }, | 106 | { "output", cmd_output }, |
107 | { "seat", cmd_seat }, | 107 | { "seat", cmd_seat }, |
108 | { "workspace", cmd_workspace }, | 108 | { "workspace", cmd_workspace }, |
109 | { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, | ||
109 | }; | 110 | }; |
110 | 111 | ||
111 | static struct cmd_handler bar_handlers[] = { | 112 | static struct cmd_handler bar_handlers[] = { |
diff --git a/sway/commands/ws_auto_back_and_forth.c b/sway/commands/ws_auto_back_and_forth.c new file mode 100644 index 00000000..2485db35 --- /dev/null +++ b/sway/commands/ws_auto_back_and_forth.c | |||
@@ -0,0 +1,12 @@ | |||
1 | #include <string.h> | ||
2 | #include <strings.h> | ||
3 | #include "sway/commands.h" | ||
4 | |||
5 | struct cmd_results *cmd_ws_auto_back_and_forth(int argc, char **argv) { | ||
6 | struct cmd_results *error = NULL; | ||
7 | if ((error = checkarg(argc, "workspace_auto_back_and_forth", EXPECTED_EQUAL_TO, 1))) { | ||
8 | return error; | ||
9 | } | ||
10 | config->auto_back_and_forth = !strcasecmp(argv[0], "yes"); | ||
11 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
12 | } | ||
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 6db615b1..4bcf72fc 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -52,17 +52,13 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor, | |||
52 | wl_list_for_each_reverse(unmanaged_surface, unmanaged, link) { | 52 | wl_list_for_each_reverse(unmanaged_surface, unmanaged, link) { |
53 | struct wlr_xwayland_surface *xsurface = | 53 | struct wlr_xwayland_surface *xsurface = |
54 | unmanaged_surface->wlr_xwayland_surface; | 54 | unmanaged_surface->wlr_xwayland_surface; |
55 | struct wlr_box box = { | 55 | |
56 | .x = unmanaged_surface->lx, | 56 | double _sx = cursor->x - unmanaged_surface->lx; |
57 | .y = unmanaged_surface->ly, | 57 | double _sy = cursor->y - unmanaged_surface->ly; |
58 | .width = xsurface->width, | 58 | if (wlr_surface_point_accepts_input(xsurface->surface, _sx, _sy)) { |
59 | .height = xsurface->height, | ||
60 | }; | ||
61 | |||
62 | if (wlr_box_contains_point(&box, cursor->x, cursor->y)) { | ||
63 | *surface = xsurface->surface; | 59 | *surface = xsurface->surface; |
64 | *sx = cursor->x - box.x; | 60 | *sx = _sx; |
65 | *sy = cursor->y - box.y; | 61 | *sy = _sy; |
66 | return NULL; | 62 | return NULL; |
67 | } | 63 | } |
68 | } | 64 | } |
@@ -179,10 +175,8 @@ static void handle_cursor_motion_absolute( | |||
179 | cursor_send_pointer_motion(cursor, event->time_msec); | 175 | cursor_send_pointer_motion(cursor, event->time_msec); |
180 | } | 176 | } |
181 | 177 | ||
182 | static void handle_cursor_button(struct wl_listener *listener, void *data) { | 178 | static void dispatch_cursor_button(struct sway_cursor *cursor, |
183 | struct sway_cursor *cursor = wl_container_of(listener, cursor, button); | 179 | uint32_t time_msec, uint32_t button, enum wlr_button_state state) { |
184 | struct wlr_event_pointer_button *event = data; | ||
185 | |||
186 | struct wlr_surface *surface = NULL; | 180 | struct wlr_surface *surface = NULL; |
187 | double sx, sy; | 181 | double sx, sy; |
188 | struct sway_container *cont = | 182 | struct sway_container *cont = |
@@ -215,8 +209,15 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { | |||
215 | seat_set_focus(cursor->seat, cont); | 209 | seat_set_focus(cursor->seat, cont); |
216 | } | 210 | } |
217 | 211 | ||
218 | wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, event->time_msec, | 212 | wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, |
219 | event->button, event->state); | 213 | time_msec, button, state); |
214 | } | ||
215 | |||
216 | static void handle_cursor_button(struct wl_listener *listener, void *data) { | ||
217 | struct sway_cursor *cursor = wl_container_of(listener, cursor, button); | ||
218 | struct wlr_event_pointer_button *event = data; | ||
219 | dispatch_cursor_button(cursor, | ||
220 | event->time_msec, event->button, event->state); | ||
220 | } | 221 | } |
221 | 222 | ||
222 | static void handle_cursor_axis(struct wl_listener *listener, void *data) { | 223 | static void handle_cursor_axis(struct wl_listener *listener, void *data) { |
@@ -248,13 +249,53 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) { | |||
248 | static void handle_tool_axis(struct wl_listener *listener, void *data) { | 249 | static void handle_tool_axis(struct wl_listener *listener, void *data) { |
249 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); | 250 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); |
250 | struct wlr_event_tablet_tool_axis *event = data; | 251 | struct wlr_event_tablet_tool_axis *event = data; |
251 | wlr_log(L_DEBUG, "TODO: handle tool axis event: %p", event); | 252 | |
253 | if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) && | ||
254 | (event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) { | ||
255 | wlr_cursor_warp_absolute(cursor->cursor, event->device, | ||
256 | event->x, event->y); | ||
257 | cursor_update_position(cursor); | ||
258 | cursor_send_pointer_motion(cursor, event->time_msec); | ||
259 | } else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) { | ||
260 | wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, -1); | ||
261 | cursor_update_position(cursor); | ||
262 | cursor_send_pointer_motion(cursor, event->time_msec); | ||
263 | } else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) { | ||
264 | wlr_cursor_warp_absolute(cursor->cursor, event->device, -1, event->y); | ||
265 | cursor_update_position(cursor); | ||
266 | cursor_send_pointer_motion(cursor, event->time_msec); | ||
267 | } | ||
252 | } | 268 | } |
253 | 269 | ||
254 | static void handle_tool_tip(struct wl_listener *listener, void *data) { | 270 | static void handle_tool_tip(struct wl_listener *listener, void *data) { |
255 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); | 271 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); |
256 | struct wlr_event_tablet_tool_tip *event = data; | 272 | struct wlr_event_tablet_tool_tip *event = data; |
257 | wlr_log(L_DEBUG, "TODO: handle tool tip event: %p", event); | 273 | dispatch_cursor_button(cursor, event->time_msec, |
274 | BTN_LEFT, event->state == WLR_TABLET_TOOL_TIP_DOWN ? | ||
275 | WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED); | ||
276 | } | ||
277 | |||
278 | static void handle_tool_button(struct wl_listener *listener, void *data) { | ||
279 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button); | ||
280 | struct wlr_event_tablet_tool_button *event = data; | ||
281 | // TODO: the user may want to configure which tool buttons are mapped to | ||
282 | // which simulated pointer buttons | ||
283 | switch (event->state) { | ||
284 | case WLR_BUTTON_PRESSED: | ||
285 | if (cursor->tool_buttons == 0) { | ||
286 | dispatch_cursor_button(cursor, | ||
287 | event->time_msec, BTN_RIGHT, event->state); | ||
288 | } | ||
289 | cursor->tool_buttons++; | ||
290 | break; | ||
291 | case WLR_BUTTON_RELEASED: | ||
292 | if (cursor->tool_buttons == 1) { | ||
293 | dispatch_cursor_button(cursor, | ||
294 | event->time_msec, BTN_RIGHT, event->state); | ||
295 | } | ||
296 | cursor->tool_buttons--; | ||
297 | break; | ||
298 | } | ||
258 | } | 299 | } |
259 | 300 | ||
260 | static void handle_request_set_cursor(struct wl_listener *listener, | 301 | static void handle_request_set_cursor(struct wl_listener *listener, |
@@ -332,6 +373,9 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) { | |||
332 | &cursor->touch_motion); | 373 | &cursor->touch_motion); |
333 | cursor->touch_motion.notify = handle_touch_motion; | 374 | cursor->touch_motion.notify = handle_touch_motion; |
334 | 375 | ||
376 | // TODO: tablet protocol support | ||
377 | // Note: We should emulate pointer events for clients that don't support the | ||
378 | // tablet protocol when the time comes | ||
335 | wl_signal_add(&wlr_cursor->events.tablet_tool_axis, | 379 | wl_signal_add(&wlr_cursor->events.tablet_tool_axis, |
336 | &cursor->tool_axis); | 380 | &cursor->tool_axis); |
337 | cursor->tool_axis.notify = handle_tool_axis; | 381 | cursor->tool_axis.notify = handle_tool_axis; |
@@ -339,6 +383,9 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) { | |||
339 | wl_signal_add(&wlr_cursor->events.tablet_tool_tip, &cursor->tool_tip); | 383 | wl_signal_add(&wlr_cursor->events.tablet_tool_tip, &cursor->tool_tip); |
340 | cursor->tool_tip.notify = handle_tool_tip; | 384 | cursor->tool_tip.notify = handle_tool_tip; |
341 | 385 | ||
386 | wl_signal_add(&wlr_cursor->events.tablet_tool_button, &cursor->tool_button); | ||
387 | cursor->tool_button.notify = handle_tool_button; | ||
388 | |||
342 | wl_signal_add(&seat->wlr_seat->events.request_set_cursor, | 389 | wl_signal_add(&seat->wlr_seat->events.request_set_cursor, |
343 | &cursor->request_set_cursor); | 390 | &cursor->request_set_cursor); |
344 | cursor->request_set_cursor.notify = handle_request_set_cursor; | 391 | cursor->request_set_cursor.notify = handle_request_set_cursor; |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 9f44955c..fccb739b 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -284,6 +284,12 @@ static void seat_configure_keyboard(struct sway_seat *seat, | |||
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | static void seat_configure_tablet_tool(struct sway_seat *seat, | ||
288 | struct sway_seat_device *sway_device) { | ||
289 | wlr_cursor_attach_input_device(seat->cursor->cursor, | ||
290 | sway_device->input_device->wlr_device); | ||
291 | } | ||
292 | |||
287 | static struct sway_seat_device *seat_get_device(struct sway_seat *seat, | 293 | static struct sway_seat_device *seat_get_device(struct sway_seat *seat, |
288 | struct sway_input_device *input_device) { | 294 | struct sway_input_device *input_device) { |
289 | struct sway_seat_device *seat_device = NULL; | 295 | struct sway_seat_device *seat_device = NULL; |
@@ -311,9 +317,11 @@ void seat_configure_device(struct sway_seat *seat, | |||
311 | case WLR_INPUT_DEVICE_KEYBOARD: | 317 | case WLR_INPUT_DEVICE_KEYBOARD: |
312 | seat_configure_keyboard(seat, seat_device); | 318 | seat_configure_keyboard(seat, seat_device); |
313 | break; | 319 | break; |
314 | case WLR_INPUT_DEVICE_TOUCH: | ||
315 | case WLR_INPUT_DEVICE_TABLET_PAD: | ||
316 | case WLR_INPUT_DEVICE_TABLET_TOOL: | 320 | case WLR_INPUT_DEVICE_TABLET_TOOL: |
321 | seat_configure_tablet_tool(seat, seat_device); | ||
322 | break; | ||
323 | case WLR_INPUT_DEVICE_TABLET_PAD: | ||
324 | case WLR_INPUT_DEVICE_TOUCH: | ||
317 | wlr_log(L_DEBUG, "TODO: configure other devices"); | 325 | wlr_log(L_DEBUG, "TODO: configure other devices"); |
318 | break; | 326 | break; |
319 | } | 327 | } |
diff --git a/sway/meson.build b/sway/meson.build index 1fe0f29a..2521069f 100644 --- a/sway/meson.build +++ b/sway/meson.build | |||
@@ -52,6 +52,7 @@ sway_sources = files( | |||
52 | 'commands/split.c', | 52 | 'commands/split.c', |
53 | 'commands/swaybg_command.c', | 53 | 'commands/swaybg_command.c', |
54 | 'commands/workspace.c', | 54 | 'commands/workspace.c', |
55 | 'commands/ws_auto_back_and_forth.c', | ||
55 | 56 | ||
56 | 'commands/bar/activate_button.c', | 57 | 'commands/bar/activate_button.c', |
57 | 'commands/bar/binding_mode_indicator.c', | 58 | 'commands/bar/binding_mode_indicator.c', |
diff --git a/sway/server.c b/sway/server.c index 0e98b5f9..c1125f14 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -111,8 +111,7 @@ bool server_init(struct sway_server *server) { | |||
111 | wlr_server_decoration_manager_set_default_mode( | 111 | wlr_server_decoration_manager_set_default_mode( |
112 | deco_manager, WLR_SERVER_DECORATION_MANAGER_MODE_SERVER); | 112 | deco_manager, WLR_SERVER_DECORATION_MANAGER_MODE_SERVER); |
113 | 113 | ||
114 | struct wlr_egl *egl = wlr_backend_get_egl(server->backend); | 114 | wlr_linux_dmabuf_create(server->wl_display, renderer); |
115 | wlr_linux_dmabuf_create(server->wl_display, egl); | ||
116 | 115 | ||
117 | server->socket = wl_display_add_socket_auto(server->wl_display); | 116 | server->socket = wl_display_add_socket_auto(server->wl_display); |
118 | if (!server->socket) { | 117 | if (!server->socket) { |