merge draw_get_image_{width,height}() into draw_get_image_size()
This commit is contained in:
parent
814b66fddb
commit
3d71a2e9a4
25
draw.c
25
draw.c
|
@ -204,32 +204,19 @@ draw_image(DrawCtx *ctx, int x, int y, int wanted_h, const char *filename)
|
|||
|
||||
}
|
||||
|
||||
int
|
||||
draw_get_image_width(const char *filename)
|
||||
Area
|
||||
draw_get_image_size(const char *filename)
|
||||
{
|
||||
int width;
|
||||
Area size;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
surface = cairo_image_surface_create_from_png(filename);
|
||||
cairo_image_surface_get_width(surface);
|
||||
width = cairo_image_surface_get_width(surface);
|
||||
size.width = cairo_image_surface_get_width(surface);
|
||||
size.height = cairo_image_surface_get_height(surface);
|
||||
cairo_surface_destroy(surface);
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
int
|
||||
draw_get_image_height(const char* filename)
|
||||
{
|
||||
int height;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
surface = cairo_image_surface_create_from_png(filename);
|
||||
cairo_image_surface_get_height(surface);
|
||||
height = cairo_image_surface_get_height(surface);
|
||||
cairo_surface_destroy(surface);
|
||||
|
||||
return height;
|
||||
return size;
|
||||
}
|
||||
|
||||
Drawable
|
||||
|
|
12
draw.h
12
draw.h
|
@ -22,6 +22,15 @@
|
|||
#ifndef AWESOME_DRAW_H
|
||||
#define AWESOME_DRAW_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Co-ords of upper left corner */
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
} Area;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Display *display;
|
||||
|
@ -40,8 +49,7 @@ void draw_rectangle(DrawCtx *, int, int, int, int, Bool, XColor);
|
|||
void draw_circle(DrawCtx *, int, int, int, Bool, XColor);
|
||||
void draw_image(DrawCtx *, int, int, int, const char *);
|
||||
void draw_image_from_argb_data(DrawCtx *, int, int, int, int, int, unsigned char *);
|
||||
int draw_get_image_width(const char *filename);
|
||||
int draw_get_image_height(const char *filename);
|
||||
Area draw_get_image_size(const char *filename);
|
||||
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
||||
unsigned short textwidth(XftFont *, char *);
|
||||
|
||||
|
|
9
screen.h
9
screen.h
|
@ -26,15 +26,6 @@
|
|||
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Co-ords of upper left corner */
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
} Area;
|
||||
|
||||
Area get_screen_area(int, Statusbar *, Padding *);
|
||||
Area get_display_area(int, Statusbar *, Padding *);
|
||||
int get_screen_bycoord(int, int);
|
||||
|
|
|
@ -29,10 +29,10 @@ static int
|
|||
iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||
int used __attribute__ ((unused)))
|
||||
{
|
||||
int height;
|
||||
widget->width = draw_get_image_width(widget->data);
|
||||
height = draw_get_image_height(widget->data);
|
||||
widget->width = ((double) widget->statusbar->height / height) * widget->width;
|
||||
Area area;
|
||||
|
||||
area = draw_get_image_size(widget->data);
|
||||
widget->width = ((double) widget->statusbar->height / area.height) * area.width;
|
||||
widget->location = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->width,
|
||||
offset,
|
||||
|
|
|
@ -38,9 +38,9 @@ netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
unsigned char *wdata;
|
||||
Atom type;
|
||||
int format, width, height, size, i;
|
||||
Area area;
|
||||
unsigned long items, rest;
|
||||
unsigned char *image, *imgdata;
|
||||
char* icon;
|
||||
Rule* r;
|
||||
Client *sel = focus_get_current_client(widget->statusbar->screen);
|
||||
|
||||
|
@ -50,17 +50,15 @@ netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
for(r = globalconf.rules; r; r = r->next)
|
||||
if(r->icon && client_match_rule(sel, r))
|
||||
{
|
||||
icon = r->icon;
|
||||
width = draw_get_image_width(icon);
|
||||
height = draw_get_image_height(icon);
|
||||
width = ((double) widget->statusbar->height / (double) height) * width;
|
||||
area = draw_get_image_size(r->icon);
|
||||
widget->width = ((double) widget->statusbar->height / (double) area.height) * area.width;
|
||||
widget->location = widget_calculate_offset(widget->statusbar->width,
|
||||
width,
|
||||
widget->width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
draw_image(ctx, widget->location, 0, widget->statusbar->height, icon);
|
||||
draw_image(ctx, widget->location, 0, widget->statusbar->height, r->icon);
|
||||
|
||||
return width;
|
||||
return widget->width;
|
||||
}
|
||||
|
||||
if(XGetWindowProperty(ctx->display, sel->win,
|
||||
|
|
Loading…
Reference in New Issue