From 1bdbe1264024f61ec75d4efdc5e9fa072a9fe314 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 1 May 2017 15:10:27 -0400 Subject: [PATCH] tweaked redraw logic to call onupdate before and after layout. This is a stop gap until i rework the redraw logic --- lib/win.c | 7 +++++-- lib/x11.c | 17 ++++++----------- xedit.c | 1 - 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/lib/win.c b/lib/win.c index 69aa0c2..db1d76b 100644 --- a/lib/win.c +++ b/lib/win.c @@ -170,9 +170,12 @@ static void layout(int width, int height) { static void onredraw(int width, int height) { size_t fheight = x11_font_height(Font); size_t fwidth = x11_font_width(Font); - onupdate(); // Let the user program update the status and such + /* layout and draw the three text regions */ + onupdate(); // Let the user program update the status and such layout(width, height); + onupdate(); // Let the user program update the status and such + for (int i = 0; i < SCROLL; i++) { View* view = win_view(i); x11_draw_rect((i == TAGS ? CLR_BASE02 : CLR_BASE03), @@ -194,7 +197,7 @@ static void onredraw(int width, int height) { x11_draw_rect(CLR_BASE01, Regions[SCROLL].width, Regions[SCROLL].y - 2, 1, Regions[SCROLL].height); x11_draw_rect(CLR_BASE00, 0, Regions[SCROLL].y - 2, Regions[SCROLL].width, thumbreg); x11_draw_rect(CLR_BASE03, 0, thumboff, Regions[SCROLL].width, thumbsz); - + /* place the cursor on screen */ if (Regions[Focused].csrx != SIZE_MAX && Regions[Focused].csry != SIZE_MAX) { x11_draw_rect(CLR_BASE3, diff --git a/lib/x11.c b/lib/x11.c index c56ea63..7fe2dbe 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -14,10 +14,6 @@ static void selclear(XEvent* evnt); static void selnotify(XEvent* evnt); static void selrequest(XEvent* evnt); -#ifndef MAXFONTS -#define MAXFONTS 16 -#endif - struct XFont { struct { int height; @@ -326,21 +322,20 @@ void x11_loop(void) { fd_set fds; int xfd = ConnectionNumber(X.display); for (XEvent e; Running;) { - struct timeval tv = { .tv_usec = 100000 }; + /* configure for 100ms timeout */ + struct timeval tv = { .tv_usec = 50000 }; FD_ZERO(&fds); FD_SET(xfd, &fds); - + + /* wait for events with a timeout, then handle them if we got any */ int ready = select(xfd+1, &fds, NULL, NULL, &tv); - if (ready > 0) + if (ready > 0) { x11_handle_events(); - - if (Running) { - /* redraw the window */ Config->redraw(X.width, X.height); XCopyArea(X.display, X.pixmap, X.window, X.gc, 0, 0, X.width, X.height, 0, 0); + } else { XFlush(X.display); } - } XCloseDisplay(X.display); /* we're exiting now. If we own the clipboard, make sure it persists */ diff --git a/xedit.c b/xedit.c index c0dafa6..dea5613 100644 --- a/xedit.c +++ b/xedit.c @@ -541,7 +541,6 @@ void onupdate(void) { strncat(status, path, remlen); win_settext(STATUS, status_bytes); win_view(STATUS)->selection = (Sel){0,0,0}; - /* calculate and update scroll region */ View* view = win_view(EDIT); -- 2.49.0