mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-03-26 07:58:16 -04:00
Merge 7066ef2dc6 into 225fbda574
This commit is contained in:
commit
3bea272ae8
4 changed files with 41 additions and 10 deletions
|
|
@ -183,7 +183,8 @@ bind=ALT,e,set_proportion,1.0
|
||||||
bind=ALT,x,switch_proportion_preset,
|
bind=ALT,x,switch_proportion_preset,
|
||||||
|
|
||||||
# switch layout
|
# switch layout
|
||||||
bind=SUPER,n,switch_layout
|
bind=SUPER,n,next_layout
|
||||||
|
bind=SUPER+SHIFT,n,previous_layout
|
||||||
|
|
||||||
# tag switch
|
# tag switch
|
||||||
bind=SUPER,Left,viewtoleft,0
|
bind=SUPER,Left,viewtoleft,0
|
||||||
|
|
|
||||||
|
|
@ -1042,6 +1042,10 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
|
||||||
} else if (strcmp(func_name, "setlayout") == 0) {
|
} else if (strcmp(func_name, "setlayout") == 0) {
|
||||||
func = setlayout;
|
func = setlayout;
|
||||||
(*arg).v = strdup(arg_value);
|
(*arg).v = strdup(arg_value);
|
||||||
|
} else if (strcmp(func_name, "next_layout") == 0) {
|
||||||
|
func = next_layout;
|
||||||
|
} else if (strcmp(func_name, "previous_layout") == 0) {
|
||||||
|
func = previous_layout;
|
||||||
} else if (strcmp(func_name, "switch_layout") == 0) {
|
} else if (strcmp(func_name, "switch_layout") == 0) {
|
||||||
func = switch_layout;
|
func = switch_layout;
|
||||||
} else if (strcmp(func_name, "togglefloating") == 0) {
|
} else if (strcmp(func_name, "togglefloating") == 0) {
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ int32_t spawn_on_empty(const Arg *arg);
|
||||||
int32_t setkeymode(const Arg *arg);
|
int32_t setkeymode(const Arg *arg);
|
||||||
int32_t switch_keyboard_layout(const Arg *arg);
|
int32_t switch_keyboard_layout(const Arg *arg);
|
||||||
int32_t setlayout(const Arg *arg);
|
int32_t setlayout(const Arg *arg);
|
||||||
|
int32_t next_layout(const Arg *arg);
|
||||||
|
int32_t previous_layout(const Arg *arg);
|
||||||
int32_t switch_layout(const Arg *arg);
|
int32_t switch_layout(const Arg *arg);
|
||||||
int32_t setmfact(const Arg *arg);
|
int32_t setmfact(const Arg *arg);
|
||||||
int32_t quit(const Arg *arg);
|
int32_t quit(const Arg *arg);
|
||||||
|
|
|
||||||
|
|
@ -975,8 +975,8 @@ int32_t switch_keyboard_layout(const Arg *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t switch_layout(const Arg *arg) {
|
// Internal helper: direction > 0 means next, direction < 0 means previous
|
||||||
|
static int32_t _switch_layout_dir(int direction) {
|
||||||
int32_t jk, ji;
|
int32_t jk, ji;
|
||||||
char *target_layout_name = NULL;
|
char *target_layout_name = NULL;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
|
|
@ -986,7 +986,6 @@ int32_t switch_layout(const Arg *arg) {
|
||||||
|
|
||||||
if (config.circle_layout_count != 0) {
|
if (config.circle_layout_count != 0) {
|
||||||
for (jk = 0; jk < config.circle_layout_count; jk++) {
|
for (jk = 0; jk < config.circle_layout_count; jk++) {
|
||||||
|
|
||||||
len = MAX(
|
len = MAX(
|
||||||
strlen(config.circle_layout[jk]),
|
strlen(config.circle_layout[jk]),
|
||||||
strlen(selmon->pertag->ltidxs[selmon->pertag->curtag]->name));
|
strlen(selmon->pertag->ltidxs[selmon->pertag->curtag]->name));
|
||||||
|
|
@ -994,9 +993,19 @@ int32_t switch_layout(const Arg *arg) {
|
||||||
if (strncmp(config.circle_layout[jk],
|
if (strncmp(config.circle_layout[jk],
|
||||||
selmon->pertag->ltidxs[selmon->pertag->curtag]->name,
|
selmon->pertag->ltidxs[selmon->pertag->curtag]->name,
|
||||||
len) == 0) {
|
len) == 0) {
|
||||||
target_layout_name = jk == config.circle_layout_count - 1
|
if (direction > 0) {
|
||||||
? config.circle_layout[0]
|
// next: wrap forward
|
||||||
: config.circle_layout[jk + 1];
|
target_layout_name = (jk == config.circle_layout_count - 1)
|
||||||
|
? config.circle_layout[0]
|
||||||
|
: config.circle_layout[jk + 1];
|
||||||
|
} else {
|
||||||
|
// previous: wrap backward
|
||||||
|
target_layout_name =
|
||||||
|
(jk == 0)
|
||||||
|
? config
|
||||||
|
.circle_layout[config.circle_layout_count - 1]
|
||||||
|
: config.circle_layout[jk - 1];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1009,7 +1018,6 @@ int32_t switch_layout(const Arg *arg) {
|
||||||
len = MAX(strlen(layouts[ji].name), strlen(target_layout_name));
|
len = MAX(strlen(layouts[ji].name), strlen(target_layout_name));
|
||||||
if (strncmp(layouts[ji].name, target_layout_name, len) == 0) {
|
if (strncmp(layouts[ji].name, target_layout_name, len) == 0) {
|
||||||
selmon->pertag->ltidxs[selmon->pertag->curtag] = &layouts[ji];
|
selmon->pertag->ltidxs[selmon->pertag->curtag] = &layouts[ji];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1019,11 +1027,21 @@ int32_t switch_layout(const Arg *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback: iterate through global layouts[]
|
||||||
for (jk = 0; jk < LENGTH(layouts); jk++) {
|
for (jk = 0; jk < LENGTH(layouts); jk++) {
|
||||||
if (strcmp(layouts[jk].name,
|
if (strcmp(layouts[jk].name,
|
||||||
selmon->pertag->ltidxs[selmon->pertag->curtag]->name) == 0) {
|
selmon->pertag->ltidxs[selmon->pertag->curtag]->name) == 0) {
|
||||||
selmon->pertag->ltidxs[selmon->pertag->curtag] =
|
if (direction > 0) {
|
||||||
jk == LENGTH(layouts) - 1 ? &layouts[0] : &layouts[jk + 1];
|
// next: wrap forward
|
||||||
|
selmon->pertag->ltidxs[selmon->pertag->curtag] =
|
||||||
|
(jk == LENGTH(layouts) - 1) ? &layouts[0]
|
||||||
|
: &layouts[jk + 1];
|
||||||
|
} else {
|
||||||
|
// previous: wrap backward
|
||||||
|
selmon->pertag->ltidxs[selmon->pertag->curtag] =
|
||||||
|
(jk == 0) ? &layouts[LENGTH(layouts) - 1]
|
||||||
|
: &layouts[jk - 1];
|
||||||
|
}
|
||||||
clear_fullscreen_and_maximized_state(selmon);
|
clear_fullscreen_and_maximized_state(selmon);
|
||||||
arrange(selmon, false, false);
|
arrange(selmon, false, false);
|
||||||
printstatus();
|
printstatus();
|
||||||
|
|
@ -1033,6 +1051,12 @@ int32_t switch_layout(const Arg *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t next_layout(const Arg *arg) { return _switch_layout_dir(1); }
|
||||||
|
|
||||||
|
int32_t previous_layout(const Arg *arg) { return _switch_layout_dir(-1); }
|
||||||
|
|
||||||
|
int32_t switch_layout(const Arg *arg) { return next_layout(arg); }
|
||||||
|
|
||||||
int32_t switch_proportion_preset(const Arg *arg) {
|
int32_t switch_proportion_preset(const Arg *arg) {
|
||||||
float target_proportion = 0;
|
float target_proportion = 0;
|
||||||
if (!selmon)
|
if (!selmon)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue