From: Michael Stapelberg Date: Wed, 17 Aug 2011 11:37:33 +0000 (+0200) Subject: Merge branch 'master' into next X-Git-Tag: 4.1~217 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4cf2cab626d16d1b9de3dc93e0a8ebb1da8a0351;hp=-c;p=i3%2Fi3 Merge branch 'master' into next --- 4cf2cab626d16d1b9de3dc93e0a8ebb1da8a0351 diff --combined src/main.c index 624bcc1b,90e5eb06..7cad3d94 --- a/src/main.c +++ b/src/main.c @@@ -5,8 -5,6 +5,8 @@@ #include #include "all.h" +#include "sd-daemon.h" + static int xkb_event_base; int xkb_current_group; @@@ -281,6 -279,7 +281,7 @@@ int main(int argc, char *argv[]) root = root_screen->root; root_depth = root_screen->root_depth; xcb_get_geometry_cookie_t gcookie = xcb_get_geometry(conn, root); + xcb_query_pointer_cookie_t pointercookie = xcb_query_pointer(conn, root); load_configuration(conn, override_configpath, false); if (only_check_config) { @@@ -430,6 -429,20 +431,20 @@@ randr_init(&randr_base); } + xcb_query_pointer_reply_t *pointerreply; + if (!(pointerreply = xcb_query_pointer_reply(conn, pointercookie, NULL))) + die("Could not query pointer position\n"); + + DLOG("Pointer at %d, %d\n", pointerreply->root_x, pointerreply->root_y); + Output *output = get_output_containing(pointerreply->root_x, pointerreply->root_y); + if (!output) { + ELOG("ERROR: No screen at (%d, %d), starting on the first screen\n", + pointerreply->root_x, pointerreply->root_y); + output = get_first_output(); + } + + con_focus(con_descend_focused(output_get_content(output->con))); + tree_render(); /* Create the UNIX domain socket for IPC */ @@@ -443,21 -456,6 +458,21 @@@ ev_io_start(main_loop, ipc_io); } + /* Also handle the UNIX domain sockets passed via socket activation */ + int fds = sd_listen_fds(1); + if (fds < 0) + ELOG("socket activation: Error in sd_listen_fds\n"); + else if (fds == 0) + DLOG("socket activation: no sockets passed\n"); + else { + for (int fd = SD_LISTEN_FDS_START; fd < (SD_LISTEN_FDS_START + fds); fd++) { + DLOG("socket activation: also listening on fd %d\n", fd); + struct ev_io *ipc_io = scalloc(sizeof(struct ev_io)); + ev_io_init(ipc_io, ipc_new_client, fd, EV_READ); + ev_io_start(main_loop, ipc_io); + } + } + /* Set up i3 specific atoms like I3_SOCKET_PATH and I3_CONFIG_PATH */ x_set_i3_atoms();