Infobar: Add hide position (Feature #8 requested by Cheaterman)

This commit is contained in:
Martin Duquesnoy 2009-03-19 00:20:07 +01:00
parent a6868a0af0
commit 0b3a2d1b8f
9 changed files with 109 additions and 50 deletions

View File

@ -502,27 +502,19 @@ client_moveresize(Client *c, XRectangle geo, Bool r)
/* }}} */
c->max = False;
if(c->geo.x != geo.x
|| c->geo.y != geo.y
|| c->geo.width != geo.width
|| c->geo.height != geo.height)
{
if(tags[selscreen][seltag[selscreen]].layout.func == freelayout
|| c->free);
c->geo = c->ogeo = geo;
/* Set the client screen */
c->screen = screen_get_with_geo(geo.x, geo.y);
c->tag = seltag[c->screen];
if(tags[selscreen][seltag[selscreen]].layout.func == freelayout
|| c->free);
c->geo = c->ogeo = geo;
frame_moveresize(c, c->geo);
c->screen = screen_get_with_geo(c->geo.x, c->geo.y);
c->tag = seltag[c->screen];
XMoveResizeWindow(dpy, c->win, BORDH, BORDH + TBARH, c->geo.width, c->geo.height);
frame_moveresize(c, c->geo);
client_configure(c);
XMoveResizeWindow(dpy, c->win, BORDH, BORDH + TBARH, c->geo.width, c->geo.height);
XSync(dpy, False);
}
client_configure(c);
return;
}
@ -695,10 +687,10 @@ client_swap(Client *a, Client *b)
clients = a;
/* Swap tag/screen property */
a->tag = b->tag;
b->tag = tt;
a->screen = b->screen;
b->screen = ts;
a->tag = b->tag;
b->tag = tt;
/* Swap position/size an move them */
client_moveresize(a, b->geo, False);

View File

@ -137,7 +137,16 @@ conf_bar_section(cfg_t *cfg_b)
conf.border.bar = cfg_getbool(cfg_b, "border");
conf.colors.bar = getcolor(alias_to_str(cfg_getstr(cfg_b, "bg")));
conf.colors.text = _strdup(alias_to_str(cfg_getstr(cfg_b, "fg")));
conf.bartop = (strcmp(_strdup(cfg_getstr(cfg_b, "position")), "top") == 0) ? True : False;
if(!strcmp(_strdup(cfg_getstr(cfg_b, "position")),"none")
|| !strcmp(_strdup(cfg_getstr(cfg_b, "position")), "hide")
|| !strcmp(_strdup(cfg_getstr(cfg_b, "position")), "hidden"))
conf.barpos = 0;
else if(!strcmp(_strdup(cfg_getstr(cfg_b, "position")), "bottom")
|| !strcmp(_strdup(cfg_getstr(cfg_b, "position")), "down"))
conf.barpos = 1;
else
conf.barpos = 2;
return;
}

View File

@ -70,6 +70,7 @@ frame_create(Client *c)
/* Create titlebar window */
if(TBARH)
{
c->titlebar = barwin_create(c->frame, 0, 0,
c->frame_geo.width ,
TBARH + BORDH * 2,
@ -77,6 +78,14 @@ frame_create(Client *c)
c->colors.fg,
True, conf.titlebar.stipple, False);
/*
CWIN(c->button, c->titlebar->win, 2, 2, TBARH - 3, TBARH - 3, 1,
CWOverrideRedirect|CWBackPixmap, c->colors.frame, &at);
XSetWindowBorder(dpy, c->button, getcolor(c->colors.fg));
*/
}
at.event_mask &= ~(EnterWindowMask | LeaveWindowMask); /* <- Delete useless mask */
/* Create resize area */
@ -173,7 +182,14 @@ frame_update(Client *c)
c->titlebar->fg = c->colors.fg;
barwin_refresh_color(c->titlebar);
/*
draw_rectangle(c->titlebar->dr, 0, 0, TBARH + 4, TBARH + BORDH * 2, c->colors.frame);
barwin_refresh(c->titlebar);
XSetWindowBackground(dpy, c->button, c->colors.frame);
XClearWindow(dpy, c->button);
XSetWindowBorder(dpy, c->button, getcolor(c->colors.fg));
*/
}
XSetWindowBackground(dpy, c->frame, c->colors.frame);

View File

