[common] Use pixmap instead of drawable type
It's just more clear. Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
24176ba8c7
commit
2742318f16
|
@ -108,19 +108,19 @@ draw_screen_default_visual(xcb_screen_t *s)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/** Get a draw context
|
||||
* \param conn Connection ref
|
||||
* \param phys_screen physical screen id
|
||||
* \param width width
|
||||
* \param height height
|
||||
* \param dw Drawable object to store in draw_context_t
|
||||
/** Create a new draw context.
|
||||
* \param conn Connection ref.
|
||||
* \param phys_screen Physical screen id.
|
||||
* \param width Width.
|
||||
* \param height Height.
|
||||
* \param px Pixmap object to store.
|
||||
* \param fg Foreground color.
|
||||
* \param bg Background color.
|
||||
* \return draw context ref
|
||||
* \return A draw context pointer.
|
||||
*/
|
||||
draw_context_t *
|
||||
draw_context_new(xcb_connection_t *conn, int phys_screen,
|
||||
int width, int height, xcb_drawable_t dw,
|
||||
int width, int height, xcb_pixmap_t px,
|
||||
xcolor_t fg, xcolor_t bg)
|
||||
{
|
||||
draw_context_t *d = p_new(draw_context_t, 1);
|
||||
|
@ -132,8 +132,8 @@ draw_context_new(xcb_connection_t *conn, int phys_screen,
|
|||
d->height = height;
|
||||
d->depth = s->root_depth;
|
||||
d->visual = draw_screen_default_visual(s);
|
||||
d->drawable = dw;
|
||||
d->surface = cairo_xcb_surface_create(conn, dw, d->visual, width, height);
|
||||
d->pixmap = px;
|
||||
d->surface = cairo_xcb_surface_create(conn, px, d->visual, width, height);
|
||||
d->cr = cairo_create(d->surface);
|
||||
d->layout = pango_cairo_create_layout(d->cr);
|
||||
d->fg = fg;
|
||||
|
@ -970,7 +970,7 @@ draw_get_image_size(const char *filename)
|
|||
}
|
||||
#endif /* WITH_IMLIB2 */
|
||||
|
||||
/** Rotate a drawable.
|
||||
/** Rotate a pixmap.
|
||||
* \param ctx Draw context to draw with.
|
||||
* \param src Drawable to draw from.
|
||||
* \param dest Drawable to draw to.
|
||||
|
@ -984,7 +984,7 @@ draw_get_image_size(const char *filename)
|
|||
*/
|
||||
void
|
||||
draw_rotate(draw_context_t *ctx,
|
||||
xcb_drawable_t src, xcb_drawable_t dest,
|
||||
xcb_pixmap_t src, xcb_pixmap_t dest,
|
||||
int src_w, int src_h,
|
||||
int dest_w, int dest_h,
|
||||
double angle, int tx, int ty)
|
||||
|
|
|
@ -97,7 +97,7 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
xcb_connection_t *connection;
|
||||
xcb_drawable_t drawable;
|
||||
xcb_pixmap_t pixmap;
|
||||
xcb_visualtype_t *visual;
|
||||
int width;
|
||||
int height;
|
||||
|
|
|
@ -45,9 +45,6 @@ simplewindow_new(xcb_connection_t *conn, int phys_screen, int x, int y,
|
|||
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(simple_window_t, 1);
|
||||
|
||||
|
@ -71,11 +68,13 @@ simplewindow_new(xcb_connection_t *conn, int phys_screen, int x, int y,
|
|||
XCB_CW_BACK_PIXMAP | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
|
||||
create_win_val);
|
||||
|
||||
sw->drawable = xcb_generate_id(conn);
|
||||
xcb_create_pixmap(conn, s->root_depth, sw->drawable, s->root, w, h);
|
||||
sw->pixmap = xcb_generate_id(conn);
|
||||
xcb_create_pixmap(conn, s->root_depth, sw->pixmap, s->root, w, h);
|
||||
|
||||
/* The default GC is just a newly created associated to the root
|
||||
* window */
|
||||
sw->gc = xcb_generate_id(sw->connection);
|
||||
xcb_create_gc(sw->connection, sw->gc, gc_draw, gc_mask, gc_values);
|
||||
xcb_create_gc(sw->connection, sw->gc, s->root, gc_mask, gc_values);
|
||||
|
||||
sw->border_width = border_width;
|
||||
|
||||
|
@ -109,15 +108,17 @@ simplewindow_resize(simple_window_t *sw, unsigned int w, unsigned int h)
|
|||
{
|
||||
xcb_screen_t *s = xcb_aux_get_screen(sw->connection, sw->phys_screen);
|
||||
const uint32_t resize_win_vals[] = { w, h };
|
||||
xcb_pixmap_t d;
|
||||
|
||||
sw->geometry.width = w;
|
||||
sw->geometry.height = h;
|
||||
xcb_free_pixmap(sw->connection, sw->drawable);
|
||||
sw->drawable = xcb_generate_id(sw->connection);
|
||||
xcb_create_pixmap(sw->connection, s->root_depth, sw->drawable, s->root, w, h);
|
||||
d = sw->pixmap;
|
||||
sw->pixmap = xcb_generate_id(sw->connection);
|
||||
xcb_create_pixmap(sw->connection, s->root_depth, sw->pixmap, s->root, w, h);
|
||||
xcb_configure_window(sw->connection, sw->window,
|
||||
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
|
||||
resize_win_vals);
|
||||
xcb_free_pixmap(sw->connection, d);
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
|
@ -33,8 +33,8 @@ typedef struct simple_window_t
|
|||
int phys_screen;
|
||||
/** The window object. */
|
||||
xcb_window_t window;
|
||||
/** The drawable copied to the window object. */
|
||||
xcb_drawable_t drawable;
|
||||
/** The pixmap copied to the window object. */
|
||||
xcb_pixmap_t pixmap;
|
||||
/** The graphic context. */
|
||||
xcb_gcontext_t gc;
|
||||
/** The window geometry. */
|
||||
|
@ -54,7 +54,7 @@ simplewindow_delete(simple_window_t **sw)
|
|||
if(*sw)
|
||||
{
|
||||
xcb_destroy_window((*sw)->connection, (*sw)->window);
|
||||
xcb_free_pixmap((*sw)->connection, (*sw)->drawable);
|
||||
xcb_free_pixmap((*sw)->connection, (*sw)->pixmap);
|
||||
xcb_free_gc((*sw)->connection, (*sw)->gc);
|
||||
p_delete(sw);
|
||||
}
|
||||
|
@ -78,13 +78,13 @@ simplewindow_move_resize(simple_window_t *sw, int x, int y,
|
|||
simplewindow_resize(sw, w, h);
|
||||
}
|
||||
|
||||
/** Refresh the window content by copying its drawable data to its window.
|
||||
/** Refresh the window content by copying its pixmap data to its window.
|
||||
* \param sw The simple window to refresh.
|
||||
*/
|
||||
static inline void
|
||||
simplewindow_refresh_drawable(simple_window_t *sw)
|
||||
simplewindow_refresh_pixmap(simple_window_t *sw)
|
||||
{
|
||||
xcb_copy_area(sw->connection, sw->drawable,
|
||||
xcb_copy_area(sw->connection, sw->pixmap,
|
||||
sw->window, sw->gc, 0, 0, 0, 0,
|
||||
sw->geometry.width,
|
||||
sw->geometry.height);
|
||||
|
|
4
event.c
4
event.c
|
@ -354,12 +354,12 @@ event_handle_expose(void *data __attribute__ ((unused)),
|
|||
if(statusbar->sw
|
||||
&& statusbar->sw->window == ev->window)
|
||||
{
|
||||
simplewindow_refresh_drawable(statusbar->sw);
|
||||
simplewindow_refresh_pixmap(statusbar->sw);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if((c = client_getbytitlebarwin(ev->window)))
|
||||
simplewindow_refresh_drawable(c->titlebar->sw);
|
||||
simplewindow_refresh_pixmap(c->titlebar->sw);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
4
mouse.c
4
mouse.c
|
@ -149,7 +149,7 @@ mouse_resizebar_draw(draw_context_t *ctx,
|
|||
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);
|
||||
simplewindow_refresh_pixmap(sw);
|
||||
}
|
||||
|
||||
/** Initialize the resizebar window.
|
||||
|
@ -180,7 +180,7 @@ mouse_resizebar_new(int phys_screen, int border, area_t geometry,
|
|||
|
||||
*ctx = draw_context_new(globalconf.connection, sw->phys_screen,
|
||||
sw->geometry.width, sw->geometry.height,
|
||||
sw->drawable,
|
||||
sw->pixmap,
|
||||
globalconf.colors.fg,
|
||||
globalconf.colors.bg);
|
||||
|
||||
|
|
|
@ -43,12 +43,12 @@ statusbar_draw(statusbar_t *statusbar)
|
|||
return;
|
||||
|
||||
widget_render(statusbar->widgets, statusbar->ctx, statusbar->sw->gc,
|
||||
statusbar->sw->drawable,
|
||||
statusbar->sw->pixmap,
|
||||
statusbar->screen, statusbar->position,
|
||||
statusbar->sw->geometry.x, statusbar->sw->geometry.y,
|
||||
statusbar);
|
||||
|
||||
simplewindow_refresh_drawable(statusbar->sw);
|
||||
simplewindow_refresh_pixmap(statusbar->sw);
|
||||
xcb_aux_sync(globalconf.connection);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ statusbar_position_update(statusbar_t *statusbar, position_t position)
|
|||
{
|
||||
statusbar_t *sb;
|
||||
area_t area;
|
||||
xcb_drawable_t dw;
|
||||
xcb_pixmap_t dw;
|
||||
xcb_screen_t *s = NULL;
|
||||
bool ignore = false;
|
||||
|
||||
|
@ -194,7 +194,7 @@ statusbar_position_update(statusbar_t *statusbar, position_t position)
|
|||
statusbar->phys_screen,
|
||||
statusbar->width,
|
||||
statusbar->height,
|
||||
statusbar->sw->drawable,
|
||||
statusbar->sw->pixmap,
|
||||
statusbar->colors.fg,
|
||||
statusbar->colors.bg);
|
||||
break;
|
||||
|
|
10
titlebar.c
10
titlebar.c
|
@ -87,27 +87,27 @@ titlebar_draw(client_t *c)
|
|||
ctx = draw_context_new(globalconf.connection, c->titlebar->sw->phys_screen,
|
||||
c->titlebar->sw->geometry.width,
|
||||
c->titlebar->sw->geometry.height,
|
||||
c->titlebar->sw->drawable,
|
||||
c->titlebar->sw->pixmap,
|
||||
c->titlebar->colors.fg,
|
||||
c->titlebar->colors.bg);
|
||||
break;
|
||||
}
|
||||
|
||||
widget_render(c->titlebar->widgets, ctx, c->titlebar->sw->gc, c->titlebar->sw->drawable,
|
||||
widget_render(c->titlebar->widgets, ctx, c->titlebar->sw->gc, c->titlebar->sw->pixmap,
|
||||
c->screen, c->titlebar->position,
|
||||
c->titlebar->sw->geometry.x, c->titlebar->sw->geometry.y, c->titlebar);
|
||||
|
||||
switch(c->titlebar->position)
|
||||
{
|
||||
case Left:
|
||||
draw_rotate(ctx, ctx->drawable, c->titlebar->sw->drawable,
|
||||
draw_rotate(ctx, ctx->pixmap, c->titlebar->sw->pixmap,
|
||||
ctx->width, ctx->height,
|
||||
ctx->height, ctx->width,
|
||||
- M_PI_2, 0, c->titlebar->sw->geometry.height);
|
||||
xcb_free_pixmap(globalconf.connection, dw);
|
||||
break;
|
||||
case Right:
|
||||
draw_rotate(ctx, ctx->drawable, c->titlebar->sw->drawable,
|
||||
draw_rotate(ctx, ctx->pixmap, c->titlebar->sw->pixmap,
|
||||
ctx->width, ctx->height,
|
||||
ctx->height, ctx->width,
|
||||
M_PI_2, c->titlebar->sw->geometry.width, 0);
|
||||
|
@ -116,7 +116,7 @@ titlebar_draw(client_t *c)
|
|||
break;
|
||||
}
|
||||
|
||||
simplewindow_refresh_drawable(c->titlebar->sw);
|
||||
simplewindow_refresh_pixmap(c->titlebar->sw);
|
||||
|
||||
draw_context_delete(&ctx);
|
||||
}
|
||||
|
|
16
widget.c
16
widget.c
|
@ -112,17 +112,17 @@ widget_common_tell(widget_t *widget,
|
|||
/** Render a list of widgets.
|
||||
* \param wnode The list of widgets.
|
||||
* \param ctx The draw context where to render.
|
||||
* \param rotate_dw The rotate drawable: where to rotate and render the final
|
||||
* \param rotate_dw The rotate pixmap: where to rotate and render the final
|
||||
* \param screen The logical screen used to render.
|
||||
* \param position The object position.
|
||||
* \param x The x coordinates of the object.
|
||||
* \param y The y coordinates of the object.
|
||||
* drawable when the object position is right or left.
|
||||
* pixmap when the object position is right or left.
|
||||
* \param object The object pointer.
|
||||
* \todo Remove GC.
|
||||
*/
|
||||
void
|
||||
widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_gcontext_t gc, xcb_drawable_t rotate_dw,
|
||||
widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_gcontext_t gc, xcb_pixmap_t rotate_px,
|
||||
int screen, position_t position,
|
||||
int x, int y, void *object)
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_gcontext_t gc, xcb_
|
|||
{
|
||||
case Left:
|
||||
draw_rotate(ctx,
|
||||
rootpix, ctx->drawable,
|
||||
rootpix, ctx->pixmap,
|
||||
rootsize.width, rootsize.height,
|
||||
ctx->width, ctx->height,
|
||||
M_PI_2,
|
||||
|
@ -173,7 +173,7 @@ widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_gcontext_t gc, xcb_
|
|||
break;
|
||||
case Right:
|
||||
draw_rotate(ctx,
|
||||
rootpix, ctx->drawable,
|
||||
rootpix, ctx->pixmap,
|
||||
rootsize.width, rootsize.height,
|
||||
ctx->width, ctx->height,
|
||||
- M_PI_2,
|
||||
|
@ -182,7 +182,7 @@ widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_gcontext_t gc, xcb_
|
|||
break;
|
||||
default:
|
||||
xcb_copy_area(globalconf.connection, rootpix,
|
||||
rotate_dw, gc,
|
||||
rotate_px, gc,
|
||||
x, y,
|
||||
0, 0,
|
||||
ctx->width, ctx->height);
|
||||
|
@ -211,13 +211,13 @@ widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_gcontext_t gc, xcb_
|
|||
switch(position)
|
||||
{
|
||||
case Right:
|
||||
draw_rotate(ctx, ctx->drawable, rotate_dw,
|
||||
draw_rotate(ctx, ctx->pixmap, rotate_px,
|
||||
ctx->width, ctx->height,
|
||||
ctx->height, ctx->width,
|
||||
M_PI_2, ctx->height, 0);
|
||||
break;
|
||||
case Left:
|
||||
draw_rotate(ctx, ctx->drawable, rotate_dw,
|
||||
draw_rotate(ctx, ctx->pixmap, rotate_px,
|
||||
ctx->width, ctx->height,
|
||||
ctx->height, ctx->width,
|
||||
- M_PI_2, 0, ctx->width);
|
||||
|
|
Loading…
Reference in New Issue