add function and keybinds to switch split mode
This commit is contained in:
parent
1f07ccbfd6
commit
24a8cf1856
37
wm.c
37
wm.c
@ -164,9 +164,9 @@ void wm_ws_tree_insert_client(Wm *wm, Workspace *ws, Client *client)
|
||||
ws->tree.type = NODE_CLIENT;
|
||||
ws->tree.client = client;
|
||||
ws->tree.pos = (Rect) {
|
||||
.x = 0, .y = dock_y + 1,
|
||||
.x = 0, .y = dock_y,
|
||||
.w = ws->monitor->info.width,
|
||||
.h = ws->monitor->info.height - dock_y + 1
|
||||
.h = ws->monitor->info.height - dock_y,
|
||||
};
|
||||
return;
|
||||
}
|
||||
@ -174,7 +174,7 @@ void wm_ws_tree_insert_client(Wm *wm, Workspace *ws, Client *client)
|
||||
TreeNode *focused_node = wm_treenode_ptr_find_focused_client_node(&ws->tree);
|
||||
assert(focused_node);
|
||||
|
||||
Client *old_client = ws->tree.client;
|
||||
Client *old_client = focused_node->client;
|
||||
focused_node->type = wm_split_to_nodetype(ws->split);
|
||||
|
||||
TreeNode child1 = wm_treenode_new(NODE_CLIENT, focused_node);
|
||||
@ -197,7 +197,15 @@ void wm_switch_ws(Wm *wm, int ws)
|
||||
int xasws;
|
||||
Client *c;
|
||||
|
||||
for (c = wm->smon->clients; c; c = c->next) {
|
||||
PtrArray clients = wm_treenode_find_client_nodes_ptr(&wm->smon->workspaces[ws].tree);
|
||||
if (clients.size == 0) {
|
||||
DEBUG_PRINT("clients size 0, returning\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < clients.size; i++) {
|
||||
c = ((TreeNode**)clients.ptrs)[i]->client;
|
||||
assert(c);
|
||||
if (c->ws->index == wm->smon->selws) {
|
||||
DEBUG_PRINT("wm_switch_ws hide client selws: %ld\n", c->ws->index)
|
||||
wm_client_hide(wm, c);
|
||||
@ -209,7 +217,8 @@ void wm_switch_ws(Wm *wm, int ws)
|
||||
wm_client_set_atom(wm, &wm-> root, "_NET_CURRENT_DESKTOP",
|
||||
(unsigned char*) &(ws), XA_CARDINAL, 1);
|
||||
|
||||
for (c = wm->smon->clients; c; c = c->next) {
|
||||
for (size_t i = 0; i < clients.size; i++) {
|
||||
c = ((TreeNode**)clients.ptrs)[i]->client;
|
||||
if (c->ws->index == wm->smon->selws) {
|
||||
wscc++;
|
||||
wm_client_show(wm, c);
|
||||
@ -684,9 +693,16 @@ void wm_kb_focus_dir(Wm *wm, Arg *args)
|
||||
wm_client_focus_dir(wm, c, args->i);
|
||||
}
|
||||
|
||||
void wm_kb_switch_split_mode(Wm *wm, Arg *args)
|
||||
{
|
||||
RETURN_IF_NULL(args)
|
||||
|
||||
wm->smon->workspaces[wm->smon->selws].split = args->i;
|
||||
}
|
||||
|
||||
void wm_keybinds_init_def(Wm *wm)
|
||||
{
|
||||
char *st[] = {"st", NULL};
|
||||
char *st[] = {"alacritty", NULL};
|
||||
char **sth = malloc(sizeof(st));
|
||||
memcpy(sth, st, sizeof(st));
|
||||
|
||||
@ -746,6 +762,15 @@ void wm_keybinds_init_def(Wm *wm)
|
||||
|
||||
(Keybind) {Mod4Mask, XK_l, *wm_kb_focus_dir,
|
||||
(Arg) {.i = RIGHT}},
|
||||
|
||||
(Keybind) {Mod4Mask, XK_b, *wm_kb_switch_split_mode,
|
||||
(Arg) {.i = SPLIT_VERTICAL}},
|
||||
|
||||
(Keybind) {Mod4Mask, XK_v, *wm_kb_switch_split_mode,
|
||||
(Arg) {.i = SPLIT_HORIZ}},
|
||||
|
||||
(Keybind) {Mod4Mask, XK_t, *wm_kb_switch_split_mode,
|
||||
(Arg) {.i = SPLIT_TAB}},
|
||||
};
|
||||
|
||||
|
||||
|
3
wm.h
3
wm.h
@ -125,6 +125,8 @@ struct Wm {
|
||||
Client root;
|
||||
Window dock;
|
||||
|
||||
Client *focused_client;
|
||||
|
||||
// TODO: active layout not working
|
||||
void (*active_layout)(Wm *wm, Monitor*);
|
||||
float cfg_ms_p;
|
||||
@ -165,6 +167,7 @@ void wm_kb_kill(Wm *wm, Arg *args);
|
||||
void wm_kb_switch_ws(Wm *wm, Arg *args);
|
||||
void wm_kb_focus_dir(Wm *wm, Arg *args);
|
||||
void wm_kb_exit(Wm* wm, Arg *args);
|
||||
void wm_kb_switch_split_mode(Wm *wm, Arg *args);
|
||||
|
||||
void wm_keybinds_init_def(Wm *wm);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user