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
|
Area
|
||||||
draw_get_image_width(const char *filename)
|
draw_get_image_size(const char *filename)
|
||||||
{
|
{
|
||||||
int width;
|
Area size;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
|
|
||||||
surface = cairo_image_surface_create_from_png(filename);
|
surface = cairo_image_surface_create_from_png(filename);
|
||||||
cairo_image_surface_get_width(surface);
|
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);
|
cairo_surface_destroy(surface);
|
||||||
|
|
||||||
return width;
|
return size;
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawable
|
Drawable
|
||||||
|
|
12
draw.h
12
draw.h
|
@ -22,6 +22,15 @@
|
||||||
#ifndef AWESOME_DRAW_H
|
#ifndef AWESOME_DRAW_H
|
||||||
#define 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
|
typedef struct
|
||||||
{
|
{
|
||||||
Display *display;
|
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_circle(DrawCtx *, int, int, int, Bool, XColor);
|
||||||
void draw_image(DrawCtx *, int, int, int, const char *);
|
void draw_image(DrawCtx *, int, int, int, const char *);
|
||||||
void draw_image_from_argb_data(DrawCtx *, int, 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);
|
Area draw_get_image_size(const char *filename);
|
||||||
int draw_get_image_height(const char *filename);
|
|
||||||
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
||||||
unsigned short textwidth(XftFont *, char *);
|
unsigned short textwidth(XftFont *, char *);
|
||||||
|
|
||||||
|
|
9
screen.h
9
screen.h
|
@ -26,15 +26,6 @@
|
||||||
|
|
||||||
#include <X11/extensions/Xinerama.h>
|
#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_screen_area(int, Statusbar *, Padding *);
|
||||||
Area get_display_area(int, Statusbar *, Padding *);
|
Area get_display_area(int, Statusbar *, Padding *);
|
||||||
int get_screen_bycoord(int, int);
|
int get_screen_bycoord(int, int);
|
||||||
|
|
|
@ -29,10 +29,10 @@ static int
|
||||||
iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
int used __attribute__ ((unused)))
|
int used __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
int height;
|
Area area;
|
||||||
widget->width = draw_get_image_width(widget->data);
|
|
||||||
height = draw_get_image_height(widget->data);
|
area = draw_get_image_size(widget->data);
|
||||||
widget->width = ((double) widget->statusbar->height / height) * widget->width;
|
widget->width = ((double) widget->statusbar->height / area.height) * area.width;
|
||||||
widget->location = widget_calculate_offset(widget->statusbar->width,
|
widget->location = widget_calculate_offset(widget->statusbar->width,
|
||||||
widget->width,
|
widget->width,
|
||||||
offset,
|
offset,
|
||||||
|
|
|
@ -38,9 +38,9 @@ netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
unsigned char *wdata;
|
unsigned char *wdata;
|
||||||
Atom type;
|
Atom type;
|
||||||
int format, width, height, size, i;
|
int format, width, height, size, i;
|
||||||
|
Area area;
|
||||||
unsigned long items, rest;
|
unsigned long items, rest;
|
||||||
unsigned char *image, *imgdata;
|
unsigned char *image, *imgdata;
|
||||||
char* icon;
|
|
||||||
Rule* r;
|
Rule* r;
|
||||||
Client *sel = focus_get_current_client(widget->statusbar->screen);
|
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)
|
for(r = globalconf.rules; r; r = r->next)
|
||||||
if(r->icon && client_match_rule(sel, r))
|
if(r->icon && client_match_rule(sel, r))
|
||||||
{
|
{
|
||||||
icon = r->icon;
|
area = draw_get_image_size(r->icon);
|
||||||
width = draw_get_image_width(icon);
|
widget->width = ((double) widget->statusbar->height / (double) area.height) * area.width;
|
||||||
height = draw_get_image_height(icon);
|
|
||||||
width = ((double) widget->statusbar->height / (double) height) * width;
|
|
||||||
widget->location = widget_calculate_offset(widget->statusbar->width,
|
widget->location = widget_calculate_offset(widget->statusbar->width,
|
||||||
width,
|
widget->width,
|
||||||
offset,
|
offset,
|
||||||
widget->alignment);
|
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,
|
if(XGetWindowProperty(ctx->display, sel->win,
|
||||||
|
|
Loading…
Reference in New Issue