Skip to content

Commit

Permalink
Merge branch 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWM committed Mar 17, 2024
2 parents d50de99 + 036e033 commit 23fe5c7
Show file tree
Hide file tree
Showing 36 changed files with 295 additions and 425 deletions.
22 changes: 12 additions & 10 deletions CMake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -287,19 +287,21 @@ if(UNIX)

if(FLTK_BACKEND_WAYLAND)
set(FLTK_USE_WAYLAND 1)
include(FindX11)
if(FLTK_BACKEND_X11)
include(FindX11)
endif()
if(FLTK_BACKEND_X11 AND X11_FOUND)
set(FLTK_USE_X11 1) # build a hybrid Wayland/X11 library
else()
set(FLTK_USE_X11 0) # build a Wayland-only library
endif()
unset(FLTK_GRAPHICS_CAIRO CACHE)
set(FLTK_GRAPHICS_CAIRO TRUE CACHE BOOL "all drawing to X11 windows uses Cairo")
option(FLTK_USE_SYSTEM_LIBDECOR "use libdecor from the system" ON)
option(FLTK_USE_SYSTEM_LIBDECOR "use libdecor from the system" OFF)
set(USE_SYSTEM_LIBDECOR 1)
unset(FLTK_USE_XRENDER CACHE)
unset(FLTK_USE_XINERAMA CACHE)
# unset(FLTK_USE_XFT CACHE)
unset(FLTK_USE_XFT CACHE)
unset(FLTK_USE_XCURSOR CACHE)
unset(FLTK_USE_XFIXES CACHE)
if(X11_FOUND)
Expand Down Expand Up @@ -331,9 +333,9 @@ if(UNIX)
unset(FLTK_USE_PANGO CACHE)
set(FLTK_USE_PANGO TRUE CACHE BOOL "use lib Pango")
if(FLTK_USE_SYSTEM_LIBDECOR)
pkg_check_modules(SYSTEM_LIBDECOR libdecor-0>=0.2.0 QUIET)
pkg_check_modules(SYSTEM_LIBDECOR libdecor-0>0.2.2 QUIET)
if(NOT SYSTEM_LIBDECOR_FOUND)
message(STATUS "Warning: system libdecor doesn't satisfy version >= 0.2.0,")
message(STATUS "Warning: system libdecor doesn't satisfy version > 0.2.2,")
message(STATUS " using bundled libdecor library instead.")
set(USE_SYSTEM_LIBDECOR 0)
else()
Expand Down Expand Up @@ -804,7 +806,7 @@ if(FLTK_GRAPHICS_CAIRO)
set(FLTK_USE_PANGO TRUE CACHE BOOL "use lib Pango")
endif(FLTK_GRAPHICS_CAIRO)

if(FLTK_USE_PANGO OR FLTK_GRAPHICS_CAIRO) # implies to use PANGOXFT
if(FLTK_USE_X11 AND (FLTK_USE_PANGO OR FLTK_GRAPHICS_CAIRO)) # implies to use PANGOXFT
set(USE_PANGOXFT true)
endif()

Expand Down Expand Up @@ -866,11 +868,11 @@ if((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND FLTK_USE_PANGO)
list(REMOVE_DUPLICATES FLTK_LDLIBS)

# *FIXME* Libraries should not be added explicitly if possible
if(FLTK_BACKEND_WAYLAND)
if(FLTK_BACKEND_WAYLAND AND FLTK_USE_LIBDECOR_GTK AND NOT USE_SYSTEM_LIBDECOR)
list(APPEND FLTK_LDLIBS -lgtk-3 -lgdk-3 -lgio-2.0)
if(FLTK_BACKEND_X11)
list(APPEND FLTK_LDLIBS -lX11)
endif()
endif()
if(FLTK_BACKEND_X11)
list(APPEND FLTK_LDLIBS -lX11)
endif()

list(REMOVE_DUPLICATES FLTK_LDLIBS)
Expand Down
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,19 @@ endif()
if(UNIX AND NOT (APPLE AND NOT FLTK_BACKEND_X11))

if(FLTK_BACKEND_WAYLAND)
message(STATUS "Use Wayland : Yes (if available at run-time)")
if(FLTK_BACKEND_X11)
message(STATUS "Use Wayland : Yes (can also run as X11 client)")
else()
message(STATUS "Use Wayland : Yes (cannot run as X11 client)")
endif(FLTK_BACKEND_X11)
if(USE_SYSTEM_LIBDECOR)
message(STATUS "Use system libdecor : Yes")
else()
message(STATUS "Use system libdecor : No")
endif()
endif(USE_SYSTEM_LIBDECOR)
else()
message(STATUS "Use Wayland : No (therefore, X11 is used)")
endif()
endif(FLTK_BACKEND_WAYLAND)

if(FLTK_USE_CAIRO)
message(STATUS "All drawing uses Cairo : Yes")
Expand Down
3 changes: 2 additions & 1 deletion FL/Fl_Terminal.H
Original file line number Diff line number Diff line change
Expand Up @@ -944,9 +944,10 @@ protected:
private:
bool is_hist_ring_row(int grow) const;
bool is_disp_ring_row(int grow) const;
protected:
public:
int selection_text_len(void) const;
const char* selection_text(void) const;
protected:
void clear_mouse_selection(void);
bool selection_extend(int X,int Y);
void select_word(int grow, int gcol);
Expand Down
12 changes: 6 additions & 6 deletions FL/fl_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@

// -- nothing yet --

#endif // __clang__
#endif /* __clang__ */


/*
Expand All @@ -162,19 +162,19 @@
#define __fl_attr(x) __attribute__ (x)
#endif

#if FL_GCC_VERSION > 40500 // gcc 4.5.0
#if FL_GCC_VERSION > 40500 /* gcc 4.5.0 */
#ifndef FL_DEPRECATED
#define FL_DEPRECATED(msg, func) func __attribute__((deprecated(msg)))
#endif
#endif // gcc 4.5.0
#endif /* gcc 4.5.0 */

#if FL_GCC_VERSION > 30100 // gcc 3.1.0
#if FL_GCC_VERSION > 30100 /* gcc 3.1.0 */
#ifndef FL_DEPRECATED
#define FL_DEPRECATED(msg, func) func __attribute__((deprecated))
#endif
#endif // gcc 3.1.0
#endif /* gcc 3.1.0 */

#endif // __GNUC__
#endif /* __GNUC__ */


/*
Expand Down
2 changes: 1 addition & 1 deletion FL/platform_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ extern FL_EXPORT int fl_control_modifier();

#endif /* FL_PLATFORM_TYPES_H */

// This is currently the same for all platforms, but may change in the future
/* This is currently the same for all platforms but may change in the future */
struct Fl_Timestamp_t {
time_t sec;
int usec;
Expand Down
8 changes: 4 additions & 4 deletions README.CMake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,12 @@ FLTK_USE_PTHREADS - default ON except on Windows.
This option is ignored (switched OFF internally) on Windows except
when using Cygwin.

FLTK_USE_SYSTEM_LIBDECOR - default ON (Wayland only)
FLTK_USE_SYSTEM_LIBDECOR - default OFF (Wayland only)
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
under Wayland. When OFF or when this package has a version 0.2.2, 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.
As of early 2024, no version > 0.2.2 of package libdecor-0-dev is available
yet.

FLTK_USE_SYSTEM_LIBJPEG - default ON (macOS and Windows: OFF)
FLTK_USE_SYSTEM_LIBPNG - default ON (macOS and Windows: OFF)
Expand Down
44 changes: 33 additions & 11 deletions README.Unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ README.Unix.txt - Building FLTK on Unix/Linux Systems
3 How to Build FLTK Using GCC
3.1 Downloading and Unpacking
3.2 Configuration and Build Systems
3.3 Configuring FLTK with autoconf and configure
3.3 Configuring FLTK with autoconf and configure (deprecated)
3.4 Building FLTK
3.5 Testing FLTK
3.6 Installing FLTK
Expand All @@ -32,6 +32,13 @@ README.Unix.txt - Building FLTK on Unix/Linux Systems
[*] TODO: we still need to write these chapters


-------------------------------------------------------------------
Note: usage of autotools, configure, and the included Makefiles
to build the FLTK library is deprecated since FLTK 1.4 and will
be removed in the next minor version (1.5).
Please consider using CMake instead.
-------------------------------------------------------------------


1 Introduction
=================
Expand Down Expand Up @@ -298,23 +305,38 @@ The following paragraphs describe the "classic" build system with autoconf,
configure, and make that has been used to build FLTK up to version 1.3.x
and can still be used with FLTK 1.4.x.

However, the FLTK team recommend using CMake which is the preferred build
system since FLTK 1.4.0 used for all platforms (including Windows). CMake
is used instead of autoconf and configure to create the build system of your
choice, for instance Makefiles, Ninja build files, Visual Studio projects, etc.
However, the FLTK team recommend to use CMake which is the preferred build
system generator since FLTK 1.4 used for all platforms (including Windows).
CMake can be used to create the build system of your choice, for instance
Makefiles, Ninja build files, Xcode or Visual Studio IDE projects etc..

-------------------------------------------------------------------
Note: usage of autotools, configure, and the included Makefiles
to build the FLTK library is deprecated since FLTK 1.4 and will
be removed in the next minor version (1.5).
Please consider using CMake instead.
-------------------------------------------------------------------

Please see README.CMake.txt for how to build FLTK and your application
programs using CMake. You can stop reading here if you do this.

You can, of course, build FLTK with CMake and your own application(s) with
your existing and well-known build system.
You can, of course, build FLTK with CMake and your own application(s)
with your existing and well-known build system.

If you like the "classic" build system more, continue reading the
following chapters but please be aware that configure support will
be removed in FLTK 1.5.

If you like the "classic" build system more, continue reading the following
chapters ...

3.3 Configuring FLTK with autoconf and configure (deprecated)
----------------------------------------------------------------

3.3 Configuring FLTK with autoconf and configure
---------------------------------------------------
-------------------------------------------------------------------
Note: usage of autotools, configure, and the included Makefiles
to build the FLTK library is deprecated since FLTK 1.4 and will
be removed in the next minor version (1.5).
Please consider using CMake instead.
-------------------------------------------------------------------

If you got FLTK via git then you need one extra step. Otherwise skip
over this part. Stay in your FLTK source-code directory and type:
Expand Down
12 changes: 4 additions & 8 deletions README.Wayland.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ On Linux and FreeBSD systems equipped with the adequate software packages
hybrid library. On systems lacking all or part of Wayland-required packages,
the default building procedure produces a X11-based library.

Use "-D FLTK_OPTION_USE_WAYLAND=OFF" with CMake or "configure --disable-wayland"
Use "-D FLTK_BACKEND_WAYLAND=OFF" with CMake or "configure --disable-wayland"
to build FLTK for the X11 library when the default would build for Wayland.

CMake option FLTK_BACKEND_X11=OFF or configure argument "--disable-x11" can
Expand All @@ -126,8 +126,8 @@ 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). 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 requires a version > 0.2.2 of these packages that's not yet available.
Therefore, 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.
Expand Down Expand Up @@ -185,7 +185,7 @@ in section 2.1 of file README.Unix.txt :
- libwayland-dev
- wayland-protocols
- libxkbcommon-dev
- libxinerama-dev
- libxinerama-dev <== except if option FLTK_BACKEND_X11=off is used
- libdbus-1-dev <== recommended to query current cursor theme
- libglew-dev <== necessary to use OpenGL version 3 or above
- cmake <== if you plan to build with CMake
Expand All @@ -194,9 +194,6 @@ 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
Expand All @@ -221,7 +218,6 @@ 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
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ AS_CASE([$host_os_gui], [cygwin* | mingw*], [
BUILD="WAYLANDX11"
graphics="Wayland or X11 with cairo"
])
AS_IF([$PKGCONFIG --exists 'libdecor-0 >= 0.2.0'],
AS_IF([$PKGCONFIG --exists 'libdecor-0 > 0.2.2'],
[
plugin_dir="$($PKGCONFIG --variable=libdir libdecor-0)/libdecor/plugins-1"
CFLAGS="$CFLAGS -DUSE_SYSTEM_LIBDECOR"
Expand Down
4 changes: 2 additions & 2 deletions documentation/src/bundled-libs.dox
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ The nanosvg library is not affected.

\section bundled-status Current status
\code
Current versions of bundled libraries (as of March 12, 2024):
Current versions of bundled libraries (as of March 13, 2024):
Library Version/git commit Release date FLTK Version
--------------------------------------------------------------------------
jpeg jpeg-9f 2024-01-14 1.4.0
nanosvg 7aeda550a8 [1] 2023-12-02 1.4.0
png libpng-1.6.42 2024-01-29 1.4.0
zlib zlib-1.3.1 2024-01-22 1.4.0
libdecor 09875530 [2] 2024-03-03 1.4.0
libdecor 4f2c03d5 [2] 2024-03-04 1.4.0
--------------------------------------------------------------------------

Previous versions of bundled libraries (FLTK 1.3.x):
Expand Down
18 changes: 6 additions & 12 deletions documentation/src/wayland.dox
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ FLTK creates a \c wl_buffer object each time an Fl_Window is mapped on a display
That's done by member function \c Fl_Wayland_Graphics_Driver::create_shm_buffer()
which follows this 3-step procedure to create a "buffer factory" for FLTK and to construct
Wayland buffers from it:
- Libdecor function <tt>os_create_anonymous_file(off_t size)</tt> creates an adequate file
- Libdecor function <tt>libdecor_os_create_anonymous_file(off_t size)</tt> creates an adequate file
and mmap's it. This file lives in RAM because it is created by function \c memfd_create().
FLTK sets this file size to 10 MB unless the size of the buffer to be created
is larger; in that case the anonymous file is sized to twice the buffer size.
Expand Down Expand Up @@ -1104,8 +1104,7 @@ 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 late 2023, libdecor is at version 0.2.0 and contains two titlebar-drawing
plugins:
Desktop. As of late 2023, libdecor contains two titlebar-drawing plugins:
- \c libdecor-gtk intended for the Gnome desktop;
- \c libdecor-cairo for other situations.

Expand All @@ -1114,15 +1113,10 @@ FLTK bundles the most recent source code of \c libdecor and its plugins. This co
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 FLTK_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.
As of early 2024, libdecor version 0.2.2 is available in very recent Linux distributions.
This version is not binary compatible with the libdecor version bundled by FLTK.
For this reason, CMake option \c FLTK_USE_SYSTEM_LIBDECOR is OFF by default, and
FLTK uses the bundled \c libdecor copy to draw titlebars.

\c Libdecor uses the Wayland protocol
<a href=https://wayland.app/protocols/xdg-decoration-unstable-v1>XDG decoration</a>
Expand Down
8 changes: 1 addition & 7 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,8 @@ endforeach(src)
# create example programs requiring cairo
############################################################

if(FLTK_HAVE_CAIRO)
set(cairo_libs "fltk::fltk;cairo")
else()
set(cairo_libs "fltk::fltk")
endif()

foreach(src ${CAIRO_SOURCES})
fl_create_example(${src} ${src}.cxx "${cairo_libs}")
fl_create_example(${src} ${src}.cxx fltk::fltk)
endforeach(src)

############################################################
Expand Down
Loading

0 comments on commit 23fe5c7

Please sign in to comment.