@ -46,9 +46,23 @@ infobar_init(void)
{
j = 0;
infobar[sc].geo.height = INFOBARH;
infobar[sc].geo.y = (conf.bartop)
? sgeo[sc].y - INFOBARH - TBARH
: sgeo[sc].height - INFOBARH;
if(!conf.barpos)
{
sgeo[sc].y = TBARH;
sgeo[selscreen].height += INFOBARH;
infobar[selscreen].geo.y = -(infobar[selscreen].geo.height) * 2;
}
else if(conf.barpos == 1)
{
sgeo[selscreen].y = TBARH;
infobar[selscreen].geo.y = sgeo[selscreen].height + TBARH;
}
else
{
sgeo[sc].y = INFOBARH + TBARH;
infobar[selscreen].geo.y = sgeo[selscreen].y - (INFOBARH + TBARH);
}
/* Create infobar barwindow */
infobar[sc].bar = barwin_create(ROOT, sgeo[sc].x - BORDH, infobar[sc].geo.y,
@ -178,18 +192,28 @@ uicb_infobar_togglepos(uicb_t cmd)
{
screen_get_sel();
conf.bartop = !conf.bartop;
conf.barpos = (conf.barpos < 2) ? conf.barpos + 1 : 0;
if(conf.bartop)
/* Hidden position */
if(!conf.barpos)
{
sgeo[selscreen].y = TBARH;
sgeo[selscreen].height += INFOBARH;
infobar[selscreen].geo.y = -(infobar[selscreen].geo.height) * 2;
}
/* Bottom position */
else if(conf.barpos == 1)
{
sgeo[selscreen].y = TBARH;
sgeo[selscreen].height -= INFOBARH;
infobar[selscreen].geo.y = sgeo[selscreen].height + TBARH;
}
/* Top position */
else
{
sgeo[selscreen].y = INFOBARH + TBARH;
infobar[selscreen].geo.y = sgeo[selscreen].y - (INFOBARH + TBARH);
}
else
{
sgeo[selscreen].y = TBARH;
infobar[selscreen].geo.y = sgeo[selscreen].height + TBARH;
}
barwin_move(infobar[selscreen].bar, sgeo[selscreen].x - BORDH, infobar[selscreen].geo.y);
infobar_draw(selscreen);

View File

@ -50,7 +50,6 @@ arrange(int screen)
tags[screen][seltag[screen]].layout.func(screen);
infobar_draw(screen);
ewmh_get_current_layout();
return;
}
@ -69,6 +68,8 @@ freelayout(int screen)
c->tile = c->lmax = False;
}
ewmh_get_current_layout();
return;
}
@ -142,6 +143,8 @@ maxlayout(int screen)
client_maximize(c);
}
ewmh_get_current_layout();
return;
}
@ -259,6 +262,8 @@ grid(int screen)
}
}
ewmh_get_current_layout();
return;
}
@ -389,6 +394,8 @@ multi_tile(int screen, Position type)
cgeo.y = c->geo.y + c->geo.height + border + TBARH;
}
ewmh_get_current_layout();
return;
}

View File

@ -38,10 +38,7 @@
void
mouse_move(Client *c)
{
int ocx = c->geo.x;
int ocy = c->geo.y;
int mx = c->geo.x;
int my = c->geo.y;
int ocx, ocy, mx, my;
int oscreen = c->screen;
int dint;
uint duint;
@ -50,9 +47,12 @@ mouse_move(Client *c)
XRectangle geo = c->geo;
XEvent ev;
if(c->max || c->lmax || c->state_fullscreen || c->state_dock)
if(c->max || c->lmax || c->state_fullscreen || c->state_dock)
return;
ocx = c->geo.x;
ocy = c->geo.y;
if(XGrabPointer(dpy, ROOT, False, MouseMask, GrabModeAsync, GrabModeAsync,
None, cursor[CurMove], CurrentTime) != GrabSuccess)
return;
@ -75,19 +75,14 @@ mouse_move(Client *c)
|| (sclient = client_gb_titlebar(sw)))
client_swap(c, sclient);
}
/* To move a client normally, in freelayout */
else
{
geo.x = (ocx + (ev.xmotion.x - mx));
geo.y = (ocy + (ev.xmotion.y - my));
if(c->screen != oscreen)
arrange(c->screen);
if(c->free || tags[c->screen][c->tag].layout.func == freelayout)
client_moveresize(c, geo, True);
else
break;
client_moveresize(c, geo, False);
}
}
else if(ev.type == MapRequest

View File

@ -69,9 +69,10 @@ screen_get_geo(int s)
xsi = XineramaQueryScreens(dpy, &n);
geo.x = xsi[s].x_org + BORDH;
geo.y = (conf.bartop)
? xsi[s].y_org + INFOBARH + TBARH
: xsi[s].y_org + TBARH;
if(!conf.barpos || conf.barpos == 1)
geo.y = TBARH;
else
geo.y = xsi[s].y_org + INFOBARH + TBARH;
geo.height = xsi[s].height - INFOBARH - TBARH;
geo.width = xsi[s].width;
@ -80,7 +81,10 @@ screen_get_geo(int s)
else
{
geo.x = BORDH;
geo.y = (conf.bartop) ? INFOBARH + TBARH : TBARH;
if(!conf.barpos || conf.barpos == 1)
geo.y = TBARH;
else
geo.y = INFOBARH + TBARH;
geo.height = MAXH - INFOBARH - TBARH;
geo.width = MAXW;
}
@ -97,13 +101,22 @@ int
screen_get_with_geo(int x, int y)
{
int i, r = 0;
int yh;
if(!conf.barpos || conf.barpos == 1)
yh = (sgeo[i].y - TBARH);
for(i = 0; i < screen_count(); ++i)
{
if(!conf.barpos || conf.barpos == 1)
yh = (sgeo[i].y - TBARH);
else
yh = (sgeo[i].y - INFOBARH - TBARH);
if((x >= sgeo[i].x && x < sgeo[i].x + sgeo[i].width)
&& (y >= ((conf.bartop) ? (sgeo[i].y - INFOBARH - TBARH) : (sgeo[i].y - TBARH))
&& (y < ((conf.bartop) ? (sgeo[i].y - INFOBARH - TBARH) : (sgeo[i].y - TBARH))
+ sgeo[i].height + INFOBARH + TBARH)))
&& y >= yh && y < yh + (sgeo[i].height + INFOBARH + TBARH))
r = i;
}
return r;
}

View File

@ -134,6 +134,7 @@ struct Client
int minax, maxax, minay, maxay;
/* Client composant {{{ */
Window win;
Window button;
BarWindow *titlebar;
Window frame, resize;
/* Border */
@ -253,7 +254,7 @@ typedef struct
char *font;
Bool raisefocus;
Bool raiseswitch;
Bool bartop;
int barpos;
struct
{
/*

2
wmfsrc
View File

@ -17,6 +17,8 @@ bar
bg = "#191919"
fg = "#D4D4D4"
border = true
# Infobar position : top, bottom or hide.
position = "top"
}