Wmfs: Remove all Boolean value in the Client struct: all works with flags and fix multi-head _NET_WM_STATE_FULLSCREEN little placement buf.

This commit is contained in:
Martin Duquesnoy 2009-08-20 17:50:59 +02:00
parent 6db79e381d
commit c97cc8a7db
7 changed files with 110 additions and 86 deletions

View File

@ -364,10 +364,10 @@ client_get_name(Client *c)
void
client_hide(Client *c)
{
CHECK(!c->hide);
CHECK(!(c->flags & HideFlag));
client_unmap(c);
c->hide = True;
c->flags |= HideFlag;
setwinstate(c->win, IconicState);
return;
@ -451,7 +451,7 @@ client_map(Client *c)
{
CHECK(c);
if(c->state_fullscreen)
if(c->flags & FSSFlag)
XMapWindow(dpy, c->win);
else
{
@ -463,7 +463,7 @@ client_map(Client *c)
barwin_map_subwin(c->titlebar);
}
XMapSubwindows(dpy, c->frame);
c->unmapped = False;
c->flags &= ~UnmapFlag;
}
return;
@ -490,6 +490,7 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar)
c = emalloc(1, sizeof(Client));
c->win = w;
c->screen = selscreen;
c->flags = 0;
if(conf.client.place_at_mouse)
{
@ -535,8 +536,6 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar)
for(t = clients; t && t->win != trans; t = t->next);
if(t)
c->tag = t->tag;
if(!c->free)
c->free = (rettrans == Success) || c->hint;
free(t);
client_attach(c);
@ -620,7 +619,7 @@ client_moveresize(Client *c, XRectangle geo, Bool r)
if(r)
client_geo_hints(&geo, c);
c->max = False;
c->flags &= ~MaxFlag;
c->geo = c->ogeo = geo;
c->screen = screen_get_with_geo(c->geo.x, c->geo.y);
@ -645,7 +644,7 @@ client_maximize(Client *c)
{
XRectangle geo;
if(!c || c->state_fullscreen)
if(!c || c->flags & FSSFlag)
return;
c->screen = screen_get_with_geo(c->geo.x, c->geo.y);
@ -729,8 +728,9 @@ client_size_hints(Client *c)
else
c->minax = c->maxax = c->minay = c->maxay = 0;
c->hint = (c->maxw && c->minw && c->maxh && c->minh
&& c->maxw == c->minw && c->maxh == c->minh);
if(c->maxw && c->minw && c->maxh && c->minh
&& c->maxw == c->minw && c->maxh == c->minh)
c->flags |= HintFlag;
return;
}
@ -743,8 +743,8 @@ void
client_swap(Client *c1, Client *c2)
{
/* Check if no one of these clients are free */
CHECK(!c1->free);
CHECK(!c2->free);
CHECK(!(c1->flags & FreeFlag));
CHECK(!(c2->flags & FreeFlag));
if(c1 == c2 || (c1->screen == c2->screen && c1->tag != c2->tag))
return;
@ -807,6 +807,8 @@ client_set_wanted_tag(Client *c)
void
client_update_attributes(Client *c)
{
Bool f;
/* For reload use */
XChangeProperty(dpy, c->win, ATOM("_WMFS_TAG"), XA_CARDINAL, 32,
PropModeReplace, (uchar*)&(c->tag), 1);
@ -814,8 +816,10 @@ client_update_attributes(Client *c)
XChangeProperty(dpy, c->win, ATOM("_WMFS_SCREEN"), XA_CARDINAL, 32,
PropModeReplace, (uchar*)&(c->screen), 1);
f = (c->flags & FreeFlag) ? True : False;
XChangeProperty(dpy, c->win, ATOM("_WMFS_ISFREE"), XA_CARDINAL, 32,
PropModeReplace, (uchar*)&(c->free), 1);
PropModeReplace, (uchar*)&f, 1);
return;
}
@ -826,7 +830,7 @@ client_update_attributes(Client *c)
void
client_raise(Client *c)
{
if(!c || c->tile)
if(!c || (c->flags & TileFlag))
return;
XRaiseWindow(dpy, c->frame);
@ -851,10 +855,10 @@ uicb_client_raise(uicb_t cmd)
void
client_unhide(Client *c)
{
CHECK(c->hide);
CHECK(c->flags & HideFlag);
client_map(c);
c->hide = False;
c->flags &= ~HideFlag;
setwinstate(c->win, NormalState);
return;
@ -912,7 +916,7 @@ client_unmap(Client *c)
{
CHECK(c);
if(c->state_fullscreen)
if(c->flags & FSSFlag)
XUnmapWindow(dpy, c->win);
else
{
@ -924,7 +928,7 @@ client_unmap(Client *c)
XUnmapWindow(dpy, c->frame);
XUnmapSubwindows(dpy, c->frame);
c->unmapped = True;
c->flags |= UnmapFlag;
}
return;
@ -964,7 +968,7 @@ client_set_screen(Client *c, int s)
arrange(s, True);
arrange(os, True);
if(!c->tile)
if(!(c->flags & TileFlag))
{
client_focus(c);
client_raise(c);
@ -1009,8 +1013,11 @@ uicb_client_move(uicb_t cmd)
XRectangle geo;
int xi = 0, yi = 0;
if(!sel || sel->tile || sel->max
|| sel->lmax || sel->state_fullscreen)
if((sel->flags & TileFlag)
|| (sel->flags & MaxFlag)
|| (sel->flags & LMaxFlag)
|| (sel->flags & FSSFlag)
|| !sel)
return;
geo = sel->geo;
@ -1035,8 +1042,11 @@ uicb_client_resize(uicb_t cmd)
XRectangle geo;
int wi = 0, hi = 0;
if(!sel || sel->tile || sel->max
|| sel->lmax || sel->state_fullscreen)
if((sel->flags & TileFlag)
|| (sel->flags & MaxFlag)
|| (sel->flags & LMaxFlag)
|| (sel->flags & FSSFlag)
|| !sel)
return;
geo = sel->geo;

View File

@ -249,10 +249,10 @@ configureevent(XConfigureRequestEvent *ev)
if((c = client_gb_win(ev->window))
|| (c = client_gb_win(ev->window)))
{
CHECK(!c->tile);
CHECK(!c->lmax);
CHECK(!c->max);
CHECK(!c->state_fullscreen);
CHECK(!(c->flags & TileFlag));
CHECK(!(c->flags & LMaxFlag));
CHECK(!(c->flags & MaxFlag));
CHECK(!(c->flags & FSSFlag));
}
if((c= client_gb_win(ev->window)))
@ -460,8 +460,10 @@ propertynotify(XPropertyEvent *ev)
default: break;
case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(dpy, c->win, &trans);
if((c->tile || c->max) && (c->hint = (client_gb_win(trans) != NULL)))
arrange(c->screen, True);
if((c->flags & TileFlag || c->flags & MaxFlag))
if(((c->flags & HintFlag && (client_gb_win(trans) != NULL)))
|| (!(c->flags & HintFlag && (client_gb_win(trans) != NULL))))
arrange(c->screen, True);
break;
case XA_WM_NORMAL_HINTS:
client_size_hints(c);
@ -487,7 +489,7 @@ unmapnotify(XUnmapEvent *ev)
if((c = client_gb_win(ev->window))
&& ev->send_event
&& !c->hide)
&& !(c->flags & HideFlag))
{
client_unmanage(c);
XSetErrorHandler(errorhandler);

View File

@ -287,29 +287,30 @@ ewmh_manage_net_wm_state(long data_l[], Client *c)
/* Manage _NET_WM_STATE_FULLSCREEN */
if(data_l[1] == net_atom[net_wm_state_fullscreen])
{
if(data_l[0] == _NET_WM_STATE_ADD && !c->state_fullscreen)
if(data_l[0] == _NET_WM_STATE_ADD && !(c->flags & FSSFlag))
{
c->screen = screen_get_with_geo(c->geo.x, c->geo.y);
client_unmap(c);
c->unmapped = False;
c->flags &= ~UnmapFlag;
XMapWindow(dpy, c->win);
XReparentWindow(dpy, c->win, ROOT, spgeo[c->screen].x, spgeo[c->screen].y);
XResizeWindow(dpy, c->win, spgeo[c->screen].x + spgeo[c->screen].width,
spgeo[c->screen].y + spgeo[c->screen].height);
XResizeWindow(dpy, c->win,
spgeo[c->screen].width,
spgeo[c->screen].height);
c->tmp_geo = c->geo;
if(c->free)
if(c->flags & FreeFlag)
c->ogeo = c->geo;
c->state_fullscreen = True;
c->max = True;
c->flags |= (FSSFlag | MaxFlag);
client_raise(c);
client_focus(c);
}
else if(data_l[0] == _NET_WM_STATE_REMOVE && c->state_fullscreen)
else if(data_l[0] == _NET_WM_STATE_REMOVE && (c->flags & FSSFlag))
{
c->state_fullscreen = False;
c->flags &= ~(FSSFlag | MaxFlag);
client_map(c);
XReparentWindow(dpy, c->win, c->frame, BORDH, TBARH);
client_moveresize(c, c->tmp_geo, False);
@ -368,8 +369,8 @@ ewmh_manage_window_type(Client *c)
/* MANAGE _NET_WM_WINDOW_TYPE_DIALOG */
else if(atom[i] == net_atom[net_wm_window_type_dialog])
{
c->free = True;
sel->tile = sel->max = sel->lmax = False;
c->flags |= FreeFlag;
c->flags &= ~(TileFlag | MaxFlag | LMaxFlag);
client_moveresize(sel, sel->ogeo, True);
client_focus(c);
tags[selscreen][seltag[selscreen]].layout.func(selscreen);

View File

@ -69,10 +69,10 @@ freelayout(int screen)
for(c = clients; c; c = c->next)
if(!ishide(c, selscreen)
&& c->screen == screen_get_sel()
&& !c->max)
&& !(c->flags & MaxFlag))
{
client_moveresize(c, c->ogeo, True);
c->tile = c->lmax = False;
c->flags &= ~(TileFlag | LMaxFlag);
}
ewmh_update_current_tag_prop();
@ -147,13 +147,9 @@ maxlayout(int screen)
for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i)
{
c->tile = False;
c->lmax = True;
c->flags &= ~TileFlag;
c->flags |= LMaxFlag;
client_maximize(c);
/* Focus the first client
if(!i)
client_focus(c); */
}
ewmh_update_current_tag_prop();
@ -169,10 +165,10 @@ maxlayout(int screen)
Client*
tiled_client(int screen, Client *c)
{
for(;c && (c->max
|| c->free
for(;c && ((c->flags & MaxFlag)
|| (c->flags & FreeFlag)
|| (c->flags & FSSFlag)
|| c->screen != screen
|| c->state_fullscreen
|| ishide(c, screen)); c = c->next);
return c;
@ -251,8 +247,8 @@ grid(int screen)
for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i)
{
/* Set client property */
c->max = c->lmax = False;
c->tile = True;
c->flags &= ~(MaxFlag | LMaxFlag);
c->flags |= TileFlag;
++cpcols;
cgeo.width = (sg.width / cols) - (BORDH * 2);
cgeo.height = (sg.height / rows) - BORDH;
@ -336,8 +332,8 @@ multi_tile(int screen, Position type)
for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i)
{
/* Set client property */
c->max = c->lmax = False;
c->tile = True;
c->flags &= ~(MaxFlag | LMaxFlag);
c->flags |= TileFlag;
/* MASTER */
if(i < nmaster)
@ -489,8 +485,8 @@ mirror(int screen, Bool horizontal)
for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i)
{
/* Set client property */
c->max = c->lmax = False;
c->tile = True;
c->flags &= ~(MaxFlag | LMaxFlag);
c->flags |= TileFlag;
if(i < nmaster)
{
@ -661,8 +657,12 @@ uicb_tile_switch(uicb_t cmd)
screen_get_sel();
if(!sel || sel->hint || !sel->tile || sel->state_fullscreen)
if(!sel
|| (sel->flags & HintFlag)
|| !(sel->flags & TileFlag)
|| (sel->flags & FSSFlag))
return;
if((c = sel) == tiled_client(selscreen, clients))
CHECK((c = tiled_client(selscreen, c->next)));
client_detach(c);
@ -679,14 +679,14 @@ uicb_tile_switch(uicb_t cmd)
void
uicb_togglefree(uicb_t cmd)
{
if(!sel || sel->screen != screen_get_sel() || sel->state_fullscreen)
if(!sel || sel->screen != screen_get_sel() || (sel->flags & FSSFlag))
return;
sel->free = !sel->free;
sel->flags ^= FreeFlag;
if(sel->free)
if((sel->flags & FreeFlag))
{
sel->tile = sel->max = sel->lmax = False;
sel->flags &= ~(TileFlag | MaxFlag | LMaxFlag);
client_moveresize(sel, sel->ogeo, True);
client_raise(sel);
}
@ -707,21 +707,21 @@ uicb_togglefree(uicb_t cmd)
void
uicb_togglemax(uicb_t cmd)
{
if(!sel || ishide(sel, selscreen) || sel->hint || sel->state_fullscreen)
if(!sel || ishide(sel, selscreen)
|| (sel->flags & HintFlag)|| (sel->flags & FSSFlag))
return;
if(!sel->max)
if(!(sel->flags & MaxFlag))
{
sel->ogeo = sel->geo;
sel->tile = False;
sel->free = False;
sel->flags &= ~(TileFlag | FreeFlag);
client_maximize(sel);
client_raise(sel);
sel->max = True;
sel->flags |= MaxFlag;
}
else
{
sel->max = False;
sel->flags &= ~MaxFlag;
tags[selscreen][seltag[selscreen]].layout.func(selscreen);
}

View File

@ -62,7 +62,7 @@ mouse_move(Client *c)
GC gci;
XEvent ev;
if(c->max || c->state_fullscreen)
if((c->flags & MaxFlag) || (c->flags & FSSFlag))
return;
ocx = c->geo.x;
@ -72,7 +72,7 @@ mouse_move(Client *c)
None, cursor[CurMove], CurrentTime) != GrabSuccess)
return;
if(!c->tile && !c->lmax)
if(!(c->flags & TileFlag) && !(c->flags & LMaxFlag))
XGrabServer(dpy);
/* Set the GC for the rectangle */
@ -81,7 +81,7 @@ mouse_move(Client *c)
xgc.line_width = BORDH;
gci = XCreateGC(dpy, ROOT, GCFunction | GCSubwindowMode | GCLineWidth, &xgc);
if(!c->tile && !c->lmax)
if(!(c->flags & TileFlag) && !(c->flags & LMaxFlag))
mouse_dragborder(c->geo, gci);
XQueryPointer(dpy, ROOT, &dw, &dw, &mx, &my, &dint, &dint, &duint);
@ -93,7 +93,7 @@ mouse_move(Client *c)
if(ev.type == MotionNotify)
{
if(c->tile || c->lmax)
if((c->flags & TileFlag) || (c->flags & LMaxFlag))
{
XQueryPointer(dpy, ROOT, &dw, &sw, &mx, &my, &dint, &dint, &duint);
@ -148,7 +148,7 @@ mouse_move(Client *c)
while(ev.type != ButtonRelease);
/* One time again to delete all the trace on the window */
if(!c->tile && !c->lmax)
if(!(c->flags & TileFlag) && !(c->flags & LMaxFlag))
{
mouse_dragborder(geo, gci);
client_moveresize(c, geo, False);
@ -178,7 +178,9 @@ mouse_resize(Client *c)
GC gci;
float mwf = tags[selscreen][seltag[selscreen]].mwfact;
if(c->max || c->lmax || c->state_fullscreen)
if((c->flags & MaxFlag)
|| (c->flags & LMaxFlag)
|| (c->flags & FSSFlag))
return;
XQueryPointer(dpy, ROOT, &w, &w, &omx, &omy, &d, &d, (uint *)&u);
@ -187,11 +189,11 @@ mouse_resize(Client *c)
pos = Left;
if(XGrabPointer(dpy, ROOT, False, MouseMask, GrabModeAsync, GrabModeAsync, None,
cursor[((c->tile) ? CurResize : ((pos == Right) ? CurRightResize : CurLeftResize))],
cursor[((c->flags & TileFlag) ? CurResize : ((pos == Right) ? CurRightResize : CurLeftResize))],
CurrentTime) != GrabSuccess)
return;
if(!c->tile)
if(!(c->flags & TileFlag))
XGrabServer(dpy);
/* Set the GC for the rectangle */
@ -200,7 +202,7 @@ mouse_resize(Client *c)
xgc.line_width = BORDH;
gci = XCreateGC(dpy, ROOT, GCFunction | GCSubwindowMode | GCLineWidth, &xgc);
if(!c->tile)
if(!(c->flags & TileFlag))
{
if(pos == Right)
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->geo.width + conf.client.borderheight, c->geo.height);
@ -216,7 +218,8 @@ mouse_resize(Client *c)
if(ev.type == MotionNotify)
{
/* To resize MWFACT in tile mode */
if(c->tile && tags[selscreen][seltag[selscreen]].layout.func != grid)
if((c->flags & TileFlag)
&& tags[selscreen][seltag[selscreen]].layout.func != grid)
{
if(tags[selscreen][seltag[selscreen]].layout.func == tile)
mwf += (ROUND(ev.xmotion.x_root) - omx) / (sgeo[c->screen].width);
@ -233,7 +236,7 @@ mouse_resize(Client *c)
tags[selscreen][seltag[selscreen]].mwfact = (mwf < 0.05) ? 0.05 : ((mwf > 0.95) ? 0.95 : mwf);
}
/* Free mode */
else if(!c->tile)
else if(!(c->flags & TileFlag))
{
mouse_dragborder(geo, gci);
@ -261,7 +264,7 @@ mouse_resize(Client *c)
}
while(ev.type != ButtonRelease);
if(!c->tile)
if(!(c->flags & TileFlag))
{
mouse_dragborder(ogeo, gci);
client_moveresize(c, geo, True);

View File

@ -39,6 +39,16 @@
#define MAXTAG 36
#define NUM_OF_LAYOUT 9
/* Clients flags definition */
#define FreeFlag (1 << 1)
#define MaxFlag (1 << 2)
#define TileFlag (1 << 3)
#define HideFlag (1 << 4)
#define LMaxFlag (1 << 5)
#define UnmapFlag (1 << 6)
#define HintFlag (1 << 7)
#define FSSFlag (1 << 8)
/* Typedef */
typedef const char* uicb_t;
typedef unsigned int uint;
@ -159,10 +169,8 @@ struct Client
char *fg;
uint resizecorner;
} colors;
/* Client Information */
Bool max, tile, free, hide;
Bool hint, lmax, unmapped;
Bool state_fullscreen;
/* Client Information by flags */
uint flags;
/* Struct in chains */
Client *next;
Client *prev;

View File

@ -213,7 +213,7 @@ scan(void)
if(screen != -1 && screen <= screen_count() - 1)
c->screen = screen;
if(free != -1)
c->free = free;
c->flags |= (free) ? FreeFlag : 0;
client_update_attributes(c);
}