xfwm: support for 2d pagers
Paramjit Oberoi
param at cs.wisc.edu
Mon Sep 27 22:51:42 CEST 2004
Attached are some test cases for the workspaceGetPosition() and
workspaceGetNumber() functions. It might be useful to keep them
around in the xfwm source somewhere.
The test driver is written in python, and it tests python versions
of the corresponding functions. I wrote this code before writing
the C version.
-param
Olivier Fourdan wrote (Tue, Sep 21, 2004 at 08:48:29AM +0200) :
> From: Olivier Fourdan <fourdan at xfce.org>
> To: xfce4 devel list <xfce4-dev at xfce.org>
> X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2)
> Date: Tue, 21 Sep 2004 08:48:29 +0200
> Subject: Re: xfwm: support for 2d pagers
> Sender: xfce4-dev-bounces at xfce.org
>
> Hi
>
> Ok applied. All shortcuts are set to "none" by default for now though.
>
> Cheers,
> Olivier.
>
> On Tue, 2004-09-21 at 06:47, Paramjit Oberoi wrote:
> > > i'm curious as to why you made that choice. why not leave the alt+ctrl
> > > combos the same, and add up and down for navigation? i think the
> > > navigation shortcuts are used much more frequently than the move window
> > > shortcuts. seems like it would make sense to learn new move window
> > > shortcuts than navigation.
> >
> > Just to clarify: the keybindings I listed are not suggested defaults.
> > They are just what I have been using for a long time. The defaults
> > should be picked so that they blend in with the already existing
> > shortcuts.
> >
> > -param
> > _______________________________________________
> > Xfce4-dev mailing list
> > Xfce4-dev at xfce.org
> > http://lunar-linux.org/mailman/listinfo/xfce4-dev
> --
> - Olivier Fourdan - fourdan at xfce.org - http://www.xfce.org -
>
> _______________________________________________
> Xfce4-dev mailing list
> Xfce4-dev at xfce.org
> http://lunar-linux.org/mailman/listinfo/xfce4-dev
-------------- next part --------------
class Layout:
"Represents the _NET_DESKTOP_LAYOUT property"
# Orientation
HORZ = 0
VERT = 1
# Starting Corner
TOPLEFT = 0
TOPRIGHT = 1
BOTTOMRIGHT = 2
BOTTOMLEFT = 3
def __init__(self, orientation, cols, rows, start=TOPLEFT):
self.orientation = orientation
self.cols = cols
self.rows = rows
self.start = start
def position(self, n):
if self.orientation == Layout.HORZ:
major_length = self.cols
minor_length = self.rows
else:
major_length = self.rows
minor_length = self.cols
row,col = divmod(n, major_length)
if self.start == Layout.TOPRIGHT:
col = major_length - col - 1
elif self.start == Layout.BOTTOMLEFT:
row = minor_length - row - 1
elif self.start == Layout.BOTTOMRIGHT:
col = major_length - col - 1
row = minor_length - row - 1
else:
assert self.start == Layout.TOPLEFT
if self.orientation == Layout.VERT:
row, col = col, row
if self.start in (Layout.TOPRIGHT, Layout.BOTTOMLEFT):
row = self.rows - row - 1
col = self.cols - col - 1
return row, col
def desknum(self, row, col):
if self.orientation == Layout.HORZ:
major_length = self.cols
minor_length = self.rows
else:
major_length = self.rows
minor_length = self.cols
if self.orientation == Layout.VERT:
row, col = col, row
if self.start in (Layout.TOPRIGHT, Layout.BOTTOMLEFT):
row = minor_length - row - 1
col = major_length - col - 1
if self.start == Layout.TOPRIGHT:
col = major_length - col - 1
elif self.start == Layout.BOTTOMLEFT:
row = minor_length - row - 1
elif self.start == Layout.BOTTOMRIGHT:
col = major_length - col - 1
row = minor_length - row - 1
else:
assert self.start == Layout.TOPLEFT
return row*major_length + col
def modify(value, by, limit, wrap):
value += by
if value >= limit:
if not wrap: value = limit
else: value = value % limit
elif value < 0:
if not wrap: value = 0
else: value = value % limit
return value
def move(layout, cur, rowmod, colmod, wrap=False):
"Returns the desktop number above current desktop"
row, col = layout.position(cur)
row = modify(row, rowmod, layout.rows, wrap)
col = modify(col, colmod, layout.cols, wrap)
return layout.desknum(row,col)
def check (lout, data):
for pos, (row, col) in data.iteritems():
if lout.position(pos) != (row, col):
print "Case:", pos
print "Expected:", (row, col)
print "Got:", lout.position(pos)
raise AssertionError()
if lout.desknum(row, col) != pos:
print "Case:", (row, col)
print "Expected:", pos
print "Got:", lout.desknum(row, col)
raise AssertionError()
L = Layout(Layout.HORZ, 4, 3)
v = {
0: (0,0), 1: (0,1), 2: (0,2), 3: (0,3),
4: (1,0), 5: (1,1), 6: (1,2), 7: (1,3),
8: (2,0), 9: (2,1), 10: (2,2), 11: (2,3),
}
check(L, v)
assert move(L, 6, -1, 0) == 2
L = Layout(Layout.HORZ, 4, 2)
v = {
0: (0,0), 1: (0,1), 2: (0,2), 3: (0,3),
4: (1,0), 5: (1,1), 6: (1,2), 7: (1,3),
}
check(L, v)
L = Layout(Layout.HORZ, 4, 3, Layout.BOTTOMRIGHT)
v = {
11: (0,0), 10: (0,1), 9: (0,2), 8: (0,3),
7: (1,0), 6: (1,1), 5: (1,2), 4: (1,3),
3: (2,0), 2: (2,1), 1: (2,2), 0: (2,3),
}
check(L, v)
assert move(L, 3, -1, 0) == 7
L = Layout(Layout.HORZ, 4, 3, Layout.TOPRIGHT)
v = {
3: (0,0), 2: (0,1), 1: (0,2), 0: (0,3),
7: (1,0), 6: (1,1), 5: (1,2), 4: (1,3),
11: (2,0), 10: (2,1), 9: (2,2), 8: (2,3),
}
check(L, v)
L = Layout(Layout.HORZ, 4, 3, Layout.BOTTOMLEFT)
v = {
8: (0,0), 9: (0,1), 10: (0,2), 11: (0,3),
4: (1,0), 5: (1,1), 6: (1,2), 7: (1,3),
0: (2,0), 1: (2,1), 2: (2,2), 3: (2,3),
}
check(L, v)
L = Layout(Layout.VERT, 4, 3)
v = {
0: (0,0), 3: (0,1), 6: (0,2), 9: (0,3),
1: (1,0), 4: (1,1), 7: (1,2), 10: (1,3),
2: (2,0), 5: (2,1), 8: (2,2), 11: (2,3),
}
check(L, v)
L = Layout(Layout.VERT, 4, 3, Layout.TOPRIGHT)
v = {
9: (0,0), 6: (0,1), 3: (0,2), 0: (0,3),
10: (1,0), 7: (1,1), 4: (1,2), 1: (1,3),
11: (2,0), 8: (2,1), 5: (2,2), 2: (2,3),
}
check(L, v)
L = Layout(Layout.VERT, 4, 3, Layout.BOTTOMLEFT)
v = {
2: (0,0), 5: (0,1), 8: (0,2), 11: (0,3),
1: (1,0), 4: (1,1), 7: (1,2), 10: (1,3),
0: (2,0), 3: (2,1), 6: (2,2), 9: (2,3),
}
check(L, v)
L = Layout(Layout.VERT, 4, 3, Layout.BOTTOMRIGHT)
v = {
11: (0,0), 8: (0,1), 5: (0,2), 2: (0,3),
7: (1,1), 4: (1,2), 1: (1,3), 10: (1,0),
9: (2,0), 6: (2,1), 3: (2,2), 0: (2,3),
}
check(L, v)
More information about the Xfce4-dev
mailing list