mirror of
https://github.com/labwc/labwc.git
synced 2026-03-24 09:06:09 -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");
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ handle_hold_end(struct wl_listener *listener, void *data)
|
|||
void
|
||||
gestures_init(struct seat *seat)
|
||||
{
|
||||
seat->pointer_gestures = wlr_pointer_gestures_v1_create(seat->server->wl_display);
|
||||
seat->pointer_gestures = wlr_pointer_gestures_v1_create(g_server.wl_display);
|
||||
|
||||
CONNECT_SIGNAL(seat->cursor, seat, pinch_begin);
|
||||
CONNECT_SIGNAL(seat->cursor, seat, pinch_update);
|
||||
|
|
|
|||
|
|
@ -179,7 +179,6 @@ static void
|
|||
update_popup_position(struct input_method_popup *popup)
|
||||
{
|
||||
struct input_method_relay *relay = popup->relay;
|
||||
struct server *server = relay->seat->server;
|
||||
struct text_input *text_input = relay->active_text_input;
|
||||
|
||||
if (!text_input || !relay->focused_surface
|
||||
|
|
@ -220,7 +219,7 @@ update_popup_position(struct input_method_popup *popup)
|
|||
}
|
||||
|
||||
struct output *output =
|
||||
output_nearest_to(server, cursor_rect.x, cursor_rect.y);
|
||||
output_nearest_to(cursor_rect.x, cursor_rect.y);
|
||||
if (!output_is_usable(output)) {
|
||||
wlr_log(WLR_ERROR,
|
||||
"Cannot position IME popup (unusable output)");
|
||||
|
|
@ -228,7 +227,7 @@ update_popup_position(struct input_method_popup *popup)
|
|||
}
|
||||
struct wlr_box output_box;
|
||||
wlr_output_layout_get_box(
|
||||
server->output_layout, output->wlr_output, &output_box);
|
||||
g_server.output_layout, output->wlr_output, &output_box);
|
||||
|
||||
/* Use xdg-positioner utilities to position popup */
|
||||
struct wlr_xdg_positioner_rules rules = {
|
||||
|
|
@ -583,14 +582,14 @@ input_method_relay_create(struct seat *seat)
|
|||
relay->seat = seat;
|
||||
wl_list_init(&relay->text_inputs);
|
||||
wl_list_init(&relay->popups);
|
||||
relay->popup_tree = lab_wlr_scene_tree_create(&seat->server->scene->tree);
|
||||
relay->popup_tree = lab_wlr_scene_tree_create(&g_server.scene->tree);
|
||||
|
||||
relay->new_text_input.notify = handle_new_text_input;
|
||||
wl_signal_add(&seat->server->text_input_manager->events.text_input,
|
||||
wl_signal_add(&g_server.text_input_manager->events.text_input,
|
||||
&relay->new_text_input);
|
||||
|
||||
relay->new_input_method.notify = handle_new_input_method;
|
||||
wl_signal_add(&seat->server->input_method_manager->events.input_method,
|
||||
wl_signal_add(&g_server.input_method_manager->events.input_method,
|
||||
&relay->new_input_method);
|
||||
|
||||
relay->focused_surface_destroy.notify = handle_focused_surface_destroy;
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ keyboard_reset_current_keybind(void)
|
|||
}
|
||||
|
||||
static void
|
||||
change_vt(struct server *server, unsigned int vt)
|
||||
change_vt(unsigned int vt)
|
||||
{
|
||||
wlr_session_change_vt(server->session, vt);
|
||||
wlr_session_change_vt(g_server.session, vt);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
|
@ -131,17 +131,16 @@ handle_modifiers(struct wl_listener *listener, void *data)
|
|||
{
|
||||
struct keyboard *keyboard = wl_container_of(listener, keyboard, modifiers);
|
||||
struct seat *seat = keyboard->base.seat;
|
||||
struct server *server = seat->server;
|
||||
struct wlr_keyboard *wlr_keyboard = keyboard->wlr_keyboard;
|
||||
|
||||
if (server->input_mode == LAB_INPUT_STATE_MOVE) {
|
||||
if (g_server.input_mode == LAB_INPUT_STATE_MOVE) {
|
||||
/* Any change to the modifier state re-enable region snap */
|
||||
seat->region_prevent_snap = false;
|
||||
/* Pressing/releasing modifier key may show/hide region overlay */
|
||||
overlay_update(seat);
|
||||
}
|
||||
|
||||
bool cycling = server->input_mode == LAB_INPUT_STATE_CYCLE;
|
||||
bool cycling = g_server.input_mode == LAB_INPUT_STATE_CYCLE;
|
||||
|
||||
if ((cycling || seat->workspace_osd_shown_by_modifier)
|
||||
&& !keyboard_get_all_modifiers(seat)) {
|
||||
|
|
@ -150,7 +149,7 @@ handle_modifiers(struct wl_listener *listener, void *data)
|
|||
should_cancel_cycling_on_next_key_release = true;
|
||||
} else {
|
||||
should_cancel_cycling_on_next_key_release = false;
|
||||
cycle_finish(server, /*switch_focus*/ true);
|
||||
cycle_finish(/*switch_focus*/ true);
|
||||
}
|
||||
}
|
||||
if (seat->workspace_osd_shown_by_modifier) {
|
||||
|
|
@ -188,7 +187,7 @@ handle_modifiers(struct wl_listener *listener, void *data)
|
|||
}
|
||||
|
||||
static struct keybind *
|
||||
match_keybinding_for_sym(struct server *server, uint32_t modifiers,
|
||||
match_keybinding_for_sym(uint32_t modifiers,
|
||||
xkb_keysym_t sym, xkb_keycode_t xkb_keycode)
|
||||
{
|
||||
struct keybind *keybind;
|
||||
|
|
@ -196,7 +195,7 @@ match_keybinding_for_sym(struct server *server, uint32_t modifiers,
|
|||
if (modifiers ^ keybind->modifiers) {
|
||||
continue;
|
||||
}
|
||||
if (view_inhibits_actions(server->active_view, &keybind->actions)) {
|
||||
if (view_inhibits_actions(g_server.active_view, &keybind->actions)) {
|
||||
continue;
|
||||
}
|
||||
if (sym == XKB_KEY_NoSymbol) {
|
||||
|
|
@ -241,13 +240,12 @@ match_keybinding_for_sym(struct server *server, uint32_t modifiers,
|
|||
* the raw keysym fallback.
|
||||
*/
|
||||
static struct keybind *
|
||||
match_keybinding(struct server *server, struct keyinfo *keyinfo,
|
||||
match_keybinding(struct keyinfo *keyinfo,
|
||||
bool is_virtual)
|
||||
{
|
||||
if (!is_virtual) {
|
||||
/* First try keycodes */
|
||||
struct keybind *keybind = match_keybinding_for_sym(server,
|
||||
keyinfo->modifiers, XKB_KEY_NoSymbol, keyinfo->xkb_keycode);
|
||||
struct keybind *keybind = match_keybinding_for_sym(keyinfo->modifiers, XKB_KEY_NoSymbol, keyinfo->xkb_keycode);
|
||||
if (keybind) {
|
||||
wlr_log(WLR_DEBUG, "keycode matched");
|
||||
return keybind;
|
||||
|
|
@ -257,7 +255,7 @@ match_keybinding(struct server *server, struct keyinfo *keyinfo,
|
|||
/* Then fall back to keysyms */
|
||||
for (int i = 0; i < keyinfo->translated.nr_syms; i++) {
|
||||
struct keybind *keybind =
|
||||
match_keybinding_for_sym(server, keyinfo->modifiers,
|
||||
match_keybinding_for_sym(keyinfo->modifiers,
|
||||
keyinfo->translated.syms[i], keyinfo->xkb_keycode);
|
||||
if (keybind) {
|
||||
wlr_log(WLR_DEBUG, "translated keysym matched");
|
||||
|
|
@ -268,7 +266,7 @@ match_keybinding(struct server *server, struct keyinfo *keyinfo,
|
|||
/* And finally test for keysyms without modifier */
|
||||
for (int i = 0; i < keyinfo->raw.nr_syms; i++) {
|
||||
struct keybind *keybind =
|
||||
match_keybinding_for_sym(server, keyinfo->modifiers,
|
||||
match_keybinding_for_sym(keyinfo->modifiers,
|
||||
keyinfo->raw.syms[i], keyinfo->xkb_keycode);
|
||||
if (keybind) {
|
||||
wlr_log(WLR_DEBUG, "raw keysym matched");
|
||||
|
|
@ -366,7 +364,7 @@ get_keyinfo(struct wlr_keyboard *wlr_keyboard, uint32_t evdev_keycode)
|
|||
}
|
||||
|
||||
static enum lab_key_handled
|
||||
handle_key_release(struct server *server, uint32_t evdev_keycode)
|
||||
handle_key_release(uint32_t evdev_keycode)
|
||||
{
|
||||
/*
|
||||
* Release events for keys that were not bound should always be
|
||||
|
|
@ -387,7 +385,7 @@ handle_key_release(struct server *server, uint32_t evdev_keycode)
|
|||
*/
|
||||
if (should_cancel_cycling_on_next_key_release) {
|
||||
should_cancel_cycling_on_next_key_release = false;
|
||||
cycle_finish(server, /*switch_focus*/ true);
|
||||
cycle_finish(/*switch_focus*/ true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -399,7 +397,7 @@ handle_key_release(struct server *server, uint32_t evdev_keycode)
|
|||
}
|
||||
|
||||
static bool
|
||||
handle_change_vt_key(struct server *server, struct keyboard *keyboard,
|
||||
handle_change_vt_key(struct keyboard *keyboard,
|
||||
struct keysyms *translated)
|
||||
{
|
||||
for (int i = 0; i < translated->nr_syms; i++) {
|
||||
|
|
@ -407,7 +405,7 @@ handle_change_vt_key(struct server *server, struct keyboard *keyboard,
|
|||
translated->syms[i] - XKB_KEY_XF86Switch_VT_1 + 1;
|
||||
if (vt >= 1 && vt <= 12) {
|
||||
keyboard_cancel_keybind_repeat(keyboard);
|
||||
change_vt(server, vt);
|
||||
change_vt(vt);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -415,31 +413,31 @@ handle_change_vt_key(struct server *server, struct keyboard *keyboard,
|
|||
}
|
||||
|
||||
static void
|
||||
handle_menu_keys(struct server *server, struct keysyms *syms)
|
||||
handle_menu_keys(struct keysyms *syms)
|
||||
{
|
||||
assert(server->input_mode == LAB_INPUT_STATE_MENU);
|
||||
assert(g_server.input_mode == LAB_INPUT_STATE_MENU);
|
||||
|
||||
for (int i = 0; i < syms->nr_syms; i++) {
|
||||
switch (syms->syms[i]) {
|
||||
case XKB_KEY_Down:
|
||||
menu_item_select_next(server);
|
||||
menu_item_select_next();
|
||||
break;
|
||||
case XKB_KEY_Up:
|
||||
menu_item_select_previous(server);
|
||||
menu_item_select_previous();
|
||||
break;
|
||||
case XKB_KEY_Right:
|
||||
menu_submenu_enter(server);
|
||||
menu_submenu_enter();
|
||||
break;
|
||||
case XKB_KEY_Left:
|
||||
menu_submenu_leave(server);
|
||||
menu_submenu_leave();
|
||||
break;
|
||||
case XKB_KEY_Return:
|
||||
case XKB_KEY_KP_Enter:
|
||||
menu_call_selected_actions(server);
|
||||
menu_call_selected_actions();
|
||||
break;
|
||||
case XKB_KEY_Escape:
|
||||
menu_close_root(server);
|
||||
cursor_update_focus(server);
|
||||
menu_close_root();
|
||||
cursor_update_focus();
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
|
|
@ -450,7 +448,7 @@ handle_menu_keys(struct server *server, struct keysyms *syms)
|
|||
|
||||
/* Returns true if the keystroke is consumed */
|
||||
static bool
|
||||
handle_cycle_view_key(struct server *server, struct keyinfo *keyinfo)
|
||||
handle_cycle_view_key(struct keyinfo *keyinfo)
|
||||
{
|
||||
if (keyinfo->is_modifier) {
|
||||
return false;
|
||||
|
|
@ -460,19 +458,19 @@ handle_cycle_view_key(struct server *server, struct keyinfo *keyinfo)
|
|||
for (int i = 0; i < keyinfo->translated.nr_syms; i++) {
|
||||
if (keyinfo->translated.syms[i] == XKB_KEY_Escape) {
|
||||
/* Esc deactivates window switcher */
|
||||
cycle_finish(server, /*switch_focus*/ false);
|
||||
cycle_finish(/*switch_focus*/ false);
|
||||
return true;
|
||||
}
|
||||
if (keyinfo->translated.syms[i] == XKB_KEY_Up
|
||||
|| keyinfo->translated.syms[i] == XKB_KEY_Left) {
|
||||
/* Up/Left cycles the window backward */
|
||||
cycle_step(server, LAB_CYCLE_DIR_BACKWARD);
|
||||
cycle_step(LAB_CYCLE_DIR_BACKWARD);
|
||||
return true;
|
||||
}
|
||||
if (keyinfo->translated.syms[i] == XKB_KEY_Down
|
||||
|| keyinfo->translated.syms[i] == XKB_KEY_Right) {
|
||||
/* Down/Right cycles the window forward */
|
||||
cycle_step(server, LAB_CYCLE_DIR_FORWARD);
|
||||
cycle_step(LAB_CYCLE_DIR_FORWARD);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -483,10 +481,9 @@ static enum lab_key_handled
|
|||
handle_compositor_keybindings(struct keyboard *keyboard,
|
||||
struct wlr_keyboard_key_event *event)
|
||||
{
|
||||
struct server *server = &g_server;
|
||||
struct wlr_keyboard *wlr_keyboard = keyboard->wlr_keyboard;
|
||||
struct keyinfo keyinfo = get_keyinfo(wlr_keyboard, event->keycode);
|
||||
bool locked = server->session_lock_manager->locked;
|
||||
bool locked = g_server.session_lock_manager->locked;
|
||||
|
||||
key_state_set_pressed(event->keycode,
|
||||
event->state == WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||
|
|
@ -498,15 +495,15 @@ handle_compositor_keybindings(struct keyboard *keyboard,
|
|||
cur_keybind = NULL;
|
||||
return LAB_KEY_HANDLED_TRUE;
|
||||
}
|
||||
actions_run(NULL, server, &cur_keybind->actions, NULL);
|
||||
actions_run(NULL, &cur_keybind->actions, NULL);
|
||||
return LAB_KEY_HANDLED_TRUE;
|
||||
} else {
|
||||
return handle_key_release(server, event->keycode);
|
||||
return handle_key_release(event->keycode);
|
||||
}
|
||||
}
|
||||
|
||||
/* Catch C-A-F1 to C-A-F12 to change tty */
|
||||
if (handle_change_vt_key(server, keyboard, &keyinfo.translated)) {
|
||||
if (handle_change_vt_key(keyboard, &keyinfo.translated)) {
|
||||
key_state_store_pressed_key_as_bound(event->keycode);
|
||||
return LAB_KEY_HANDLED_TRUE_AND_VT_CHANGED;
|
||||
}
|
||||
|
|
@ -517,12 +514,12 @@ handle_compositor_keybindings(struct keyboard *keyboard,
|
|||
* _all_ key press/releases are registered
|
||||
*/
|
||||
if (!locked) {
|
||||
if (server->input_mode == LAB_INPUT_STATE_MENU) {
|
||||
if (g_server.input_mode == LAB_INPUT_STATE_MENU) {
|
||||
key_state_store_pressed_key_as_bound(event->keycode);
|
||||
handle_menu_keys(server, &keyinfo.translated);
|
||||
handle_menu_keys(&keyinfo.translated);
|
||||
return LAB_KEY_HANDLED_TRUE;
|
||||
} else if (server->input_mode == LAB_INPUT_STATE_CYCLE) {
|
||||
if (handle_cycle_view_key(server, &keyinfo)) {
|
||||
} else if (g_server.input_mode == LAB_INPUT_STATE_CYCLE) {
|
||||
if (handle_cycle_view_key(&keyinfo)) {
|
||||
key_state_store_pressed_key_as_bound(event->keycode);
|
||||
return LAB_KEY_HANDLED_TRUE;
|
||||
}
|
||||
|
|
@ -532,7 +529,7 @@ handle_compositor_keybindings(struct keyboard *keyboard,
|
|||
/*
|
||||
* Handle compositor keybinds
|
||||
*/
|
||||
cur_keybind = match_keybinding(server, &keyinfo, keyboard->is_virtual);
|
||||
cur_keybind = match_keybinding(&keyinfo, keyboard->is_virtual);
|
||||
if (cur_keybind && (!locked || cur_keybind->allow_when_locked)) {
|
||||
/*
|
||||
* Update key-state before action_run() because the action
|
||||
|
|
@ -541,7 +538,7 @@ handle_compositor_keybindings(struct keyboard *keyboard,
|
|||
*/
|
||||
key_state_store_pressed_key_as_bound(event->keycode);
|
||||
if (!cur_keybind->on_release) {
|
||||
actions_run(NULL, server, &cur_keybind->actions, NULL);
|
||||
actions_run(NULL, &cur_keybind->actions, NULL);
|
||||
}
|
||||
return LAB_KEY_HANDLED_TRUE;
|
||||
}
|
||||
|
|
@ -571,7 +568,7 @@ handle_keybind_repeat(void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
start_keybind_repeat(struct server *server, struct keyboard *keyboard,
|
||||
start_keybind_repeat(struct keyboard *keyboard,
|
||||
struct wlr_keyboard_key_event *event)
|
||||
{
|
||||
struct wlr_keyboard *wlr_keyboard = keyboard->wlr_keyboard;
|
||||
|
|
@ -582,7 +579,7 @@ start_keybind_repeat(struct server *server, struct keyboard *keyboard,
|
|||
keyboard->keybind_repeat_keycode = event->keycode;
|
||||
keyboard->keybind_repeat_rate = wlr_keyboard->repeat_info.rate;
|
||||
keyboard->keybind_repeat = wl_event_loop_add_timer(
|
||||
server->wl_event_loop, handle_keybind_repeat, keyboard);
|
||||
g_server.wl_event_loop, handle_keybind_repeat, keyboard);
|
||||
wl_event_source_timer_update(keyboard->keybind_repeat,
|
||||
wlr_keyboard->repeat_info.delay);
|
||||
}
|
||||
|
|
@ -638,7 +635,7 @@ handle_key(struct wl_listener *listener, void *data)
|
|||
*/
|
||||
if (!is_modifier(keyboard->wlr_keyboard, event->keycode)
|
||||
&& event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||
start_keybind_repeat(seat->server, keyboard, event);
|
||||
start_keybind_repeat(keyboard, event);
|
||||
}
|
||||
} else if (!input_method_keyboard_grab_forward_key(keyboard, event)) {
|
||||
wlr_seat_set_keyboard(wlr_seat, keyboard->wlr_keyboard);
|
||||
|
|
@ -714,7 +711,7 @@ keyboard_update_layout(struct seat *seat, xkb_layout_index_t layout)
|
|||
}
|
||||
|
||||
static void
|
||||
reset_window_keyboard_layout_groups(struct server *server)
|
||||
reset_window_keyboard_layout_groups(void)
|
||||
{
|
||||
if (!rc.kb_layout_per_window) {
|
||||
return;
|
||||
|
|
@ -726,15 +723,15 @@ reset_window_keyboard_layout_groups(struct server *server)
|
|||
* but let's keep it simple for now and just reset them all.
|
||||
*/
|
||||
struct view *view;
|
||||
for_each_view(view, &server->views, LAB_VIEW_CRITERIA_NONE) {
|
||||
for_each_view(view, &g_server.views, LAB_VIEW_CRITERIA_NONE) {
|
||||
view->keyboard_layout = 0;
|
||||
}
|
||||
|
||||
struct view *active_view = server->active_view;
|
||||
struct view *active_view = g_server.active_view;
|
||||
if (!active_view) {
|
||||
return;
|
||||
}
|
||||
keyboard_update_layout(&server->seat, active_view->keyboard_layout);
|
||||
keyboard_update_layout(&g_server.seat, active_view->keyboard_layout);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -742,7 +739,7 @@ reset_window_keyboard_layout_groups(struct server *server)
|
|||
* XKB_DEFAULT_OPTIONS, and friends.
|
||||
*/
|
||||
static void
|
||||
set_layout(struct server *server, struct wlr_keyboard *kb)
|
||||
set_layout(struct wlr_keyboard *kb)
|
||||
{
|
||||
static bool fallback_mode;
|
||||
|
||||
|
|
@ -761,7 +758,7 @@ set_layout(struct server *server, struct wlr_keyboard *kb)
|
|||
if (keymap && !layout_empty) {
|
||||
if (!wlr_keyboard_keymaps_match(kb->keymap, keymap)) {
|
||||
wlr_keyboard_set_keymap(kb, keymap);
|
||||
reset_window_keyboard_layout_groups(server);
|
||||
reset_window_keyboard_layout_groups();
|
||||
}
|
||||
xkb_keymap_unref(keymap);
|
||||
} else {
|
||||
|
|
@ -771,7 +768,7 @@ set_layout(struct server *server, struct wlr_keyboard *kb)
|
|||
wlr_log(WLR_ERROR, "entering fallback mode with layout 'us'");
|
||||
fallback_mode = true;
|
||||
setenv("XKB_DEFAULT_LAYOUT", "us", 1);
|
||||
set_layout(server, kb);
|
||||
set_layout(kb);
|
||||
}
|
||||
}
|
||||
xkb_context_unref(context);
|
||||
|
|
@ -781,10 +778,10 @@ void
|
|||
keyboard_configure(struct seat *seat, struct wlr_keyboard *kb, bool is_virtual)
|
||||
{
|
||||
if (!is_virtual) {
|
||||
set_layout(seat->server, kb);
|
||||
set_layout(kb);
|
||||
}
|
||||
wlr_keyboard_set_repeat_info(kb, rc.repeat_rate, rc.repeat_delay);
|
||||
keybind_update_keycodes(seat->server);
|
||||
keybind_update_keycodes();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -183,9 +183,9 @@ tablet_pad_create(struct seat *seat, struct wlr_input_device *wlr_device)
|
|||
pad->seat = seat;
|
||||
pad->wlr_input_device = wlr_device;
|
||||
pad->pad = wlr_tablet_pad_from_input_device(wlr_device);
|
||||
if (seat->server->tablet_manager) {
|
||||
if (g_server.tablet_manager) {
|
||||
pad->pad_v2 = wlr_tablet_pad_create(
|
||||
seat->server->tablet_manager, seat->seat, wlr_device);
|
||||
g_server.tablet_manager, seat->seat, wlr_device);
|
||||
}
|
||||
pad->pad->data = pad;
|
||||
wlr_log(WLR_INFO, "tablet pad capabilities: %zu button(s) %zu strip(s) %zu ring(s)",
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ handle_set_cursor(struct wl_listener *listener, void *data)
|
|||
struct wlr_seat_client *focused_client =
|
||||
seat->seat->pointer_state.focused_client;
|
||||
|
||||
if (seat->server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
if (g_server.input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ tablet_tool_create(struct seat *seat,
|
|||
struct drawing_tablet_tool *tool = znew(*tool);
|
||||
tool->seat = seat;
|
||||
tool->tool_v2 =
|
||||
wlr_tablet_tool_create(seat->server->tablet_manager,
|
||||
wlr_tablet_tool_create(g_server.tablet_manager,
|
||||
seat->seat, wlr_tablet_tool);
|
||||
wlr_tablet_tool->data = tool;
|
||||
wlr_log(WLR_INFO, "tablet tool capabilities:%s%s%s%s%s%s",
|
||||
|
|
@ -239,7 +239,7 @@ tablet_get_coords(struct drawing_tablet *tablet, struct drawing_tablet_tool *too
|
|||
|
||||
double sx, sy;
|
||||
struct wlr_scene_node *node =
|
||||
wlr_scene_node_at(&tablet->seat->server->scene->tree.node, lx, ly, &sx, &sy);
|
||||
wlr_scene_node_at(&g_server.scene->tree.node, lx, ly, &sx, &sy);
|
||||
|
||||
/* find the surface and return it if it accepts tablet events */
|
||||
struct wlr_surface *surface = lab_wlr_surface_from_node(node);
|
||||
|
|
@ -275,7 +275,7 @@ notify_motion(struct drawing_tablet *tablet, struct drawing_tablet_tool *tool,
|
|||
}
|
||||
|
||||
double sx, sy;
|
||||
bool notify = cursor_process_motion(tablet->seat->server, time, &sx, &sy);
|
||||
bool notify = cursor_process_motion(time, &sx, &sy);
|
||||
if (notify) {
|
||||
wlr_tablet_v2_tablet_tool_notify_motion(tool->tool_v2, sx, sy);
|
||||
if (enter_surface) {
|
||||
|
|
@ -449,7 +449,7 @@ handle_tablet_tool_axis(struct wl_listener *listener, void *data)
|
|||
* Note that surface is also NULL when mouse emulation is forced.
|
||||
*/
|
||||
if (!is_down_mouse_emulation && ((surface
|
||||
&& tablet->seat->server->input_mode == LAB_INPUT_STATE_PASSTHROUGH)
|
||||
&& g_server.input_mode == LAB_INPUT_STATE_PASSTHROUGH)
|
||||
|| wlr_tablet_tool_v2_has_implicit_grab(tool->tool_v2))) {
|
||||
/* motion seems to be supported by all tools */
|
||||
notify_motion(tablet, tool, surface, x, y, dx, dy, ev->time_msec);
|
||||
|
|
@ -667,8 +667,7 @@ handle_tablet_tool_button(struct wl_listener *listener, void *data)
|
|||
if (mousebind->mouse_event == MOUSE_ACTION_PRESS
|
||||
&& mousebind->button == button
|
||||
&& mousebind->context == LAB_NODE_CLIENT) {
|
||||
actions_run(view, tool->seat->server,
|
||||
&mousebind->actions, NULL);
|
||||
actions_run(view, &mousebind->actions, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -720,9 +719,9 @@ tablet_create(struct seat *seat, struct wlr_input_device *wlr_device)
|
|||
tablet->wlr_input_device = wlr_device;
|
||||
tablet->tablet = wlr_tablet_from_input_device(wlr_device);
|
||||
tablet->tablet->data = tablet;
|
||||
if (seat->server->tablet_manager) {
|
||||
if (g_server.tablet_manager) {
|
||||
tablet->tablet_v2 = wlr_tablet_create(
|
||||
seat->server->tablet_manager, seat->seat, wlr_device);
|
||||
g_server.tablet_manager, seat->seat, wlr_device);
|
||||
}
|
||||
wlr_log(WLR_INFO, "tablet dimensions: %.2fmm x %.2fmm",
|
||||
tablet->tablet->width_mm, tablet->tablet->height_mm);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ touch_get_coords(struct seat *seat, struct wlr_touch *touch, double x, double y,
|
|||
* This matches normal pointer/mouse behavior where the first click on
|
||||
* a surface closes a root/client menu.
|
||||
*/
|
||||
if (seat->server->input_mode == LAB_INPUT_STATE_MENU) {
|
||||
if (g_server.input_mode == LAB_INPUT_STATE_MENU) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ touch_get_coords(struct seat *seat, struct wlr_touch *touch, double x, double y,
|
|||
|
||||
double sx, sy;
|
||||
struct wlr_scene_node *node =
|
||||
wlr_scene_node_at(&seat->server->scene->tree.node, lx, ly, &sx, &sy);
|
||||
wlr_scene_node_at(&g_server.scene->tree.node, lx, ly, &sx, &sy);
|
||||
|
||||
*x_offset = lx - sx;
|
||||
*y_offset = ly - sy;
|
||||
|
|
@ -169,7 +169,7 @@ handle_touch_down(struct wl_listener *listener, void *data)
|
|||
if (mousebind->mouse_event == MOUSE_ACTION_PRESS
|
||||
&& mousebind->button == BTN_LEFT
|
||||
&& mousebind->context == LAB_NODE_CLIENT) {
|
||||
actions_run(view, seat->server, &mousebind->actions, NULL);
|
||||
actions_run(view, &mousebind->actions, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ handle_touch_up(struct wl_listener *listener, void *data)
|
|||
} else {
|
||||
cursor_emulate_button(seat, BTN_LEFT,
|
||||
WL_POINTER_BUTTON_STATE_RELEASED, event->time_msec);
|
||||
ssd_update_hovered_button(seat->server, NULL);
|
||||
ssd_update_hovered_button(NULL);
|
||||
}
|
||||
wl_list_remove(&touch_point->link);
|
||||
zfree(touch_point);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue