From d1ecdfbd55b0854dc467205ef6c6f6aede004835 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 16 Jan 2019 20:38:34 -0500 Subject: [PATCH] maybe fixed some random issues --- TODO.md | 3 ++ log.txt | 117 +++++++++++++++++++++++++++++++++++++++++++++++ src/lib/x11.c | 6 ++- src/lib/x11_gc.c | 12 ++++- src/registrar.c | 26 +++++------ src/tide.c | 33 +++++++------ 6 files changed, 164 insertions(+), 33 deletions(-) create mode 100644 log.txt diff --git a/TODO.md b/TODO.md index 1c66a91..5f99894 100644 --- a/TODO.md +++ b/TODO.md @@ -7,6 +7,9 @@ * registrar: doesnt match open windows when new file created and is then opened for edit or line number * registrar: group by hostname or group env var in registrar * tide: gap buffer does not handle UTF-8 currently +* tide: sometimes tide starts with white screen until an event occurs +* tide: highlight current line if jumped to line is 0 +* tide: jumping to line should call XMapRaised ## BACKLOG diff --git a/log.txt b/log.txt new file mode 100644 index 0000000..7878d69 --- /dev/null +++ b/log.txt @@ -0,0 +1,117 @@ +syncing +update start +get events +process events + process event +resize + process event +resize + process event +resize + process event +resize + process event + process event +resize + process event +resize + process event +resize + process event +resize + process event + process event + process event + process event + process event + process event +redraw +flush +update start +syncing again +spawning job + +poll() +done + +poll() +done + +poll() +done + +poll() +done + +poll() +done + +poll() +done + +poll() +done + +poll() +done + +poll() +done + +poll() +done + +poll() +done + +poll() +done + +poll() +done + +poll() +done + +poll() +done + +poll() +update start +get events +process events + process event +redraw +flush +update start +update start +get events +process events +redraw +flush +update start +done + +poll() +done + +poll() +update start +get events +process events + process event +redraw +flush +get events +process events + process event +redraw +flush +update start +update start +get events +process events +redraw +flush +update start +done diff --git a/src/lib/x11.c b/src/lib/x11.c index 9a1730d..74df7d9 100644 --- a/src/lib/x11.c +++ b/src/lib/x11.c @@ -51,9 +51,11 @@ void x11_mkwin(XConf* x, int width, int height, int evmask) { 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); } diff --git a/src/lib/x11_gc.c b/src/lib/x11_gc.c index 2d59a22..93b3000 100644 --- a/src/lib/x11_gc.c +++ b/src/lib/x11_gc.c @@ -26,7 +26,7 @@ void x11_init_gc(XConf* x) { 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; @@ -60,6 +60,16 @@ void x11_show(XConf* x) { 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) { diff --git a/src/registrar.c b/src/registrar.c index b7f3a0f..d956382 100644 --- a/src/registrar.c +++ b/src/registrar.c @@ -147,19 +147,19 @@ void propnotify(XConf* x, XEvent* e) { if(file) XFree(file); if(addr) XFree(addr); } - /* cleanup any invalid windows */ - TWindow* wins = Windows; - Windows = NULL; - while (wins) { - TWindow* curr = wins; - wins = curr->next; - if (!wins->path) { - free(curr); - } else { - curr->next = Windows; - Windows = curr; - } - } +// /* cleanup any invalid windows */ +// TWindow* wins = Windows; +// Windows = NULL; +// while (wins) { +// TWindow* curr = wins; +// wins = curr->next; +// if (!wins->path) { +// free(curr); +// } else { +// curr->next = Windows; +// Windows = curr; +// } +// } } void find_windows(XConf* x) { diff --git a/src/tide.c b/src/tide.c index 13b2c7a..bb22ec9 100644 --- a/src/tide.c +++ b/src/tide.c @@ -251,11 +251,9 @@ static void xclientmsg(XConf* x, XEvent* e) { } 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]) @@ -280,14 +278,13 @@ static void xupdate(Job* job) { 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(""); @@ -306,13 +303,13 @@ void win_init(KeyBinding* bindings) { | 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 */ @@ -321,12 +318,6 @@ void win_init(KeyBinding* bindings) { 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) { @@ -356,13 +347,13 @@ void win_prop_set(char* xname, char* ename, char* value) { } 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) { @@ -445,7 +436,6 @@ static void exec(char* cmd, char* arg) { 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) { @@ -922,6 +912,14 @@ int main(int argc, char** argv) { /* 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); @@ -934,6 +932,7 @@ int main(int argc, char** argv) { } /* now create the window and start the event loop */ + xupdate(NULL); win_loop(); return 0; } -- 2.49.0