Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ports/gtk/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ get_filename_component(PKGCONFIG_DIR "${PKGCONFIG}" DIRECTORY )
vcpkg_add_to_path("${PKGCONFIG_DIR}") # Post install script runs pkg-config so it needs to be on PATH
vcpkg_add_to_path("${CURRENT_HOST_INSTALLED_DIR}/tools/glib/")

set(wayland false)
set(x11 false)
set(win32 false)
set(osx false)
if(VCPKG_TARGET_IS_LINUX)
set(OPTIONS -Dwayland-backend=false) # CI missing at least wayland-protocols
set(wayland true)
Copy link
Copy Markdown
Contributor

@AenBleidd AenBleidd Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this should be always enabled by default? It is still possible to build GTK with X11 backend, and thus this port should give a possibility to do that, and not just hardcode Wayland for Linux

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, currently x11 is also hardcoded for linux. When enabling wayland that does not disable x11, it just enables both backends. So on a X11 desktop GTK would pick the x11 backend, on a wayland desktop the wayland backend (currently it quits there).

Ideally we'd want VCPKG features for the backend selection, but in general this port currently lacks any proper feature support. E.g. vulkan, opengl etc. should also be selectable.
To me it seemed like this is out of scope of this PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By this change you will force all applications to build (or install) Wayland even if they don't use it, so this is a breaking change. Also can you confirm that with Wayland backend application will switch to X11 when there is not Wayland support and what is more important will not require installing anything additional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm this since i've used Gtk (without VCPKG) for years. The automatic backend selection is the default behaviour unless explicitly set: https://docs.gtk.org/gtk4/running.html#gdk_backend

This port not having features forces a lot of restrictions. My distro has no X11 support, still this port forces me to build & compile the x11 backend.

If majority wants me to pull this out as a feature I'll do so, but then the other backends should be "optional" aswell

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And in this port you explicitly wet it to use Wayland. I do know that on Wayland X11 applications can run because Wayland provides a special mediator library.
I'm not sure this will work other way around when you build an application setting a Wayland backend that ill fall back to X11 if Wayland is not present.
To clarify: I'm ok to have Wayland a defaul backend, but there should be a possibility to configure this port to use some other backend.

If majority wants me to pull this out as a feature I'll do so, but then the other backends should be "optional" aswell

This is basically up to maintainers to decide.
However, the only 'other' backend is broadway, since macos is MacOs specific, and win32 is Windows specific.

Copy link
Copy Markdown
Contributor Author

@feliwir feliwir Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you that features would be sweet, the question is just if this is in scope of this PR.
To have all Gtk build options represented as features would require us to add more than 10+ features probably (e.g. the renderer choice etc.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to do anything in one PR. You can start with backend options and add other features later.
I mean, if you do this change now, it will be visible immediately (ok, for the majority of users after the next monthly release), and at that point it will be too late to improve something since the only option will be the rollback.
Regarding the other features, if would be nice to have them if they are required.

Copy link
Copy Markdown
Member

@BillyONeal BillyONeal Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are things I believe to be true:

There is some time where we would have had to change the backend we choose out of the box, and now that all of the major distros are done so, I think we should. I understand that is exceedingly unfortunate for @AenBleidd 's use case where vcpkg was building all of the X related libraries he needs, but given the GTK maintainer's statement linked above ( gtk-rs/gtk4-rs#1963 (comment) ) that seems like a strong statement that is not the expected user base from their perspective.

EDIT: But if even Ubuntu 22.04 "Noble"'s Wayland is too old we might have no good options?

To that end, I think we should change this to Wayland and/or both. portfile.cmake can have an option or something to make it easy for folks in @AenBleidd 's scenario to maintain an overlay port.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not happy with that but that's fair enough. My suggestion would be at least to announce it somewhere before merging that people are aware beforehand and not just awake in the morning to see all their builds failed not knowing what they need to do next to fix them all (I know about version pinning but let's be honest: it doesn't really work since you cannot fix a particular version of particular library without affecting other libraries).
Anyway, @BillyONeal, thank you for the detailed analysis and sorry for any possible mess.

Copy link
Copy Markdown
Contributor

@AenBleidd AenBleidd Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BillyONeal, a little piece of information for you.
When I last tried to build Wayland (like really build without system packages installed), it was failed due to broken ports (see my comment here).
Not sure how much this is relevant now but worth taking a look I support since you want to enforce Wayland.

set(x11 true)
# Enable the wayland gdk backend (only when building on Unix except for macOS)
elseif(VCPKG_TARGET_IS_WINDOWS)
Expand All @@ -34,6 +35,7 @@ elseif(VCPKG_TARGET_IS_OSX)
set(osx true)
endif()

list(APPEND OPTIONS -Dwayland-backend=${wayland}) #Enable the Wayland gdk backend (only when building on Unix)
list(APPEND OPTIONS -Dx11-backend=${x11}) #Enable the X11 gdk backend (only when building on Unix)
list(APPEND OPTIONS -Dbroadway-backend=false) #Enable the broadway (HTML5) gdk backend
list(APPEND OPTIONS -Dwin32-backend=${win32}) #Enable the Windows gdk backend (only when building on Windows)
Expand Down
4 changes: 4 additions & 0 deletions ports/gtk/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
{
"name": "vcpkg-tool-meson",
"host": true
},
{
"name": "wayland-protocols",
"platform": "linux"
}
],
"features": {
Expand Down
2 changes: 1 addition & 1 deletion versions/g-/gtk.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"versions": [
{
"git-tree": "a00d8b7fc33fb6fa4794606fa5a83d682dc94e70",
"git-tree": "adfa7f2296204fe8e67abcc0a1ce8ea44215c15e",
"version": "4.22.0",
"port-version": 0
},
Expand Down
Loading