statusbar drawable is no more stored but dynamicaly created; this fix a problem with statusbar on right

This commit is contained in:
Julien Danjou 2007-11-11 22:27:00 +01:00
parent db65104aa2
commit 0753ed5fb5
6 changed files with 40 additions and 46 deletions

View File

@ -58,7 +58,6 @@ cleanup_screen(awesome_config *awesomeconf)
XftFontClose(awesomeconf->display, awesomeconf->font); XftFontClose(awesomeconf->display, awesomeconf->font);
XUngrabKey(awesomeconf->display, AnyKey, AnyModifier, RootWindow(awesomeconf->display, awesomeconf->phys_screen)); XUngrabKey(awesomeconf->display, AnyKey, AnyModifier, RootWindow(awesomeconf->display, awesomeconf->phys_screen));
XFreePixmap(awesomeconf->display, awesomeconf->statusbar.drawable);
XDestroyWindow(awesomeconf->display, awesomeconf->statusbar.window); XDestroyWindow(awesomeconf->display, awesomeconf->statusbar.window);
XFreeCursor(awesomeconf->display, awesomeconf->cursor[CurNormal]); XFreeCursor(awesomeconf->display, awesomeconf->cursor[CurNormal]);
XFreeCursor(awesomeconf->display, awesomeconf->cursor[CurResize]); XFreeCursor(awesomeconf->display, awesomeconf->cursor[CurResize]);

View File

@ -85,8 +85,6 @@ typedef struct
int position; int position;
/** Window */ /** Window */
Window window; Window window;
/** Drawable object */
Drawable drawable;
/** Screen */ /** Screen */
int screen; int screen;
} Statusbar; } Statusbar;

11
draw.c
View File

