Skip to content

Commit 59d2bbf

Browse files
authored
Linux/Wayland new feature: Accept native parent window handle (#153)
* Linux/Wayland: Support parent windows * Set screen from display server * Update readme * Add GLFW3 test
1 parent fc168e8 commit 59d2bbf

16 files changed

Lines changed: 1024 additions & 152 deletions

.github/workflows/cmake.yml

Lines changed: 102 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ jobs:
3737

3838
build-ubuntu:
3939

40-
name: Ubuntu ${{ matrix.os.name }} - ${{ matrix.compiler.name }}, ${{ matrix.portal.name }}, ${{ matrix.autoappend.name }}, ${{ matrix.casesensitive.name }}, ${{ matrix.shared_lib.name }}, C++${{ matrix.cppstd }}
40+
name: Ubuntu ${{ matrix.os.name }} - ${{ matrix.compiler.name }}, ${{ matrix.portal.name }}, ${{ matrix.wayland.name }}, ${{ matrix.autoappend.name }}, ${{ matrix.casesensitive.name }}, ${{ matrix.shared_lib.name }}, C++${{ matrix.cppstd }}
4141
runs-on: ${{ matrix.os.label }}
4242

4343
strategy:
4444
matrix:
4545
os: [ {label: ubuntu-latest, name: latest}, {label: ubuntu-22.04, name: 22.04} ]
4646
portal: [ {flag: OFF, dep: libgtk-3-dev, name: GTK}, {flag: ON, dep: libdbus-1-dev, name: Portal} ] # The NFD_PORTAL setting defaults to OFF (i.e. uses GTK)
4747
autoappend: [ {flag: OFF, name: NoAppendExtn} ] # By default the NFD_PORTAL mode does not append extensions, because it breaks some features of the portal
48+
wayland: [ {flag: OFF, dep: , name: NoWayland} ]
4849
casesensitive: [ {flag: OFF, name: CaseInsensitive} ] # Case insensitive or case sensitive file filtering
4950
compiler: [ {c: gcc, cpp: g++, name: GCC}, {c: clang, cpp: clang++, name: Clang} ] # The default compiler is gcc/g++
5051
cppstd: [20, 11]
@@ -53,34 +54,47 @@ jobs:
5354
- os: {label: ubuntu-latest, name: latest}
5455
portal: {flag: ON, dep: libdbus-1-dev, name: Portal}
5556
autoappend: {flag: ON, name: AutoAppendExtn}
57+
wayland: {flag: OFF, dep: , name: NoWayland}
5658
casesensitive: {flag: OFF, name: CaseInsensitive}
5759
compiler: {c: gcc, cpp: g++, name: GCC}
5860
cppstd: 11
5961
shared_lib: {flag: OFF, name: Static}
6062
- os: {label: ubuntu-latest, name: latest}
6163
portal: {flag: ON, dep: libdbus-1-dev, name: Portal}
6264
autoappend: {flag: ON, name: AutoAppendExtn}
65+
wayland: {flag: OFF, dep: , name: NoWayland}
6366
casesensitive: {flag: OFF, name: CaseInsensitive}
6467
compiler: {c: clang, cpp: clang++, name: Clang}
6568
cppstd: 11
6669
shared_lib: {flag: OFF, name: Static}
6770
- os: {label: ubuntu-latest, name: latest}
6871
portal: {flag: ON, dep: libdbus-1-dev, name: Portal}
6972
autoappend: {flag: OFF, name: NoAppendExtn}
73+
wayland: {flag: OFF, dep: , name: NoWayland}
7074
casesensitive: {flag: OFF, name: CaseInsensitive}
7175
compiler: {c: gcc, cpp: g++, name: GCC}
7276
cppstd: 11
7377
shared_lib: {flag: ON, name: Shared}
78+
- os: {label: ubuntu-latest, name: latest}
79+
portal: {flag: ON, dep: libdbus-1-dev, name: Portal}
80+
autoappend: {flag: OFF, name: NoAppendExtn}
81+
wayland: {flag: ON, dep: libwayland-dev libwayland-bin, name: Wayland}
82+
casesensitive: {flag: OFF, name: CaseInsensitive}
83+
compiler: {c: gcc, cpp: g++, name: GCC}
84+
cppstd: 11
85+
shared_lib: {flag: ON, name: Static}
7486
- os: {label: ubuntu-latest, name: latest}
7587
portal: {flag: OFF, dep: libgtk-3-dev, name: GTK}
7688
autoappend: {flag: OFF, name: NoAppendExtn}
89+
wayland: {flag: OFF, dep: , name: NoWayland}
7790
casesensitive: {flag: ON, name: CaseSensitive}
7891
compiler: {c: gcc, cpp: g++, name: GCC}
7992
cppstd: 11
8093
shared_lib: {flag: OFF, name: Static}
8194
- os: {label: ubuntu-latest, name: latest}
8295
portal: {flag: ON, dep: libdbus-1-dev, name: Portal}
8396
autoappend: {flag: OFF, name: NoAppendExtn}
97+
wayland: {flag: OFF, dep: , name: NoWayland}
8498
casesensitive: {flag: ON, name: CaseSensitive}
8599
compiler: {c: gcc, cpp: g++, name: GCC}
86100
cppstd: 11
@@ -89,16 +103,18 @@ jobs:
89103
steps:
90104
- name: Checkout
91105
uses: actions/checkout@v4
106+
with:
107+
submodules: true
92108
- name: Install Dependencies
93-
run: sudo apt-get update && sudo apt-get install ${{ matrix.portal.dep }}
109+
run: sudo apt-get update && sudo apt-get install ${{ matrix.portal.dep }} ${{ matrix.wayland.dep }}
94110
- name: Configure
95-
run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${{ matrix.compiler.c }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp }} -DCMAKE_CXX_STANDARD=${{ matrix.cppstd }} -DCMAKE_C_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DNFD_PORTAL=${{ matrix.portal.flag }} -DNFD_APPEND_EXTENSION=${{ matrix.autoappend.flag }} -DNFD_CASE_SENSITIVE_FILTER=${{ matrix.casesensitive.flag }} -DBUILD_SHARED_LIBS=${{ matrix.shared_lib.flag }} -DNFD_BUILD_TESTS=ON ..
111+
run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${{ matrix.compiler.c }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp }} -DCMAKE_CXX_STANDARD=${{ matrix.cppstd }} -DCMAKE_C_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DNFD_PORTAL=${{ matrix.portal.flag }} -DNFD_WAYLAND=${{ matrix.wayland.flag }} -DNFD_APPEND_EXTENSION=${{ matrix.autoappend.flag }} -DNFD_CASE_SENSITIVE_FILTER=${{ matrix.casesensitive.flag }} -DBUILD_SHARED_LIBS=${{ matrix.shared_lib.flag }} -DNFD_BUILD_TESTS=ON ..
96112
- name: Build
97113
run: cmake --build build --target install
98114
- name: Upload test binaries
99115
uses: actions/upload-artifact@v4
100116
with:
101-
name: Ubuntu ${{ matrix.os.name }} - ${{ matrix.compiler.name }}, ${{ matrix.portal.name }}, ${{ matrix.autoappend.name }}, ${{ matrix.casesensitive.name }}, ${{ matrix.shared_lib.name }}, C++${{ matrix.cppstd }}
117+
name: Ubuntu ${{ matrix.os.name }} - ${{ matrix.compiler.name }}, ${{ matrix.portal.name }}, ${{ matrix.wayland.name }}, ${{ matrix.autoappend.name }}, ${{ matrix.casesensitive.name }}, ${{ matrix.shared_lib.name }}, C++${{ matrix.cppstd }}
102118
path: |
103119
build/src/*
104120
build/test/*
@@ -208,26 +224,58 @@ jobs:
208224
209225
build-ubuntu-sdl2:
210226

211-
name: Ubuntu latest - GCC, ${{ matrix.portal.name }}, Static, SDL2
227+
name: Ubuntu latest - GCC, ${{ matrix.portal.name }}, ${{ matrix.wayland.name }}, Static, SDL2
212228
runs-on: ubuntu-latest
213229

214230
strategy:
215231
matrix:
216232
portal: [ {flag: OFF, dep: libgtk-3-dev, name: GTK}, {flag: ON, dep: libdbus-1-dev, name: Portal} ] # The NFD_PORTAL setting defaults to OFF (i.e. uses GTK)
233+
wayland: [ {flag: OFF, dep: , name: NoWayland}, {flag: ON, dep: libwayland-dev libwayland-bin, name: Wayland} ]
217234

218235
steps:
219236
- name: Checkout
220237
uses: actions/checkout@v4
238+
with:
239+
submodules: true
221240
- name: Install Dependencies
222-
run: sudo apt-get update && sudo apt-get install ${{ matrix.portal.dep }} libsdl2-dev libsdl2-ttf-dev
241+
run: sudo apt-get update && sudo apt-get install ${{ matrix.portal.dep }} ${{ matrix.wayland.dep }} libsdl2-dev libsdl2-ttf-dev
223242
- name: Configure
224-
run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DNFD_PORTAL=${{ matrix.portal.flag }} -DNFD_APPEND_EXTENSION=OFF -DNFD_BUILD_TESTS=OFF -DNFD_BUILD_SDL2_TESTS=ON ..
243+
run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DNFD_PORTAL=${{ matrix.portal.flag }} -DNFD_WAYLAND=${{ matrix.wayland.flag }} -DNFD_APPEND_EXTENSION=OFF -DNFD_BUILD_TESTS=OFF -DNFD_BUILD_SDL2_TESTS=ON ..
225244
- name: Build
226245
run: cmake --build build --target install
227246
- name: Upload test binaries
228247
uses: actions/upload-artifact@v4
229248
with:
230-
name: Ubuntu latest - GCC, ${{ matrix.portal.name }}, Static, SDL2
249+
name: Ubuntu latest - GCC, ${{ matrix.portal.name }}, ${{ matrix.wayland.name }}, Static, SDL2
250+
path: |
251+
build/src/*
252+
build/test/*
253+
254+
build-ubuntu-glfw3:
255+
256+
name: Ubuntu latest - GCC, ${{ matrix.portal.name }}, ${{ matrix.wayland.name }}, Static, GLFW3
257+
runs-on: ubuntu-latest
258+
259+
strategy:
260+
matrix:
261+
portal: [ {flag: OFF, dep: libgtk-3-dev, name: GTK}, {flag: ON, dep: libdbus-1-dev, name: Portal} ] # The NFD_PORTAL setting defaults to OFF (i.e. uses GTK)
262+
wayland: [ {flag: OFF, dep: , name: NoWayland}, {flag: ON, dep: libwayland-dev libwayland-bin, name: Wayland} ]
263+
264+
steps:
265+
- name: Checkout
266+
uses: actions/checkout@v4
267+
with:
268+
submodules: true
269+
- name: Install Dependencies
270+
run: sudo apt-get update && sudo apt-get install ${{ matrix.portal.dep }} ${{ matrix.wayland.dep }} libglfw3-dev
271+
- name: Configure
272+
run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DNFD_PORTAL=${{ matrix.portal.flag }} -DNFD_WAYLAND=${{ matrix.wayland.flag }} -DNFD_APPEND_EXTENSION=OFF -DNFD_BUILD_TESTS=OFF -DNFD_BUILD_GLFW3_TESTS=ON ..
273+
- name: Build
274+
run: cmake --build build --target install
275+
- name: Upload test binaries
276+
uses: actions/upload-artifact@v4
277+
with:
278+
name: Ubuntu latest - GCC, ${{ matrix.portal.name }}, ${{ matrix.wayland.name }}, Static, GLFW3
231279
path: |
232280
build/src/*
233281
build/test/*
@@ -254,6 +302,28 @@ jobs:
254302
build/src/*
255303
build/test/*
256304
305+
build-macos-glfw3:
306+
307+
name: MacOS latest - Clang, Static, GLFW3
308+
runs-on: macos-latest
309+
310+
steps:
311+
- name: Checkout
312+
uses: actions/checkout@v4
313+
- name: Install Dependencies
314+
run: brew install glfw
315+
- name: Configure
316+
run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DNFD_BUILD_TESTS=OFF -DNFD_BUILD_GLFW3_TESTS=ON ..
317+
- name: Build
318+
run: cmake --build build --target install
319+
- name: Upload test binaries
320+
uses: actions/upload-artifact@v4
321+
with:
322+
name: MacOS latest - Clang, Static, GLFW3
323+
path: |
324+
build/src/*
325+
build/test/*
326+
257327
build-windows-sdl2:
258328

259329
name: Windows latest - MSVC, Static, SDL2
@@ -277,3 +347,27 @@ jobs:
277347
path: |
278348
build/src/Release/*
279349
build/test/Release/*
350+
351+
build-windows-glfw3:
352+
353+
name: Windows latest - MSVC, Static, GLFW3
354+
runs-on: windows-latest
355+
356+
steps:
357+
- name: Checkout
358+
uses: actions/checkout@v4
359+
- name: Install pkgconfiglite
360+
run: choco install pkgconfiglite
361+
- name: Install Dependencies
362+
run: vcpkg integrate install && vcpkg install glfw3 --triplet=x64-windows-release
363+
- name: Configure
364+
run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="x64-windows-release" -DNFD_BUILD_TESTS=OFF -DNFD_BUILD_GLFW3_TESTS=ON ..
365+
- name: Build
366+
run: cmake --build build --target install --config Release
367+
- name: Upload test binaries
368+
uses: actions/upload-artifact@v4
369+
with:
370+
name: Windows latest - MSVC, Static, GLFW3
371+
path: |
372+
build/src/Release/*
373+
build/test/Release/*

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "3ps/wayland-protocols"]
2+
path = 3ps/wayland-protocols
3+
url = https://gitlab.freedesktop.org/wayland/wayland-protocols.git

3ps/wayland-protocols

Submodule wayland-protocols added at 8822301

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ endif ()
99
option(BUILD_SHARED_LIBS "Build a shared library instead of static" OFF)
1010
option(NFD_BUILD_TESTS "Build tests for nfd" ${nfd_ROOT_PROJECT})
1111
option(NFD_BUILD_SDL2_TESTS "Build SDL2 tests for nfd" OFF)
12+
option(NFD_BUILD_GLFW3_TESTS "Build GLFW3 tests for nfd" OFF)
1213
option(NFD_INSTALL "Generate install target for nfd" ${nfd_ROOT_PROJECT})
1314

1415
set(nfd_PLATFORM Undefined)
@@ -47,6 +48,6 @@ endif()
4748

4849
add_subdirectory(src)
4950

50-
if(${NFD_BUILD_TESTS} OR ${NFD_BUILD_SDL2_TESTS})
51+
if(${NFD_BUILD_TESTS} OR ${NFD_BUILD_SDL2_TESTS} OR ${NFD_BUILD_GLFW3_TESTS})
5152
add_subdirectory(test)
5253
endif()

0 commit comments

Comments
 (0)