Skip to content

Commit

Permalink
make the test anim configurable on the command line
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@12884 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 22, 2016
1 parent 78e3bdd commit 6cafc0d
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/tests/xpra/clients/test_gl_vscrollup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,44 @@ def __init__(self, client, wid, W=630, H=480):
self.paint_rect(0, 0, W, H, chr(255)*4*W*H)
self.paint_rect(W//2-16, H//2-16, 32, 32, chr(0)*4*32*32)

def scrollup(self):
#scroll one line up:
ydelta = 1
def scrollup(self, ydelta=1):
print("scrollup(%s)" % ydelta)
scrolls = (0, ydelta, self.W, self.H-ydelta, -ydelta),
self.window.draw_region(0, 0, self.W, self.H, "scroll", scrolls, self.W*4, 0, typedict({"flush" : 1}), [])
self.window.draw_region(0, 0, self.W, self.H, "scroll", scrolls, self.W*4, 0, typedict({"flush" : 0}), [])
dots = []
for _ in range(self.W):
for _ in range(self.W*ydelta):
CB = 0xFF << ((self.wid % 4) * 8)
v = int(time.time()*10000)
c = struct.pack("@I", v & 0xFFFFFFFF & ~CB)
dots.append(c)
img_data = b"".join(dots)
self.paint_rect(0, self.H-ydelta*2, self.W, ydelta, img_data)
self.paint_rect(0, self.H-ydelta, self.W, ydelta, img_data)
return True

def scrolluponce(self, ydelta):
self.scrollup(ydelta)
return False

def paint_rect(self, x=200, y=200, w=32, h=32, img_data="", options={}):
self.window.draw_region(x, y, w, h, "rgb32", img_data, w*4, 0, typedict(options), [])


def main():
try:
import sys
N = int(sys.argv[1])
except:
N = 1
import sys
def argint(n, d):
try:
return int(sys.argv[n])
except:
return d
N = argint(1, 1) #number of windows
delay = argint(2, 20)
ydelta = argint(3, 1)
client = FakeGTKClient()
print("%i windows, delay=%ims, ydelta=%i" % (N, delay, ydelta))
for wid in range(N):
anim = GLWindowAnim(client, wid)
glib.timeout_add(20, anim.scrollup)
glib.idle_add(anim.scrolluponce, ydelta)
glib.timeout_add(delay, anim.scrollup, ydelta)
try:
gtk_main()
except KeyboardInterrupt:
Expand Down

0 comments on commit 6cafc0d

Please sign in to comment.