From d73d5b0b1fb9ecb15459e98ab43ac0a77fff5021 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Sat, 11 Apr 2026 05:56:49 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E6=B7=BB=E5=8A=A0=20output=20=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E5=BE=AA=E7=8E=AF=E5=88=87=E6=8D=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/state.c | 9 +++++++++ src/core/state.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/core/state.c b/src/core/state.c index d8faebc..40da138 100644 --- a/src/core/state.c +++ b/src/core/state.c @@ -1,6 +1,7 @@ #include "core/state.h" #include +#include #include #include @@ -267,6 +268,14 @@ bool state_output_valid(const state_t *state, output_id_t id) { #endif } +void state_cycle_current_output(state_t *state, int delta) { + int64_t count = (int64_t)state->output_count; + int64_t current = (int64_t)state->current_output_index; + int64_t next = (current + (int64_t)delta) % count; + if (next < 0) next += count; + state->current_output_index = (size_t)next; +} + static inline void window_set_geometry_mode( window_t *window, window_geometry_mode_t geometry_mode) { window->geometry_mode = geometry_mode; diff --git a/src/core/state.h b/src/core/state.h index d8c43a1..ee156af 100644 --- a/src/core/state.h +++ b/src/core/state.h @@ -65,6 +65,7 @@ typedef struct state_t { output_t *outputs; size_t output_count; + size_t current_output_index; window_t *windows; size_t window_count; @@ -129,6 +130,7 @@ void state_output_set_current_workspace(state_t *state, output_id_t output_id, workspace_id_t workspace_id); size_t state_output_count(const state_t *state); bool state_output_valid(const state_t *state, output_id_t id); +void state_cycle_current_output(state_t *state, int delta); /* * state 持有的 window 集合接口