| #!/usr/bin/python2 | |
| # How to test: | |
| # | |
| # 1. Minimize all windows belonging to the VM, except for one terminal. | |
| # 2. Run "sleep 10; ./window.py" in the terminal. | |
| # 3. Focus a window from another VM before the popup appears. | |
| # 4. Move the pointer to the popup without travelling through the terminal. | |
| # 5. Click on the popup. | |
| # | |
| # The popup window will receive mouse clicks, but no keyboard input. | |
| import xcb | |
| from xcb.xproto import * | |
| override_redirect = True | |
| #override_redirect = False | |
| conn = xcb.connect() | |
| root = conn.get_setup().roots[0] | |
| window = conn.generate_id() | |
| conn.core.CreateWindow(root.root_depth, window, root.root, 0, 0, 234, 234, 0, | |
| WindowClass.InputOutput, root.root_visual, | |
| CW.BackPixel | CW.OverrideRedirect | CW.EventMask, | |
| [ | |
| root.white_pixel, | |
| override_redirect, | |
| 2**25 - 1 # subscribe to all events | |
| ]) | |
| conn.core.MapWindow(window) | |
| #conn.core.SetInputFocus(InputFocus._None, window, Time.CurrentTime) | |
| conn.core.GrabKeyboard(True, root.root, Time.CurrentTime, | |
| GrabMode.Async, GrabMode.Async) | |
| conn.flush() | |
| while True: | |
| event = conn.wait_for_event() | |
| print(event.__class__.__name__) | |
| # exit on middle mouse button, Escape key, or WM_DELETE_WINDOW | |
| if (isinstance(event, ButtonPressEvent) and event.detail == 2) or \ | |
| (isinstance(event, KeyPressEvent) and event.detail == 9) or \ | |
| (isinstance(event, ClientMessageEvent) and event.data.data32[0] == 240): | |
| exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment