diff --git a/src/config/defaults.c b/src/config/defaults.c index a4ed91e..4fef215 100644 --- a/src/config/defaults.c +++ b/src/config/defaults.c @@ -3,7 +3,6 @@ #include #include -#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 diff --git a/src/core/action.c b/src/core/action.c index 111c4a5..8a5f75e 100644 --- a/src/core/action.c +++ b/src/core/action.c @@ -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); } diff --git a/src/core/action.h b/src/core/action.h index fa6b4de..3842c2d 100644 --- a/src/core/action.h +++ b/src/core/action.h @@ -1,11 +1,23 @@ #pragma once -#include "core/runtime.h" +#include +#include 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); diff --git a/src/core/runtime.c b/src/core/runtime.c index 4bcd8df..12cde03 100644 --- a/src/core/runtime.c +++ b/src/core/runtime.c @@ -272,9 +272,16 @@ void runtime_run(runtime_t *runtime) { .layouts = &runtime->layouts, .runtime = runtime, .action_api = { - .spawn = spawn, - .quit = quit, - .raise_or_run = raise_or_run, + .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, }, };