mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-05 13:29:54 -05:00
feat: add toggle_named_scratch
This commit is contained in:
parent
f61dbf41dc
commit
90edcafd4e
3 changed files with 78 additions and 14 deletions
|
|
@ -553,6 +553,10 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, char *arg_v
|
||||||
(*arg).ui2 = parse_num_type(arg_value2);
|
(*arg).ui2 = parse_num_type(arg_value2);
|
||||||
(*arg).i = (*arg).ui == NUM_TYPE_DEFAULT ? atoi(arg_value) : atoi(arg_value+1);
|
(*arg).i = (*arg).ui == NUM_TYPE_DEFAULT ? atoi(arg_value) : atoi(arg_value+1);
|
||||||
(*arg).i2 = (*arg).ui2 == NUM_TYPE_DEFAULT ? atoi(arg_value2) : atoi(arg_value2+1);
|
(*arg).i2 = (*arg).ui2 == NUM_TYPE_DEFAULT ? atoi(arg_value2) : atoi(arg_value2+1);
|
||||||
|
} else if (strcmp(func_name, "toggle_named_scratch") == 0) {
|
||||||
|
func = toggle_named_scratch;
|
||||||
|
(*arg).v = strdup(arg_value);
|
||||||
|
(*arg).v2 = strdup(arg_value2);
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,3 +53,4 @@ void togglefakefullscreen(const Arg *arg);
|
||||||
void toggleoverlay(const Arg *arg);
|
void toggleoverlay(const Arg *arg);
|
||||||
void movewin(const Arg *arg);
|
void movewin(const Arg *arg);
|
||||||
void resizewin(const Arg *arg);
|
void resizewin(const Arg *arg);
|
||||||
|
void toggle_named_scratch(const Arg *arg);
|
||||||
87
src/maomao.c
87
src/maomao.c
|
|
@ -1432,26 +1432,85 @@ void swallow(Client *c, Client *w) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggle_scratchpad(const Arg *arg) {
|
bool switch_scratch_client_state(Client *c) {
|
||||||
Client *c;
|
if (c->is_in_scratchpad && c->is_scratchpad_show &&
|
||||||
|
(selmon->tagset[selmon->seltags] & c->tags) == 0) {
|
||||||
|
unsigned int target = get_tags_first_tag(selmon->tagset[selmon->seltags]);
|
||||||
|
tag_client(&(Arg){.ui = target}, c);
|
||||||
|
return true;
|
||||||
|
} else if (c->is_in_scratchpad && c->is_scratchpad_show &&
|
||||||
|
(selmon->tagset[selmon->seltags] & c->tags) != 0) {
|
||||||
|
set_minized(c);
|
||||||
|
return true;
|
||||||
|
} else if (c && c->is_in_scratchpad && !c->is_scratchpad_show) {
|
||||||
|
show_scratchpad(c);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggle_named_scratch(const Arg *arg) {
|
||||||
|
Client *c = NULL;
|
||||||
|
Client *target_client = NULL;
|
||||||
|
const char *appid, *title;
|
||||||
|
char *arg_id = arg->v;
|
||||||
|
char *arg_title = arg->v2;
|
||||||
|
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
if (c->mon != selmon) {
|
if (c->mon != selmon) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (c->is_in_scratchpad && c->is_scratchpad_show &&
|
|
||||||
(selmon->tagset[selmon->seltags] & c->tags) == 0) {
|
if (!(appid = client_get_appid(c)))
|
||||||
unsigned int target = get_tags_first_tag(selmon->tagset[selmon->seltags]);
|
appid = broken;
|
||||||
tag_client(&(Arg){.ui = target}, c);
|
if (!(title = client_get_title(c)))
|
||||||
return;
|
title = broken;
|
||||||
} else if (c->is_in_scratchpad && c->is_scratchpad_show &&
|
|
||||||
(selmon->tagset[selmon->seltags] & c->tags) != 0) {
|
if (arg_id && strncmp(arg_id, "none", 4) == 0)
|
||||||
set_minized(c);
|
arg_id = NULL;
|
||||||
return;
|
|
||||||
} else if (c && c->is_in_scratchpad && !c->is_scratchpad_show) {
|
if (arg_title && strncmp(arg_title, "none", 4) == 0)
|
||||||
show_scratchpad(c);
|
arg_title = NULL;
|
||||||
return;
|
|
||||||
|
if ((arg_title && strstr(title, arg_title) && !arg_id) ||
|
||||||
|
(arg_id && strstr(appid, arg_id) && !arg_title) ||
|
||||||
|
(arg_id && strstr(appid, arg_id) && arg_title &&
|
||||||
|
strstr(title, arg_title))) {
|
||||||
|
target_client = c;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!target_client)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wl_list_for_each(c, &clients, link) {
|
||||||
|
if (c->mon != selmon) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(c->is_in_scratchpad && c->is_scratchpad_show && c != target_client) {
|
||||||
|
set_minized(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!target_client->is_in_scratchpad)
|
||||||
|
set_minized(target_client);
|
||||||
|
else
|
||||||
|
switch_scratch_client_state(target_client);
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggle_scratchpad(const Arg *arg) {
|
||||||
|
Client *c;
|
||||||
|
bool hit = false;
|
||||||
|
wl_list_for_each(c, &clients, link) {
|
||||||
|
if (c->mon != selmon) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
hit =switch_scratch_client_state(c);
|
||||||
|
if(hit)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpureset(struct wl_listener *listener, void *data) {
|
void gpureset(struct wl_listener *listener, void *data) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue