experimental support for status bar to be on right or left
This commit is contained in:
parent
4e14888e73
commit
05dad60786
4
config.c
4
config.c
|
@ -370,6 +370,10 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
||||||
awesomeconf->statusbar.dposition = BarOff;
|
awesomeconf->statusbar.dposition = BarOff;
|
||||||
else if(tmp && !a_strncmp(tmp, "bottom", 6))
|
else if(tmp && !a_strncmp(tmp, "bottom", 6))
|
||||||
awesomeconf->statusbar.dposition = BarBot;
|
awesomeconf->statusbar.dposition = BarBot;
|
||||||
|
else if(tmp && !a_strncmp(tmp, "right", 5))
|
||||||
|
awesomeconf->statusbar.dposition = BarRight;
|
||||||
|
else if(tmp && !a_strncmp(tmp, "left", 4))
|
||||||
|
awesomeconf->statusbar.dposition = BarLeft;
|
||||||
else
|
else
|
||||||
awesomeconf->statusbar.dposition = BarTop;
|
awesomeconf->statusbar.dposition = BarTop;
|
||||||
|
|
||||||
|
|
2
config.h
2
config.h
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
/** Bar possible position */
|
/** Bar possible position */
|
||||||
enum
|
enum
|
||||||
{ BarTop, BarBot, BarOff };
|
{ BarTop, BarBot, BarLeft, BarRight, BarOff };
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{ ColBorder, ColFG, ColBG, ColLast }; /* color */
|
{ ColBorder, ColFG, ColBG, ColLast }; /* color */
|
||||||
|
|
19
draw.c
19
draw.c
|
@ -125,6 +125,25 @@ drawcircle(Display *disp, int screen, int x, int y, int r, Drawable drawable, in
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
draw_rotate(Display *disp, int screen, Drawable drawable, int dw, int dh, double angle)
|
||||||
|
{
|
||||||
|
cairo_surface_t *surface, *source;
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
|
surface = 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);
|
||||||
|
cairo_rotate(cr, M_PI / 2);
|
||||||
|
cairo_translate(cr, 0.0, -dh);
|
||||||
|
|
||||||
|
cairo_set_source_surface(cr, source, 0.0, 0.0);
|
||||||
|
cairo_paint_with_alpha(cr, 1.0);
|
||||||
|
|
||||||
|
cairo_destroy(cr);
|
||||||
|
cairo_surface_destroy(source);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned short
|
unsigned short
|
||||||
textwidth(Display *disp, XftFont *font, char *text)
|
textwidth(Display *disp, XftFont *font, char *text)
|
||||||
{
|
{
|
||||||
|
|
1
draw.h
1
draw.h
|
@ -27,6 +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);
|
||||||
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
|
||||||
|
|
14
screen.c
14
screen.c
|
@ -52,12 +52,18 @@ get_screen_info(Display *disp, int screen, Statusbar *statusbar)
|
||||||
|
|
||||||
if(statusbar)
|
if(statusbar)
|
||||||
for(i = 0; i < screen_number; i++)
|
for(i = 0; i < screen_number; i++)
|
||||||
|
switch(statusbar->position)
|
||||||
{
|
{
|
||||||
if(statusbar->position == BarTop
|
case BarTop:
|
||||||
|| statusbar->position == BarBot)
|
|
||||||
si[i].height -= statusbar->height;
|
|
||||||
if(statusbar->position == BarTop)
|
|
||||||
si[i].y_org += statusbar->height;
|
si[i].y_org += statusbar->height;
|
||||||
|
case BarBot:
|
||||||
|
si[i].height -= statusbar->height;
|
||||||
|
break;
|
||||||
|
case BarLeft:
|
||||||
|
si[i].x_org += statusbar->height;
|
||||||
|
case BarRight:
|
||||||
|
si[i].width -= statusbar->height;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return si;
|
return si;
|
||||||
|
|
51
statusbar.c
51
statusbar.c
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
|
@ -46,7 +47,7 @@ isoccupied(Client **head, unsigned int t, int screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawstatusbar(awesome_config * awesomeconf)
|
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;
|
||||||
|
@ -157,8 +158,21 @@ drawstatusbar(awesome_config * awesomeconf)
|
||||||
awesomeconf->font,
|
awesomeconf->font,
|
||||||
NULL, awesomeconf->colors_normal);
|
NULL, awesomeconf->colors_normal);
|
||||||
}
|
}
|
||||||
|
if(awesomeconf->statusbar.position == BarRight
|
||||||
|
|| awesomeconf->statusbar.position == BarLeft)
|
||||||
|
{
|
||||||
|
draw_rotate(awesomeconf->display, awesomeconf->phys_screen,
|
||||||
|
awesomeconf->statusbar.drawable, awesomeconf->statusbar.width,
|
||||||
|
awesomeconf->statusbar.height, M_PI * 1.5);
|
||||||
XCopyArea(awesomeconf->display, awesomeconf->statusbar.drawable,
|
XCopyArea(awesomeconf->display, awesomeconf->statusbar.drawable,
|
||||||
awesomeconf->statusbar.window, DefaultGC(awesomeconf->display, awesomeconf->phys_screen), 0, 0,
|
awesomeconf->statusbar.window,
|
||||||
|
DefaultGC(awesomeconf->display, awesomeconf->phys_screen), 0, 0,
|
||||||
|
awesomeconf->statusbar.height, awesomeconf->statusbar.width, 0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
XCopyArea(awesomeconf->display, awesomeconf->statusbar.drawable,
|
||||||
|
awesomeconf->statusbar.window,
|
||||||
|
DefaultGC(awesomeconf->display, awesomeconf->phys_screen), 0, 0,
|
||||||
awesomeconf->statusbar.width, awesomeconf->statusbar.height, 0, 0);
|
awesomeconf->statusbar.width, awesomeconf->statusbar.height, 0, 0);
|
||||||
XSync(awesomeconf->display, False);
|
XSync(awesomeconf->display, False);
|
||||||
}
|
}
|
||||||
|
@ -170,8 +184,13 @@ initstatusbar(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, Xf
|
||||||
int i, phys_screen = get_phys_screen(disp, screen);
|
int i, phys_screen = get_phys_screen(disp, screen);
|
||||||
ScreenInfo *si = get_screen_info(disp, screen, NULL);
|
ScreenInfo *si = get_screen_info(disp, screen, NULL);
|
||||||
|
|
||||||
statusbar->width = si[screen].width;
|
|
||||||
statusbar->height = font->height * 1.5;
|
statusbar->height = font->height * 1.5;
|
||||||
|
|
||||||
|
if(statusbar->position == BarRight || statusbar->position == BarLeft)
|
||||||
|
statusbar->width = si[screen].height;
|
||||||
|
else
|
||||||
|
statusbar->width = si[screen].width;
|
||||||
|
|
||||||
p_delete(&si);
|
p_delete(&si);
|
||||||
|
|
||||||
statusbar->screen = screen;
|
statusbar->screen = screen;
|
||||||
|
@ -182,20 +201,37 @@ initstatusbar(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, Xf
|
||||||
wa.override_redirect = 1;
|
wa.override_redirect = 1;
|
||||||
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)
|
||||||
|
{
|
||||||
|
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->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);
|
||||||
XDefineCursor(disp, statusbar->window, cursor);
|
|
||||||
updatebarpos(disp, *statusbar);
|
|
||||||
XMapRaised(disp, statusbar->window);
|
|
||||||
statusbar->drawable = XCreatePixmap(disp,
|
statusbar->drawable = XCreatePixmap(disp,
|
||||||
RootWindow(disp, phys_screen),
|
RootWindow(disp, phys_screen),
|
||||||
statusbar->width,
|
statusbar->width,
|
||||||
statusbar->height,
|
statusbar->height,
|
||||||
DefaultDepth(disp, phys_screen));
|
DefaultDepth(disp, phys_screen));
|
||||||
|
}
|
||||||
|
XDefineCursor(disp, statusbar->window, cursor);
|
||||||
|
updatebarpos(disp, *statusbar);
|
||||||
|
XMapRaised(disp, statusbar->window);
|
||||||
|
|
||||||
for(i = 0; i < nlayouts; i++)
|
for(i = 0; i < nlayouts; i++)
|
||||||
statusbar->txtlayoutwidth = MAX(statusbar->txtlayoutwidth,
|
statusbar->txtlayoutwidth = MAX(statusbar->txtlayoutwidth,
|
||||||
|
@ -213,6 +249,9 @@ updatebarpos(Display *disp, Statusbar statusbar)
|
||||||
default:
|
default:
|
||||||
XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].y_org);
|
XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].y_org);
|
||||||
break;
|
break;
|
||||||
|
case BarRight:
|
||||||
|
XMoveWindow(disp, statusbar.window, si[statusbar.screen].width - statusbar.width, si[statusbar.screen].y_org);
|
||||||
|
break;
|
||||||
case BarBot:
|
case BarBot:
|
||||||
XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].height - statusbar.height);
|
XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].height - statusbar.height);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue