diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 9f63d104..6ced4523 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -1004,6 +1004,10 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, func = bind_to_view; (*arg).ui = 1 << (atoi(arg_value) - 1); (*arg).i = atoi(arg_value2); + } else if (strcmp(func_name, "view_tagmon") == 0) { + func = view_tagmon; + (*arg).ui = 1 << (atoi(arg_value) - 1); + (*arg).v = strdup(arg_value2); } else if (strcmp(func_name, "toggletag") == 0) { func = toggletag; (*arg).ui = 1 << (atoi(arg_value) - 1); diff --git a/src/dispatch/bind_declare.h b/src/dispatch/bind_declare.h index cc84923c..5f553a77 100644 --- a/src/dispatch/bind_declare.h +++ b/src/dispatch/bind_declare.h @@ -64,4 +64,5 @@ 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 view_tagmon(const Arg *arg); +int setoption(const Arg *arg); diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index 21f2884b..ba1bfeba 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -1546,3 +1546,54 @@ int toggleoverview(const Arg *arg) { refresh_monitors_workspaces_status(selmon); return 0; } + +int view_tagmon(const Arg *arg) { + Client *c = NULL, *old_selmon_sel = NULL; + Monitor *m = NULL; + int _warpcursor = warpcursor; + + if (arg->v) { + wl_list_for_each(m, &mons, link) { + if (!m->wlr_output->enabled) { + continue; + } + if (regex_match(arg->v, m->wlr_output->name)) { + break; + } + } + } else { + return 0; + } + + if (!m || !m->wlr_output->enabled) + return 0; + + if (selmon == m) { + // Don't warp cursor if already at monitor + _warpcursor = 0; + } + + old_selmon_sel = selmon->sel; + selmon = m; + if (_warpcursor) { + warp_cursor_to_selmon(selmon); + } + c = focustop(selmon); + if (!c) { + selmon->sel = NULL; + wlr_seat_pointer_notify_clear_focus(seat); + wlr_seat_keyboard_notify_clear_focus(seat); + } else + focusclient(c, 1); + + if (old_selmon_sel) { + setborder_color(old_selmon_sel); + } + + Arg v_arg; + // Set the tag bitmask + v_arg.ui = arg->ui; + // default value? + v_arg.i = 0; + return bind_to_view(&v_arg); +}