Use "cycle" instead of "osd" across the codebase

We were using the word "osd" to describe the window switcher, but it can
be used with on-screen display (OSD) disabled by
`<windowSwitcher><osd show="false">`. Let's use "cycle" instead to avoid
confusion.
This commit is contained in:
tokyo4j 2025-11-29 02:41:54 +09:00 committed by Hiroaki Yamamoto
parent 65cc2e40ba
commit 4fcb873f6f
21 changed files with 265 additions and 266 deletions

View file

@ -47,7 +47,7 @@ enum lab_node_type {
LAB_NODE_FRAME, LAB_NODE_FRAME,
LAB_NODE_ROOT, LAB_NODE_ROOT,
LAB_NODE_MENUITEM, LAB_NODE_MENUITEM,
LAB_NODE_OSD_ITEM, LAB_NODE_CYCLE_OSD_ITEM,
LAB_NODE_LAYER_SURFACE, LAB_NODE_LAYER_SURFACE,
LAB_NODE_UNMANAGED, LAB_NODE_UNMANAGED,
LAB_NODE_ALL, LAB_NODE_ALL,

View file

@ -182,8 +182,8 @@ struct rcxml {
bool unshade; bool unshade;
enum lab_view_criteria criteria; enum lab_view_criteria criteria;
struct wl_list fields; /* struct window_switcher_field.link */ struct wl_list fields; /* struct window_switcher_field.link */
enum window_switcher_style style; enum cycle_osd_style style;
enum osd_output_criteria output_criteria; enum cycle_osd_output_criteria output_criteria;
char *thumbnail_label_format; char *thumbnail_label_format;
} window_switcher; } window_switcher;

View file

@ -107,15 +107,15 @@ enum lab_window_type {
LAB_WINDOW_TYPE_LEN LAB_WINDOW_TYPE_LEN
}; };
enum window_switcher_style { enum cycle_osd_style {
WINDOW_SWITCHER_CLASSIC, CYCLE_OSD_STYLE_CLASSIC,
WINDOW_SWITCHER_THUMBNAIL, CYCLE_OSD_STYLE_THUMBNAIL,
}; };
enum osd_output_criteria { enum cycle_osd_output_criteria {
OSD_OUTPUT_ALL, CYCLE_OSD_OUTPUT_ALL,
OSD_OUTPUT_POINTER, CYCLE_OSD_OUTPUT_POINTER,
OSD_OUTPUT_KEYBOARD, CYCLE_OSD_OUTPUT_KEYBOARD,
}; };
#endif /* LABWC_CONFIG_TYPES_H */ #endif /* LABWC_CONFIG_TYPES_H */

View file

