XSetWMProtocols(x->display, x->self, &wmDeleteMessage, 1);
/* setup window attributes and events */
XSetWindowAttributes swa;
- swa.backing_store = WhenMapped;
swa.bit_gravity = NorthWestGravity;
- XChangeWindowAttributes(x->display, x->self, CWBackingStore|CWBitGravity, &swa);
+ XChangeWindowAttributes(x->display, x->self,
+ CWBackingStore|CWBitGravity,
+// CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask | CWColormap,
+ &swa);
XSelectInput(x->display, x->self, evmask);
}
XGCValues gcv;
gcv.foreground = WhitePixel(x->display, x->screen);
gcv.graphics_exposures = False;
- x->gc = XCreateGC(x->display, x->self, GCForeground|GCGraphicsExposures, &gcv);
+ x->gc = XCreateGC(x->display, x->self, GCGraphicsExposures, &gcv);
x->eventfns[FocusIn] = xfocus;
x->eventfns[FocusOut] = xfocus;
x->eventfns[ConfigureNotify] = xresize;
ce.height = x->height;
XSendEvent(x->display, x->self, False, StructureNotifyMask, (XEvent *)&ce);
XMapWindow(x->display, x->self);
+ XSync(x->display, False);
+
+ /* Waiting for window mapping */
+ XEvent ev;
+ do {
+ XNextEvent(x->display, &ev);
+ if (XFilterEvent(&ev, None))
+ continue;
+ xresize(x, &ev);
+ } while (ev.type != MapNotify);
}
XftFont* x11_font_load(XConf* x, char* name) {
}
static void xupdate(Job* job) {
- int nevents, nqueued;
+ int nqueued;
do {
nqueued = XEventsQueued(X.display, QueuedAfterFlush);
- XTimeCoord* coords = XGetMotionEvents(X.display, X.self, CurrentTime, CurrentTime, &nevents);
- if (coords) XFree(coords);
for (XEvent e; XPending(X.display);) {
XNextEvent(X.display, &e);
if (!XFilterEvent(&e, None) && X.eventfns[e.type])
draw_scroll(&X, &csr, win_view(EDIT), Divider);
XCopyArea(X.display, X.pixmap, X.self, X.gc, 0, 0, X.width, X.height, 0, 0);
SyncMouse = false;
+ XFlush(X.display);
}
} while ((nqueued = XEventsQueued(X.display, QueuedAfterFlush)) > 0);
}
void win_init(KeyBinding* bindings) {
Keys = bindings;
- view_init(&Regions[TAGS], NULL);
- view_init(&Regions[EDIT], NULL);
signal(SIGPIPE, SIG_IGN); // Ignore the SIGPIPE signal
setlocale(LC_CTYPE, "");
XSetLocaleModifiers("");
| ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
- | StructureNotifyMask
| PropertyChangeMask
| ExposureMask
+ | VisibilityChangeMask
+ | StructureNotifyMask
);
x11_init_gc(&X);
x11_sel_init(&X);
- x11_centerwin(&X);
x11_show(&X);
/* register event handlers */
X.eventfns[ButtonRelease] = xbtnrelease;
X.eventfns[MotionNotify] = xbtnmotion;
X.eventfns[ClientMessage] = xclientmsg;
-
- /* Populate the tags region */
- View* view = win_view(TAGS);
- view_putstr(view, TagString);
- buf_logclear(&(view->buffer));
- win_prop_set("TIDE", "", "tide");
}
void win_title(char* path) {
}
void win_loop(void) {
- X.running = True;
- XMapWindow(X.display, X.self);
tide_send("ADD");
job_spawn(ConnectionNumber(X.display), xupdate, 0, 0);
- while (X.running)
+ XSync(X.display, False);
+ while (X.running) {
if (job_poll(Timeout))
xupdate(NULL);
+ }
}
void win_quit(void) {
if (tag) {
for (; *cmd && !isspace(*cmd); cmd++); /* strip off tag name */
for (; *cmd && isspace(*cmd); cmd++); /* strip off leading space */
- //tag_exec(tag, (*cmd ? strdup(cmd) : arg));
arg = (*cmd ? strdup(cmd) : arg);
tag->action(!arg || !*arg ? NULL : arg);
} else if (arg) {
/* create the window */
win_init(Bindings);
+ /* Initialize the views */
+ view_init(&Regions[TAGS], NULL);
+ view_init(&Regions[EDIT], NULL);
+ view_putstr(win_view(TAGS), TagString);
+ view_resize(win_view(TAGS), 640, 1);
+ buf_logclear(win_buf(TAGS));
+ win_prop_set("TIDE", "", "tide");
+
/* if we still have args left we're going to open it in this instance */
if (*argv) {
char* path = realpath(*argv, NULL);
}
/* now create the window and start the event loop */
+ xupdate(NULL);
win_loop();
return 0;
}