Skip to content

Commit

Permalink
#3978 more refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Sep 28, 2023
1 parent 7aaaccd commit 8d50203
Show file tree
Hide file tree
Showing 206 changed files with 936 additions and 846 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ tests/unittests/test-file*
/xpra/codecs/*/*.cpp
/xpra/codecs/*/*.c
/xpra/codecs/*.c
/xpra/gtk_common/*.c
/xpra/gtk_common/dialogs/*.c
/xpra/gtk_common/examples/*.c
/xpra/gtk/*.c
/xpra/gtk/dialogs/*.c
/xpra/gtk/examples/*.c
/xpra/gtk/bindings/*.c
/xpra/gstreamer/*.c
/xpra/keyboard/*.c
/xpra/net/*/*/*.c
Expand Down
2 changes: 1 addition & 1 deletion docs/Subsystems/Clipboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ It contains common features such as basic configuration, scheduling, filtering,
| `x11` | [xpra.x11.gtk_x11.clipboard](../../xpra/x11/gtk_x11/clipboard.py) |
| `win32` | [xpra.platform.win32.clipboard](../../xpra/platform/win32/clipboard.py) |
| `MacOS` | [xpra.platform.darwin.clipboard](../../xpra/platform/darwin/clipboard.py) |
| others | [xpra.gtk_common.gtk_clipboard](../../xpra/gtk_common/clipboard.py) |
| others | [xpra.gtk_common.gtk_clipboard](../../xpra/gtk/clipboard.py) |



Expand Down
2 changes: 1 addition & 1 deletion fs/libexec/xpra/auth_dialog
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

import sys

from xpra.gtk_common.dialogs.auth_dialog import main
from xpra.gtk.dialogs.auth_dialog import main
sys.exit(main())
59 changes: 29 additions & 30 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def has_header_file(name, isdir=False):
"server", "client", "shadow",
"rencodeplus", "brotli", "qrencode", "websockets", "netdev", "vsock",
"lz4",
"gtk3", "x11", "gtk_x11",
"bindings", "x11", "gtk_x11",
"pam", "sd_listen", "proc",
),
}
Expand Down Expand Up @@ -1131,14 +1131,13 @@ def clean():
#ensure we remove the files we generate:
CLEAN_FILES = [
"xpra/build_info.py",
"xpra/gtk_common/gtk3/gdk_atoms.c",
"xpra/gtk_common/gtk3/gdk_bindings.c",
"xpra/x11/gtk3/gdk_bindings.c",
"xpra/x11/gtk3/gdk_display_source.c",
"xpra/gtk/bindings/atoms.c",
"xpra/gtk/bindings/gdk_bindings.c",
"xpra/x11/bindings/gdk_bindings.c",
"xpra/x11/bindings/display_source.c",
"xpra/x11/bindings/xwait.c",
"xpra/x11/bindings/wait_for_x_server.c",
"xpra/x11/bindings/keyboard.c",
"xpra/x11/bindings/display_source.c",
"xpra/x11/bindings/events.c",
"xpra/x11/bindings/window.c",
"xpra/x11/bindings/randr.c",
Expand Down Expand Up @@ -1188,11 +1187,11 @@ def clean():
"xpra/codecs/drm/drm.c",
"xpra/codecs/webp/encoder.c",
"xpra/codecs/webp/decoder.c",
"xpra/codecs/libyuv/colorspace_converter.cpp",
"xpra/codecs/csc_cython/colorspace_converter.c",
"xpra/codecs/libyuv/converter.cpp",
"xpra/codecs/csc_cython/converter.c",
"xpra/codecs/argb/argb.c",
"xpra/codecs/nvapi_version.c",
"xpra/gtk_common/gdk_atoms.c",
"xpra/gtk/bindings/atoms.c",
"xpra/client/gtk3/cairo_workaround.c",
"xpra/server/cystats.c",
"xpra/util/rectangle.c",
Expand All @@ -1212,7 +1211,7 @@ def clean():
#on win32, the build creates ".pyd" files, clean those too:
CLEAN_FILES.append(p+".pyd")
#when building with python3, we need to clean files named like:
#"xpra/codecs/csc_libyuv/colorspace_converter-cpython-36m.dll"
#"xpra/codecs/csc_libyuv/converter-cpython-36m.dll"
filename = os.path.join(os.getcwd(), p.replace("/", os.path.sep)+"*.dll")
CLEAN_FILES += glob.glob(filename)
if 'clean' in sys.argv:
Expand Down Expand Up @@ -1564,8 +1563,8 @@ def add_service_exe(script, icon, base_name):
add_gui_exe("xpra/platform/win32/scripts/shadow_server.py", "server-notconnected.ico", "Xpra-Shadow")
add_gui_exe("fs/bin/xpra_launcher", "xpra.ico", "Xpra-Launcher")
add_console_exe("fs/bin/xpra_launcher", "xpra.ico", "Xpra-Launcher-Debug")
add_gui_exe("xpra/gtk_common/dialogs/view_keyboard.py", "keyboard.ico", "GTK_Keyboard_Test")
add_gui_exe("xpra/gtk_common/dialogs/bug_report.py", "bugs.ico", "Bug_Report")
add_gui_exe("xpra/gtk/dialogs/view_keyboard.py", "keyboard.ico", "GTK_Keyboard_Test")
add_gui_exe("xpra/gtk/dialogs/bug_report.py", "bugs.ico", "Bug_Report")
add_gui_exe("xpra/platform/win32/gdi_screen_capture.py", "screenshot.ico", "Screenshot")
if server_ENABLED:
add_gui_exe("fs/libexec/xpra/auth_dialog", "authentication.ico", "Auth_Dialog")
Expand All @@ -1575,10 +1574,10 @@ def add_service_exe(script, icon, base_name):
add_console_exe("xpra/net/net_util.py", "network.ico", "Network_info")
if gtk3_ENABLED:
add_console_exe("xpra/scripts/gtk_info.py", "gtk.ico", "GTK_info")
add_console_exe("xpra/gtk_common/keymap.py", "keymap.ico", "Keymap_info")
add_console_exe("xpra/gtk/keymap.py", "keymap.ico", "Keymap_info")
add_console_exe("xpra/platform/keyboard.py", "keymap.ico", "Keyboard_info")
add_gui_exe("xpra/gtk_common/examples/tray.py", "xpra.ico", "SystemTray_Test")
add_gui_exe("xpra/client/gtk3/u2f_tool.py", "authentication.ico", "U2F_Tool")
add_gui_exe("xpra/gtk/examples/tray.py", "xpra.ico", "SystemTray_Test")
add_gui_exe("xpra/client/bindings/u2f_tool.py", "authentication.ico", "U2F_Tool")
if client_ENABLED or server_ENABLED:
add_console_exe("xpra/platform/win32/scripts/exec.py", "python.ico", "Python_exec_cmd")
add_console_exe("xpra/platform/win32/scripts/execfile.py", "python.ico", "Python_execfile_cmd")
Expand Down Expand Up @@ -2069,8 +2068,8 @@ def noop(*_args, **_kwargs): # pylint: disable=function-redefined
toggle_packages(gtk_x11_ENABLED, "xpra.x11.gtk_x11")
toggle_packages(server_ENABLED and gtk_x11_ENABLED, "xpra.x11.models", "xpra.x11.desktop", "xpra.x11.server")
if gtk_x11_ENABLED:
add_packages("xpra.x11.gtk3")
ace("xpra.x11.gtk3.gdk_display_source", "gdk-3.0")
add_packages("xpra.x11.bindings")
ace("xpra.x11.bindings.display_source", "gdk-3.0")
ace("xpra.x11.gtk3.gdk_bindings,xpra/x11/gtk3/gdk_x11_macros.c", "gdk-3.0,xdamage")

tace(client_ENABLED and gtk3_ENABLED, "xpra.client.gtk3.cairo_workaround", "py3cairo",
Expand All @@ -2091,19 +2090,19 @@ def bundle_tests():
bundle_tests()


#special case for client: cannot use toggle_packages which would include gtk3, etc:
#special case for client: cannot use toggle_packages which would include bindings, etc:
if client_ENABLED:
add_modules("xpra.client")
add_packages("xpra.client.base")
add_packages("xpra.client.mixins", "xpra.client.auth")
add_modules("xpra.scripts.gtk_info", "xpra.scripts.show_webcam", "xpra.scripts.pinentry_wrapper")
if gtk3_ENABLED:
add_modules("xpra.scripts.bug_report", "xpra.scripts.splash")
toggle_packages((client_ENABLED and gtk3_ENABLED) or audio_ENABLED or server_ENABLED, "xpra.gtk_common")
toggle_packages(client_ENABLED and gtk3_ENABLED, "xpra.client.gtk3", "xpra.client.gtk3", "xpra.client.gui")
toggle_packages((client_ENABLED and gtk3_ENABLED) or audio_ENABLED or server_ENABLED, "xpra.gtk")
toggle_packages(client_ENABLED and gtk3_ENABLED, "xpra.client.bindings", "xpra.client.bindings", "xpra.client.gui")
toggle_packages((client_ENABLED and gtk3_ENABLED) or (audio_ENABLED and WIN32 and MINGW_PREFIX), "gi")
toggle_packages(client_ENABLED and opengl_ENABLED and gtk3_ENABLED, "xpra.client.gl.gtk3")
toggle_packages(client_ENABLED and gtk3_ENABLED and example_ENABLED, "xpra.gtk_common.examples")
toggle_packages(client_ENABLED and opengl_ENABLED and gtk3_ENABLED, "xpra.client.gl.bindings")
toggle_packages(client_ENABLED and gtk3_ENABLED and example_ENABLED, "xpra.gtk.examples")
if client_ENABLED and WIN32 and MINGW_PREFIX:
ace("xpra.platform.win32.propsys,xpra/platform/win32/setappid.cpp",
language="c++",
Expand Down Expand Up @@ -2133,9 +2132,9 @@ def bundle_tests():
toggle_modules(audio_ENABLED and not (OSX or WIN32), "xpra.audio.pulseaudio")

toggle_packages(clipboard_ENABLED, "xpra.clipboard")
tace(clipboard_ENABLED, "xpra.gtk_common.gtk3.gdk_atoms", "gtk+-3.0")
toggle_packages(clipboard_ENABLED or gtk3_ENABLED, "xpra.gtk_common.gtk3")
tace(gtk3_ENABLED, "xpra.gtk_common.gtk3.gdk_bindings", "gtk+-3.0,pygobject-3.0")
tace(clipboard_ENABLED, "xpra.gtk.bindings.atoms", "gtk+-3.0")
toggle_packages(clipboard_ENABLED or gtk3_ENABLED, "xpra.gtk.bindings")
tace(gtk3_ENABLED, "xpra.gtk.bindings.gdk_bindings", "gtk+-3.0,pygobject-3.0")

tace(client_ENABLED or server_ENABLED, "xpra.buffers.cyxor", optimize=3)
tace(client_ENABLED or server_ENABLED or shadow_ENABLED, "xpra.util.rectangle", optimize=3)
Expand Down Expand Up @@ -2236,9 +2235,9 @@ def bundle_tests():
tace(avif_ENABLED, "xpra.codecs.avif.encoder", "libavif")
tace(avif_ENABLED, "xpra.codecs.avif.decoder", "libavif")
toggle_packages(csc_libyuv_ENABLED, "xpra.codecs.libyuv")
tace(csc_libyuv_ENABLED, "xpra.codecs.libyuv.colorspace_converter", "libyuv", language="c++")
tace(csc_libyuv_ENABLED, "xpra.codecs.libyuv.converter", "libyuv", language="c++")
toggle_packages(csc_cython_ENABLED, "xpra.codecs.csc_cython")
tace(csc_cython_ENABLED, "xpra.codecs.csc_cython.colorspace_converter", optimize=3)
tace(csc_cython_ENABLED, "xpra.codecs.csc_cython.converter", optimize=3)
toggle_packages(vpx_ENABLED, "xpra.codecs.vpx")
tace(vpx_ENABLED, "xpra.codecs.vpx.encoder", "vpx")
tace(vpx_ENABLED, "xpra.codecs.vpx.decoder", "vpx")
Expand Down Expand Up @@ -2297,10 +2296,10 @@ def ax(base):
if gstreamer_ENABLED:
ax("xpra.gstreamer")
if gtk3_ENABLED:
ax("xpra.gtk_common")
ax("xpra.gtk_common.dialogs")
ax("xpra.gtk")
ax("xpra.gtk.dialogs")
if example_ENABLED:
ax("xpra.gtk_common.examples")
ax("xpra.gtk.examples")
if keyboard_ENABLED:
ax("xpra.keyboard")
if http_ENABLED:
Expand Down
32 changes: 12 additions & 20 deletions tests/perf/test_measure_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from subprocess import Popen, PIPE, STDOUT

from xpra.exit_codes import exit_str
from xpra.gtk_common.gtk_util import get_root_size
from xpra.gtk.gtk_util import get_root_size
from xpra.log import Logger

log = Logger("util")
Expand Down Expand Up @@ -238,25 +238,18 @@ def get_stderr(command):
VNCVIEWER_VERSION = "TigerVNC Viewer %s" % (v_lines[0].split()[5])
print ("VNCVIEWER_VERSION=%s" % VNCVIEWER_VERSION)

#get svnversion, prefer directly from svn:
try:
SVN_VERSION = getoutput(["svnversion", "-n"]).split(":")[-1].strip()
except:
SVN_VERSION = ""
if not SVN_VERSION:
#fallback to getting it from xpra's src_info:
try:
from xpra.src_info import REVISION, LOCAL_MODIFICATIONS
SVN_VERSION = 'r%s' % REVISION
if LOCAL_MODIFICATIONS:
SVN_VERSION += "M"
except:
pass
if not SVN_VERSION:
from xpra.src_info import REVISION, LOCAL_MODIFICATIONS
VERSION = 'r%s' % REVISION
if LOCAL_MODIFICATIONS:
VERSION += "M"
except Exception:
VERSION = ""
if not VERSION:
#fallback to running python:
SVN_VERSION = getoutput(["python", "-c",
VERSION = getoutput(["python", "-c",
"from xpra.src_info import REVISION,LOCAL_MODIFICATIONS;print(('r%s%s' % (REVISION, ' M'[int(bool(LOCAL_MODIFICATIONS))])).strip())"])
print("Found xpra revision: '%s'" % str(SVN_VERSION))
print("Found xpra revision: '%s'" % str(VERSION))

WINDOW_MANAGER = os.environ.get("DESKTOP_SESSION", "unknown")

Expand Down Expand Up @@ -486,11 +479,10 @@ def with_server(start_server_command, stop_server_commands, in_tests, get_stats_
"Server Version" : server_version,
"Client Version" : client_version,
"Custom Params" : config.CUSTOM_PARAMS,
"SVN Version" : SVN_VERSION,
"Version" : VERSION,
"Encoding" : encoding,
"Quality" : quality,
"Speed" : speed,
"OpenGL" : opengl,
"Test Command" : get_command_name(test_command),
"Sample Duration (s)" : config.MEASURE_TIME,
"Sample Time (epoch)" : time.time(),
Expand Down Expand Up @@ -563,7 +555,7 @@ def get_command_name(command_arg):
name = config.TEST_NAMES.get(command_arg)
if name:
return name
except:
except Exception:
pass
if isinstance(command_arg, list):
c = command_arg[0] #["/usr/bin/xterm", "blah"] -> "/usr/bin/xterm"
Expand Down
20 changes: 10 additions & 10 deletions tests/scripts/pycallgraph
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ net = ['xpra.net.protocol.*',
'xpra.net.avahi*',
]
x11 = ['xpra.x11.*',
'xpra.gtk_common.error.*']
'xpra.gtk.error.*']
damage = [
#'xpra.server.source.*',
#'xpra.server.*._damage',
'xpra.server.region*',
'xpra.server.window*_source.*',
'xpra.server.video_subregion.*',
'xpra.server.batch_delay_calculator.*',
'xpra.gtk_common.pixbuf_to_rgb.*',
'xpra.gtk.pixbuf_to_rgb.*',
'xpra.deque.*',
'xpra.server.source_stats.*',
'xpra.server.window_stats.*']
Expand All @@ -51,7 +51,7 @@ mouse = ['xpra.*server*._process_pointer_position',
'xpra.*server*._process_button_action',
'xpra.*server*._process_mouse_common']
keyboard = [
'xpra.gtk_common.keys.*',
'xpra.gtk.keys.*',
'xpra.keyboard.*',
'xpra.x11.xkbhelper.*', 'xpra.x11.gtk_x11.keys.*',
'xpra.x11.server_keyboard_config.*',
Expand Down Expand Up @@ -90,18 +90,18 @@ bell = ['xpra.x11.gtk_x11.window.WindowModel.do_xpra_xkb_event',
misc = ['xpra.dotxpra.*', 'xpra.x11.bindings.wait_for_server.*',
'xpra.scripts.*', 'subprocess.*',
'multiprocessing.*',
'xpra.gtk_common.gobject_compat.*',
'xpra.gtk.gobject_compat.*',
'xpra.x11.gtk_x11.tray.*',
'xpra.codecs.version_info.*',
'xpra.version_util.*',
'xpra.gtk_common.gtk_util.add_gtk_version_info',
'xpra.gtk.gtk_util.add_gtk_version_info',
'xpra.build_info.*']

xsettings = ['xpra.platform.posix.xroot_props.*', 'xpra.platform.posix.xsettings.*', 'xpra.x11.xsettings_prop.*']
clipboard = ['xpra.clipboard.*',
'xpra.client.*.*clipboard_helper',
'xpra.gtk_common.gdk_atoms.*',
'xpra.gtk_common.nested_main.*',
'xpra.gtk.gdk_atoms.*',
'xpra.gtk.nested_main.*',
'xpra.x11.gtk_x11.selection.*',
'xpra.*.ClientExtras.setup_clipboard_helper']
sound = ['xpra.sound.*',
Expand Down Expand Up @@ -272,11 +272,11 @@ one_offs = ['__main__',
'threading.Thread.setDaemon', 'threading.Thread.set_daemon', 'threading.Thread._set_daemon',
'threading.Thread.__init__',
'threading.Condition.*', 'threading.Event.*',
'xpra.gtk_common.quit.*', #gtk_main_quit_forever, gtk_main_quit_really, gtk_main_quit_on_fatal_exceptions_enable
'xpra.gtk.quit.*', #gtk_main_quit_forever, gtk_main_quit_really, gtk_main_quit_on_fatal_exceptions_enable
'xpra.x11.gtk_x11.wm.Wm.__init__',
'xpra.x11.gtk_x11.wm.Wm.__setup_ewmh_window',
'xpra.x11.gtk_x11.wm.Wm.enableCursors',
'xpra.gtk_common.*.n_arg_signal',
'xpra.gtk.*.n_arg_signal',
'xpra.x11.gtk_x11.error._ErrorManager.__init__',
#dotxpra finding sockets:
'glob.*',
Expand Down Expand Up @@ -317,7 +317,7 @@ one_offs = ['__main__',
'xpra.client.*.run',
'xpra.client.*.gtk*_main',
'xpra.client.*.verify_connected',
'xpra.gtk_common.*.gtk*main',
'xpra.gtk.*.gtk*main',
'xpra.platform.platform_import',
'xpra.platform.*.get*_classes',
'xpra.*.ui_thread_watcher.*get_UI_watcher', #UI_thread_watcher, get_UI_watcher
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/unit/client/keyboard_helper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def noop():
window = AdHocStruct()
window.quit = noop
modifier_names = kh.get_modifier_names()
modifiers_used = tuple(modifier_names.get(x, x) for x in kh.shortcut_modifiers)
modifiers_used = [modifier_names.get(x, x) for x in kh.shortcut_modifiers]
assert kh.key_handled_as_shortcut(window, "F4", modifiers_used, True)
assert not kh.key_handled_as_shortcut(window, "F1", (), True)
kh.cleanup()
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/unit/codecs/csc_colorspace_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _test_csc(self, mod,
raise Exception("%s does not support %s as input" % (mod, in_csc))
if out_csc not in csc_mod.get_output_colorspaces(in_csc):
raise Exception("%s does not support %s as output for %s" % (mod, out_csc, in_csc))
csc = csc_mod.ColorspaceConverter()
csc = csc_mod.Converter()
csc.init_context(width, height, in_csc,
width, height, out_csc)
image = make_test_image(in_csc, width, height)
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/unit/gtk_common/keymap_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import unittest

from xpra.os_util import POSIX
from xpra.gtk_common.keymap import get_gtk_keymap, do_get_gtk_keymap
from xpra.gtk.keymap import get_gtk_keymap, do_get_gtk_keymap


class TestKeymap(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/unit/net/subprocess_wrapper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from queue import SimpleQueue
from gi.repository import GObject, GLib #@UnresolvedImport

from xpra.gtk_common.gobject_util import one_arg_signal
from xpra.gtk.gobject import one_arg_signal
from xpra.net.protocol.socket_handler import SocketProtocol
from xpra.net.subprocess_wrapper import subprocess_caller, subprocess_callee
from xpra.net.bytestreams import Connection
Expand Down
13 changes: 10 additions & 3 deletions tests/unittests/unit/server/shadow_server_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,19 @@ def test_dbus_interface(self):
else:
dstr = display.lstrip(":")
new_delay = 2
cmd = [dbus_send, "--session", "--type=method_call",
f"--dest=org.xpra.Server{dstr}", "/org/xpra/Server",
"org.xpra.Server.SetRefreshDelay", f"int32:{new_delay}"]
cmd = [
dbus_send,
"--session",
"--type=method_call",
f"--dest=org.xpra.Server{dstr}",
"/org/xpra/Server",
"org.xpra.Server.SetRefreshDelay",
f"int32:{new_delay}",
]
env = self.get_run_env()
env["DISPLAY"] = display
self.run_command(cmd, env=env).wait(20)
time.sleep(1)
#check that the value has changed:
info = self.get_server_info(display)
assert info
Expand Down
1 change: 0 additions & 1 deletion tests/unittests/unit/x11/size_hints_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def test_sanitize(self):
sanitize_size_hints = size_hints_util.sanitize_size_hints
with silence_warn(size_hints_util):
INTPAIRS = (0, "foo", (1,))
sanitize_size_hints(None)
for attr, values in {
"min-aspect" : (0, -1, MAX_ASPECT, "foo"),
"max-aspect" : (0, -1, MAX_ASPECT, "foo"),
Expand Down
2 changes: 1 addition & 1 deletion tests/xpra/clients/fake_gtk_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import gi
gi.require_version('Gtk', '3.0') # @UndefinedVariable
from gi.repository import Gtk, GLib #pylint: disable=wrong-import-position @UnresolvedImport
from xpra.gtk_common.gtk_util import get_default_root_window
from xpra.gtk.gtk_util import get_default_root_window
from tests.xpra.clients.fake_client import FakeClient


Expand Down
Loading

0 comments on commit 8d50203

Please sign in to comment.