From df67fb2508ad75c08b8b24729d0466c818c252c5 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sat, 28 Sep 2019 23:18:43 +0100 Subject: [PATCH] tests: add testcase for #239, bug number 2 If a window is unmapped during the draw_callback re-run when the screen is just redirected, that window won't get a chance to acquire a pixmap. If fading is enabled, the compositor will try to render that window and crash. Signed-off-by: Yuxuan Shui --- tests/configs/issue239_2.conf | 8 ++++++ tests/run_tests.sh | 1 + tests/testcases/issue239_2.py | 49 +++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 tests/configs/issue239_2.conf create mode 100755 tests/testcases/issue239_2.py diff --git a/tests/configs/issue239_2.conf b/tests/configs/issue239_2.conf new file mode 100644 index 0000000..5f89f47 --- /dev/null +++ b/tests/configs/issue239_2.conf @@ -0,0 +1,8 @@ +fading = true; +fade-in-step = 1; +fade-out-step = 0.01; +shadow = true; +shadow-exclude = [ +"name = 'NoShadow'" +] +unredir-if-possible = true; diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 6f78790..ca8f416 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -5,3 +5,4 @@ cd $(dirname $0) ./run_one_test.sh $compton configs/empty.conf testcases/basic.py ./run_one_test.sh $compton configs/issue239.conf testcases/issue239.py +./run_one_test.sh $compton configs/issue239_2.conf testcases/issue239_2.py diff --git a/tests/testcases/issue239_2.py b/tests/testcases/issue239_2.py new file mode 100755 index 0000000..4d6c5d7 --- /dev/null +++ b/tests/testcases/issue239_2.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +import xcffib.xproto as xproto +import xcffib +import time + +conn = xcffib.connect() +setup = conn.get_setup() +root = setup.roots[0].root +visual = setup.roots[0].root_visual +depth = setup.roots[0].root_depth + +# issue 239 is caused by a window gaining a shadow during its fade-out transition +wid = conn.generate_id() +print("Window ids are ", hex(wid)) + +# Create a window +mask = xproto.CW.BackPixel +value = [ setup.roots[0].white_pixel ] +conn.core.CreateWindowChecked(depth, wid, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, mask, value).check() + +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 + + +# Map the window +conn.core.MapWindowChecked(wid).check() + +time.sleep(0.5) + +conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, name_atom, atom_atom, 32, 1, [fs_atom]).check() + +time.sleep(0.5) + +conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, name_atom, atom_atom, 32, 0, []).check() + +conn.core.GetInputFocus().reply() + +# Unmap the window +conn.core.UnmapWindowChecked(wid).check() + +time.sleep(0.5) + +# Destroy the window +conn.core.DestroyWindowChecked(wid).check()