allow to shrink net_wm_icon to statusbar size
This commit is contained in:
parent
557cb90ff0
commit
e72a278080
19
draw.c
19
draw.c
|
@ -149,15 +149,24 @@ drawcircle(DrawCtx *ctx, int x, int y, int r, Bool filled, XColor color)
|
|||
cairo_surface_destroy(surface);
|
||||
}
|
||||
|
||||
void draw_image_from_argb_data(DrawCtx *ctx, int x, int y, int w, int h, unsigned char *data)
|
||||
void draw_image_from_argb_data(DrawCtx *ctx, int x, int y, int w, int h,
|
||||
int wanted_w, unsigned char *data)
|
||||
{
|
||||
double ratio;
|
||||
cairo_surface_t *surface, *source;
|
||||
cairo_t *cr;
|
||||
|
||||
source = cairo_xlib_surface_create(ctx->display, ctx->drawable, ctx->visual, ctx->width, ctx->height);
|
||||
surface = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, w, h, 0);
|
||||
cr = cairo_create (source);
|
||||
cairo_set_source_surface(cr, surface, x, y);
|
||||
surface = cairo_xlib_surface_create(ctx->display, ctx->drawable, ctx->visual, ctx->width, ctx->height);
|
||||
source = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, w, h, 0);
|
||||
cr = cairo_create (surface);
|
||||
if(wanted_w > 0 && w > 0)
|
||||
{
|
||||
ratio = (double) wanted_w / (double) w;
|
||||
cairo_scale(cr, ratio, ratio);
|
||||
cairo_set_source_surface(cr, source, x / ratio, y / ratio);
|
||||
}
|
||||
else
|
||||
cairo_set_source_surface(cr, source, x, y);
|
||||
cairo_paint(cr);
|
||||
|
||||
cairo_destroy(cr);
|
||||
|
|
2
draw.h
2
draw.h
|
@ -42,7 +42,7 @@ void drawtext(DrawCtx *, int, int, int, int, XftFont *, const char *, XColor fg,
|
|||
void drawrectangle(DrawCtx *, int, int, int, int, Bool, XColor);
|
||||
void drawcircle(DrawCtx *, int, int, int, Bool, XColor);
|
||||
void drawimage(DrawCtx *, int, int, const char *);
|
||||
void draw_image_from_argb_data(DrawCtx *, int, int, int, int, unsigned char *);
|
||||
void draw_image_from_argb_data(DrawCtx *, int, int, int, int, int, unsigned char *);
|
||||
int draw_get_image_width(const char *filename);
|
||||
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
||||
unsigned short textwidth(DrawCtx *, XftFont *, char *);
|
||||
|
|
|
@ -83,12 +83,12 @@ netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
offset,
|
||||
widget->alignment);
|
||||
|
||||
draw_image_from_argb_data(ctx, location, 0, width, height, image);
|
||||
draw_image_from_argb_data(ctx, location, 0, width, height, vscreen.statusbar->height, image);
|
||||
|
||||
p_delete(&image);
|
||||
|
||||
XFree(data);
|
||||
return width;
|
||||
return vscreen.statusbar->height;
|
||||
}
|
||||
|
||||
Widget *
|
||||
|
|
Loading…
Reference in New Issue