From: Michael Stapelberg Date: Thu, 22 Sep 2011 21:08:42 +0000 (+0100) Subject: Implement the I3_SYNC client protocol X-Git-Tag: 4.1~139^2~13 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1481cd95c941e87fff8713a514ddc26700ce0b7d;p=i3%2Fi3 Implement the I3_SYNC client protocol This is mainly useful for the testsuite. The tests can wait until i3 processed all X11 events and then continue. This eliminates sleep() calls which leads to a more robust and faster testsuite. --- diff --git a/include/atoms.xmacro b/include/atoms.xmacro index 7f83a7ee..309a3325 100644 --- a/include/atoms.xmacro +++ b/include/atoms.xmacro @@ -24,3 +24,4 @@ xmacro(WM_TAKE_FOCUS) xmacro(WM_WINDOW_ROLE) xmacro(I3_SOCKET_PATH) xmacro(I3_CONFIG_PATH) +xmacro(I3_SYNC) diff --git a/src/handlers.c b/src/handlers.c index 267159ec..b3cb1df7 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -648,6 +648,25 @@ static int handle_client_message(xcb_client_message_event_t *event) { tree_render(); x_push_changes(croot); + } else if (event->type == A_I3_SYNC) { + DLOG("i3 sync, yay\n"); + xcb_window_t window = event->data.data32[0]; + uint32_t rnd = event->data.data32[1]; + DLOG("Sending random value %d back to X11 window 0x%08x\n", rnd, window); + + void *reply = scalloc(32); + xcb_client_message_event_t *ev = reply; + + ev->response_type = XCB_CLIENT_MESSAGE; + ev->window = window; + ev->type = A_I3_SYNC; + ev->format = 32; + ev->data.data32[0] = window; + ev->data.data32[1] = rnd; + + xcb_send_event(conn, false, window, XCB_EVENT_MASK_NO_EVENT, (char*)ev); + xcb_flush(conn); + free(reply); } else { ELOG("unhandled clientmessage\n"); return 0;