experimental support for status bar to be on right or left

This commit is contained in:
Julien Danjou 2007-11-11 18:59:11 +01:00
parent 4e14888e73
commit 05dad60786
6 changed files with 92 additions and 23 deletions

View File

@ -370,6 +370,10 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
awesomeconf->statusbar.dposition = BarOff;
else if(tmp && !a_strncmp(tmp, "bottom", 6))
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
awesomeconf->statusbar.dposition = BarTop;

View File

@ -28,7 +28,7 @@
/** Bar possible position */
enum
{ BarTop, BarBot, BarOff };
{ BarTop, BarBot, BarLeft, BarRight, BarOff };
enum
{ ColBorder, ColFG, ColBG, ColLast }; /* color */

19
draw.c
View File

@ -125,6 +125,25 @@ drawcircle(Display *disp, int screen, int x, int y, int r, Drawable drawable, in
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
textwidth(Display *disp, XftFont *font, char *text)
{

1
draw.h
View File

@ -27,6 +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);
unsigned short textwidth(Display *, XftFont *, char *);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -52,13 +52,19 @@ get_screen_info(Display *disp, int screen, Statusbar *statusbar)
if(statusbar)
for(i = 0; i < screen_number; i++)
{
if(statusbar->position == BarTop
|| statusbar->position == BarBot)
si[i].height -= statusbar->height;
if(statusbar->position == BarTop)
switch(statusbar->position)
{
case BarTop:
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;
}

View File

@ -20,6 +20,7 @@
*/
#include <stdio.h>
#include <math.h>
#include "layout.h"
#include "statusbar.h"
@ -46,7 +47,7 @@ isoccupied(Client **head, unsigned int t, int screen)
}
void
drawstatusbar(awesome_config * awesomeconf)
drawstatusbar(awesome_config *awesomeconf)
{
int z, i, x = 0, y = 0, w;
Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
@ -157,9 +158,22 @@ drawstatusbar(awesome_config * awesomeconf)
awesomeconf->font,
NULL, awesomeconf->colors_normal);
}
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);
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,
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);
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);
ScreenInfo *si = get_screen_info(disp, screen, NULL);
statusbar->width = si[screen].width;
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);
statusbar->screen = screen;
@ -182,20 +201,37 @@ initstatusbar(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, Xf
wa.override_redirect = 1;
wa.background_pixmap = ParentRelative;
wa.event_mask = ButtonPressMask | ExposureMask;
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);
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);
statusbar->drawable = XCreatePixmap(disp,
RootWindow(disp, phys_screen),
statusbar->width,
statusbar->height,
DefaultDepth(disp, phys_screen));
for(i = 0; i < nlayouts; i++)
statusbar->txtlayoutwidth = MAX(statusbar->txtlayoutwidth,
@ -213,6 +249,9 @@ updatebarpos(Display *disp, Statusbar statusbar)
default:
XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].y_org);
break;
case BarRight:
XMoveWindow(disp, statusbar.window, si[statusbar.screen].width - statusbar.width, si[statusbar.screen].y_org);
break;
case BarBot:
XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].height - statusbar.height);
break;