Merge branch 'wlroots' into focus-inactive-fixes

This commit is contained in:
Tony Crisci 2018-04-08 12:47:56 -04:00
commit ae78f6fb93
9 changed files with 94 additions and 24 deletions

View File

@ -1,6 +1,6 @@
#ifndef _SWAY_INPUT_CURSOR_H
#define _SWAY_INPUT_CURSOR_H
#include <stdint.h>
#include "sway/input/seat.h"
struct sway_cursor {
@ -22,6 +22,8 @@ struct sway_cursor {
struct wl_listener tool_axis;
struct wl_listener tool_tip;
struct wl_listener tool_button;
uint32_t tool_buttons;
struct wl_listener request_set_cursor;
};

View File

@ -35,7 +35,7 @@ pangocairo = dependency('pangocairo')
gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: false)
pixman = dependency('pixman-1')
libcap = dependency('libcap')
libinput = dependency('libinput')
libinput = dependency('libinput', version: '>=1.6.0')
libpam = cc.find_library('libpam')
math = cc.find_library('m')
rt = cc.find_library('rt')

View File

@ -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[] = {

View File

@ -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);
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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',

View File

@ -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) {

View File

@ -411,7 +411,7 @@ static uint32_t render_workspace_button(cairo_t *cairo,
hotspot->height = height;
hotspot->callback = workspace_hotspot_callback;
hotspot->destroy = free;
hotspot->data = strdup(name);
hotspot->data = strdup(ws->name);
wl_list_insert(&output->hotspots, &hotspot->link);
*x += width;