From: Michael D. Lowis Date: Thu, 16 May 2019 02:42:41 +0000 (-0400) Subject: implement crude version of dwm tiling X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=750fe7c240aa8cc8b2a3aaf8416ea3c8c54f5f03;p=projs%2Ftide.git implement crude version of dwm tiling --- diff --git a/src/tframe.c b/src/tframe.c index 26da11a..718d15b 100644 --- a/src/tframe.c +++ b/src/tframe.c @@ -158,14 +158,20 @@ static void xbtnmotion(XConf* x, XEvent* e) { ******************************************************************************/ static void retile_children(XConf* x) { - size_t width = x->width / NChildren; - size_t extra = x->width % NChildren; - size_t offset = width+extra; + size_t height = x->height - Divider - 2; + Child_T* child = Children; - XMoveResizeWindow(x->display, child->wid, 0, Divider+2, width+extra, x->height - Divider - 2); - for (child = child->next; child; child = child->next) { - XMoveResizeWindow(x->display, child->wid, offset, Divider+2, width, x->height - Divider - 2); - offset += width; + if (NChildren == 1) { + XMoveResizeWindow(x->display, child->wid, 0, Divider+2, x->width, height); + } else { + /* place the master window */ + XMoveResizeWindow(x->display, child->wid, 0, Divider+2, x->width/2, height); + /* place the slave windows */ + size_t slave_height = height / (NChildren - 1); + size_t offset = Divider+2; + for (child = child->next; child; child = child->next, offset += slave_height) { + XMoveResizeWindow(x->display, child->wid, x->width/2, offset, x->width/2, slave_height); + } } retile = 0; } diff --git a/src/tide.c b/src/tide.c index 628b5e7..473c89b 100644 --- a/src/tide.c +++ b/src/tide.c @@ -200,6 +200,7 @@ static void xredraw(XConf* x) { draw_view(x, &Regions[EDIT], x->font, editrows, &csr, EditBg, EditFg, EditSel, SyncMouse); draw_scroll(x, &csr, win_view(EDIT), Divider); draw_rect(x, WinBdr, 0, x->height-1, x->width, 1); + draw_rect(x, WinBdr, x->width-1, 0, 1, x->height); XCopyArea(x->display, x->pixmap, x->self, x->gc, 0, 0, x->width, x->height, 0, 0); SyncMouse = false; XFlush(x->display);