Compare commits

...

2 Commits

3 changed files with 16 additions and 108 deletions

View File

@ -117,6 +117,21 @@ void wm_node_type_to_str(NodeType type, char *buf, size_t bufsize)
}
}
void wm_treenode_to_str(TreeNode *node, char *buf, size_t bufsize)
{
assert(node);
assert(buf);
char type[128] = {0};
wm_node_type_to_str(node->type, type, sizeof(type));
snprintf(buf, bufsize, "{ type: %s, parent: %p, children: { nodes: %p, "
"size: %ld, capacity: %ld }, pos: { x: %d, y: %d, w: %d, h: %d }, "
"client: %p, id: %d }\n", type, node->parent,
node->children.nodes, node->children.size, node->children.capacity,
node->pos.x, node->pos.y, node->pos.w, node->pos.h,
node->client, node->id);
}
void wm_tree_to_DOT(TreeNode *root, const char *filename)
{
DEBUG_PRINT("%s\n", __func__);
@ -217,7 +232,6 @@ TreeNode* wm_treenode_remove_client(Wm *wm, TreeNode *root, Client *client)
if (client_node->parent == NULL) {
client_node->client = NULL;
wm_treenode_free(client_node);
return NULL;
}

View File

@ -73,6 +73,7 @@ void wm_treenode_remove_node(TreeNode *root, unsigned int node_id);
int wm_get_node_index(TreeNode *parent, unsigned int node_id);
void wm_tree_to_DOT(TreeNode *root, const char *filename);
void wm_node_type_to_str(NodeType type, char *buf, size_t bufsize);
void wm_treenode_to_str(TreeNode *node, char *buf, size_t bufsize);
NodeArray wm_nodearray_new();
void wm_nodearray_push(NodeArray *arr, TreeNode *node);

107
src/wm.c
View File

@ -262,113 +262,6 @@ void wm_switch_ws(Wm *wm, size_t ws)
wm_ptrarray_free(&switch_ws_clients);
}
void wm_mstack(Wm *wm, Monitor *m)
{
DEBUG_PRINT("%s\n", __func__)
RETURN_IF_NULL(m);
Client *c;
XWindowChanges ch;
int cc_sws = 0;
int n = 0;
int sx = 0;
int sy = 0;
XEvent e;
unsigned int value_mask = CWX | CWY | CWWidth | CWHeight;
// TODO: function
// FIXME: &root probably wrong
if (wm->dock != ULONG_MAX) {
XWindowAttributes x;
XGetWindowAttributes(wm->display, wm->dock, &x);
sx = x.x;
sy = x.y+x.height;
DEBUG_PRINT("%s dock sx x: %d y: %d\n", __func__, sx, sy)
}
for (c = m->clients; c; c = c->next) {
if (c->ws->index == m->selws && c != &wm->root && !c->is_floating) {
cc_sws++;
}
}
DEBUG_PRINT("mstack cc_sws: %d\n", cc_sws)
if (cc_sws <= 0) {
DEBUG_PRINT("mstack cc_sws <= 0, returning\n")
return;
}
// dynamic
if (cc_sws == 1) {
for (c = m->clients; c; c = c->next) {
if (c->ws->index == m->selws && c != &wm->root)
break;
}
c->x = 0;
c->y = sy;
c->w = wm->smon->info.width-wm->config.border_width*2;
c->h = (wm->smon->info.height-wm->config.border_width*2)-sy;
ch = wm_client_to_xwchanges(c);
DEBUG_PRINT("mstack client: %p\n", c);
// XGetWMName(wm->display, c->window, &xt);
DEBUG_PRINT("mstack window id: %ld\n", c->window);
// DEBUG_PRINT("mstack wm_name: %s\n", xt.value)
// DEBUG_PRINT("mstack client width: %d\n", ch.width)
// DEBUG_PRINT("mstack client height: %d\n", ch.height)
XConfigureWindow(wm->display, c->window, value_mask, &ch);
wm_client_show(wm, c);
wm_client_focus(wm, c);
}
else {
// FIXME not working with dock
for (c = m->clients; c; c = c->next) {
if (c->ws->index == m->selws && c->window != wm->root.window && !c->is_floating) {
if (n == 0) {
c->x = 0;
c->y = sy;
c->w = m->info.width*wm->config.ms_p-wm->config.border_width*2;
c->h = (m->info.height-wm->config.border_width*2)-sy;
} else {
c->x = (m->info.width*wm->config.ms_p);
c->y = ((n-1)*m->info.height/(cc_sws-1))+sy;
c->w = (m->info.width - m->info.width*wm->config.ms_p) -
wm->config.border_width*2;
c->h = ((m->info.height)/(cc_sws-1)-wm->config.border_width*2);
}
n++;
ch = wm_client_to_xwchanges(c);
DEBUG_PRINT("mstack client: %p\n", c);
DEBUG_PRINT("mstack window id: %ld\n", c->window);
XConfigureWindow(wm->display, c->window, value_mask, &ch);
wm_client_show(wm, c);
DEBUG_PRINT("%s %d. client next: %p\n", __func__, n, c->next)
if (c->next == NULL)
{
wm_client_focus(wm, c);
}
}
}
}
DEBUG_PRINT("%s end\n", __func__)
XSync(wm->display, False);
while(XCheckMaskEvent(wm->display, EnterWindowMask, &e));
wm_monitor_clients_border(wm, m);
}
void wm_layout(Wm *wm, Monitor *m)
{
RETURN_IF_NULL(m);