From 3091944e628ea40988ccb3a6f46215c9ea127092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Majerech?= Date: Thu, 23 Apr 2026 22:38:59 +0200 Subject: [PATCH 1/2] glfw: fix build for Wayland backend --- releases.json | 1 + subprojects/packagefiles/glfw/meson.build | 67 +++++++++++------------ 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/releases.json b/releases.json index 1135815be9..d2d3db2a5c 100644 --- a/releases.json +++ b/releases.json @@ -1346,6 +1346,7 @@ "glfw3" ], "versions": [ + "3.4-2", "3.4-1", "3.3.10-1", "3.3.9-1", diff --git a/subprojects/packagefiles/glfw/meson.build b/subprojects/packagefiles/glfw/meson.build index 7c8a2531b0..e9e349de7c 100644 --- a/subprojects/packagefiles/glfw/meson.build +++ b/subprojects/packagefiles/glfw/meson.build @@ -90,42 +90,37 @@ elif opt_display == 'wayland' ) endif s_wayland = [] - protocols = { - 'idle-inhibit': 'unstable', - 'pointer-constraints': 'unstable', - 'relative-pointer': 'unstable', - 'viewporter': 'stable', - 'xdg-decoration': 'unstable', - 'xdg-shell': 'stable', - } - foreach p, s : protocols - x_path = join_paths(wl_dir, s, p, p) - if s == 'stable' - x_name = p - xml = files(x_path + '.xml') - else - x_name = p + '-unstable-v1' - xml = files(x_path + '-unstable-v1.xml') - endif - foreach f : ['client-header', 'server-header', 'private-code'] - if (f == 'client-header' and p == 'xdg-decoration') - outfile = 'wayland-' + p + '-client-protocol.h' - elif f == 'client-header' - outfile = 'wayland-' + x_name + '-client-protocol.h' - elif f == 'server-header' - outfile = 'wayland-' + p + '-server-protocol.h' - elif (f == 'private-code' and p == 'xdg-decoration') - outfile = 'wayland-' + p + '-protocol.c' - else - outfile = 'wayland-' + x_name + '-protocol.c' - endif - s_wayland += custom_target( - '@0@ @1@'.format(p, f), - command: ['wayland-scanner', f, '@INPUT@', '@OUTPUT@'], - input: xml, - output: outfile, - ) - endforeach + + protocols = [ + 'fractional-scale-v1', + 'idle-inhibit-unstable-v1', + 'pointer-constraints-unstable-v1', + 'relative-pointer-unstable-v1', + 'viewporter', + 'wayland', + 'xdg-activation-v1', + 'xdg-decoration-unstable-v1', + 'xdg-shell', + ] + + foreach proto : protocols + xml_file = files('deps' / 'wayland' / (proto + '.xml')) + header_file = proto + '-client-protocol.h' + code_file = proto + '-client-protocol-code.h' + + s_wayland += custom_target( + '@0@ client-header'.format(proto), + command: ['wayland-scanner', 'client-header', '@INPUT@', '@OUTPUT@'], + input: xml_file, + output: header_file, + ) + + s_wayland += custom_target( + '@0@ private-code'.format(proto), + command: ['wayland-scanner', 'private-code', '@INPUT@', '@OUTPUT@'], + input: xml_file, + output: code_file, + ) endforeach # Win32 elif opt_display == 'win32' From 8ba16a8aac52902387f1f9a12181d248608aeacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Majerech?= Date: Thu, 23 Apr 2026 23:03:37 +0200 Subject: [PATCH 2/2] glfw: allow setting multiple backends --- subprojects/packagefiles/glfw/meson.build | 95 +++++++++++++------ .../packagefiles/glfw/meson_options.txt | 4 +- 2 files changed, 67 insertions(+), 32 deletions(-) diff --git a/subprojects/packagefiles/glfw/meson.build b/subprojects/packagefiles/glfw/meson.build index e9e349de7c..3a283f179c 100644 --- a/subprojects/packagefiles/glfw/meson.build +++ b/subprojects/packagefiles/glfw/meson.build @@ -27,13 +27,13 @@ add_project_arguments( language: 'c', ) -if opt_display == 'auto' +if opt_display == ['auto'] if sys_os == 'windows' - opt_display = 'win32' + opt_display = ['win32'] elif sys_os == 'darwin' - opt_display = 'cocoa' + opt_display = ['cocoa'] else - opt_display = 'x11' + opt_display = ['x11'] endif endif @@ -41,18 +41,27 @@ endif deps = [] #@ Backend API # OSMesa -if opt_display == 'osmesa' +if opt_display.contains('osmesa') deps += dependency('osmesa') - # X11 -elif opt_display == 'x11' +endif + +# X11 +if opt_display.contains('x11') foreach x : ['x11', 'xrandr', 'xinerama', 'xcursor', 'xi'] deps += dependency( x, required: true, ) endforeach - # Wayland -elif opt_display == 'wayland' + + add_project_arguments( + '-D_GLFW_X11', + language: 'c', + ) +endif + +# Wayland +if opt_display.contains('wayland') warning('Wayland support is experimental & incomplete.') warning( 'GLFW < 3.4 cannot detect Wayland if both x11 and Wayland exist on-system!', @@ -122,13 +131,27 @@ elif opt_display == 'wayland' output: code_file, ) endforeach - # Win32 -elif opt_display == 'win32' + + add_project_arguments( + '-D_GLFW_WAYLAND', + language: 'c', + ) +endif + +# Win32 +if opt_display.contains('win32') if sys_os != 'windows' error('Non Windows is unsupported') endif - # Cocoa -elif opt_display == 'cocoa' + + add_project_arguments( + '-D_GLFW_WIN32', + language: 'c', + ) +endif + +# Cocoa +if opt_display.contains('cocoa') if sys_os != 'darwin' error('Non macOS is unsupported') endif @@ -136,7 +159,13 @@ elif opt_display == 'cocoa' 'appleframeworks', modules: ['Cocoa', 'CoreFoundation', 'IOKit'], ) + + add_project_arguments( + '-D_GLFW_COCOA', + language: 'c', + ) endif + #@ System Dependencies foreach l : ['m', 'rt'] deps += sys_cc.find_library( @@ -157,12 +186,6 @@ else endif deps += dependency('threads') -### Configuration ### -add_project_arguments( - '-D_GLFW_' + opt_display.to_upper(), - language: 'c', -) - ### Targets ### #@ Primary target: ## GLFW library @@ -190,9 +213,12 @@ elif sys_os == 'windows' else s_os = files('src/posix_module.c', 'src/posix_thread.c', 'src/posix_time.c') endif + # Backend files -if opt_display == 'osmesa' - s_display = files( +s_display = [] + +if opt_display.contains('osmesa') + s_display += files( 'src/null_init.c', 'src/null_joystick.c', 'src/null_monitor.c', @@ -201,8 +227,10 @@ if opt_display == 'osmesa' 'src/posix_thread.c', 'src/posix_time.c', ) -elif opt_display == 'x11' - s_display = files( +endif + +if opt_display.contains('x11') + s_display += files( 'src/glx_context.c', 'src/linux_joystick.c', 'src/posix_poll.c', @@ -211,8 +239,10 @@ elif opt_display == 'x11' 'src/x11_window.c', 'src/xkb_unicode.c', ) -elif opt_display == 'wayland' - s_display = files( +endif + +if opt_display.contains('wayland') + s_display += files( 'src/linux_joystick.c', 'src/posix_poll.c', 'src/wl_init.c', @@ -220,20 +250,24 @@ elif opt_display == 'wayland' 'src/wl_window.c', 'src/xkb_unicode.c', ) -elif opt_display == 'win32' - s_display = files( +endif + +if opt_display.contains('win32') + s_display += files( 'src/wgl_context.c', 'src/win32_init.c', 'src/win32_joystick.c', 'src/win32_monitor.c', 'src/win32_window.c', ) -elif opt_display == 'cocoa' +endif + +if opt_display.contains('cocoa') add_languages( 'objc', native: false, ) - s_display = files( + s_display += files( 'src/cocoa_init.m', 'src/cocoa_joystick.m', 'src/cocoa_monitor.m', @@ -248,8 +282,9 @@ elif opt_display == 'cocoa' ) endif endif + srcfiles = [s_common, s_os, s_display] -if opt_display == 'wayland' +if opt_display.contains('wayland') srcfiles += s_wayland endif incdirs = include_directories('include', 'src') diff --git a/subprojects/packagefiles/glfw/meson_options.txt b/subprojects/packagefiles/glfw/meson_options.txt index aebbc7f2df..de8c0ca7bd 100644 --- a/subprojects/packagefiles/glfw/meson_options.txt +++ b/subprojects/packagefiles/glfw/meson_options.txt @@ -23,8 +23,8 @@ option( #@ Configuration options option( 'display-api', - type: 'combo', + type: 'array', choices: ['auto', 'osmesa', 'x11', 'wayland', 'win32', 'cocoa'], - value: 'auto', + value: ['auto'], description: 'Choose backend display API.', )