typedef enum Position
This commit is contained in:
parent
343c6c7df0
commit
af6ff367eb
14
config.h
14
config.h
|
@ -27,8 +27,14 @@
|
|||
#include "layout.h"
|
||||
|
||||
/** Bar possible position */
|
||||
enum
|
||||
{ BarTop, BarBot, BarLeft, BarRight, BarOff };
|
||||
typedef enum
|
||||
{
|
||||
Top,
|
||||
Bottom,
|
||||
Left,
|
||||
Right,
|
||||
Off
|
||||
} Position;
|
||||
|
||||
/** Common colors */
|
||||
enum
|
||||
|
@ -124,9 +130,9 @@ struct Statusbar
|
|||
/** Layout txt width */
|
||||
int txtlayoutwidth;
|
||||
/** Default position */
|
||||
int dposition;
|
||||
Position dposition;
|
||||
/** Bar position */
|
||||
int position;
|
||||
Position position;
|
||||
/** Window */
|
||||
Window window;
|
||||
/** Screen */
|
||||
|
|
6
event.c
6
event.c
|
@ -72,8 +72,8 @@ handle_event_buttonpress(XEvent *e)
|
|||
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
||||
if(statusbar->window == ev->window)
|
||||
{
|
||||
if(statusbar->position == BarTop
|
||||
|| globalconf.screens[screen].statusbar->position == BarBot)
|
||||
if(statusbar->position == Top
|
||||
|| globalconf.screens[screen].statusbar->position == Bottom)
|
||||
{
|
||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||
if(ev->x >= widget->location && ev->x <= widget->location + widget->width)
|
||||
|
@ -82,7 +82,7 @@ handle_event_buttonpress(XEvent *e)
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if(statusbar->position == BarRight)
|
||||
else if(statusbar->position == Right)
|
||||
{
|
||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||
if(ev->y >= widget->location && ev->y <= widget->location + widget->width)
|
||||
|
|
14
screen.c
14
screen.c
|
@ -76,16 +76,18 @@ get_screen_area(int screen, Statusbar *statusbar, Padding *padding)
|
|||
for(sb = statusbar; sb; sb = sb->next)
|
||||
switch(sb->position)
|
||||
{
|
||||
case BarTop:
|
||||
case Top:
|
||||
area.y += sb->height;
|
||||
case BarBot:
|
||||
case Bottom:
|
||||
area.height -= sb->height;
|
||||
break;
|
||||
case BarLeft:
|
||||
case Left:
|
||||
area.x += sb->height;
|
||||
case BarRight:
|
||||
case Right:
|
||||
area.width -= sb->height;
|
||||
break;
|
||||
case Off:
|
||||
break;
|
||||
}
|
||||
|
||||
return area;
|
||||
|
@ -110,8 +112,8 @@ get_display_area(int screen, Statusbar *statusbar, Padding *padding)
|
|||
|
||||
for(sb = statusbar; sb; sb = sb->next)
|
||||
{
|
||||
area.y += sb->position == BarTop ? sb->height : 0;
|
||||
area.height -= (sb->position == BarTop || sb->position == BarBot) ? sb->height : 0;
|
||||
area.y += sb->position == Top ? sb->height : 0;
|
||||
area.height -= (sb->position == Top || sb->position == Bottom) ? sb->height : 0;
|
||||
}
|
||||
|
||||
/* make padding corrections */
|
||||
|
|
44
statusbar.c
44
statusbar.c
|
@ -38,7 +38,7 @@ statusbar_draw(Statusbar *statusbar)
|
|||
int left = 0, right = 0;
|
||||
|
||||
/* don't waste our time */
|
||||
if(statusbar->position == BarOff)
|
||||
if(statusbar->position == Off)
|
||||
return;
|
||||
|
||||
XFreePixmap(globalconf.display, statusbar->drawable);
|
||||
|
@ -67,11 +67,11 @@ statusbar_draw(Statusbar *statusbar)
|
|||
if (widget->alignment == AlignFlex)
|
||||
left += widget->draw(widget, ctx, left, (left + right));
|
||||
|
||||
if(statusbar->position == BarRight
|
||||
|| statusbar->position == BarLeft)
|
||||
if(statusbar->position == Right
|
||||
|| statusbar->position == Left)
|
||||
{
|
||||
Drawable d;
|
||||
if(statusbar->position == BarRight)
|
||||
if(statusbar->position == Right)
|
||||
d = draw_rotate(ctx, phys_screen, M_PI_2, statusbar->height, 0);
|
||||
else
|
||||
d = draw_rotate(ctx, phys_screen, - M_PI_2, 0, statusbar->width);
|
||||
|
@ -104,11 +104,11 @@ statusbar_display(Statusbar *statusbar)
|
|||
int phys_screen = get_phys_screen(statusbar->screen);
|
||||
|
||||
/* don't waste our time */
|
||||
if(statusbar->position == BarOff)
|
||||
if(statusbar->position == Off)
|
||||
return;
|
||||
|
||||
if(statusbar->position == BarRight
|
||||
|| statusbar->position == BarLeft)
|
||||
if(statusbar->position == Right
|
||||
|| statusbar->position == Left)
|
||||
XCopyArea(globalconf.display, statusbar->drawable,
|
||||
statusbar->window,
|
||||
DefaultGC(globalconf.display, phys_screen), 0, 0,
|
||||
|
@ -143,7 +143,7 @@ statusbar_init(Statusbar *statusbar, int screen)
|
|||
|
||||
if(statusbar->width <= 0)
|
||||
{
|
||||
if(statusbar->position == BarRight || statusbar->position == BarLeft)
|
||||
if(statusbar->position == Right || statusbar->position == Left)
|
||||
statusbar->width = area.height;
|
||||
else
|
||||
statusbar->width = area.width;
|
||||
|
@ -157,7 +157,7 @@ statusbar_init(Statusbar *statusbar, int screen)
|
|||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||
if(statusbar->dposition == BarRight || statusbar->dposition == BarLeft)
|
||||
if(statusbar->dposition == Right || statusbar->dposition == Left)
|
||||
statusbar->window = XCreateWindow(globalconf.display,
|
||||
RootWindow(globalconf.display,
|
||||
phys_screen),
|
||||
|
@ -225,19 +225,19 @@ statusbar_update_position(Statusbar *statusbar)
|
|||
XMoveWindow(globalconf.display, statusbar->window,
|
||||
area.x, area.y);
|
||||
break;
|
||||
case BarLeft:
|
||||
case Left:
|
||||
XMoveWindow(globalconf.display, statusbar->window,
|
||||
area.x, (area.y + area.height) - statusbar->width);
|
||||
break;
|
||||
case BarRight:
|
||||
case Right:
|
||||
XMoveWindow(globalconf.display, statusbar->window,
|
||||
area.x + (area.width - statusbar->height), area.y);
|
||||
break;
|
||||
case BarBot:
|
||||
case Bottom:
|
||||
XMoveWindow(globalconf.display, statusbar->window,
|
||||
area.x, area.height - statusbar->height);
|
||||
break;
|
||||
case BarOff:
|
||||
case Off:
|
||||
XUnmapWindow(globalconf.display, statusbar->window);
|
||||
break;
|
||||
}
|
||||
|
@ -245,18 +245,18 @@ statusbar_update_position(Statusbar *statusbar)
|
|||
while(XCheckMaskEvent(globalconf.display, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
int
|
||||
Position
|
||||
statusbar_get_position_from_str(const char *pos)
|
||||
{
|
||||
if(!a_strncmp(pos, "off", 3))
|
||||
return BarOff;
|
||||
return Off;
|
||||
else if(!a_strncmp(pos, "bottom", 6))
|
||||
return BarBot;
|
||||
return Bottom;
|
||||
else if(!a_strncmp(pos, "right", 5))
|
||||
return BarRight;
|
||||
return Right;
|
||||
else if(!a_strncmp(pos, "left", 4))
|
||||
return BarLeft;
|
||||
return BarTop;
|
||||
return Left;
|
||||
return Top;
|
||||
}
|
||||
|
||||
static Statusbar *
|
||||
|
@ -275,10 +275,10 @@ get_statusbar_byname(int screen, const char *name)
|
|||
static void
|
||||
statusbar_toggle(Statusbar *statusbar)
|
||||
{
|
||||
if(statusbar->position == BarOff)
|
||||
statusbar->position = (statusbar->dposition == BarOff) ? BarTop : statusbar->dposition;
|
||||
if(statusbar->position == Off)
|
||||
statusbar->position = (statusbar->dposition == Off) ? Top : statusbar->dposition;
|
||||
else
|
||||
statusbar->position = BarOff;
|
||||
statusbar->position = Off;
|
||||
|
||||
statusbar_update_position(statusbar);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
void statusbar_draw_all(int);
|
||||
void statusbar_init(Statusbar *, int);
|
||||
void statusbar_display(Statusbar *);
|
||||
int statusbar_get_position_from_str(const char *);
|
||||
Position statusbar_get_position_from_str(const char *);
|
||||
void statusbar_update_position(Statusbar *);
|
||||
|
||||
Uicb uicb_statusbar_toggle;
|
||||
|
|
|
@ -119,9 +119,10 @@ taglist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
|||
|
||||
for(b = widget->buttons; b; b = b->next)
|
||||
if(ev->button == b->button && CLEANMASK(ev->state) == b->mod && b->func)
|
||||
switch(widget->statusbar->position)
|
||||
{
|
||||
if(widget->statusbar->position == BarTop
|
||||
|| widget->statusbar->position == BarBot)
|
||||
case Top:
|
||||
case Bottom:
|
||||
for(tag = vscreen.tags; tag; tag = tag->next, i++)
|
||||
{
|
||||
width = textwidth(vscreen.font, tag->name) + vscreen.font->height;
|
||||
|
@ -134,7 +135,8 @@ taglist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
|||
}
|
||||
prev_width += width;
|
||||
}
|
||||
else if(widget->statusbar->position == BarRight)
|
||||
break;
|
||||
case Right:
|
||||
for(tag = vscreen.tags; tag; tag = tag->next, i++)
|
||||
{
|
||||
width = textwidth(vscreen.font, tag->name) + vscreen.font->height;
|
||||
|
@ -147,7 +149,8 @@ taglist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
|||
}
|
||||
prev_width += width;
|
||||
}
|
||||
else
|
||||
break;
|
||||
default:
|
||||
for(tag = vscreen.tags; tag; tag = tag->next, i++)
|
||||
{
|
||||
width = textwidth(vscreen.font, tag->name) + vscreen.font->height;
|
||||
|
@ -160,9 +163,8 @@ taglist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
|||
}
|
||||
prev_width += width;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Widget *
|
||||
|
|
|
@ -152,14 +152,19 @@ tasklist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
|||
|
||||
if(ev->button == Button1 && CLEANMASK(ev->state) == NoSymbol)
|
||||
{
|
||||
if(widget->statusbar->position == BarTop
|
||||
|| widget->statusbar->position == BarBot)
|
||||
switch(widget->statusbar->position)
|
||||
{
|
||||
case Top:
|
||||
case Bottom:
|
||||
ci = (ev->x - widget->location) / box_width;
|
||||
else if(widget->statusbar->position == BarRight)
|
||||
break;
|
||||
case Right:
|
||||
ci = (ev->y - widget->location) / box_width;
|
||||
else
|
||||
break;
|
||||
default:
|
||||
ci = ((widget->statusbar->width - ev->y) - widget->location) / box_width;
|
||||
|
||||
break;
|
||||
}
|
||||
/* found first visible client */
|
||||
for(c = globalconf.clients;
|
||||
c && !ISVISIBLE_ON_TB(c, widget->statusbar->screen);
|
||||
|
|
Loading…
Reference in New Issue