Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CC=gcc
CFLAGS=-Wall -lX11 -g -lm
PRECFLAGS=-Wall -g
POSTCFLAGS=-lX11 -lm
VPATH=./src

WM_OBJS= atoms.o events.o tree.o commands.o responses.o util.o window.o lookup.o foo-wm.o
Expand All @@ -11,10 +12,10 @@ src/config.h:
cp src/config.def.h src/config.h

foo-wm: src/config.h $(WM_OBJS)
$(CC) $(CFLAGS) $(WM_OBJS) -o foo-wm
$(CC) $(PRECFLAGS) $(WM_OBJS) $(POSTCFLAGS) -o foo-wm

foo-wm-c: $(CLI_OBJS)
$(CC) $(CFLAGS) $(CLI_OBJS) -o foo-wm-c
$(CC) $(PRECFLAGS) $(CLI_OBJS) $(POSTCFLAGS) -o foo-wm-c

clean:
rm -rf foo-wm foo-wm-c *.o
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Bugs
- 'containerize' 'containerize' -- case of the missing container
- brotherNode() in tree.c, node->parent = brother->parent ?
* This could potentially break the old node's brothers and node parent child ptr
- XMapWindow and XRaiseWindow always called for Windows in placeNode regardless if already mapped/raised
- Destroying last client doesn't focus container / set focusedNode
* Tree:
- Container (1)
Expand Down
32 changes: 31 additions & 1 deletion src/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,38 @@ void placeNode(Node * node, int x, int y, int width, int height) {

if (isClient(node)) {
fprintf(stderr,"Rendering window\n");
XMapWindow(display, node -> window);
XWindowAttributes attr;
XGetWindowAttributes(display, node -> window, &attr);

// Make sure that the window isn't already visible before remapping it.
if (attr.map_state != IsViewable)
XMapWindow(display, node -> window);

/* Making sure that a window isn't already raised requires some gymnastics:
* According to 'http://tronche.com/gui/x/xlib/window-information/XQueryTree.html'
* XQueryTree produces children in stacking order. Thus, the final child
* is on top.
*
* Note that I comment this out because it is probably very dumb to
* use this code - XRaiseWindow is probably fast compared to
* the XQueryTree request, the XQueryTree response, and freeing the array.
*/

/*
Window root_window = RootWindow(display, DefaultScreen(display));
Window root_tmp, parent_tmp;
Window *children;
int n_children;
XQueryTree(display, root, &root_tmp, &parent_tmp, &children, *n_children);

Window top_window = children[n_children - 1];
XFree(children);

if (node -> window != top_window)
XRaiseWindow(display, node -> window);
*/
XRaiseWindow(display, node -> window);

XMoveResizeWindow(display, node -> window,
(x < 0) ? 0 : x, (y < 0) ? 0 : y,
(width - (border * 2)) > 0 ? (width - border * 2) : 1,
Expand Down