Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* add better colour handling
* handle (logging) button events in fake client class

git-svn-id: https://xpra.org/svn/Xpra/trunk@12880 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 22, 2016
1 parent 727f6c2 commit 4e2b398
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/tests/xpra/clients/fake_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def handle_key_action(self, *args):
def send_mouse_position(self, *args):
log.info("send_mouse_position(%s)", args)

def send_button(self, *args):
log.info("send_button%s", args)

def send_configure_event(self, skip_geometry):
log.info("send_configure_event(%s)", skip_geometry)

Expand Down
31 changes: 17 additions & 14 deletions src/tests/xpra/clients/test_gl_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# later version. See the file COPYING for details.

import math
import struct
from xpra.log import Logger
log = Logger()

Expand Down Expand Up @@ -51,52 +52,54 @@ def paint_window(window):
"00be0d210000019a60e1d50000000049454e44ae426082")
window.draw_region((W-256)//2, (H-256)//2, 256, 256, "png", img_data, W*4, 0, typedict(), [])

def paint_rect(window, x=200, y=200, w=32, h=32, color=0x80, options=typedict()):
def paint_rect(window, x=200, y=200, w=32, h=32, color=0x80808080, options=typedict()):
print("paint_rect%s" % ((x, y, w, h),))
W, H = window.get_size()
img_data = chr(color)*w*4*h
c = struct.pack("@I", color)
img_data = c*w*h
window.draw_region(x, y, w, h, "rgb32", img_data, w*4, 0, typedict(options), [])

def paint_and_scroll(window, ydelta=10, color=0xA0):
def paint_and_scroll(window, ydelta=10, color=0xA0A0A0A):
print("paint_and_scroll(%i, %#x)" % (ydelta, color))
W, H = window.get_size()
if ydelta>0:
#scroll down, repaint the top:
client_options = {"scrolls" : ((0, 0, W, H-ydelta, ydelta),) }
window.draw_region(0, 0, W, H, "scroll", "", W*4, 0, typedict(client_options), [])
paint_rect(window, 0, 0, W, ydelta, color)
#paint_rect(window, 0, 0, W, ydelta, color)
else:
#scroll up, repaint the bottom:
client_options = {"scrolls" : ((0, -ydelta, W, H+ydelta, ydelta),) }
window.draw_region(0, 0, W, H, "scroll", "", W*4, 0, typedict(client_options), [])
paint_rect(window, 0, H-ydelta, W, -ydelta, color)
#paint_rect(window, 0, H-ydelta, W, -ydelta, color)

def split_scroll(window):
def split_scroll(window, i=1):
W, H = window.get_size()
scrolls = [
(0, 1, W, H//2-1, -1),
(0, H//2, W, H//2-1, 1),
(0, i, W, H//2, -i),
(0, H//2, W, H//2-i, i),
]
window.draw_region(0, 0, W, H, "scroll", "", W*4, 0, typedict({"scrolls" : scrolls}), [])


def main():
W = 640
H = 480
client = fake_gtk_client()
window = GLClientWindow(client, None, 1, 10, 10, W, H, W, H, typedict({}), False, typedict({}), 0, None)
window.show()
glib.timeout_add(0, paint_rect, window, 0, 0, W, H, 0xFF)
glib.timeout_add(0, paint_rect, window, 0, 0, W, H, 0xFFFFFFFF)
glib.timeout_add(0, paint_window, window)
for i in range(4):
glib.timeout_add(500, paint_rect, window, W//4*i + W//8, 100, 32, 32, 0x30*i)
for i in range(50):
glib.timeout_add(1000+i*20, paint_rect, window, int(W//3+math.sin(i/10.0)*64), H//2-32)
glib.timeout_add(1000+i*20, paint_rect, window, int(W//3+math.sin(i/10.0)*128), int(H//2-32+math.cos(i/10.0)*64))
glib.timeout_add(1000+i*20, paint_and_scroll, window, -1)
glib.timeout_add(2000+i*20, paint_rect, window, int(W//3*2-math.sin(i/10.0)*64), H//2-16, 32, 32, 0x10)
glib.timeout_add(2000+i*20, paint_rect, window, int(W//3*2-math.sin(i/10.0)*128), int(H//2-16-math.cos(i/10.0)*64), 32, 32, 0x10)
glib.timeout_add(2000+i*20, paint_and_scroll, window, +1)
for i in range(200):
glib.timeout_add(4000+i*20, split_scroll, window)
glib.timeout_add(4000+i*20, split_scroll, window, max(1, i//50))
glib.timeout_add(4000+i*20, paint_rect, window, 0, H//2-1, W, 2, i+i*0x100)

try:
gtk.main()
except KeyboardInterrupt:
Expand Down

0 comments on commit 4e2b398

Please sign in to comment.