From c4ff8737267029aa5079bf0ad4ee424c3d2c7c59 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 28 Dec 2024 14:25:09 -0800 Subject: [PATCH] ci: test gtk via a matrix --- .github/workflows/test.yml | 52 +++++++++++++++++++++++++++++--------- src/apprt/gtk/key.zig | 11 ++++---- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c9b515d467..a9369b66e0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -329,18 +329,6 @@ jobs: - name: Test GTK Build run: nix develop -c zig build -Dapp-runtime=gtk -Dgtk-adwaita=true -Demit-docs - - name: Test GTK Build (No Libadwaita) - run: nix develop -c zig build -Dapp-runtime=gtk -Dgtk-adwaita=false -Demit-docs - - - name: Test GTK build with explicit X11 - run: nix develop -c zig build -Dapp-runtime=gtk -Dgtk-adwaita=true -Demit-docs -Dgtk-x11=true - - - name: Test GTK build with no X11 - run: nix develop -c zig build -Dapp-runtime=gtk -Dgtk-adwaita=true -Demit-docs -Dgtk-x11=false - - - name: Test GTK build with no Adwaita and no X11 - run: nix develop -c zig build -Dapp-runtime=gtk -Dgtk-adwaita=false -Demit-docs -Dgtk-x11=false - - name: Test GLFW Build run: nix develop -c zig build -Dapp-runtime=glfw @@ -348,6 +336,46 @@ jobs: - name: Test System Build run: nix develop -c zig build --system ${ZIG_GLOBAL_CACHE_DIR}/p + test-gtk: + strategy: + fail-fast: false + matrix: + adwaita: ["true", "false"] + x11: ["true", "false"] + runs-on: namespace-profile-ghostty-md + needs: test + env: + ZIG_LOCAL_CACHE_DIR: /zig/local-cache + ZIG_GLOBAL_CACHE_DIR: /zig/global-cache + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Cache + uses: namespacelabs/nscloud-cache-action@v1.2.0 + with: + path: | + /nix + /zig + + - name: Test GTK Build + run: | + nix develop -c \ + zig build \ + -Dapp-runtime=gtk \ + -Dgtk-adwaita=${{ matrix.adwaita }} \ + -Dgtk-x11=${{ matrix.x11 }} + + # Install Nix and use that to run our tests so our environment matches exactly. + - uses: cachix/install-nix-action@v30 + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: cachix/cachix-action@v15 + with: + name: ghostty + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + + test-macos: runs-on: namespace-profile-ghostty-macos needs: test diff --git a/src/apprt/gtk/key.zig b/src/apprt/gtk/key.zig index cd5d483d98..80191b7f5d 100644 --- a/src/apprt/gtk/key.zig +++ b/src/apprt/gtk/key.zig @@ -114,18 +114,19 @@ pub fn eventMods( const device = c.gdk_event_get_device(event); var mods = mods: { + // Add any modifier state events from Xkb if we have them (X11 + // only). Null back from the Xkb call means there was no modifier + // event to read. This likely means that the key event did not + // result in a modifier change and we can safely rely on the GDK + // state. if (comptime build_options.x11) { const display = c.gtk_widget_get_display(widget); if (x11_xkb) |xkb| { - // Add any modifier state events from Xkb if we have them (X11 - // only). Null back from the Xkb call means there was no modifier - // event to read. This likely means that the key event did not - // result in a modifier change and we can safely rely on the GDK - // state. if (xkb.modifier_state_from_notify(display)) |x11_mods| break :mods x11_mods; break :mods translateMods(gtk_mods); } } + // On Wayland, we have to use the GDK device because the mods sent // to this event do not have the modifier key applied if it was // presssed (i.e. left control).