From: Michael D. Lowis Date: Fri, 14 Jul 2017 23:27:08 +0000 (-0400) Subject: fixed win_update callback X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=a9c13716a1bbbd59ea89e45482d353bcbc1a9757;p=projs%2Ftide.git fixed win_update callback --- diff --git a/lib/win.c b/lib/win.c index df1a6d6..c579d91 100644 --- a/lib/win.c +++ b/lib/win.c @@ -61,6 +61,7 @@ void win_dialog(char* name, void (*errfn)(char*)) { } static void win_update(int xfd, void* data) { + if (xfd < 0) return; if (x11_events_queued()) x11_events_take(); x11_flush(); diff --git a/lib/x11.c b/lib/x11.c index f59e849..509efcf 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -197,8 +197,12 @@ void x11_flush(void) { void x11_finish(void) { XCloseDisplay(X.display); /* we're exiting now. If we own the clipboard, make sure it persists */ - if (Selections[CLIPBOARD].text) - exec_cmd((char*[]){ "xcpd", NULL }, Selections[CLIPBOARD].text, NULL, NULL); + if (Selections[CLIPBOARD].text) { + char* text = Selections[CLIPBOARD].text; + size_t len = strlen(text); + exec_job((char*[]){ "xcpd", NULL }, text, len, NULL); + while (event_poll(100)); + } } /******************************************************************************/ @@ -305,11 +309,8 @@ static void handle_mouse(XEvent* e) { } static void set_focus(bool focused) { - if (focused) { - if (X.xic) XSetICFocus(X.xic); - } else { - if (X.xic) XUnsetICFocus(X.xic); - } + if (X.xic) + (focused ? XSetICFocus : XUnsetICFocus)(X.xic); Config->set_focus(focused); }