添加切换当前屏幕快捷键
This commit is contained in:
@@ -7,3 +7,4 @@ void quit(const user_action_arg_t *arg);
|
||||
void select_tag(const user_action_arg_t *arg);
|
||||
void kill_client(const user_action_arg_t *arg);
|
||||
void focus_stack(const user_action_arg_t *arg);
|
||||
void focus_monitor(const user_action_arg_t *arg);
|
||||
|
||||
@@ -93,6 +93,8 @@ const keybinding_t keys[] = {
|
||||
{SUPER | SHIFT, XK_c, kill_client, {0}},
|
||||
{ALT, XK_j, focus_stack, {.b = true}},
|
||||
{ALT, XK_k, focus_stack, {.b = false}},
|
||||
{SUPER | SHIFT, XK_j, focus_monitor, {.b = true}},
|
||||
{SUPER | SHIFT, XK_k, focus_monitor, {.b = false}},
|
||||
{SUPER, XK_1, select_tag, {.ui = 0}},
|
||||
{SUPER, XK_2, select_tag, {.ui = 1}},
|
||||
{SUPER, XK_3, select_tag, {.ui = 2}},
|
||||
|
||||
26
src/main.c
26
src/main.c
@@ -67,6 +67,7 @@ static void set_client_fullscreen(client_t *client, bool fullscreen);
|
||||
static void apply_monitor_layout(monitor_t *monitor);
|
||||
static client_t *get_client_of_window(xcb_window_t window);
|
||||
static monitor_t *get_monitor_of_window(xcb_window_t window);
|
||||
static monitor_t *get_monitor_by_direction(bool forward);
|
||||
static gboolean handle_xcb_event(GIOChannel *channel, GIOCondition condition,
|
||||
gpointer userdata);
|
||||
static void cleanup(void);
|
||||
@@ -147,6 +148,19 @@ void focus_stack(const user_action_arg_t *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
void focus_monitor(const user_action_arg_t *arg) {
|
||||
if (!monitors->next) return;
|
||||
|
||||
bool forward = arg->b;
|
||||
monitor_t *monitor = get_monitor_by_direction(forward);
|
||||
if (monitor == current_monitor) return;
|
||||
|
||||
unfocus(current_monitor->selected_client, false);
|
||||
current_monitor = monitor;
|
||||
focus(NULL);
|
||||
/* TODO: 调整鼠标光标 */
|
||||
}
|
||||
|
||||
/* 调试函数,开发完成后删除 */
|
||||
static void print_monitor_list_info(monitor_t *monitor_list) {
|
||||
logger("========================= monitor info =========================\n");
|
||||
@@ -1056,6 +1070,18 @@ monitor_t *get_monitor_of_window(xcb_window_t window) {
|
||||
return current_monitor;
|
||||
}
|
||||
|
||||
monitor_t *get_monitor_by_direction(bool forward) {
|
||||
monitor_t *m = NULL;
|
||||
if (forward) {
|
||||
if (!(m = current_monitor->next)) m = monitors;
|
||||
} else if (current_monitor == monitors) {
|
||||
for (m = monitors; m->next; m = m->next);
|
||||
} else {
|
||||
for (m = monitors; m->next != current_monitor; m = m->next);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
gboolean handle_xcb_event(GIOChannel *channel, GIOCondition condition,
|
||||
gpointer userdata) {
|
||||
if (condition & (G_IO_HUP | G_IO_ERR)) {
|
||||
|
||||
Reference in New Issue
Block a user