diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2013-11-22 15:48:45 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2013-11-22 15:48:45 +0100 |
commit | d3beff23395356ec71fcc35a3b802163e12df73e (patch) | |
tree | ca45a904db22ed53b46ba98631ec4cdef83e6a4c /i3-input | |
parent | ca39289e3e333f1abe63c155e6516375920a0df2 (diff) | |
download | i3-d3beff23395356ec71fcc35a3b802163e12df73e.tar.gz i3-d3beff23395356ec71fcc35a3b802163e12df73e.zip |
make i3bar use libi3’s root_atom_contents()
This removes code duplication, which will be useful for a subsequent
commit.
Furthermore, we now don’t open X11 connections unnecessarily in some
corner cases.
Diffstat (limited to 'i3-input')
-rw-r--r-- | i3-input/main.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/i3-input/main.c b/i3-input/main.c index 49db4df2..da95c903 100644 --- a/i3-input/main.c +++ b/i3-input/main.c @@ -368,23 +368,23 @@ int main(int argc, char *argv[]) { printf("using format \"%s\"\n", format); + int screen; + conn = xcb_connect(NULL, &screen); + if (!conn || xcb_connection_has_error(conn)) + die("Cannot open display\n"); + if (socket_path == NULL) - socket_path = root_atom_contents("I3_SOCKET_PATH"); + socket_path = root_atom_contents("I3_SOCKET_PATH", conn, screen); if (socket_path == NULL) socket_path = "/tmp/i3-ipc.sock"; sockfd = ipc_connect(socket_path); - int screens; - conn = xcb_connect(NULL, &screens); - if (!conn || xcb_connection_has_error(conn)) - die("Cannot open display\n"); - /* Request the current InputFocus to restore when i3-input exits. */ focus_cookie = xcb_get_input_focus(conn); - root_screen = xcb_aux_get_screen(conn, screens); + root_screen = xcb_aux_get_screen(conn, screen); root = root_screen->root; symbols = xcb_key_symbols_alloc(conn); |