| 1 |
|
| 2 |
|
| 3 |
import xcffib.xproto as xproto |
| 4 |
import xcffib |
| 5 |
import time |
| 6 |
import os |
| 7 |
import subprocess |
| 8 |
import asyncio |
| 9 |
from dbus_next.aio import MessageBus |
| 10 |
from dbus_next.message import Message, MessageType |
| 11 |
from common import * |
| 12 |
|
| 13 |
display = os.environ["DISPLAY"].replace(":", "_") |
| 14 |
conn = xcffib.connect() |
| 15 |
setup = conn.get_setup() |
| 16 |
root = setup.roots[0].root |
| 17 |
visual = setup.roots[0].root_visual |
| 18 |
depth = setup.roots[0].root_depth |
| 19 |
x = xproto.xprotoExtension(conn) |
| 20 |
visual32 = find_32bit_visual(conn) |
| 21 |
|
| 22 |
async def get_client_win_async(wid): |
| 23 |
message = await bus.call(Message(destination='com.github.chjj.compton.'+display, |
| 24 |
path='/com/github/chjj/compton', |
| 25 |
interface='com.github.chjj.compton', |
| 26 |
member='win_get', |
| 27 |
signature='us', |
| 28 |
body=[wid, 'client_win'])) |
| 29 |
return message.body[0] |
| 30 |
|
| 31 |
def get_client_win(wid): |
| 32 |
return loop.run_until_complete(get_client_win_async(wid)) |
| 33 |
|
| 34 |
def wait(): |
| 35 |
time.sleep(0.5) |
| 36 |
|
| 37 |
def create_client_window(name): |
| 38 |
client_win = conn.generate_id() |
| 39 |
print("Window : ", hex(client_win)) |
| 40 |
conn.core.CreateWindowChecked(depth, client_win, root, 0, 0, 100, 100, 0, |
| 41 |
xproto.WindowClass.InputOutput, visual, 0, []).check() |
| 42 |
set_window_name(conn, client_win, "Test window "+name) |
| 43 |
set_window_class(conn, client_win, "Test windows") |
| 44 |
set_window_state(conn, client_win, 1) |
| 45 |
conn.core.MapWindowChecked(client_win).check() |
| 46 |
return client_win |
| 47 |
|
| 48 |
loop = asyncio.get_event_loop() |
| 49 |
bus = loop.run_until_complete(MessageBus().connect()) |
| 50 |
|
| 51 |
cmid = conn.generate_id() |
| 52 |
colormap = conn.core.CreateColormapChecked(xproto.ColormapAlloc._None, cmid, root, visual32).check() |
| 53 |
|
| 54 |
|
| 55 |
client_wins = [] |
| 56 |
for i in range(0,2): |
| 57 |
client_wins.append(create_client_window(str(i))) |
| 58 |
|
| 59 |
|
| 60 |
frame_win = conn.generate_id() |
| 61 |
print("Window : ", hex(frame_win)) |
| 62 |
conn.core.CreateWindowChecked(depth, frame_win, root, 0, 0, 200, 200, 0, |
| 63 |
xproto.WindowClass.InputOutput, visual, 0, []).check() |
| 64 |
set_window_name(conn, frame_win, "Frame") |
| 65 |
conn.core.MapWindowChecked(frame_win).check() |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
conn.core.ReparentWindowChecked(client_wins[0], frame_win, 0, 0).check() |
| 70 |
wait() |
| 71 |
|
| 72 |
conn.core.ReparentWindowChecked(client_wins[1], frame_win, 0, 0).check() |
| 73 |
wait() |
| 74 |
|
| 75 |
conn.core.ReparentWindowChecked(client_wins[0], root, 0, 0).check() |
| 76 |
wait() |
| 77 |
assert get_client_win(frame_win) == client_wins[1] |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
conn.core.ReparentWindowChecked(client_wins[0], frame_win, 0, 0).check() |
| 82 |
wait() |
| 83 |
|
| 84 |
conn.core.ReparentWindowChecked(client_wins[1], frame_win, 0, 0).check() |
| 85 |
wait() |
| 86 |
|
| 87 |
conn.core.DestroyWindowChecked(client_wins[0]).check() |
| 88 |
wait() |
| 89 |
assert get_client_win(frame_win) == client_wins[1] |
| 90 |
|
| 91 |
client_wins[0] = create_client_window("0") |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
conn.core.UnmapWindowChecked(frame_win).check() |
| 96 |
wait() |
| 97 |
|
| 98 |
conn.core.ReparentWindowChecked(client_wins[0], frame_win, 0, 0).check() |
| 99 |
wait() |
| 100 |
|
| 101 |
conn.core.DestroyWindowChecked(client_wins[0]).check() |
| 102 |
conn.core.MapWindowChecked(frame_win).check() |
| 103 |
conn.core.ReparentWindowChecked(client_wins[1], frame_win, 0, 0).check() |
| 104 |
wait() |
| 105 |
assert get_client_win(frame_win) == client_wins[1] |
| 106 |
|
| 107 |
client_wins[0] = create_client_window("0") |
| 108 |
|
| 109 |
|
| 110 |
for wid in client_wins: |
| 111 |
conn.core.DestroyWindowChecked(wid).check() |
| 112 |
conn.core.DestroyWindowChecked(frame_win).check() |