x->width = width, x->height = height;
x->self = XCreateSimpleWindow(
x->display, x->root, 0, 0, x->width, x->height, 0, x->depth, -1);
+
/* register interest in the delete window message */
Atom wmDeleteMessage = XInternAtom(x->display, "WM_DELETE_WINDOW", False);
XSetWMProtocols(x->display, x->self, &wmDeleteMessage, 1);
/* setup window attributes and events */
XSetWindowAttributes swa;
swa.bit_gravity = NorthWestGravity;
+ swa.do_not_propagate_mask = 0; // do not hide any events from child window
XChangeWindowAttributes(x->display, x->self,
- CWBackingStore|CWBitGravity,
-// CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask | CWColormap,
+ CWBackingStore|CWBitGravity|CWEventMask|NoEventMask|CWBackPixel,
&swa);
XSelectInput(x->display, x->self, evmask);
}
static View Tags;
static int Divider;
static int FontSel;
+Window Child = 0;
+int retile = 0;
/* X11 Window Code
******************************************************************************/
return extents.xOff;
}
-Window child_window = 0;
-
static void xmaprequest(XConf* x, XEvent* e) {
(void)x;
XMapWindow(e->xmaprequest.display, e->xmaprequest.window);
- child_window = e->xmaprequest.window;
+ Child = e->xmaprequest.window;
+ retile = 1;
}
static void xconfigure(XConf* x, XEvent* e) {
+ if (e->xconfigure.window != x->self) return;
if (e->xconfigure.width != x->width || e->xconfigure.height != x->height) {
x->width = e->xconfigure.width;
x->height = e->xconfigure.height;
x->pixmap = XCreatePixmap(x->display, x->self, x->width, x->height, x->depth);
x->xft = XftDrawCreate(x->display, x->pixmap, x->visual, x->colormap);
+ retile = 1;
}
-
- if (child_window) {
- // Get container window attributes
- XWindowAttributes attrs;
- XGetWindowAttributes(x->display, x->self, &attrs);
-
- // Move and resize child
- XMoveResizeWindow(x->display,
- child_window,
- 0, Divider+2, attrs.width, attrs.height - Divider - 2);
- }
-}
-
-static void xdestroy(XConf* x, XEvent* e) {
- (void)x, (void)e;
}
static void xclientmsg(XConf* x, XEvent* e) {
win_quit();
}
+static void xexpose(XConf* x, XEvent* e) {
+ (void)x, (void)e;
+ retile = 1;
+}
+
static void xupdate(Job* job) {
int nqueued, nevents;
do {
/* draw the regions to the window */
drawcsr csr = { .w = X.width, .h = X.height };
csr.x += ScrollWidth + 1;
- draw_statbox(&X, Tags.buffer.status);
+ draw_statbox(&X, NORMAL);
draw_view(&X, &Tags, X.font, tagrows, &csr, TagsBg, TagsFg, TagsSel, false);
+ int prev_div = Divider;
Divider = draw_hrule(&X, &csr);
draw_rect(&X, EditBg, 0, Divider+2, csr.w, csr.h);
XCopyArea(X.display, X.pixmap, X.self, X.gc, 0, 0, X.width, X.height, 0, 0);
+ if ((retile || prev_div != Divider) && Child) {
+ XMoveResizeWindow(X.display, Child, -1, Divider, X.width, X.height - Divider);
+ retile = 0;
+ }
XFlush(X.display);
}
} while ((nqueued = XEventsQueued(X.display, QueuedAfterFlush)) > 0);
// X.eventfns[ButtonPress] = xbtnpress;
// X.eventfns[ButtonRelease] = xbtnrelease;
// X.eventfns[MotionNotify] = xbtnmotion;
-
X.eventfns[MapRequest] = xmaprequest;
X.eventfns[ConfigureNotify] = xconfigure;
- X.eventfns[DestroyNotify] = xdestroy;
X.eventfns[ClientMessage] = xclientmsg;
+ X.eventfns[Expose] = xexpose;
}
void win_loop(void) {
sprintf(window_id, "%lu", X.self);
setenv("TIDE_PARENT", window_id, 1);
- if (fork() == 0) {
- char* tidecmd[] = { "tide", 0 };
- execvp(tidecmd[0], tidecmd);
- fprintf(stderr, "error: can't execute child process!\n");
- exit(1);
- }
+// for (int i = 0; i < 1; i++) {
+ if (fork() == 0) {
+ char* tidecmd[] = { "tide", 0 };
+ execvp(tidecmd[0], tidecmd);
+ fprintf(stderr, "error: can't execute child process!\n");
+ exit(1);
+ }
+// }
/* now create the window and start the event loop */
xupdate(NULL);