diff --git a/mir-ci/mir_ci/tests/robot/platforms/wayland/WaylandHid.py b/mir-ci/mir_ci/tests/robot/platforms/wayland/WaylandHid.py index cafd5e95..ef5a32ad 100644 --- a/mir-ci/mir_ci/tests/robot/platforms/wayland/WaylandHid.py +++ b/mir-ci/mir_ci/tests/robot/platforms/wayland/WaylandHid.py @@ -26,6 +26,10 @@ def __init__(self) -> None: display_name = os.environ.get("WAYLAND_DISPLAY", "wayland-0") super().__init__(display_name) + @keyword + async def set_output_scale(self, output_scale: float) -> None: + self.output_scale = output_scale + @keyword async def move_pointer_to_absolute(self, x: int, y: int) -> None: await self.connect() diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-button-combo-boxes-maximized.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-button-combo-boxes-maximized.png new file mode 100644 index 00000000..d54279f1 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-button-combo-boxes-maximized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4e799a91cd9d7de2db56dc8374ff197d3892275f6d4a904c553f8552ac37c5bb +size 1453 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-button.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-button.png new file mode 100644 index 00000000..e2d05628 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-button.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:07fe4c9c6c6d765eb945ffef0310fcd66166069d164eb94669793a0f7e91cb32 +size 865 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-screenshot.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-screenshot.png new file mode 100644 index 00000000..bf22365e --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-screenshot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2ef39906daf81d20ecfc714c07406ad354fd189430de759cca5b31e58b772810 +size 47089 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-title-combo-boxes-maximized.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-title-combo-boxes-maximized.png new file mode 100644 index 00000000..a861193b --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-title-combo-boxes-maximized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b130bef713e46b217b2dbab58c234f23f09a626e421e2dde6eec6ac57a72c2e +size 1599 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-title-main.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-title-main.png new file mode 100644 index 00000000..d9e9ac66 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-title-main.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2701c852f6a623b1a0fea66cbd6c70ab22a1a6fb836a139860536a08042c304 +size 1331 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-title.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-title.png new file mode 100644 index 00000000..4741b483 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.0-gtk4-demo-title.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:75d52ce7aa1a61d7ac9fa5ad772b0724d5e00d2fd68a020c2a424583e4764e28 +size 1018 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-button-combo-boxes-maximized.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-button-combo-boxes-maximized.png new file mode 100644 index 00000000..71363905 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-button-combo-boxes-maximized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df0508c85f9ba9a4312a119c4c19289095c17af16e720ecc69b7c862f3e0a45d +size 2849 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-screenshot-floating.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-screenshot-floating.png new file mode 100644 index 00000000..a7e6baf4 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-screenshot-floating.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f3096399546d5dc7edcb4a952f535b16bd76bcf9619e1923407e84fdc1fab7b2 +size 123031 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-screenshot-maximized.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-screenshot-maximized.png new file mode 100644 index 00000000..d44445d9 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-screenshot-maximized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ab4e93a718d335a7878faf695cf5dcafce028911a2c96fb373d2edfa505e290 +size 104717 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-title-app-title.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-title-app-title.png new file mode 100644 index 00000000..27440df9 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-title-app-title.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d870151c7a783cb9a91e23f936c5f14a7a471b5f7ca6ff86c9d06664aa1012e +size 2157 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-title-combo-boxes-maximized.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-title-combo-boxes-maximized.png new file mode 100644 index 00000000..cd1bf6f0 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.25-gtk4-demo-title-combo-boxes-maximized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22d3d5c29f352f1613f46bbfb09f6c2b4921c98e59ea403900655e3c82362950 +size 2914 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-button-combo-boxes-maximized.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-button-combo-boxes-maximized.png new file mode 100644 index 00000000..0217998b --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-button-combo-boxes-maximized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d4b157c2db3fe9b3a4fc730d7abde8442ba36d2409225bec818c58a37f6f584 +size 3843 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-button.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-button.png new file mode 100644 index 00000000..703b9421 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-button.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9ae9ae2741ece901fc6a48a1d98dec6c327794c30a2fe3f2ec553824746be10 +size 4329 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-screenshot.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-screenshot.png new file mode 100644 index 00000000..279c14e4 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-screenshot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06499c41e7c298a3e4db14b24f2fad3fe5cc4b6c753c5c25680f23b39020d84b +size 128599 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-title-combo-boxes-maximized.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-title-combo-boxes-maximized.png new file mode 100644 index 00000000..adfb82c6 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-title-combo-boxes-maximized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:454ce515253301240cd7408ec0dc58312391bbc8d180e30d2773760aedf8102d +size 2810 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-title-main-half.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-title-main-half.png new file mode 100644 index 00000000..75bf259e --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-title-main-half.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b43fa000d4ff69f990753cd2ded974d3f83996e9ab1c8b8a5977aa54d5dfe1c +size 3750 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-title-main.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-title-main.png new file mode 100644 index 00000000..05388ad2 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-title-main.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0bea8c23c44067e14ec1c2ae02957743b994ce7b5f6880c7af26b8507e1422b7 +size 3486 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-title.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-title.png new file mode 100644 index 00000000..753464ce --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.5-gtk4-demo-title.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3298683b230d3c979b149415df6921e49397ef0adf1dac6438d184b32b040916 +size 4573 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-button-combo-boxes-maximized.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-button-combo-boxes-maximized.png new file mode 100644 index 00000000..431403d3 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-button-combo-boxes-maximized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8456ffdfcc85ddddf85017836a13209be60ea998f0a56473adcd9a1c1a5d04d +size 4042 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-screenshot-floating.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-screenshot-floating.png new file mode 100644 index 00000000..ff35fe0c --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-screenshot-floating.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a1e94d2577e1b11f9082a1d6b57d9209d57e7aff1625c40a2e62e476e7d417a +size 177619 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-screenshot-maximized.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-screenshot-maximized.png new file mode 100644 index 00000000..a9503d72 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-screenshot-maximized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:885bee3556642d5451bb1aefd6d9fe55e3d09bf2829daac0a728d4e1f62bf21a +size 170068 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-title-app-title.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-title-app-title.png new file mode 100644 index 00000000..52b4c1ae --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-title-app-title.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c80b3d8fa2d63a522ce698f8eccdea2484cdc0029b17f75f8ed3934471512b5a +size 3287 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-title-combo-boxes-maximized.png b/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-title-combo-boxes-maximized.png new file mode 100644 index 00000000..60351553 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/1.75-gtk4-demo-title-combo-boxes-maximized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc7bf27ef01998654e58b91cd030b03b7d1d5851704fe06831e987cae52f9f03 +size 2881 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-button-combo-boxes-maximized.png b/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-button-combo-boxes-maximized.png new file mode 100644 index 00000000..378ca686 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-button-combo-boxes-maximized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:758e7facc7cd645934e7cd1573e0c811357fef3f3be074fb8f74b376e4dd573f +size 3358 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-button.png b/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-button.png new file mode 100644 index 00000000..3cd56e4c --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-button.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0541ccb0cffcaa34db34df63d52561ce34673c29ab1095b5923d2efda95bfb1 +size 2297 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-screenshot.png b/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-screenshot.png new file mode 100644 index 00000000..aa6ee83a --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-screenshot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d196b23079b6daca89c20e570f983da763593c9fafb6133fa0bae9c739b299a +size 68345 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-title-combo-boxes-maximized.png b/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-title-combo-boxes-maximized.png new file mode 100644 index 00000000..bfb3e464 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-title-combo-boxes-maximized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dbefc3b27d9d9c1caa4fe10a7aa06c8f3a33be9d89c1fe020b1c057642e9b8e4 +size 3984 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-title-main.png b/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-title-main.png new file mode 100644 index 00000000..78c82cbf --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-title-main.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd0ca981bf2be1170204480a8c2ddb92e0b9e64f848e27d21317a3e4d2b32588 +size 3056 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-title.png b/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-title.png new file mode 100644 index 00000000..adaac02f --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/2.0-gtk4-demo-title.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fb03db12e8253be927db0d5fd53dd9dfbe36688746185bdefc32ec8606154a46 +size 2309 diff --git a/mir-ci/mir_ci/tests/robot/suites/scale/scale.robot b/mir-ci/mir_ci/tests/robot/suites/scale/scale.robot new file mode 100644 index 00000000..e2d0b643 --- /dev/null +++ b/mir-ci/mir_ci/tests/robot/suites/scale/scale.robot @@ -0,0 +1,38 @@ +*** Settings *** +Resource ${KVM_RESOURCE} + +Suite Setup Suite Setup +Test Setup Set Output Scale ${SCALE} + + +*** Variables *** +${T} ${CURDIR} +${SCREENSHOT} ${T}/${SCALE}-gtk4-demo-screenshot.png +${DEMO-APP-TITLE} ${T}/${SCALE}-gtk4-demo-title-main.png +${DEMO-APP-TITLE-HALF} ${T}/${SCALE}-gtk4-demo-title-main-half.png +${BUTTON} ${T}/${SCALE}-gtk4-demo-button.png +${TITLE} ${T}/${SCALE}-gtk4-demo-title.png + + +*** Test Cases *** +Ensure Scaling Is Visually Correct + Move Pointer To Proportional (1.0, 1.0) + + Match ${SCREENSHOT} + +Click Button With Scaling Enabled + Walk Pointer To ${BUTTON} + Click LEFT Button + + Match ${TITLE} + + +*** Keywords *** +Suite Setup + Set Output Scale ${SCALE} + # Work around https://github.com/canonical/mir/issues/3553 + ${aligned}= Run Keyword And Return Status + ... Walk Pointer To ${DEMO-APP-TITLE} + IF ${aligned} == False Walk Pointer To ${DEMO-APP-TITLE-HALF} + Click LEFT Button + Click LEFT Button diff --git a/mir-ci/mir_ci/tests/test_scale.py b/mir-ci/mir_ci/tests/test_scale.py new file mode 100644 index 00000000..1b7b461a --- /dev/null +++ b/mir-ci/mir_ci/tests/test_scale.py @@ -0,0 +1,85 @@ +import itertools +from pathlib import Path +from textwrap import dedent +from typing import Collection + +import pytest +from mir_ci import VARIANT +from mir_ci.fixtures.servers import ServerCap, servers +from mir_ci.program.app import App, AppType +from mir_ci.program.display_server import DisplayServer + +TESTS_PATH = Path(__file__).parent +APP_PATH = "gtk4-demo" +ROBOT_PATH = TESTS_PATH / "robot" + + +def collect_asset(asset: Path, variant): + variants = reversed((variant, *variant.parents[:-1])) + return itertools.chain( + asset.glob("*"), + *((asset / "variants" / v).glob("*") for v in variants), + ) + + +def collect_assets(platform: str, resources: Collection[str], suite: str, variant: Path = VARIANT): + return { + p.name: p + for p in itertools.chain( + collect_asset(ROBOT_PATH / "platforms" / platform, variant), + *(collect_asset(ROBOT_PATH / "resources" / resource, variant) for resource in resources), + collect_asset(ROBOT_PATH / "suites" / suite, variant), + ) + if p.is_file() + } + + +@pytest.mark.xdg( + XDG_CONFIG_HOME={ + "glib-2.0/settings/keyfile": dedent( + """\ + [org/gnome/desktop/interface] + color-scheme='prefer-light' + gtk-theme='Adwaita' + icon-theme='Adwaita' + font-name='Ubuntu 11' + cursor-theme='Adwaita' + cursor-size=24 + font-antialiasing='grayscale' + """ + ), + }, +) +@pytest.mark.env(GSETTINGS_BACKEND="keyfile") +@pytest.mark.parametrize("server", servers(ServerCap.DISPLAY_CONFIG)) +@pytest.mark.parametrize("scale", [1.0, 1.5, 2.0]) +@pytest.mark.deps( + debs=("gtk-4-examples",), + pip_pkgs=( + ("pygobject", "gi"), + ("robotframework~=6.1.1", "robot"), + ("rpaframework", "RPA"), + ("rpaframework-recognition", "RPA.recognition"), + ), +) +class TestScale: + async def test_scale(self, robot_log, server, scale, tmp_path) -> None: + extensions = ("all",) # TODO no need to enable all extension + + server_instance = DisplayServer( + server, + add_extensions=extensions, + env={"MIR_SERVER_X11_OUTPUT": "1024x768", "MIR_SERVER_DISPLAY_SCALE": str(scale)}, + ) + + assets = collect_assets("wayland", ["kvm"], "scale") + + async with server_instance, server_instance.program(App(APP_PATH, AppType.deb)): + tuple((tmp_path / k).symlink_to(v) for k, v in assets.items()) + + robot = server_instance.program( + App(("robot", "-d", tmp_path, "--log", robot_log, "--variable", f"SCALE:{scale}", tmp_path)) + ) + + async with robot: + await robot.wait(120) diff --git a/mir-ci/mir_ci/wayland/virtual_pointer.py b/mir-ci/mir_ci/wayland/virtual_pointer.py index f41bd78c..37f677df 100644 --- a/mir-ci/mir_ci/wayland/virtual_pointer.py +++ b/mir-ci/mir_ci/wayland/virtual_pointer.py @@ -20,7 +20,7 @@ class Button(IntEnum): class VirtualPointer(WaylandClient): required_extensions = (ZwlrVirtualPointerManagerV1.name, ZxdgOutputManagerV1.name) - def __init__(self, display_name: str) -> None: + def __init__(self, display_name: str, output_scale=1.0) -> None: super().__init__(display_name) self.pointer_manager: Optional[ZwlrVirtualPointerManagerV1Proxy] = None self.pointer: Optional[ZwlrVirtualPointerV1Proxy] = None @@ -29,6 +29,7 @@ def __init__(self, display_name: str) -> None: self.xdg_outputs: List[ZxdgOutputV1Proxy] = [] self.output_width = 0 self.output_height = 0 + self.output_scale = output_scale def registry_global(self, registry, id_num: int, iface_name: str, version: int) -> None: if iface_name == ZwlrVirtualPointerManagerV1.name: @@ -53,9 +54,10 @@ def disconnected(self) -> None: pass def xdg_output_logical_size(self, xdg_output, width: int, height: int) -> None: + # Whenever the logical size changes, we update the cached physical size if xdg_output == self.xdg_outputs[0]: - self.output_width = width - self.output_height = height + self.output_width = int(width * self.output_scale) + self.output_height = int(height * self.output_scale) def move_to_absolute(self, x: float, y: float) -> None: assert self.output_width > 0, "Output width must be greater than 0"