[titlebar] Better handling of position changes
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
d4764787c5
commit
10903a3cb5
9
client.c
9
client.c
|
@ -144,7 +144,7 @@ client_updatetitle(Client *c)
|
|||
xgettextprop(globalconf.display, c->win,
|
||||
XInternAtom(globalconf.display, "WM_NAME", False), c->name, sizeof(c->name));
|
||||
|
||||
titlebar_update(c);
|
||||
titlebar_draw(c);
|
||||
|
||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ client_unfocus(Client *c)
|
|||
XSetWindowBorder(globalconf.display, c->win,
|
||||
globalconf.screens[c->screen].styles.normal.border.pixel);
|
||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||
titlebar_update(c);
|
||||
titlebar_draw(c);
|
||||
}
|
||||
|
||||
/** Ban client and unmap it
|
||||
|
@ -210,7 +210,7 @@ client_focus(Client *c, int screen, Bool raise)
|
|||
window_settrans(c->win, globalconf.screens[c->screen].opacity_focused);
|
||||
XSetWindowBorder(globalconf.display, c->win,
|
||||
globalconf.screens[screen].styles.focus.border.pixel);
|
||||
titlebar_update(c);
|
||||
titlebar_draw(c);
|
||||
XSetInputFocus(globalconf.display, c->win, RevertToPointerRoot, CurrentTime);
|
||||
if(raise)
|
||||
client_stack(c);
|
||||
|
@ -668,7 +668,10 @@ client_updatewmhints(Client *c)
|
|||
if((wmh = XGetWMHints(globalconf.display, c->win)))
|
||||
{
|
||||
if((c->isurgent = ((wmh->flags & XUrgencyHint) && globalconf.focus->client != c)))
|
||||
{
|
||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||
titlebar_draw(c);
|
||||
}
|
||||
if((wmh->flags & StateHint) && wmh->initial_state == WithdrawnState)
|
||||
{
|
||||
c->border = 0;
|
||||
|
|
100
titlebar.c
100
titlebar.c
|
@ -23,21 +23,19 @@
|
|||
|
||||
#include "titlebar.h"
|
||||
#include "screen.h"
|
||||
#include "layouts/floating.h"
|
||||
|
||||
extern AwesomeConf globalconf;
|
||||
|
||||
/** Initialize a titlebar: create the SimpleWindow.
|
||||
* We still need to update its geometry to have it placed correctly.
|
||||
* \param c the client
|
||||
*/
|
||||
void
|
||||
titlebar_init(Client *c)
|
||||
{
|
||||
int width;
|
||||
|
||||
if(c->titlebar.position == Off
|
||||
|| c->titlebar.position == Auto)
|
||||
{
|
||||
c->titlebar.position = Off;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!c->titlebar.height)
|
||||
c->titlebar.height = 1.5 * MAX(c->titlebar.styles.normal.font->height,
|
||||
MAX(c->titlebar.styles.focus.font->height,
|
||||
|
@ -45,63 +43,41 @@ titlebar_init(Client *c)
|
|||
|
||||
switch(c->titlebar.position)
|
||||
{
|
||||
case Off:
|
||||
return;
|
||||
case Auto:
|
||||
c->titlebar.position = Off;
|
||||
return;
|
||||
case Top:
|
||||
if(!c->titlebar.width)
|
||||
width = c->geometry.width + 2 * c->border;
|
||||
else
|
||||
width = MIN(c->titlebar.width, c->geometry.width);
|
||||
c->titlebar.sw = simplewindow_new(globalconf.display,
|
||||
c->phys_screen,
|
||||
c->geometry.x,
|
||||
c->geometry.y - c->titlebar.height,
|
||||
width,
|
||||
c->titlebar.height,
|
||||
0);
|
||||
break;
|
||||
case Bottom:
|
||||
if(!c->titlebar.width)
|
||||
width = c->geometry.width + 2 * c->border;
|
||||
else
|
||||
width = MIN(c->titlebar.width, c->geometry.width);
|
||||
c->titlebar.sw = simplewindow_new(globalconf.display,
|
||||
c->phys_screen,
|
||||
c->geometry.x,
|
||||
c->geometry.y + c->geometry.height + 2 * c->border,
|
||||
width,
|
||||
c->titlebar.height,
|
||||
0);
|
||||
c->phys_screen, 0, 0,
|
||||
width, c->titlebar.height, 0);
|
||||
break;
|
||||
case Left:
|
||||
if(!c->titlebar.width)
|
||||
width = c->geometry.height + 2 * c->border;
|
||||
else
|
||||
width = MIN(c->titlebar.width, c->geometry.height);
|
||||
c->titlebar.sw = simplewindow_new(globalconf.display,
|
||||
c->phys_screen,
|
||||
c->geometry.x - c->titlebar.height,
|
||||
c->geometry.y,
|
||||
c->titlebar.height,
|
||||
width,
|
||||
0);
|
||||
break;
|
||||
case Right:
|
||||
if(!c->titlebar.width)
|
||||
width = c->geometry.height + 2 * c->border;
|
||||
else
|
||||
width = MIN(c->titlebar.width, c->geometry.height);
|
||||
c->titlebar.sw = simplewindow_new(globalconf.display,
|
||||
c->phys_screen,
|
||||
c->geometry.x + c->geometry.width + 2 * c->border,
|
||||
c->geometry.y,
|
||||
c->titlebar.height,
|
||||
width,
|
||||
0);
|
||||
c->phys_screen, 0, 0,
|
||||
c->titlebar.height, width, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Add the titlebar geometry to a geometry.
|
||||
* \param t the titlebar
|
||||
* \param geometry the geometry
|
||||
* \return a new geometry bigger if the titlebar is visible
|
||||
*/
|
||||
area_t
|
||||
titlebar_geometry_add(Titlebar *t, area_t geometry)
|
||||
{
|
||||
|
@ -131,6 +107,11 @@ titlebar_geometry_add(Titlebar *t, area_t geometry)
|
|||
return geometry;
|
||||
}
|
||||
|
||||
/** Remove the titlebar geometry to a geometry.
|
||||
* \param t the titlebar
|
||||
* \param geometry the geometry
|
||||
* \return a new geometry smaller if the titlebar is visible
|
||||
*/
|
||||
area_t
|
||||
titlebar_geometry_remove(Titlebar *t, area_t geometry)
|
||||
{
|
||||
|
@ -160,8 +141,11 @@ titlebar_geometry_remove(Titlebar *t, area_t geometry)
|
|||
return geometry;
|
||||
}
|
||||
|
||||
/** Draw the titlebar content.
|
||||
* \param c the client
|
||||
*/
|
||||
void
|
||||
titlebar_update(Client *c)
|
||||
titlebar_draw(Client *c)
|
||||
{
|
||||
Drawable dw = 0;
|
||||
DrawCtx *ctx;
|
||||
|
@ -198,7 +182,7 @@ titlebar_update(Client *c)
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Check if the client is focused/urgent/normal */
|
||||
if(globalconf.focus->client == c)
|
||||
style = c->titlebar.styles.focus;
|
||||
else if(c->isurgent)
|
||||
|
@ -231,6 +215,9 @@ titlebar_update(Client *c)
|
|||
draw_context_delete(&ctx);
|
||||
}
|
||||
|
||||
/** Update the titlebar geometry for a floating client.
|
||||
* \param c the client
|
||||
*/
|
||||
void
|
||||
titlebar_update_geometry_floating(Client *c)
|
||||
{
|
||||
|
@ -243,6 +230,9 @@ titlebar_update_geometry_floating(Client *c)
|
|||
{
|
||||
default:
|
||||
return;
|
||||
case Off:
|
||||
XUnmapWindow(globalconf.display, c->titlebar.sw->window);
|
||||
return;
|
||||
case Top:
|
||||
if(!c->titlebar.width)
|
||||
width = c->geometry.width + 2 * c->border;
|
||||
|
@ -333,9 +323,15 @@ titlebar_update_geometry_floating(Client *c)
|
|||
break;
|
||||
}
|
||||
|
||||
titlebar_update(c);
|
||||
XMapWindow(globalconf.display, c->titlebar.sw->window);
|
||||
titlebar_draw(c);
|
||||
}
|
||||
|
||||
|
||||
/** Update the titlebar geometry for a tiled client.
|
||||
* \param c the client
|
||||
* \param geometry the geometry the client will receive
|
||||
*/
|
||||
void
|
||||
titlebar_update_geometry(Client *c, area_t geometry)
|
||||
{
|
||||
|
@ -348,6 +344,9 @@ titlebar_update_geometry(Client *c, area_t geometry)
|
|||
{
|
||||
default:
|
||||
return;
|
||||
case Off:
|
||||
XUnmapWindow(globalconf.display, c->titlebar.sw->window);
|
||||
return;
|
||||
case Top:
|
||||
if(!c->titlebar.width)
|
||||
width = geometry.width + 2 * c->border;
|
||||
|
@ -440,7 +439,8 @@ titlebar_update_geometry(Client *c, area_t geometry)
|
|||
break;
|
||||
}
|
||||
|
||||
titlebar_update(c);
|
||||
XMapWindow(globalconf.display, c->titlebar.sw->window);
|
||||
titlebar_draw(c);
|
||||
}
|
||||
|
||||
/** Toggle window titlebar visibility
|
||||
|
@ -459,11 +459,11 @@ uicb_client_toggletitlebar(int screen __attribute__ ((unused)), char *arg __attr
|
|||
if(!c->titlebar.position)
|
||||
c->titlebar.position = c->titlebar.dposition;
|
||||
else
|
||||
{
|
||||
c->titlebar.position = Off;
|
||||
XUnmapWindow(globalconf.display, c->titlebar.sw->window);
|
||||
}
|
||||
|
||||
if(c->isfloating || layout_get_current(screen)->arrange == layout_floating)
|
||||
titlebar_update_geometry_floating(c);
|
||||
else
|
||||
globalconf.screens[c->screen].need_arrange = True;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "structs.h"
|
||||
|
||||
void titlebar_init(Client *);
|
||||
void titlebar_update(Client *);
|
||||
void titlebar_draw(Client *);
|
||||
void titlebar_update_geometry_floating(Client *);
|
||||
void titlebar_update_geometry(Client *, area_t);
|
||||
area_t titlebar_geometry_add(Titlebar *, area_t);
|
||||
|
|
Loading…
Reference in New Issue