mirror of
https://github.com/0intro/wmii
synced 2024-11-29 00:53:09 +03:00
Allow specifying screen in area specs. Closes issue #133.
This commit is contained in:
parent
b75ccc7266
commit
fce61e7c6d
@ -234,9 +234,10 @@ class liveprop(object):
|
||||
setattr(area, self.attr, val)
|
||||
|
||||
class Area(object):
|
||||
def __init__(self, tag, ord, offset=None, width=None, height=None, frames=None):
|
||||
def __init__(self, tag, ord, screen='sel', offset=None, width=None, height=None, frames=None):
|
||||
self.tag = tag
|
||||
self.ord = str(ord)
|
||||
self.screen = str(screen)
|
||||
self.offset = offset
|
||||
self.width = width
|
||||
self.height = height
|
||||
@ -254,6 +255,10 @@ class Area(object):
|
||||
height = prop('height')
|
||||
frames = prop('frames')
|
||||
|
||||
@property
|
||||
def spec(self):
|
||||
return '%s:%s' % (self.screen, self.ord)
|
||||
|
||||
def _get_mode(self):
|
||||
for k, v in self.tag.iteritems():
|
||||
if k == 'colmode':
|
||||
@ -262,7 +267,7 @@ class Area(object):
|
||||
return v[1]
|
||||
mode = property(
|
||||
_get_mode,
|
||||
lambda self, val: self.tag.set('colmode %s' % self.ord, val))
|
||||
lambda self, val: self.tag.set('colmode %s' % self.spec, val))
|
||||
|
||||
def grow(self, dir, amount=None):
|
||||
self.tag.grow(self, dir, amount)
|
||||
@ -353,7 +358,9 @@ class Tag(Dir):
|
||||
area = Area(tag=self, ord=l[1], width=l[2], height=l[3],
|
||||
frames=[])
|
||||
else:
|
||||
area = Area(tag=self, ord=l[1], offset=l[2], width=l[3],
|
||||
m = re.match(l[1], '(?:(\d+):)?(\d+)')
|
||||
area = Area(tag=self, screen=m.group(1) or 0,
|
||||
ord=m.group(2), offset=l[2], width=l[3],
|
||||
frames=[])
|
||||
areas.append(area)
|
||||
i = 0
|
||||
|
@ -229,7 +229,7 @@ char* msg_sendclient(View*, IxpMsg*, bool swap);
|
||||
char* readctl_client(Client*);
|
||||
char* readctl_root(void);
|
||||
char* readctl_view(View*);
|
||||
Area* strarea(View*, int, const char*);
|
||||
Area* strarea(View*, ulong, const char*);
|
||||
void warning(const char*, ...);
|
||||
/* debug */
|
||||
void debug(int, const char*, ...);
|
||||
|
@ -329,8 +329,9 @@ strclient(View *v, char *s) {
|
||||
}
|
||||
|
||||
Area*
|
||||
strarea(View *v, int scrn, const char *s) {
|
||||
strarea(View *v, ulong scrn, const char *s) {
|
||||
Area *a;
|
||||
char *p;
|
||||
long i;
|
||||
|
||||
/*
|
||||
@ -341,14 +342,26 @@ strarea(View *v, int scrn, const char *s) {
|
||||
|
||||
if(s == nil)
|
||||
return nil;
|
||||
|
||||
if((p = strchr(s, ':'))) {
|
||||
*p++ = '\0';
|
||||
if(!strcmp(s, "sel"))
|
||||
scrn = v->selscreen;
|
||||
else if(!getulong(s, &scrn))
|
||||
return nil;
|
||||
s = p;
|
||||
}
|
||||
|
||||
if(!strcmp(s, "sel")) {
|
||||
if(scrn != v->selscreen)
|
||||
return nil;
|
||||
return v->sel;
|
||||
}
|
||||
if(!strcmp(s, "~"))
|
||||
return v->floating;
|
||||
if(!getlong(s, &i) || i == 0)
|
||||
return nil;
|
||||
|
||||
/* FIXME: Very broken! */
|
||||
if(i > 0) {
|
||||
for(a = v->areas[scrn]; a; a = a->next)
|
||||
if(i-- == 1) break;
|
||||
@ -643,7 +656,6 @@ message_view(View *v, IxpMsg *m) {
|
||||
switch(getsym(s)) {
|
||||
case LCOLMODE:
|
||||
s = msg_getword(m);
|
||||
/* XXX: Multihead */
|
||||
a = strarea(v, screen->idx, s);
|
||||
if(a == nil) /* || a->floating) */
|
||||
return Ebadvalue;
|
||||
@ -1003,7 +1015,6 @@ msg_sendclient(View *v, IxpMsg *m, bool swap) {
|
||||
Frame *f, *ff;
|
||||
Client *c;
|
||||
char *s;
|
||||
ulong i, scrn;
|
||||
int sym;
|
||||
|
||||
s = msg_getword(m);
|
||||
@ -1051,13 +1062,8 @@ msg_sendclient(View *v, IxpMsg *m, bool swap) {
|
||||
to = v->floating;
|
||||
break;
|
||||
default:
|
||||
scrn = 0;
|
||||
if(!getulong(s, &i))
|
||||
if(2 != sscanf(s, "%lu:%lu", &scrn, &i))
|
||||
return Ebadvalue;
|
||||
if(i == 0 || scrn > nscreens)
|
||||
return Ebadvalue;
|
||||
to = view_findarea(v, scrn, i, true);
|
||||
to = strarea(v, v->selscreen, s);
|
||||
// to = view_findarea(v, scrn, i, true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user