commit e602759b49a64f97546ee0dec8514b7c2e7e98b5
parent 6de315bf570e651339a9a2a26d2b72f5a405b334
Author: Kris Maglione <kris@suckless.org>
Date: Thu, 10 Jun 2010 01:14:48 -0400
Float detection enhancements. Add float=always and float=never to clients.
Diffstat:
9 files changed, 77 insertions(+), 53 deletions(-)
diff --git a/alternative_wmiircs/python/pygmi/event.py b/alternative_wmiircs/python/pygmi/event.py
@@ -40,7 +40,7 @@ class Match(object):
elif isinstance(a, basestring):
a = a.__eq__
elif isinstance(a, (list, tuple, set)):
- a = curry(lambda ary, k: k in ary, a)
+ a = (lambda ary: (lambda k: k in ary))(a)
elif hasattr(a, 'search'):
a = a.search
else:
@@ -67,10 +67,11 @@ def flatten(items):
(1, 'foo'), (2: 'foo'), (3: 'foo'), (4: 'bar')
"""
for k, v in items:
- if not isinstance(k, (list, tuple)):
- k = k,
- for key in k:
- yield key, v
+ if isinstance(k, (list, tuple)):
+ for key in k:
+ yield key, v
+ else:
+ yield k, v
class Events():
"""
@@ -276,12 +277,11 @@ class Actions(object):
raise AttributeError()
if hasattr(self, name + '_'):
return getattr(self, name + '_')
- def action(args=''):
- cmd = pygmi.find_script(name)
- if cmd:
- call(pygmi.shell, '-c', '$* %s' % args, '--', cmd,
- background=True)
- return action
+ cmd = pygmi.find_script(name)
+ if not cmd:
+ raise AttributeError()
+ return lambda args='': call(pygmi.shell, '-c', '$* %s' % args, '--', cmd,
+ background=True)
def _call(self, args):
"""
diff --git a/alternative_wmiircs/python/pygmi/fs.py b/alternative_wmiircs/python/pygmi/fs.py
@@ -8,7 +8,7 @@ from pygmi import *
from pygmi.util import prop
__all__ = ('wmii', 'Tags', 'Tag', 'Area', 'Frame', 'Client',
- 'Button', 'Colors', 'Color', 'Toggle')
+ 'Button', 'Colors', 'Color', 'Toggle', 'Always', 'Never')
spacere = re.compile(r'\s')
@@ -19,9 +19,13 @@ class utf8(object):
@apply
class Toggle(utf8):
def __unicode__(self):
- return u'Toggle'
- def __repr__(self):
- return 'Toggle'
+ return unicode(self.__class__.__name__)
+@apply
+class Always(Toggle.__class__):
+ pass
+@apply
+class Never(Toggle.__class__):
+ pass
def constrain(min, max, val):
if val < min:
@@ -616,7 +620,8 @@ class Rule(collections.MutableMapping, utf8):
def quotevalue(cls, val):
if val is True: return "on"
if val is False: return "off"
- if val is Toggle: return "toggle"
+ if val in (Toggle, Always, Never):
+ return unicode(val).lower()
return unicode(val)
def __get__(self, obj, cls):
diff --git a/cmd/wmii/client.c b/cmd/wmii/client.c
@@ -313,11 +313,7 @@ client_destroy(Client *c) {
r = client_grav(c, ZR);
- hide = false;
- if(!c->sel || c->sel->view != selview)
- hide = true;
-
- XGrabServer(display);
+ hide = (!c->sel || c->sel->view != selview);
/* In case the client is already destroyed. */
traperrors(true);
@@ -328,25 +324,24 @@ client_destroy(Client *c) {
else
reparentwindow(&c->w, &scr.root, r.min);
- if(starting > -1)
+ if(starting >= 0)
XRemoveFromSaveSet(display, c->w.xid);
- traperrors(false);
- XUngrabServer(display);
-
none = nil;
client_setviews(c, &none);
- if(starting > -1)
+ if(starting >= 0)
client_unmap(c, WithdrawnState);
refree(&c->tagre);
refree(&c->tagvre);
free(c->retags);
+ traperrors(false);
+
destroywindow(c->framewin);
ewmh_destroyclient(c);
group_remove(c);
- if(starting > -1)
+ if(starting >= 0)
event("DestroyClient %#C\n", c);
event_flush(FocusChangeMask, true);
@@ -427,6 +422,8 @@ client_grav(Client *c, Rectangle rd) {
bool
client_floats_p(Client *c) {
+ if(c->floating == Never)
+ return false;
return c->trans
|| c->floating
|| c->fixedsize
@@ -533,8 +530,7 @@ client_focus(Client *c) {
Dprint(DFocus, "client_focus([%#C]%C)\n", c, c);
Dprint(DFocus, "\t[%#C]%C\n\t=> [%#C]%C\n",
- disp.focus, disp.focus,
- c, c);
+ disp.focus, disp.focus, c, c);
if(disp.focus != c) {
if(c && !c->sel->collapsed) {
@@ -748,7 +744,6 @@ client_updatename(Client *c) {
char *str;
c->name[0] = '\0';
-
if((str = windowname(&c->w))) {
utflcpy(c->name, str, sizeof c->name);
free(str);
@@ -1185,7 +1180,7 @@ client_applytags(Client *c, const char *tags) {
cur = nil;
if(!strcmp(buf+n, "~"))
- c->floating = add;
+ c->floating = add ? On : Never;
else
if(!strcmp(buf+n, "!") || !strcmp(buf+n, "sel"))
cur = selview->name;
diff --git a/cmd/wmii/column.c b/cmd/wmii/column.c
@@ -105,7 +105,8 @@ void
column_insert(Area *a, Frame *f, Frame *pos) {
f->area = a;
- f->client->floating = false;
+ if(f->client->floating == On)
+ f->client->floating = Off;
f->screen = a->screen;
f->column = area_idx(a);
frame_insert(f, pos);
diff --git a/cmd/wmii/dat.h b/cmd/wmii/dat.h
@@ -23,6 +23,9 @@
#define FOCUSCOLORS "#000000 #81654f #000000"
#define NORMCOLORS "#000000 #c1c48b #81654f"
+/* From CGO */
+#define assert_equal(x, y) typedef char _##x##_does_not_equal_##y[((x)-(y))*((x)-(y))*-2+1]
+
enum {
PingTime = 10000,
PingPeriod = 4000,
@@ -72,11 +75,16 @@ extern char* modes[];
(x) == Off ? "off" : \
(x) == Toggle ? "toggle" : "<toggle>")
enum {
+ Never = -1,
Off,
On,
+ /* Xlib defines this. :( */
+ // Always,
Toggle,
};
+assert_equal(Always, 2);
+
enum Barpos {
BBottom,
BTop,
@@ -173,7 +181,7 @@ struct Client {
int pid;
int dead;
int fullscreen;
- bool floating;
+ int floating;
bool fixedsize;
bool urgent;
bool borderless;
diff --git a/cmd/wmii/float.c b/cmd/wmii/float.c
@@ -10,7 +10,8 @@ static void float_placeframe(Frame*);
void
float_attach(Area *a, Frame *f) {
- f->client->floating = true;
+ if(f->client->floating == Off)
+ f->client->floating = On;
f->r = f->floatr;
float_placeframe(f);
diff --git a/cmd/wmii/message.c b/cmd/wmii/message.c
@@ -119,13 +119,12 @@ static char* incmodetab[] = {
"show",
"squeeze",
};
-#ifdef notdef
+static char* floatingtab[] = {
+ "never", "off", "on", "always"
+};
static char* toggletab[] = {
- "off",
- "on",
- "toggle",
+ "off", "on", "toggle",
};
-#endif
/* Edit ,y/^[a-zA-Z].*\n.* {\n/d
* Edit s/^([a-zA-Z].*)\n(.*) {\n/\1 \2;\n/
@@ -170,6 +169,18 @@ _bsearch(char *from, char **tab, int ntab) {
}
static int
+_lsearch(char *from, char **tab, int ntab) {
+ int i;
+
+ if(from != nil)
+ for(i=0; i < ntab; i++)
+ if(!strcmp(from, tab[i]))
+ return i;
+ error(Ebadvalue);
+ return 0;
+}
+
+static int
getsym(char *s) {
return _bsearch(s, symtab, nelem(symtab));
}
@@ -186,13 +197,7 @@ setdef(int *ptr, char *s, char *tab[], int ntab) {
static int
gettoggle(char *s) {
- switch(getsym(s)) {
- case LON: return On;
- case LOFF: return Off;
- case LTOGGLE: return Toggle;
- default: error(Ebadusage);
- }
- return -1;
+ return _lsearch(s, toggletab, nelem(toggletab));
}
static int
@@ -384,7 +389,7 @@ char*
readctl_client(Client *c) {
bufclear();
bufprint("%#C\n", c);
- bufprint("floating %s\n", TOGGLE(c->floating));
+ bufprint("floating %s\n", floatingtab[c->floating + 1]);
if(c->fullscreen >= 0)
bufprint("fullscreen %d\n", c->fullscreen);
else
@@ -419,7 +424,7 @@ message_client(Client *c, IxpMsg *m) {
switch(getsym(s)) {
case LFLOATING:
- toggle(c->floating, gettoggle(m->pos));
+ c->floating = -1 + _lsearch(msg_getword(m), floatingtab, nelem(floatingtab));
break;
case LFULLSCREEN:
s = msg_getword(m);
diff --git a/cmd/wmii/view.c b/cmd/wmii/view.c
@@ -364,13 +364,18 @@ view_attach(View *v, Frame *f) {
oldsel = v->oldsel;
a = v->sel;
- if(client_floats_p(c)) {
+ if(c->floating == Never)
+ a = view_findarea(v, v->selscreen, v->selcol, false);
+ else if(client_floats_p(c)) {
if(v->sel != v->floating && c->fullscreen < 0)
oldsel = v->sel;
a = v->floating;
}
- else if((ff = client_groupframe(c, v)))
+ else if((ff = client_groupframe(c, v))) {
a = ff->area;
+ if(v->oldsel && ff->client == view_selclient(v))
+ a = v->oldsel;
+ }
else if(v->sel->floating) {
if(v->oldsel)
a = v->oldsel;
@@ -382,7 +387,7 @@ view_attach(View *v, Frame *f) {
|| c->sel && c->sel->area && !c->sel->area->floating)
a = v->firstarea;
}
- if(!a->floating && view_fullscreen_p(v, a->screen))
+ if(!a->floating && c->floating != Never && view_fullscreen_p(v, a->screen))
a = v->floating;
area_attach(a, f);
diff --git a/man/wmii.man1 b/man/wmii.man1
@@ -332,9 +332,13 @@ represents the currently selected client.
of the client. The following commands may be written to
it:
>>
- : floating <on | off | toggle>
+ : floating <on | off | always | never>
Defines whether this client is likely to float when
- attached to a new view.
+ attached to a new view. Ordinarilly, the value
+ changes automatically whenever the window is
+ moved between the floating and managed layers.
+ However, setting a value of _always_ or _never_
+ overrides this behavior.
: fullscreen <on | off | toggle>
Sets the client's fullscreen state.
: group <group id>