diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-04-12 20:08:19 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-04-12 20:08:19 -0400 |
commit | 00996e01627cf984c5c441bfb95bd2f0c0fde085 (patch) | |
tree | cf8d1d60a04aa8510ea5c451c45280c91619f4f1 /window-xlib.c | |
parent | 7f72a6a1b16b8d754943a76d1e87ccd9d51a38c3 (diff) | |
download | runes-00996e01627cf984c5c441bfb95bd2f0c0fde085.tar.gz runes-00996e01627cf984c5c441bfb95bd2f0c0fde085.zip |
fix threading issues
Diffstat (limited to 'window-xlib.c')
-rw-r--r-- | window-xlib.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/window-xlib.c b/window-xlib.c index d89af2e..8320d13 100644 --- a/window-xlib.c +++ b/window-xlib.c @@ -15,7 +15,8 @@ static char *atom_names[RUNES_NUM_ATOMS] = { "_NET_WM_ICON_NAME", "_NET_WM_NAME", "UTF8_STRING", - "WM_PROTOCOLS" + "WM_PROTOCOLS", + "RUNES_FLUSH" }; static void runes_window_backend_get_next_event(uv_work_t *req); @@ -25,6 +26,7 @@ static void runes_window_backend_init_wm_properties( RunesTerm *t, int argc, char *argv[]); static void runes_window_backend_resize_window( RunesTerm *t, int width, int height); +static void runes_window_backend_flush(RunesTerm *t); void runes_window_backend_init(RunesTerm *t) { @@ -32,6 +34,8 @@ void runes_window_backend_init(RunesTerm *t) unsigned long white; XIM im; + XInitThreads(); + w->dpy = XOpenDisplay(NULL); white = WhitePixel(w->dpy, DefaultScreen(w->dpy)); w->w = XCreateSimpleWindow( @@ -91,12 +95,19 @@ cairo_surface_t *runes_window_backend_surface_create(RunesTerm *t) w->dpy, w->w, vis, attrs.width, attrs.height); } -void runes_window_backend_flush(RunesTerm *t) +void runes_window_backend_request_flush(RunesTerm *t) { - cairo_set_source_surface(t->backend_cr, cairo_get_target(t->cr), 0.0, 0.0); - cairo_paint(t->backend_cr); - runes_display_draw_cursor(t); + XEvent e; + + e.xclient.type = ClientMessage; + e.xclient.window = t->w.w; + e.xclient.format = 32; + e.xclient.data.l[0] = t->w.atoms[RUNES_ATOM_RUNES_FLUSH]; + + XSendEvent(t->w.dpy, t->w.w, False, NoEventMask, &e); + XLockDisplay(t->w.dpy); XFlush(t->w.dpy); + XUnlockDisplay(t->w.dpy); } void runes_window_backend_get_size(RunesTerm *t, int *xpixel, int *ypixel) @@ -228,6 +239,9 @@ static void runes_window_backend_process_event(uv_work_t *req, int status) e ); } + else if (a == w->atoms[RUNES_ATOM_RUNES_FLUSH]) { + runes_window_backend_flush(t); + } break; } default: @@ -305,3 +319,11 @@ static void runes_window_backend_resize_window( runes_pty_backend_set_window_size(t); } } + +static void runes_window_backend_flush(RunesTerm *t) +{ + cairo_set_source_surface(t->backend_cr, cairo_get_target(t->cr), 0.0, 0.0); + cairo_paint(t->backend_cr); + runes_display_draw_cursor(t); + XFlush(t->w.dpy); +} |