]> git.sur5r.net Git - i3/i3/commitdiff
move i3 sync code into sync_respond (for following commits)
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 30 Mar 2018 19:05:32 +0000 (21:05 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 30 Mar 2018 19:05:32 +0000 (21:05 +0200)
Makefile.am
include/all.h
include/sync.h [new file with mode: 0644]
src/handlers.c
src/sync.c [new file with mode: 0644]

index 184b07343f8cc0b143c1eeaa8feba3d969b1b74c..557c65a58fe9e4506c8529c8d549f3a033a78f58 100644 (file)
@@ -562,6 +562,7 @@ i3_SOURCES = \
        src/sd-daemon.c \
        src/sighandler.c \
        src/startup.c \
+       src/sync.c \
        src/tree.c \
        src/util.c \
        src/version.c \
index ecc875d08298f6b33b8b03340b84c8d1e33266a3..e93b066bc59f64058dce80ae77f7d775a61a8bc7 100644 (file)
@@ -82,4 +82,5 @@
 #include "fake_outputs.h"
 #include "display_version.h"
 #include "restore_layout.h"
+#include "sync.h"
 #include "main.h"
diff --git a/include/sync.h b/include/sync.h
new file mode 100644 (file)
index 0000000..e726f99
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * vim:ts=4:sw=4:expandtab
+ *
+ * i3 - an improved dynamic tiling window manager
+ * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
+ *
+ * sync.c: i3 sync protocol: https://i3wm.org/docs/testsuite.html#i3_sync
+ *
+ */
+#pragma once
+
+#include <xcb/xcb.h>
+
+void sync_respond(xcb_window_t window, uint32_t rnd);
index 50fd85669223267e123a97ebe5bdfea09c9ab1e3..d5023b9d9eeddbc0d24ef119da9fafb0fa8568dd 100644 (file)
@@ -800,21 +800,7 @@ static void handle_client_message(xcb_client_message_event_t *event) {
     } else if (event->type == A_I3_SYNC) {
         xcb_window_t window = event->data.data32[0];
         uint32_t rnd = event->data.data32[1];
-        DLOG("[i3 sync protocol] Sending random value %d back to X11 window 0x%08x\n", rnd, window);
-
-        void *reply = scalloc(32, 1);
-        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);
+        sync_respond(window, rnd);
     } else if (event->type == A__NET_REQUEST_FRAME_EXTENTS) {
         /*
          * A client can request an estimate for the frame size which the window
diff --git a/src/sync.c b/src/sync.c
new file mode 100644 (file)
index 0000000..dafbc35
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * vim:ts=4:sw=4:expandtab
+ *
+ * i3 - an improved dynamic tiling window manager
+ * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
+ *
+ * sync.c: i3 sync protocol: https://i3wm.org/docs/testsuite.html#i3_sync
+ *
+ */
+#include "all.h"
+
+void sync_respond(xcb_window_t window, uint32_t rnd) {
+    DLOG("[i3 sync protocol] Sending random value %d back to X11 window 0x%08x\n", rnd, window);
+
+    void *reply = scalloc(32, 1);
+    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);
+}