From: Michael Stapelberg Date: Wed, 17 Aug 2011 11:37:08 +0000 (+0200) Subject: Bugfix: Set focus to where the mouse pointer is when starting (Thanks nutron) X-Git-Tag: 4.0.2~38^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=09ad9808f6aaa421f90e38d20c9442e86e2d8bda;p=i3%2Fi3 Bugfix: Set focus to where the mouse pointer is when starting (Thanks nutron) Fixes #477 --- diff --git a/src/main.c b/src/main.c index 39b9ec9a..90e5eb06 100644 --- a/src/main.c +++ b/src/main.c @@ -279,6 +279,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) { @@ -428,6 +429,20 @@ int main(int argc, char *argv[]) { 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 */