feat: add dispatch enable_monitor,disable_monitr,toggle_monitor
This commit is contained in:
@@ -1048,6 +1048,15 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
|
|||||||
(*arg).v = strdup(arg_value);
|
(*arg).v = strdup(arg_value);
|
||||||
(*arg).v2 = strdup(arg_value2);
|
(*arg).v2 = strdup(arg_value2);
|
||||||
(*arg).v3 = strdup(arg_value3);
|
(*arg).v3 = strdup(arg_value3);
|
||||||
|
} else if (strcmp(func_name, "disable_monitor") == 0) {
|
||||||
|
func = disable_monitor;
|
||||||
|
(*arg).v = strdup(arg_value);
|
||||||
|
} else if (strcmp(func_name, "enable_monitor") == 0) {
|
||||||
|
func = enable_monitor;
|
||||||
|
(*arg).v = strdup(arg_value);
|
||||||
|
} else if (strcmp(func_name, "toggle_monitor") == 0) {
|
||||||
|
func = toggle_monitor;
|
||||||
|
(*arg).v = strdup(arg_value);
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,4 +66,7 @@ int create_virtual_output(const Arg *arg);
|
|||||||
int destroy_all_virtual_output(const Arg *arg);
|
int destroy_all_virtual_output(const Arg *arg);
|
||||||
int focuslast(const Arg *arg);
|
int focuslast(const Arg *arg);
|
||||||
int toggle_trackpad_enable(const Arg *arg);
|
int toggle_trackpad_enable(const Arg *arg);
|
||||||
int setoption(const Arg *arg);
|
int setoption(const Arg *arg);
|
||||||
|
int disable_monitor(const Arg *arg);
|
||||||
|
int enable_monitor(const Arg *arg);
|
||||||
|
int toggle_monitor(const Arg *arg);
|
||||||
@@ -1570,3 +1570,48 @@ int toggleoverview(const Arg *arg) {
|
|||||||
refresh_monitors_workspaces_status(selmon);
|
refresh_monitors_workspaces_status(selmon);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int disable_monitor(const Arg *arg) {
|
||||||
|
Monitor *m = NULL;
|
||||||
|
struct wlr_output_state state = {0};
|
||||||
|
wl_list_for_each(m, &mons, link) {
|
||||||
|
if (regex_match(arg->v, m->wlr_output->name)) {
|
||||||
|
wlr_output_state_set_enabled(&state, false);
|
||||||
|
wlr_output_commit_state(m->wlr_output, &state);
|
||||||
|
m->asleep = 1;
|
||||||
|
updatemons(NULL, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int enable_monitor(const Arg *arg) {
|
||||||
|
Monitor *m = NULL;
|
||||||
|
struct wlr_output_state state = {0};
|
||||||
|
wl_list_for_each(m, &mons, link) {
|
||||||
|
if (regex_match(arg->v, m->wlr_output->name)) {
|
||||||
|
wlr_output_state_set_enabled(&state, true);
|
||||||
|
wlr_output_commit_state(m->wlr_output, &state);
|
||||||
|
m->asleep = 0;
|
||||||
|
updatemons(NULL, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int toggle_monitor(const Arg *arg) {
|
||||||
|
Monitor *m = NULL;
|
||||||
|
struct wlr_output_state state = {0};
|
||||||
|
wl_list_for_each(m, &mons, link) {
|
||||||
|
if (regex_match(arg->v, m->wlr_output->name)) {
|
||||||
|
wlr_output_state_set_enabled(&state, !m->wlr_output->enabled);
|
||||||
|
wlr_output_commit_state(m->wlr_output, &state);
|
||||||
|
m->asleep = !m->wlr_output->enabled;
|
||||||
|
updatemons(NULL, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -439,7 +439,6 @@ struct Monitor {
|
|||||||
Client *sel, *prevsel;
|
Client *sel, *prevsel;
|
||||||
int isoverview;
|
int isoverview;
|
||||||
int is_in_hotarea;
|
int is_in_hotarea;
|
||||||
int gamma_lut_changed;
|
|
||||||
int asleep;
|
int asleep;
|
||||||
unsigned int visible_clients;
|
unsigned int visible_clients;
|
||||||
unsigned int visible_tiling_clients;
|
unsigned int visible_tiling_clients;
|
||||||
@@ -4050,7 +4049,6 @@ void powermgrsetmode(struct wl_listener *listener, void *data) {
|
|||||||
if (!m)
|
if (!m)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m->gamma_lut_changed = 1; /* Reapply gamma LUT when re-enabling the ouput */
|
|
||||||
wlr_output_state_set_enabled(&state, event->mode);
|
wlr_output_state_set_enabled(&state, event->mode);
|
||||||
wlr_output_commit_state(m->wlr_output, &state);
|
wlr_output_commit_state(m->wlr_output, &state);
|
||||||
|
|
||||||
@@ -5427,10 +5425,6 @@ void updatemons(struct wl_listener *listener, void *data) {
|
|||||||
if ((c = focustop(m)) && c->isfullscreen)
|
if ((c = focustop(m)) && c->isfullscreen)
|
||||||
resize(c, m->m, 0);
|
resize(c, m->m, 0);
|
||||||
|
|
||||||
/* Try to re-set the gamma LUT when updating monitors,
|
|
||||||
* it's only really needed when enabling a disabled output, but meh.
|
|
||||||
*/
|
|
||||||
m->gamma_lut_changed = 1;
|
|
||||||
|
|
||||||
config_head->state.x = m->m.x;
|
config_head->state.x = m->m.x;
|
||||||
config_head->state.y = m->m.y;
|
config_head->state.y = m->m.y;
|
||||||
|
|||||||
Reference in New Issue
Block a user