use updated util function signatures

This commit is contained in:
Akos Horvath 2023-06-01 15:23:45 +02:00
parent cf3bea02da
commit 1298543661

45
wm.c
View File

@ -72,7 +72,7 @@ void wm_monitors_open_all(Wm *wm, Display *d)
// TODO config
snprintf(ws->name, WM_WS_NAME_LEN, "%d", j);
wm_treenode_init(&ws->tree, NODE_CLIENT, NULL);
ws->tree = wm_treenode_new(NODE_CLIENT, NULL);
}
//wm->monitors[i].clients = &wm->root;
@ -150,6 +150,7 @@ NodeType wm_split_to_nodetype(SplitMode mode)
void wm_ws_tree_insert_client(Wm *wm, Workspace *ws, Client *client)
{
DEBUG_PRINT("%s\n", __func__);
int dock_y = 0;
if (wm->dock != -1) {
@ -159,7 +160,7 @@ void wm_ws_tree_insert_client(Wm *wm, Workspace *ws, Client *client)
dock_y = x.height;
}
if (wm_treenode_is_empty(&ws->tree)) {
if (wm_treenode_is_empty(&ws->tree) && ws->tree.client == NULL) {
ws->tree.type = NODE_CLIENT;
ws->tree.client = client;
ws->tree.pos = (Rect) {
@ -171,12 +172,13 @@ 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;
focused_node->type = wm_split_to_nodetype(ws->split);
TreeNode child1, child2;
wm_treenode_init(&child1, NODE_CLIENT, focused_node);
wm_treenode_init(&child2, NODE_CLIENT, focused_node);
TreeNode child1 = wm_treenode_new(NODE_CLIENT, focused_node);
TreeNode child2 = wm_treenode_new(NODE_CLIENT, focused_node);
wm_treenode_split_space(focused_node, &child1.pos, &child2.pos);
child1.client = old_client;
@ -271,7 +273,7 @@ void wm_mstack(Wm *wm, Monitor *m)
c->y = sy;
c->w = wm->smon->info.width-wm->cfg_border_width*2;
c->h = (wm->smon->info.height-wm->cfg_border_width*2)-sy;
ch = wm_client_to_xwchanges(*c);
ch = wm_client_to_xwchanges(c);
DEBUG_PRINT("mstack client: 0x%x\n", c);
// XGetWMName(wm->display, c->window, &xt);
DEBUG_PRINT("mstack window id: %d\n", c->window);
@ -300,7 +302,7 @@ void wm_mstack(Wm *wm, Monitor *m)
c->h = ((m->info.height)/(cc_sws-1)-wm->cfg_border_width*2);
}
n++;
ch = wm_client_to_xwchanges(*c);
ch = wm_client_to_xwchanges(c);
// TODO store wm name when client is created
@ -343,32 +345,37 @@ void wm_set_layout(Wm *wm, void(*f)(Wm *wm, Monitor*))
void wm_layout(Wm *wm, Monitor *m)
{
RETURN_IF_NULL(m);
size_t i;
DEBUG_PRINT("%s\n", __func__);
Workspace *ws = &m->workspaces[m->selws];
PtrArray clients = wm_treenode_find_client_nodes_ptr(&ws->tree);
for (size_t i = 0; i < clients.size; i++) {
TreeNode *node = (TreeNode*) clients.ptrs[i];
assert(node->client);
for (i = 0; i < clients.size; i++) {
TreeNode *node = clients.ptrs[i];
Client *client = node->client;
assert(client);
node->client->x = node->pos.x;
node->client->y = node->pos.y;
node->client->w = node->pos.w;
node->client->h = node->pos.h;
client->x = node->pos.x;
client->y = node->pos.y;
client->w = node->pos.w;
client->h = node->pos.h;
unsigned int value_mask = CWX | CWY | CWWidth | CWHeight;
XWindowChanges xwc = wm_client_to_xwchanges(*node->client);
XConfigureWindow(wm->display, node->client->window, value_mask, &xwc);
if (node->client->focused)
wm_client_focus(wm, node->client);
XWindowChanges xwc = wm_client_to_xwchanges((client));
XConfigureWindow(wm->display, client->window, value_mask, &xwc);
wm_client_show(wm, client);
}
wm_client_focus(wm, clients.ptrs[i]);
XEvent e;
XSync(wm->display, False);
while(XCheckMaskEvent(wm->display, EnterWindowMask, &e));
wm_monitor_clients_border(wm, m);
wm_ptrarray_free(&clients);
}
Client *wm_get_last_client(Wm *wm, Monitor m)