[statusbar] Fix left and right statusbars alpha support

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-30 17:53:10 +02:00
parent 0c8910d1df
commit 7cff3567e3
4 changed files with 60 additions and 25 deletions

View File

@ -892,18 +892,23 @@ draw_get_image_size(const char *filename)
}
#endif /* WITH_IMLIB2 */
/** Rotate a drawable
* \param ctx Draw context to draw to
* \param dest Drawable to draw the result
* \param dest_w Drawable width
* \param dest_h Drawable height
* \param angle angle to rotate
* \param tx translate to this x coordinate
* \param ty translate to this y coordinate
* \return new rotated drawable
/** Rotate a drawable.
* \param ctx Draw context to draw with.
* \param src Drawable to draw from.
* \param dest Drawable to draw to.
* \param src_w Drawable width.
* \param src_h Drawable height.
* \param dest_w Drawable width.
* \param dest_h Drawable height.
* \param angle angle to rotate.
* \param tx Translate to this x coordinate.
* \param ty Translate to this y coordinate.
*/
void
draw_rotate(draw_context_t *ctx, xcb_drawable_t dest, int dest_w, int dest_h,
draw_rotate(draw_context_t *ctx,
xcb_drawable_t src, xcb_drawable_t dest,
int src_w, int src_h,
int dest_w, int dest_h,
double angle, int tx, int ty)
{
cairo_surface_t *surface, *source;
@ -911,8 +916,8 @@ draw_rotate(draw_context_t *ctx, xcb_drawable_t dest, int dest_w, int dest_h,
surface = cairo_xcb_surface_create(ctx->connection, dest,
ctx->visual, dest_w, dest_h);
source = cairo_xcb_surface_create(ctx->connection, ctx->drawable,
ctx->visual, ctx->width, ctx->height);
source = cairo_xcb_surface_create(ctx->connection, src,
ctx->visual, src_w, src_h);
cr = cairo_create (surface);
cairo_translate(cr, tx, ty);
@ -1049,7 +1054,6 @@ xcolor_new(xcb_connection_t *conn, int phys_screen, const char *colstr, xcolor_t
colnum = strtoul(buf, NULL, 16);
p_delete(&buf);
color->alpha = RGB_COLOR_8_TO_16(strtoul(&colstr[7], NULL, 16));
printf("%d alpha\n", color->alpha);
if(errno != 0)
{
warn("awesome: error, invalid color '%s'", colstr);

View File

@ -141,7 +141,7 @@ void draw_circle(draw_context_t *, int, int, int, bool, xcolor_t);
void draw_image(draw_context_t *, int, int, int, const char *);
void draw_image_from_argb_data(draw_context_t *, int, int, int, int, int, unsigned char *);
area_t draw_get_image_size(const char *filename);
void draw_rotate(draw_context_t *, xcb_drawable_t, int, int, double, int, int);
void draw_rotate(draw_context_t *, xcb_drawable_t, xcb_drawable_t, int, int, int, int, double, int, int);
area_t draw_text_extents(xcb_connection_t *, int, font_t *, const char *);
alignment_t draw_align_get_from_str(const char *);
bool xcolor_new(xcb_connection_t *, int, const char *, xcolor_t *);

View File

@ -49,7 +49,7 @@ statusbar_draw(statusbar_t *statusbar)
char *data;
xcb_get_property_reply_t *prop_r;
xcb_get_property_cookie_t prop_c;
area_t rectangle = { 0, 0, 0, 0, NULL, NULL };
area_t rectangle = { 0, 0, 0, 0, NULL, NULL }, rootsize;;
xcb_atom_t rootpix_atom, pixmap_atom;
xutil_intern_atom_request_t rootpix_atom_req, pixmap_atom_req;
@ -80,12 +80,37 @@ statusbar_draw(statusbar_t *statusbar)
if((data = xcb_get_property_value(prop_r)))
{
rootpix = *(xcb_pixmap_t *) data;
xcb_copy_area(globalconf.connection, rootpix,
statusbar->sw->drawable, statusbar->sw->gc,
statusbar->sw->geometry.x, statusbar->sw->geometry.y,
0, 0,
statusbar->sw->geometry.width,
statusbar->sw->geometry.height);
switch(statusbar->position)
{
case Left:
rootsize = get_display_area(statusbar->phys_screen, NULL, NULL);
draw_rotate(statusbar->ctx,
rootpix, statusbar->ctx->drawable,
rootsize.width, rootsize.height,
statusbar->width, statusbar->height,
M_PI_2,
statusbar->sw->geometry.y + statusbar->width,
- statusbar->sw->geometry.x);
break;
case Right:
rootsize = get_display_area(statusbar->phys_screen, NULL, NULL);
draw_rotate(statusbar->ctx,
rootpix, statusbar->ctx->drawable,
rootsize.width, rootsize.height,
statusbar->width, statusbar->height,
- M_PI_2,
- statusbar->sw->geometry.y,
statusbar->sw->geometry.x + statusbar->height);
break;
default:
xcb_copy_area(globalconf.connection, rootpix,
statusbar->sw->drawable, statusbar->sw->gc,
statusbar->sw->geometry.x, statusbar->sw->geometry.y,
0, 0,
statusbar->sw->geometry.width,
statusbar->sw->geometry.height);
break;
}
}
p_delete(&prop_r);
}
@ -110,12 +135,14 @@ statusbar_draw(statusbar_t *statusbar)
switch(statusbar->position)
{
case Right:
draw_rotate(statusbar->ctx, statusbar->sw->drawable,
draw_rotate(statusbar->ctx, statusbar->ctx->drawable, statusbar->sw->drawable,
statusbar->ctx->width, statusbar->ctx->height,
statusbar->ctx->height, statusbar->ctx->width,
M_PI_2, statusbar->height, 0);
break;
case Left:
draw_rotate(statusbar->ctx, statusbar->sw->drawable,
draw_rotate(statusbar->ctx, statusbar->ctx->drawable, statusbar->sw->drawable,
statusbar->ctx->width, statusbar->ctx->height,
statusbar->ctx->height, statusbar->ctx->width,
- M_PI_2, 0, statusbar->width);
break;

View File

@ -108,12 +108,16 @@ titlebar_draw(client_t *c)
switch(c->titlebar.position)
{
case Left:
draw_rotate(ctx, c->titlebar_sw->drawable, ctx->height, ctx->width,
draw_rotate(ctx, ctx->drawable, c->titlebar_sw->drawable,
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, c->titlebar_sw->drawable, ctx->height, ctx->width,
draw_rotate(ctx, ctx->drawable, c->titlebar_sw->drawable,
ctx->width, ctx->height,
ctx->height, ctx->width,
M_PI_2, c->titlebar_sw->geometry.width, 0);
xcb_free_pixmap(globalconf.connection, dw);
default: