statusbar drawable is no more stored but dynamicaly created; this fix a problem with statusbar on right
This commit is contained in:
parent
db65104aa2
commit
0753ed5fb5
|
@ -58,7 +58,6 @@ cleanup_screen(awesome_config *awesomeconf)
|
|||
|
||||
XftFontClose(awesomeconf->display, awesomeconf->font);
|
||||
XUngrabKey(awesomeconf->display, AnyKey, AnyModifier, RootWindow(awesomeconf->display, awesomeconf->phys_screen));
|
||||
XFreePixmap(awesomeconf->display, awesomeconf->statusbar.drawable);
|
||||
XDestroyWindow(awesomeconf->display, awesomeconf->statusbar.window);
|
||||
XFreeCursor(awesomeconf->display, awesomeconf->cursor[CurNormal]);
|
||||
XFreeCursor(awesomeconf->display, awesomeconf->cursor[CurResize]);
|
||||
|
|
2
config.h
2
config.h
|
@ -85,8 +85,6 @@ typedef struct
|
|||
int position;
|
||||
/** Window */
|
||||
Window window;
|
||||
/** Drawable object */
|
||||
Drawable drawable;
|
||||
/** Screen */
|
||||
int screen;
|
||||
} Statusbar;
|
||||
|
|
13
draw.c
13
draw.c
|
@ -125,13 +125,18 @@ drawcircle(Display *disp, int screen, int x, int y, int r, Drawable drawable, in
|
|||
cairo_surface_destroy(surface);
|
||||
}
|
||||
|
||||
void
|
||||
Drawable
|
||||
draw_rotate(Display *disp, int screen, Drawable drawable, int dw, int dh, double angle, int tx, int ty)
|
||||
{
|
||||
cairo_surface_t *surface, *source;
|
||||
cairo_t *cr;
|
||||
|
||||
surface = cairo_xlib_surface_create(disp, drawable, DefaultVisual(disp, screen), dw, dw);
|
||||
Drawable newdrawable;
|
||||
|
||||
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);
|
||||
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_surface_destroy(source);
|
||||
|
||||
return newdrawable;
|
||||
}
|
||||
|
||||
unsigned short
|
||||
|
|
2
draw.h
2
draw.h
|
@ -27,7 +27,7 @@
|
|||
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 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 *);
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99
|
||||
|
|
6
event.c
6
event.c
|
@ -321,16 +321,10 @@ handle_event_configurenotify(XEvent * e, awesome_config *awesomeconf)
|
|||
DisplayHeight(e->xany.display, screen) = ev->height;
|
||||
|
||||
/* update statusbar */
|
||||
XFreePixmap(e->xany.display, awesomeconf[screen].statusbar.drawable);
|
||||
|
||||
si = get_screen_info(e->xany.display, screen, NULL);
|
||||
awesomeconf[screen].statusbar.width = si[screen].width;
|
||||
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,
|
||||
awesomeconf[screen].statusbar.window,
|
||||
awesomeconf[screen].statusbar.width,
|
||||
|
|
62
statusbar.c
62
statusbar.c
|
@ -51,6 +51,13 @@ drawstatusbar(awesome_config *awesomeconf)
|
|||
{
|
||||
int z, i, x = 0, y = 0, w;
|
||||
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++)
|
||||
{
|
||||
|
@ -61,7 +68,7 @@ drawstatusbar(awesome_config *awesomeconf)
|
|||
drawtext(awesomeconf->display, awesomeconf->phys_screen,
|
||||
x, y, w,
|
||||
awesomeconf->statusbar.height,
|
||||
awesomeconf->statusbar.drawable,
|
||||
drawable,
|
||||
awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height,
|
||||
awesomeconf->font,
|
||||
|
@ -71,7 +78,7 @@ drawstatusbar(awesome_config *awesomeconf)
|
|||
x, y,
|
||||
(awesomeconf->font->height + 2) / 4,
|
||||
(awesomeconf->font->height + 2) / 4,
|
||||
awesomeconf->statusbar.drawable,
|
||||
drawable,
|
||||
awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height,
|
||||
sel && sel->tags[i],
|
||||
|
@ -82,7 +89,7 @@ drawstatusbar(awesome_config *awesomeconf)
|
|||
drawtext(awesomeconf->display, awesomeconf->phys_screen,
|
||||
x, y, w,
|
||||
awesomeconf->statusbar.height,
|
||||
awesomeconf->statusbar.drawable,
|
||||
drawable,
|
||||
awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height,
|
||||
awesomeconf->font,
|
||||
|
@ -92,7 +99,7 @@ drawstatusbar(awesome_config *awesomeconf)
|
|||
x, y,
|
||||
(awesomeconf->font->height + 2) / 4,
|
||||
(awesomeconf->font->height + 2) / 4,
|
||||
awesomeconf->statusbar.drawable,
|
||||
drawable,
|
||||
awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height,
|
||||
sel && sel->tags[i],
|
||||
|
@ -103,7 +110,7 @@ drawstatusbar(awesome_config *awesomeconf)
|
|||
drawtext(awesomeconf->display, awesomeconf->phys_screen,
|
||||
x, y, awesomeconf->statusbar.txtlayoutwidth,
|
||||
awesomeconf->statusbar.height,
|
||||
awesomeconf->statusbar.drawable,
|
||||
drawable,
|
||||
awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height,
|
||||
awesomeconf->font,
|
||||
|
@ -120,7 +127,7 @@ drawstatusbar(awesome_config *awesomeconf)
|
|||
drawtext(awesomeconf->display, awesomeconf->phys_screen,
|
||||
x, y, w,
|
||||
awesomeconf->statusbar.height,
|
||||
awesomeconf->statusbar.drawable,
|
||||
drawable,
|
||||
awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height,
|
||||
awesomeconf->font,
|
||||
|
@ -133,7 +140,7 @@ drawstatusbar(awesome_config *awesomeconf)
|
|||
drawtext(awesomeconf->display, awesomeconf->phys_screen,
|
||||
x, y, w,
|
||||
awesomeconf->statusbar.height,
|
||||
awesomeconf->statusbar.drawable,
|
||||
drawable,
|
||||
awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height,
|
||||
awesomeconf->font,
|
||||
|
@ -142,7 +149,7 @@ drawstatusbar(awesome_config *awesomeconf)
|
|||
drawcircle(awesomeconf->display, awesomeconf->phys_screen,
|
||||
x, y,
|
||||
(awesomeconf->font->height + 2) / 4,
|
||||
awesomeconf->statusbar.drawable,
|
||||
drawable,
|
||||
awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height,
|
||||
sel->ismax,
|
||||
|
@ -152,7 +159,7 @@ drawstatusbar(awesome_config *awesomeconf)
|
|||
drawtext(awesomeconf->display, awesomeconf->phys_screen,
|
||||
x, y, w,
|
||||
awesomeconf->statusbar.height,
|
||||
awesomeconf->statusbar.drawable,
|
||||
drawable,
|
||||
awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height,
|
||||
awesomeconf->font,
|
||||
|
@ -161,26 +168,29 @@ drawstatusbar(awesome_config *awesomeconf)
|
|||
if(awesomeconf->statusbar.position == BarRight
|
||||
|| awesomeconf->statusbar.position == BarLeft)
|
||||
{
|
||||
Drawable d;
|
||||
if(awesomeconf->statusbar.position == BarRight)
|
||||
draw_rotate(awesomeconf->display, awesomeconf->phys_screen,
|
||||
awesomeconf->statusbar.drawable, awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height, M_PI_2,
|
||||
awesomeconf->statusbar.height, 0);
|
||||
d = draw_rotate(awesomeconf->display, awesomeconf->phys_screen,
|
||||
drawable, awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height, M_PI_2,
|
||||
awesomeconf->statusbar.height, 0);
|
||||
else
|
||||
draw_rotate(awesomeconf->display, awesomeconf->phys_screen,
|
||||
awesomeconf->statusbar.drawable, awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height, - M_PI_2,
|
||||
0, -awesomeconf->statusbar.height);
|
||||
XCopyArea(awesomeconf->display, awesomeconf->statusbar.drawable,
|
||||
d = draw_rotate(awesomeconf->display, awesomeconf->phys_screen,
|
||||
drawable, awesomeconf->statusbar.width,
|
||||
awesomeconf->statusbar.height, - M_PI_2,
|
||||
0, -awesomeconf->statusbar.height);
|
||||
XCopyArea(awesomeconf->display, d,
|
||||
awesomeconf->statusbar.window,
|
||||
DefaultGC(awesomeconf->display, awesomeconf->phys_screen), 0, 0,
|
||||
awesomeconf->statusbar.height, awesomeconf->statusbar.width, 0, 0);
|
||||
XFreePixmap(awesomeconf->display, d);
|
||||
}
|
||||
else
|
||||
XCopyArea(awesomeconf->display, awesomeconf->statusbar.drawable,
|
||||
XCopyArea(awesomeconf->display, drawable,
|
||||
awesomeconf->statusbar.window,
|
||||
DefaultGC(awesomeconf->display, awesomeconf->phys_screen), 0, 0,
|
||||
awesomeconf->statusbar.width, awesomeconf->statusbar.height, 0, 0);
|
||||
XFreePixmap(awesomeconf->display, drawable);
|
||||
XSync(awesomeconf->display, False);
|
||||
}
|
||||
|
||||
|
@ -209,33 +219,19 @@ initstatusbar(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, Xf
|
|||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||
if(statusbar->dposition == BarRight || statusbar->dposition == BarLeft)
|
||||
{
|
||||
statusbar->window = XCreateWindow(disp, RootWindow(disp, phys_screen), 0, 0,
|
||||
statusbar->height,
|
||||
statusbar->width,
|
||||
0, DefaultDepth(disp, phys_screen), CopyFromParent,
|
||||
DefaultVisual(disp, phys_screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
statusbar->drawable = XCreatePixmap(disp,
|
||||
RootWindow(disp, phys_screen),
|
||||
statusbar->width,
|
||||
statusbar->width,
|
||||
DefaultDepth(disp, phys_screen));
|
||||
}
|
||||
else
|
||||
{
|
||||
statusbar->window = XCreateWindow(disp, RootWindow(disp, phys_screen), 0, 0,
|
||||
statusbar->width,
|
||||
statusbar->height,
|
||||
0, DefaultDepth(disp, phys_screen), CopyFromParent,
|
||||
DefaultVisual(disp, phys_screen),
|
||||
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);
|
||||
updatebarpos(disp, *statusbar);
|
||||
XMapRaised(disp, statusbar->window);
|
||||
|
|
Loading…
Reference in New Issue