mirror of
https://github.com/labwc/labwc.git
synced 2026-04-09 08:21:18 -04:00
tree-wide: auto-replace of (struct server *)
#!/bin/bash
read -r -d '' EXPRS << EOF
s/xwayland->server/xwayland->svr/g;
s/\t*struct server \*server;\n//g;
s/\t*struct server \*server =.*?;\n//gs;
s/\t*.* = ([a-z_]*->)*server[;,]\n//g;
s/\{\n\n/\{\n/g;
s/\n\n+/\n\n/g;
s/\(\s*struct server \*server\)/(void)/g;
s/\(\s*struct server \*server,\s*/(/g;
s/,\s*struct server \*server\)/)/g;
s/,\s*struct server \*server,\s*/, /g;
s/\(\s*([a-z_]*->)*server\)/()/g;
s/\(\s*([a-z_]*->)*server,\s*/(/g;
s/,\s*([a-z_]*->)*server\)/)/g;
s/,\s*([a-z_]*->)*server,\s*/, /g;
s/([a-z_]*->)*server->/g_server./g;
s/xwayland->svr/xwayland->server/g;
EOF
find src include \( -name \*.c -o -name \*.h \) -exec \
perl -0777 -i -pe "$EXPRS" \{\} \;
This commit is contained in:
parent
60ac8f07bb
commit
cb49bddf63
81 changed files with 1522 additions and 1682 deletions
|
|
@ -148,7 +148,7 @@ handle_request_set_cursor(struct wl_listener *listener, void *data)
|
|||
{
|
||||
struct seat *seat = wl_container_of(listener, seat, request_set_cursor);
|
||||
|
||||
if (seat->server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
if (g_server.input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
/* Prevent setting a cursor image when moving or resizing */
|
||||
return;
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@ handle_request_set_shape(struct wl_listener *listener, void *data)
|
|||
struct wlr_seat_client *focused_client = seat->seat->pointer_state.focused_client;
|
||||
|
||||
/* Prevent setting a cursor image when moving or resizing */
|
||||
if (seat->server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
if (g_server.input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -265,12 +265,12 @@ handle_request_set_primary_selection(struct wl_listener *listener, void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
process_cursor_move(struct server *server, uint32_t time)
|
||||
process_cursor_move(uint32_t time)
|
||||
{
|
||||
struct view *view = server->grabbed_view;
|
||||
struct view *view = g_server.grabbed_view;
|
||||
|
||||
int x = server->grab_box.x + (server->seat.cursor->x - server->grab_x);
|
||||
int y = server->grab_box.y + (server->seat.cursor->y - server->grab_y);
|
||||
int x = g_server.grab_box.x + (g_server.seat.cursor->x - g_server.grab_x);
|
||||
int y = g_server.grab_box.y + (g_server.seat.cursor->y - g_server.grab_y);
|
||||
|
||||
/* Apply resistance for maximized/tiled view */
|
||||
bool needs_untile = resistance_unsnap_apply(view, &x, &y);
|
||||
|
|
@ -286,7 +286,7 @@ process_cursor_move(struct server *server, uint32_t time)
|
|||
.width = view->natural_geometry.width,
|
||||
.height = view->natural_geometry.height,
|
||||
};
|
||||
interactive_anchor_to_cursor(server, &new_geo);
|
||||
interactive_anchor_to_cursor(&new_geo);
|
||||
/* Shaded clients will not process resize events until unshaded */
|
||||
view_set_shade(view, false);
|
||||
view_set_maximized(view, VIEW_AXIS_NONE);
|
||||
|
|
@ -300,18 +300,18 @@ process_cursor_move(struct server *server, uint32_t time)
|
|||
resistance_move_apply(view, &x, &y);
|
||||
|
||||
view_move(view, x, y);
|
||||
overlay_update(&server->seat);
|
||||
overlay_update(&g_server.seat);
|
||||
}
|
||||
|
||||
static void
|
||||
process_cursor_resize(struct server *server, uint32_t time)
|
||||
process_cursor_resize(uint32_t time)
|
||||
{
|
||||
/* Rate-limit resize events respecting monitor refresh rate */
|
||||
static uint32_t last_resize_time = 0;
|
||||
static struct view *last_resize_view = NULL;
|
||||
|
||||
assert(server->grabbed_view);
|
||||
if (server->grabbed_view == last_resize_view) {
|
||||
assert(g_server.grabbed_view);
|
||||
if (g_server.grabbed_view == last_resize_view) {
|
||||
int32_t refresh = 0;
|
||||
if (output_is_usable(last_resize_view->output)) {
|
||||
refresh = last_resize_view->output->wlr_output->refresh;
|
||||
|
|
@ -327,43 +327,43 @@ process_cursor_resize(struct server *server, uint32_t time)
|
|||
}
|
||||
|
||||
last_resize_time = time;
|
||||
last_resize_view = server->grabbed_view;
|
||||
last_resize_view = g_server.grabbed_view;
|
||||
|
||||
double dx = server->seat.cursor->x - server->grab_x;
|
||||
double dy = server->seat.cursor->y - server->grab_y;
|
||||
double dx = g_server.seat.cursor->x - g_server.grab_x;
|
||||
double dy = g_server.seat.cursor->y - g_server.grab_y;
|
||||
|
||||
struct view *view = server->grabbed_view;
|
||||
struct view *view = g_server.grabbed_view;
|
||||
struct wlr_box new_view_geo = view->current;
|
||||
|
||||
if (server->resize_edges & LAB_EDGE_TOP) {
|
||||
if (g_server.resize_edges & LAB_EDGE_TOP) {
|
||||
/* Shift y to anchor bottom edge when resizing top */
|
||||
new_view_geo.y = server->grab_box.y + dy;
|
||||
new_view_geo.height = server->grab_box.height - dy;
|
||||
} else if (server->resize_edges & LAB_EDGE_BOTTOM) {
|
||||
new_view_geo.height = server->grab_box.height + dy;
|
||||
new_view_geo.y = g_server.grab_box.y + dy;
|
||||
new_view_geo.height = g_server.grab_box.height - dy;
|
||||
} else if (g_server.resize_edges & LAB_EDGE_BOTTOM) {
|
||||
new_view_geo.height = g_server.grab_box.height + dy;
|
||||
}
|
||||
|
||||
if (server->resize_edges & LAB_EDGE_LEFT) {
|
||||
if (g_server.resize_edges & LAB_EDGE_LEFT) {
|
||||
/* Shift x to anchor right edge when resizing left */
|
||||
new_view_geo.x = server->grab_box.x + dx;
|
||||
new_view_geo.width = server->grab_box.width - dx;
|
||||
} else if (server->resize_edges & LAB_EDGE_RIGHT) {
|
||||
new_view_geo.width = server->grab_box.width + dx;
|
||||
new_view_geo.x = g_server.grab_box.x + dx;
|
||||
new_view_geo.width = g_server.grab_box.width - dx;
|
||||
} else if (g_server.resize_edges & LAB_EDGE_RIGHT) {
|
||||
new_view_geo.width = g_server.grab_box.width + dx;
|
||||
}
|
||||
|
||||
resistance_resize_apply(view, &new_view_geo);
|
||||
view_adjust_size(view, &new_view_geo.width, &new_view_geo.height);
|
||||
|
||||
if (server->resize_edges & LAB_EDGE_TOP) {
|
||||
if (g_server.resize_edges & LAB_EDGE_TOP) {
|
||||
/* After size adjustments, make sure to anchor bottom edge */
|
||||
new_view_geo.y = server->grab_box.y +
|
||||
server->grab_box.height - new_view_geo.height;
|
||||
new_view_geo.y = g_server.grab_box.y +
|
||||
g_server.grab_box.height - new_view_geo.height;
|
||||
}
|
||||
|
||||
if (server->resize_edges & LAB_EDGE_LEFT) {
|
||||
if (g_server.resize_edges & LAB_EDGE_LEFT) {
|
||||
/* After size adjustments, make sure to anchor bottom right */
|
||||
new_view_geo.x = server->grab_box.x +
|
||||
server->grab_box.width - new_view_geo.width;
|
||||
new_view_geo.x = g_server.grab_box.x +
|
||||
g_server.grab_box.width - new_view_geo.width;
|
||||
}
|
||||
|
||||
if (rc.resize_draw_contents) {
|
||||
|
|
@ -422,7 +422,7 @@ cursor_update_image(struct seat *seat)
|
|||
seat->server_cursor = LAB_CURSOR_DEFAULT;
|
||||
wlr_cursor_set_xcursor(seat->cursor, seat->xcursor_manager, "");
|
||||
wlr_seat_pointer_clear_focus(seat->seat);
|
||||
cursor_update_focus(seat->server);
|
||||
cursor_update_focus();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -533,15 +533,15 @@ update_pressed_surface(struct seat *seat, const struct cursor_context *ctx)
|
|||
* and process_cursor_axis()
|
||||
*/
|
||||
static void
|
||||
cursor_update_common(struct server *server, const struct cursor_context *ctx,
|
||||
cursor_update_common(const struct cursor_context *ctx,
|
||||
struct cursor_context *notified_ctx)
|
||||
{
|
||||
struct seat *seat = &server->seat;
|
||||
struct seat *seat = &g_server.seat;
|
||||
struct wlr_seat *wlr_seat = seat->seat;
|
||||
|
||||
ssd_update_hovered_button(server, ctx->node);
|
||||
ssd_update_hovered_button(ctx->node);
|
||||
|
||||
if (server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
if (g_server.input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
/*
|
||||
* Prevent updating focus/cursor image during
|
||||
* interactive move/resize, window switcher and
|
||||
|
|
@ -565,8 +565,8 @@ cursor_update_common(struct server *server, const struct cursor_context *ctx,
|
|||
int lx, ly;
|
||||
wlr_scene_node_coords(seat->pressed.ctx.node, &lx, &ly);
|
||||
*notified_ctx = seat->pressed.ctx;
|
||||
notified_ctx->sx = server->seat.cursor->x - lx;
|
||||
notified_ctx->sy = server->seat.cursor->y - ly;
|
||||
notified_ctx->sx = g_server.seat.cursor->x - lx;
|
||||
notified_ctx->sy = g_server.seat.cursor->y - ly;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -620,24 +620,24 @@ cursor_get_resize_edges(struct wlr_cursor *cursor, const struct cursor_context *
|
|||
}
|
||||
|
||||
bool
|
||||
cursor_process_motion(struct server *server, uint32_t time, double *sx, double *sy)
|
||||
cursor_process_motion(uint32_t time, double *sx, double *sy)
|
||||
{
|
||||
/* If the mode is non-passthrough, delegate to those functions. */
|
||||
if (server->input_mode == LAB_INPUT_STATE_MOVE) {
|
||||
process_cursor_move(server, time);
|
||||
if (g_server.input_mode == LAB_INPUT_STATE_MOVE) {
|
||||
process_cursor_move(time);
|
||||
return false;
|
||||
} else if (server->input_mode == LAB_INPUT_STATE_RESIZE) {
|
||||
process_cursor_resize(server, time);
|
||||
} else if (g_server.input_mode == LAB_INPUT_STATE_RESIZE) {
|
||||
process_cursor_resize(time);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Otherwise, find view under the pointer and send the event along */
|
||||
struct cursor_context ctx = get_cursor_context(server);
|
||||
struct seat *seat = &server->seat;
|
||||
struct cursor_context ctx = get_cursor_context();
|
||||
struct seat *seat = &g_server.seat;
|
||||
|
||||
if (ctx.type == LAB_NODE_MENUITEM) {
|
||||
menu_process_cursor_motion(ctx.node);
|
||||
cursor_set(&server->seat, LAB_CURSOR_DEFAULT);
|
||||
cursor_set(&g_server.seat, LAB_CURSOR_DEFAULT);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -659,8 +659,7 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
|
|||
* moving/resizing the wrong view
|
||||
*/
|
||||
mousebind->pressed_in_context = false;
|
||||
actions_run(seat->pressed.ctx.view, server,
|
||||
&mousebind->actions, &seat->pressed.ctx);
|
||||
actions_run(seat->pressed.ctx.view, &mousebind->actions, &seat->pressed.ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -670,7 +669,7 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
|
|||
* and the pressed view is set while out-of-surface dragging.
|
||||
*/
|
||||
struct cursor_context notified_ctx = {0};
|
||||
cursor_update_common(server, &ctx, ¬ified_ctx);
|
||||
cursor_update_common(&ctx, ¬ified_ctx);
|
||||
|
||||
if (rc.focus_follow_mouse) {
|
||||
/*
|
||||
|
|
@ -701,10 +700,10 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
|
|||
}
|
||||
|
||||
static void
|
||||
_cursor_update_focus(struct server *server)
|
||||
_cursor_update_focus(void)
|
||||
{
|
||||
/* Focus surface under cursor if it isn't already focused */
|
||||
struct cursor_context ctx = get_cursor_context(server);
|
||||
struct cursor_context ctx = get_cursor_context();
|
||||
|
||||
if ((ctx.view || ctx.surface) && rc.focus_follow_mouse
|
||||
&& !rc.focus_follow_mouse_requires_movement) {
|
||||
|
|
@ -712,21 +711,21 @@ _cursor_update_focus(struct server *server)
|
|||
* Always focus the surface below the cursor when
|
||||
* followMouse=yes and followMouseRequiresMovement=no.
|
||||
*/
|
||||
desktop_focus_view_or_surface(&server->seat, ctx.view,
|
||||
desktop_focus_view_or_surface(&g_server.seat, ctx.view,
|
||||
ctx.surface, rc.raise_on_focus);
|
||||
}
|
||||
|
||||
cursor_update_common(server, &ctx, NULL);
|
||||
cursor_update_common(&ctx, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
cursor_update_focus(struct server *server)
|
||||
cursor_update_focus(void)
|
||||
{
|
||||
/* Prevent recursion via view_move_to_front() */
|
||||
static bool updating_focus = false;
|
||||
if (!updating_focus) {
|
||||
updating_focus = true;
|
||||
_cursor_update_focus(server);
|
||||
_cursor_update_focus();
|
||||
updating_focus = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -735,7 +734,7 @@ static void
|
|||
warp_cursor_to_constraint_hint(struct seat *seat,
|
||||
struct wlr_pointer_constraint_v1 *constraint)
|
||||
{
|
||||
if (!seat->server->active_view) {
|
||||
if (!g_server.active_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -744,8 +743,8 @@ warp_cursor_to_constraint_hint(struct seat *seat,
|
|||
double sx = constraint->current.cursor_hint.x;
|
||||
double sy = constraint->current.cursor_hint.y;
|
||||
wlr_cursor_warp(seat->cursor, NULL,
|
||||
seat->server->active_view->current.x + sx,
|
||||
seat->server->active_view->current.y + sy);
|
||||
g_server.active_view->current.x + sx,
|
||||
g_server.active_view->current.y + sy);
|
||||
|
||||
/* Make sure we are not sending unnecessary surface movements */
|
||||
wlr_seat_pointer_warp(seat->seat, sx, sy);
|
||||
|
|
@ -788,26 +787,24 @@ void
|
|||
create_constraint(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_pointer_constraint_v1 *wlr_constraint = data;
|
||||
struct server *server = wl_container_of(listener, server,
|
||||
new_constraint);
|
||||
struct constraint *constraint = znew(*constraint);
|
||||
|
||||
constraint->constraint = wlr_constraint;
|
||||
constraint->seat = &server->seat;
|
||||
constraint->seat = &g_server.seat;
|
||||
constraint->destroy.notify = handle_constraint_destroy;
|
||||
wl_signal_add(&wlr_constraint->events.destroy, &constraint->destroy);
|
||||
|
||||
struct view *view = server->active_view;
|
||||
struct view *view = g_server.active_view;
|
||||
if (view && view->surface == wlr_constraint->surface) {
|
||||
constrain_cursor(server, wlr_constraint);
|
||||
constrain_cursor(wlr_constraint);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
constrain_cursor(struct server *server, struct wlr_pointer_constraint_v1
|
||||
constrain_cursor(struct wlr_pointer_constraint_v1
|
||||
*constraint)
|
||||
{
|
||||
struct seat *seat = &server->seat;
|
||||
struct seat *seat = &g_server.seat;
|
||||
if (seat->current_constraint == constraint) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -837,7 +834,7 @@ constrain_cursor(struct server *server, struct wlr_pointer_constraint_v1
|
|||
static void
|
||||
apply_constraint(struct seat *seat, struct wlr_pointer *pointer, double *x, double *y)
|
||||
{
|
||||
if (!seat->server->active_view) {
|
||||
if (!g_server.active_view) {
|
||||
return;
|
||||
}
|
||||
if (!seat->current_constraint
|
||||
|
|
@ -850,8 +847,8 @@ apply_constraint(struct seat *seat, struct wlr_pointer *pointer, double *x, doub
|
|||
double sx = seat->cursor->x;
|
||||
double sy = seat->cursor->y;
|
||||
|
||||
sx -= seat->server->active_view->current.x;
|
||||
sy -= seat->server->active_view->current.y;
|
||||
sx -= g_server.active_view->current.x;
|
||||
sy -= g_server.active_view->current.y;
|
||||
|
||||
double sx_confined, sy_confined;
|
||||
if (!wlr_region_confine(&seat->current_constraint->region, sx, sy,
|
||||
|
|
@ -892,7 +889,7 @@ preprocess_cursor_motion(struct seat *seat, struct wlr_pointer *pointer,
|
|||
*/
|
||||
wlr_cursor_move(seat->cursor, &pointer->base, dx, dy);
|
||||
double sx, sy;
|
||||
bool notify = cursor_process_motion(seat->server, time_msec, &sx, &sy);
|
||||
bool notify = cursor_process_motion(time_msec, &sx, &sy);
|
||||
if (notify) {
|
||||
wlr_seat_pointer_notify_motion(seat->seat, time_msec, sx, sy);
|
||||
}
|
||||
|
|
@ -919,7 +916,6 @@ handle_motion(struct wl_listener *listener, void *data)
|
|||
* _relative_ pointer motion event (i.e. a delta)
|
||||
*/
|
||||
struct seat *seat = wl_container_of(listener, seat, on_cursor.motion);
|
||||
struct server *server = seat->server;
|
||||
struct wlr_pointer_motion_event *event = data;
|
||||
idle_manager_notify_activity(seat->seat);
|
||||
cursor_set_visible(seat, /* visible */ true);
|
||||
|
|
@ -952,7 +948,7 @@ handle_motion(struct wl_listener *listener, void *data)
|
|||
WL_POINTER_AXIS_SOURCE_CONTINUOUS, event->time_msec);
|
||||
} else {
|
||||
wlr_relative_pointer_manager_v1_send_relative_motion(
|
||||
server->relative_pointer_manager,
|
||||
g_server.relative_pointer_manager,
|
||||
seat->seat, (uint64_t)event->time_msec * 1000,
|
||||
event->delta_x, event->delta_y, event->unaccel_dx,
|
||||
event->unaccel_dy);
|
||||
|
|
@ -990,15 +986,14 @@ handle_motion_absolute(struct wl_listener *listener, void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
process_release_mousebinding(struct server *server,
|
||||
struct cursor_context *ctx, uint32_t button)
|
||||
process_release_mousebinding(struct cursor_context *ctx, uint32_t button)
|
||||
{
|
||||
if (server->input_mode == LAB_INPUT_STATE_CYCLE) {
|
||||
if (g_server.input_mode == LAB_INPUT_STATE_CYCLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct mousebind *mousebind;
|
||||
uint32_t modifiers = keyboard_get_all_modifiers(&server->seat);
|
||||
uint32_t modifiers = keyboard_get_all_modifiers(&g_server.seat);
|
||||
|
||||
wl_list_for_each(mousebind, &rc.mousebinds, link) {
|
||||
if (ctx->type == LAB_NODE_CLIENT
|
||||
|
|
@ -1019,7 +1014,7 @@ process_release_mousebinding(struct server *server,
|
|||
default:
|
||||
continue;
|
||||
}
|
||||
actions_run(ctx->view, server, &mousebind->actions, ctx);
|
||||
actions_run(ctx->view, &mousebind->actions, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1059,17 +1054,17 @@ is_double_click(long double_click_speed, uint32_t button,
|
|||
}
|
||||
|
||||
static bool
|
||||
process_press_mousebinding(struct server *server, struct cursor_context *ctx,
|
||||
process_press_mousebinding(struct cursor_context *ctx,
|
||||
uint32_t button)
|
||||
{
|
||||
if (server->input_mode == LAB_INPUT_STATE_CYCLE) {
|
||||
if (g_server.input_mode == LAB_INPUT_STATE_CYCLE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct mousebind *mousebind;
|
||||
bool double_click = is_double_click(rc.doubleclick_time, button, ctx);
|
||||
bool consumed_by_frame_context = false;
|
||||
uint32_t modifiers = keyboard_get_all_modifiers(&server->seat);
|
||||
uint32_t modifiers = keyboard_get_all_modifiers(&g_server.seat);
|
||||
|
||||
wl_list_for_each(mousebind, &rc.mousebinds, link) {
|
||||
if (ctx->type == LAB_NODE_CLIENT
|
||||
|
|
@ -1108,7 +1103,7 @@ process_press_mousebinding(struct server *server, struct cursor_context *ctx,
|
|||
}
|
||||
consumed_by_frame_context |= mousebind->context == LAB_NODE_FRAME;
|
||||
consumed_by_frame_context |= mousebind->context == LAB_NODE_ALL;
|
||||
actions_run(ctx->view, server, &mousebind->actions, ctx);
|
||||
actions_run(ctx->view, &mousebind->actions, ctx);
|
||||
}
|
||||
}
|
||||
return consumed_by_frame_context;
|
||||
|
|
@ -1138,8 +1133,7 @@ static uint32_t press_msec;
|
|||
bool
|
||||
cursor_process_button_press(struct seat *seat, uint32_t button, uint32_t time_msec)
|
||||
{
|
||||
struct server *server = seat->server;
|
||||
struct cursor_context ctx = get_cursor_context(server);
|
||||
struct cursor_context ctx = get_cursor_context();
|
||||
|
||||
/* Used on next button release to check if it can close menu or select menu item */
|
||||
press_msec = time_msec;
|
||||
|
|
@ -1147,10 +1141,10 @@ cursor_process_button_press(struct seat *seat, uint32_t button, uint32_t time_ms
|
|||
if (ctx.view || ctx.surface) {
|
||||
/* Store cursor context for later action processing */
|
||||
cursor_context_save(&seat->pressed, &ctx);
|
||||
interactive_set_grab_context(server, &ctx);
|
||||
interactive_set_grab_context(&ctx);
|
||||
}
|
||||
|
||||
if (server->input_mode == LAB_INPUT_STATE_MENU) {
|
||||
if (g_server.input_mode == LAB_INPUT_STATE_MENU) {
|
||||
/*
|
||||
* If menu was already opened on press, set a very small value
|
||||
* so subsequent release always closes menu or selects menu item.
|
||||
|
|
@ -1195,7 +1189,7 @@ cursor_process_button_press(struct seat *seat, uint32_t button, uint32_t time_ms
|
|||
|
||||
/* Bindings to the Frame context swallow mouse events if activated */
|
||||
bool consumed_by_frame_context =
|
||||
process_press_mousebinding(server, &ctx, button);
|
||||
process_press_mousebinding(&ctx, button);
|
||||
|
||||
if (ctx.surface && !consumed_by_frame_context) {
|
||||
/* Notify client with pointer focus of button press */
|
||||
|
|
@ -1210,8 +1204,7 @@ bool
|
|||
cursor_process_button_release(struct seat *seat, uint32_t button,
|
||||
uint32_t time_msec)
|
||||
{
|
||||
struct server *server = seat->server;
|
||||
struct cursor_context ctx = get_cursor_context(server);
|
||||
struct cursor_context ctx = get_cursor_context();
|
||||
struct wlr_surface *pressed_surface = seat->pressed.ctx.surface;
|
||||
|
||||
/* Always notify button release event when it's not bound */
|
||||
|
|
@ -1219,26 +1212,26 @@ cursor_process_button_release(struct seat *seat, uint32_t button,
|
|||
|
||||
cursor_context_save(&seat->pressed, NULL);
|
||||
|
||||
if (server->input_mode == LAB_INPUT_STATE_MENU) {
|
||||
if (g_server.input_mode == LAB_INPUT_STATE_MENU) {
|
||||
/* TODO: take into account overflow of time_msec */
|
||||
if (time_msec - press_msec > rc.menu_ignore_button_release_period) {
|
||||
if (ctx.type == LAB_NODE_MENUITEM) {
|
||||
menu_call_selected_actions(server);
|
||||
menu_call_selected_actions();
|
||||
} else {
|
||||
menu_close_root(server);
|
||||
cursor_update_focus(server);
|
||||
menu_close_root();
|
||||
cursor_update_focus();
|
||||
}
|
||||
}
|
||||
return notify;
|
||||
}
|
||||
if (server->input_mode == LAB_INPUT_STATE_CYCLE) {
|
||||
if (g_server.input_mode == LAB_INPUT_STATE_CYCLE) {
|
||||
if (ctx.type == LAB_NODE_CYCLE_OSD_ITEM) {
|
||||
cycle_on_cursor_release(server, ctx.node);
|
||||
cycle_on_cursor_release(ctx.node);
|
||||
}
|
||||
return notify;
|
||||
}
|
||||
|
||||
if (server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
if (g_server.input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
return notify;
|
||||
}
|
||||
|
||||
|
|
@ -1250,7 +1243,7 @@ cursor_process_button_release(struct seat *seat, uint32_t button,
|
|||
return notify;
|
||||
}
|
||||
|
||||
process_release_mousebinding(server, &ctx, button);
|
||||
process_release_mousebinding(&ctx, button);
|
||||
|
||||
return notify;
|
||||
}
|
||||
|
|
@ -1258,8 +1251,6 @@ cursor_process_button_release(struct seat *seat, uint32_t button,
|
|||
bool
|
||||
cursor_finish_button_release(struct seat *seat, uint32_t button)
|
||||
{
|
||||
struct server *server = seat->server;
|
||||
|
||||
/* Clear "pressed" status for all bindings of this mouse button */
|
||||
struct mousebind *mousebind;
|
||||
wl_list_for_each(mousebind, &rc.mousebinds, link) {
|
||||
|
|
@ -1270,17 +1261,17 @@ cursor_finish_button_release(struct seat *seat, uint32_t button)
|
|||
|
||||
lab_set_remove(&seat->bound_buttons, button);
|
||||
|
||||
if (server->input_mode == LAB_INPUT_STATE_MOVE
|
||||
|| server->input_mode == LAB_INPUT_STATE_RESIZE) {
|
||||
if (resize_outlines_enabled(server->grabbed_view)) {
|
||||
resize_outlines_finish(server->grabbed_view);
|
||||
if (g_server.input_mode == LAB_INPUT_STATE_MOVE
|
||||
|| g_server.input_mode == LAB_INPUT_STATE_RESIZE) {
|
||||
if (resize_outlines_enabled(g_server.grabbed_view)) {
|
||||
resize_outlines_finish(g_server.grabbed_view);
|
||||
}
|
||||
/* Exit interactive move/resize mode */
|
||||
interactive_finish(server->grabbed_view);
|
||||
interactive_finish(g_server.grabbed_view);
|
||||
return true;
|
||||
} else if (server->grabbed_view) {
|
||||
} else if (g_server.grabbed_view) {
|
||||
/* Button was released without starting move/resize */
|
||||
interactive_cancel(server->grabbed_view);
|
||||
interactive_cancel(g_server.grabbed_view);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -1370,15 +1361,15 @@ compare_delta(double delta, double delta_discrete, struct accumulated_scroll *ac
|
|||
}
|
||||
|
||||
static bool
|
||||
process_cursor_axis(struct server *server, enum wl_pointer_axis orientation,
|
||||
process_cursor_axis(enum wl_pointer_axis orientation,
|
||||
double delta, double delta_discrete)
|
||||
{
|
||||
struct cursor_context ctx = get_cursor_context(server);
|
||||
uint32_t modifiers = keyboard_get_all_modifiers(&server->seat);
|
||||
struct cursor_context ctx = get_cursor_context();
|
||||
uint32_t modifiers = keyboard_get_all_modifiers(&g_server.seat);
|
||||
|
||||
enum direction direction = LAB_DIRECTION_INVALID;
|
||||
struct scroll_info info = compare_delta(delta, delta_discrete,
|
||||
&server->seat.accumulated_scrolls[orientation]);
|
||||
&g_server.seat.accumulated_scrolls[orientation]);
|
||||
|
||||
if (orientation == WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
|
||||
if (info.direction < 0) {
|
||||
|
|
@ -1415,7 +1406,7 @@ process_cursor_axis(struct server *server, enum wl_pointer_axis orientation,
|
|||
* on touchpads or hi-res mice doesn't exceed the threshold
|
||||
*/
|
||||
if (info.run_action) {
|
||||
actions_run(ctx.view, server, &mousebind->actions, &ctx);
|
||||
actions_run(ctx.view, &mousebind->actions, &ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1424,7 +1415,7 @@ process_cursor_axis(struct server *server, enum wl_pointer_axis orientation,
|
|||
/* Bindings swallow mouse events if activated */
|
||||
if (ctx.surface && !consumed) {
|
||||
/* Make sure we are sending the events to the surface under the cursor */
|
||||
cursor_update_common(server, &ctx, NULL);
|
||||
cursor_update_common(&ctx, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1440,7 +1431,6 @@ handle_axis(struct wl_listener *listener, void *data)
|
|||
* event, for example when you move the scroll wheel.
|
||||
*/
|
||||
struct seat *seat = wl_container_of(listener, seat, on_cursor.axis);
|
||||
struct server *server = seat->server;
|
||||
struct wlr_pointer_axis_event *event = data;
|
||||
idle_manager_notify_activity(seat->seat);
|
||||
cursor_set_visible(seat, /* visible */ true);
|
||||
|
|
@ -1451,7 +1441,7 @@ handle_axis(struct wl_listener *listener, void *data)
|
|||
struct input *input = event->pointer->base.data;
|
||||
double scroll_factor = input->scroll_factor;
|
||||
|
||||
bool notify = process_cursor_axis(server, event->orientation,
|
||||
bool notify = process_cursor_axis(event->orientation,
|
||||
event->delta, event->delta_discrete);
|
||||
|
||||
if (notify) {
|
||||
|
|
@ -1483,7 +1473,6 @@ cursor_emulate_axis(struct seat *seat, struct wlr_input_device *device,
|
|||
enum wl_pointer_axis orientation, double delta, double delta_discrete,
|
||||
enum wl_pointer_axis_source source, uint32_t time_msec)
|
||||
{
|
||||
struct server *server = seat->server;
|
||||
struct input *input = device->data;
|
||||
|
||||
double scroll_factor = 1.0;
|
||||
|
|
@ -1493,7 +1482,7 @@ cursor_emulate_axis(struct seat *seat, struct wlr_input_device *device,
|
|||
scroll_factor = input->scroll_factor;
|
||||
}
|
||||
|
||||
bool notify = process_cursor_axis(server, orientation, delta, delta_discrete);
|
||||
bool notify = process_cursor_axis(orientation, delta, delta_discrete);
|
||||
if (notify) {
|
||||
/* Notify the client with pointer focus of the axis event. */
|
||||
wlr_seat_pointer_notify_axis(seat->seat, time_msec,
|
||||
|
|
@ -1514,13 +1503,13 @@ cursor_emulate_move(struct seat *seat, struct wlr_input_device *device,
|
|||
}
|
||||
|
||||
wlr_relative_pointer_manager_v1_send_relative_motion(
|
||||
seat->server->relative_pointer_manager,
|
||||
g_server.relative_pointer_manager,
|
||||
seat->seat, (uint64_t)time_msec * 1000,
|
||||
dx, dy, dx, dy);
|
||||
|
||||
wlr_cursor_move(seat->cursor, device, dx, dy);
|
||||
double sx, sy;
|
||||
bool notify = cursor_process_motion(seat->server, time_msec, &sx, &sy);
|
||||
bool notify = cursor_process_motion(time_msec, &sx, &sy);
|
||||
if (notify) {
|
||||
wlr_seat_pointer_notify_motion(seat->seat, time_msec, sx, sy);
|
||||
}
|
||||
|
|
@ -1615,7 +1604,7 @@ cursor_reload(struct seat *seat)
|
|||
{
|
||||
cursor_load(seat);
|
||||
#if HAVE_XWAYLAND
|
||||
xwayland_reset_cursor(seat->server);
|
||||
xwayland_reset_cursor();
|
||||
#endif
|
||||
cursor_update_image(seat);
|
||||
}
|
||||
|
|
@ -1643,7 +1632,7 @@ cursor_init(struct seat *seat)
|
|||
CONNECT_SIGNAL(seat->seat, seat, request_set_cursor);
|
||||
|
||||
struct wlr_cursor_shape_manager_v1 *cursor_shape_manager =
|
||||
wlr_cursor_shape_manager_v1_create(seat->server->wl_display,
|
||||
wlr_cursor_shape_manager_v1_create(g_server.wl_display,
|
||||
LAB_CURSOR_SHAPE_V1_VERSION);
|
||||
if (!cursor_shape_manager) {
|
||||
wlr_log(WLR_ERROR, "unable to create cursor_shape interface");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue