]> git.sur5r.net Git - i3/i3/blobdiff - src/main.c
Merge branch 'master' into next
[i3/i3] / src / main.c
index 6028e1ddf92aab87168f3f156b1967c97b78281e..878ea5bcf259314910490027c640ae0aa7a6accb 100644 (file)
@@ -31,6 +31,10 @@ struct rlimit original_rlimit_core;
 /** The number of file descriptors passed via socket activation. */
 int listen_fds;
 
+/* We keep the xcb_check watcher around to be able to enable and disable it
+ * temporarily for drag_pointer(). */
+static struct ev_check *xcb_check;
+
 static int xkb_event_base;
 
 int xkb_current_group;
@@ -143,6 +147,23 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) {
     }
 }
 
+/*
+ * Enable or disable the main X11 event handling function.
+ * This is used by drag_pointer() which has its own, modal event handler, which
+ * takes precedence over the normal event handler.
+ *
+ */
+void main_set_x11_cb(bool enable) {
+    DLOG("Setting main X11 callback to enabled=%d\n", enable);
+    if (enable) {
+        ev_check_start(main_loop, xcb_check);
+        /* Trigger the watcher explicitly to handle all remaining X11 events.
+         * drag_pointer()’s event handler exits in the middle of the loop. */
+        ev_feed_event(main_loop, xcb_check, 0);
+    } else {
+        ev_check_stop(main_loop, xcb_check);
+    }
+}
 
 /*
  * When using xmodmap to change the keyboard mapping, this event
@@ -295,7 +316,7 @@ int main(int argc, char *argv[]) {
     init_logging();
 
     /* On release builds, disable SHM logging by default. */
-    shmlog_size = (is_debug_build() ? default_shmlog_size : 0);
+    shmlog_size = (is_debug_build() || strstr(argv[0], "i3-with-shmlog") != NULL ? default_shmlog_size : 0);
 
     start_argv = argv;
 
@@ -618,6 +639,8 @@ int main(int argc, char *argv[]) {
         }
     }
 
+    restore_connect();
+
     /* Setup NetWM atoms */
     #define xmacro(name) \
         do { \
@@ -740,7 +763,7 @@ int main(int argc, char *argv[]) {
 
     struct ev_io *xcb_watcher = scalloc(sizeof(struct ev_io));
     struct ev_io *xkb = scalloc(sizeof(struct ev_io));
-    struct ev_check *xcb_check = scalloc(sizeof(struct ev_check));
+    xcb_check = scalloc(sizeof(struct ev_check));
     struct ev_prepare *xcb_prepare = scalloc(sizeof(struct ev_prepare));
 
     ev_io_init(xcb_watcher, xcb_got_event, xcb_get_file_descriptor(conn), EV_READ);