切换 client 所在 monitor
This commit is contained in:
19
src/action.c
19
src/action.c
@@ -33,6 +33,25 @@ void send_client_to_tag(const user_action_arg_t *arg) {
|
|||||||
if (wm.client_focused) client_send_to_tag(wm.client_focused, arg->ui);
|
if (wm.client_focused) client_send_to_tag(wm.client_focused, arg->ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void send_client_to_next_monitor(const user_action_arg_t *arg) {
|
||||||
|
if (!wm.client_focused) return;
|
||||||
|
|
||||||
|
monitor_t *current_monitor = wm.client_focused->monitor;
|
||||||
|
monitor_t *next_monitor = current_monitor->next;
|
||||||
|
if (next_monitor == nullptr) {
|
||||||
|
next_monitor = wm.monitor_list;
|
||||||
|
} else {
|
||||||
|
for (monitor_t *m = wm.monitor_list; m && m->next != current_monitor;
|
||||||
|
m = m->next) {
|
||||||
|
next_monitor = m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current_monitor != next_monitor) {
|
||||||
|
client_send_to_monitor(wm.client_focused, next_monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void spawn(const user_action_arg_t *arg) {
|
void spawn(const user_action_arg_t *arg) {
|
||||||
const char *cmd = (const char *)arg->ptr;
|
const char *cmd = (const char *)arg->ptr;
|
||||||
if (cmd == nullptr || strlen(cmd) == 0) return;
|
if (cmd == nullptr || strlen(cmd) == 0) return;
|
||||||
|
|||||||
@@ -51,5 +51,6 @@ typedef struct keyboard_t {
|
|||||||
void focus_client_in_same_tag(const user_action_arg_t *arg);
|
void focus_client_in_same_tag(const user_action_arg_t *arg);
|
||||||
void select_tag_of_current_monitor(const user_action_arg_t *arg);
|
void select_tag_of_current_monitor(const user_action_arg_t *arg);
|
||||||
void send_client_to_tag(const user_action_arg_t *arg);
|
void send_client_to_tag(const user_action_arg_t *arg);
|
||||||
|
void send_client_to_next_monitor(const user_action_arg_t *arg);
|
||||||
void spawn(const user_action_arg_t *arg);
|
void spawn(const user_action_arg_t *arg);
|
||||||
void quit(const user_action_arg_t *arg);
|
void quit(const user_action_arg_t *arg);
|
||||||
|
|||||||
21
src/client.c
21
src/client.c
@@ -238,6 +238,27 @@ void client_send_to_tag(client_t *client, uint32_t tag_mask) {
|
|||||||
monitor_select_tag(client->monitor, tag_mask);
|
monitor_select_tag(client->monitor, tag_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void client_send_to_monitor(client_t *client, monitor_t *monitor) {
|
||||||
|
if (client->monitor == monitor) return;
|
||||||
|
|
||||||
|
for (tag_t *tag = client->monitor->tag_list; tag; tag = tag->next) {
|
||||||
|
client_remove_from_tag(client, tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
monitor_t *m = client->monitor;
|
||||||
|
|
||||||
|
client->monitor = monitor;
|
||||||
|
client->tags = monitor->selected_tag->mask;
|
||||||
|
client_add_to_tag(client, monitor->selected_tag);
|
||||||
|
|
||||||
|
monitor_arrange(m);
|
||||||
|
monitor_arrange(monitor);
|
||||||
|
monitor_draw_bar(m);
|
||||||
|
monitor_draw_bar(monitor);
|
||||||
|
|
||||||
|
xcb_flush(wm.xcb_conn);
|
||||||
|
}
|
||||||
|
|
||||||
void client_move_to(client_t *client, int16_t x, int16_t y) {
|
void client_move_to(client_t *client, int16_t x, int16_t y) {
|
||||||
client->geometry.x = x;
|
client->geometry.x = x;
|
||||||
client->geometry.y = y;
|
client->geometry.y = y;
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ static const keyboard_t key_list[] = {
|
|||||||
TAGKEYS(XK_7, 1 << 6),
|
TAGKEYS(XK_7, 1 << 6),
|
||||||
TAGKEYS(XK_8, 1 << 7),
|
TAGKEYS(XK_8, 1 << 7),
|
||||||
TAGKEYS(XK_9, 1 << 8),
|
TAGKEYS(XK_9, 1 << 8),
|
||||||
|
|
||||||
|
{modifier_alt, XK_o, send_client_to_next_monitor, {0}},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const layout_t layout_list[] = {
|
static const layout_t layout_list[] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user