Lot of cosmetic changes: proto change, etc.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-03-21 11:26:56 +01:00
parent b39529b44d
commit 1d468c5583
17 changed files with 84 additions and 61 deletions

View File

@ -40,8 +40,8 @@ send_msg(char *msg, ssize_t msg_len)
{
struct sockaddr_un *addr;
int csfd, ret_value = EXIT_SUCCESS;
csfd = get_client_socket();
addr = get_client_addr(getenv("DISPLAY"));
csfd = socket_getclient();
addr = socket_getaddr(getenv("DISPLAY"));
if(!addr || csfd < 0)
return EXIT_FAILURE;

View File

@ -643,7 +643,7 @@ main(int argc, char **argv)
globalconf.prompt = a_strdup(argv[optind]);
/* Get the numlock mask */
globalconf.numlockmask = get_numlockmask(disp);
globalconf.numlockmask = xgetnumlockmask(disp);
si = screensinfo_new(disp);
if(si->xinerama_is_active)
@ -748,8 +748,8 @@ main(int argc, char **argv)
}
p_delete(&globalconf.text);
draw_context_delete(globalconf.ctx);
simplewindow_delete(globalconf.sw);
draw_context_delete(&globalconf.ctx);
simplewindow_delete(&globalconf.sw);
XCloseDisplay(disp);
return EXIT_SUCCESS;

View File

@ -237,7 +237,7 @@ main(int argc, char **argv)
usleep(100000);
}
simplewindow_delete(sw);
simplewindow_delete(&sw);
XCloseDisplay(disp);
return EXIT_SUCCESS;

View File

@ -334,8 +334,8 @@ main(int argc, char *argv[])
XSync(dpy, False);
/* get socket fd */
csfd = get_client_socket();
addr = get_client_addr(getenv("DISPLAY"));
csfd = socket_getclient();
addr = socket_getaddr(getenv("DISPLAY"));
if(bind(csfd, (const struct sockaddr *) addr, SUN_LEN(addr)))
{

View File

@ -649,7 +649,7 @@ client_unmanage(Client *c)
XUngrabServer(globalconf.display);
if(c->titlebar.sw)
simplewindow_delete(c->titlebar.sw);
simplewindow_delete(&c->titlebar.sw);
p_delete(&c);
}

View File