@ -125,13 +125,18 @@ drawcircle(Display *disp, int screen, int x, int y, int r, Drawable drawable, in
cairo_surface_destroy(surface); cairo_surface_destroy(surface);
} }
void Drawable
draw_rotate(Display *disp, int screen, Drawable drawable, int dw, int dh, double angle, int tx, int ty) draw_rotate(Display *disp, int screen, Drawable drawable, int dw, int dh, double angle, int tx, int ty)
{ {
cairo_surface_t *surface, *source; cairo_surface_t *surface, *source;
cairo_t *cr; cairo_t *cr;
Drawable newdrawable;
surface = cairo_xlib_surface_create(disp, drawable, DefaultVisual(disp, screen), dw, dw); newdrawable = XCreatePixmap(disp,
RootWindow(disp, screen),
dw, dw,
DefaultDepth(disp, screen));
surface = cairo_xlib_surface_create(disp, newdrawable, DefaultVisual(disp, screen), dw, dw);
source = cairo_xlib_surface_create(disp, drawable, DefaultVisual(disp, screen), dw, dw); source = cairo_xlib_surface_create(disp, drawable, DefaultVisual(disp, screen), dw, dw);
cr = cairo_create (surface); cr = cairo_create (surface);
@ -143,6 +148,8 @@ draw_rotate(Display *disp, int screen, Drawable drawable, int dw, int dh, double
cairo_destroy(cr); cairo_destroy(cr);
cairo_surface_destroy(source); cairo_surface_destroy(source);
return newdrawable;
} }
unsigned short unsigned short

2
draw.h
View File

@ -27,7 +27,7 @@
void drawtext(Display *, int, int, int, int, int, Drawable, int, int, XftFont *, const char *, XColor []); void drawtext(Display *, int, int, int, int, int, Drawable, int, int, XftFont *, const char *, XColor []);
void drawrectangle(Display *, int, int, int, int, int, Drawable, int, int, Bool, XColor); void drawrectangle(Display *, int, int, int, int, int, Drawable, int, int, Bool, XColor);
void drawcircle(Display *, int, int, int, int, Drawable, int, int, Bool, XColor); void drawcircle(Display *, int, int, int, int, Drawable, int, int, Bool, XColor);
void draw_rotate(Display *, int, Drawable, int, int, double, int, int); Drawable draw_rotate(Display *, int, Drawable, int, int, double, int, int);
unsigned short textwidth(Display *, XftFont *, char *); unsigned short textwidth(Display *, XftFont *, char *);
#endif #endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -321,16 +321,10 @@ handle_event_configurenotify(XEvent * e, awesome_config *awesomeconf)
DisplayHeight(e->xany.display, screen) = ev->height; DisplayHeight(e->xany.display, screen) = ev->height;
/* update statusbar */ /* update statusbar */
XFreePixmap(e->xany.display, awesomeconf[screen].statusbar.drawable);
si = get_screen_info(e->xany.display, screen, NULL); si = get_screen_info(e->xany.display, screen, NULL);
awesomeconf[screen].statusbar.width = si[screen].width; awesomeconf[screen].statusbar.width = si[screen].width;
p_delete(&si); p_delete(&si);
awesomeconf[screen].statusbar.drawable = XCreatePixmap(e->xany.display, RootWindow(e->xany.display, screen),
awesomeconf[screen].statusbar.width,
awesomeconf[screen].statusbar.height,
DefaultDepth(e->xany.display, screen));
XResizeWindow(e->xany.display, XResizeWindow(e->xany.display,
awesomeconf[screen].statusbar.window, awesomeconf[screen].statusbar.window,
awesomeconf[screen].statusbar.width, awesomeconf[screen].statusbar.width,

View File

@ -51,6 +51,13 @@ drawstatusbar(awesome_config *awesomeconf)
{ {
int z, i, x = 0, y = 0, w; int z, i, x = 0, y = 0, w;
Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel; Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
Drawable drawable;
drawable = XCreatePixmap(awesomeconf->display,
RootWindow(awesomeconf->display, awesomeconf->phys_screen),
awesomeconf->statusbar.width,
awesomeconf->statusbar.width,
DefaultDepth(awesomeconf->display, awesomeconf->phys_screen));
for(i = 0; i < awesomeconf->ntags; i++) for(i = 0; i < awesomeconf->ntags; i++)
{ {
@ -61,7 +68,7 @@ drawstatusbar(awesome_config *awesomeconf)
drawtext(awesomeconf->display, awesomeconf->phys_screen, drawtext(awesomeconf->display, awesomeconf->phys_screen,
x, y, w, x, y, w,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->statusbar.drawable, drawable,
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->font, awesomeconf->font,
@ -71,7 +78,7 @@ drawstatusbar(awesome_config *awesomeconf)
x, y, x, y,
(awesomeconf->font->height + 2) / 4, (awesomeconf->font->height + 2) / 4,
(awesomeconf->font->height + 2) / 4, (awesomeconf->font->height + 2) / 4,
awesomeconf->statusbar.drawable, drawable,
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
sel && sel->tags[i], sel && sel->tags[i],
@ -82,7 +89,7 @@ drawstatusbar(awesome_config *awesomeconf)
drawtext(awesomeconf->display, awesomeconf->phys_screen, drawtext(awesomeconf->display, awesomeconf->phys_screen,
x, y, w, x, y, w,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->statusbar.drawable, drawable,
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->font, awesomeconf->font,
@ -92,7 +99,7 @@ drawstatusbar(awesome_config *awesomeconf)
x, y, x, y,
(awesomeconf->font->height + 2) / 4, (awesomeconf->font->height + 2) / 4,
(awesomeconf->font->height + 2) / 4, (awesomeconf->font->height + 2) / 4,
awesomeconf->statusbar.drawable, drawable,
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
sel && sel->tags[i], sel && sel->tags[i],
@ -103,7 +110,7 @@ drawstatusbar(awesome_config *awesomeconf)
drawtext(awesomeconf->display, awesomeconf->phys_screen, drawtext(awesomeconf->display, awesomeconf->phys_screen,
x, y, awesomeconf->statusbar.txtlayoutwidth, x, y, awesomeconf->statusbar.txtlayoutwidth,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->statusbar.drawable, drawable,
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->font, awesomeconf->font,
@ -120,7 +127,7 @@ drawstatusbar(awesome_config *awesomeconf)
drawtext(awesomeconf->display, awesomeconf->phys_screen, drawtext(awesomeconf->display, awesomeconf->phys_screen,
x, y, w, x, y, w,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->statusbar.drawable, drawable,
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->font, awesomeconf->font,
@ -133,7 +140,7 @@ drawstatusbar(awesome_config *awesomeconf)
drawtext(awesomeconf->display, awesomeconf->phys_screen, drawtext(awesomeconf->display, awesomeconf->phys_screen,
x, y, w, x, y, w,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->statusbar.drawable, drawable,
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->font, awesomeconf->font,
@ -142,7 +149,7 @@ drawstatusbar(awesome_config *awesomeconf)
drawcircle(awesomeconf->display, awesomeconf->phys_screen, drawcircle(awesomeconf->display, awesomeconf->phys_screen,
x, y, x, y,
(awesomeconf->font->height + 2) / 4, (awesomeconf->font->height + 2) / 4,
awesomeconf->statusbar.drawable, drawable,
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
sel->ismax, sel->ismax,
@ -152,7 +159,7 @@ drawstatusbar(awesome_config *awesomeconf)
drawtext(awesomeconf->display, awesomeconf->phys_screen, drawtext(awesomeconf->display, awesomeconf->phys_screen,
x, y, w, x, y, w,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->statusbar.drawable, drawable,
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->font, awesomeconf->font,
@ -161,26 +168,29 @@ drawstatusbar(awesome_config *awesomeconf)
if(awesomeconf->statusbar.position == BarRight if(awesomeconf->statusbar.position == BarRight
|| awesomeconf->statusbar.position == BarLeft) || awesomeconf->statusbar.position == BarLeft)
{ {
Drawable d;
if(awesomeconf->statusbar.position == BarRight) if(awesomeconf->statusbar.position == BarRight)
draw_rotate(awesomeconf->display, awesomeconf->phys_screen, d = draw_rotate(awesomeconf->display, awesomeconf->phys_screen,
awesomeconf->statusbar.drawable, awesomeconf->statusbar.width, drawable, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, M_PI_2, awesomeconf->statusbar.height, M_PI_2,
awesomeconf->statusbar.height, 0); awesomeconf->statusbar.height, 0);
else else
draw_rotate(awesomeconf->display, awesomeconf->phys_screen, d = draw_rotate(awesomeconf->display, awesomeconf->phys_screen,
awesomeconf->statusbar.drawable, awesomeconf->statusbar.width, drawable, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, - M_PI_2, awesomeconf->statusbar.height, - M_PI_2,
0, -awesomeconf->statusbar.height); 0, -awesomeconf->statusbar.height);
XCopyArea(awesomeconf->display, awesomeconf->statusbar.drawable, XCopyArea(awesomeconf->display, d,
awesomeconf->statusbar.window, awesomeconf->statusbar.window,
DefaultGC(awesomeconf->display, awesomeconf->phys_screen), 0, 0, DefaultGC(awesomeconf->display, awesomeconf->phys_screen), 0, 0,
awesomeconf->statusbar.height, awesomeconf->statusbar.width, 0, 0); awesomeconf->statusbar.height, awesomeconf->statusbar.width, 0, 0);
XFreePixmap(awesomeconf->display, d);
} }
else else
XCopyArea(awesomeconf->display, awesomeconf->statusbar.drawable, XCopyArea(awesomeconf->display, drawable,
awesomeconf->statusbar.window, awesomeconf->statusbar.window,
DefaultGC(awesomeconf->display, awesomeconf->phys_screen), 0, 0, DefaultGC(awesomeconf->display, awesomeconf->phys_screen), 0, 0,
awesomeconf->statusbar.width, awesomeconf->statusbar.height, 0, 0); awesomeconf->statusbar.width, awesomeconf->statusbar.height, 0, 0);
XFreePixmap(awesomeconf->display, drawable);
XSync(awesomeconf->display, False); XSync(awesomeconf->display, False);
} }
@ -209,33 +219,19 @@ initstatusbar(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, Xf
wa.background_pixmap = ParentRelative; wa.background_pixmap = ParentRelative;
wa.event_mask = ButtonPressMask | ExposureMask; wa.event_mask = ButtonPressMask | ExposureMask;
if(statusbar->dposition == BarRight || statusbar->dposition == BarLeft) if(statusbar->dposition == BarRight || statusbar->dposition == BarLeft)
{
statusbar->window = XCreateWindow(disp, RootWindow(disp, phys_screen), 0, 0, statusbar->window = XCreateWindow(disp, RootWindow(disp, phys_screen), 0, 0,
statusbar->height, statusbar->height,
statusbar->width, statusbar->width,
0, DefaultDepth(disp, phys_screen), CopyFromParent, 0, DefaultDepth(disp, phys_screen), CopyFromParent,
DefaultVisual(disp, phys_screen), DefaultVisual(disp, phys_screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
statusbar->drawable = XCreatePixmap(disp,
RootWindow(disp, phys_screen),
statusbar->width,
statusbar->width,
DefaultDepth(disp, phys_screen));
}
else else
{
statusbar->window = XCreateWindow(disp, RootWindow(disp, phys_screen), 0, 0, statusbar->window = XCreateWindow(disp, RootWindow(disp, phys_screen), 0, 0,
statusbar->width, statusbar->width,
statusbar->height, statusbar->height,
0, DefaultDepth(disp, phys_screen), CopyFromParent, 0, DefaultDepth(disp, phys_screen), CopyFromParent,
DefaultVisual(disp, phys_screen), DefaultVisual(disp, phys_screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
statusbar->drawable = XCreatePixmap(disp,
RootWindow(disp, phys_screen),
statusbar->width,
statusbar->height,
DefaultDepth(disp, phys_screen));
}
XDefineCursor(disp, statusbar->window, cursor); XDefineCursor(disp, statusbar->window, cursor);
updatebarpos(disp, *statusbar); updatebarpos(disp, *statusbar);
XMapRaised(disp, statusbar->window); XMapRaised(disp, statusbar->window);