common: add node-type.c/h (renaming ssd_part_type to lab_node_type)

ssd_part_type contains several node types that are not actually part of
server-side decorations (ROOT, MENU, OSD, etc.)

Rename it accordingly and move it to a common location, along with some
related conversion/comparison functions.
This commit is contained in:
John Lindgren 2025-09-03 05:08:52 -04:00
parent 502473f343
commit 1188534876
28 changed files with 345 additions and 315 deletions

View file

@ -113,9 +113,9 @@ cursor_get_from_edge(enum lab_edge resize_edges)
}
static enum lab_cursors
cursor_get_from_ssd(enum ssd_part_type view_area)
cursor_get_from_ssd(enum lab_node_type view_area)
{
enum lab_edge resize_edges = ssd_resize_edges(view_area);
enum lab_edge resize_edges = node_type_to_edges(view_area);
return cursor_get_from_edge(resize_edges);
}
@ -580,7 +580,7 @@ cursor_update_common(struct server *server, struct cursor_context *ctx,
enum lab_edge
cursor_get_resize_edges(struct wlr_cursor *cursor, struct cursor_context *ctx)
{
enum lab_edge resize_edges = ssd_resize_edges(ctx->type);
enum lab_edge resize_edges = node_type_to_edges(ctx->type);
if (ctx->view && !resize_edges) {
struct wlr_box box = ctx->view->current;
resize_edges |=
@ -609,7 +609,7 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
struct cursor_context ctx = get_cursor_context(server);
struct seat *seat = &server->seat;
if (ctx.type == LAB_SSD_MENU) {
if (ctx.type == LAB_NODE_MENU) {
menu_process_cursor_motion(ctx.node);
cursor_set(&server->seat, LAB_CURSOR_DEFAULT);
return false;
@ -621,7 +621,7 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
struct mousebind *mousebind;
wl_list_for_each(mousebind, &rc.mousebinds, link) {
if (ctx.type == LAB_SSD_CLIENT
if (ctx.type == LAB_NODE_CLIENT
&& view_inhibits_actions(ctx.view, &mousebind->actions)) {
continue;
}
@ -964,11 +964,11 @@ process_release_mousebinding(struct server *server,
uint32_t modifiers = keyboard_get_all_modifiers(&server->seat);
wl_list_for_each(mousebind, &rc.mousebinds, link) {
if (ctx->type == LAB_SSD_CLIENT
if (ctx->type == LAB_NODE_CLIENT
&& view_inhibits_actions(ctx->view, &mousebind->actions)) {
continue;
}
if (ssd_part_contains(mousebind->context, ctx->type)
if (node_type_contains(mousebind->context, ctx->type)
&& mousebind->button == button
&& modifiers == mousebind->modifiers) {
switch (mousebind->mouse_event) {
@ -991,7 +991,7 @@ static bool
is_double_click(long double_click_speed, uint32_t button,
struct cursor_context *ctx)
{
static enum ssd_part_type last_type;
static enum lab_node_type last_type;
static uint32_t last_button;
static struct view *last_view;
static struct timespec last_click;
@ -1015,7 +1015,7 @@ is_double_click(long double_click_speed, uint32_t button,
*/
last_button = 0;
last_view = NULL;
last_type = LAB_SSD_NONE;
last_type = LAB_NODE_NONE;
return true;
}
return false;
@ -1035,11 +1035,11 @@ process_press_mousebinding(struct server *server, struct cursor_context *ctx,
uint32_t modifiers = keyboard_get_all_modifiers(&server->seat);
wl_list_for_each(mousebind, &rc.mousebinds, link) {
if (ctx->type == LAB_SSD_CLIENT
if (ctx->type == LAB_NODE_CLIENT
&& view_inhibits_actions(ctx->view, &mousebind->actions)) {
continue;
}
if (ssd_part_contains(mousebind->context, ctx->type)
if (node_type_contains(mousebind->context, ctx->type)
&& mousebind->button == button
&& modifiers == mousebind->modifiers) {
switch (mousebind->mouse_event) {
@ -1053,9 +1053,9 @@ process_press_mousebinding(struct server *server, struct cursor_context *ctx,
if (!double_click) {
/* Swallow the press event */
consumed_by_frame_context |=
mousebind->context == LAB_SSD_FRAME;
mousebind->context == LAB_NODE_FRAME;
consumed_by_frame_context |=
mousebind->context == LAB_SSD_ALL;
mousebind->context == LAB_NODE_ALL;
mousebind->pressed_in_context = true;
}
continue;
@ -1069,8 +1069,8 @@ process_press_mousebinding(struct server *server, struct cursor_context *ctx,
default:
continue;
}
consumed_by_frame_context |= mousebind->context == LAB_SSD_FRAME;
consumed_by_frame_context |= mousebind->context == LAB_SSD_ALL;
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);
}
}
@ -1108,14 +1108,14 @@ cursor_process_button_press(struct seat *seat, uint32_t button, uint32_t time_ms
* Action processing does not run for these surfaces and thus
* the Focus action (used for normal views) does not work.
*/
if (ctx.type == LAB_SSD_LAYER_SURFACE) {
if (ctx.type == LAB_NODE_LAYER_SURFACE) {
wlr_log(WLR_DEBUG, "press on layer-surface");
struct wlr_layer_surface_v1 *layer =
wlr_layer_surface_v1_try_from_wlr_surface(ctx.surface);
if (layer && layer->current.keyboard_interactive) {
layer_try_set_focus(seat, layer);
}
} else if (ctx.type == LAB_SSD_LAYER_SUBSURFACE) {
} else if (ctx.type == LAB_NODE_LAYER_SUBSURFACE) {
wlr_log(WLR_DEBUG, "press on layer-subsurface");
struct wlr_layer_surface_v1 *layer =
subsurface_parent_layer(ctx.surface);
@ -1123,13 +1123,13 @@ cursor_process_button_press(struct seat *seat, uint32_t button, uint32_t time_ms
layer_try_set_focus(seat, layer);
}
#ifdef HAVE_XWAYLAND
} else if (ctx.type == LAB_SSD_UNMANAGED) {
} else if (ctx.type == LAB_NODE_UNMANAGED) {
desktop_focus_view_or_surface(seat, NULL, ctx.surface,
/*raise*/ false);
#endif
}
if (ctx.type != LAB_SSD_CLIENT && ctx.type != LAB_SSD_LAYER_SUBSURFACE
if (ctx.type != LAB_NODE_CLIENT && ctx.type != LAB_NODE_LAYER_SUBSURFACE
&& wlr_seat_pointer_has_grab(seat->seat)) {
/*
* If we have an active popup grab (an open popup) we want to
@ -1173,7 +1173,7 @@ cursor_process_button_release(struct seat *seat, uint32_t button,
if (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_SSD_MENU) {
if (ctx.type == LAB_NODE_MENU) {
menu_call_selected_actions(server);
} else {
menu_close_root(server);
@ -1342,11 +1342,11 @@ process_cursor_axis(struct server *server, enum wl_pointer_axis orientation,
if (direction != LAB_DIRECTION_INVALID) {
struct mousebind *mousebind;
wl_list_for_each(mousebind, &rc.mousebinds, link) {
if (ctx.type == LAB_SSD_CLIENT
if (ctx.type == LAB_NODE_CLIENT
&& view_inhibits_actions(ctx.view, &mousebind->actions)) {
continue;
}
if (ssd_part_contains(mousebind->context, ctx.type)
if (node_type_contains(mousebind->context, ctx.type)
&& mousebind->direction == direction
&& modifiers == mousebind->modifiers
&& mousebind->mouse_event == MOUSE_ACTION_SCROLL) {