]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cycle: factor out get_osd_impl()
authortokyo4j <hrak1529@gmail.com>
Sun, 30 Nov 2025 13:07:18 +0000 (22:07 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 30 Nov 2025 21:33:46 +0000 (21:33 +0000)
src/cycle/cycle.c

index cb32915077c279e4e5e752fe23f7244774da6e8a..9d5750d450cd265805308dc2bc915da5f4870f38 100644 (file)
@@ -257,18 +257,29 @@ preview_selected_view(struct view *view)
        wlr_scene_node_raise_to_top(cycle->preview_node);
 }
 
+static struct cycle_osd_impl *
+get_osd_impl(void)
+{
+       switch (rc.window_switcher.style) {
+       case CYCLE_OSD_STYLE_CLASSIC:
+               return &cycle_osd_classic_impl;
+       case CYCLE_OSD_STYLE_THUMBNAIL:
+               return &cycle_osd_thumbnail_impl;
+       }
+       return NULL;
+}
+
 static void
-update_osd_on_output(struct server *server, struct output *output,
-       struct cycle_osd_impl *osd_impl, struct wl_array *views)
+update_osd_on_output(struct output *output, struct wl_array *views)
 {
        if (!output_is_usable(output)) {
                return;
        }
        if (!output->cycle_osd.tree) {
-               osd_impl->create(output, views);
+               get_osd_impl()->create(output, views);
                assert(output->cycle_osd.tree);
        }
-       osd_impl->update(output);
+       get_osd_impl()->update(output);
 }
 
 static void
@@ -278,16 +289,6 @@ update_cycle(struct server *server)
        wl_array_init(&views);
        view_array_append(server, &views, rc.window_switcher.criteria);
 
-       struct cycle_osd_impl *osd_impl = NULL;
-       switch (rc.window_switcher.style) {
-       case CYCLE_OSD_STYLE_CLASSIC:
-               osd_impl = &cycle_osd_classic_impl;
-               break;
-       case CYCLE_OSD_STYLE_THUMBNAIL:
-               osd_impl = &cycle_osd_thumbnail_impl;
-               break;
-       }
-
        if (!wl_array_len(&views) || !server->cycle.selected_view) {
                cycle_finish(server, /*switch_focus*/ false);
                goto out;
@@ -299,13 +300,12 @@ update_cycle(struct server *server)
                case CYCLE_OSD_OUTPUT_ALL: {
                        struct output *output;
                        wl_list_for_each(output, &server->outputs, link) {
-                               update_osd_on_output(server, output, osd_impl, &views);
+                               update_osd_on_output(output, &views);
                        }
                        break;
                }
                case CYCLE_OSD_OUTPUT_POINTER:
-                       update_osd_on_output(server,
-                               output_nearest_to_cursor(server), osd_impl, &views);
+                       update_osd_on_output(output_nearest_to_cursor(server), &views);
                        break;
                case CYCLE_OSD_OUTPUT_KEYBOARD: {
                        struct output *output;
@@ -315,7 +315,7 @@ update_cycle(struct server *server)
                                /* Fallback to pointer, if there is no active_view */
                                output = output_nearest_to_cursor(server);
                        }
-                       update_osd_on_output(server, output, osd_impl, &views);
+                       update_osd_on_output(output, &views);
                        break;
                }
                }