From 2d54942295c5100753b2faf2d0a2b70ef706e06f Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Fri, 27 Nov 2020 20:35:09 +0000 Subject: [PATCH] testcase: add redirect_when_unmapped_window_has_shadow While working on this PR, I introduced a bug where shadow images for unmapped windows aren't properly recreated after unredirect/redirect. The shadow image is freed during unredirect, OTOH redirect only set IMAGE_STALE flags for mapped window, thus the shadow images for unmapped windows will be missing. This bug is already fixed in the previous commit. But the testcase is good to keep nonetheless. Signed-off-by: Yuxuan Shui --- tests/run_tests.sh | 1 + ...edirect_when_unmapped_window_has_shadow.py | 65 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100755 tests/testcases/redirect_when_unmapped_window_has_shadow.py diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 6c871dec..3eec3789 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -17,4 +17,5 @@ eval `dbus-launch --sh-syntax` ./run_one_test.sh $exe /dev/null testcases/issue299.py ./run_one_test.sh $exe configs/issue465.conf testcases/issue465.py ./run_one_test.sh $exe configs/clear_shadow_unredirected.conf testcases/clear_shadow_unredirected.py +./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 diff --git a/tests/testcases/redirect_when_unmapped_window_has_shadow.py b/tests/testcases/redirect_when_unmapped_window_has_shadow.py new file mode 100755 index 00000000..aeceb33c --- /dev/null +++ b/tests/testcases/redirect_when_unmapped_window_has_shadow.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +import xcffib.xproto as xproto +import xcffib +import time +from common import set_window_name + +conn = xcffib.connect() +setup = conn.get_setup() +root = setup.roots[0].root +visual = setup.roots[0].root_visual +depth = setup.roots[0].root_depth + +name = "_NET_WM_STATE" +name_atom = conn.core.InternAtom(False, len(name), name).reply().atom +atom = "ATOM" +atom_atom = conn.core.InternAtom(False, len(atom), atom).reply().atom +fs = "_NET_WM_STATE_FULLSCREEN" +fs_atom = conn.core.InternAtom(False, len(fs), fs).reply().atom + +wid1 = conn.generate_id() +print("Window 1 id is ", hex(wid1)) + +# Create a window +conn.core.CreateWindowChecked(depth, wid1, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check() + +# Map the window +print("mapping 1") +conn.core.MapWindowChecked(wid1).check() + +time.sleep(0.5) + +print("unmapping 1") +# Unmap the window +conn.core.UnmapWindowChecked(wid1).check() + +time.sleep(0.5) + +# create and map a second window +wid2 = conn.generate_id() +print("Window 2 id is ", hex(wid2)) +conn.core.CreateWindowChecked(depth, wid2, root, 200, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check() +print("mapping 2") +conn.core.MapWindowChecked(wid2).check() +time.sleep(0.5) + +# Set fullscreen property on the second window, causing screen to be unredirected +conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid2, name_atom, atom_atom, 32, 1, [fs_atom]).check() + +time.sleep(0.5) + +# Unset fullscreen property on the second window, causing screen to be redirected +conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid2, name_atom, atom_atom, 32, 0, []).check() + +time.sleep(0.5) + +# map the first window again +print("mapping 1") +conn.core.MapWindowChecked(wid1).check() + +time.sleep(0.5) + +# Destroy the windows +conn.core.DestroyWindowChecked(wid1).check() +conn.core.DestroyWindowChecked(wid2).check()