From 8eaed8c5f65612442115830cf3c82a3e5b71cf67 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Mon, 9 Feb 2026 21:44:03 +1100 Subject: [PATCH] fix(linux): remove Screen typedef collision with X11 Xlib.h (#4979) * fix(linux): remove unused C Screen typedef that collides with X11 Xlib.h The GTK4 backend includes for X11 window positioning, which pulls in . Xlib defines its own `Screen` typedef, conflicting with the identically-named struct in linux_cgo_gtk4.h. The C Screen struct was unused - the Go code constructs Go Screen structs directly from GDK monitor data, never referencing C.Screen. Fixes #4957 Co-Authored-By: Claude Opus 4.6 * ci: run GTK4 build and tests on all v3-alpha PRs The GTK4 CI steps were gated on github.head_ref == 'feature/webkit-gtk6-support', meaning no other branch ever ran GTK4 compilation checks. This allowed the Screen typedef collision to slip through undetected. Now that GTK4 support has been merged, run GTK4 dependency installation, example builds, and test suite on every PR targeting v3-alpha. Co-Authored-By: Claude Opus 4.6 * docs: add GTK4 Screen typedef fix to unreleased changelog Co-Authored-By: Claude Opus 4.6 * Fix changelog * fix changelog * fix(ci): pass BUILD_TAGS through to go build in test:example:linux The GTK4 CI step ran BUILD_TAGS=gtk4 task test:examples but the Taskfile task ignored the env var, always building with no -tags flag. Use shell parameter expansion so BUILD_TAGS flows through to go build. Co-Authored-By: Claude Opus 4.6 --------- Co-authored-by: Claude Opus 4.6 --- .github/workflows/build-and-test-v3.yml | 22 ++++++++++------------ v3/Taskfile.yaml | 13 ++++--------- v3/UNRELEASED_CHANGELOG.md | 1 + v3/pkg/application/linux_cgo_gtk4.h | 16 ---------------- 4 files changed, 15 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build-and-test-v3.yml b/.github/workflows/build-and-test-v3.yml index cc2c6ded0..0392e5abf 100644 --- a/.github/workflows/build-and-test-v3.yml +++ b/.github/workflows/build-and-test-v3.yml @@ -118,8 +118,8 @@ jobs: packages: libgtk-3-dev libwebkit2gtk-4.1-dev libwayland-dev build-essential pkg-config xvfb x11-xserver-utils at-spi2-core xdg-desktop-portal-gtk version: 1.0 - - name: Install linux dependencies (GTK4) - webkit-gtk6-support branch only - if: matrix.os == 'ubuntu-latest' && github.head_ref == 'feature/webkit-gtk6-support' + - name: Install linux dependencies (GTK4) + if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install -y libgtk-4-dev libwebkitgtk-6.0-dev @@ -150,8 +150,8 @@ jobs: task test:examples echo "Example compilation tests (GTK3) completed successfully" - - name: Build Examples (GTK4 experimental) - if: matrix.os == 'ubuntu-latest' && github.head_ref == 'feature/webkit-gtk6-support' + - name: Build Examples (GTK4) + if: matrix.os == 'ubuntu-latest' working-directory: v3 run: | echo "Starting example compilation tests (GTK4)..." @@ -180,11 +180,10 @@ jobs: go test -v ./... ' - - name: Run tests (ubuntu) - GTK4 experimental - if: matrix.os == 'ubuntu-latest' && github.head_ref == 'feature/webkit-gtk6-support' + - name: Run tests (ubuntu) - GTK4 + if: matrix.os == 'ubuntu-latest' working-directory: v3 - # Skip all service tests that hang in CI due to GTK4 display requirements - # The services tests require a fully functional GTK4 display which xvfb cannot provide + # Skip service tests that hang in CI due to GTK4 display requirements run: > xvfb-run --auto-servernum sh -c ' @@ -243,8 +242,8 @@ jobs: packages: libgtk-3-dev libwebkit2gtk-4.1-dev libwayland-dev build-essential pkg-config version: 1.0 - - name: Install linux dependencies (GTK4) - webkit-gtk6-support branch only - if: matrix.os == 'ubuntu-latest' && github.head_ref == 'feature/webkit-gtk6-support' + - name: Install linux dependencies (GTK4) + if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install -y libgtk-4-dev libwebkitgtk-6.0-dev @@ -292,8 +291,7 @@ jobs: cd .. wails3 build - # Note: GTK4 template builds are not tested here as wails build doesn't - # support -tags flag yet. GTK4 compilation is verified by Go tests. + # GTK4 template builds are covered by the Go example compilation tests above. build_results: if: ${{ always() }} diff --git a/v3/Taskfile.yaml b/v3/Taskfile.yaml index 171853e14..81603c409 100644 --- a/v3/Taskfile.yaml +++ b/v3/Taskfile.yaml @@ -92,14 +92,14 @@ tasks: GOARCH: amd64 test:example:linux: - summary: Build example for Linux with GTK3 (default) + summary: Build example for Linux (pass BUILD_TAGS env var to add -tags, e.g. BUILD_TAGS=gtk4) dir: 'examples/{{.DIR}}' platforms: - linux cmds: - - echo "Building example {{.DIR}} for Linux (GTK3)" + - echo "Building example {{.DIR}} for Linux (${BUILD_TAGS:-GTK3})" - go mod tidy - - go build -o "testbuild-{{.DIR}}-linux" + - go build ${BUILD_TAGS:+-tags $BUILD_TAGS} -o "testbuild-{{.DIR}}-linux" test:example:linux:gtk4: summary: Build example for Linux with GTK4 (experimental, opt-in via -tags gtk4) @@ -365,12 +365,7 @@ tasks: vars: DIR: "{{.ITEM}}" platforms: [linux] - # GTK4 tests are run separately via Docker tasks since CI doesn't have GTK4 deps - # - for: { var: EXAMPLEDIRS } - # task: test:example:linux:gtk4 - # vars: - # DIR: "{{.ITEM}}" - # platforms: [linux] + # GTK4 example builds are handled in CI via: BUILD_TAGS=gtk4 task test:examples - for: { var: EXAMPLEDIRS } task: test:example:windows vars: diff --git a/v3/UNRELEASED_CHANGELOG.md b/v3/UNRELEASED_CHANGELOG.md index 823ba99b8..fbd0259cf 100644 --- a/v3/UNRELEASED_CHANGELOG.md +++ b/v3/UNRELEASED_CHANGELOG.md @@ -25,6 +25,7 @@ After processing, the content will be moved to the main changelog and this file ## Fixed +- Fix GTK4 build failure caused by C `Screen` typedef colliding with X11 Xlib.h (#4957) - Fix dock badge methods consistency on macOS ## Deprecated diff --git a/v3/pkg/application/linux_cgo_gtk4.h b/v3/pkg/application/linux_cgo_gtk4.h index ff1d6a93a..81126e98a 100644 --- a/v3/pkg/application/linux_cgo_gtk4.h +++ b/v3/pkg/application/linux_cgo_gtk4.h @@ -29,22 +29,6 @@ typedef struct WindowEvent { uint event; } WindowEvent; -typedef struct Screen { - const char* id; - const char* name; - int p_width; - int p_height; - int x; - int y; - int w_width; - int w_height; - int w_x; - int w_y; - float scaleFactor; - double rotation; - bool isPrimary; -} Screen; - typedef struct MenuItemData { guint id; GSimpleAction *action;