From 7f3a9cb15a7a7c17aa588cb4f17906de088cde2f Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 4 May 2017 14:03:35 -0400 Subject: [PATCH] use XEventsQueued to work around an issue where selection requests are sometimes not delivered promptly until some other event occurs. --- TODO.sync-conflict-20170503-192815.md | 33 +++++++++++++++++++++++++++ inc/edit.h | 1 + inc/x11.h | 1 + lib/win.c | 8 +++---- lib/x11.c | 4 ++++ 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 TODO.sync-conflict-20170503-192815.md diff --git a/TODO.sync-conflict-20170503-192815.md b/TODO.sync-conflict-20170503-192815.md new file mode 100644 index 0000000..b5753e1 --- /dev/null +++ b/TODO.sync-conflict-20170503-192815.md @@ -0,0 +1,33 @@ +# Issue List + +Up Next: + +* refactor x11.c and win.c +* Make Fn keys execute nth command in the tags buffers +* Run commands in the background and don't block the main thread. +* check for file changes on save +* check for file changes when window regains focus +* 100% coverage with unit and unit-integration tests +* right click to fetch file or line +* Status line should omit characters from beginning of path to make file path fit + +Straight-up Bugs: + +* double free error on picking a tag with nothing in the buffer +* fix crash on saving read-only file +* fix crash on save to file that can't be created +* tab inserts dont coalesce like one would expect + +The Future: + +* shortcut to repeat previous operation +* add command line flags to toggle options (Tabs, Indent, etc..) +* add command env vars to set options (Tabs, Indent, etc..) +* implement command diffing logic to optimize the undo/redo log + +# Auxillary Programs + +* Visual diff tool +* Win-like terminal emulator +* File browser +* Acme-like window manager diff --git a/inc/edit.h b/inc/edit.h index fc39bc7..2967638 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -212,6 +212,7 @@ enum { ScrollLines = 4, /* number of lines to scroll by for mouse wheel scrolling */ BufSize = 8192, /* default buffer size */ FontCacheSize = 16, /* Maximum number of fonts allowed in the font cache */ + EventTimeout = 100, /* Maximum blocking wait time for events */ }; /* choose the font to use for xft */ diff --git a/inc/x11.h b/inc/x11.h index 9d04255..9498680 100644 --- a/inc/x11.h +++ b/inc/x11.h @@ -139,6 +139,7 @@ void x11_flip(void); void x11_flush(void); void x11_finish(void); +int x11_events_queued(void); bool x11_events_await(unsigned int ms); void x11_events_take(void); diff --git a/lib/win.c b/lib/win.c index d7d4b36..00ded98 100644 --- a/lib/win.c +++ b/lib/win.c @@ -77,14 +77,14 @@ void win_loop(void) { x11_show(); x11_flip(); while (x11_running()) { - bool pending = x11_events_await(200 /* ms */); - if (update_focus() || pending) { + bool pending = x11_events_await(EventTimeout); + int nevents = x11_events_queued(); + if (update_focus() || pending || nevents) { x11_events_take(); if (x11_running()) x11_flip(); - } else { - x11_flush(); } + x11_flush(); } x11_finish(); } diff --git a/lib/x11.c b/lib/x11.c index d3bc4de..f0d97e1 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -331,6 +331,10 @@ void x11_handle_event(XEvent* e) { } } +int x11_events_queued(void) { + return XEventsQueued(X.display, QueuedAfterFlush); +} + bool x11_events_await(unsigned int ms) { fd_set fds; int xfd = ConnectionNumber(X.display), redraw = 1; -- 2.49.0