|
|
|
@ -290,7 +290,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
|
|
|
|
|
|
|
|
|
|
static bool trigger_pointer_button_binding(struct sway_seat *seat,
|
|
|
|
|
struct wlr_input_device *device, uint32_t button,
|
|
|
|
|
enum wlr_button_state state, uint32_t modifiers,
|
|
|
|
|
enum wl_pointer_button_state state, uint32_t modifiers,
|
|
|
|
|
bool on_titlebar, bool on_border, bool on_contents, bool on_workspace) {
|
|
|
|
|
// We can reach this for non-pointer devices if we're currently emulating
|
|
|
|
|
// pointer input for one. Emulated input should not trigger bindings. The
|
|
|
|
@ -304,7 +304,7 @@ static bool trigger_pointer_button_binding(struct sway_seat *seat,
|
|
|
|
|
char *device_identifier = device ? input_device_get_identifier(device)
|
|
|
|
|
: strdup("*");
|
|
|
|
|
struct sway_binding *binding = NULL;
|
|
|
|
|
if (state == WLR_BUTTON_PRESSED) {
|
|
|
|
|
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
|
|
|
|
state_add_button(e, button);
|
|
|
|
|
binding = get_active_mouse_binding(e,
|
|
|
|
|
config->current_mode->mouse_bindings, modifiers, false,
|
|
|
|
@ -329,7 +329,7 @@ static bool trigger_pointer_button_binding(struct sway_seat *seat,
|
|
|
|
|
|
|
|
|
|
static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
|
|
|
|
struct wlr_input_device *device, uint32_t button,
|
|
|
|
|
enum wlr_button_state state) {
|
|
|
|
|
enum wl_pointer_button_state state) {
|
|
|
|
|
struct sway_cursor *cursor = seat->cursor;
|
|
|
|
|
|
|
|
|
|
// Determine what's under the cursor
|
|
|
|
@ -362,7 +362,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
|
|
|
|
|
|
|
|
|
// Handle clicking an empty workspace
|
|
|
|
|
if (node && node->type == N_WORKSPACE) {
|
|
|
|
|
if (state == WLR_BUTTON_PRESSED) {
|
|
|
|
|
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
|
|
|
|
seat_set_focus(seat, node);
|
|
|
|
|
transaction_commit_dirty();
|
|
|
|
|
}
|
|
|
|
@ -377,7 +377,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
|
|
|
|
seat_set_focus_layer(seat, layer);
|
|
|
|
|
transaction_commit_dirty();
|
|
|
|
|
}
|
|
|
|
|
if (state == WLR_BUTTON_PRESSED) {
|
|
|
|
|
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
|
|
|
|
seatop_begin_down_on_surface(seat, surface, sx, sy);
|
|
|
|
|
}
|
|
|
|
|
seat_pointer_notify_button(seat, time_msec, button, state);
|
|
|
|
@ -386,7 +386,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
|
|
|
|
|
|
|
|
|
// Handle tiling resize via border
|
|
|
|
|
if (cont && resize_edge && button == BTN_LEFT &&
|
|
|
|
|
state == WLR_BUTTON_PRESSED && !is_floating) {
|
|
|
|
|
state == WL_POINTER_BUTTON_STATE_PRESSED && !is_floating) {
|
|
|
|
|
// If a resize is triggered on a tabbed or stacked container, change
|
|
|
|
|
// focus to the tab which already had inactive focus -- otherwise, we'd
|
|
|
|
|
// change the active tab when the user probably just wanted to resize.
|
|
|
|
@ -404,7 +404,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
|
|
|
|
// Handle tiling resize via mod
|
|
|
|
|
bool mod_pressed = modifiers & config->floating_mod;
|
|
|
|
|
if (cont && !is_floating_or_child && mod_pressed &&
|
|
|
|
|
state == WLR_BUTTON_PRESSED) {
|
|
|
|
|
state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
|
|
|
|
uint32_t btn_resize = config->floating_mod_inverse ?
|
|
|
|
|
BTN_LEFT : BTN_RIGHT;
|
|
|
|
|
if (button == btn_resize) {
|
|
|
|
@ -432,7 +432,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle changing focus when clicking on a container
|
|
|
|
|
if (cont && state == WLR_BUTTON_PRESSED) {
|
|
|
|
|
if (cont && state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
|
|
|
|
// Default case: focus the container that was just clicked.
|
|
|
|
|
node = &cont->node;
|
|
|
|
|
|
|
|
|
@ -453,7 +453,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
|
|
|
|
|
|
|
|
|
// Handle beginning floating move
|
|
|
|
|
if (cont && is_floating_or_child && !is_fullscreen_or_child &&
|
|
|
|
|
state == WLR_BUTTON_PRESSED) {
|
|
|
|
|
state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
|
|
|
|
uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT;
|
|
|
|
|
if (button == btn_move && (mod_pressed || on_titlebar)) {
|
|
|
|
|
seatop_begin_move_floating(seat, container_toplevel_ancestor(cont));
|
|
|
|
@ -463,7 +463,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
|
|
|
|
|
|
|
|
|
// Handle beginning floating resize
|
|
|
|
|
if (cont && is_floating_or_child && !is_fullscreen_or_child &&
|
|
|
|
|
state == WLR_BUTTON_PRESSED) {
|
|
|
|
|
state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
|
|
|
|
// Via border
|
|
|
|
|
if (button == BTN_LEFT && resize_edge != WLR_EDGE_NONE) {
|
|
|
|
|
seat_set_focus_container(seat, cont);
|
|
|
|
@ -489,7 +489,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
|
|
|
|
|
|
|
|
|
// Handle moving a tiling container
|
|
|
|
|
if (config->tiling_drag && (mod_pressed || on_titlebar) &&
|
|
|
|
|
state == WLR_BUTTON_PRESSED && !is_floating_or_child &&
|
|
|
|
|
state == WL_POINTER_BUTTON_STATE_PRESSED && !is_floating_or_child &&
|
|
|
|
|
cont && cont->pending.fullscreen_mode == FULLSCREEN_NONE) {
|
|
|
|
|
// If moving a container by its title bar, use a threshold for the drag
|
|
|
|
|
if (!mod_pressed && config->tiling_drag_threshold > 0) {
|
|
|
|
@ -502,14 +502,14 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle mousedown on a container surface
|
|
|
|
|
if (surface && cont && state == WLR_BUTTON_PRESSED) {
|
|
|
|
|
if (surface && cont && state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
|
|
|
|
seatop_begin_down(seat, cont, sx, sy);
|
|
|
|
|
seat_pointer_notify_button(seat, time_msec, button, WLR_BUTTON_PRESSED);
|
|
|
|
|
seat_pointer_notify_button(seat, time_msec, button, WL_POINTER_BUTTON_STATE_PRESSED);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle clicking a container surface or decorations
|
|
|
|
|
if (cont && state == WLR_BUTTON_PRESSED) {
|
|
|
|
|
if (cont && state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
|
|
|
|
seat_pointer_notify_button(seat, time_msec, button, state);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -684,7 +684,7 @@ static void handle_touch_down(struct sway_seat *seat,
|
|
|
|
|
pointer_motion(cursor, event->time_msec, &event->touch->base, dx, dy,
|
|
|
|
|
dx, dy);
|
|
|
|
|
dispatch_cursor_button(cursor, &event->touch->base, event->time_msec,
|
|
|
|
|
BTN_LEFT, WLR_BUTTON_PRESSED);
|
|
|
|
|
BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -694,9 +694,9 @@ static void handle_touch_down(struct sway_seat *seat,
|
|
|
|
|
|
|
|
|
|
static uint32_t wl_axis_to_button(struct wlr_pointer_axis_event *event) {
|
|
|
|
|
switch (event->orientation) {
|
|
|
|
|
case WLR_AXIS_ORIENTATION_VERTICAL:
|
|
|
|
|
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
|
|
|
|
return event->delta < 0 ? SWAY_SCROLL_UP : SWAY_SCROLL_DOWN;
|
|
|
|
|
case WLR_AXIS_ORIENTATION_HORIZONTAL:
|
|
|
|
|
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
|
|
|
|
return event->delta < 0 ? SWAY_SCROLL_LEFT : SWAY_SCROLL_RIGHT;
|
|
|
|
|
default:
|
|
|
|
|
sway_log(SWAY_DEBUG, "Unknown axis orientation");
|
|
|
|
|