Skip to content

Commit

Permalink
tests: add a repro for #1091
Browse files Browse the repository at this point in the history
Signed-off-by: Yuxuan Shui <[email protected]>
  • Loading branch information
yshui committed Feb 19, 2024
1 parent cffdd8e commit a203c1e
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
1 change: 1 addition & 0 deletions tests/configs/pull1091.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
unredir-if-possible = true;
1 change: 1 addition & 0 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ eval `dbus-launch --sh-syntax`
./run_one_test.sh $exe configs/clear_shadow_unredirected.conf testcases/redirect_when_unmapped_window_has_shadow.py
./run_one_test.sh $exe configs/issue394.conf testcases/issue394.py
./run_one_test.sh $exe configs/issue239.conf testcases/issue525.py
./run_one_test.sh $exe configs/pull1091.conf testcases/pull1091.py
8 changes: 6 additions & 2 deletions tests/testcases/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def set_window_size_async(conn, wid, width, height):
value_list = [width, height]
return conn.core.ConfigureWindowChecked(wid, value_mask, value_list)

def set_window_bypass_compositor(conn, wid, value = 1):
prop_name = to_atom(conn, "_NET_WM_BYPASS_COMPOSITOR")
return conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, prop_name, xproto.Atom.CARDINAL, 32, 1, [value])

def find_picom_window(conn):
prop_name = to_atom(conn, "WM_NAME")
setup = conn.get_setup()
Expand All @@ -45,13 +49,13 @@ def find_picom_window(conn):
if name.value.buf() == b"picom":
return w

def prepare_root_configure(conn):
def prepare_root_configure(conn, size = 1000):
setup = conn.get_setup()
root = setup.roots[0].root
# Xorg sends root ConfigureNotify when we add a new mode to an output
rr = conn(randr.key)
name = ''.join([random.choice(string.ascii_letters + string.digits) for n in range(0, 32)])
mode_info = randr.ModeInfo.synthetic(id = 0, width = 1000, height = 1000, dot_clock = 0,
mode_info = randr.ModeInfo.synthetic(id = 0, width = size, height = size, dot_clock = 0,
hsync_start = 0, hsync_end = 0, htotal = 0, hskew = 0, vsync_start = 0, vsync_end = 0,
vtotal = 0, name_len = len(name), mode_flags = 0)

Expand Down
2 changes: 1 addition & 1 deletion tests/testcases/issue314.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import xcffib.xproto as xproto
import xcffib
import time
from common import set_window_name, trigger_root_configure
from common import set_window_name

conn = xcffib.connect()
setup = conn.get_setup()
Expand Down
41 changes: 41 additions & 0 deletions tests/testcases/pull1091.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3

import xcffib.xproto as xproto
import xcffib
from common import *

conn = xcffib.connect()
setup = conn.get_setup()
root = setup.roots[0].root
visual = setup.roots[0].root_visual
depth = setup.roots[0].root_depth

# assertion failure mentioned in 1091 happens when a root change happens right after we
# redirected the screen, before we have even rendered a single frame
wid = conn.generate_id()
print("Window id is ", hex(wid))

# Create a window
conn.core.CreateWindowChecked(depth, wid, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check()

# Map the window
print("mapping")
conn.core.MapWindowChecked(wid).check()

time.sleep(0.5)

for i in range(0, 8):
modes = []
for s in range(0, 10):
reply, mode, output = prepare_root_configure(conn, i * 100 + 100 + s)
modes.append((reply, mode, output))

set_window_bypass_compositor(conn, wid).check()
time.sleep(0.1)

set_window_bypass_compositor(conn, wid, 0)
conn.flush()
for reply, mode, output in modes:
trigger_root_configure(conn, reply, mode, output).reply()

time.sleep(0.1)

0 comments on commit a203c1e

Please sign in to comment.