feat:add global shortcut pass

This commit is contained in:
DreamMaoMao 2025-03-14 12:54:44 +08:00
parent 16fa2cad95
commit b1b5a6d57a
5 changed files with 114 additions and 8 deletions

View file

@ -7,6 +7,13 @@
#define SYSCONFDIR "/etc"
#endif
typedef struct {
uint32_t mod;
xkb_keysym_t keysym;
void (*func)(const Arg *);
Arg arg;
} KeyBinding;
typedef struct {
const char *id;
const char *title;
@ -22,6 +29,9 @@ typedef struct {
int height;
int isterm;
int noswallow;
uint32_t passmod;
xkb_keysym_t keysym;
KeyBinding globalkeybinding;
} ConfigWinRule;
typedef struct {
@ -36,13 +46,6 @@ typedef struct {
int noswallow;
} ConfigMonitorRule;
typedef struct {
uint32_t mod;
xkb_keysym_t keysym;
void (*func)(const Arg *);
Arg arg;
} KeyBinding;
// 定义一个宏来简化默认按键绑定的添加
#define CHVT(n) \
{ \
@ -802,6 +805,7 @@ void parse_config_line(Config *config, const char *line) {
rule->id = NULL;
rule->title = NULL;
rule->tags = 0;
rule->globalkeybinding = (KeyBinding){0};
char *token = strtok(value, ",");
while (token != NULL) {
@ -839,6 +843,11 @@ void parse_config_line(Config *config, const char *line) {
rule->scroller_proportion = atof(val);
} else if (strcmp(key, "isfullscreen") == 0) {
rule->isfullscreen = atoi(val);
} else if (strcmp(key, "globalkeybinding") == 0) {
char mod_str[256], keysym_str[256];
sscanf(val, "%[^-]-%[a-zA-Z]", mod_str, keysym_str);
rule->globalkeybinding.mod = parse_mod(mod_str);
rule->globalkeybinding.keysym = parse_keysym(keysym_str);
}
}
token = strtok(NULL, ",");