From 72b55fdd4ff8fac8f103c9979807e30a613ccac8 Mon Sep 17 00:00:00 2001 From: Axel Wagner Date: Fri, 23 Jul 2010 05:04:13 +0200 Subject: [PATCH] Get outputs on start. Create dock window for every output. --- i3bar/include/xcb.h | 1 + i3bar/src/ipc.c | 9 +++++++-- i3bar/src/main.c | 3 +++ i3bar/src/xcb.c | 48 ++++++++------------------------------------- 4 files changed, 19 insertions(+), 42 deletions(-) diff --git a/i3bar/include/xcb.h b/i3bar/include/xcb.h index 69c53b83..16bc2bdf 100644 --- a/i3bar/include/xcb.h +++ b/i3bar/include/xcb.h @@ -19,6 +19,7 @@ xcb_window_t xcb_root; void init_xcb(); void clean_xcb(); void get_atoms(); +void destroy_windows(); void create_windows(); #endif diff --git a/i3bar/src/ipc.c b/i3bar/src/ipc.c index b753c088..5d7a0bab 100644 --- a/i3bar/src/ipc.c +++ b/i3bar/src/ipc.c @@ -9,6 +9,7 @@ #include "common.h" #include "outputs.h" #include "workspaces.h" +#include "xcb.h" #include "ipc.h" ev_io* i3_connection; @@ -42,12 +43,16 @@ void got_workspace_reply(char *reply) { } void got_subscribe_reply(char *reply) { - printf("Got Subscribe Reply: %s\n", reply); + printf("Got Subscribe Reply: %s\n", reply); } void got_output_reply(char *reply) { + printf("Got Outputs-Data!\nDestroying Windows...\n"); + destroy_windows(); + printf("Parsing JSON...\n"); parse_outputs_json(reply); - printf("Got Outputs-Data!\n"); + printf("Creating_Windows,,,\n"); + create_windows(); } handler_t reply_handlers[] = { diff --git a/i3bar/src/main.c b/i3bar/src/main.c index dbb6104c..b42d227c 100644 --- a/i3bar/src/main.c +++ b/i3bar/src/main.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -17,6 +18,8 @@ int main(int argc, char **argv) { subscribe_events(); + i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_OUTPUTS, NULL); + ev_loop(main_loop, 0); ev_default_destroy(); diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index d23d114b..20cc23c1 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -42,6 +42,14 @@ void get_atoms() { printf("Got Atoms\n"); } +void destroy_windows() { + i3_output *walk = outputs; + while(walk != NULL) { + xcb_destroy_window(xcb_connection, walk->win); + walk->win = XCB_NONE; + } +} + void create_windows() { uint32_t mask; uint32_t values[2]; @@ -83,43 +91,3 @@ void create_windows() { } xcb_flush(xcb_connection); } - -#if 0 - xcb_screen_t* screens = xcb_setup_roots_iterator(xcb_get_setup(xcb_connection)).data; - - xcb_gcontext_t ctx = xcb_generate_id(xcb_connection); - - xcb_window_t win = screens->root; - uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES; - uint32_t values[2]; - values[0] = screens->black_pixel; - values[1] = 0; - xcb_create_gc(xcb_connection, ctx, win, mask, values); - - request_atoms(); - - /* Fenster erzeugen */ - win = xcb_generate_id(xcb_connection); - mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; - values[0] = screens->white_pixel; - values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS; - xcb_create_window(xcb_connection, screens->root_depth, win, screens->root, - 10, 10, 20, 20, 1, - XCB_WINDOW_CLASS_INPUT_OUTPUT, screens->root_visual, - mask, values); - - get_atoms(); - - xcb_change_property(xcb_connection, - XCB_PROP_MODE_REPLACE, - win, - atoms[_NET_WM_WINDOW_TYPE], - atoms[ATOM], - 32, - 1, - (unsigned char *) &atoms[_NET_WM_WINDOW_TYPE_DOCK]); - - xcb_map_window(xcb_connection, win); - - xcb_flush(xcb_connection); -#endif -- 2.39.5