X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=xcb.c;h=a2477633631c09866f68043b3fad1844a34e5f79;hb=b5bbd2fe048e8aa44c619cd8ec8c2691ee142d2d;hp=818bf757d2f3bd9d52632a518014cc9c26a322db;hpb=e03e93fd1bb6f347b13d42796c1f0dada4ca8bb5;p=i3%2Fi3lock diff --git a/xcb.c b/xcb.c index 818bf75..a247763 100644 --- a/xcb.c +++ b/xcb.c @@ -1,7 +1,7 @@ /* * vim:ts=4:sw=4:expandtab * - * © 2010-2011 Michael Stapelberg + * © 2010-2012 Michael Stapelberg * * xcb.c: contains all functions which use XCB to talk to X11. Mostly wrappers * around the rather complicated/ugly parts of the XCB API. @@ -20,6 +20,9 @@ #include "cursors.h" +xcb_connection_t *conn; +xcb_screen_t *screen; + #define curs_invisible_width 8 #define curs_invisible_height 8 @@ -53,7 +56,7 @@ static uint32_t get_colorpixel(char *hex) { (strtol(strgroups[2], NULL, 16))}; return (rgb16[0] << 16) + (rgb16[1] << 8) + rgb16[2]; -} +} xcb_visualtype_t *get_root_visual_type(xcb_screen_t *screen) { xcb_visualtype_t *visual_type = NULL; @@ -78,18 +81,19 @@ xcb_visualtype_t *get_root_visual_type(xcb_screen_t *screen) { return NULL; } -xcb_pixmap_t create_bg_pixmap(xcb_connection_t *conn, xcb_screen_t *scr, char *color) { +xcb_pixmap_t create_bg_pixmap(xcb_connection_t *conn, xcb_screen_t *scr, u_int32_t* resolution, char *color) { xcb_pixmap_t bg_pixmap = xcb_generate_id(conn); xcb_create_pixmap(conn, scr->root_depth, bg_pixmap, scr->root, - scr->width_in_pixels, scr->height_in_pixels); + resolution[0], resolution[1]); /* Generate a Graphics Context and fill the pixmap with background color * (for images that are smaller than your screen) */ xcb_gcontext_t gc = xcb_generate_id(conn); uint32_t values[] = { get_colorpixel(color) }; xcb_create_gc(conn, gc, bg_pixmap, XCB_GC_FOREGROUND, values); - xcb_rectangle_t rect = { 0, 0, scr->width_in_pixels, scr->height_in_pixels }; + xcb_rectangle_t rect = { 0, 0, resolution[0], resolution[1] }; xcb_poly_fill_rectangle(conn, bg_pixmap, gc, 1, &rect); + xcb_free_gc(conn, gc); return bg_pixmap; } @@ -114,10 +118,11 @@ xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, c values[2] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | - XCB_EVENT_MASK_VISIBILITY_CHANGE; + XCB_EVENT_MASK_VISIBILITY_CHANGE | + XCB_EVENT_MASK_STRUCTURE_NOTIFY; xcb_create_window(conn, - 24, + XCB_COPY_FROM_PARENT, win, /* the window id */ scr->root, /* parent == root */ 0, 0, @@ -167,6 +172,8 @@ uint32_t get_mod_mask(xcb_connection_t *conn, xcb_key_symbols_t *symbols, uint32 } } + free(modeswitchcodes); + free(modmap_r); return 0; }