diff --git a/CMakeLists.txt b/CMakeLists.txt index 0826759e..1aa8dc3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,16 +59,16 @@ set(AWE_SRCS ${SOURCE_DIR}/titlebar.c ${SOURCE_DIR}/widget.c ${SOURCE_DIR}/window.c + ${SOURCE_DIR}/draw.c + ${SOURCE_DIR}/swindow.c + ${SOURCE_DIR}/xscreen.c ${SOURCE_DIR}/common/buffer.c ${SOURCE_DIR}/common/atoms.c - ${SOURCE_DIR}/common/draw.c ${SOURCE_DIR}/common/markup.c ${SOURCE_DIR}/common/socket.c - ${SOURCE_DIR}/common/swindow.c ${SOURCE_DIR}/common/util.c ${SOURCE_DIR}/common/version.c ${SOURCE_DIR}/common/xembed.c - ${SOURCE_DIR}/common/xscreen.c ${SOURCE_DIR}/common/xutil.c ${SOURCE_DIR}/layouts/fibonacci.c ${SOURCE_DIR}/layouts/floating.c diff --git a/awesome.c b/awesome.c index 7a7cdd2d..8b645bb7 100644 --- a/awesome.c +++ b/awesome.c @@ -426,7 +426,7 @@ main(int argc, char **argv) atoms_init(globalconf.connection); /* init screens struct */ - globalconf.screens_info = screensinfo_new(globalconf.connection); + globalconf.screens_info = screensinfo_new(); globalconf.screen_focus = globalconf.screens = p_new(screen_t, globalconf.screens_info->nscreen); /* \todo stop duplicating this */ for(screen_nbr = 0; screen_nbr < globalconf.screens_info->nscreen; screen_nbr++) @@ -436,15 +436,13 @@ main(int argc, char **argv) } /* init default font and colors */ - colors_reqs[0] = xcolor_init_unchecked(globalconf.connection, &globalconf.colors.fg, - globalconf.default_screen, "black", - sizeof("black")-1); + colors_reqs[0] = xcolor_init_unchecked(&globalconf.colors.fg, + "black", sizeof("black") - 1); - colors_reqs[1] = xcolor_init_unchecked(globalconf.connection, &globalconf.colors.bg, - globalconf.default_screen, "white", - sizeof("white")-1); + colors_reqs[1] = xcolor_init_unchecked(&globalconf.colors.bg, + "white", sizeof("white") - 1); - globalconf.font = draw_font_new(globalconf.connection, globalconf.default_screen, "sans 8"); + globalconf.font = draw_font_new(globalconf.default_screen, "sans 8"); /* init cursors */ globalconf.cursor[CurNormal] = xutil_cursor_new(globalconf.connection, XUTIL_CURSOR_LEFT_PTR); @@ -458,7 +456,7 @@ main(int argc, char **argv) globalconf.cursor[CurBotLeft] = xutil_cursor_new(globalconf.connection, XUTIL_CURSOR_BOTTOM_LEFT_CORNER); for(colors_nbr = 0; colors_nbr < 2; colors_nbr++) - xcolor_init_reply(globalconf.connection, colors_reqs[colors_nbr]); + xcolor_init_reply(colors_reqs[colors_nbr]); /* Process the reply of previously sent mapping request */ xutil_lock_mask_get(globalconf.connection, xmapping_cookie, diff --git a/client.c b/client.c index 4bd4d4bd..8b41c859 100644 --- a/client.c +++ b/client.c @@ -1350,11 +1350,7 @@ luaA_client_newindex(lua_State *L) break; case A_TK_BORDER_COLOR: if((buf = luaL_checklstring(L, 3, &len)) - && xcolor_init_reply(globalconf.connection, - xcolor_init_unchecked(globalconf.connection, - &(*c)->border_color, - (*c)->phys_screen, buf, - len))) + && xcolor_init_reply(xcolor_init_unchecked(&(*c)->border_color, buf, len))) xcb_change_window_attributes(globalconf.connection, (*c)->win, XCB_CW_BORDER_PIXEL, &(*c)->border_color.pixel); break; diff --git a/common/swindow.h b/common/swindow.h deleted file mode 100644 index 99a04518..00000000 --- a/common/swindow.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * swindow.h - simple window handling functions header - * - * Copyright © 2008 Julien Danjou - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#ifndef AWESOME_COMMON_SWINDOW_H -#define AWESOME_COMMON_SWINDOW_H - -#include "common/draw.h" - -/** A simple window. */ -typedef struct simple_window_t -{ - /** The display connection. */ - xcb_connection_t *connection; - /** The physical screen number the window is on. */ - int phys_screen; - /** The window object. */ - xcb_window_t window; - /** The pixmap copied to the window object. */ - xcb_pixmap_t pixmap; - /** The graphic context. */ - xcb_gcontext_t gc; - /** The window geometry. */ - area_t geometry; - /** The window border width */ - int border_width; -} simple_window_t; - -simple_window_t * simplewindow_new(xcb_connection_t *, int, int, int, unsigned int, unsigned int, unsigned int); - -/** Destroy a simple window and all its resources. - * \param sw The simple_window_t to delete. - */ -static inline void -simplewindow_delete(simple_window_t **sw) -{ - if(*sw) - { - xcb_destroy_window((*sw)->connection, (*sw)->window); - xcb_free_pixmap((*sw)->connection, (*sw)->pixmap); - xcb_free_gc((*sw)->connection, (*sw)->gc); - p_delete(sw); - } -} - -void simplewindow_move(simple_window_t *, int, int); -void simplewindow_resize(simple_window_t *, int, int); -void simplewindow_moveresize(simple_window_t *, int, int, int, int); - -/** Refresh the window content by copying its pixmap data to its window. - * \param sw The simple window to refresh. - */ -static inline void -simplewindow_refresh_pixmap(simple_window_t *sw) -{ - xcb_copy_area(sw->connection, sw->pixmap, - sw->window, sw->gc, 0, 0, 0, 0, - sw->geometry.width, - sw->geometry.height); -} - -/** Set a simple window border width. - * \param sw The simple window to change border width. - * \param border_width The border width in pixel. - */ -static inline void -simplewindow_border_width_set(simple_window_t *sw, uint32_t border_width) -{ - xcb_configure_window(sw->connection, sw->window, XCB_CONFIG_WINDOW_BORDER_WIDTH, - &border_width); - sw->border_width = border_width; -} - -/** Set a simple window border color. - * \param sw The simple window to change border width. - * \param color The border color. - */ -static inline void -simplewindow_border_color_set(simple_window_t *sw, const xcolor_t *color) -{ - xcb_change_window_attributes(sw->connection, sw->window, - XCB_CW_BORDER_PIXEL, &color->pixel); -} - -#endif -// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/common/draw.c b/draw.c similarity index 92% rename from common/draw.c rename to draw.c index f16010e5..8e94cecc 100644 --- a/common/draw.c +++ b/draw.c @@ -29,8 +29,6 @@ #include #endif -#include - #include #include #include @@ -38,10 +36,12 @@ #include #include +#include "structs.h" + #include "common/tokenize.h" -#include "common/draw.h" #include "common/markup.h" -#include "common/xutil.h" + +extern awesome_t globalconf; static iconv_t iso2utf8 = (iconv_t) -1; @@ -109,7 +109,6 @@ draw_screen_default_visual(xcb_screen_t *s) } /** Create a new draw context. - * \param conn Connection ref. * \param phys_screen Physical screen id. * \param width Width. * \param height Height. @@ -119,21 +118,20 @@ draw_screen_default_visual(xcb_screen_t *s) * \return A draw context pointer. */ draw_context_t * -draw_context_new(xcb_connection_t *conn, int phys_screen, +draw_context_new(int phys_screen, int width, int height, xcb_pixmap_t px, const xcolor_t *fg, const xcolor_t *bg) { draw_context_t *d = p_new(draw_context_t, 1); - xcb_screen_t *s = xutil_screen_get(conn, phys_screen); + xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen); - d->connection = conn; d->phys_screen = phys_screen; d->width = width; d->height = height; d->depth = s->root_depth; d->visual = draw_screen_default_visual(s); d->pixmap = px; - d->surface = cairo_xcb_surface_create(conn, px, d->visual, width, height); + d->surface = cairo_xcb_surface_create(globalconf.connection, px, d->visual, width, height); d->cr = cairo_create(d->surface); d->layout = pango_cairo_create_layout(d->cr); d->fg = *fg; @@ -143,23 +141,22 @@ draw_context_new(xcb_connection_t *conn, int phys_screen, }; /** Create a new Pango font - * \param conn Connection ref * \param phys_screen The physical screen number. * \param fontname Pango fontname (e.g. [FAMILY-LIST] [STYLE-OPTIONS] [SIZE]) * \return a new font */ font_t * -draw_font_new(xcb_connection_t *conn, int phys_screen, const char *fontname) +draw_font_new(int phys_screen, const char *fontname) { cairo_surface_t *surface; - xcb_screen_t *s = xutil_screen_get(conn, phys_screen); + xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen); cairo_t *cr; PangoLayout *layout; font_t *font = p_new(font_t, 1); /* Create a dummy cairo surface, cairo context and pango layout in * order to get font informations */ - surface = cairo_xcb_surface_create(conn, + surface = cairo_xcb_surface_create(globalconf.connection, phys_screen, draw_screen_default_visual(s), s->width_in_pixels, @@ -226,11 +223,9 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem, switch(a_tokenize(*names, -1)) { case A_TK_COLOR: - reqs[++reqs_nbr] = xcolor_init_unchecked(data->connection, - &data->bg_color, - data->phys_screen, - *values, - a_strlen(*values)); + reqs[++reqs_nbr] = xcolor_init_unchecked(&data->bg_color, + *values, + a_strlen(*values)); bg_color_nbr = reqs_nbr; break; @@ -254,11 +249,9 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem, switch(a_tokenize(*names, -1)) { case A_TK_COLOR: - reqs[++reqs_nbr] = xcolor_init_unchecked(data->connection, - &data->border.color, - data->phys_screen, - *values, - a_strlen(*values)); + reqs[++reqs_nbr] = xcolor_init_unchecked(&data->border.color, + *values, + a_strlen(*values)); break; case A_TK_WIDTH: data->border.width = atoi(*values); @@ -275,11 +268,9 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem, data->align = draw_align_fromstr(*values, -1); break; case A_TK_SHADOW: - reqs[++reqs_nbr] = xcolor_init_unchecked(data->connection, - &data->shadow.color, - data->phys_screen, - *values, - a_strlen(*values)); + reqs[++reqs_nbr] = xcolor_init_unchecked(&data->shadow.color, + *values, + a_strlen(*values)); break; case A_TK_SHADOW_OFFSET: data->shadow.offset = atoi(*values); @@ -308,9 +299,9 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem, for(i = 0; i <= reqs_nbr; i++) if(i == bg_color_nbr) - data->has_bg_color = xcolor_init_reply(data->connection, reqs[i]); + data->has_bg_color = xcolor_init_reply(reqs[i]); else - xcolor_init_reply(data->connection, reqs[i]); + xcolor_init_reply(reqs[i]); } bool @@ -367,8 +358,6 @@ draw_text(draw_context_t *ctx, font_t *font, if(!pdata) { draw_parser_data_init(&parser_data); - parser_data.connection = ctx->connection; - parser_data.phys_screen = ctx->phys_screen; if(draw_text_markup_expand(&parser_data, text, len)) { text = parser_data.text; @@ -754,7 +743,7 @@ draw_graph_line(draw_context_t *ctx, area_t rect, int *to, int cur_index, * \param wanted_h Wanted height: if > 0, image will be resized. * \param data The image pixels array. */ -void +static void draw_image_from_argb_data(draw_context_t *ctx, int x, int y, int w, int h, int wanted_h, unsigned char *data) { @@ -1006,9 +995,9 @@ draw_rotate(draw_context_t *ctx, cairo_surface_t *surface, *source; cairo_t *cr; - surface = cairo_xcb_surface_create(ctx->connection, dest, + surface = cairo_xcb_surface_create(globalconf.connection, dest, ctx->visual, dest_w, dest_h); - source = cairo_xcb_surface_create(ctx->connection, src, + source = cairo_xcb_surface_create(globalconf.connection, src, ctx->visual, src_w, src_h); cr = cairo_create (surface); @@ -1024,7 +1013,6 @@ draw_rotate(draw_context_t *ctx, } /** Return the width and height of a text in pixel. - * \param conn Connection ref. * \param phys_screen Physical screen number. * \param font Font to use. * \param text The text. @@ -1033,26 +1021,23 @@ draw_rotate(draw_context_t *ctx, * \return Text height and width. */ area_t -draw_text_extents(xcb_connection_t *conn, int phys_screen, font_t *font, +draw_text_extents(int phys_screen, font_t *font, const char *text, ssize_t len, draw_parser_data_t *parser_data) { cairo_surface_t *surface; cairo_t *cr; PangoLayout *layout; PangoRectangle ext; - xcb_screen_t *s = xutil_screen_get(conn, phys_screen); + xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen); area_t geom = { 0, 0, 0, 0 }; if(!len) return geom; - parser_data->connection = conn; - parser_data->phys_screen = phys_screen; - if(!draw_text_markup_expand(parser_data, text, len)) return geom; - surface = cairo_xcb_surface_create(conn, phys_screen, + surface = cairo_xcb_surface_create(globalconf.connection, phys_screen, draw_screen_default_visual(s), s->width_in_pixels, s->height_in_pixels); @@ -1114,17 +1099,14 @@ draw_align_tostr(alignment_t a) #define RGB_COLOR_8_TO_16(i) (65535 * ((i) & 0xff) / 255) /** Send a request to initialize a X color. - * \param conn Connection ref. * \param color xcolor_t struct to store color into. - * \param phys_screen Physical screen number. * \param colstr Color specification. * \return request informations. */ xcolor_init_request_t -xcolor_init_unchecked(xcb_connection_t *conn, xcolor_t *color, int phys_screen, - const char *colstr, ssize_t len) +xcolor_init_unchecked(xcolor_t *color, const char *colstr, ssize_t len) { - xcb_screen_t *s = xutil_screen_get(conn, phys_screen); + xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen); xcolor_init_request_t req; unsigned long colnum; uint16_t red, green, blue; @@ -1173,13 +1155,15 @@ xcolor_init_unchecked(xcb_connection_t *conn, xcolor_t *color, int phys_screen, blue = RGB_COLOR_8_TO_16(colnum); req.is_hexa = true; - req.cookie_hexa = xcb_alloc_color_unchecked(conn, s->default_colormap, - red, green, blue); + req.cookie_hexa = xcb_alloc_color_unchecked(globalconf.connection, + s->default_colormap, + red, green, blue); } else { req.is_hexa = false; - req.cookie_named = xcb_alloc_named_color_unchecked(conn, s->default_colormap, len, + req.cookie_named = xcb_alloc_named_color_unchecked(globalconf.connection, + s->default_colormap, len, colstr); } @@ -1190,13 +1174,11 @@ xcolor_init_unchecked(xcb_connection_t *conn, xcolor_t *color, int phys_screen, } /** Initialize a X color. - * \param conn Connection ref. * \param req xcolor_init request. * \return True if color allocation was successfull. */ bool -xcolor_init_reply(xcb_connection_t *conn, - xcolor_init_request_t req) +xcolor_init_reply(xcolor_init_request_t req) { if(req.has_error) return false; @@ -1205,7 +1187,8 @@ xcolor_init_reply(xcb_connection_t *conn, { xcb_alloc_color_reply_t *hexa_color; - if((hexa_color = xcb_alloc_color_reply(conn, req.cookie_hexa, NULL))) + if((hexa_color = xcb_alloc_color_reply(globalconf.connection, + req.cookie_hexa, NULL))) { req.color->pixel = hexa_color->pixel; req.color->red = hexa_color->red; @@ -1221,7 +1204,8 @@ xcolor_init_reply(xcb_connection_t *conn, { xcb_alloc_named_color_reply_t *named_color; - if((named_color = xcb_alloc_named_color_reply(conn, req.cookie_named, NULL))) + if((named_color = xcb_alloc_named_color_reply(globalconf.connection, + req.cookie_named, NULL))) { req.color->pixel = named_color->pixel; req.color->red = named_color->visual_red; diff --git a/common/draw.h b/draw.h similarity index 89% rename from common/draw.h rename to draw.h index 8ee88c6d..332e1c2b 100644 --- a/common/draw.h +++ b/draw.h @@ -86,7 +86,6 @@ typedef struct typedef struct { - xcb_connection_t *connection; xcb_pixmap_t pixmap; xcb_visualtype_t *visual; int width; @@ -108,7 +107,7 @@ typedef struct } draw_image_t; draw_context_t * -draw_context_new(xcb_connection_t *, int, int, int, xcb_drawable_t, +draw_context_new(int, int, int, xcb_drawable_t, const xcolor_t *, const xcolor_t*); /** Delete a draw context. @@ -129,7 +128,7 @@ draw_context_delete(draw_context_t **ctx) } } -font_t *draw_font_new(xcb_connection_t *, int, const char *); +font_t *draw_font_new(int, const char *); void draw_font_delete(font_t **); char * draw_iso2utf8(const char *, size_t); @@ -149,9 +148,7 @@ a_iso2utf8(char **dest, const char *str, ssize_t len) typedef struct { - xcb_connection_t *connection; PangoAttrList *attr_list; - int phys_screen; char *text; ssize_t len; alignment_t align; @@ -195,9 +192,8 @@ void draw_graph_line(draw_context_t *, area_t, int *, int, position_t, vector_t, draw_image_t *draw_image_new(const char *); void draw_image_delete(draw_image_t **); void draw_image(draw_context_t *, int, int, int, draw_image_t *); -void draw_image_from_argb_data(draw_context_t *, int, int, int, int, int, unsigned char *); 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 *, ssize_t, draw_parser_data_t *); +area_t draw_text_extents(int, font_t *, const char *, ssize_t, draw_parser_data_t *); alignment_t draw_align_fromstr(const char *, ssize_t); const char *draw_align_tostr(alignment_t); @@ -215,10 +211,8 @@ typedef struct const char *colstr; } xcolor_init_request_t; -xcolor_init_request_t xcolor_init_unchecked(xcb_connection_t *, xcolor_t *, int, - const char *, ssize_t); - -bool xcolor_init_reply(xcb_connection_t *, xcolor_init_request_t); +xcolor_init_request_t xcolor_init_unchecked(xcolor_t *, const char *, ssize_t); +bool xcolor_init_reply(xcolor_init_request_t); static inline void draw_parser_data_init(draw_parser_data_t *pdata) diff --git a/lua.c b/lua.c index a4557bb4..81fb83ad 100644 --- a/lua.c +++ b/lua.c @@ -269,8 +269,7 @@ luaA_font_set(lua_State *L) deprecate(); const char *font = luaL_checkstring(L, 1); draw_font_delete(&globalconf.font); - globalconf.font = draw_font_new(globalconf.connection, - globalconf.default_screen, font); + globalconf.font = draw_font_new(globalconf.default_screen, font); return 0; } @@ -290,8 +289,7 @@ luaA_font(lua_State *L) { const char *newfont = luaL_checkstring(L, 1); draw_font_delete(&globalconf.font); - globalconf.font = draw_font_new(globalconf.connection, - globalconf.default_screen, newfont); + globalconf.font = draw_font_new(globalconf.default_screen, newfont); } font = pango_font_description_to_string(globalconf.font->desc); @@ -319,19 +317,13 @@ luaA_colors_set(lua_State *L) luaA_checktable(L, 1); if((buf = luaA_getopt_lstring(L, 1, "fg", NULL, &len))) - reqs[++colors_nbr] = xcolor_init_unchecked(globalconf.connection, - &globalconf.colors.fg, - globalconf.default_screen, - buf, len); + reqs[++colors_nbr] = xcolor_init_unchecked(&globalconf.colors.fg, buf, len); if((buf = luaA_getopt_lstring(L, 1, "bg", NULL, &len))) - reqs[++colors_nbr] = xcolor_init_unchecked(globalconf.connection, - &globalconf.colors.bg, - globalconf.default_screen, - buf, len); + reqs[++colors_nbr] = xcolor_init_unchecked(&globalconf.colors.bg, buf, len); for(i = 0; i <= colors_nbr; i++) - xcolor_init_reply(globalconf.connection, reqs[i]); + xcolor_init_reply(reqs[i]); return 0; } @@ -349,19 +341,13 @@ luaA_colors(lua_State *L) luaA_checktable(L, 1); if((buf = luaA_getopt_lstring(L, 1, "fg", NULL, &len))) - reqs[++colors_nbr] = xcolor_init_unchecked(globalconf.connection, - &globalconf.colors.fg, - globalconf.default_screen, - buf, len); + reqs[++colors_nbr] = xcolor_init_unchecked(&globalconf.colors.fg, buf, len); if((buf = luaA_getopt_lstring(L, 1, "bg", NULL, &len))) - reqs[++colors_nbr] = xcolor_init_unchecked(globalconf.connection, - &globalconf.colors.bg, - globalconf.default_screen, - buf, len); + reqs[++colors_nbr] = xcolor_init_unchecked(&globalconf.colors.bg, buf, len); for(i = 0; i <= colors_nbr; i++) - xcolor_init_reply(globalconf.connection, reqs[i]); + xcolor_init_reply(reqs[i]); } lua_newtable(L); diff --git a/lua.h b/lua.h index 773e6c48..2d689895 100644 --- a/lua.h +++ b/lua.h @@ -26,8 +26,8 @@ #include #include +#include "draw.h" #include "common/util.h" -#include "common/draw.h" /** Object types */ typedef enum diff --git a/mouse.c b/mouse.c index 0088cb2a..6c7c4fc6 100644 --- a/mouse.c +++ b/mouse.c @@ -278,8 +278,7 @@ mouse_infobox_new(int phys_screen, int border, area_t geometry, draw_parser_data_init(&pdata); - geom = draw_text_extents(globalconf.connection, - globalconf.default_screen, + geom = draw_text_extents(globalconf.default_screen, globalconf.font, MOUSE_INFOBOX_STRING_DEFAULT, sizeof(MOUSE_INFOBOX_STRING_DEFAULT)-1, @@ -287,11 +286,11 @@ mouse_infobox_new(int phys_screen, int border, area_t geometry, geom.x = geometry.x + ((2 * border + geometry.width) - geom.width) / 2; geom.y = geometry.y + ((2 * border + geometry.height) - geom.height) / 2; - sw = simplewindow_new(globalconf.connection, phys_screen, + sw = simplewindow_new(phys_screen, geom.x, geom.y, geom.width, geom.height, 0); - *ctx = draw_context_new(globalconf.connection, sw->phys_screen, + *ctx = draw_context_new(sw->phys_screen, sw->geometry.width, sw->geometry.height, sw->pixmap, &globalconf.colors.fg, diff --git a/statusbar.c b/statusbar.c index 3c6b0ebd..0a4935f7 100644 --- a/statusbar.c +++ b/statusbar.c @@ -454,7 +454,7 @@ statusbar_position_update(statusbar_t *statusbar) statusbar_clean(statusbar); statusbar->sw = - simplewindow_new(globalconf.connection, statusbar->phys_screen, 0, 0, + simplewindow_new(statusbar->phys_screen, 0, 0, wingeometry.width, wingeometry.height, 0); switch(statusbar->position) @@ -468,8 +468,7 @@ statusbar_position_update(statusbar_t *statusbar) xcb_create_pixmap(globalconf.connection, s->root_depth, dw, s->root, statusbar->width, statusbar->height); - statusbar->ctx = draw_context_new(globalconf.connection, - statusbar->phys_screen, + statusbar->ctx = draw_context_new(statusbar->phys_screen, statusbar->width, statusbar->height, dw, @@ -478,8 +477,7 @@ statusbar_position_update(statusbar_t *statusbar) break; default: statusbar->width = wingeometry.width; - statusbar->ctx = draw_context_new(globalconf.connection, - statusbar->phys_screen, + statusbar->ctx = draw_context_new(statusbar->phys_screen, statusbar->width, statusbar->height, statusbar->sw->pixmap, @@ -541,17 +539,11 @@ luaA_statusbar_new(lua_State *L) sb->colors.fg = globalconf.colors.fg; if((buf = luaA_getopt_lstring(L, 2, "fg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &sb->colors.fg, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&sb->colors.fg, buf, len); sb->colors.bg = globalconf.colors.bg; if((buf = luaA_getopt_lstring(L, 2, "bg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &sb->colors.bg, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&sb->colors.bg, buf, len); buf = luaA_getopt_lstring(L, 2, "align", "left", &len); sb->align = draw_align_fromstr(buf, len); @@ -570,7 +562,7 @@ luaA_statusbar_new(lua_State *L) sb->screen = SCREEN_UNDEF; for(i = 0; i <= reqs_nbr; i++) - xcolor_init_reply(globalconf.connection, reqs[i]); + xcolor_init_reply(reqs[i]); return luaA_statusbar_userdata_new(L, sb); } @@ -725,11 +717,7 @@ luaA_statusbar_newindex(lua_State *L) break; case A_TK_FG: if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(globalconf.connection, - xcolor_init_unchecked(globalconf.connection, - &(*statusbar)->colors.fg, - globalconf.default_screen, - buf, len))) + if(xcolor_init_reply(xcolor_init_unchecked(&(*statusbar)->colors.fg, buf, len))) { if((*statusbar)->ctx) (*statusbar)->ctx->fg = (*statusbar)->colors.fg; @@ -738,10 +726,7 @@ luaA_statusbar_newindex(lua_State *L) break; case A_TK_BG: if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(globalconf.connection, - xcolor_init_unchecked(globalconf.connection, - &(*statusbar)->colors.bg, - globalconf.default_screen, buf, len))) + if(xcolor_init_reply(xcolor_init_unchecked(&(*statusbar)->colors.bg, buf, len))) { if((*statusbar)->ctx) (*statusbar)->ctx->bg = (*statusbar)->colors.bg; diff --git a/statusbar.h b/statusbar.h index 1565b760..c158a19b 100644 --- a/statusbar.h +++ b/statusbar.h @@ -23,8 +23,8 @@ #define AWESOME_STATUSBAR_H #include "structs.h" +#include "swindow.h" #include "common/refcount.h" -#include "common/swindow.h" static inline void statusbar_delete(statusbar_t **statusbar) diff --git a/structs.h b/structs.h index 096f0070..3ea86e76 100644 --- a/structs.h +++ b/structs.h @@ -28,12 +28,12 @@ #include "lua.h" #include "layout.h" +#include "swindow.h" +#include "xscreen.h" #include "common/xutil.h" -#include "common/draw.h" -#include "common/swindow.h" -#include "common/xscreen.h" #include "common/xembed.h" #include "common/refcount.h" +#include "draw.h" /** Stacking layout layers */ typedef enum diff --git a/common/swindow.c b/swindow.c similarity index 61% rename from common/swindow.c rename to swindow.c index 7325d7ff..738393a6 100644 --- a/common/swindow.c +++ b/swindow.c @@ -21,11 +21,13 @@ #include -#include "common/swindow.h" +#include "structs.h" +#include "swindow.h" #include "common/xutil.h" +extern awesome_t globalconf; + /** Create a simple window. - * \param conn Connection ref. * \param phys_screen Physical screen number. * \param x x coordinate. * \param y y coordinate. @@ -36,12 +38,12 @@ * with simplewindow_delete(). */ simple_window_t * -simplewindow_new(xcb_connection_t *conn, int phys_screen, int x, int y, +simplewindow_new(int phys_screen, int x, int y, unsigned int w, unsigned int h, unsigned int border_width) { simple_window_t *sw; - xcb_screen_t *s = xutil_screen_get(conn, phys_screen); + xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen); uint32_t create_win_val[3]; const uint32_t gc_mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND; const uint32_t gc_values[2] = { s->black_pixel, s->white_pixel }; @@ -52,7 +54,6 @@ simplewindow_new(xcb_connection_t *conn, int phys_screen, int x, int y, sw->geometry.y = y; sw->geometry.width = w; sw->geometry.height = h; - sw->connection = conn; sw->phys_screen = phys_screen; create_win_val[0] = XCB_BACK_PIXMAP_PARENT_RELATIVE; @@ -63,25 +64,42 @@ simplewindow_new(xcb_connection_t *conn, int phys_screen, int x, int y, | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE; - sw->window = xcb_generate_id(conn); - xcb_create_window(conn, s->root_depth, sw->window, s->root, x, y, w, h, + sw->window = xcb_generate_id(globalconf.connection); + xcb_create_window(globalconf.connection, s->root_depth, sw->window, s->root, x, y, w, h, border_width, XCB_COPY_FROM_PARENT, s->root_visual, XCB_CW_BACK_PIXMAP | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK, create_win_val); - sw->pixmap = xcb_generate_id(conn); - xcb_create_pixmap(conn, s->root_depth, sw->pixmap, s->root, w, h); + sw->pixmap = xcb_generate_id(globalconf.connection); + xcb_create_pixmap(globalconf.connection, s->root_depth, sw->pixmap, s->root, w, h); /* The default GC is just a newly created associated to the root + * bal + * gg * window */ - sw->gc = xcb_generate_id(sw->connection); - xcb_create_gc(sw->connection, sw->gc, s->root, gc_mask, gc_values); + sw->gc = xcb_generate_id(globalconf.connection); + xcb_create_gc(globalconf.connection, sw->gc, s->root, gc_mask, gc_values); sw->border_width = border_width; return sw; } +/** Destroy a simple window and all its resources. + * \param sw The simple_window_t to delete. + */ +void +simplewindow_delete(simple_window_t **sw) +{ + if(*sw) + { + xcb_destroy_window(globalconf.connection, (*sw)->window); + xcb_free_pixmap(globalconf.connection, (*sw)->pixmap); + xcb_free_gc(globalconf.connection, (*sw)->gc); + p_delete(sw); + } +} + /** Move a simple window. * \param sw The simple window to move. * \param x New x coordinate. @@ -94,7 +112,7 @@ simplewindow_move(simple_window_t *sw, int x, int y) sw->geometry.x = x; sw->geometry.y = y; - xcb_configure_window(sw->connection, sw->window, + xcb_configure_window(globalconf.connection, sw->window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, move_win_vals); } @@ -107,7 +125,7 @@ simplewindow_move(simple_window_t *sw, int x, int y) void simplewindow_resize(simple_window_t *sw, int w, int h) { - xcb_screen_t *s = xutil_screen_get(sw->connection, sw->phys_screen); + xcb_screen_t *s = xutil_screen_get(globalconf.connection, sw->phys_screen); uint32_t resize_win_vals[2]; xcb_pixmap_t d; @@ -116,12 +134,12 @@ simplewindow_resize(simple_window_t *sw, int w, int h) sw->geometry.width = resize_win_vals[0] = w; sw->geometry.height = resize_win_vals[1] = h; d = sw->pixmap; - sw->pixmap = xcb_generate_id(sw->connection); - xcb_create_pixmap(sw->connection, s->root_depth, sw->pixmap, s->root, w, h); - xcb_configure_window(sw->connection, sw->window, + sw->pixmap = xcb_generate_id(globalconf.connection); + xcb_create_pixmap(globalconf.connection, s->root_depth, sw->pixmap, s->root, w, h); + xcb_configure_window(globalconf.connection, sw->window, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, resize_win_vals); - xcb_free_pixmap(sw->connection, d); + xcb_free_pixmap(globalconf.connection, d); } } @@ -137,7 +155,7 @@ simplewindow_moveresize(simple_window_t *sw, int x, int y, int w, int h) { uint32_t moveresize_win_vals[4], mask_vals = 0; xcb_pixmap_t d; - xcb_screen_t *s = xutil_screen_get(sw->connection, sw->phys_screen); + xcb_screen_t *s = xutil_screen_get(globalconf.connection, sw->phys_screen); if(sw->geometry.x != x || sw->geometry.y != y) { @@ -160,12 +178,47 @@ simplewindow_moveresize(simple_window_t *sw, int x, int y, int w, int h) } mask_vals |= XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; d = sw->pixmap; - sw->pixmap = xcb_generate_id(sw->connection); - xcb_create_pixmap(sw->connection, s->root_depth, sw->pixmap, s->root, w, h); - xcb_free_pixmap(sw->connection, d); + sw->pixmap = xcb_generate_id(globalconf.connection); + xcb_create_pixmap(globalconf.connection, s->root_depth, sw->pixmap, s->root, w, h); + xcb_free_pixmap(globalconf.connection, d); } - xcb_configure_window(sw->connection, sw->window, mask_vals, moveresize_win_vals); + xcb_configure_window(globalconf.connection, sw->window, mask_vals, moveresize_win_vals); +} + +/** Refresh the window content by copying its pixmap data to its window. + * \param sw The simple window to refresh. + */ +void +simplewindow_refresh_pixmap(simple_window_t *sw) +{ + xcb_copy_area(globalconf.connection, sw->pixmap, + sw->window, sw->gc, 0, 0, 0, 0, + sw->geometry.width, + sw->geometry.height); +} + +/** Set a simple window border width. + * \param sw The simple window to change border width. + * \param border_width The border width in pixel. + */ +void +simplewindow_border_width_set(simple_window_t *sw, uint32_t border_width) +{ + xcb_configure_window(globalconf.connection, sw->window, XCB_CONFIG_WINDOW_BORDER_WIDTH, + &border_width); + sw->border_width = border_width; +} + +/** Set a simple window border color. + * \param sw The simple window to change border width. + * \param color The border color. + */ +void +simplewindow_border_color_set(simple_window_t *sw, const xcolor_t *color) +{ + xcb_change_window_attributes(globalconf.connection, sw->window, + XCB_CW_BORDER_PIXEL, &color->pixel); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/swindow.h b/swindow.h new file mode 100644 index 00000000..b20a0584 --- /dev/null +++ b/swindow.h @@ -0,0 +1,55 @@ +/* + * swindow.h - simple window handling functions header + * + * Copyright © 2008 Julien Danjou + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef AWESOME_COMMON_SWINDOW_H +#define AWESOME_COMMON_SWINDOW_H + +#include "draw.h" + +/** A simple window. */ +typedef struct simple_window_t +{ + /** The physical screen number the window is on. */ + int phys_screen; + /** The window object. */ + xcb_window_t window; + /** The pixmap copied to the window object. */ + xcb_pixmap_t pixmap; + /** The graphic context. */ + xcb_gcontext_t gc; + /** The window geometry. */ + area_t geometry; + /** The window border width */ + int border_width; +} simple_window_t; + +simple_window_t * simplewindow_new(int, int, int, unsigned int, unsigned int, unsigned int); +void simplewindow_delete(simple_window_t **); + +void simplewindow_move(simple_window_t *, int, int); +void simplewindow_resize(simple_window_t *, int, int); +void simplewindow_moveresize(simple_window_t *, int, int, int, int); +void simplewindow_refresh_pixmap(simple_window_t *); +void simplewindow_border_width_set(simple_window_t *, uint32_t); +void simplewindow_border_color_set(simple_window_t *, const xcolor_t *); + +#endif +// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/titlebar.c b/titlebar.c index 56096d8f..f7937d62 100644 --- a/titlebar.c +++ b/titlebar.c @@ -93,7 +93,7 @@ titlebar_draw(client_t *c) s->root, c->titlebar->sw->geometry.height, c->titlebar->sw->geometry.width); - ctx = draw_context_new(globalconf.connection, c->titlebar->sw->phys_screen, + ctx = draw_context_new(c->titlebar->sw->phys_screen, c->titlebar->sw->geometry.height, c->titlebar->sw->geometry.width, dw, @@ -101,7 +101,7 @@ titlebar_draw(client_t *c) &c->titlebar->colors.bg); break; default: - ctx = draw_context_new(globalconf.connection, c->titlebar->sw->phys_screen, + ctx = draw_context_new(c->titlebar->sw->phys_screen, c->titlebar->sw->geometry.width, c->titlebar->sw->geometry.height, c->titlebar->sw->pixmap, @@ -283,7 +283,7 @@ titlebar_init(client_t *c) titlebar_geometry_compute(c, c->geometry, &geom); - c->titlebar->sw = simplewindow_new(globalconf.connection, c->phys_screen, geom.x, geom.y, + c->titlebar->sw = simplewindow_new(c->phys_screen, geom.x, geom.y, geom.width, geom.height, c->titlebar->border.width); if(c->titlebar->border.width) @@ -331,29 +331,20 @@ luaA_titlebar_new(lua_State *L) tb->colors.fg = globalconf.colors.fg; if((buf = luaA_getopt_lstring(L, 2, "fg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &tb->colors.fg, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&tb->colors.fg, buf, len); tb->colors.bg = globalconf.colors.bg; if((buf = luaA_getopt_lstring(L, 2, "bg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &tb->colors.bg, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&tb->colors.bg, buf, len); tb->border.color = globalconf.colors.fg; if((buf = luaA_getopt_lstring(L, 2, "border_color", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &tb->border.color, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&tb->border.color, buf, len); tb->border.width = luaA_getopt_number(L, 2, "border_width", 0); for(i = 0; i <= reqs_nbr; i++) - xcolor_init_reply(globalconf.connection, reqs[i]); + xcolor_init_reply(reqs[i]); return luaA_titlebar_userdata_new(globalconf.L, tb); } @@ -422,30 +413,19 @@ luaA_titlebar_newindex(lua_State *L) break; case A_TK_BORDER_COLOR: if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(globalconf.connection, - xcolor_init_unchecked(globalconf.connection, - &(*titlebar)->border.color, - globalconf.default_screen, buf, len))) + if(xcolor_init_reply(xcolor_init_unchecked(&(*titlebar)->border.color, buf, len))) if((*titlebar)->sw) xcb_change_window_attributes(globalconf.connection, (*titlebar)->sw->window, XCB_CW_BORDER_PIXEL, &(*titlebar)->border.color.pixel); return 0; case A_TK_FG: if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(globalconf.connection, - xcolor_init_unchecked(globalconf.connection, - &(*titlebar)->colors.fg, - globalconf.default_screen, - buf, len))) + if(xcolor_init_reply(xcolor_init_unchecked(&(*titlebar)->colors.fg, buf, len))) (*titlebar)->need_update = true; return 0; case A_TK_BG: if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(globalconf.connection, - xcolor_init_unchecked(globalconf.connection, - &(*titlebar)->colors.bg, - globalconf.default_screen, - buf, len))) + if(xcolor_init_reply(xcolor_init_unchecked(&(*titlebar)->colors.bg, buf, len))) (*titlebar)->need_update = true; break; case A_TK_POSITION: diff --git a/widgets/graph.c b/widgets/graph.c index 5f01d66e..3fda731f 100644 --- a/widgets/graph.c +++ b/widgets/graph.c @@ -24,7 +24,6 @@ #include "widget.h" #include "common/tokenize.h" -#include "common/draw.h" extern awesome_t globalconf; @@ -302,22 +301,13 @@ luaA_graph_plot_properties_set(lua_State *L) plot = graph_plot_add(d, title); if((buf = luaA_getopt_lstring(L, 3, "fg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &plot->color_start, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&plot->color_start, buf, len); if((buf = luaA_getopt_lstring(L, 3, "fg_center", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &plot->pcolor_center, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&plot->pcolor_center, buf, len); if((buf = luaA_getopt_lstring(L, 3, "fg_end", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &plot->pcolor_end, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&plot->pcolor_end, buf, len); plot->vertical_gradient = luaA_getopt_boolean(L, 3, "vertical_gradient", plot->vertical_gradient); plot->scale = luaA_getopt_boolean(L, 3, "scale", plot->scale); @@ -343,7 +333,7 @@ luaA_graph_plot_properties_set(lua_State *L) } for(i = 0; i <= reqs_nbr; i++) - xcolor_init_reply(globalconf.connection, reqs[i]); + xcolor_init_reply(reqs[i]); widget_invalidate_bywidget(*widget); @@ -529,11 +519,7 @@ luaA_graph_newindex(lua_State *L, awesome_token_t token) case A_TK_BG: if((buf = luaL_checklstring(L, 3, &len))) { - if(xcolor_init_reply(globalconf.connection, - xcolor_init_unchecked(globalconf.connection, - &color, - globalconf.default_screen, - buf, len))) + if(xcolor_init_reply(xcolor_init_unchecked(&color, buf, len))) d->bg = color; else return 0; @@ -542,11 +528,7 @@ luaA_graph_newindex(lua_State *L, awesome_token_t token) case A_TK_BORDER_COLOR: if((buf = luaL_checklstring(L, 3, &len))) { - if(xcolor_init_reply(globalconf.connection, - xcolor_init_unchecked(globalconf.connection, - &color, - globalconf.default_screen, - buf, len))) + if(xcolor_init_reply(xcolor_init_unchecked(&color, buf, len))) d->border_color = color; else return 0; diff --git a/widgets/progressbar.c b/widgets/progressbar.c index e1ded0bd..f1a4dbe9 100644 --- a/widgets/progressbar.c +++ b/widgets/progressbar.c @@ -431,40 +431,22 @@ luaA_progressbar_bar_properties_set(lua_State *L) bar = progressbar_bar_add(d, title); if((buf = luaA_getopt_lstring(L, 3, "fg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &bar->fg, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&bar->fg, buf, len); if((buf = luaA_getopt_lstring(L, 3, "fg_off", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &bar->fg_off, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&bar->fg_off, buf, len); if((buf = luaA_getopt_lstring(L, 3, "bg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &bar->bg, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&bar->bg, buf, len); if((buf = luaA_getopt_lstring(L, 3, "border_color", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &bar->border_color, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&bar->border_color, buf, len); if((buf = luaA_getopt_lstring(L, 3, "fg_center", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &bar->fg_center, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&bar->fg_center, buf, len); if((buf = luaA_getopt_lstring(L, 3, "fg_end", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(globalconf.connection, - &bar->fg_end, - globalconf.default_screen, - buf, len); + reqs[++reqs_nbr] = xcolor_init_unchecked(&bar->fg_end, buf, len); bar->min_value = luaA_getopt_number(L, 3, "min_value", bar->min_value); /* hack to prevent max_value beeing less than min_value @@ -484,7 +466,7 @@ luaA_progressbar_bar_properties_set(lua_State *L) bar->reverse = luaA_getopt_boolean(L, 3, "reverse", bar->reverse); for(i = 0; i <= reqs_nbr; i++) - xcolor_init_reply(globalconf.connection, reqs[i]); + xcolor_init_reply(reqs[i]); widget_invalidate_bywidget(*widget); diff --git a/widgets/taglist.c b/widgets/taglist.c index 726c3164..69772ba9 100644 --- a/widgets/taglist.c +++ b/widgets/taglist.c @@ -126,7 +126,7 @@ taglist_draw(draw_context_t *ctx, int screen, widget_node_t *w, lua_pop(globalconf.L, 1); draw_parser_data_init(&pdata[i]); - area = draw_text_extents(ctx->connection, ctx->phys_screen, + area = draw_text_extents(ctx->phys_screen, globalconf.font, text[i], len[i], &pdata[i]); if(pdata[i].bg_image) diff --git a/widgets/tasklist.c b/widgets/tasklist.c index caea9db3..df0f7a53 100644 --- a/widgets/tasklist.c +++ b/widgets/tasklist.c @@ -122,9 +122,6 @@ tasklist_draw_item(draw_context_t *ctx, { draw_parser_data_init(&pdata); - pdata.connection = ctx->connection; - pdata.phys_screen = ctx->phys_screen; - /* Actually look for the proper background color, since * otherwise the background statusbar color is used instead */ if(draw_text_markup_expand(&pdata, diff --git a/widgets/textbox.c b/widgets/textbox.c index d8ac4c66..4c8f3e31 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -153,7 +153,7 @@ luaA_textbox_newindex(lua_State *L, awesome_token_t token) if(buf) { a_iso2utf8(&d->text, buf, len); - d->extents = draw_text_extents(globalconf.connection, globalconf.default_screen, + d->extents = draw_text_extents(globalconf.default_screen, globalconf.font, d->text, d->len, &d->pdata).width; } else diff --git a/common/xscreen.c b/xscreen.c similarity index 86% rename from common/xscreen.c rename to xscreen.c index 5bb67dcf..8d02f405 100644 --- a/common/xscreen.c +++ b/xscreen.c @@ -1,5 +1,5 @@ /* - * common/xscreen.c - common X screen management + * xscreen.c - common X screen management * * Copyright © 2007-2008 Julien Danjou * @@ -22,8 +22,10 @@ #include #include -#include "common/xscreen.h" -#include "common/xutil.h" +#include "xscreen.h" +#include "structs.h" + +extern awesome_t globalconf; static inline area_t screen_xsitoarea(xcb_xinerama_screen_info_t si) @@ -46,11 +48,10 @@ screensinfo_delete(screens_info_t **si) } /** Get screens informations. - * \param conn X connection. * \return A pointer to complete screens_info_t structure. */ screens_info_t * -screensinfo_new(xcb_connection_t *conn) +screensinfo_new(void) { screens_info_t *si; xcb_xinerama_query_screens_reply_t *xsq; @@ -63,17 +64,17 @@ screensinfo_new(xcb_connection_t *conn) si = p_new(screens_info_t, 1); /* Check for extension before checking for Xinerama */ - if(xcb_get_extension_data(conn, &xcb_xinerama_id)->present) + if(xcb_get_extension_data(globalconf.connection, &xcb_xinerama_id)->present) { - xia = xcb_xinerama_is_active_reply(conn, xcb_xinerama_is_active(conn), NULL); + xia = xcb_xinerama_is_active_reply(globalconf.connection, xcb_xinerama_is_active(globalconf.connection), NULL); si->xinerama_is_active = xia->state; p_delete(&xia); } if(si->xinerama_is_active) { - xsq = xcb_xinerama_query_screens_reply(conn, - xcb_xinerama_query_screens_unchecked(conn), + xsq = xcb_xinerama_query_screens_reply(globalconf.connection, + xcb_xinerama_query_screens_unchecked(globalconf.connection), NULL); xsi = xcb_xinerama_query_screens_screen_info(xsq); @@ -115,11 +116,11 @@ screensinfo_new(xcb_connection_t *conn) } else { - si->nscreen = xcb_setup_roots_length(xcb_get_setup(conn)); + si->nscreen = xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); si->geometry = p_new(area_t, si->nscreen); for(screen = 0; screen < si->nscreen; screen++) { - s = xutil_screen_get(conn, screen); + s = xutil_screen_get(globalconf.connection, screen); si->geometry[screen].x = 0; si->geometry[screen].y = 0; si->geometry[screen].width = s->width_in_pixels; diff --git a/common/xscreen.h b/xscreen.h similarity index 93% rename from common/xscreen.h rename to xscreen.h index 2e6d83d1..4fc36784 100644 --- a/common/xscreen.h +++ b/xscreen.h @@ -22,7 +22,7 @@ #ifndef AWESOME_COMMON_XSCREEN_H #define AWESOME_COMMON_XSCREEN_H -#include "common/draw.h" +#include "draw.h" typedef struct { @@ -32,7 +32,7 @@ typedef struct } screens_info_t; void screensinfo_delete(screens_info_t **); -screens_info_t * screensinfo_new(xcb_connection_t *); +screens_info_t * screensinfo_new(void); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80