diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-04-21 07:38:51 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-04-21 07:38:51 +0200 |
| commit | 9367bb5108e35134c9e5b570606bb76a7e4772c0 (patch) | |
| tree | ba46da049e11bdc16a9650337ba16c68db7a59a8 | |
| parent | 24885b3810c653eade5feb324e6f1619fcbf0bb2 (diff) | |
Avoid code duplication using os_create_anonymous_file() from libdecor.
| -rw-r--r-- | libdecor/build/Makefile | 3 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx | 18 |
3 files changed, 7 insertions, 16 deletions
diff --git a/libdecor/build/Makefile b/libdecor/build/Makefile index 789283cba..99f825d96 100644 --- a/libdecor/build/Makefile +++ b/libdecor/build/Makefile @@ -16,7 +16,8 @@ include ../../makeinclude -CFLAGS_DECOR = -I. -I../.. -I../../src -I../src -fPIC -D_GNU_SOURCE -DUSE_SYSTEM_LIBDECOR=0 +CFLAGS_DECOR = -I. -I../.. -I../../src -I../src -fPIC -D_GNU_SOURCE \ + -DUSE_SYSTEM_LIBDECOR=0 -DHAVE_MEMFD_CREATE -DHAVE_MKOSTEMP -DHAVE_POSIX_FALLOCATE OBJECTS = fl_libdecor.o libdecor-cairo-blur.o fl_libdecor-plugins.o \ ../../src/xdg-decoration-protocol.o ../../src/xdg-shell-protocol.o \ ../../src/text-input-protocol.o cursor-settings.o os-compatibility.o diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 01264e0a4..75f72a6d3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -468,7 +468,7 @@ if (OPTION_USE_WAYLAND) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_SYSTEM_LIBDECOR") else() set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src -DLIBDECOR_PLUGIN_API_VERSION=1 -DLIBDECOR_PLUGIN_DIR=\\\"/usr/local/lib\\\" ") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_SYSTEM_LIBDECOR=0") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_SYSTEM_LIBDECOR=0 -DHAVE_MEMFD_CREATE -DHAVE_MKOSTEMP -DHAVE_POSIX_FALLOCATE") endif (OPTION_USE_SYSTEM_LIBDECOR) if (GTK_FOUND) diff --git a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx index c593a207b..79044c522 100644 --- a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx @@ -32,23 +32,13 @@ extern unsigned fl_cmap[256]; // defined in fl_color.cxx +extern "C" { + int os_create_anonymous_file(off_t); +} static int create_anonymous_file(int size, char **pshared) { - int ret; - int fd = memfd_create("FLTK-for-Wayland", MFD_CLOEXEC | MFD_ALLOW_SEALING); - if (fd < 0) { - Fl::fatal("memfd_create failed: %s\n", strerror(errno)); - } - fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK); - do { - ret = posix_fallocate(fd, 0, size); - } while (ret == EINTR); - if (ret != 0) { - close(fd); - errno = ret; - Fl::fatal("creating anonymous file of size %d failed: %s\n", size, strerror(errno)); - } + int fd = os_create_anonymous_file(size); *pshared = (char*)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (*pshared == MAP_FAILED) { close(fd); |
