More work on cthulhu recognizing focused items that should be read.
This commit is contained in:
1 parent
9374b5a2e5
commit
300f4a7504
9 files changed
+456
-9
No files matched your search
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2026 Storm Dragon
|
||||
# Authors: Storm Dragon, Angus Kola
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Real GTK socket/plug embedding on separate providers for private tests."""
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Atk", "1.0")
|
||||
gi.require_version("GdkX11", "3.0")
|
||||
from gi.repository import Atk, GdkX11, GLib, Gtk
|
||||
|
||||
|
||||
mode = sys.argv[1]
|
||||
processName = "mate-panel" if mode == "panel" else "applet" if mode == "standalone" else mode
|
||||
GLib.set_prgname(processName)
|
||||
if ctypes.CDLL(None).prctl(15, processName.encode(), 0, 0, 0) != 0:
|
||||
raise RuntimeError("cannot set fixture process name")
|
||||
window = Gtk.Plug.new(int(sys.argv[2])) if mode == "applet" else Gtk.Window()
|
||||
if mode == "applet":
|
||||
window.connect("delete-event", lambda *_args: True)
|
||||
if mode == "standalone":
|
||||
Atk.get_root().set_name("mate-panel")
|
||||
window.set_title("Embedded applet fixture " + mode)
|
||||
window.set_default_size(400, 120)
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
window.add(box)
|
||||
socket = None
|
||||
if mode in ("applet", "standalone"):
|
||||
box.get_accessible().set_role(Atk.Role.PANEL)
|
||||
box.get_accessible().set_name("Network applet")
|
||||
first = Gtk.Button(label="Network")
|
||||
first.get_accessible().set_role(Atk.Role.ICON)
|
||||
first.get_accessible().set_name("")
|
||||
second = Gtk.Button(label="Applet settings")
|
||||
box.add(first)
|
||||
box.add(second)
|
||||
elif mode == "editor":
|
||||
first = Gtk.Entry()
|
||||
first.get_accessible().set_name("Editor entry")
|
||||
box.add(first)
|
||||
else:
|
||||
first = Gtk.Button(label="Before applet")
|
||||
second = Gtk.Button(label="After applet")
|
||||
socket = Gtk.Socket()
|
||||
box.add(first)
|
||||
box.add(socket)
|
||||
box.add(second)
|
||||
barrier = Gtk.Label()
|
||||
barrier.get_accessible().set_role(Atk.Role.ALERT)
|
||||
box.add(barrier)
|
||||
window.show_all()
|
||||
pendingInput = ""
|
||||
|
||||
|
||||
def receive_command(_source, _condition):
|
||||
global pendingInput
|
||||
content = os.read(sys.stdin.fileno(), 4096)
|
||||
if not content:
|
||||
Gtk.main_quit()
|
||||
return False
|
||||
pendingInput += content.decode()
|
||||
while "\n" in pendingInput:
|
||||
command, pendingInput = pendingInput.split("\n", 1)
|
||||
if command == "first":
|
||||
first.grab_focus()
|
||||
elif command == "second":
|
||||
second.grab_focus()
|
||||
elif command == "stale":
|
||||
first.get_accessible().notify_state_change(Atk.StateType.FOCUSED, True)
|
||||
barrier.set_text("")
|
||||
barrier.set_text("Applet barrier")
|
||||
elif command == "detach":
|
||||
socket.destroy()
|
||||
barrier.set_text("Detached host barrier")
|
||||
elif command.startswith("edit "):
|
||||
first.set_text(command.removeprefix("edit "))
|
||||
first.grab_focus()
|
||||
elif command == "quit":
|
||||
Gtk.main_quit()
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
GLib.io_add_watch(sys.stdin, GLib.IO_IN | GLib.IO_HUP, receive_command)
|
||||
GLib.idle_add(lambda: print(
|
||||
"ready", GdkX11.X11Window.get_xid(window.get_window()),
|
||||
socket.get_id() if socket is not None else 0, flush=True) or False)
|
||||
Gtk.main()
|
||||
@@ -24,6 +24,9 @@ if providerName == "marco":
|
||||
raise RuntimeError("cannot set fixture process name")
|
||||
|
||||
window = Gtk.Window(title="Switcher fixture " + providerName)
|
||||
# Label updates must not resize the foreground window while the test compares
|
||||
# its full X11 snapshot to check that the switcher has not taken ownership.
|
||||
window.set_default_size(400, 100)
|
||||
if providerName == "marco":
|
||||
window.set_accept_focus(False)
|
||||
window.set_focus_on_map(False)
|
||||
|
||||
Reference in new issue
Block a user