diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-04-08 12:47:56 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-04-08 12:47:56 -0400 |
commit | ae78f6fb9383392915421784cb97910bbbfb60f2 (patch) | |
tree | ec7daa6d31dfc6cbe3ff8e9db1bba2754077eedb /sway | |
parent | 70b33342fec0e0cc720cbb62a059c40a34c5314f (diff) | |
parent | ebabcc8b44846eaccdd34e3e48aa07d6bf7b58a7 (diff) |
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[] = { { "output", cmd_output }, { "seat", cmd_seat }, { "workspace", cmd_workspace }, + { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, }; 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 @@ +#include <string.h> +#include <strings.h> +#include "sway/commands.h" + +struct cmd_results *cmd_ws_auto_back_and_forth(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "workspace_auto_back_and_forth", EXPECTED_EQUAL_TO, 1))) { + return error; + } + config->auto_back_and_forth = !strcasecmp(argv[0], "yes"); + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} 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, wl_list_for_each_reverse(unmanaged_surface, unmanaged, link) { struct wlr_xwayland_surface *xsurface = unmanaged_surface->wlr_xwayland_surface; - struct wlr_box box = { - .x = unmanaged_surface->lx, - .y = unmanaged_surface->ly, - .width = xsurface->width, - .height = xsurface->height, - }; - - if (wlr_box_contains_point(&box, cursor->x, cursor->y)) { + + double _sx = cursor->x - unmanaged_surface->lx; + double _sy = cursor->y - unmanaged_surface->ly; + if (wlr_surface_point_accepts_input(xsurface->surface, _sx, _sy)) { *surface = xsurface->surface; - *sx = cursor->x - box.x; - *sy = cursor->y - box.y; + *sx = _sx; + *sy = _sy; return NULL; } } @@ -179,10 +175,8 @@ static void handle_cursor_motion_absolute( cursor_send_pointer_motion(cursor, event->time_msec); } -static void handle_cursor_button(struct wl_listener *listener, void *data) { - struct sway_cursor *cursor = wl_container_of(listener, cursor, button); - struct wlr_event_pointer_button *event = data; - +static void dispatch_cursor_button(struct sway_cursor *cursor, + uint32_t time_msec, uint32_t button, enum wlr_button_state state) { struct wlr_surface *surface = NULL; double sx, sy; struct sway_container *cont = @@ -215,8 +209,15 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { seat_set_focus(cursor->seat, cont); } - wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, event->time_msec, - event->button, event->state); + wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, + time_msec, button, state); +} + +static void handle_cursor_button(struct wl_listener *listener, void *data) { + struct sway_cursor *cursor = wl_container_of(listener, cursor, button); + struct wlr_event_pointer_button *event = data; + dispatch_cursor_button(cursor, + event->time_msec, event->button, event->state); } 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) { static void handle_tool_axis(struct wl_listener *listener, void *data) { struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); struct wlr_event_tablet_tool_axis *event = data; - wlr_log(L_DEBUG, "TODO: handle tool axis event: %p", event); + + if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) && + (event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) { + wlr_cursor_warp_absolute(cursor->cursor, event->device, + event->x, event->y); + cursor_update_position(cursor); + cursor_send_pointer_motion(cursor, event->time_msec); + } else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) { + wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, -1); + cursor_update_position(cursor); + cursor_send_pointer_motion(cursor, event->time_msec); + } else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) { + wlr_cursor_warp_absolute(cursor->cursor, event->device, -1, event->y); + cursor_update_position(cursor); + cursor_send_pointer_motion(cursor, event->time_msec); + } } static void handle_tool_tip(struct wl_listener *listener, void *data) { struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); struct wlr_event_tablet_tool_tip *event = data; - wlr_log(L_DEBUG, "TODO: handle tool tip event: %p", event); + dispatch_cursor_button(cursor, event->time_msec, + BTN_LEFT, event->state == WLR_TABLET_TOOL_TIP_DOWN ? + WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED); +} + +static void handle_tool_button(struct wl_listener *listener, void *data) { + struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button); + struct wlr_event_tablet_tool_button *event = data; + // TODO: the user may want to configure which tool buttons are mapped to + // which simulated pointer buttons + switch (event->state) { + case WLR_BUTTON_PRESSED: + if (cursor->tool_buttons == 0) { + dispatch_cursor_button(cursor, + event->time_msec, BTN_RIGHT, event->state); + } + cursor->tool_buttons++; + break; + case WLR_BUTTON_RELEASED: + if (cursor->tool_buttons == 1) { + dispatch_cursor_button(cursor, + event->time_msec, BTN_RIGHT, event->state); + } + cursor->tool_buttons--; + break; + } } static void handle_request_set_cursor(struct wl_listener *listener, @@ -332,6 +373,9 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) { &cursor->touch_motion); cursor->touch_motion.notify = handle_touch_motion; + // TODO: tablet protocol support + // Note: We should emulate pointer events for clients that don't support the + // tablet protocol when the time comes wl_signal_add(&wlr_cursor->events.tablet_tool_axis, &cursor->tool_axis); cursor->tool_axis.notify = handle_tool_axis; @@ -339,6 +383,9 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) { wl_signal_add(&wlr_cursor->events.tablet_tool_tip, &cursor->tool_tip); cursor->tool_tip.notify = handle_tool_tip; + wl_signal_add(&wlr_cursor->events.tablet_tool_button, &cursor->tool_button); + cursor->tool_button.notify = handle_tool_button; + wl_signal_add(&seat->wlr_seat->events.request_set_cursor, &cursor->request_set_cursor); 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, } } +static void seat_configure_tablet_tool(struct sway_seat *seat, + struct sway_seat_device *sway_device) { + wlr_cursor_attach_input_device(seat->cursor->cursor, + sway_device->input_device->wlr_device); +} + static struct sway_seat_device *seat_get_device(struct sway_seat *seat, struct sway_input_device *input_device) { struct sway_seat_device *seat_device = NULL; @@ -311,9 +317,11 @@ void seat_configure_device(struct sway_seat *seat, case WLR_INPUT_DEVICE_KEYBOARD: seat_configure_keyboard(seat, seat_device); break; - case WLR_INPUT_DEVICE_TOUCH: - case WLR_INPUT_DEVICE_TABLET_PAD: case WLR_INPUT_DEVICE_TABLET_TOOL: + seat_configure_tablet_tool(seat, seat_device); + break; + case WLR_INPUT_DEVICE_TABLET_PAD: + case WLR_INPUT_DEVICE_TOUCH: wlr_log(L_DEBUG, "TODO: configure other devices"); break; } 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( 'commands/split.c', 'commands/swaybg_command.c', 'commands/workspace.c', + 'commands/ws_auto_back_and_forth.c', 'commands/bar/activate_button.c', '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) { wlr_server_decoration_manager_set_default_mode( deco_manager, WLR_SERVER_DECORATION_MANAGER_MODE_SERVER); - struct wlr_egl *egl = wlr_backend_get_egl(server->backend); - wlr_linux_dmabuf_create(server->wl_display, egl); + wlr_linux_dmabuf_create(server->wl_display, renderer); server->socket = wl_display_add_socket_auto(server->wl_display); if (!server->socket) { |