mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
opt: allow bind multi action to one keybind
This commit is contained in:
parent
1863eb0182
commit
1d4138412a
5 changed files with 367 additions and 291 deletions
|
|
@ -29,7 +29,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t mod;
|
uint32_t mod;
|
||||||
KeySymCode keysymcode;
|
KeySymCode keysymcode;
|
||||||
void (*func)(const Arg *);
|
int (*func)(const Arg *);
|
||||||
Arg arg;
|
Arg arg;
|
||||||
char mode[28];
|
char mode[28];
|
||||||
bool iscommonmode;
|
bool iscommonmode;
|
||||||
|
|
@ -110,20 +110,20 @@ KeyBinding default_key_bindings[] = {CHVT(1), CHVT(2), CHVT(3), CHVT(4),
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int mod;
|
unsigned int mod;
|
||||||
unsigned int button;
|
unsigned int button;
|
||||||
void (*func)(const Arg *);
|
int (*func)(const Arg *);
|
||||||
Arg arg;
|
Arg arg;
|
||||||
} MouseBinding;
|
} MouseBinding;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int mod;
|
unsigned int mod;
|
||||||
unsigned int dir;
|
unsigned int dir;
|
||||||
void (*func)(const Arg *);
|
int (*func)(const Arg *);
|
||||||
Arg arg;
|
Arg arg;
|
||||||
} AxisBinding;
|
} AxisBinding;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int fold;
|
unsigned int fold;
|
||||||
void (*func)(const Arg *);
|
int (*func)(const Arg *);
|
||||||
Arg arg;
|
Arg arg;
|
||||||
} SwitchBinding;
|
} SwitchBinding;
|
||||||
|
|
||||||
|
|
@ -131,7 +131,7 @@ typedef struct {
|
||||||
unsigned int mod;
|
unsigned int mod;
|
||||||
unsigned int motion;
|
unsigned int motion;
|
||||||
unsigned int fingers_count;
|
unsigned int fingers_count;
|
||||||
void (*func)(const Arg *);
|
int (*func)(const Arg *);
|
||||||
Arg arg;
|
Arg arg;
|
||||||
} GestureBinding;
|
} GestureBinding;
|
||||||
|
|
||||||
|
|
@ -325,7 +325,7 @@ typedef struct {
|
||||||
|
|
||||||
} Config;
|
} Config;
|
||||||
|
|
||||||
typedef void (*FuncType)(const Arg *);
|
typedef int (*FuncType)(const Arg *);
|
||||||
Config config;
|
Config config;
|
||||||
|
|
||||||
void parse_config_file(Config *config, const char *file_path);
|
void parse_config_file(Config *config, const char *file_path);
|
||||||
|
|
@ -3032,7 +3032,8 @@ void reset_option(void) {
|
||||||
arrange(selmon, false);
|
arrange(selmon, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reload_config(const Arg *arg) {
|
int reload_config(const Arg *arg) {
|
||||||
parse_config();
|
parse_config();
|
||||||
reset_option();
|
reset_option();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,67 +1,67 @@
|
||||||
void minimized(const Arg *arg);
|
int minimized(const Arg *arg);
|
||||||
void restore_minimized(const Arg *arg);
|
int restore_minimized(const Arg *arg);
|
||||||
void toggle_scratchpad(const Arg *arg);
|
int toggle_scratchpad(const Arg *arg);
|
||||||
void focusdir(const Arg *arg);
|
int focusdir(const Arg *arg);
|
||||||
void toggleoverview(const Arg *arg);
|
int toggleoverview(const Arg *arg);
|
||||||
void set_proportion(const Arg *arg);
|
int set_proportion(const Arg *arg);
|
||||||
void increase_proportion(const Arg *arg);
|
int increase_proportion(const Arg *arg);
|
||||||
void switch_proportion_preset(const Arg *arg);
|
int switch_proportion_preset(const Arg *arg);
|
||||||
void zoom(const Arg *arg);
|
int zoom(const Arg *arg);
|
||||||
void tagsilent(const Arg *arg);
|
int tagsilent(const Arg *arg);
|
||||||
void tagtoleft(const Arg *arg);
|
int tagtoleft(const Arg *arg);
|
||||||
void tagtoright(const Arg *arg);
|
int tagtoright(const Arg *arg);
|
||||||
void viewtoleft(const Arg *arg);
|
int viewtoleft(const Arg *arg);
|
||||||
void viewtoright(const Arg *arg);
|
int viewtoright(const Arg *arg);
|
||||||
void viewtoleft_have_client(const Arg *arg);
|
int viewtoleft_have_client(const Arg *arg);
|
||||||
void viewtoright_have_client(const Arg *arg);
|
int viewtoright_have_client(const Arg *arg);
|
||||||
void togglefloating(const Arg *arg);
|
int togglefloating(const Arg *arg);
|
||||||
void togglefullscreen(const Arg *arg);
|
int togglefullscreen(const Arg *arg);
|
||||||
void togglemaxmizescreen(const Arg *arg);
|
int togglemaxmizescreen(const Arg *arg);
|
||||||
void togglegaps(const Arg *arg);
|
int togglegaps(const Arg *arg);
|
||||||
void tagmon(const Arg *arg);
|
int tagmon(const Arg *arg);
|
||||||
void spawn(const Arg *arg);
|
int spawn(const Arg *arg);
|
||||||
void spawn_shell(const Arg *arg);
|
int spawn_shell(const Arg *arg);
|
||||||
void spawn_on_empty(const Arg *arg);
|
int spawn_on_empty(const Arg *arg);
|
||||||
void setkeymode(const Arg *arg);
|
int setkeymode(const Arg *arg);
|
||||||
void setlayout(const Arg *arg);
|
int setlayout(const Arg *arg);
|
||||||
void switch_layout(const Arg *arg);
|
int switch_layout(const Arg *arg);
|
||||||
void switch_keyboard_layout(const Arg *arg);
|
int switch_keyboard_layout(const Arg *arg);
|
||||||
void setmfact(const Arg *arg);
|
int setmfact(const Arg *arg);
|
||||||
void quit(const Arg *arg);
|
int quit(const Arg *arg);
|
||||||
void moveresize(const Arg *arg);
|
int moveresize(const Arg *arg);
|
||||||
void exchange_client(const Arg *arg);
|
int exchange_client(const Arg *arg);
|
||||||
void exchange_stack_client(const Arg *arg);
|
int exchange_stack_client(const Arg *arg);
|
||||||
void killclient(const Arg *arg);
|
int killclient(const Arg *arg);
|
||||||
void toggleglobal(const Arg *arg);
|
int toggleglobal(const Arg *arg);
|
||||||
void incnmaster(const Arg *arg);
|
int incnmaster(const Arg *arg);
|
||||||
void focusmon(const Arg *arg);
|
int focusmon(const Arg *arg);
|
||||||
void focusstack(const Arg *arg);
|
int focusstack(const Arg *arg);
|
||||||
void chvt(const Arg *arg);
|
int chvt(const Arg *arg);
|
||||||
void reload_config(const Arg *arg);
|
int reload_config(const Arg *arg);
|
||||||
void smartmovewin(const Arg *arg);
|
int smartmovewin(const Arg *arg);
|
||||||
void smartresizewin(const Arg *arg);
|
int smartresizewin(const Arg *arg);
|
||||||
void centerwin(const Arg *arg);
|
int centerwin(const Arg *arg);
|
||||||
void bind_to_view(const Arg *arg);
|
int bind_to_view(const Arg *arg);
|
||||||
void toggletag(const Arg *arg);
|
int toggletag(const Arg *arg);
|
||||||
void toggleview(const Arg *arg);
|
int toggleview(const Arg *arg);
|
||||||
void tag(const Arg *arg);
|
int tag(const Arg *arg);
|
||||||
void comboview(const Arg *arg);
|
int comboview(const Arg *arg);
|
||||||
void incgaps(const Arg *arg);
|
int incgaps(const Arg *arg);
|
||||||
void incigaps(const Arg *arg);
|
int incigaps(const Arg *arg);
|
||||||
void incihgaps(const Arg *arg);
|
int incihgaps(const Arg *arg);
|
||||||
void incivgaps(const Arg *arg);
|
int incivgaps(const Arg *arg);
|
||||||
void incogaps(const Arg *arg);
|
int incogaps(const Arg *arg);
|
||||||
void incohgaps(const Arg *arg);
|
int incohgaps(const Arg *arg);
|
||||||
void incovgaps(const Arg *arg);
|
int incovgaps(const Arg *arg);
|
||||||
void defaultgaps(const Arg *arg);
|
int defaultgaps(const Arg *arg);
|
||||||
void togglefakefullscreen(const Arg *arg);
|
int togglefakefullscreen(const Arg *arg);
|
||||||
void toggleoverlay(const Arg *arg);
|
int toggleoverlay(const Arg *arg);
|
||||||
void movewin(const Arg *arg);
|
int movewin(const Arg *arg);
|
||||||
void resizewin(const Arg *arg);
|
int resizewin(const Arg *arg);
|
||||||
void toggle_named_scratchpad(const Arg *arg);
|
int toggle_named_scratchpad(const Arg *arg);
|
||||||
void toggle_render_border(const Arg *arg);
|
int toggle_render_border(const Arg *arg);
|
||||||
void create_virtual_output(const Arg *arg);
|
int create_virtual_output(const Arg *arg);
|
||||||
void destroy_all_virtual_output(const Arg *arg);
|
int destroy_all_virtual_output(const Arg *arg);
|
||||||
void focuslast(const Arg *arg);
|
int focuslast(const Arg *arg);
|
||||||
void toggle_trackpad_enable(const Arg *arg);
|
int toggle_trackpad_enable(const Arg *arg);
|
||||||
void setoption(const Arg *arg);
|
int setoption(const Arg *arg);
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -281,7 +281,7 @@ void dwl_ipc_output_dispatch(struct wl_client *client,
|
||||||
const char *arg3, const char *arg4,
|
const char *arg3, const char *arg4,
|
||||||
const char *arg5) {
|
const char *arg5) {
|
||||||
|
|
||||||
void (*func)(const Arg *);
|
int (*func)(const Arg *);
|
||||||
Arg arg;
|
Arg arg;
|
||||||
func = parse_func_name((char *)dispatch, &arg, (char *)arg1, (char *)arg2,
|
func = parse_func_name((char *)dispatch, &arg, (char *)arg1, (char *)arg2,
|
||||||
(char *)arg3, (char *)arg4, (char *)arg5);
|
(char *)arg3, (char *)arg4, (char *)arg5);
|
||||||
|
|
|
||||||
88
src/mango.c
88
src/mango.c
|
|
@ -191,7 +191,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int mod;
|
unsigned int mod;
|
||||||
unsigned int button;
|
unsigned int button;
|
||||||
void (*func)(const Arg *);
|
int (*func)(const Arg *);
|
||||||
const Arg arg;
|
const Arg arg;
|
||||||
} Button; // 鼠标按键
|
} Button; // 鼠标按键
|
||||||
|
|
||||||
|
|
@ -203,7 +203,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int mod;
|
unsigned int mod;
|
||||||
unsigned int dir;
|
unsigned int dir;
|
||||||
void (*func)(const Arg *);
|
int (*func)(const Arg *);
|
||||||
const Arg arg;
|
const Arg arg;
|
||||||
} Axis;
|
} Axis;
|
||||||
|
|
||||||
|
|
@ -355,7 +355,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int mod;
|
unsigned int mod;
|
||||||
xkb_keysym_t keysym;
|
xkb_keysym_t keysym;
|
||||||
void (*func)(const Arg *);
|
int (*func)(const Arg *);
|
||||||
const Arg arg;
|
const Arg arg;
|
||||||
} Key;
|
} Key;
|
||||||
|
|
||||||
|
|
@ -717,6 +717,7 @@ static void set_float_malposition(Client *tc);
|
||||||
static void set_size_per(Monitor *m, Client *c);
|
static void set_size_per(Monitor *m, Client *c);
|
||||||
static void resize_tile_client(Client *grabc, bool isdrag, int offsetx,
|
static void resize_tile_client(Client *grabc, bool isdrag, int offsetx,
|
||||||
int offsety, unsigned int time);
|
int offsety, unsigned int time);
|
||||||
|
static void refresh_monitors_workspaces_status(Monitor *m);
|
||||||
|
|
||||||
#include "data/static_keymap.h"
|
#include "data/static_keymap.h"
|
||||||
#include "dispatch/bind_declare.h"
|
#include "dispatch/bind_declare.h"
|
||||||
|
|
@ -919,16 +920,6 @@ void clear_fullscreen_flag(Client *c) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void minimized(const Arg *arg) {
|
|
||||||
|
|
||||||
if (selmon && selmon->isoverview)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (selmon->sel && !selmon->sel->isminied) {
|
|
||||||
set_minimized(selmon->sel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void show_scratchpad(Client *c) {
|
void show_scratchpad(Client *c) {
|
||||||
c->is_scratchpad_show = 1;
|
c->is_scratchpad_show = 1;
|
||||||
if (c->isfullscreen || c->ismaxmizescreen) {
|
if (c->isfullscreen || c->ismaxmizescreen) {
|
||||||
|
|
@ -3235,6 +3226,8 @@ keybinding(unsigned int mods, xkb_keysym_t sym, unsigned int keycode) {
|
||||||
int handled = 0;
|
int handled = 0;
|
||||||
const KeyBinding *k;
|
const KeyBinding *k;
|
||||||
int ji;
|
int ji;
|
||||||
|
int isbreak = 0;
|
||||||
|
|
||||||
for (ji = 0; ji < config.key_bindings_count; ji++) {
|
for (ji = 0; ji < config.key_bindings_count; ji++) {
|
||||||
if (config.key_bindings_count < 1)
|
if (config.key_bindings_count < 1)
|
||||||
break;
|
break;
|
||||||
|
|
@ -3248,9 +3241,12 @@ keybinding(unsigned int mods, xkb_keysym_t sym, unsigned int keycode) {
|
||||||
(k->keysymcode.type == KEY_TYPE_CODE &&
|
(k->keysymcode.type == KEY_TYPE_CODE &&
|
||||||
keycode == k->keysymcode.keycode)) &&
|
keycode == k->keysymcode.keycode)) &&
|
||||||
k->func) {
|
k->func) {
|
||||||
k->func(&k->arg);
|
|
||||||
|
isbreak = k->func(&k->arg);
|
||||||
handled = 1;
|
handled = 1;
|
||||||
break;
|
|
||||||
|
if (isbreak)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return handled;
|
return handled;
|
||||||
|
|
@ -5117,68 +5113,6 @@ int hidecursor(void *data) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示所有tag 或 跳转到聚焦窗口的tag
|
|
||||||
void toggleoverview(const Arg *arg) {
|
|
||||||
Client *c = NULL;
|
|
||||||
|
|
||||||
if (selmon->isoverview && ov_tab_mode && arg->i != -1 && selmon->sel) {
|
|
||||||
focusstack(&(Arg){.i = 1});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
selmon->isoverview ^= 1;
|
|
||||||
unsigned int target;
|
|
||||||
unsigned int visible_client_number = 0;
|
|
||||||
|
|
||||||
if (selmon->isoverview) {
|
|
||||||
wl_list_for_each(c, &clients,
|
|
||||||
link) if (c && c->mon == selmon &&
|
|
||||||
!client_is_unmanaged(c) &&
|
|
||||||
!client_should_ignore_focus(c) &&
|
|
||||||
!c->isminied && !c->isunglobal) {
|
|
||||||
visible_client_number++;
|
|
||||||
}
|
|
||||||
if (visible_client_number > 0) {
|
|
||||||
target = ~0 & TAGMASK;
|
|
||||||
} else {
|
|
||||||
selmon->isoverview ^= 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (!selmon->isoverview && selmon->sel) {
|
|
||||||
target = get_tags_first_tag(selmon->sel->tags);
|
|
||||||
} else if (!selmon->isoverview && !selmon->sel) {
|
|
||||||
target = (1 << (selmon->pertag->prevtag - 1));
|
|
||||||
view(&(Arg){.ui = target}, false);
|
|
||||||
refresh_monitors_workspaces_status(selmon);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 正常视图到overview,退出所有窗口的浮动和全屏状态参与平铺,
|
|
||||||
// overview到正常视图,还原之前退出的浮动和全屏窗口状态
|
|
||||||
if (selmon->isoverview) {
|
|
||||||
wl_list_for_each(c, &clients, link) {
|
|
||||||
if (c && c->mon == selmon && !client_is_unmanaged(c) &&
|
|
||||||
!client_should_ignore_focus(c) && !c->isunglobal)
|
|
||||||
overview_backup(c);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
wl_list_for_each(c, &clients, link) {
|
|
||||||
if (c && c->mon == selmon && !c->iskilling &&
|
|
||||||
!client_is_unmanaged(c) && !c->isunglobal &&
|
|
||||||
!client_should_ignore_focus(c) && client_surface(c)->mapped)
|
|
||||||
overview_restore(c, &(Arg){.ui = target});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
view(&(Arg){.ui = target}, false);
|
|
||||||
|
|
||||||
if (ov_tab_mode && selmon->isoverview && selmon->sel) {
|
|
||||||
focusstack(&(Arg){.i = 1});
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh_monitors_workspaces_status(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
void unlocksession(struct wl_listener *listener, void *data) {
|
void unlocksession(struct wl_listener *listener, void *data) {
|
||||||
SessionLock *lock = wl_container_of(listener, lock, unlock);
|
SessionLock *lock = wl_container_of(listener, lock, unlock);
|
||||||
destroylock(lock, 1);
|
destroylock(lock, 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue