[hackers] [wmii] Allow specifying screen in area specs. Closes issue #133. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Sun, 11 Oct 2009 09:36:11 +0000 (UTC)

changeset: 2529:78d30408fe67
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Oct 10 14:57:00 2009 -0400
files: alternative_wmiircs/python/pygmi/fs.py cmd/wmii/fns.h cmd/wmii/message.c
description:
Allow specifying screen in area specs. Closes issue #133.

diff -r 801633ca6d00 -r 78d30408fe67 alternative_wmiircs/python/pygmi/fs.py
--- a/alternative_wmiircs/python/pygmi/fs.py Sat Oct 10 14:57:00 2009 -0400
+++ b/alternative_wmiircs/python/pygmi/fs.py Sat Oct 10 14:57:00 2009 -0400
@@ -234,9 +234,10 @@
         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 @@
     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 @@
                     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 @@
                     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
diff -r 801633ca6d00 -r 78d30408fe67 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Sat Oct 10 14:57:00 2009 -0400
+++ b/cmd/wmii/fns.h Sat Oct 10 14:57:00 2009 -0400
@@ -229,7 +229,7 @@
 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*, ...);
diff -r 801633ca6d00 -r 78d30408fe67 cmd/wmii/message.c
--- a/cmd/wmii/message.c Sat Oct 10 14:57:00 2009 -0400
+++ b/cmd/wmii/message.c Sat Oct 10 14:57:00 2009 -0400
@@ -329,8 +329,9 @@
 }
 
 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 @@
 
         if(s == nil)
                 return nil;
- if(!strcmp(s, "sel"))
+
+ 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 @@
         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 @@
         Frame *f, *ff;
         Client *c;
         char *s;
- ulong i, scrn;
         int sym;
 
         s = msg_getword(m);
@@ -1051,13 +1062,8 @@
                 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;
         }
 
Received on Sun Oct 11 2009 - 09:36:11 UTC

This archive was generated by hypermail 2.2.0 : Sun Oct 11 2009 - 09:48:19 UTC