Skip to content

Commit

Permalink
make it possible to launch multiple windows
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@12883 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 22, 2016
1 parent 4709cc7 commit 78e3bdd
Showing 1 changed file with 34 additions and 20 deletions.
54 changes: 34 additions & 20 deletions src/tests/xpra/clients/test_gl_vscrollup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,46 @@
load_codecs(encoders=False, decoders=True, csc=False)


def main():
W = 640
H = 480
client = FakeGTKClient()
window = GLClientWindow(client, None, 1, 10, 10, W, H, W, H, typedict({}), False, typedict({}), 0, None)
window.show()
def paint_rect(x=200, y=200, w=32, h=32, img_data="", options={}):
#print("paint_rect%s" % ((x, y, w, h),))
window.draw_region(x, y, w, h, "rgb32", img_data, w*4, 0, typedict(options), [])
img_data = chr(255)*4*W*H
glib.timeout_add(0, paint_rect, 0, 0, W, H, img_data)
img_data = chr(0)*4*32*32
glib.timeout_add(10, paint_rect, W//2-16, H//2-16, 32, 32, img_data)
def scrollup():
class GLWindowAnim(object):

def __init__(self, client, wid, W=630, H=480):
self.wid = wid
self.W = W
self.H = H
self.window = GLClientWindow(client, None, 1, 10, 10, W, H, W, H, typedict({}), False, typedict({}), 0, None)
self.window.show()
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
scrolls = (0, ydelta, W, H-ydelta, -ydelta),
window.draw_region(0, 0, W, H, "scroll", scrolls, W*4, 0, typedict({"flush" : 1}), [])
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}), [])
dots = []
for _ in range(W):
c = struct.pack("@I", int(time.time()*1000) % 0xFFFFFFFF)
for _ in range(self.W):
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)
paint_rect(0, H-ydelta*2, W, ydelta, img_data)
self.paint_rect(0, self.H-ydelta*2, self.W, ydelta, img_data)
return True
glib.timeout_add(20, scrollup)

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
client = FakeGTKClient()
for wid in range(N):
anim = GLWindowAnim(client, wid)
glib.timeout_add(20, anim.scrollup)
try:
gtk_main()
except KeyboardInterrupt:
Expand Down

0 comments on commit 78e3bdd

Please sign in to comment.