mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-16 18:49:15 +02:00
This is a major release and includes BREAKING changes! Breaking Changes: * More intuitive switch of focus, next, prev and exchange (#20, 40 in Bugs.md) Cagebreak will probably still feel broadly the same though. * Remove -r flag - This is replaced by output configuration. * Socket disabled by default - The socket is enabled by invoking Cagebreak with the -e flag. * Socket permissions restricted to the user of the Cagebreak process (700) This may require modification of scripts interacting with the socket with different UIDs than the UID of the Cagebreak process. * Rename "Current frame" indicator to "Current tile" Changelog: * Move to wlr_scene * Add events displaying change over the socket * this enables scripting tools * Add support for scaling outputs (thanks to Oliver Friedmann) * Remove -r flag * Add rotation to output configuration * Add cursor enable|disable flag * Add input keyboard configuration * Custom path flag for configuration file * Restrict socket permissions to the user running cagebreak (700) * Fix Issue #31 (resolve some terminology) 38 in Bugs.md * Fix Issue #30 - 39 in Bugs.md * Fix Issue #20 - 40 in Bugs.md * Fix Issue #12 - 41 in Bugs.md (dump + events over socket) * Fix Bugs found via scan-build static analysis (42 - 45 in Bugs.md) * Fix Issue #33 - 46 in Bugs.md * Fix Issue #32 - 47 in Bugs.md * Fix Issue #16 - 48 in Bugs.md * Fix Issue #3 - 49 in Bugs.md (disabling keybinding interpretation for specific keyboards is now possible) * Fix Issue #26 - 50 in Bugs.md * Fix Issue #7 - 51 in Bugs.md (Change cursor to square while Cagebreak is waiting for a key) * Fix config bug for some commands - 52 in Bugs.md * Fix Issue #35 - 53 in Bugs.md (update to wlroots 0.16.1) * Improve FAQ.md (related to some Issues) * Disable outputs when unable to set any mode (crashed previously) * Add Code of Conduct * Print version number on startup
144 lines
7.2 KiB
C
144 lines
7.2 KiB
C
// Copyright 2020 - 2023, project-repo and the cagebreak contributors
|
|
// SPDX -License-Identifier: MIT
|
|
|
|
#ifndef KEYBINDING_H
|
|
|
|
#define KEYBINDING_H
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <xkbcommon/xkbcommon.h>
|
|
|
|
struct cg_server;
|
|
|
|
#define FOREACH_KEYBINDING(KEYBINDING) \
|
|
KEYBINDING(KEYBINDING_RUN_COMMAND, \
|
|
exec) /* data.c is the string to execute */ \
|
|
KEYBINDING(KEYBINDING_CLOSE_VIEW, close) \
|
|
KEYBINDING(KEYBINDING_SPLIT_VERTICAL, vsplit) \
|
|
KEYBINDING(KEYBINDING_SPLIT_HORIZONTAL, hsplit) \
|
|
KEYBINDING(KEYBINDING_CHANGE_TTY, switchvt) /*data.u is the desired tty*/ \
|
|
KEYBINDING(KEYBINDING_LAYOUT_FULLSCREEN, only) \
|
|
KEYBINDING(KEYBINDING_CYCLE_VIEWS, \
|
|
cycle_views) /* data.b is 0 if forward, 1 if reverse */ \
|
|
KEYBINDING(KEYBINDING_CYCLE_TILES, \
|
|
cycle_tiles) /* data.b is 0 if forward, 1 if reverse */ \
|
|
KEYBINDING(KEYBINDING_CYCLE_OUTPUT, \
|
|
cycle_outputs) /* data.b is 0 if forward, 1 if reverse */ \
|
|
KEYBINDING(KEYBINDING_CONFIGURE_OUTPUT, \
|
|
output) /* data.o_cfg is the desired output */ \
|
|
\
|
|
KEYBINDING(KEYBINDING_CONFIGURE_MESSAGE, \
|
|
configure_message) /* data.m_cfg is the desired config */ \
|
|
KEYBINDING(KEYBINDING_CONFIGURE_INPUT, \
|
|
input) /* data.i_cfg is the desired input configuration */ \
|
|
\
|
|
KEYBINDING(KEYBINDING_QUIT, quit) \
|
|
KEYBINDING(KEYBINDING_NOOP, abort) \
|
|
KEYBINDING(KEYBINDING_SWITCH_OUTPUT, \
|
|
screen) /* data.u is the desired output */ \
|
|
KEYBINDING(KEYBINDING_SWITCH_WORKSPACE, \
|
|
workspace) /* data.u is the desired workspace */ \
|
|
KEYBINDING(KEYBINDING_SWITCH_MODE, mode) /* data.u is the desired mode */ \
|
|
KEYBINDING(KEYBINDING_SWITCH_DEFAULT_MODE, \
|
|
setmode) /* data.u is the desired mode */ \
|
|
KEYBINDING( \
|
|
KEYBINDING_RESIZE_TILE_HORIZONTAL, \
|
|
resize_tile_horizontal) /* data.i is the number of pixels to add */ \
|
|
\
|
|
KEYBINDING( \
|
|
KEYBINDING_RESIZE_TILE_VERTICAL, \
|
|
resize_tile_vertical) /* data.i is the number of pixels to add to */ \
|
|
\
|
|
KEYBINDING(KEYBINDING_MOVE_VIEW_TO_WORKSPACE, \
|
|
movetoworkspace) /* data.u is the desired workspace */ \
|
|
KEYBINDING(KEYBINDING_MOVE_VIEW_TO_OUTPUT, \
|
|
movetoscreen) /* data.u is the desired output */ \
|
|
KEYBINDING(KEYBINDING_MOVE_VIEW_TO_CYCLE_OUTPUT, \
|
|
move_view_to_cycle_output) /* data.b is 0 if forward, 1 if */ \
|
|
\
|
|
KEYBINDING(KEYBINDING_DUMP, dump) \
|
|
KEYBINDING(KEYBINDING_SHOW_TIME, time) \
|
|
KEYBINDING(KEYBINDING_SHOW_INFO, show_info) \
|
|
KEYBINDING(KEYBINDING_DISPLAY_MESSAGE, message) \
|
|
KEYBINDING(KEYBINDING_CURSOR, cursor) \
|
|
\
|
|
KEYBINDING(KEYBINDING_SWAP_LEFT, exchangeleft) \
|
|
KEYBINDING(KEYBINDING_SWAP_RIGHT, exchangeright) \
|
|
KEYBINDING(KEYBINDING_SWAP_TOP, exchangeup) \
|
|
KEYBINDING(KEYBINDING_SWAP_BOTTOM, exchangedown) \
|
|
\
|
|
KEYBINDING(KEYBINDING_FOCUS_LEFT, focusleft) \
|
|
KEYBINDING(KEYBINDING_FOCUS_RIGHT, focusright) \
|
|
KEYBINDING(KEYBINDING_FOCUS_TOP, focusup) \
|
|
KEYBINDING(KEYBINDING_FOCUS_BOTTOM, focusdown) \
|
|
KEYBINDING(KEYBINDING_FOCUS_TILE, focus_tile) \
|
|
\
|
|
KEYBINDING(KEYBINDING_DEFINEKEY, \
|
|
definekey) /* data.kb is the keybinding definition */ \
|
|
KEYBINDING(KEYBINDING_BACKGROUND, \
|
|
background) /* data.color is the background color */ \
|
|
KEYBINDING(KEYBINDING_DEFINEMODE, \
|
|
definemode) /* data.c is the mode name */ \
|
|
KEYBINDING(KEYBINDING_WORKSPACES, \
|
|
workspaces) /* data.i is the number of workspaces */
|
|
|
|
#define GENERATE_ENUM(ENUM, NAME) ENUM,
|
|
#define GENERATE_STRING(STRING, NAME) #NAME,
|
|
|
|
/* Important: if you add a keybinding which uses data.c or requires "free"
|
|
* to be called, don't forget to add it to the function "keybinding_list_free"
|
|
* in keybinding.c */
|
|
enum keybinding_action { FOREACH_KEYBINDING(GENERATE_ENUM) };
|
|
|
|
extern char *keybinding_action_string[];
|
|
|
|
union keybinding_params {
|
|
char *c;
|
|
uint32_t u;
|
|
int32_t i;
|
|
bool b;
|
|
float color[3];
|
|
struct keybinding *kb;
|
|
struct cg_output_config *o_cfg;
|
|
struct cg_input_config *i_cfg;
|
|
struct cg_message_config *m_cfg;
|
|
};
|
|
|
|
struct keybinding {
|
|
uint16_t mode;
|
|
xkb_mod_mask_t modifiers;
|
|
xkb_keysym_t key;
|
|
enum keybinding_action action;
|
|
union keybinding_params data; // See enum keybinding_action for details
|
|
};
|
|
|
|
struct keybinding_list {
|
|
uint32_t length;
|
|
uint32_t capacity;
|
|
struct keybinding **keybindings;
|
|
};
|
|
|
|
int
|
|
keybinding_list_push(struct keybinding_list *list,
|
|
struct keybinding *keybinding);
|
|
void
|
|
keybinding_list_free(struct keybinding_list *list);
|
|
void
|
|
keybinding_cycle_outputs(struct cg_server *server, bool reverse,
|
|
bool trigger_event);
|
|
struct keybinding **
|
|
find_keybinding(const struct keybinding_list *list,
|
|
const struct keybinding *keybinding);
|
|
struct keybinding_list *
|
|
keybinding_list_init();
|
|
|
|
int
|
|
run_action(enum keybinding_action action, struct cg_server *server,
|
|
union keybinding_params data);
|
|
void
|
|
keybinding_free(struct keybinding *keybinding, bool recursive);
|
|
|
|
#endif /* end of include guard KEYBINDINGS_H */
|