diff --git a/src/config/parse_config.h b/src/config/parse_config.h index ba7dcb4..f5d2558 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -1031,6 +1031,15 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, (*arg).v = strdup(arg_value); (*arg).v2 = strdup(arg_value2); (*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 { return NULL; } diff --git a/src/dispatch/bind_declare.h b/src/dispatch/bind_declare.h index c57a132..b02ccf9 100644 --- a/src/dispatch/bind_declare.h +++ b/src/dispatch/bind_declare.h @@ -66,4 +66,7 @@ int create_virtual_output(const Arg *arg); int destroy_all_virtual_output(const Arg *arg); int focuslast(const Arg *arg); int toggle_trackpad_enable(const Arg *arg); -int setoption(const Arg *arg); \ No newline at end of file +int setoption(const Arg *arg); +int disable_monitor(const Arg *arg); +int enable_monitor(const Arg *arg); +int toggle_monitor(const Arg *arg); \ No newline at end of file diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index d628970..1822357 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -1573,3 +1573,48 @@ int toggleoverview(const Arg *arg) { refresh_monitors_workspaces_status(selmon); 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; +} \ No newline at end of file diff --git a/src/mango.c b/src/mango.c index f828630..2fb2e63 100644 --- a/src/mango.c +++ b/src/mango.c @@ -436,7 +436,6 @@ struct Monitor { Client *sel, *prevsel; int isoverview; int is_in_hotarea; - int gamma_lut_changed; int asleep; unsigned int visible_clients; unsigned int visible_tiling_clients; @@ -3988,7 +3987,6 @@ void powermgrsetmode(struct wl_listener *listener, void *data) { if (!m) return; - m->gamma_lut_changed = 1; /* Reapply gamma LUT when re-enabling the ouput */ wlr_output_state_set_enabled(&state, event->mode); wlr_output_commit_state(m->wlr_output, &state); @@ -5371,10 +5369,6 @@ void updatemons(struct wl_listener *listener, void *data) { if ((c = focustop(m)) && c->isfullscreen) 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.y = m->m.y;