@ -14,7 +14,7 @@ enum lab_cycle_dir {
}; };
/* TODO: add field with keyboard layout? */ /* TODO: add field with keyboard layout? */
enum window_switcher_field_content { enum cycle_osd_field_content {
LAB_FIELD_NONE = 0, LAB_FIELD_NONE = 0,
LAB_FIELD_TYPE, LAB_FIELD_TYPE,
LAB_FIELD_TYPE_SHORT, LAB_FIELD_TYPE_SHORT,
@ -35,8 +35,8 @@ enum window_switcher_field_content {
LAB_FIELD_COUNT LAB_FIELD_COUNT
}; };
struct window_switcher_field { struct cycle_osd_field {
enum window_switcher_field_content content; enum cycle_osd_field_content content;
int width; int width;
char *format; char *format;
struct wl_list link; /* struct rcxml.window_switcher.fields */ struct wl_list link; /* struct rcxml.window_switcher.fields */
@ -48,54 +48,54 @@ struct server;
struct wlr_scene_node; struct wlr_scene_node;
/* Begin window switcher */ /* Begin window switcher */
void osd_begin(struct server *server, enum lab_cycle_dir direction); void cycle_begin(struct server *server, enum lab_cycle_dir direction);
/* Cycle the selected view in the window switcher */ /* Cycle the selected view in the window switcher */
void osd_cycle(struct server *server, enum lab_cycle_dir direction); void cycle_step(struct server *server, enum lab_cycle_dir direction);
/* Closes the OSD */ /* Closes the OSD */
void osd_finish(struct server *server, bool switch_focus); void cycle_finish(struct server *server, bool switch_focus);
/* Notify OSD about a destroying view */ /* Notify OSD about a destroying view */
void osd_on_view_destroy(struct view *view); void cycle_on_view_destroy(struct view *view);
/* Focus the clicked window and close OSD */ /* Focus the clicked window and close OSD */
void osd_on_cursor_release(struct server *server, struct wlr_scene_node *node); void cycle_on_cursor_release(struct server *server, struct wlr_scene_node *node);
/* Used by osd.c internally to render window switcher fields */ /* Used by osd.c internally to render window switcher fields */
void osd_field_get_content(struct window_switcher_field *field, void cycle_osd_field_get_content(struct cycle_osd_field *field,
struct buf *buf, struct view *view); struct buf *buf, struct view *view);
/* Sets view info to buf according to format */ /* Sets view info to buf according to format */
void osd_field_set_custom(struct buf *buf, struct view *view, void cycle_osd_field_set_custom(struct buf *buf, struct view *view,
const char *format); const char *format);
/* Used by rcxml.c when parsing the config */ /* Used by rcxml.c when parsing the config */
void osd_field_arg_from_xml_node(struct window_switcher_field *field, void cycle_osd_field_arg_from_xml_node(struct cycle_osd_field *field,
const char *nodename, const char *content); const char *nodename, const char *content);
bool osd_field_is_valid(struct window_switcher_field *field); bool cycle_osd_field_is_valid(struct cycle_osd_field *field);
void osd_field_free(struct window_switcher_field *field); void cycle_osd_field_free(struct cycle_osd_field *field);
/* Internal API */ /* Internal API */
struct osd_item { struct cycle_osd_item {
struct view *view; struct view *view;
struct wlr_scene_tree *tree; struct wlr_scene_tree *tree;
struct wl_list link; struct wl_list link;
}; };
struct osd_impl { struct cycle_osd_impl {
/* /*
* Create a scene-tree of OSD for an output. * Create a scene-tree of OSD for an output.
* This sets output->osd_scene.{items,tree}. * This sets output->cycle_osd.{items,tree}.
*/ */
void (*create)(struct output *output, struct wl_array *views); void (*create)(struct output *output, struct wl_array *views);
/* /*
* Update output->osd_scene.tree to highlight * Update output->cycle_osd.tree to highlight
* server->osd_state.cycle_view. * server->cycle_state.selected_view.
*/ */
void (*update)(struct output *output); void (*update)(struct output *output);
}; };
extern struct osd_impl osd_classic_impl; extern struct cycle_osd_impl cycle_osd_classic_impl;
extern struct osd_impl osd_thumbnail_impl; extern struct cycle_osd_impl cycle_osd_thumbnail_impl;
#endif // LABWC_CYCLE_H #endif // LABWC_CYCLE_H

View file

@ -18,7 +18,7 @@ enum input_mode {
LAB_INPUT_STATE_MOVE, LAB_INPUT_STATE_MOVE,
LAB_INPUT_STATE_RESIZE, LAB_INPUT_STATE_RESIZE,
LAB_INPUT_STATE_MENU, LAB_INPUT_STATE_MENU,
LAB_INPUT_STATE_WINDOW_SWITCHER, LAB_INPUT_STATE_CYCLE, /* a.k.a. window switching */
}; };
struct seat { struct seat {
@ -302,15 +302,15 @@ struct server {
struct wlr_security_context_manager_v1 *security_context_manager_v1; struct wlr_security_context_manager_v1 *security_context_manager_v1;
/* Set when in cycle (alt-tab) mode */ /* Set when in cycle (alt-tab) mode */
struct osd_state { struct cycle_state {
struct view *cycle_view; struct view *selected_view;
bool preview_was_shaded; bool preview_was_shaded;
bool preview_was_enabled; bool preview_was_enabled;
struct wlr_scene_node *preview_node; struct wlr_scene_node *preview_node;
struct wlr_scene_tree *preview_parent; struct wlr_scene_tree *preview_parent;
struct wlr_scene_node *preview_anchor; struct wlr_scene_node *preview_anchor;
struct lab_scene_rect *preview_outline; struct lab_scene_rect *preview_outline;
} osd_state; } cycle;
struct theme *theme; struct theme *theme;

View file

@ -53,10 +53,10 @@ struct menuitem *node_menuitem_from_node(
struct wlr_scene_node *wlr_scene_node); struct wlr_scene_node *wlr_scene_node);
/** /**
* node_osd_item_from_node - return osd item struct from node * node_cycle_osd_item_from_node - return cycle OSD item struct from node
* @wlr_scene_node: wlr_scene_node from which to return data * @wlr_scene_node: wlr_scene_node from which to return data
*/ */
struct osd_item *node_osd_item_from_node( struct cycle_osd_item *node_cycle_osd_item_from_node(
struct wlr_scene_node *wlr_scene_node); struct wlr_scene_node *wlr_scene_node);
/** /**

View file

@ -15,14 +15,14 @@ struct output {
struct wlr_scene_output *scene_output; struct wlr_scene_output *scene_output;
struct wlr_scene_tree *layer_tree[LAB_NR_LAYERS]; struct wlr_scene_tree *layer_tree[LAB_NR_LAYERS];
struct wlr_scene_tree *layer_popup_tree; struct wlr_scene_tree *layer_popup_tree;
struct wlr_scene_tree *osd_tree; struct wlr_scene_tree *cycle_osd_tree;
struct wlr_scene_tree *session_lock_tree; struct wlr_scene_tree *session_lock_tree;
struct wlr_scene_buffer *workspace_osd; struct wlr_scene_buffer *workspace_osd;
struct osd_scene { struct cycle_osd_scene {
struct wl_list items; /* struct osd_item */ struct wl_list items; /* struct cycle_osd_item */
struct wlr_scene_tree *tree; struct wlr_scene_tree *tree;
} osd_scene; } cycle_osd;
/* In output-relative scene coordinates */ /* In output-relative scene coordinates */
struct wlr_box usable_area; struct wlr_box usable_area;

View file

@ -1112,17 +1112,17 @@ run_action(struct view *view, struct server *server, struct action *action,
} }
break; break;
case ACTION_TYPE_NEXT_WINDOW: case ACTION_TYPE_NEXT_WINDOW:
if (server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) { if (server->input_mode == LAB_INPUT_STATE_CYCLE) {
osd_cycle(server, LAB_CYCLE_DIR_FORWARD); cycle_step(server, LAB_CYCLE_DIR_FORWARD);
} else { } else {
osd_begin(server, LAB_CYCLE_DIR_FORWARD); cycle_begin(server, LAB_CYCLE_DIR_FORWARD);
} }
break; break;
case ACTION_TYPE_PREVIOUS_WINDOW: case ACTION_TYPE_PREVIOUS_WINDOW:
if (server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) { if (server->input_mode == LAB_INPUT_STATE_CYCLE) {
osd_cycle(server, LAB_CYCLE_DIR_BACKWARD); cycle_step(server, LAB_CYCLE_DIR_BACKWARD);
} else { } else {
osd_begin(server, LAB_CYCLE_DIR_BACKWARD); cycle_begin(server, LAB_CYCLE_DIR_BACKWARD);
} }
break; break;
case ACTION_TYPE_RECONFIGURE: case ACTION_TYPE_RECONFIGURE:
@ -1569,7 +1569,7 @@ actions_run(struct view *activator, struct server *server,
struct action *action; struct action *action;
wl_list_for_each(action, actions, link) { wl_list_for_each(action, actions, link) {
if (server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER if (server->input_mode == LAB_INPUT_STATE_CYCLE
&& action->type != ACTION_TYPE_NEXT_WINDOW && action->type != ACTION_TYPE_NEXT_WINDOW
&& action->type != ACTION_TYPE_PREVIOUS_WINDOW) { && action->type != ACTION_TYPE_PREVIOUS_WINDOW) {
wlr_log(WLR_INFO, "Only NextWindow or PreviousWindow " wlr_log(WLR_INFO, "Only NextWindow or PreviousWindow "

View file

@ -323,23 +323,23 @@ fill_window_rules(xmlNode *node)
static void static void
clear_window_switcher_fields(void) clear_window_switcher_fields(void)
{ {
struct window_switcher_field *field, *field_tmp; struct cycle_osd_field *field, *field_tmp;
wl_list_for_each_safe(field, field_tmp, &rc.window_switcher.fields, link) { wl_list_for_each_safe(field, field_tmp, &rc.window_switcher.fields, link) {
wl_list_remove(&field->link); wl_list_remove(&field->link);
osd_field_free(field); cycle_osd_field_free(field);
} }
} }
static void static void
fill_window_switcher_field(xmlNode *node) fill_window_switcher_field(xmlNode *node)
{ {
struct window_switcher_field *field = znew(*field); struct cycle_osd_field *field = znew(*field);
wl_list_append(&rc.window_switcher.fields, &field->link); wl_list_append(&rc.window_switcher.fields, &field->link);
xmlNode *child; xmlNode *child;
char *key, *content; char *key, *content;
LAB_XML_FOR_EACH(node, child, key, content) { LAB_XML_FOR_EACH(node, child, key, content) {
osd_field_arg_from_xml_node(field, key, content); cycle_osd_field_arg_from_xml_node(field, key, content);
} }
} }
@ -1212,20 +1212,20 @@ entry(xmlNode *node, char *nodename, char *content)
set_bool(content, &rc.window_switcher.show); set_bool(content, &rc.window_switcher.show);
} else if (!strcasecmp(nodename, "style.osd.windowSwitcher")) { } else if (!strcasecmp(nodename, "style.osd.windowSwitcher")) {
if (!strcasecmp(content, "classic")) { if (!strcasecmp(content, "classic")) {
rc.window_switcher.style = WINDOW_SWITCHER_CLASSIC; rc.window_switcher.style = CYCLE_OSD_STYLE_CLASSIC;
} else if (!strcasecmp(content, "thumbnail")) { } else if (!strcasecmp(content, "thumbnail")) {
rc.window_switcher.style = WINDOW_SWITCHER_THUMBNAIL; rc.window_switcher.style = CYCLE_OSD_STYLE_THUMBNAIL;
} else { } else {
wlr_log(WLR_ERROR, "Invalid windowSwitcher style %s: " wlr_log(WLR_ERROR, "Invalid windowSwitcher style %s: "
"should be one of classic|thumbnail", content); "should be one of classic|thumbnail", content);
} }
} else if (!strcasecmp(nodename, "output.osd.windowSwitcher")) { } else if (!strcasecmp(nodename, "output.osd.windowSwitcher")) {
if (!strcasecmp(content, "all")) { if (!strcasecmp(content, "all")) {
rc.window_switcher.output_criteria = OSD_OUTPUT_ALL; rc.window_switcher.output_criteria = CYCLE_OSD_OUTPUT_ALL;
} else if (!strcasecmp(content, "pointer")) { } else if (!strcasecmp(content, "pointer")) {
rc.window_switcher.output_criteria = OSD_OUTPUT_POINTER; rc.window_switcher.output_criteria = CYCLE_OSD_OUTPUT_POINTER;
} else if (!strcasecmp(content, "keyboard")) { } else if (!strcasecmp(content, "keyboard")) {
rc.window_switcher.output_criteria = OSD_OUTPUT_KEYBOARD; rc.window_switcher.output_criteria = CYCLE_OSD_OUTPUT_KEYBOARD;
} else { } else {
wlr_log(WLR_ERROR, "Invalid windowSwitcher output %s: " wlr_log(WLR_ERROR, "Invalid windowSwitcher output %s: "
"should be one of all|pointer|keyboard", content); "should be one of all|pointer|keyboard", content);
@ -1238,9 +1238,9 @@ entry(xmlNode *node, char *nodename, char *content)
" Use <osd show=\"\" />"); " Use <osd show=\"\" />");
} else if (!strcasecmp(nodename, "style.windowSwitcher")) { } else if (!strcasecmp(nodename, "style.windowSwitcher")) {
if (!strcasecmp(content, "classic")) { if (!strcasecmp(content, "classic")) {
rc.window_switcher.style = WINDOW_SWITCHER_CLASSIC; rc.window_switcher.style = CYCLE_OSD_STYLE_CLASSIC;
} else if (!strcasecmp(content, "thumbnail")) { } else if (!strcasecmp(content, "thumbnail")) {
rc.window_switcher.style = WINDOW_SWITCHER_THUMBNAIL; rc.window_switcher.style = CYCLE_OSD_STYLE_THUMBNAIL;
} }
wlr_log(WLR_ERROR, "<windowSwitcher style=\"\" /> is deprecated." wlr_log(WLR_ERROR, "<windowSwitcher style=\"\" /> is deprecated."
" Use <osd style=\"\" />"); " Use <osd style=\"\" />");
@ -1465,8 +1465,8 @@ rcxml_init(void)
rc.snap_tiling_events_mode = LAB_TILING_EVENTS_ALWAYS; rc.snap_tiling_events_mode = LAB_TILING_EVENTS_ALWAYS;
rc.window_switcher.show = true; rc.window_switcher.show = true;
rc.window_switcher.style = WINDOW_SWITCHER_CLASSIC; rc.window_switcher.style = CYCLE_OSD_STYLE_CLASSIC;
rc.window_switcher.output_criteria = OSD_OUTPUT_ALL; rc.window_switcher.output_criteria = CYCLE_OSD_OUTPUT_ALL;
rc.window_switcher.thumbnail_label_format = xstrdup("%T"); rc.window_switcher.thumbnail_label_format = xstrdup("%T");
rc.window_switcher.preview = true; rc.window_switcher.preview = true;
rc.window_switcher.outlines = true; rc.window_switcher.outlines = true;
@ -1635,7 +1635,7 @@ static void
load_default_window_switcher_fields(void) load_default_window_switcher_fields(void)
{ {
static const struct { static const struct {
enum window_switcher_field_content content; enum cycle_osd_field_content content;
int width; int width;
} fields[] = { } fields[] = {
#if HAVE_LIBSFDO #if HAVE_LIBSFDO
@ -1648,7 +1648,7 @@ load_default_window_switcher_fields(void)
#endif #endif
}; };
struct window_switcher_field *field; struct cycle_osd_field *field;
for (size_t i = 0; i < ARRAY_SIZE(fields); i++) { for (size_t i = 0; i < ARRAY_SIZE(fields); i++) {
field = znew(*field); field = znew(*field);
field->content = fields[i].content; field->content = fields[i].content;
@ -1867,13 +1867,13 @@ validate(void)
/* OSD fields */ /* OSD fields */
int field_width_sum = 0; int field_width_sum = 0;
struct window_switcher_field *field, *field_tmp; struct cycle_osd_field *field, *field_tmp;
wl_list_for_each_safe(field, field_tmp, &rc.window_switcher.fields, link) { wl_list_for_each_safe(field, field_tmp, &rc.window_switcher.fields, link) {
field_width_sum += field->width; field_width_sum += field->width;
if (!osd_field_is_valid(field) || field_width_sum > 100) { if (!cycle_osd_field_is_valid(field) || field_width_sum > 100) {
wlr_log(WLR_ERROR, "Deleting invalid window switcher field %p", field); wlr_log(WLR_ERROR, "Deleting invalid window switcher field %p", field);
wl_list_remove(&field->link); wl_list_remove(&field->link);
osd_field_free(field); cycle_osd_field_free(field);
} }
} }
} }

View file

@ -17,32 +17,32 @@
#include "theme.h" #include "theme.h"
#include "view.h" #include "view.h"
static void update_osd(struct server *server); static void update_cycle(struct server *server);
static void static void
destroy_osd_scenes(struct server *server) destroy_osd_scenes(struct server *server)
{ {
struct output *output; struct output *output;
wl_list_for_each(output, &server->outputs, link) { wl_list_for_each(output, &server->outputs, link) {
struct osd_item *item, *tmp; struct cycle_osd_item *item, *tmp;
wl_list_for_each_safe(item, tmp, &output->osd_scene.items, link) { wl_list_for_each_safe(item, tmp, &output->cycle_osd.items, link) {
wl_list_remove(&item->link); wl_list_remove(&item->link);
free(item); free(item);
} }
if (output->osd_scene.tree) { if (output->cycle_osd.tree) {
wlr_scene_node_destroy(&output->osd_scene.tree->node); wlr_scene_node_destroy(&output->cycle_osd.tree->node);
output->osd_scene.tree = NULL; output->cycle_osd.tree = NULL;
} }
} }
} }
static void static void
osd_update_preview_outlines(struct view *view) update_preview_outlines(struct view *view)
{ {
/* Create / Update preview outline tree */ /* Create / Update preview outline tree */
struct server *server = view->server; struct server *server = view->server;
struct theme *theme = server->theme; struct theme *theme = server->theme;
struct lab_scene_rect *rect = view->server->osd_state.preview_outline; struct lab_scene_rect *rect = view->server->cycle.preview_outline;
if (!rect) { if (!rect) {
struct lab_scene_rect_options opts = { struct lab_scene_rect_options opts = {
.border_colors = (float *[3]) { .border_colors = (float *[3]) {
@ -55,7 +55,7 @@ osd_update_preview_outlines(struct view *view)
}; };
rect = lab_scene_rect_create(&server->scene->tree, &opts); rect = lab_scene_rect_create(&server->scene->tree, &opts);
wlr_scene_node_place_above(&rect->tree->node, &server->menu_tree->node); wlr_scene_node_place_above(&rect->tree->node, &server->menu_tree->node);
server->osd_state.preview_outline = rect; server->cycle.preview_outline = rect;
} }
struct wlr_box geo = ssd_max_extents(view); struct wlr_box geo = ssd_max_extents(view);
@ -68,7 +68,7 @@ osd_update_preview_outlines(struct view *view)
* If !start_view, the second focusable view is returned. * If !start_view, the second focusable view is returned.
*/ */
static struct view * static struct view *
get_next_cycle_view(struct server *server, struct view *start_view, get_next_selected_view(struct server *server, struct view *start_view,
enum lab_cycle_dir dir) enum lab_cycle_dir dir)
{ {
struct view *(*iter)(struct wl_list *head, struct view *view, struct view *(*iter)(struct wl_list *head, struct view *view,
@ -96,127 +96,128 @@ get_next_cycle_view(struct server *server, struct view *start_view,
} }
void void
osd_on_view_destroy(struct view *view) cycle_on_view_destroy(struct view *view)
{ {
assert(view); assert(view);
struct osd_state *osd_state = &view->server->osd_state; struct server *server = view->server;
struct cycle_state *cycle = &server->cycle;
if (view->server->input_mode != LAB_INPUT_STATE_WINDOW_SWITCHER) { if (server->input_mode != LAB_INPUT_STATE_CYCLE) {
/* OSD not active, no need for clean up */ /* OSD not active, no need for clean up */
return; return;
} }
if (osd_state->cycle_view == view) { if (cycle->selected_view == view) {
/* /*
* If we are the current OSD selected view, cycle * If we are the current OSD selected view, cycle
* to the next because we are dying. * to the next because we are dying.
*/ */
/* Also resets preview node */ /* Also resets preview node */
osd_state->cycle_view = get_next_cycle_view(view->server, cycle->selected_view = get_next_selected_view(server,
osd_state->cycle_view, LAB_CYCLE_DIR_BACKWARD); cycle->selected_view, LAB_CYCLE_DIR_BACKWARD);
/* /*
* If we cycled back to ourselves, then we have no more windows. * If we cycled back to ourselves, then we have no more windows.
* Just close the OSD for good. * Just close the OSD for good.
*/ */
if (osd_state->cycle_view == view || !osd_state->cycle_view) { if (cycle->selected_view == view
/* osd_finish() additionally resets cycle_view to NULL */ || !cycle->selected_view) {
osd_finish(view->server, /*switch_focus*/ false); /* cycle_finish() additionally resets selected_view to NULL */
cycle_finish(server, /*switch_focus*/ false);
} }
} }
if (osd_state->cycle_view) { if (cycle->selected_view) {
/* Recreate the OSD to reflect the view has now gone. */ /* Recreate the OSD to reflect the view has now gone. */
destroy_osd_scenes(view->server); destroy_osd_scenes(server);
update_osd(view->server); update_cycle(server);
} }
if (view->scene_tree) { if (view->scene_tree) {
struct wlr_scene_node *node = &view->scene_tree->node; struct wlr_scene_node *node = &view->scene_tree->node;
if (osd_state->preview_anchor == node) { if (cycle->preview_anchor == node) {
/* /*
* If we are the anchor for the current OSD selected view, * If we are the anchor for the current OSD selected view,
* replace the anchor with the node before us. * replace the anchor with the node before us.
*/ */
osd_state->preview_anchor = lab_wlr_scene_get_prev_node(node); cycle->preview_anchor = lab_wlr_scene_get_prev_node(node);
} }
} }
} }
void void
osd_on_cursor_release(struct server *server, struct wlr_scene_node *node) cycle_on_cursor_release(struct server *server, struct wlr_scene_node *node)
{ {
assert(server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER); assert(server->input_mode == LAB_INPUT_STATE_CYCLE);
struct osd_item *item = node_osd_item_from_node(node); struct cycle_osd_item *item = node_cycle_osd_item_from_node(node);
server->osd_state.cycle_view = item->view; server->cycle.selected_view = item->view;
osd_finish(server, /*switch_focus*/ true); cycle_finish(server, /*switch_focus*/ true);
} }
static void static void
restore_preview_node(struct server *server) restore_preview_node(struct server *server)
{ {
struct osd_state *osd_state = &server->osd_state; if (server->cycle.preview_node) {
if (osd_state->preview_node) { wlr_scene_node_reparent(server->cycle.preview_node,
wlr_scene_node_reparent(osd_state->preview_node, server->cycle.preview_parent);
osd_state->preview_parent);
if (osd_state->preview_anchor) { if (server->cycle.preview_anchor) {
wlr_scene_node_place_above(osd_state->preview_node, wlr_scene_node_place_above(server->cycle.preview_node,
osd_state->preview_anchor); server->cycle.preview_anchor);
} else { } else {
/* Selected view was the first node */ /* Selected view was the first node */
wlr_scene_node_lower_to_bottom(osd_state->preview_node); wlr_scene_node_lower_to_bottom(server->cycle.preview_node);
} }
/* Node was disabled / minimized before, disable again */ /* Node was disabled / minimized before, disable again */
if (!osd_state->preview_was_enabled) { if (!server->cycle.preview_was_enabled) {
wlr_scene_node_set_enabled(osd_state->preview_node, false); wlr_scene_node_set_enabled(server->cycle.preview_node, false);
} }
if (osd_state->preview_was_shaded) { if (server->cycle.preview_was_shaded) {
struct view *view = node_view_from_node(osd_state->preview_node); struct view *view = node_view_from_node(server->cycle.preview_node);
view_set_shade(view, true); view_set_shade(view, true);
} }
osd_state->preview_node = NULL; server->cycle.preview_node = NULL;
osd_state->preview_parent = NULL; server->cycle.preview_parent = NULL;
osd_state->preview_anchor = NULL; server->cycle.preview_anchor = NULL;
osd_state->preview_was_shaded = false; server->cycle.preview_was_shaded = false;
} }
} }
void void
osd_begin(struct server *server, enum lab_cycle_dir direction) cycle_begin(struct server *server, enum lab_cycle_dir direction)
{ {
if (server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) { if (server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
return; return;
} }
server->osd_state.cycle_view = get_next_cycle_view(server, server->cycle.selected_view = get_next_selected_view(server,
server->osd_state.cycle_view, direction); server->cycle.selected_view, direction);
seat_focus_override_begin(&server->seat, seat_focus_override_begin(&server->seat,
LAB_INPUT_STATE_WINDOW_SWITCHER, LAB_CURSOR_DEFAULT); LAB_INPUT_STATE_CYCLE, LAB_CURSOR_DEFAULT);
update_osd(server); update_cycle(server);
/* Update cursor, in case it is within the area covered by OSD */ /* Update cursor, in case it is within the area covered by OSD */
cursor_update_focus(server); cursor_update_focus(server);
} }
void void
osd_cycle(struct server *server, enum lab_cycle_dir direction) cycle_step(struct server *server, enum lab_cycle_dir direction)
{ {
assert(server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER); assert(server->input_mode == LAB_INPUT_STATE_CYCLE);
server->osd_state.cycle_view = get_next_cycle_view(server, server->cycle.selected_view = get_next_selected_view(server,
server->osd_state.cycle_view, direction); server->cycle.selected_view, direction);
update_osd(server); update_cycle(server);
} }
void void
osd_finish(struct server *server, bool switch_focus) cycle_finish(struct server *server, bool switch_focus)
{ {
if (server->input_mode != LAB_INPUT_STATE_WINDOW_SWITCHER) { if (server->input_mode != LAB_INPUT_STATE_CYCLE) {
return; return;
} }
@ -224,62 +225,63 @@ osd_finish(struct server *server, bool switch_focus)
/* FIXME: this sets focus to the old surface even with switch_focus=true */ /* FIXME: this sets focus to the old surface even with switch_focus=true */
seat_focus_override_end(&server->seat); seat_focus_override_end(&server->seat);
struct view *cycle_view = server->osd_state.cycle_view; struct view *selected_view = server->cycle.selected_view;
server->osd_state.preview_node = NULL; server->cycle.preview_node = NULL;
server->osd_state.preview_anchor = NULL; server->cycle.preview_anchor = NULL;
server->osd_state.cycle_view = NULL; server->cycle.selected_view = NULL;
server->osd_state.preview_was_shaded = false; server->cycle.preview_was_shaded = false;
destroy_osd_scenes(server); destroy_osd_scenes(server);
if (server->osd_state.preview_outline) { if (server->cycle.preview_outline) {
/* Destroy the whole multi_rect so we can easily react to new themes */ /* Destroy the whole multi_rect so we can easily react to new themes */
wlr_scene_node_destroy(&server->osd_state.preview_outline->tree->node); wlr_scene_node_destroy(&server->cycle.preview_outline->tree->node);
server->osd_state.preview_outline = NULL; server->cycle.preview_outline = NULL;
} }
/* Hiding OSD may need a cursor change */ /* Hiding OSD may need a cursor change */
cursor_update_focus(server); cursor_update_focus(server);
if (switch_focus && cycle_view) { if (switch_focus && selected_view) {
if (rc.window_switcher.unshade) { if (rc.window_switcher.unshade) {
view_set_shade(cycle_view, false); view_set_shade(selected_view, false);
} }
desktop_focus_view(cycle_view, /*raise*/ true); desktop_focus_view(selected_view, /*raise*/ true);
} }
} }
static void static void
preview_cycled_view(struct view *view) preview_selected_view(struct view *view)
{ {
assert(view); assert(view);
assert(view->scene_tree); assert(view->scene_tree);
struct osd_state *osd_state = &view->server->osd_state; struct server *server = view->server;
struct cycle_state *cycle = &server->cycle;
/* Move previous selected node back to its original place */ /* Move previous selected node back to its original place */
restore_preview_node(view->server); restore_preview_node(server);
/* Store some pointers so we can reset the preview later on */ /* Store some pointers so we can reset the preview later on */
osd_state->preview_node = &view->scene_tree->node; cycle->preview_node = &view->scene_tree->node;
osd_state->preview_parent = view->scene_tree->node.parent; cycle->preview_parent = view->scene_tree->node.parent;
/* Remember the sibling right before the selected node */ /* Remember the sibling right before the selected node */
osd_state->preview_anchor = lab_wlr_scene_get_prev_node( cycle->preview_anchor = lab_wlr_scene_get_prev_node(
osd_state->preview_node); cycle->preview_node);
while (osd_state->preview_anchor && !osd_state->preview_anchor->data) { while (cycle->preview_anchor && !cycle->preview_anchor->data) {
/* Ignore non-view nodes */ /* Ignore non-view nodes */
osd_state->preview_anchor = lab_wlr_scene_get_prev_node( cycle->preview_anchor = lab_wlr_scene_get_prev_node(
osd_state->preview_anchor); cycle->preview_anchor);
} }
/* Store node enabled / minimized state and force-enable if disabled */ /* Store node enabled / minimized state and force-enable if disabled */
osd_state->preview_was_enabled = osd_state->preview_node->enabled; cycle->preview_was_enabled = cycle->preview_node->enabled;
if (!osd_state->preview_was_enabled) { if (!cycle->preview_was_enabled) {
wlr_scene_node_set_enabled(osd_state->preview_node, true); wlr_scene_node_set_enabled(cycle->preview_node, true);
} }
if (rc.window_switcher.unshade && view->shaded) { if (rc.window_switcher.unshade && view->shaded) {
view_set_shade(view, false); view_set_shade(view, false);
osd_state->preview_was_shaded = true; cycle->preview_was_shaded = true;
} }
/* /*
@ -287,64 +289,64 @@ preview_cycled_view(struct view *view)
* Create a permanent server->osd_preview_tree instead that can * Create a permanent server->osd_preview_tree instead that can
* also be used as parent for the preview outlines. * also be used as parent for the preview outlines.
*/ */
wlr_scene_node_reparent(osd_state->preview_node, wlr_scene_node_reparent(cycle->preview_node,
view->server->view_tree_always_on_top); view->server->view_tree_always_on_top);
/* Finally raise selected node to the top */ /* Finally raise selected node to the top */
wlr_scene_node_raise_to_top(osd_state->preview_node); wlr_scene_node_raise_to_top(cycle->preview_node);
} }
static void static void
update_osd_on_output(struct server *server, struct output *output, update_osd_on_output(struct server *server, struct output *output,
struct osd_impl *osd_impl, struct wl_array *views) struct cycle_osd_impl *osd_impl, struct wl_array *views)
{ {
if (!output_is_usable(output)) { if (!output_is_usable(output)) {
return; return;
} }
if (!output->osd_scene.tree) { if (!output->cycle_osd.tree) {
osd_impl->create(output, views); osd_impl->create(output, views);
assert(output->osd_scene.tree); assert(output->cycle_osd.tree);
} }
osd_impl->update(output); osd_impl->update(output);
} }
static void static void
update_osd(struct server *server) update_cycle(struct server *server)
{ {
struct wl_array views; struct wl_array views;
wl_array_init(&views); wl_array_init(&views);
view_array_append(server, &views, rc.window_switcher.criteria); view_array_append(server, &views, rc.window_switcher.criteria);
struct osd_impl *osd_impl = NULL; struct cycle_osd_impl *osd_impl = NULL;
switch (rc.window_switcher.style) { switch (rc.window_switcher.style) {
case WINDOW_SWITCHER_CLASSIC: case CYCLE_OSD_STYLE_CLASSIC:
osd_impl = &osd_classic_impl; osd_impl = &cycle_osd_classic_impl;
break; break;
case WINDOW_SWITCHER_THUMBNAIL: case CYCLE_OSD_STYLE_THUMBNAIL:
osd_impl = &osd_thumbnail_impl; osd_impl = &cycle_osd_thumbnail_impl;
break; break;
} }
if (!wl_array_len(&views) || !server->osd_state.cycle_view) { if (!wl_array_len(&views) || !server->cycle.selected_view) {
osd_finish(server, /*switch_focus*/ false); cycle_finish(server, /*switch_focus*/ false);
goto out; goto out;
} }
if (rc.window_switcher.show) { if (rc.window_switcher.show) {
/* Display the actual OSD */ /* Display the actual OSD */
switch (rc.window_switcher.output_criteria) { switch (rc.window_switcher.output_criteria) {
case OSD_OUTPUT_ALL: { case CYCLE_OSD_OUTPUT_ALL: {
struct output *output; struct output *output;
wl_list_for_each(output, &server->outputs, link) { wl_list_for_each(output, &server->outputs, link) {
update_osd_on_output(server, output, osd_impl, &views); update_osd_on_output(server, output, osd_impl, &views);
} }
break; break;
} }
case OSD_OUTPUT_POINTER: case CYCLE_OSD_OUTPUT_POINTER:
update_osd_on_output(server, update_osd_on_output(server,
output_nearest_to_cursor(server), osd_impl, &views); output_nearest_to_cursor(server), osd_impl, &views);
break; break;
case OSD_OUTPUT_KEYBOARD: { case CYCLE_OSD_OUTPUT_KEYBOARD: {
struct output *output; struct output *output;
if (server->active_view) { if (server->active_view) {
output = server->active_view->output; output = server->active_view->output;
@ -359,13 +361,13 @@ update_osd(struct server *server)
} }
if (rc.window_switcher.preview) { if (rc.window_switcher.preview) {
preview_cycled_view(server->osd_state.cycle_view); preview_selected_view(server->cycle.selected_view);
} }
/* Outline current window */ /* Outline current window */
if (rc.window_switcher.outlines) { if (rc.window_switcher.outlines) {
if (view_is_focusable(server->osd_state.cycle_view)) { if (view_is_focusable(server->cycle.selected_view)) {
osd_update_preview_outlines(server->osd_state.cycle_view); update_preview_outlines(server->cycle.selected_view);
} }
} }

View file

@ -20,8 +20,8 @@
#include "theme.h" #include "theme.h"
#include "workspaces.h" #include "workspaces.h"
struct osd_classic_item { struct cycle_osd_classic_item {
struct osd_item base; struct cycle_osd_item base;
struct wlr_scene_tree *normal_tree, *active_tree; struct wlr_scene_tree *normal_tree, *active_tree;
}; };
@ -34,7 +34,7 @@ create_fields_scene(struct server *server, struct view *view,
struct window_switcher_classic_theme *switcher_theme = struct window_switcher_classic_theme *switcher_theme =
&theme->osd_window_switcher_classic; &theme->osd_window_switcher_classic;
struct window_switcher_field *field; struct cycle_osd_field *field;
wl_list_for_each(field, &rc.window_switcher.fields, link) { wl_list_for_each(field, &rc.window_switcher.fields, link) {
int field_width = field_widths_sum * field->width / 100.0; int field_width = field_widths_sum * field->width / 100.0;
struct wlr_scene_node *node = NULL; struct wlr_scene_node *node = NULL;
@ -51,7 +51,7 @@ create_fields_scene(struct server *server, struct view *view,
height = icon_size; height = icon_size;
} else { } else {
struct buf buf = BUF_INIT; struct buf buf = BUF_INIT;
osd_field_get_content(field, &buf, view); cycle_osd_field_get_content(field, &buf, view);
if (!string_null_or_empty(buf.data)) { if (!string_null_or_empty(buf.data)) {
struct scaled_font_buffer *font_buffer = struct scaled_font_buffer *font_buffer =
@ -76,9 +76,9 @@ create_fields_scene(struct server *server, struct view *view,
} }
static void static void
osd_classic_create(struct output *output, struct wl_array *views) cycle_osd_classic_create(struct output *output, struct wl_array *views)
{ {
assert(!output->osd_scene.tree && wl_list_empty(&output->osd_scene.items)); assert(!output->cycle_osd.tree && wl_list_empty(&output->cycle_osd.items));
struct server *server = output->server; struct server *server = output->server;
struct theme *theme = server->theme; struct theme *theme = server->theme;
@ -102,7 +102,7 @@ osd_classic_create(struct output *output, struct wl_array *views)
h += switcher_theme->item_height; h += switcher_theme->item_height;
} }
output->osd_scene.tree = wlr_scene_tree_create(output->osd_tree); output->cycle_osd.tree = wlr_scene_tree_create(output->cycle_osd_tree);
float *text_color = theme->osd_label_text_color; float *text_color = theme->osd_label_text_color;
float *bg_color = theme->osd_bg_color; float *bg_color = theme->osd_bg_color;
@ -116,7 +116,7 @@ osd_classic_create(struct output *output, struct wl_array *views)
.width = w, .width = w,
.height = h, .height = h,
}; };
lab_scene_rect_create(output->osd_scene.tree, &bg_opts); lab_scene_rect_create(output->cycle_osd.tree, &bg_opts);
int y = padding; int y = padding;
@ -134,7 +134,7 @@ osd_classic_create(struct output *output, struct wl_array *views)
} }
struct scaled_font_buffer *font_buffer = struct scaled_font_buffer *font_buffer =
scaled_font_buffer_create(output->osd_scene.tree); scaled_font_buffer_create(output->cycle_osd.tree);
wlr_scene_node_set_position(&font_buffer->scene_buffer->node, wlr_scene_node_set_position(&font_buffer->scene_buffer->node,
x, y + (switcher_theme->item_height - font_height(&font)) / 2); x, y + (switcher_theme->item_height - font_height(&font)) / 2);
scaled_font_buffer_update(font_buffer, workspace_name, 0, scaled_font_buffer_update(font_buffer, workspace_name, 0,
@ -157,12 +157,12 @@ osd_classic_create(struct output *output, struct wl_array *views)
/* Draw text for each node */ /* Draw text for each node */
struct view **view; struct view **view;
wl_array_for_each(view, views) { wl_array_for_each(view, views) {
struct osd_classic_item *item = znew(*item); struct cycle_osd_classic_item *item = znew(*item);
wl_list_append(&output->osd_scene.items, &item->base.link); wl_list_append(&output->cycle_osd.items, &item->base.link);
item->base.view = *view; item->base.view = *view;
item->base.tree = wlr_scene_tree_create(output->osd_scene.tree); item->base.tree = wlr_scene_tree_create(output->cycle_osd.tree);
node_descriptor_create(&item->base.tree->node, node_descriptor_create(&item->base.tree->node,
LAB_NODE_OSD_ITEM, NULL, item); LAB_NODE_CYCLE_OSD_ITEM, NULL, item);
/* /*
* OSD border * OSD border
* +---------------------------------+ * +---------------------------------+
@ -218,23 +218,23 @@ osd_classic_create(struct output *output, struct wl_array *views)
error:; error:;
/* Center OSD */ /* Center OSD */
wlr_scene_node_set_position(&output->osd_scene.tree->node, wlr_scene_node_set_position(&output->cycle_osd.tree->node,
output_box.x + (output_box.width - w) / 2, output_box.x + (output_box.width - w) / 2,
output_box.y + (output_box.height - h) / 2); output_box.y + (output_box.height - h) / 2);
} }
static void static void
osd_classic_update(struct output *output) cycle_osd_classic_update(struct output *output)
{ {
struct osd_classic_item *item; struct cycle_osd_classic_item *item;
wl_list_for_each(item, &output->osd_scene.items, base.link) { wl_list_for_each(item, &output->cycle_osd.items, base.link) {
bool active = item->base.view == output->server->osd_state.cycle_view; bool active = item->base.view == output->server->cycle.selected_view;
wlr_scene_node_set_enabled(&item->normal_tree->node, !active); wlr_scene_node_set_enabled(&item->normal_tree->node, !active);
wlr_scene_node_set_enabled(&item->active_tree->node, active); wlr_scene_node_set_enabled(&item->active_tree->node, active);
} }
} }
struct osd_impl osd_classic_impl = { struct cycle_osd_impl cycle_osd_classic_impl = {
.create = osd_classic_create, .create = cycle_osd_classic_create,
.update = osd_classic_update, .update = cycle_osd_classic_update,
}; };

View file

@ -204,11 +204,11 @@ static const struct field_converter field_converter[LAB_FIELD_COUNT] = {
[LAB_FIELD_TITLE] = { 'T', field_set_title }, [LAB_FIELD_TITLE] = { 'T', field_set_title },
[LAB_FIELD_TITLE_SHORT] = { 't', field_set_title_short }, [LAB_FIELD_TITLE_SHORT] = { 't', field_set_title_short },
/* fmt_char can never be matched so prevents LAB_FIELD_CUSTOM recursion */ /* fmt_char can never be matched so prevents LAB_FIELD_CUSTOM recursion */
[LAB_FIELD_CUSTOM] = { '\0', osd_field_set_custom }, [LAB_FIELD_CUSTOM] = { '\0', cycle_osd_field_set_custom },
}; };
void void
osd_field_set_custom(struct buf *buf, struct view *view, const char *format) cycle_osd_field_set_custom(struct buf *buf, struct view *view, const char *format)
{ {
if (!format) { if (!format) {
wlr_log(WLR_ERROR, "Missing format for custom window switcher field"); wlr_log(WLR_ERROR, "Missing format for custom window switcher field");
@ -286,7 +286,7 @@ reset_format:
} }
void void
osd_field_arg_from_xml_node(struct window_switcher_field *field, cycle_osd_field_arg_from_xml_node(struct cycle_osd_field *field,
const char *nodename, const char *content) const char *nodename, const char *content)
{ {
if (!strcmp(nodename, "content")) { if (!strcmp(nodename, "content")) {
@ -332,7 +332,7 @@ osd_field_arg_from_xml_node(struct window_switcher_field *field,
} }
bool bool
osd_field_is_valid(struct window_switcher_field *field) cycle_osd_field_is_valid(struct cycle_osd_field *field)
{ {
if (field->content == LAB_FIELD_NONE) { if (field->content == LAB_FIELD_NONE) {
wlr_log(WLR_ERROR, "Invalid OSD field: no content set"); wlr_log(WLR_ERROR, "Invalid OSD field: no content set");
@ -350,7 +350,7 @@ osd_field_is_valid(struct window_switcher_field *field)
} }
void void
osd_field_get_content(struct window_switcher_field *field, cycle_osd_field_get_content(struct cycle_osd_field *field,
struct buf *buf, struct view *view) struct buf *buf, struct view *view)
{ {
if (field->content == LAB_FIELD_NONE) { if (field->content == LAB_FIELD_NONE) {
@ -363,7 +363,7 @@ osd_field_get_content(struct window_switcher_field *field,
} }
void void
osd_field_free(struct window_switcher_field *field) cycle_osd_field_free(struct cycle_osd_field *field)
{ {
zfree(field->format); zfree(field->format);
zfree(field); zfree(field);

View file

@ -19,8 +19,8 @@
#include "theme.h" #include "theme.h"
#include "view.h" #include "view.h"
struct osd_thumbnail_item { struct cycle_osd_thumbnail_item {
struct osd_item base; struct cycle_osd_item base;
struct scaled_font_buffer *normal_label; struct scaled_font_buffer *normal_label;
struct scaled_font_buffer *active_label; struct scaled_font_buffer *active_label;
struct lab_scene_rect *active_bg; struct lab_scene_rect *active_bg;
@ -102,7 +102,7 @@ create_label(struct wlr_scene_tree *parent, struct view *view,
const float *text_color, const float *bg_color, int y) const float *text_color, const float *bg_color, int y)
{ {
struct buf buf = BUF_INIT; struct buf buf = BUF_INIT;
osd_field_set_custom(&buf, view, cycle_osd_field_set_custom(&buf, view,
rc.window_switcher.thumbnail_label_format); rc.window_switcher.thumbnail_label_format);
struct scaled_font_buffer *buffer = struct scaled_font_buffer *buffer =
scaled_font_buffer_create(parent); scaled_font_buffer_create(parent);
@ -115,7 +115,7 @@ create_label(struct wlr_scene_tree *parent, struct view *view,
return buffer; return buffer;
} }
static struct osd_thumbnail_item * static struct cycle_osd_thumbnail_item *
create_item_scene(struct wlr_scene_tree *parent, struct view *view, create_item_scene(struct wlr_scene_tree *parent, struct view *view,
struct output *output) struct output *output)
{ {
@ -136,10 +136,10 @@ create_item_scene(struct wlr_scene_tree *parent, struct view *view,
return NULL; return NULL;
} }
struct osd_thumbnail_item *item = znew(*item); struct cycle_osd_thumbnail_item *item = znew(*item);
wl_list_append(&output->osd_scene.items, &item->base.link); wl_list_append(&output->cycle_osd.items, &item->base.link);
struct wlr_scene_tree *tree = wlr_scene_tree_create(parent); struct wlr_scene_tree *tree = wlr_scene_tree_create(parent);
node_descriptor_create(&tree->node, LAB_NODE_OSD_ITEM, NULL, item); node_descriptor_create(&tree->node, LAB_NODE_CYCLE_OSD_ITEM, NULL, item);
item->base.tree = tree; item->base.tree = tree;
item->base.view = view; item->base.view = view;
@ -226,9 +226,9 @@ get_items_geometry(struct output *output, struct theme *theme,
} }
static void static void
osd_thumbnail_create(struct output *output, struct wl_array *views) cycle_osd_thumbnail_create(struct output *output, struct wl_array *views)
{ {
assert(!output->osd_scene.tree && wl_list_empty(&output->osd_scene.items)); assert(!output->cycle_osd.tree && wl_list_empty(&output->cycle_osd.items));
struct server *server = output->server; struct server *server = output->server;
struct theme *theme = server->theme; struct theme *theme = server->theme;
@ -236,7 +236,7 @@ osd_thumbnail_create(struct output *output, struct wl_array *views)
&theme->osd_window_switcher_thumbnail; &theme->osd_window_switcher_thumbnail;
int padding = theme->osd_border_width + switcher_theme->padding; int padding = theme->osd_border_width + switcher_theme->padding;
output->osd_scene.tree = wlr_scene_tree_create(output->osd_tree); output->cycle_osd.tree = wlr_scene_tree_create(output->cycle_osd_tree);
int nr_views = wl_array_len(views); int nr_views = wl_array_len(views);
assert(nr_views > 0); assert(nr_views > 0);
@ -247,8 +247,8 @@ osd_thumbnail_create(struct output *output, struct wl_array *views)
struct view **view; struct view **view;
int index = 0; int index = 0;
wl_array_for_each(view, views) { wl_array_for_each(view, views) {
struct osd_thumbnail_item *item = create_item_scene( struct cycle_osd_thumbnail_item *item = create_item_scene(
output->osd_scene.tree, *view, output); output->cycle_osd.tree, *view, output);
if (!item) { if (!item) {
break; break;
} }
@ -268,7 +268,7 @@ osd_thumbnail_create(struct output *output, struct wl_array *views)
.height = nr_rows * switcher_theme->item_height + 2 * padding, .height = nr_rows * switcher_theme->item_height + 2 * padding,
}; };
struct lab_scene_rect *bg = struct lab_scene_rect *bg =
lab_scene_rect_create(output->osd_scene.tree, &bg_opts); lab_scene_rect_create(output->cycle_osd.tree, &bg_opts);
wlr_scene_node_lower_to_bottom(&bg->tree->node); wlr_scene_node_lower_to_bottom(&bg->tree->node);
/* center */ /* center */
@ -277,15 +277,15 @@ osd_thumbnail_create(struct output *output, struct wl_array *views)
&output_box); &output_box);
int lx = output_box.x + (output_box.width - bg_opts.width) / 2; int lx = output_box.x + (output_box.width - bg_opts.width) / 2;
int ly = output_box.y + (output_box.height - bg_opts.height) / 2; int ly = output_box.y + (output_box.height - bg_opts.height) / 2;
wlr_scene_node_set_position(&output->osd_scene.tree->node, lx, ly); wlr_scene_node_set_position(&output->cycle_osd.tree->node, lx, ly);
} }
static void static void
osd_thumbnail_update(struct output *output) cycle_osd_thumbnail_update(struct output *output)
{ {
struct osd_thumbnail_item *item; struct cycle_osd_thumbnail_item *item;
wl_list_for_each(item, &output->osd_scene.items, base.link) { wl_list_for_each(item, &output->cycle_osd.items, base.link) {
bool active = (item->base.view == output->server->osd_state.cycle_view); bool active = (item->base.view == output->server->cycle.selected_view);
wlr_scene_node_set_enabled(&item->active_bg->tree->node, active); wlr_scene_node_set_enabled(&item->active_bg->tree->node, active);
wlr_scene_node_set_enabled( wlr_scene_node_set_enabled(
&item->active_label->scene_buffer->node, active); &item->active_label->scene_buffer->node, active);
@ -294,7 +294,7 @@ osd_thumbnail_update(struct output *output)
} }
} }
struct osd_impl osd_thumbnail_impl = { struct cycle_osd_impl cycle_osd_thumbnail_impl = {
.create = osd_thumbnail_create, .create = cycle_osd_thumbnail_create,
.update = osd_thumbnail_update, .update = cycle_osd_thumbnail_update,
}; };

View file

@ -21,7 +21,7 @@
#define IGNORE_SSD true #define IGNORE_SSD true
#define IGNORE_MENU true #define IGNORE_MENU true
#define IGNORE_OSD_PREVIEW_OUTLINE true #define IGNORE_CYCLE_PREVIEW_OUTLINE true
#define IGNORE_SNAPPING_OVERLAY true #define IGNORE_SNAPPING_OVERLAY true
static struct view *last_view; static struct view *last_view;
@ -118,7 +118,7 @@ get_special(struct server *server, struct wlr_scene_node *node)
if (node->parent == &server->scene->tree) { if (node->parent == &server->scene->tree) {
struct output *output; struct output *output;
wl_list_for_each(output, &server->outputs, link) { wl_list_for_each(output, &server->outputs, link) {
if (node == &output->osd_tree->node) { if (node == &output->cycle_osd_tree->node) {
return "output->osd_tree"; return "output->osd_tree";
} }
if (node == &output->layer_popup_tree->node) { if (node == &output->layer_popup_tree->node) {
@ -150,10 +150,10 @@ get_special(struct server *server, struct wlr_scene_node *node)
/* Created on-demand */ /* Created on-demand */
return "seat->im_relay->popup_tree"; return "seat->im_relay->popup_tree";
} }
if (server->osd_state.preview_outline if (server->cycle.preview_outline
&& node == &server->osd_state.preview_outline->tree->node) { && node == &server->cycle.preview_outline->tree->node) {
/* Created on-demand */ /* Created on-demand */
return "osd_state->preview_outline"; return "cycle_state->preview_outline";
} }
#if HAVE_XWAYLAND #if HAVE_XWAYLAND
if (node == &server->unmanaged_tree->node) { if (node == &server->unmanaged_tree->node) {
@ -216,13 +216,11 @@ dump_tree(struct server *server, struct wlr_scene_node *node,
} }
printf("%.*s %*c %4d %4d [%p]\n", max_width - 1, type, padding, ' ', x, y, node); printf("%.*s %*c %4d %4d [%p]\n", max_width - 1, type, padding, ' ', x, y, node);
struct lab_scene_rect *osd_preview_outline =
server->osd_state.preview_outline;
if ((IGNORE_MENU && node == &server->menu_tree->node) if ((IGNORE_MENU && node == &server->menu_tree->node)
|| (IGNORE_SSD && last_view || (IGNORE_SSD && last_view
&& ssd_debug_is_root_node(last_view->ssd, node)) && ssd_debug_is_root_node(last_view->ssd, node))
|| (IGNORE_OSD_PREVIEW_OUTLINE && osd_preview_outline || (IGNORE_CYCLE_PREVIEW_OUTLINE && server->cycle.preview_outline
&& node == &osd_preview_outline->tree->node) && node == &server->cycle.preview_outline->tree->node)
|| (IGNORE_SNAPPING_OVERLAY && server->seat.overlay.rect || (IGNORE_SNAPPING_OVERLAY && server->seat.overlay.rect
&& node == &server->seat.overlay.rect->tree->node)) { && node == &server->seat.overlay.rect->tree->node)) {
printf("%*c%s\n", pos + 4 + INDENT_SIZE, ' ', "<skipping children>"); printf("%*c%s\n", pos + 4 + INDENT_SIZE, ' ', "<skipping children>");

View file

@ -74,7 +74,7 @@ desktop_focus_view(struct view *view, bool raise)
return; return;
} }
if (view->server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) { if (view->server->input_mode == LAB_INPUT_STATE_CYCLE) {
wlr_log(WLR_DEBUG, "not focusing window while window switching"); wlr_log(WLR_DEBUG, "not focusing window while window switching");
return; return;
} }
@ -340,10 +340,10 @@ get_cursor_context(struct server *server)
ret.node = node; ret.node = node;
ret.type = LAB_NODE_MENUITEM; ret.type = LAB_NODE_MENUITEM;
return ret; return ret;
case LAB_NODE_OSD_ITEM: case LAB_NODE_CYCLE_OSD_ITEM:
/* Always return the top scene node for osd items */ /* Always return the top scene node for osd items */
ret.node = node; ret.node = node;
ret.type = LAB_NODE_OSD_ITEM; ret.type = LAB_NODE_CYCLE_OSD_ITEM;
return ret; return ret;
case LAB_NODE_BUTTON_FIRST...LAB_NODE_BUTTON_LAST: case LAB_NODE_BUTTON_FIRST...LAB_NODE_BUTTON_LAST:
case LAB_NODE_SSD_ROOT: case LAB_NODE_SSD_ROOT:

View file

@ -920,7 +920,7 @@ static void
process_release_mousebinding(struct server *server, process_release_mousebinding(struct server *server,
struct cursor_context *ctx, uint32_t button) struct cursor_context *ctx, uint32_t button)
{ {
if (server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) { if (server->input_mode == LAB_INPUT_STATE_CYCLE) {
return; return;
} }
@ -989,7 +989,7 @@ static bool
process_press_mousebinding(struct server *server, struct cursor_context *ctx, process_press_mousebinding(struct server *server, struct cursor_context *ctx,
uint32_t button) uint32_t button)
{ {
if (server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) { if (server->input_mode == LAB_INPUT_STATE_CYCLE) {
return false; return false;
} }
@ -1157,9 +1157,9 @@ cursor_process_button_release(struct seat *seat, uint32_t button,
} }
return notify; return notify;
} }
if (server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) { if (server->input_mode == LAB_INPUT_STATE_CYCLE) {
if (ctx.type == LAB_NODE_OSD_ITEM) { if (ctx.type == LAB_NODE_CYCLE_OSD_ITEM) {
osd_on_cursor_release(server, ctx.node); cycle_on_cursor_release(server, ctx.node);
} }
return notify; return notify;
} }

View file

@ -141,17 +141,16 @@ handle_modifiers(struct wl_listener *listener, void *data)
overlay_update(seat); overlay_update(seat);
} }
bool window_switcher_active = server->input_mode bool cycling = server->input_mode == LAB_INPUT_STATE_CYCLE;
== LAB_INPUT_STATE_WINDOW_SWITCHER;
if ((window_switcher_active || seat->workspace_osd_shown_by_modifier) if ((cycling || seat->workspace_osd_shown_by_modifier)
&& !keyboard_get_all_modifiers(seat)) { && !keyboard_get_all_modifiers(seat)) {
if (window_switcher_active) { if (cycling) {
if (key_state_nr_bound_keys()) { if (key_state_nr_bound_keys()) {
should_cancel_cycling_on_next_key_release = true; should_cancel_cycling_on_next_key_release = true;
} else { } else {
should_cancel_cycling_on_next_key_release = false; should_cancel_cycling_on_next_key_release = false;
osd_finish(server, /*switch_focus*/ true); cycle_finish(server, /*switch_focus*/ true);
} }
} }
if (seat->workspace_osd_shown_by_modifier) { if (seat->workspace_osd_shown_by_modifier) {
@ -388,7 +387,7 @@ handle_key_release(struct server *server, uint32_t evdev_keycode)
*/ */
if (should_cancel_cycling_on_next_key_release) { if (should_cancel_cycling_on_next_key_release) {
should_cancel_cycling_on_next_key_release = false; should_cancel_cycling_on_next_key_release = false;
osd_finish(server, /*switch_focus*/ true); cycle_finish(server, /*switch_focus*/ true);
} }
/* /*
@ -461,19 +460,19 @@ handle_cycle_view_key(struct server *server, struct keyinfo *keyinfo)
for (int i = 0; i < keyinfo->translated.nr_syms; i++) { for (int i = 0; i < keyinfo->translated.nr_syms; i++) {
if (keyinfo->translated.syms[i] == XKB_KEY_Escape) { if (keyinfo->translated.syms[i] == XKB_KEY_Escape) {
/* Esc deactivates window switcher */ /* Esc deactivates window switcher */
osd_finish(server, /*switch_focus*/ false); cycle_finish(server, /*switch_focus*/ false);
return true; return true;
} }
if (keyinfo->translated.syms[i] == XKB_KEY_Up if (keyinfo->translated.syms[i] == XKB_KEY_Up
|| keyinfo->translated.syms[i] == XKB_KEY_Left) { || keyinfo->translated.syms[i] == XKB_KEY_Left) {
/* Up/Left cycles the window backward */ /* Up/Left cycles the window backward */
osd_cycle(server, LAB_CYCLE_DIR_BACKWARD); cycle_step(server, LAB_CYCLE_DIR_BACKWARD);
return true; return true;
} }
if (keyinfo->translated.syms[i] == XKB_KEY_Down if (keyinfo->translated.syms[i] == XKB_KEY_Down
|| keyinfo->translated.syms[i] == XKB_KEY_Right) { || keyinfo->translated.syms[i] == XKB_KEY_Right) {
/* Down/Right cycles the window forward */ /* Down/Right cycles the window forward */
osd_cycle(server, LAB_CYCLE_DIR_FORWARD); cycle_step(server, LAB_CYCLE_DIR_FORWARD);
return true; return true;
} }
} }
@ -523,7 +522,7 @@ handle_compositor_keybindings(struct keyboard *keyboard,
key_state_store_pressed_key_as_bound(event->keycode); key_state_store_pressed_key_as_bound(event->keycode);
handle_menu_keys(server, &keyinfo.translated); handle_menu_keys(server, &keyinfo.translated);
return LAB_KEY_HANDLED_TRUE; return LAB_KEY_HANDLED_TRUE;
} else if (server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) { } else if (server->input_mode == LAB_INPUT_STATE_CYCLE) {
if (handle_cycle_view_key(server, &keyinfo)) { if (handle_cycle_view_key(server, &keyinfo)) {
key_state_store_pressed_key_as_bound(event->keycode); key_state_store_pressed_key_as_bound(event->keycode);
return LAB_KEY_HANDLED_TRUE; return LAB_KEY_HANDLED_TRUE;

View file

@ -59,13 +59,13 @@ node_menuitem_from_node(struct wlr_scene_node *wlr_scene_node)
return (struct menuitem *)node_descriptor->data; return (struct menuitem *)node_descriptor->data;
} }
struct osd_item * struct cycle_osd_item *
node_osd_item_from_node(struct wlr_scene_node *wlr_scene_node) node_cycle_osd_item_from_node(struct wlr_scene_node *wlr_scene_node)
{ {
assert(wlr_scene_node->data); assert(wlr_scene_node->data);
struct node_descriptor *node_descriptor = wlr_scene_node->data; struct node_descriptor *node_descriptor = wlr_scene_node->data;
assert(node_descriptor->type == LAB_NODE_OSD_ITEM); assert(node_descriptor->type == LAB_NODE_CYCLE_OSD_ITEM);
return (struct osd_item *)node_descriptor->data; return (struct cycle_osd_item *)node_descriptor->data;
} }
struct ssd_button * struct ssd_button *

View file

@ -182,7 +182,7 @@ handle_output_destroy(struct wl_listener *listener, void *data)
wlr_scene_node_destroy(&output->layer_tree[i]->node); wlr_scene_node_destroy(&output->layer_tree[i]->node);
} }
wlr_scene_node_destroy(&output->layer_popup_tree->node); wlr_scene_node_destroy(&output->layer_popup_tree->node);
wlr_scene_node_destroy(&output->osd_tree->node); wlr_scene_node_destroy(&output->cycle_osd_tree->node);
wlr_scene_node_destroy(&output->session_lock_tree->node); wlr_scene_node_destroy(&output->session_lock_tree->node);
if (output->workspace_osd) { if (output->workspace_osd) {
wlr_scene_node_destroy(&output->workspace_osd->node); wlr_scene_node_destroy(&output->workspace_osd->node);
@ -542,7 +542,7 @@ handle_new_output(struct wl_listener *listener, void *data)
wl_signal_add(&wlr_output->events.request_state, &output->request_state); wl_signal_add(&wlr_output->events.request_state, &output->request_state);
wl_list_init(&output->regions); wl_list_init(&output->regions);
wl_list_init(&output->osd_scene.items); wl_list_init(&output->cycle_osd.items);
/* /*
* Create layer-trees (background, bottom, top and overlay) and * Create layer-trees (background, bottom, top and overlay) and
@ -553,7 +553,7 @@ handle_new_output(struct wl_listener *listener, void *data)
wlr_scene_tree_create(&server->scene->tree); wlr_scene_tree_create(&server->scene->tree);
} }
output->layer_popup_tree = wlr_scene_tree_create(&server->scene->tree); output->layer_popup_tree = wlr_scene_tree_create(&server->scene->tree);
output->osd_tree = wlr_scene_tree_create(&server->scene->tree); output->cycle_osd_tree = wlr_scene_tree_create(&server->scene->tree);
output->session_lock_tree = wlr_scene_tree_create(&server->scene->tree); output->session_lock_tree = wlr_scene_tree_create(&server->scene->tree);
/* /*
@ -577,7 +577,7 @@ handle_new_output(struct wl_listener *listener, void *data)
wlr_scene_node_place_below(&output->layer_tree[3]->node, menu_node); wlr_scene_node_place_below(&output->layer_tree[3]->node, menu_node);
wlr_scene_node_place_below(&output->layer_popup_tree->node, menu_node); wlr_scene_node_place_below(&output->layer_popup_tree->node, menu_node);
wlr_scene_node_raise_to_top(&output->osd_tree->node); wlr_scene_node_raise_to_top(&output->cycle_osd_tree->node);
wlr_scene_node_raise_to_top(&output->session_lock_tree->node); wlr_scene_node_raise_to_top(&output->session_lock_tree->node);
/* /*

View file

@ -562,21 +562,21 @@ server_init(struct server *server)
* z-order for nodes which cover the whole work-area. For per-output * z-order for nodes which cover the whole work-area. For per-output
* scene-trees, see handle_new_output() in src/output.c * scene-trees, see handle_new_output() in src/output.c
* *
* | Type | Scene Tree | Per Output | Example * | Type | Scene Tree | Per Output | Example
* | ----------------- | ---------------- | ---------- | ------- * | ------------------- | ---------------- | ---------- | -------
* | ext-session | lock-screen | Yes | swaylock * | ext-session | lock-screen | Yes | swaylock
* | osd | osd_tree | Yes | * | window switcher OSD | cycle_osd_tree | Yes |
* | compositor-menu | menu_tree | No | root-menu * | compositor-menu | menu_tree | No | root-menu
* | layer-shell | layer-popups | Yes | * | layer-shell | layer-popups | Yes |
* | layer-shell | overlay-layer | Yes | * | layer-shell | overlay-layer | Yes |
* | layer-shell | top-layer | Yes | waybar * | layer-shell | top-layer | Yes | waybar
* | xwayland-OR | unmanaged | No | dmenu * | xwayland-OR | unmanaged | No | dmenu
* | xdg-popups | xdg-popups | No | * | xdg-popups | xdg-popups | No |
* | toplevels windows | always-on-top | No | * | toplevels windows | always-on-top | No |
* | toplevels windows | normal | No | firefox * | toplevels windows | normal | No | firefox
* | toplevels windows | always-on-bottom | No | pcmanfm-qt --desktop * | toplevels windows | always-on-bottom | No | pcmanfm-qt --desktop
* | layer-shell | bottom-layer | Yes | waybar * | layer-shell | bottom-layer | Yes | waybar
* | layer-shell | background-layer | Yes | swaybg * | layer-shell | background-layer | Yes | swaybg
*/ */
server->view_tree_always_on_bottom = wlr_scene_tree_create(&server->scene->tree); server->view_tree_always_on_bottom = wlr_scene_tree_create(&server->scene->tree);

View file

@ -823,7 +823,7 @@ view_minimize(struct view *view, bool minimized)
{ {
assert(view); assert(view);
if (view->server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) { if (view->server->input_mode == LAB_INPUT_STATE_CYCLE) {
wlr_log(WLR_ERROR, "not minimizing window while window switching"); wlr_log(WLR_ERROR, "not minimizing window while window switching");
return; return;
} }
@ -2620,7 +2620,7 @@ view_destroy(struct view *view)
zfree(view->tiled_region_evacuate); zfree(view->tiled_region_evacuate);
} }
osd_on_view_destroy(view); cycle_on_view_destroy(view);
undecorate(view); undecorate(view);
view_set_icon(view, NULL, NULL); view_set_icon(view, NULL, NULL);