diff --git a/awesome-menu.c b/awesome-menu.c index 29b8a3207..9b3154edf 100644 --- a/awesome-menu.c +++ b/awesome-menu.c @@ -500,7 +500,7 @@ redraw(void) else if(geometry.width) draw_rectangle(globalconf.ctx, geometry, 1.0, true, globalconf.styles.normal.bg); - simplewindow_refresh_drawable(globalconf.sw, globalconf.default_screen); + simplewindow_refresh_drawable(globalconf.sw); xcb_aux_sync(globalconf.connection); } @@ -1374,7 +1374,7 @@ main(int argc, char **argv) break; case XCB_EXPOSE: if(!((xcb_expose_event_t *) ev)->count) - simplewindow_refresh_drawable(globalconf.sw, globalconf.default_screen); + simplewindow_refresh_drawable(globalconf.sw); break; default: break; diff --git a/awesome-message.c b/awesome-message.c index ca1719f3f..169dd8a4d 100644 --- a/awesome-message.c +++ b/awesome-message.c @@ -221,7 +221,7 @@ main(int argc, char **argv) p_delete(&ctx); xcb_map_window(globalconf.connection, sw->window); - simplewindow_refresh_drawable(sw, globalconf.default_screen); + simplewindow_refresh_drawable(sw); xcb_aux_sync(globalconf.connection); signal(SIGALRM, &exit_on_signal); @@ -241,7 +241,7 @@ main(int argc, char **argv) case XCB_KEY_PRESS: running = false; case XCB_EXPOSE: - simplewindow_refresh_drawable(sw, globalconf.default_screen); + simplewindow_refresh_drawable(sw); break; default: break; diff --git a/common/swindow.c b/common/swindow.c index e8ae363e8..1bebc037c 100644 --- a/common/swindow.c +++ b/common/swindow.c @@ -42,6 +42,11 @@ simplewindow_new(xcb_connection_t *conn, int phys_screen, int x, int y, SimpleWindow *sw; xcb_screen_t *s = xcb_aux_get_screen(conn, phys_screen); uint32_t create_win_val[3]; + const uint32_t gc_mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND; + const uint32_t gc_values[2] = { s->black_pixel, s->white_pixel }; + /* The default GC is just a newly created associated to the root + * window */ + xcb_drawable_t gc_draw = s->root; sw = p_new(SimpleWindow, 1); @@ -68,6 +73,9 @@ simplewindow_new(xcb_connection_t *conn, int phys_screen, int x, int y, sw->drawable = xcb_generate_id(conn); xcb_create_pixmap(conn, s->root_depth, sw->drawable, s->root, w, h); + sw->gc = xcb_generate_id(sw->connection); + xcb_create_gc(sw->connection, sw->gc, gc_draw, gc_mask, gc_values); + return sw; } @@ -125,21 +133,10 @@ simplewindow_resize(SimpleWindow *sw, unsigned int w, unsigned int h) * \param phys_screen physical screen id */ void -simplewindow_refresh_drawable(SimpleWindow *sw, int phys_screen) +simplewindow_refresh_drawable(SimpleWindow *sw) { - xcb_screen_t *s = xcb_aux_get_screen(sw->connection, phys_screen); - - /* The default GC is just a newly created associated to the root - * window */ - xcb_drawable_t gc_draw = s->root; - xcb_gcontext_t gc = xcb_generate_id(sw->connection); - - const uint32_t gc_mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND; - const uint32_t gc_values[2] = { s->black_pixel, s->white_pixel }; - - xcb_create_gc(sw->connection, gc, gc_draw, gc_mask, gc_values); xcb_copy_area(sw->connection, sw->drawable, - sw->window, gc, 0, 0, 0, 0, + sw->window, sw->gc, 0, 0, 0, 0, sw->geometry.width, sw->geometry.height); } diff --git a/common/swindow.h b/common/swindow.h index a5b32450d..4f5559786 100644 --- a/common/swindow.h +++ b/common/swindow.h @@ -31,6 +31,7 @@ typedef struct SimpleWindow int phys_screen; xcb_window_t window; xcb_drawable_t drawable; + xcb_gcontext_t gc; area_t geometry; } SimpleWindow; @@ -38,7 +39,7 @@ SimpleWindow * simplewindow_new(xcb_connection_t *, int, int, int, unsigned int, void simplewindow_delete(SimpleWindow **); void simplewindow_move(SimpleWindow *, int, int); void simplewindow_resize(SimpleWindow *, unsigned int, unsigned int); -void simplewindow_refresh_drawable(SimpleWindow *, int); +void simplewindow_refresh_drawable(SimpleWindow *); static inline void simplewindow_move_resize(SimpleWindow *sw, int x, int y, diff --git a/event.c b/event.c index ab856804d..15aee30ca 100644 --- a/event.c +++ b/event.c @@ -374,7 +374,7 @@ event_handle_expose(void *data __attribute__ ((unused)), for(c = globalconf.clients; c; c = c->next) if(c->titlebar.sw && c->titlebar.sw->window == ev->window) { - simplewindow_refresh_drawable(c->titlebar.sw, c->phys_screen); + simplewindow_refresh_drawable(c->titlebar.sw); return 0; } } diff --git a/mouse.c b/mouse.c index ffa688a8e..9bbfc34d1 100644 --- a/mouse.c +++ b/mouse.c @@ -149,7 +149,7 @@ mouse_resizebar_draw(DrawCtx *ctx, style_t style, SimpleWindow *sw, area_t geome simplewindow_move(sw, geometry.x + ((2 * border + geometry.width) - sw->geometry.width) / 2, geometry.y + ((2 * border + geometry.height) - sw->geometry.height) / 2); - simplewindow_refresh_drawable(sw, sw->phys_screen); + simplewindow_refresh_drawable(sw); } /** Initialize the resizebar window. diff --git a/statusbar.c b/statusbar.c index b4eccd51d..119a166d1 100644 --- a/statusbar.c +++ b/statusbar.c @@ -166,7 +166,7 @@ statusbar_display(Statusbar *statusbar) { /* don't waste our time */ if(statusbar->position != Off) - simplewindow_refresh_drawable(statusbar->sw, statusbar->phys_screen); + simplewindow_refresh_drawable(statusbar->sw); } void diff --git a/titlebar.c b/titlebar.c index 23ae1d831..57f16cff7 100644 --- a/titlebar.c +++ b/titlebar.c @@ -219,7 +219,7 @@ titlebar_draw(Client *c) break; } - simplewindow_refresh_drawable(c->titlebar.sw, c->titlebar.sw->phys_screen); + simplewindow_refresh_drawable(c->titlebar.sw); draw_context_delete(&ctx); }