Use rect for border instead WindowBorder
This commit is contained in:
parent
cfb64b94f3
commit
389b0a9cc5
@ -11,6 +11,7 @@
|
|||||||
#include "barwin.h"
|
#include "barwin.h"
|
||||||
#include "ewmh.h"
|
#include "ewmh.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
#include "draw.h"
|
||||||
|
|
||||||
#define CLIENT_MOUSE_MOD Mod1Mask
|
#define CLIENT_MOUSE_MOD Mod1Mask
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ client_gb_win(Window w)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct client*
|
struct client*
|
||||||
client_gb_pos(struct tag *t, int x, int y)
|
client_gb_pos(struct tag *t, int x, int y)
|
||||||
{
|
{
|
||||||
struct client *c;
|
struct client *c;
|
||||||
@ -141,25 +142,32 @@ client_grabbuttons(struct client *c, bool focused)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
client_draw_bord(void)
|
||||||
|
{
|
||||||
|
struct geo g = { 0, 0, W->screen->ugeo.w, W->screen->ugeo.h };
|
||||||
|
|
||||||
|
draw_rect(W->screen->seltag->frame, g, THEME_DEFAULT->client_n.bg);
|
||||||
|
|
||||||
|
/* Selected client's border */
|
||||||
|
if(W->client)
|
||||||
|
draw_rect(W->client->tag->frame, W->client->geo, THEME_DEFAULT->client_s.bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
client_focus(struct client *c)
|
client_focus(struct client *c)
|
||||||
{
|
{
|
||||||
/* Unfocus selected */
|
/* Unfocus selected */
|
||||||
if(W->client && W->client != c)
|
if(W->client && W->client != c)
|
||||||
{
|
|
||||||
XSetWindowBorder(W->dpy, W->client->win, THEME_DEFAULT->client_n.bg);
|
|
||||||
|
|
||||||
client_grabbuttons(W->client, false);
|
client_grabbuttons(W->client, false);
|
||||||
}
|
|
||||||
|
|
||||||
/* Focus c */
|
/* Focus c */
|
||||||
if((W->client = c))
|
if((W->client = c))
|
||||||
{
|
{
|
||||||
c->tag->sel = c;
|
c->tag->sel = c;
|
||||||
|
|
||||||
XSetWindowBorder(W->dpy, c->win, THEME_DEFAULT->client_s.bg);
|
client_draw_bord();
|
||||||
|
|
||||||
XSetInputFocus(W->dpy, c->win, RevertToPointerRoot, CurrentTime);
|
|
||||||
|
|
||||||
client_grabbuttons(c, true);
|
client_grabbuttons(c, true);
|
||||||
}
|
}
|
||||||
@ -251,15 +259,14 @@ client_new(Window w, XWindowAttributes *wa)
|
|||||||
c->geo.y = wa->y;
|
c->geo.y = wa->y;
|
||||||
c->geo.w = wa->width;
|
c->geo.w = wa->width;
|
||||||
c->geo.h = wa->height;
|
c->geo.h = wa->height;
|
||||||
c->tgeo = c->geo;
|
c->tgeo = c->wgeo = c->geo;
|
||||||
|
|
||||||
/* Set tag */
|
/* Set tag */
|
||||||
tag_client(W->screen->seltag, c);
|
tag_client(W->screen->seltag, c);
|
||||||
|
|
||||||
/* X window attributes */
|
/* X window attributes */
|
||||||
XSelectInput(W->dpy, w, EnterWindowMask | LeaveWindowMask | StructureNotifyMask | PropertyChangeMask);
|
XSelectInput(W->dpy, w, EnterWindowMask | LeaveWindowMask | StructureNotifyMask | PropertyChangeMask);
|
||||||
XSetWindowBorder(W->dpy, w, THEME_DEFAULT->client_n.bg);
|
XSetWindowBorderWidth(W->dpy, w, 0);
|
||||||
XSetWindowBorderWidth(W->dpy, w, THEME_DEFAULT->client_border_width);
|
|
||||||
client_grabbuttons(c, false);
|
client_grabbuttons(c, false);
|
||||||
|
|
||||||
/* Attach */
|
/* Attach */
|
||||||
@ -277,9 +284,21 @@ client_new(Window w, XWindowAttributes *wa)
|
|||||||
void
|
void
|
||||||
client_moveresize(struct client *c, struct geo g)
|
client_moveresize(struct client *c, struct geo g)
|
||||||
{
|
{
|
||||||
c->geo = g;
|
int bord = THEME_DEFAULT->client_border_width;
|
||||||
|
|
||||||
XMoveResizeWindow(W->dpy, c->win, g.x, g.y, g.w, g.h);
|
c->geo = c->wgeo = g;
|
||||||
|
|
||||||
|
/* Window geo */
|
||||||
|
c->wgeo.x += bord;
|
||||||
|
c->wgeo.y += bord ;
|
||||||
|
c->wgeo.w -= (bord << 1);
|
||||||
|
c->wgeo.h -= (bord << 1);
|
||||||
|
|
||||||
|
XMoveResizeWindow(W->dpy, c->win,
|
||||||
|
c->wgeo.x, c->wgeo.y,
|
||||||
|
c->wgeo.w, c->wgeo.h);
|
||||||
|
|
||||||
|
client_draw_bord();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -288,8 +307,8 @@ client_maximize(struct client *c)
|
|||||||
c->geo = c->tag->screen->ugeo;
|
c->geo = c->tag->screen->ugeo;
|
||||||
|
|
||||||
c->geo.x = c->geo.y = 0; /* Frame x/y, not screen geo */
|
c->geo.x = c->geo.y = 0; /* Frame x/y, not screen geo */
|
||||||
c->geo.w = c->tag->screen->ugeo.w - (THEME_DEFAULT->client_border_width << 1);
|
c->geo.w = c->tag->screen->ugeo.w;
|
||||||
c->geo.h = c->tag->screen->ugeo.h - (THEME_DEFAULT->client_border_width << 1);
|
c->geo.h = c->tag->screen->ugeo.h;
|
||||||
|
|
||||||
client_moveresize(c, c->geo);
|
client_moveresize(c, c->geo);
|
||||||
}
|
}
|
||||||
@ -298,15 +317,16 @@ void
|
|||||||
client_fac_resize(struct client *c, Position p, int fac)
|
client_fac_resize(struct client *c, Position p, int fac)
|
||||||
{
|
{
|
||||||
struct client *gc = client_next_with_pos(c, p);
|
struct client *gc = client_next_with_pos(c, p);
|
||||||
|
Position rp = RPOS(p);
|
||||||
|
|
||||||
if(!gc || gc->screen != c->screen)
|
if(!gc || gc->screen != c->screen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Check futur size/pos */
|
/* Check futur size/pos */
|
||||||
if(!client_fac_geo(c, p, fac)
|
if(!client_fac_geo(c, p, fac)
|
||||||
|| !client_fac_geo(gc, RPOS(p), -fac)
|
|| !client_fac_geo(gc, rp, -fac)
|
||||||
|| !client_fac_check_row(c, p, fac)
|
|| !client_fac_check_row(c, p, fac)
|
||||||
|| !client_fac_check_row(gc, RPOS(p), -fac))
|
|| !client_fac_check_row(gc, rp, -fac))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
@ -320,7 +340,7 @@ client_fac_resize(struct client *c, Position p, int fac)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
client_fac_arrange_row(c, p, fac);
|
client_fac_arrange_row(c, p, fac);
|
||||||
client_fac_arrange_row(gc, RPOS(p), -fac);
|
client_fac_arrange_row(gc, rp, -fac);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
void client_configure(struct client *c);
|
void client_configure(struct client *c);
|
||||||
struct client *client_gb_win(Window w);
|
struct client *client_gb_win(Window w);
|
||||||
|
struct client* client_gb_pos(struct tag *t, int x, int y);
|
||||||
struct client *client_next_with_pos(struct client *bc, Position p);
|
struct client *client_next_with_pos(struct client *bc, Position p);
|
||||||
void client_focus(struct client *c);
|
void client_focus(struct client *c);
|
||||||
void client_get_name(struct client *c);
|
void client_get_name(struct client *c);
|
||||||
@ -53,7 +54,7 @@ client_fac_geo(struct client *c, Position p, int fac)
|
|||||||
|
|
||||||
/* Check for incompatible geo */
|
/* Check for incompatible geo */
|
||||||
if(cg.w > c->screen->ugeo.w || cg.h > c->screen->ugeo.h
|
if(cg.w > c->screen->ugeo.w || cg.h > c->screen->ugeo.h
|
||||||
|| cg.w < 1 || cg.h < 1)
|
|| cg.w < 3 || cg.h < 3)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Set transformed geo in tmp geo */
|
/* Set transformed geo in tmp geo */
|
||||||
|
|||||||
@ -22,6 +22,13 @@ draw_text(Drawable d, struct theme *t, int x, int y, Color fg, const char *str)
|
|||||||
XmbDrawString(W->dpy, d, t->font.fontset, W->gc, x, y, str, strlen(str));
|
XmbDrawString(W->dpy, d, t->font.fontset, W->gc, x, y, str, strlen(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
draw_rect(Drawable d, struct geo g, Color bg)
|
||||||
|
{
|
||||||
|
XSetForeground(W->dpy, W->gc, bg);
|
||||||
|
XFillRectangle(W->dpy, d, W->gc, g.x, g.y, g.w, g.h);
|
||||||
|
}
|
||||||
|
|
||||||
static inline unsigned short
|
static inline unsigned short
|
||||||
draw_textw(struct theme *t, const char *str)
|
draw_textw(struct theme *t, const char *str)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -12,14 +12,13 @@ static struct geo
|
|||||||
layout_split(struct client *c, bool vertical)
|
layout_split(struct client *c, bool vertical)
|
||||||
{
|
{
|
||||||
struct geo og, geo;
|
struct geo og, geo;
|
||||||
int bord = THEME_DEFAULT->client_border_width;
|
|
||||||
|
|
||||||
geo = og = c->geo;
|
geo = og = c->geo;
|
||||||
|
|
||||||
if(vertical)
|
if(vertical)
|
||||||
{
|
{
|
||||||
c->geo.w >>= 1;
|
c->geo.w >>= 1;
|
||||||
geo.x = (c->geo.x + bord) + (c->geo.w + bord);
|
geo.x = c->geo.x + c->geo.w;
|
||||||
geo.w >>= 1;
|
geo.w >>= 1;
|
||||||
|
|
||||||
/* Remainder */
|
/* Remainder */
|
||||||
@ -28,7 +27,7 @@ layout_split(struct client *c, bool vertical)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
c->geo.h >>= 1;
|
c->geo.h >>= 1;
|
||||||
geo.y = (c->geo.y + bord) + (c->geo.h + bord);
|
geo.y = c->geo.y + c->geo.h;
|
||||||
geo.h >>= 1;
|
geo.h >>= 1;
|
||||||
|
|
||||||
/* Remainder */
|
/* Remainder */
|
||||||
@ -45,14 +44,14 @@ layout_split_arrange_size(struct geo g, struct client *c, Position p)
|
|||||||
{
|
{
|
||||||
if(LDIR(p))
|
if(LDIR(p))
|
||||||
{
|
{
|
||||||
c->geo.w += g.w + (THEME_DEFAULT->client_border_width << 1);
|
c->geo.w += g.w;
|
||||||
|
|
||||||
if(p == Right)
|
if(p == Right)
|
||||||
c->geo.x = g.x;
|
c->geo.x = g.x;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
c->geo.h += g.h + (THEME_DEFAULT->client_border_width << 1);
|
c->geo.h += g.h;
|
||||||
|
|
||||||
if(p == Bottom)
|
if(p == Bottom)
|
||||||
c->geo.y = g.y;
|
c->geo.y = g.y;
|
||||||
@ -66,23 +65,18 @@ layout_split_check_row_dir(struct client *c, struct client *g, Position p)
|
|||||||
{
|
{
|
||||||
struct geo cgeo = c->geo;
|
struct geo cgeo = c->geo;
|
||||||
struct client *cc;
|
struct client *cc;
|
||||||
int bord = THEME_DEFAULT->client_border_width;
|
int s = 0, cs = (LDIR(p) ? g->geo.h : g->geo.w);
|
||||||
int i = 0, s = 0, cs = (LDIR(p) ? g->geo.h : g->geo.w );
|
|
||||||
|
|
||||||
SLIST_FOREACH(cc, &c->tag->clients, tnext)
|
SLIST_FOREACH(cc, &c->tag->clients, tnext)
|
||||||
if(GEO_PARENTROW(cgeo, cc->geo, RPOS(p))
|
if(GEO_PARENTROW(cgeo, cc->geo, RPOS(p))
|
||||||
&& GEO_CHECK_ROW(cc->geo, g->geo, p))
|
&& GEO_CHECK_ROW(cc->geo, g->geo, p))
|
||||||
{
|
{
|
||||||
s += (LDIR(p)
|
s += (LDIR(p) ? cc->geo.h : cc->geo.w);
|
||||||
? cc->geo.h + bord
|
|
||||||
: cc->geo.w + bord) + (i > 1 ? bord : 0);
|
|
||||||
|
|
||||||
if(s == cs)
|
if(s == cs)
|
||||||
return true;
|
return true;
|
||||||
if(s > cs)
|
if(s > cs)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -147,7 +141,6 @@ layout_split_arrange_closed(struct client *ghost)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Integrate a client in split layout: split sc and fill c in new geo */
|
/* Integrate a client in split layout: split sc and fill c in new geo */
|
||||||
|
|||||||
@ -104,7 +104,7 @@ struct client
|
|||||||
struct tag *tag;
|
struct tag *tag;
|
||||||
struct screen *screen;
|
struct screen *screen;
|
||||||
struct barwin *titlebar;
|
struct barwin *titlebar;
|
||||||
struct geo geo, tgeo;
|
struct geo geo, tgeo, wgeo;
|
||||||
char *title;
|
char *title;
|
||||||
Flags flags;
|
Flags flags;
|
||||||
Window win;
|
Window win;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user