core: 添加 output 索引循环切换接口

This commit is contained in:
2026-04-11 05:56:49 +08:00
parent 3a6525087d
commit d73d5b0b1f
2 changed files with 11 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
#include "core/state.h"
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <zdwm/types.h>
@@ -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;

View File

@@ -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 集合接口