tests: reduce some code duplication
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
323a59b933
commit
b109526e15
|
@ -3,6 +3,7 @@
|
||||||
import xcffib.xproto as xproto
|
import xcffib.xproto as xproto
|
||||||
import xcffib
|
import xcffib
|
||||||
import time
|
import time
|
||||||
|
from common import set_window_name
|
||||||
|
|
||||||
conn = xcffib.connect()
|
conn = xcffib.connect()
|
||||||
setup = conn.get_setup()
|
setup = conn.get_setup()
|
||||||
|
@ -18,13 +19,7 @@ print("Window id is ", hex(wid))
|
||||||
conn.core.CreateWindowChecked(depth, wid, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check()
|
conn.core.CreateWindowChecked(depth, wid, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check()
|
||||||
|
|
||||||
# Set Window name so it doesn't get a shadow
|
# Set Window name so it doesn't get a shadow
|
||||||
name = "_NET_WM_NAME"
|
set_window_name(conn, wid, "NoShadow")
|
||||||
name_atom = conn.core.InternAtom(True, len(name), name).reply().atom
|
|
||||||
str_type = "STRING"
|
|
||||||
str_type_atom = conn.core.InternAtom(True, len(str_type), str_type).reply().atom
|
|
||||||
|
|
||||||
win_name = "NoShadow"
|
|
||||||
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, name_atom, str_type_atom, 8, len(win_name), win_name).check()
|
|
||||||
|
|
||||||
# Map the window
|
# Map the window
|
||||||
print("mapping")
|
print("mapping")
|
||||||
|
@ -34,8 +29,7 @@ time.sleep(0.5)
|
||||||
|
|
||||||
# Set the Window name so it gets a shadow
|
# Set the Window name so it gets a shadow
|
||||||
print("set new name")
|
print("set new name")
|
||||||
win_name = "YesShadow"
|
set_window_name(conn, wid, "YesShadow")
|
||||||
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, name_atom, str_type_atom, 8, len(win_name), win_name).check()
|
|
||||||
|
|
||||||
# Unmap the window
|
# Unmap the window
|
||||||
conn.core.UnmapWindowChecked(wid).check()
|
conn.core.UnmapWindowChecked(wid).check()
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import xcffib.xproto as xproto
|
import xcffib.xproto as xproto
|
||||||
import xcffib
|
import xcffib
|
||||||
import time
|
import time
|
||||||
|
from common import set_window_name
|
||||||
|
|
||||||
conn = xcffib.connect()
|
conn = xcffib.connect()
|
||||||
setup = conn.get_setup()
|
setup = conn.get_setup()
|
||||||
|
@ -17,14 +18,8 @@ print("Window id is ", hex(wid))
|
||||||
# Create a window
|
# Create a window
|
||||||
conn.core.CreateWindowChecked(depth, wid, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check()
|
conn.core.CreateWindowChecked(depth, wid, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check()
|
||||||
|
|
||||||
# Set Window name so it doesn't get a shadow
|
# Set Window name so it gets a shadow
|
||||||
name = "_NET_WM_NAME"
|
set_window_name(conn, wid, "YesShadow")
|
||||||
name_atom = conn.core.InternAtom(True, len(name), name).reply().atom
|
|
||||||
str_type = "STRING"
|
|
||||||
str_type_atom = conn.core.InternAtom(True, len(str_type), str_type).reply().atom
|
|
||||||
|
|
||||||
win_name = "YesShadow"
|
|
||||||
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, name_atom, str_type_atom, 8, len(win_name), win_name).check()
|
|
||||||
|
|
||||||
# Map the window
|
# Map the window
|
||||||
print("mapping")
|
print("mapping")
|
||||||
|
@ -33,15 +28,13 @@ conn.core.MapWindowChecked(wid).check()
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
print("set new name")
|
print("set new name")
|
||||||
win_name = "NoShadow"
|
set_window_name(conn, wid, "NoShadow")
|
||||||
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, name_atom, str_type_atom, 8, len(win_name), win_name).check()
|
|
||||||
|
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
# Set the Window name so it gets a shadow
|
# Set the Window name so it gets a shadow
|
||||||
print("set new name")
|
print("set new name")
|
||||||
win_name = "YesShadow"
|
set_window_name(conn, wid, "YesShadow")
|
||||||
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, name_atom, str_type_atom, 8, len(win_name), win_name).check()
|
|
||||||
|
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import xcffib.xproto as xproto
|
import xcffib.xproto as xproto
|
||||||
import xcffib
|
import xcffib
|
||||||
import time
|
import time
|
||||||
|
from common import set_window_name
|
||||||
|
|
||||||
conn = xcffib.connect()
|
conn = xcffib.connect()
|
||||||
setup = conn.get_setup()
|
setup = conn.get_setup()
|
||||||
|
@ -17,14 +18,8 @@ print("Window id is ", hex(wid))
|
||||||
# Create a window
|
# Create a window
|
||||||
conn.core.CreateWindowChecked(depth, wid, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check()
|
conn.core.CreateWindowChecked(depth, wid, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check()
|
||||||
|
|
||||||
# Set Window name so it doesn't get a shadow
|
# Set Window name so it gets a shadow
|
||||||
name = "_NET_WM_NAME"
|
set_window_name(conn, wid, "YesShadow")
|
||||||
name_atom = conn.core.InternAtom(True, len(name), name).reply().atom
|
|
||||||
str_type = "STRING"
|
|
||||||
str_type_atom = conn.core.InternAtom(True, len(str_type), str_type).reply().atom
|
|
||||||
|
|
||||||
win_name = "YesShadow"
|
|
||||||
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, name_atom, str_type_atom, 8, len(win_name), win_name).check()
|
|
||||||
|
|
||||||
# Map the window
|
# Map the window
|
||||||
print("mapping")
|
print("mapping")
|
||||||
|
@ -33,13 +28,11 @@ conn.core.MapWindowChecked(wid).check()
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
print("set new name")
|
print("set new name")
|
||||||
win_name = "NoShadow"
|
set_window_name(conn, wid, "NoShadow")
|
||||||
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, name_atom, str_type_atom, 8, len(win_name), win_name).check()
|
|
||||||
|
|
||||||
# Set the Window name so it gets a shadow
|
# Set the Window name so it gets a shadow
|
||||||
print("set new name")
|
print("set new name")
|
||||||
win_name = "YesShadow"
|
set_window_name(conn, wid, "YesShadow")
|
||||||
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, name_atom, str_type_atom, 8, len(win_name), win_name).check()
|
|
||||||
|
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue