Wayland: make OPTION_USE_SYSTEM_LIBDECOR ON by default
This commit makes the default FLTK build setting use libdecor as packaged in Linux when the build system contains packages libdecor-0-dev and libdecor-0-plugin-1-gtk in version ≥ 0.2.0. Otherwise, FLTK uses the bundled version of libdecor. This includes situations where package libdecor-0-dev is present in an earlier version.
This commit is contained in:
parent
96730f80cb
commit
f72748bb45
@ -258,7 +258,7 @@ if (UNIX)
|
||||
endif (X11_FOUND)
|
||||
unset (OPTION_USE_CAIRO CACHE)
|
||||
set (OPTION_USE_CAIRO TRUE CACHE BOOL "all drawing to X11 windows uses Cairo")
|
||||
option (OPTION_USE_SYSTEM_LIBDECOR "use libdecor from the system" OFF)
|
||||
option (OPTION_USE_SYSTEM_LIBDECOR "use libdecor from the system" ON)
|
||||
unset (OPTION_USE_XRENDER CACHE)
|
||||
unset (OPTION_USE_XINERAMA CACHE)
|
||||
unset (OPTION_USE_XFT CACHE)
|
||||
@ -293,13 +293,25 @@ if (UNIX)
|
||||
unset (OPTION_USE_PANGO CACHE)
|
||||
set (OPTION_USE_PANGO TRUE CACHE BOOL "use lib Pango")
|
||||
if (OPTION_USE_SYSTEM_LIBDECOR)
|
||||
pkg_check_modules(SYSTEM_LIBDECOR libdecor-0)
|
||||
pkg_check_modules(SYSTEM_LIBDECOR libdecor-0>=0.2.0)
|
||||
if (NOT SYSTEM_LIBDECOR_FOUND)
|
||||
set (OPTION_USE_SYSTEM_LIBDECOR OFF)
|
||||
else ()
|
||||
pkg_get_variable(LIBDECOR_LIBDIR libdecor-0 libdir)
|
||||
set (LIBDECOR_PLUGIN_DIR ${LIBDECOR_LIBDIR}/libdecor/plugins-1)
|
||||
if (EXISTS ${LIBDECOR_PLUGIN_DIR} AND IS_DIRECTORY ${LIBDECOR_PLUGIN_DIR})
|
||||
set (LIBDECOR_PLUGIN_DIR "\\\"${LIBDECOR_PLUGIN_DIR}\\\" " )
|
||||
else ()
|
||||
set (OPTION_USE_SYSTEM_LIBDECOR OFF)
|
||||
endif ()
|
||||
endif (NOT SYSTEM_LIBDECOR_FOUND)
|
||||
endif (OPTION_USE_SYSTEM_LIBDECOR)
|
||||
|
||||
if (OPTION_USE_SYSTEM_LIBDECOR)
|
||||
set (OPTION_ALLOW_GTK_PLUGIN ON)
|
||||
else ()
|
||||
option (OPTION_ALLOW_GTK_PLUGIN "Allow to use libdecor's GTK plugin" ON)
|
||||
endif (OPTION_USE_SYSTEM_LIBDECOR)
|
||||
|
||||
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
CHECK_INCLUDE_FILE (linux/input.h LINUX_INPUT_H)
|
||||
@ -856,7 +868,7 @@ if ((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND OPTION_USE_PANGO)
|
||||
|
||||
endif ((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND OPTION_USE_PANGO)
|
||||
|
||||
if (OPTION_USE_WAYLAND AND NOT OPTION_USE_SYSTEM_LIBDECOR)
|
||||
if (OPTION_USE_WAYLAND)
|
||||
|
||||
# Note: Disable OPTION_ALLOW_GTK_PLUGIN to get cairo titlebars rather than GTK
|
||||
if (OPTION_ALLOW_GTK_PLUGIN)
|
||||
@ -869,7 +881,7 @@ if (OPTION_USE_WAYLAND AND NOT OPTION_USE_SYSTEM_LIBDECOR)
|
||||
endif (GTK_FOUND)
|
||||
endif (OPTION_ALLOW_GTK_PLUGIN)
|
||||
|
||||
endif (OPTION_USE_WAYLAND AND NOT OPTION_USE_SYSTEM_LIBDECOR)
|
||||
endif (OPTION_USE_WAYLAND)
|
||||
|
||||
if (OPTION_USE_XFT)
|
||||
set (USE_XFT X11_Xft_FOUND)
|
||||
|
@ -281,6 +281,11 @@ if (UNIX AND NOT (APPLE AND NOT OPTION_APPLE_X11))
|
||||
|
||||
if (OPTION_USE_WAYLAND)
|
||||
message (STATUS "Use Wayland : Yes (if available at run-time)")
|
||||
if (OPTION_USE_SYSTEM_LIBDECOR)
|
||||
message (STATUS "Use system libdecor : Yes")
|
||||
else ()
|
||||
message (STATUS "Use system libdecor : No")
|
||||
endif ()
|
||||
else ()
|
||||
message (STATUS "Use Wayland : No (therefore, X11 is used)")
|
||||
endif ()
|
||||
|
@ -232,10 +232,12 @@ OPTION_USE_STD - default OFF
|
||||
or major (maybe 4.0.0) release which will default to use std::string
|
||||
and more modern C++ features.
|
||||
|
||||
OPTION_USE_SYSTEM_LIBDECOR - default OFF
|
||||
This option makes FLTK use package libdecor-0 to draw window titlebars
|
||||
under Wayland. It's mainly meant for future use, when that package
|
||||
and its plugins will be part of major Linux distributions.
|
||||
OPTION_USE_SYSTEM_LIBDECOR - default ON
|
||||
This option makes FLTK use package libdecor-0-dev to draw window titlebars
|
||||
under Wayland. When OFF or when this package has a version < 0.2.0, FLTK
|
||||
uses its bundled copy of libdecor to draw window titlebars.
|
||||
As of november 2023, version 0.2.0 of package libdecor-0-dev is available
|
||||
only in testing distributions.
|
||||
|
||||
Documentation options: these options are only available if `doxygen' is
|
||||
installed and found by CMake. PDF related options require also `latex'.
|
||||
|
@ -75,10 +75,10 @@ be used to produce a Wayland-only library which can be useful, e.g., when
|
||||
cross-compiling for systems that lack X11 headers and libraries.
|
||||
|
||||
The FLTK Wayland platform uses a library called libdecor which handles window decorations
|
||||
(i.e., titlebars, shade). Libdecor is bundled in the FLTK source code and FLTK uses by default
|
||||
this form of libdecor. CMake OPTION_USE_SYSTEM_LIBDECOR can be turned on to have FLTK
|
||||
use the system's version of libdecor which is available on recent Linux distributions (e.g.,
|
||||
Debian Bookworm or more recent in packages libdecor-0-0 and libdecor-0-plugin-1-cairo).
|
||||
(i.e., titlebars, shade). On very recent Linux distributions (e.g., Debian trixie)
|
||||
libdecor is available as Linux packages (libdecor-0-dev and libdecor-0-plugin-1-gtk).
|
||||
FLTK requires version 0.2.0 of these packages or more.
|
||||
In other situations, FLTK uses a copy of libdecor bundled in the FLTK source code.
|
||||
FLTK equipped with libdecor supports both the client-side decoration mode (CSD) and the
|
||||
server-side decoration mode (SSD) as determined by the active Wayland compositor.
|
||||
Mutter (gnome's Wayland compositor) and Weston use CSD mode, KWin and Sway use SSD mode.
|
||||
@ -145,6 +145,9 @@ in section 2.1 of file README.Unix.txt :
|
||||
These packages allow to run FLTK apps under the Gnome-Wayland desktop:
|
||||
- gnome-core
|
||||
- libgtk-3-dev <== highly recommended, gives windows a Gnome-style titlebar
|
||||
- libdecor-0-dev and libdecor-0-plugin-1-gtk in versions ≥ 0.2.0
|
||||
<== Recommended if available for the Linux version in use,
|
||||
<== FLTK uses a bundled copy of these packages otherwise.
|
||||
|
||||
These packages allow to run FLTK apps under the KDE/Plasma-Wayland desktop:
|
||||
- kde-plasma-desktop
|
||||
@ -169,6 +172,7 @@ package groups listed in section 2.2 of file README.Unix.txt :
|
||||
- mesa-libGLU-devel
|
||||
- dbus-devel <== recommended to query current cursor theme
|
||||
- gtk3-devel <== highly recommended, gives windows a GTK-style titlebar
|
||||
- libdecor-0.2.0 <== recommended, present in Fedora Rawhide, not in Fedora 39
|
||||
- glew-devel <== necessary to use OpenGL version 3 or above
|
||||
- cmake <== if you plan to build with CMake
|
||||
- cmake-gui <== if you plan to use the GUI of CMake
|
||||
|
12
configure.ac
12
configure.ac
@ -1055,12 +1055,18 @@ AS_CASE([$host_os_gui], [cygwin* | mingw*], [
|
||||
BUILD="WAYLANDX11"
|
||||
graphics="Wayland or X11 with cairo"
|
||||
])
|
||||
# CFLAGS="$CFLAGS -DUSE_SYSTEM_LIBDECOR=0"
|
||||
# CXXFLAGS="$CXXFLAGS -DUSE_SYSTEM_LIBDECOR=0"
|
||||
AS_IF([$PKGCONFIG --exists 'libdecor-0 >= 0.2.0'],
|
||||
[
|
||||
plugin_dir="$($PKGCONFIG --variable=libdir libdecor-0)/libdecor/plugins-1"
|
||||
CFLAGS="$CFLAGS -DUSE_SYSTEM_LIBDECOR"
|
||||
CFLAGS="$CFLAGS -DLIBDECOR_PLUGIN_DIR=\\\"$plugin_dir\\\" "
|
||||
LIBS="$LIBS $($PKGCONFIG --libs libdecor-0)"
|
||||
],
|
||||
[CFLAGS="$CFLAGS -DUSE_SYSTEM_LIBDECOR=0 -DLIBDECOR_PLUGIN_DIR=\"\" "]
|
||||
)
|
||||
LIBS="$LIBS $($PKGCONFIG --libs wayland-cursor) $($PKGCONFIG --libs wayland-client) $($PKGCONFIG --libs xkbcommon) $($PKGCONFIG --libs pangocairo) "
|
||||
AS_IF([test x$enable_x11 != xno], [LIBS="$LIBS $($PKGCONFIG --libs x11)"] )
|
||||
LIBS="$LIBS -ldl"
|
||||
# CXXFLAGS="$CXXFLAGS -I../libdecor/src"
|
||||
DSOFLAGS="$LIBS $DSOFLAGS"
|
||||
enable_pango=yes
|
||||
LIBDECORDIR="libdecor/build"
|
||||
|
@ -26,7 +26,7 @@ always entirely filled with whatever resizable windows are mapped at any given
|
||||
time. Compositors follow either the
|
||||
client-side decoration (CSD) rule where client apps draw window titlebars, or the
|
||||
server-side decoration (SSD) rule where the compositor draws titlebars. FLTK supports both
|
||||
CSD and SSD compositors. It bundles a library called \c libdecor charged of determining whether
|
||||
CSD and SSD compositors. It uses a library called \c libdecor charged of determining whether
|
||||
a CSD or a SSD compositor is active, and of drawing titlebars in the first case.
|
||||
|
||||
Wayland is divided in various protocols that a given compositor may or may not support,
|
||||
@ -92,7 +92,7 @@ Overall, and ignoring for now OpenGL usage, FLTK interacts with Wayland as follo
|
||||
- When opening the display: FLTK calls \c Fl::add_fd() in \c FL_READ mode to associate
|
||||
a callback function to the socket connecting the client and the compositor.
|
||||
- Client to compositor: FLTK calls C functions of the \c libwayland-client.so,
|
||||
\c libwayland-cursor.so and \c libxkbcommon.so shared libraries and of the bundled
|
||||
\c libwayland-cursor.so and \c libxkbcommon.so shared libraries and of the
|
||||
libdecor library. These send suitable messages to the compositor writing to the socket.
|
||||
The names of these functions begin with \c wl_, \c xkb_ or \c libdecor_.
|
||||
- Compositor to client: the callback function runs when there are data to read in the
|
||||
@ -1061,14 +1061,25 @@ and also to draw window titlebars when in CSD mode (see \ref bundled-libdecor).
|
||||
\c Libdecor is conceived to be present in a shared library linked to the Wayland
|
||||
client application which itself, and if the running Wayland compositor uses CSD mode,
|
||||
loads another shared library intended to draw titlebars in a way that best matches the
|
||||
Desktop. As of early 2023, two titlebar-drawing \c libdecor plugins are available:
|
||||
Desktop. As of late 2023, libdecor is at version 0.2.0 and contains two titlebar-drawing
|
||||
plugins:
|
||||
- \c libdecor-gtk intended for the Gnome desktop;
|
||||
- \c libdecor-cairo for other situations.
|
||||
|
||||
Because \c libdecor is not yet in Linux packages, or only in a preliminary state, FLTK bundles the
|
||||
most recent source code of \c libdecor and its plugins. This code is included in libfltk.
|
||||
FLTK uses \c libdecor-gtk when software package \c libgtk-3-dev is present in the
|
||||
build system, and \c libdecor-cairo otherwise.
|
||||
Because \c libdecor is not yet in major Linux packages, or only at version 0.1.x,
|
||||
FLTK bundles the most recent source code of \c libdecor and its plugins. This code
|
||||
is included in libfltk. FLTK uses \c libdecor-gtk when software package \c libgtk-3-dev
|
||||
is present in the build system, and \c libdecor-cairo otherwise.
|
||||
|
||||
As of late 2023, libdecor version 0.2.0 is available in very recent Linux distributions
|
||||
in packages \c libdecor-0-dev and \c libdecor-0-plugin-1-gtk. If they are installed on the
|
||||
build system, preprocessor variable \c USE_SYSTEM_LIBDECOR is 1,
|
||||
and both \c libdecor and its plugin are loaded at run-time from shared libraries.
|
||||
When these packages are not available or are at an earlier version, FLTK uses the bundled
|
||||
copy of \c libdecor.
|
||||
When CMake \c OPTION_USE_SYSTEM_LIBDECOR is OFF, FLTK uses the bundled \c libdecor copy
|
||||
even if shared libraries \c libdecor.so and \c libdecor-gtk.so are installed.
|
||||
This option is ON by default.
|
||||
|
||||
\c Libdecor uses the Wayland protocol
|
||||
<a href=https://wayland.app/protocols/xdg-decoration-unstable-v1>
|
||||
@ -1079,12 +1090,6 @@ However, if environment variable \c LIBDECOR_FORCE_CSD is defined to value \c 1
|
||||
FLTK app runs, \c libdecor instructs an SSD-able compositor to refrain from decorating its
|
||||
windows and decorates windows itself.
|
||||
|
||||
CMake \c OPTION_USE_SYSTEM_LIBDECOR has been defined to allow FLTK in the future, when \c libdecor and
|
||||
\c libdecor-gtk will be part of Linux packages, to use these packages rather than the \c libdecor
|
||||
code bundled in FLTK. When this option is ON, preprocessor variable \c USE_SYSTEM_LIBDECOR is 1,
|
||||
and both \c libdecor and its plugin are loaded at run-time from shared libraries. This option is OFF
|
||||
by default.
|
||||
|
||||
Whatever the value of \c OPTION_USE_SYSTEM_LIBDECOR, FLTK and \c libdecor use environment variable
|
||||
\c LIBDECOR_PLUGIN_DIR as follows: if this variable is defined and points to the name of a directory,
|
||||
this directory is searched for a potential \c libdecor plugin in the form of a shared library;
|
||||
|
@ -27,7 +27,7 @@ FreeBSD_CFLAGS = -I/usr/local/include
|
||||
EXTRA_DECOR = ${${UNAME}_CFLAGS}
|
||||
|
||||
CFLAGS_DECOR = -I. -I../.. -I../../src -I../src -I../src/plugins $(EXTRA_DECOR) -fPIC -D_GNU_SOURCE \
|
||||
-DUSE_SYSTEM_LIBDECOR=0 -DHAVE_MEMFD_CREATE -DHAVE_MKOSTEMP -DHAVE_POSIX_FALLOCATE
|
||||
-DHAVE_MEMFD_CREATE -DHAVE_MKOSTEMP -DHAVE_POSIX_FALLOCATE
|
||||
|
||||
Linux_NOPIE = -no-pie
|
||||
FreeBSD_NOPIE =
|
||||
@ -39,10 +39,10 @@ depend:
|
||||
: echo "libdecor/build: make depend..."
|
||||
|
||||
fl_libdecor.o : fl_libdecor.c ../src/libdecor.c ../../src/xdg-shell-protocol.c ../../src/xdg-decoration-protocol.c ../../src/text-input-protocol.c ../../src/gtk-shell-protocol.c
|
||||
$(CC) $(CFLAGS) $(CFLAGS_DECOR) -c fl_libdecor.c -DLIBDECOR_PLUGIN_API_VERSION=1 -DLIBDECOR_PLUGIN_DIR=\"\"
|
||||
$(CC) $(CFLAGS) $(CFLAGS_DECOR) -c fl_libdecor.c -DLIBDECOR_PLUGIN_API_VERSION=1
|
||||
|
||||
fl_libdecor-plugins.o : fl_libdecor-plugins.c ../src/plugins/cairo/libdecor-cairo.c
|
||||
$(CC) $(CFLAGS) $(CFLAGS_DECOR) -c fl_libdecor-plugins.c -DLIBDECOR_PLUGIN_API_VERSION=1 -DLIBDECOR_PLUGIN_DIR=\"\"
|
||||
$(CC) $(CFLAGS) $(CFLAGS_DECOR) -c fl_libdecor-plugins.c -DLIBDECOR_PLUGIN_API_VERSION=1
|
||||
|
||||
libdecor-cairo-blur.o : ../src/plugins/common/libdecor-cairo-blur.c
|
||||
$(CC) $(CFLAGS_DECOR) -c ../src/plugins/common/libdecor-cairo-blur.c
|
||||
|
@ -15,6 +15,7 @@
|
||||
//
|
||||
|
||||
/* Improvements to libdecor.c without modifying libdecor.c itself */
|
||||
#if ! USE_SYSTEM_LIBDECOR
|
||||
|
||||
#include "xdg-shell-client-protocol.h"
|
||||
#ifdef XDG_TOPLEVEL_STATE_SUSPENDED_SINCE_VERSION
|
||||
@ -126,3 +127,5 @@ LIBDECOR_EXPORT struct libdecor *libdecor_new(struct wl_display *wl_display, str
|
||||
wl_display_flush(wl_display);
|
||||
return context;
|
||||
}
|
||||
|
||||
#endif //! USE_SYSTEM_LIBDECOR
|
||||
|
@ -521,10 +521,7 @@ if (OPTION_USE_WAYLAND)
|
||||
endif (DBUS_FOUND)
|
||||
if (OPTION_USE_SYSTEM_LIBDECOR)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_SYSTEM_LIBDECOR")
|
||||
get_filename_component(PATH_TO_SHARED_LIBS ${HAVE_LIB_PANGO} DIRECTORY)
|
||||
set (LIBDECOR_PLUGIN_DIR "\\\"${PATH_TO_SHARED_LIBS}/libdecor/plugins-1\\\" " )
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLIBDECOR_PLUGIN_DIR=${LIBDECOR_PLUGIN_DIR} ")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_SYSTEM_LIBDECOR")
|
||||
if (GTK_FOUND)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_GTK")
|
||||
endif (GTK_FOUND)
|
||||
@ -690,7 +687,8 @@ if (UNIX AND OPTION_USE_WAYLAND)
|
||||
)
|
||||
list (APPEND STATIC_FILES "xdg-decoration-protocol.c")
|
||||
list (APPEND SHARED_FILES "xdg-decoration-protocol.c")
|
||||
if (GTK_FOUND AND OPTION_ALLOW_GTK_PLUGIN)
|
||||
endif (NOT OPTION_USE_SYSTEM_LIBDECOR)
|
||||
if (GTK_FOUND AND (OPTION_USE_SYSTEM_LIBDECOR OR OPTION_ALLOW_GTK_PLUGIN))
|
||||
add_custom_command(
|
||||
OUTPUT gtk-shell-protocol.c gtk-shell-client-protocol.h
|
||||
COMMAND wayland-scanner private-code ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/gtk-shell.xml gtk-shell-protocol.c
|
||||
@ -700,8 +698,7 @@ if (UNIX AND OPTION_USE_WAYLAND)
|
||||
)
|
||||
list (APPEND STATIC_FILES "gtk-shell-protocol.c")
|
||||
list (APPEND SHARED_FILES "gtk-shell-protocol.c")
|
||||
endif (GTK_FOUND AND OPTION_ALLOW_GTK_PLUGIN)
|
||||
endif (NOT OPTION_USE_SYSTEM_LIBDECOR)
|
||||
endif (GTK_FOUND AND (OPTION_USE_SYSTEM_LIBDECOR OR OPTION_ALLOW_GTK_PLUGIN))
|
||||
add_custom_command(
|
||||
OUTPUT text-input-protocol.c text-input-client-protocol.h
|
||||
COMMAND wayland-scanner private-code ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml text-input-protocol.c
|
||||
|
@ -1792,25 +1792,6 @@ int Fl_Wayland_Window_Driver::set_cursor_4args(const Fl_RGB_Image *rgb, int hotx
|
||||
}
|
||||
|
||||
|
||||
#if defined(USE_SYSTEM_LIBDECOR) && USE_SYSTEM_LIBDECOR
|
||||
// This is only to fix a bug in libdecor where what libdecor_frame_set_min_content_size()
|
||||
// does is often destroyed by libdecor-cairo.
|
||||
static void delayed_minsize(Fl_Window *win) {
|
||||
struct wld_window *wl_win = fl_wl_xid(win);
|
||||
Fl_Window_Driver *driver = Fl_Window_Driver::driver(win);
|
||||
if (wl_win->kind == Fl_Wayland_Window_Driver::DECORATED) {
|
||||
float f = Fl::screen_scale(win->screen_num());
|
||||
libdecor_frame_set_min_content_size(wl_win->frame, driver->minw()*f, driver->minh()*f);
|
||||
}
|
||||
bool need_resize = false;
|
||||
int W = win->w(), H = win->h();
|
||||
if (W < driver->minw()) { W = driver->minw(); need_resize = true; }
|
||||
if (H < driver->minh()) { H = driver->minh(); need_resize = true; }
|
||||
if (need_resize) win->size(W, H);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void Fl_Wayland_Window_Driver::resize(int X, int Y, int W, int H) {
|
||||
struct wld_window *fl_win = fl_wl_xid(pWindow);
|
||||
if (fl_win && fl_win->kind == DECORATED && !xdg_toplevel()) {
|
||||
@ -1890,11 +1871,6 @@ void Fl_Wayland_Window_Driver::resize(int X, int Y, int W, int H) {
|
||||
xdg_surface_set_window_geometry(fl_win->xdg_surface, 0, 0, W, H);
|
||||
//printf("xdg_surface_set_window_geometry: %dx%d\n",W, H);
|
||||
}
|
||||
#if defined(USE_SYSTEM_LIBDECOR) && USE_SYSTEM_LIBDECOR
|
||||
if (W < minw() || H < minh()) {
|
||||
Fl::add_timeout(0.01, (Fl_Timeout_Handler)delayed_minsize, pWindow);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (!in_handle_configure && xdg_toplevel()) {
|
||||
// Wayland doesn't seem to provide a reliable way for the app to set the
|
||||
|
Loading…
Reference in New Issue
Block a user