|
|
@ -5,15 +5,19 @@
|
|
|
|
#elif __FreeBSD__
|
|
|
|
#elif __FreeBSD__
|
|
|
|
#include <dev/evdev/input-event-codes.h>
|
|
|
|
#include <dev/evdev/input-event-codes.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
#include <wlr/types/wlr_cursor.h>
|
|
|
|
#include <wlr/types/wlr_cursor.h>
|
|
|
|
#include <wlr/types/wlr_xcursor_manager.h>
|
|
|
|
#include <wlr/types/wlr_xcursor_manager.h>
|
|
|
|
#include <wlr/types/wlr_idle.h>
|
|
|
|
#include <wlr/types/wlr_idle.h>
|
|
|
|
#include "list.h"
|
|
|
|
#include "list.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "log.h"
|
|
|
|
|
|
|
|
#include "sway/desktop.h"
|
|
|
|
#include "sway/desktop/transaction.h"
|
|
|
|
#include "sway/desktop/transaction.h"
|
|
|
|
#include "sway/input/cursor.h"
|
|
|
|
#include "sway/input/cursor.h"
|
|
|
|
|
|
|
|
#include "sway/input/keyboard.h"
|
|
|
|
#include "sway/layers.h"
|
|
|
|
#include "sway/layers.h"
|
|
|
|
#include "sway/output.h"
|
|
|
|
#include "sway/output.h"
|
|
|
|
|
|
|
|
#include "sway/tree/arrange.h"
|
|
|
|
#include "sway/tree/view.h"
|
|
|
|
#include "sway/tree/view.h"
|
|
|
|
#include "sway/tree/workspace.h"
|
|
|
|
#include "sway/tree/workspace.h"
|
|
|
|
#include "wlr-layer-shell-unstable-v1-protocol.h"
|
|
|
|
#include "wlr-layer-shell-unstable-v1-protocol.h"
|
|
|
@ -127,7 +131,7 @@ static struct sway_container *container_at_coords(
|
|
|
|
return ws;
|
|
|
|
return ws;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
c = seat_get_focus_inactive(seat, output->swayc);
|
|
|
|
c = seat_get_active_child(seat, output->swayc);
|
|
|
|
if (c) {
|
|
|
|
if (c) {
|
|
|
|
return c;
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -139,6 +143,171 @@ static struct sway_container *container_at_coords(
|
|
|
|
return output->swayc;
|
|
|
|
return output->swayc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static enum wlr_edges find_resize_edge(struct sway_container *cont,
|
|
|
|
|
|
|
|
struct sway_cursor *cursor) {
|
|
|
|
|
|
|
|
if (cont->type != C_VIEW) {
|
|
|
|
|
|
|
|
return WLR_EDGE_NONE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
struct sway_view *view = cont->sway_view;
|
|
|
|
|
|
|
|
if (view->border == B_NONE || !view->border_thickness || view->using_csd) {
|
|
|
|
|
|
|
|
return WLR_EDGE_NONE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum wlr_edges edge = 0;
|
|
|
|
|
|
|
|
if (cursor->cursor->x < cont->x + view->border_thickness) {
|
|
|
|
|
|
|
|
edge |= WLR_EDGE_LEFT;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor->cursor->y < cont->y + view->border_thickness) {
|
|
|
|
|
|
|
|
edge |= WLR_EDGE_TOP;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor->cursor->x >= cont->x + cont->width - view->border_thickness) {
|
|
|
|
|
|
|
|
edge |= WLR_EDGE_RIGHT;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor->cursor->y >= cont->y + cont->height - view->border_thickness) {
|
|
|
|
|
|
|
|
edge |= WLR_EDGE_BOTTOM;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return edge;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void handle_move_motion(struct sway_seat *seat,
|
|
|
|
|
|
|
|
struct sway_cursor *cursor) {
|
|
|
|
|
|
|
|
struct sway_container *con = seat->op_container;
|
|
|
|
|
|
|
|
desktop_damage_whole_container(con);
|
|
|
|
|
|
|
|
container_floating_translate(con,
|
|
|
|
|
|
|
|
cursor->cursor->x - cursor->previous.x,
|
|
|
|
|
|
|
|
cursor->cursor->y - cursor->previous.y);
|
|
|
|
|
|
|
|
desktop_damage_whole_container(con);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void calculate_floating_constraints(struct sway_container *con,
|
|
|
|
|
|
|
|
int *min_width, int *max_width, int *min_height, int *max_height) {
|
|
|
|
|
|
|
|
if (config->floating_minimum_width == -1) { // no minimum
|
|
|
|
|
|
|
|
*min_width = 0;
|
|
|
|
|
|
|
|
} else if (config->floating_minimum_width == 0) { // automatic
|
|
|
|
|
|
|
|
*min_width = 75;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
*min_width = config->floating_minimum_width;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (config->floating_minimum_height == -1) { // no minimum
|
|
|
|
|
|
|
|
*min_height = 0;
|
|
|
|
|
|
|
|
} else if (config->floating_minimum_height == 0) { // automatic
|
|
|
|
|
|
|
|
*min_height = 50;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
*min_height = config->floating_minimum_height;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (config->floating_maximum_width == -1) { // no maximum
|
|
|
|
|
|
|
|
*max_width = INT_MAX;
|
|
|
|
|
|
|
|
} else if (config->floating_maximum_width == 0) { // automatic
|
|
|
|
|
|
|
|
struct sway_container *ws = container_parent(con, C_WORKSPACE);
|
|
|
|
|
|
|
|
*max_width = ws->width;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
*max_width = config->floating_maximum_width;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (config->floating_maximum_height == -1) { // no maximum
|
|
|
|
|
|
|
|
*max_height = INT_MAX;
|
|
|
|
|
|
|
|
} else if (config->floating_maximum_height == 0) { // automatic
|
|
|
|
|
|
|
|
struct sway_container *ws = container_parent(con, C_WORKSPACE);
|
|
|
|
|
|
|
|
*max_height = ws->height;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
*max_height = config->floating_maximum_height;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void handle_resize_motion(struct sway_seat *seat,
|
|
|
|
|
|
|
|
struct sway_cursor *cursor) {
|
|
|
|
|
|
|
|
struct sway_container *con = seat->op_container;
|
|
|
|
|
|
|
|
enum wlr_edges edge = seat->op_resize_edge;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The amount the mouse has moved since the start of the resize operation
|
|
|
|
|
|
|
|
// Positive is down/right
|
|
|
|
|
|
|
|
double mouse_move_x = cursor->cursor->x - seat->op_ref_lx;
|
|
|
|
|
|
|
|
double mouse_move_y = cursor->cursor->y - seat->op_ref_ly;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (edge == WLR_EDGE_TOP || edge == WLR_EDGE_BOTTOM) {
|
|
|
|
|
|
|
|
mouse_move_x = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (edge == WLR_EDGE_LEFT || edge == WLR_EDGE_RIGHT) {
|
|
|
|
|
|
|
|
mouse_move_y = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double grow_width = edge & WLR_EDGE_LEFT ? -mouse_move_x : mouse_move_x;
|
|
|
|
|
|
|
|
double grow_height = edge & WLR_EDGE_TOP ? -mouse_move_y : mouse_move_y;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (seat->op_resize_preserve_ratio) {
|
|
|
|
|
|
|
|
double x_multiplier = grow_width / seat->op_ref_width;
|
|
|
|
|
|
|
|
double y_multiplier = grow_height / seat->op_ref_height;
|
|
|
|
|
|
|
|
double max_multiplier = fmax(x_multiplier, y_multiplier);
|
|
|
|
|
|
|
|
grow_width = seat->op_ref_width * max_multiplier;
|
|
|
|
|
|
|
|
grow_height = seat->op_ref_height * max_multiplier;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Determine new width/height, and accommodate for floating min/max values
|
|
|
|
|
|
|
|
double width = seat->op_ref_width + grow_width;
|
|
|
|
|
|
|
|
double height = seat->op_ref_height + grow_height;
|
|
|
|
|
|
|
|
int min_width, max_width, min_height, max_height;
|
|
|
|
|
|
|
|
calculate_floating_constraints(con, &min_width, &max_width,
|
|
|
|
|
|
|
|
&min_height, &max_height);
|
|
|
|
|
|
|
|
width = fmax(min_width, fmin(width, max_width));
|
|
|
|
|
|
|
|
height = fmax(min_height, fmin(height, max_height));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Apply the view's min/max size
|
|
|
|
|
|
|
|
if (con->type == C_VIEW) {
|
|
|
|
|
|
|
|
double view_min_width, view_max_width, view_min_height, view_max_height;
|
|
|
|
|
|
|
|
view_get_constraints(con->sway_view, &view_min_width, &view_max_width,
|
|
|
|
|
|
|
|
&view_min_height, &view_max_height);
|
|
|
|
|
|
|
|
width = fmax(view_min_width, fmin(width, view_max_width));
|
|
|
|
|
|
|
|
height = fmax(view_min_height, fmin(height, view_max_height));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Recalculate these, in case we hit a min/max limit
|
|
|
|
|
|
|
|
grow_width = width - seat->op_ref_width;
|
|
|
|
|
|
|
|
grow_height = height - seat->op_ref_height;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Determine grow x/y values - these are relative to the container's x/y at
|
|
|
|
|
|
|
|
// the start of the resize operation.
|
|
|
|
|
|
|
|
double grow_x = 0, grow_y = 0;
|
|
|
|
|
|
|
|
if (edge & WLR_EDGE_LEFT) {
|
|
|
|
|
|
|
|
grow_x = -grow_width;
|
|
|
|
|
|
|
|
} else if (edge & WLR_EDGE_RIGHT) {
|
|
|
|
|
|
|
|
grow_x = 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
grow_x = -grow_width / 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (edge & WLR_EDGE_TOP) {
|
|
|
|
|
|
|
|
grow_y = -grow_height;
|
|
|
|
|
|
|
|
} else if (edge & WLR_EDGE_BOTTOM) {
|
|
|
|
|
|
|
|
grow_y = 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
grow_y = -grow_height / 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Determine the amounts we need to bump everything relative to the current
|
|
|
|
|
|
|
|
// size.
|
|
|
|
|
|
|
|
int relative_grow_width = width - con->width;
|
|
|
|
|
|
|
|
int relative_grow_height = height - con->height;
|
|
|
|
|
|
|
|
int relative_grow_x = (seat->op_ref_con_lx + grow_x) - con->x;
|
|
|
|
|
|
|
|
int relative_grow_y = (seat->op_ref_con_ly + grow_y) - con->y;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Actually resize stuff
|
|
|
|
|
|
|
|
con->x += relative_grow_x;
|
|
|
|
|
|
|
|
con->y += relative_grow_y;
|
|
|
|
|
|
|
|
con->width += relative_grow_width;
|
|
|
|
|
|
|
|
con->height += relative_grow_height;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (con->type == C_VIEW) {
|
|
|
|
|
|
|
|
struct sway_view *view = con->sway_view;
|
|
|
|
|
|
|
|
view->x += relative_grow_x;
|
|
|
|
|
|
|
|
view->y += relative_grow_y;
|
|
|
|
|
|
|
|
view->width += relative_grow_width;
|
|
|
|
|
|
|
|
view->height += relative_grow_height;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
arrange_windows(con);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
|
|
|
|
void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
|
|
|
|
bool allow_refocusing) {
|
|
|
|
bool allow_refocusing) {
|
|
|
|
if (time_msec == 0) {
|
|
|
|
if (time_msec == 0) {
|
|
|
@ -146,6 +315,18 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct sway_seat *seat = cursor->seat;
|
|
|
|
struct sway_seat *seat = cursor->seat;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (seat->operation != OP_NONE) {
|
|
|
|
|
|
|
|
if (seat->operation == OP_MOVE) {
|
|
|
|
|
|
|
|
handle_move_motion(seat, cursor);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
handle_resize_motion(seat, cursor);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor->previous.x = cursor->cursor->x;
|
|
|
|
|
|
|
|
cursor->previous.y = cursor->cursor->y;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_seat *wlr_seat = seat->wlr_seat;
|
|
|
|
struct wlr_seat *wlr_seat = seat->wlr_seat;
|
|
|
|
struct wlr_surface *surface = NULL;
|
|
|
|
struct wlr_surface *surface = NULL;
|
|
|
|
double sx, sy;
|
|
|
|
double sx, sy;
|
|
|
@ -194,15 +375,21 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// reset cursor if switching between clients
|
|
|
|
// Handle cursor image
|
|
|
|
struct wl_client *client = NULL;
|
|
|
|
if (surface) {
|
|
|
|
if (surface != NULL) {
|
|
|
|
// Reset cursor if switching between clients
|
|
|
|
client = wl_resource_get_client(surface->resource);
|
|
|
|
struct wl_client *client = wl_resource_get_client(surface->resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client != cursor->image_client) {
|
|
|
|
if (client != cursor->image_client) {
|
|
|
|
wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
|
|
|
|
cursor_set_image(cursor, "left_ptr", client);
|
|
|
|
"left_ptr", cursor->cursor);
|
|
|
|
}
|
|
|
|
cursor->image_client = client;
|
|
|
|
} else if (c && container_is_floating(c)) {
|
|
|
|
|
|
|
|
// Try a floating container's resize edge
|
|
|
|
|
|
|
|
enum wlr_edges edge = find_resize_edge(c, cursor);
|
|
|
|
|
|
|
|
const char *image = edge == WLR_EDGE_NONE ?
|
|
|
|
|
|
|
|
"left_ptr" : wlr_xcursor_get_resize_name(edge);
|
|
|
|
|
|
|
|
cursor_set_image(cursor, image, NULL);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
cursor_set_image(cursor, "left_ptr", NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// send pointer enter/leave
|
|
|
|
// send pointer enter/leave
|
|
|
@ -243,8 +430,53 @@ static void handle_cursor_motion_absolute(
|
|
|
|
transaction_commit_dirty();
|
|
|
|
transaction_commit_dirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void dispatch_cursor_button_floating(struct sway_cursor *cursor,
|
|
|
|
|
|
|
|
uint32_t time_msec, uint32_t button, enum wlr_button_state state,
|
|
|
|
|
|
|
|
struct wlr_surface *surface, double sx, double sy,
|
|
|
|
|
|
|
|
struct sway_container *cont) {
|
|
|
|
|
|
|
|
struct sway_seat *seat = cursor->seat;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Deny moving or resizing a fullscreen view
|
|
|
|
|
|
|
|
if (cont->type == C_VIEW && cont->sway_view->is_fullscreen) {
|
|
|
|
|
|
|
|
seat_pointer_notify_button(seat, time_msec, button, state);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat);
|
|
|
|
|
|
|
|
bool mod_pressed = keyboard &&
|
|
|
|
|
|
|
|
(wlr_keyboard_get_modifiers(keyboard) & config->floating_mod);
|
|
|
|
|
|
|
|
enum wlr_edges edge = find_resize_edge(cont, cursor);
|
|
|
|
|
|
|
|
bool over_title = edge == WLR_EDGE_NONE && !surface;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check for beginning move
|
|
|
|
|
|
|
|
if (button == BTN_LEFT && state == WLR_BUTTON_PRESSED &&
|
|
|
|
|
|
|
|
(mod_pressed || over_title)) {
|
|
|
|
|
|
|
|
seat_begin_move(seat, cont, BTN_LEFT);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check for beginning resize
|
|
|
|
|
|
|
|
bool resizing_via_border = button == BTN_LEFT && edge != WLR_EDGE_NONE;
|
|
|
|
|
|
|
|
bool resizing_via_mod = button == BTN_RIGHT && mod_pressed;
|
|
|
|
|
|
|
|
if ((resizing_via_border || resizing_via_mod) &&
|
|
|
|
|
|
|
|
state == WLR_BUTTON_PRESSED) {
|
|
|
|
|
|
|
|
seat_begin_resize(seat, cont, button, edge);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send event to surface
|
|
|
|
|
|
|
|
seat_set_focus(seat, cont);
|
|
|
|
|
|
|
|
seat_pointer_notify_button(seat, time_msec, button, state);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void dispatch_cursor_button(struct sway_cursor *cursor,
|
|
|
|
void dispatch_cursor_button(struct sway_cursor *cursor,
|
|
|
|
uint32_t time_msec, uint32_t button, enum wlr_button_state state) {
|
|
|
|
uint32_t time_msec, uint32_t button, enum wlr_button_state state) {
|
|
|
|
|
|
|
|
if (cursor->seat->operation != OP_NONE &&
|
|
|
|
|
|
|
|
button == cursor->seat->op_button && state == WLR_BUTTON_RELEASED) {
|
|
|
|
|
|
|
|
seat_end_mouse_operation(cursor->seat);
|
|
|
|
|
|
|
|
seat_pointer_notify_button(cursor->seat, time_msec, button, state);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (time_msec == 0) {
|
|
|
|
if (time_msec == 0) {
|
|
|
|
time_msec = get_current_time_msec();
|
|
|
|
time_msec = get_current_time_msec();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -259,6 +491,10 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
|
|
|
|
if (layer->current.keyboard_interactive) {
|
|
|
|
if (layer->current.keyboard_interactive) {
|
|
|
|
seat_set_focus_layer(cursor->seat, layer);
|
|
|
|
seat_set_focus_layer(cursor->seat, layer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
seat_pointer_notify_button(cursor->seat, time_msec, button, state);
|
|
|
|
|
|
|
|
} else if (cont && container_is_floating(cont)) {
|
|
|
|
|
|
|
|
dispatch_cursor_button_floating(cursor, time_msec, button, state,
|
|
|
|
|
|
|
|
surface, sx, sy, cont);
|
|
|
|
} else if (surface && cont && cont->type != C_VIEW) {
|
|
|
|
} else if (surface && cont && cont->type != C_VIEW) {
|
|
|
|
// Avoid moving keyboard focus from a surface that accepts it to one
|
|
|
|
// Avoid moving keyboard focus from a surface that accepts it to one
|
|
|
|
// that does not unless the change would move us to a new workspace.
|
|
|
|
// that does not unless the change would move us to a new workspace.
|
|
|
@ -275,12 +511,14 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
|
|
|
|
if (new_ws != old_ws) {
|
|
|
|
if (new_ws != old_ws) {
|
|
|
|
seat_set_focus(cursor->seat, cont);
|
|
|
|
seat_set_focus(cursor->seat, cont);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
seat_pointer_notify_button(cursor->seat, time_msec, button, state);
|
|
|
|
} else if (cont) {
|
|
|
|
} else if (cont) {
|
|
|
|
seat_set_focus(cursor->seat, cont);
|
|
|
|
seat_set_focus(cursor->seat, cont);
|
|
|
|
|
|
|
|
seat_pointer_notify_button(cursor->seat, time_msec, button, state);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
seat_pointer_notify_button(cursor->seat, time_msec, button, state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_seat_pointer_notify_button(cursor->seat->wlr_seat,
|
|
|
|
|
|
|
|
time_msec, button, state);
|
|
|
|
|
|
|
|
transaction_commit_dirty();
|
|
|
|
transaction_commit_dirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -467,6 +705,9 @@ static void handle_request_set_cursor(struct wl_listener *listener,
|
|
|
|
void *data) {
|
|
|
|
void *data) {
|
|
|
|
struct sway_cursor *cursor =
|
|
|
|
struct sway_cursor *cursor =
|
|
|
|
wl_container_of(listener, cursor, request_set_cursor);
|
|
|
|
wl_container_of(listener, cursor, request_set_cursor);
|
|
|
|
|
|
|
|
if (cursor->seat->operation != OP_NONE) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
struct wlr_seat_pointer_request_set_cursor_event *event = data;
|
|
|
|
struct wlr_seat_pointer_request_set_cursor_event *event = data;
|
|
|
|
|
|
|
|
|
|
|
|
struct wl_client *focused_client = NULL;
|
|
|
|
struct wl_client *focused_client = NULL;
|
|
|
@ -488,6 +729,16 @@ static void handle_request_set_cursor(struct wl_listener *listener,
|
|
|
|
cursor->image_client = focused_client;
|
|
|
|
cursor->image_client = focused_client;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cursor_set_image(struct sway_cursor *cursor, const char *image,
|
|
|
|
|
|
|
|
struct wl_client *client) {
|
|
|
|
|
|
|
|
if (!cursor->image || strcmp(cursor->image, image) != 0) {
|
|
|
|
|
|
|
|
wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, image,
|
|
|
|
|
|
|
|
cursor->cursor);
|
|
|
|
|
|
|
|
cursor->image = image;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor->image_client = client;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sway_cursor_destroy(struct sway_cursor *cursor) {
|
|
|
|
void sway_cursor_destroy(struct sway_cursor *cursor) {
|
|
|
|
if (!cursor) {
|
|
|
|
if (!cursor) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|