feat(action): 绑定 toggle_fullscreen/maximize/floating 快捷键
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#include <zdwm/action.h>
|
||||
#include <zdwm/types.h>
|
||||
|
||||
#include "base/log.h"
|
||||
#include "base/macros.h"
|
||||
|
||||
static constexpr char launcher[] =
|
||||
@@ -32,7 +31,6 @@ static void quit(
|
||||
const zdwm_action_api_t *api,
|
||||
const zdwm_action_arg_t *arg
|
||||
) {
|
||||
logger("quit: restart: %s\n", arg->b ? "true" : "false");
|
||||
api->quit(runtime, arg->b);
|
||||
}
|
||||
|
||||
@@ -45,6 +43,30 @@ static void raise_or_run(
|
||||
api->raise_or_run(runtime, args->class_name, args->command);
|
||||
}
|
||||
|
||||
static void toggle_fullscreen(
|
||||
zdwm_runtime_t *runtime,
|
||||
const zdwm_action_api_t *api,
|
||||
const zdwm_action_arg_t *arg
|
||||
) {
|
||||
api->toggle_fullscreen(runtime);
|
||||
}
|
||||
|
||||
static void toggle_maximize(
|
||||
zdwm_runtime_t *runtime,
|
||||
const zdwm_action_api_t *api,
|
||||
const zdwm_action_arg_t *arg
|
||||
) {
|
||||
api->toggle_maximize(runtime);
|
||||
}
|
||||
|
||||
static void toggle_floating(
|
||||
zdwm_runtime_t *runtime,
|
||||
const zdwm_action_api_t *api,
|
||||
const zdwm_action_arg_t *arg
|
||||
) {
|
||||
api->toggle_floating(runtime);
|
||||
}
|
||||
|
||||
bool config_defaults_build(
|
||||
const zdwm_api_t *api,
|
||||
zdwm_config_builder_t *builder,
|
||||
@@ -118,6 +140,9 @@ bool config_defaults_build(
|
||||
BIND(default_mode, Super "+e", raise_or_run, {.ptr = &editor});
|
||||
BIND(default_mode, Super "+q", raise_or_run, {.ptr = &browser});
|
||||
BIND(default_mode, Super "+a", raise_or_run, {.ptr = &chrome});
|
||||
BIND(default_mode, Super "+f", toggle_fullscreen, {0});
|
||||
BIND(default_mode, Super "+m", toggle_maximize, {0});
|
||||
BIND(default_mode, Super "+Control+space", toggle_floating, {0});
|
||||
|
||||
#undef BIND
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ void cycle_layout(runtime_t *runtime, int32_t delta) {
|
||||
runtime->plan.need_relayout = true;
|
||||
}
|
||||
|
||||
void cycle_current_output(zdwm_runtime_t *runtime, int32_t delta) {
|
||||
void cycle_current_output(runtime_t *runtime, int32_t delta) {
|
||||
auto state = &runtime->state;
|
||||
state_cycle_current_output(state, delta);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/runtime.h"
|
||||
#include <stdint.h>
|
||||
#include <zdwm/action.h>
|
||||
|
||||
void spawn(const char *command);
|
||||
void quit(runtime_t *runtime, bool restart);
|
||||
void quit(zdwm_runtime_t *runtime, bool restart);
|
||||
void raise_or_run(
|
||||
zdwm_runtime_t *runtime,
|
||||
const char *class_name,
|
||||
const char *command
|
||||
);
|
||||
|
||||
void toggle_fullscreen(zdwm_runtime_t *runtime);
|
||||
void toggle_maximize(zdwm_runtime_t *runtime);
|
||||
void toggle_floating(zdwm_runtime_t *runtime);
|
||||
void toggle_sticky(zdwm_runtime_t *runtime);
|
||||
void switch_workspace(
|
||||
zdwm_runtime_t *runtime,
|
||||
zdwm_workspace_id_t workspace_id
|
||||
);
|
||||
void cycle_layout(zdwm_runtime_t *runtime, int32_t delta);
|
||||
void cycle_current_output(zdwm_runtime_t *runtime, int32_t delta);
|
||||
|
||||
@@ -275,6 +275,13 @@ void runtime_run(runtime_t *runtime) {
|
||||
.spawn = spawn,
|
||||
.quit = quit,
|
||||
.raise_or_run = raise_or_run,
|
||||
.toggle_fullscreen = toggle_fullscreen,
|
||||
.toggle_maximize = toggle_maximize,
|
||||
.toggle_floating = toggle_floating,
|
||||
.toggle_sticky = toggle_sticky,
|
||||
.switch_workspace = switch_workspace,
|
||||
.cycle_layout = cycle_layout,
|
||||
.cycle_current_output = cycle_current_output,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user