fix workspace switching

This commit is contained in:
Akos Horvath 2023-07-03 18:02:12 +02:00
parent 784fd89cf8
commit 32d4a52800

View File

@ -67,7 +67,7 @@ void wm_monitors_open_all(Wm *wm, Display *d)
wm->monitors[i].selws = 0;
for (size_t j = 0; j < wm->monitors[i].wscount; j++) {
Workspace *ws = &wm->monitors[i].workspaces[i];
Workspace *ws = &wm->monitors[i].workspaces[j];
ws->index = j;
ws->monitor = &wm->monitors[i];
@ -201,14 +201,11 @@ void wm_switch_ws(Wm *wm, size_t ws)
int wscc = 0;
Client *c;
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;
}
PtrArray current_ws_clients = wm_treenode_find_client_nodes_ptr(
&wm->smon->workspaces[wm->smon->selws].tree);
for (size_t i = 0; i < clients.size; i++) {
c = ((TreeNode**)clients.ptrs)[i]->client;
for (size_t i = 0; i < current_ws_clients.size; i++) {
c = ((TreeNode**)current_ws_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)
@ -221,15 +218,21 @@ void wm_switch_ws(Wm *wm, size_t ws)
wm_client_set_atom(wm, &wm-> root, "_NET_CURRENT_DESKTOP",
(unsigned char*) &(ws), XA_CARDINAL, 1);
for (size_t i = 0; i < clients.size; i++) {
c = ((TreeNode**)clients.ptrs)[i]->client;
PtrArray switch_ws_clients = wm_treenode_find_client_nodes_ptr(
&wm->smon->workspaces[wm->smon->selws].tree);
for (size_t i = 0; i < switch_ws_clients.size; i++) {
c = ((TreeNode**)switch_ws_clients.ptrs)[i]->client;
if (c->ws->index == wm->smon->selws) {
wscc++;
wm_client_show(wm, c);
}
}
DEBUG_PRINT("wm_switch_ws focused ws client count: %d\n", wscc)
DEBUG_PRINT("wm_switch_ws focused ws client count: %d\n", wscc);
wm_ptrarray_free(&current_ws_clients);
wm_ptrarray_free(&switch_ws_clients);
}
// TODO maybe x,y is not 0, because of bar