@ -107,17 +107,18 @@ draw_context_new(Display *disp, int phys_screen, int width, int height, Drawable
* \param ctx DrawCtx to delete
*/
void
draw_context_delete(DrawCtx *ctx)
draw_context_delete(DrawCtx **ctx)
{
g_object_unref(ctx->layout);
cairo_surface_destroy(ctx->surface);
cairo_destroy(ctx->cr);
p_delete(&ctx);
g_object_unref((*ctx)->layout);
cairo_surface_destroy((*ctx)->surface);
cairo_destroy((*ctx)->cr);
p_delete(ctx);
}
/** Create a new Pango font
* \param disp Display ref
* \param fontname Pango fontname (e.g. [FAMILY-LIST] [STYLE-OPTIONS] [SIZE])
* \return a new font
*/
font_t *
draw_font_new(Display *disp, char *fontname)
@ -173,10 +174,10 @@ draw_font_new(Display *disp, char *fontname)
* \param font font_t to delete
*/
void
draw_font_free(font_t *font)
draw_font_delete(font_t **font)
{
pango_font_description_free(font->desc);
p_delete(&font);
pango_font_description_free((*font)->desc);
p_delete(font);
}
/** Draw text into a draw context
@ -289,7 +290,8 @@ draw_text(DrawCtx *ctx,
*/
static cairo_pattern_t *
draw_setup_cairo_color_source(DrawCtx *ctx, area_t rect,
XColor *pcolor, XColor *pcolor_center, XColor *pcolor_end)
XColor *pcolor, XColor *pcolor_center,
XColor *pcolor_end)
{
cairo_pattern_t *pat = NULL;
@ -330,18 +332,24 @@ draw_rectangle(DrawCtx *ctx, area_t geometry, Bool filled, XColor color)
{
cairo_set_antialias(ctx->cr, CAIRO_ANTIALIAS_NONE);
cairo_set_line_width(ctx->cr, 1.0);
cairo_set_source_rgb(ctx->cr, color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0);
cairo_set_source_rgb(ctx->cr,
color.red / 65535.0,
color.green / 65535.0,
color.blue / 65535.0);
if(filled)
{
cairo_rectangle(ctx->cr, geometry.x, geometry.y, geometry.width, geometry.height);
cairo_rectangle(ctx->cr, geometry.x, geometry.y,
geometry.width, geometry.height);
cairo_fill(ctx->cr);
}
else
{
cairo_rectangle(ctx->cr, geometry.x + 1, geometry.y, geometry.width - 1, geometry.height - 1);
cairo_rectangle(ctx->cr, geometry.x + 1, geometry.y,
geometry.width - 1, geometry.height - 1);
cairo_stroke(ctx->cr);
}
}
/** Draw rectangle with gradient colors
* \param ctx Draw context
* \param geometry geometry
@ -354,7 +362,8 @@ draw_rectangle(DrawCtx *ctx, area_t geometry, Bool filled, XColor color)
*/
void
draw_rectangle_gradient(DrawCtx *ctx, area_t geometry, Bool filled,
area_t pattern_rect, XColor *pcolor, XColor *pcolor_center, XColor *pcolor_end)
area_t pattern_rect, XColor *pcolor,
XColor *pcolor_center, XColor *pcolor_end)
{
cairo_pattern_t *pat;
@ -404,13 +413,15 @@ draw_graph_setup(DrawCtx *ctx)
* \param pcolor_end color at the right
*/
void
draw_graph(DrawCtx *ctx, area_t rect, int *from, int *to, int cur_index, Position grow,
area_t patt_rect, XColor *pcolor, XColor *pcolor_center, XColor *pcolor_end)
draw_graph(DrawCtx *ctx, area_t rect, int *from, int *to, int cur_index,
Position grow, area_t patt_rect,
XColor *pcolor, XColor *pcolor_center, XColor *pcolor_end)
{
int i, x, y, w;
cairo_pattern_t *pat;
pat = draw_setup_cairo_color_source(ctx, patt_rect, pcolor, pcolor_center, pcolor_end);
pat = draw_setup_cairo_color_source(ctx, patt_rect,
pcolor, pcolor_center, pcolor_end);
x = rect.x;
y = rect.y;
@ -462,8 +473,9 @@ draw_graph(DrawCtx *ctx, area_t rect, int *from, int *to, int cur_index, Positio
* \param pcolor_end color at the right
*/
void
draw_graph_line(DrawCtx *ctx, area_t rect, int *to, int cur_index, Position grow,
area_t patt_rect, XColor *pcolor, XColor *pcolor_center, XColor *pcolor_end)
draw_graph_line(DrawCtx *ctx, area_t rect, int *to, int cur_index,
Position grow, area_t patt_rect,
XColor *pcolor, XColor *pcolor_center, XColor *pcolor_end)
{
int i, x, y, w;
int flag = 0; /* used to prevent drawing a line from 0 to 0 values */
@ -664,8 +676,10 @@ draw_rotate(DrawCtx *ctx, Drawable dest, int dest_w, int dest_h,
cairo_surface_t *surface, *source;
cairo_t *cr;
surface = cairo_xlib_surface_create(ctx->display, dest, ctx->visual, dest_w, dest_h);
source = cairo_xlib_surface_create(ctx->display, ctx->drawable, ctx->visual, ctx->width, ctx->height);
surface = cairo_xlib_surface_create(ctx->display, dest,
ctx->visual, dest_w, dest_h);
source = cairo_xlib_surface_create(ctx->display, ctx->drawable,
ctx->visual, ctx->width, ctx->height);
cr = cairo_create (surface);
cairo_translate(cr, tx, ty);
@ -693,7 +707,7 @@ draw_textwidth(Display *disp, font_t *font, char *text)
PangoLayout *layout;
PangoRectangle ext;
if (!a_strlen(text))
if(!a_strlen(text))
return 0;
surface = cairo_xlib_surface_create(disp, DefaultScreen(disp),
@ -721,13 +735,13 @@ draw_textwidth(Display *disp, font_t *font, char *text)
Alignment
draw_align_get_from_str(const char *align)
{
if(!a_strncmp(align, "left", 4))
if(!a_strcmp(align, "left"))
return AlignLeft;
else if(!a_strncmp(align, "center", 6))
else if(!a_strcmp(align, "center"))
return AlignCenter;
else if(!a_strncmp(align, "right", 5))
else if(!a_strcmp(align, "right"))
return AlignRight;
else if(!a_strncmp(align, "flex", 4))
else if(!a_strcmp(align, "flex"))
return AlignFlex;
return AlignAuto;
@ -759,6 +773,14 @@ draw_color_new(Display *disp, int phys_screen, const char *colstr, XColor *color
return ret;
}
/** Init a style struct. Every value will be inherited from m
* if they are not set in the configuration section cfg.
* \param disp Display ref
* \param phys_screen Physical screen number
* \param cfg style configuration section
* \param c style to fill
* \param m style to use as template
*/
void
draw_style_init(Display *disp, int phys_screen, cfg_t *cfg,
style_t *c, style_t *m)
@ -790,7 +812,7 @@ draw_style_init(Display *disp, int phys_screen, cfg_t *cfg,
}
/** Remove a area from a list of them,
* spliting the space between several area that can overlaps
* spliting the space between several area that can overlap
* \param head list head
* \param elem area to remove
*/

View File

@ -118,10 +118,11 @@ typedef struct
} DrawCtx;
DrawCtx *draw_context_new(Display *, int, int, int, Drawable);
void draw_context_delete(DrawCtx *);
void draw_context_delete(DrawCtx **);
font_t *draw_font_new(Display *disp, char *fontname);
void draw_font_free(font_t *);
void draw_font_delete(font_t **);
void draw_text(DrawCtx *, area_t, Alignment, int, char *, style_t);
void draw_rectangle(DrawCtx *, area_t, Bool, XColor);
void draw_rectangle_gradient(DrawCtx *, area_t, Bool, area_t, XColor *, XColor *, XColor *);

View File

@ -36,7 +36,7 @@
* \return sockaddr_un struct ready to be used or NULL if a problem occured
*/
struct sockaddr_un *
get_client_addr(const char *display)
socket_getaddr(const char *display)
{
char *homedir, *tmp;
const char *real_display = NULL;
@ -82,7 +82,7 @@ get_client_addr(const char *display)
* \return the socket file descriptor
*/
int
get_client_socket(void)
socket_getclient(void)
{
int csfd;

View File

@ -22,8 +22,8 @@
#ifndef AWESOME_COMMON_SOCKET_H
#define AWESOME_COMMON_SOCKET_H
struct sockaddr_un * get_client_addr(const char *);
int get_client_socket(void);
struct sockaddr_un * socket_getaddr(const char *);
int socket_getclient(void);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -78,11 +78,11 @@ simplewindow_new(Display *disp, int phys_screen, int x, int y,
* \param sw the SimpleWindow to delete
*/
void
simplewindow_delete(SimpleWindow *sw)
simplewindow_delete(SimpleWindow **sw)
{
XDestroyWindow(sw->display, sw->window);
XFreePixmap(sw->display, sw->drawable);
p_delete(&sw);
XDestroyWindow((*sw)->display, (*sw)->window);
XFreePixmap((*sw)->display, (*sw)->drawable);
p_delete(sw);
}
/** Move a simple window
@ -118,13 +118,6 @@ simplewindow_resize(SimpleWindow *sw, unsigned int w, unsigned int h)
return XResizeWindow(sw->display, sw->window, w, h);
}
int simplewindow_move_resize(SimpleWindow *sw, int x, int y,
unsigned int w, unsigned int h)
{
return (simplewindow_move(sw, x, y)
&& simplewindow_resize(sw, w, h));
}
/** Refresh the window content
* \param sw the SimpleWindow to refresh
* \param phys_screen physical screen id

View File

@ -35,11 +35,18 @@ typedef struct SimpleWindow
} SimpleWindow;
SimpleWindow * simplewindow_new(Display *, int, int, int, unsigned int, unsigned int, unsigned int);
void simplewindow_delete(SimpleWindow *);
void simplewindow_delete(SimpleWindow **);
int simplewindow_move(SimpleWindow *, int, int);
int simplewindow_resize(SimpleWindow *, unsigned int, unsigned int);
int simplewindow_refresh_drawable(SimpleWindow *, int);
int simplewindow_move_resize(SimpleWindow *, int, int, unsigned int, unsigned int);
static inline int
simplewindow_move_resize(SimpleWindow *sw, int x, int y,
unsigned int w, unsigned int h)
{
return (simplewindow_move(sw, x, y)
&& simplewindow_resize(sw, w, h));
}
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -47,7 +47,7 @@ screen_get_bycoord(ScreensInfo *si, int screen, int x, int y)
}
static inline area_t
screen_xsi_to_area(XineramaScreenInfo si)
screen_xsitoarea(XineramaScreenInfo si)
{
area_t a;
@ -100,7 +100,7 @@ screensinfo_new(Display *disp)
MAX(xsi[screen].height, xsi[screen_to_test].height);
}
if(!drop)
si->geometry[si->nscreen++] = screen_xsi_to_area(xsi[screen]);
si->geometry[si->nscreen++] = screen_xsitoarea(xsi[screen]);
}
/* realloc smaller if xinerama_screen_number != screen registered */

View File

@ -57,7 +57,7 @@ xgettextprop(Display *disp, Window w, Atom atom, char *text, ssize_t textlen)
}
unsigned int
get_numlockmask(Display *disp)
xgetnumlockmask(Display *disp)
{
XModifierKeymap *modmap;
unsigned int mask = 0;

View File

@ -25,7 +25,7 @@
#include <X11/Xlib.h>
Bool xgettextprop(Display *, Window, Atom, char *, ssize_t);
unsigned int get_numlockmask(Display *);
unsigned int xgetnumlockmask(Display *);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -550,7 +550,7 @@ config_parse(const char *confpatharg)
globalconf.buttons.titlebar = parse_mouse_bindings(cfg_mouse, "titlebar", True);
/* Keys */
globalconf.numlockmask = get_numlockmask(globalconf.display);
globalconf.numlockmask = xgetnumlockmask(globalconf.display);
globalconf.keys = section_keys(cfg_keys);

View File

@ -153,7 +153,7 @@ titlebar_update(Client *c)
simplewindow_refresh_drawable(c->titlebar.sw, c->titlebar.sw->phys_screen);
draw_context_delete(ctx);
draw_context_delete(&ctx);
}
void

View File

@ -92,7 +92,7 @@ textbox_tell(Widget *widget, char *property, char *command)
if((newfont = draw_font_new(globalconf.display, command)))
{
if(d->style.font != globalconf.screens[widget->statusbar->screen].styles.normal.font)
draw_font_free(d->style.font);
draw_font_delete(&d->style.font);
d->style.font = newfont;
}
else