mirror of
https://github.com/fltk/fltk.git
synced 2026-06-02 15:46:52 +08:00
Make hybrid Wayland/X11 platform.
This commit is contained in:
+38
-2
@@ -197,12 +197,20 @@ if (UNIX)
|
|||||||
option (OPTION_USE_WAYLAND "use Wayland" OFF)
|
option (OPTION_USE_WAYLAND "use Wayland" OFF)
|
||||||
if (OPTION_USE_WAYLAND)
|
if (OPTION_USE_WAYLAND)
|
||||||
set (FLTK_USE_WAYLAND 1)
|
set (FLTK_USE_WAYLAND 1)
|
||||||
|
set (FLTK_USE_X11 1) # to build a hybrid Wayland/X11 library
|
||||||
|
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" OFF)
|
||||||
unset (OPTION_USE_XRENDER CACHE)
|
unset (OPTION_USE_XRENDER CACHE)
|
||||||
unset (OPTION_USE_XINERAMA CACHE)
|
unset (OPTION_USE_XINERAMA CACHE)
|
||||||
unset (OPTION_USE_XFT CACHE)
|
unset (OPTION_USE_XFT CACHE)
|
||||||
unset (OPTION_USE_XCURSOR CACHE)
|
unset (OPTION_USE_XCURSOR CACHE)
|
||||||
unset (OPTION_USE_XFIXES CACHE)
|
unset (OPTION_USE_XFIXES CACHE)
|
||||||
|
set (HAVE_XFIXES 1)
|
||||||
|
set (HAVE_XRENDER 1)
|
||||||
|
set (USE_XFT 1)
|
||||||
|
set (HAVE_XCURSOR 1)
|
||||||
|
set (HAVE_XINERAMA 1)
|
||||||
unset (OPTION_USE_PANGO CACHE)
|
unset (OPTION_USE_PANGO CACHE)
|
||||||
set (OPTION_USE_PANGO TRUE CACHE BOOL "use lib Pango")
|
set (OPTION_USE_PANGO TRUE CACHE BOOL "use lib Pango")
|
||||||
if (OPTION_USE_SYSTEM_LIBDECOR)
|
if (OPTION_USE_SYSTEM_LIBDECOR)
|
||||||
@@ -211,6 +219,9 @@ if (UNIX)
|
|||||||
set (OPTION_USE_SYSTEM_LIBDECOR OFF)
|
set (OPTION_USE_SYSTEM_LIBDECOR OFF)
|
||||||
endif (NOT SYSTEM_LIBDECOR_FOUND)
|
endif (NOT SYSTEM_LIBDECOR_FOUND)
|
||||||
endif (OPTION_USE_SYSTEM_LIBDECOR)
|
endif (OPTION_USE_SYSTEM_LIBDECOR)
|
||||||
|
|
||||||
|
option (OPTION_ALLOW_GTK_PLUGIN "Allow to use libdecor's GTK plugin" ON)
|
||||||
|
|
||||||
endif (OPTION_USE_WAYLAND)
|
endif (OPTION_USE_WAYLAND)
|
||||||
endif (UNIX)
|
endif (UNIX)
|
||||||
|
|
||||||
@@ -311,7 +322,7 @@ endif (OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION)
|
|||||||
# Include optional Cairo support
|
# Include optional Cairo support
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
option (OPTION_CAIRO "use lib Cairo" OFF)
|
option (OPTION_CAIRO "add support for Fl_Cairo_Window" OFF)
|
||||||
option (OPTION_CAIROEXT
|
option (OPTION_CAIROEXT
|
||||||
"use FLTK code instrumentation for Cairo extended use" OFF
|
"use FLTK code instrumentation for Cairo extended use" OFF
|
||||||
)
|
)
|
||||||
@@ -556,8 +567,17 @@ endif (OPTION_USE_XCURSOR)
|
|||||||
if (X11_Xft_FOUND)
|
if (X11_Xft_FOUND)
|
||||||
option (OPTION_USE_XFT "use lib Xft" ON)
|
option (OPTION_USE_XFT "use lib Xft" ON)
|
||||||
option (OPTION_USE_PANGO "use lib Pango" OFF)
|
option (OPTION_USE_PANGO "use lib Pango" OFF)
|
||||||
|
if (NOT OPTION_USE_WAYLAND)
|
||||||
|
option (OPTION_USE_CAIRO "all drawing to X11 windows uses Cairo" OFF)
|
||||||
|
endif (NOT OPTION_USE_WAYLAND)
|
||||||
endif (X11_Xft_FOUND)
|
endif (X11_Xft_FOUND)
|
||||||
|
|
||||||
|
# test option compatibility: Cairo for Xlib requires Pango
|
||||||
|
if (OPTION_USE_CAIRO)
|
||||||
|
unset (OPTION_USE_PANGO CACHE)
|
||||||
|
set (OPTION_USE_PANGO TRUE CACHE BOOL "use lib Pango")
|
||||||
|
endif (OPTION_USE_CAIRO)
|
||||||
|
|
||||||
# test option compatibility: Pango requires Xft
|
# test option compatibility: Pango requires Xft
|
||||||
if (OPTION_USE_PANGO AND NOT OPTION_USE_WAYLAND)
|
if (OPTION_USE_PANGO AND NOT OPTION_USE_WAYLAND)
|
||||||
if (NOT X11_Xft_FOUND)
|
if (NOT X11_Xft_FOUND)
|
||||||
@@ -654,14 +674,30 @@ if ((X11_Xft_FOUND OR OPTION_USE_WAYLAND) AND OPTION_USE_PANGO)
|
|||||||
endif (HAVE_LIB_PANGO AND HAVE_LIB_PANGOXFT AND HAVE_LIB_GOBJECT)
|
endif (HAVE_LIB_PANGO AND HAVE_LIB_PANGOXFT AND HAVE_LIB_GOBJECT)
|
||||||
endif (PANGOXFT_FOUND AND PANGOCAIRO_FOUND AND CAIRO_FOUND)
|
endif (PANGOXFT_FOUND AND PANGOCAIRO_FOUND AND CAIRO_FOUND)
|
||||||
|
|
||||||
|
if (USE_PANGO AND (OPTION_USE_CAIRO OR OPTION_USE_WAYLAND))
|
||||||
|
set (FLTK_USE_CAIRO 1)
|
||||||
|
# fl_debug_var (FLTK_USE_CAIRO)
|
||||||
|
endif (USE_PANGO AND (OPTION_USE_CAIRO OR OPTION_USE_WAYLAND))
|
||||||
|
|
||||||
endif ((X11_Xft_FOUND OR OPTION_USE_WAYLAND) AND OPTION_USE_PANGO)
|
endif ((X11_Xft_FOUND OR OPTION_USE_WAYLAND) AND OPTION_USE_PANGO)
|
||||||
|
|
||||||
if (OPTION_USE_WAYLAND AND NOT OPTION_USE_SYSTEM_LIBDECOR)
|
if (OPTION_USE_WAYLAND AND NOT OPTION_USE_SYSTEM_LIBDECOR)
|
||||||
|
|
||||||
|
# Note: Disable OPTION_ALLOW_GTK_PLUGIN to get cairo titlebars rather than GTK
|
||||||
|
# FIXME: This needs to be redesigned! Forcing GTK_FOUND to 0 (NO) is a bad
|
||||||
|
# FIXME: idea because there could be unwanted side effects. AlbrechtS
|
||||||
|
if (OPTION_ALLOW_GTK_PLUGIN)
|
||||||
pkg_check_modules(GTK gtk+-3.0)
|
pkg_check_modules(GTK gtk+-3.0)
|
||||||
# set (GTK_FOUND 0) # use this to get cairo titlebars rather than GTK
|
|
||||||
if (GTK_FOUND)
|
if (GTK_FOUND)
|
||||||
include_directories (${GTK_INCLUDE_DIRS})
|
include_directories (${GTK_INCLUDE_DIRS})
|
||||||
endif (GTK_FOUND)
|
endif (GTK_FOUND)
|
||||||
|
else ()
|
||||||
|
if (GTK_FOUND)
|
||||||
|
message (STATUS "*** FIXME: Disable GTK plugin by forcing GTK_FOUND to 0 ***")
|
||||||
|
set (GTK_FOUND 0)
|
||||||
|
endif (GTK_FOUND)
|
||||||
|
endif (OPTION_ALLOW_GTK_PLUGIN)
|
||||||
|
|
||||||
endif (OPTION_USE_WAYLAND AND NOT OPTION_USE_SYSTEM_LIBDECOR)
|
endif (OPTION_USE_WAYLAND AND NOT OPTION_USE_SYSTEM_LIBDECOR)
|
||||||
|
|
||||||
if (OPTION_USE_XFT)
|
if (OPTION_USE_XFT)
|
||||||
|
|||||||
+11
-5
@@ -241,9 +241,15 @@ endif ()
|
|||||||
if (UNIX)
|
if (UNIX)
|
||||||
|
|
||||||
if (OPTION_USE_WAYLAND)
|
if (OPTION_USE_WAYLAND)
|
||||||
message (STATUS "Use Wayland: Yes")
|
message (STATUS "Use Wayland: Yes (when available at run-time)")
|
||||||
else ()
|
else ()
|
||||||
message (STATUS "Use Wayland: No")
|
message (STATUS "Use Wayland: No (therefore, X11 is used)")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (FLTK_USE_CAIRO)
|
||||||
|
message (STATUS "All drawing uses Cairo: Yes")
|
||||||
|
else ()
|
||||||
|
message (STATUS "All drawing uses Cairo: No")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (USE_PANGO)
|
if (USE_PANGO)
|
||||||
@@ -260,11 +266,11 @@ if (UNIX)
|
|||||||
endif (UNIX)
|
endif (UNIX)
|
||||||
|
|
||||||
if (FLTK_HAVE_CAIROEXT)
|
if (FLTK_HAVE_CAIROEXT)
|
||||||
message (STATUS "Cairo support: Yes (extended)")
|
message (STATUS "Fl_Cairo_Window support: Yes (extended)")
|
||||||
elseif (FLTK_HAVE_CAIRO)
|
elseif (FLTK_HAVE_CAIRO)
|
||||||
message (STATUS "Cairo support: Yes (standard)")
|
message (STATUS "Fl_Cairo_Window support: Yes (standard)")
|
||||||
else ()
|
else ()
|
||||||
message (STATUS "Cairo support: No")
|
message (STATUS "Fl_Cairo_Window support: No")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
message ("")
|
message ("")
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
class Fl_Graphics_Driver;
|
class Fl_Graphics_Driver;
|
||||||
class Fl_RGB_Image;
|
class Fl_RGB_Image;
|
||||||
class Fl_Widget;
|
class Fl_Widget;
|
||||||
|
class Fl_Image_Surface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A drawing surface that's susceptible to receive graphical output.
|
A drawing surface that's susceptible to receive graphical output.
|
||||||
@@ -91,6 +92,7 @@ public:
|
|||||||
}
|
}
|
||||||
/** \brief The destructor. */
|
/** \brief The destructor. */
|
||||||
virtual ~Fl_Surface_Device();
|
virtual ~Fl_Surface_Device();
|
||||||
|
virtual Fl_Image_Surface *as_image_surface();
|
||||||
static void push_current(Fl_Surface_Device *new_current);
|
static void push_current(Fl_Surface_Device *new_current);
|
||||||
static Fl_Surface_Device *pop_current();
|
static Fl_Surface_Device *pop_current();
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-2
@@ -187,8 +187,9 @@ public:
|
|||||||
and may be followed by adequate attribute values.
|
and may be followed by adequate attribute values.
|
||||||
*/
|
*/
|
||||||
int mode(const int *a) {return mode(0, a);}
|
int mode(const int *a) {return mode(0, a);}
|
||||||
/** Returns a pointer to the GLContext that this window is using.
|
/** Returns a pointer to the window's OpenGL rendering context.
|
||||||
\see void context(GLContext c, int destroy_flag) */
|
\see void context(GLContext c, int destroy_flag)
|
||||||
|
*/
|
||||||
GLContext context() const {return context_;}
|
GLContext context() const {return context_;}
|
||||||
void context(GLContext, int destroy_flag = 0);
|
void context(GLContext, int destroy_flag = 0);
|
||||||
void make_current();
|
void make_current();
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ public:
|
|||||||
int printable_rect(int *w, int *h);
|
int printable_rect(int *w, int *h);
|
||||||
Fl_Offscreen offscreen();
|
Fl_Offscreen offscreen();
|
||||||
void rescale();
|
void rescale();
|
||||||
|
Fl_Image_Surface *as_image_surface();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -98,6 +99,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
class Fl_Image_Surface_Driver : public Fl_Widget_Surface {
|
class Fl_Image_Surface_Driver : public Fl_Widget_Surface {
|
||||||
friend class Fl_Image_Surface;
|
friend class Fl_Image_Surface;
|
||||||
|
private:
|
||||||
|
Fl_Image_Surface *image_surface_;
|
||||||
protected:
|
protected:
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
@@ -110,6 +113,7 @@ protected:
|
|||||||
virtual void untranslate() = 0;
|
virtual void untranslate() = 0;
|
||||||
int printable_rect(int *w, int *h);
|
int printable_rect(int *w, int *h);
|
||||||
virtual Fl_RGB_Image *image() = 0;
|
virtual Fl_RGB_Image *image() = 0;
|
||||||
|
virtual Fl_Image_Surface *as_image_surface();
|
||||||
/** Each platform implements this function its own way.
|
/** Each platform implements this function its own way.
|
||||||
It returns an object implementing all virtual functions
|
It returns an object implementing all virtual functions
|
||||||
of class Fl_Image_Surface_Driver for the plaform.
|
of class Fl_Image_Surface_Driver for the plaform.
|
||||||
|
|||||||
@@ -23,6 +23,13 @@
|
|||||||
# error "Never use <FL/mac.H> directly; include <FL/platform.H> instead."
|
# error "Never use <FL/mac.H> directly; include <FL/platform.H> instead."
|
||||||
#endif // !FL_PLATFORM_H
|
#endif // !FL_PLATFORM_H
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
@class NSOpenGLContext;
|
||||||
|
#elif defined(__cplusplus)
|
||||||
|
class NSOpenGLContext;
|
||||||
|
#endif /* __OBJC__ */
|
||||||
|
extern NSOpenGLContext *fl_mac_glcontext(GLContext rc);
|
||||||
|
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
@class FLWindow; // a subclass of the NSWindow Cocoa class
|
@class FLWindow; // a subclass of the NSWindow Cocoa class
|
||||||
typedef FLWindow *Window;
|
typedef FLWindow *Window;
|
||||||
@@ -125,6 +132,12 @@ extern CGContextRef fl_gc;
|
|||||||
*/
|
*/
|
||||||
void fl_mac_set_about(Fl_Callback *cb, void *user_data, int shortcut = 0);
|
void fl_mac_set_about(Fl_Callback *cb, void *user_data, int shortcut = 0);
|
||||||
|
|
||||||
|
/** Returns the macOS-specific graphics context for the current window */
|
||||||
|
extern CGContextRef fl_mac_gc();
|
||||||
|
/** Returns the macOS-specific window reference corresponding to the given Fl_Window object */
|
||||||
|
extern FLWindow *fl_mac_xid(const Fl_Window *win);
|
||||||
|
/** Returns the Fl_Window corresponding to the given macOS-specific window reference */
|
||||||
|
extern Fl_Window *fl_mac_find(FLWindow *);
|
||||||
|
|
||||||
/** The version number of the running Mac OS X (e.g., 100604 for 10.6.4, 101300 for 10.13).
|
/** The version number of the running Mac OS X (e.g., 100604 for 10.6.4, 101300 for 10.13).
|
||||||
FLTK initializes this global variable before main() begins running. If
|
FLTK initializes this global variable before main() begins running. If
|
||||||
|
|||||||
+2
-2
@@ -51,7 +51,7 @@ class Fl_Window;
|
|||||||
|
|
||||||
class FL_EXPORT Fl_X {
|
class FL_EXPORT Fl_X {
|
||||||
public:
|
public:
|
||||||
Window xid;
|
fl_uintptr_t xid;
|
||||||
Fl_Window* w;
|
Fl_Window* w;
|
||||||
Fl_Region region;
|
Fl_Region region;
|
||||||
Fl_X *next;
|
Fl_X *next;
|
||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Window fl_xid(const Fl_Window* w) { Fl_X *xTemp = Fl_X::i(w); return xTemp ? xTemp->xid : 0; }
|
inline Window fl_xid(const Fl_Window* w) { Fl_X *xTemp = Fl_X::i(w); return xTemp ? (Window)xTemp->xid : 0; }
|
||||||
#else
|
#else
|
||||||
extern FL_EXPORT Window fl_xid_(const Fl_Window* w);
|
extern FL_EXPORT Window fl_xid_(const Fl_Window* w);
|
||||||
# define fl_xid(w) fl_xid_(w)
|
# define fl_xid(w) fl_xid_(w)
|
||||||
|
|||||||
+44
-56
@@ -32,15 +32,40 @@ typedef opaque fl_intptr_t;
|
|||||||
A variable of type fl_uintptr_t can also store an unsigned long int value. */
|
A variable of type fl_uintptr_t can also store an unsigned long int value. */
|
||||||
typedef opaque fl_uintptr_t;
|
typedef opaque fl_uintptr_t;
|
||||||
|
|
||||||
typedef opaque Fl_Offscreen; /**< an offscreen drawing buffer */
|
/**
|
||||||
typedef opaque Fl_Region; /**< a region made of several rectangles */
|
Platform-specific value representing an offscreen drawing buffer.
|
||||||
|
\note This value can be safely cast to these types on each platform:
|
||||||
|
\li X11: Pixmap
|
||||||
|
\li Wayland: struct fl_wld_buffer *
|
||||||
|
\li Windows: HBITMAP
|
||||||
|
\li macOS: CGContextRef
|
||||||
|
*/
|
||||||
|
typedef opaque Fl_Offscreen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Pointer to a platform-specific structure representing a collection of rectangles.
|
||||||
|
\note This pointer can be safely cast to these types on each platform:
|
||||||
|
\li X11: Region as defined by X11
|
||||||
|
\li Wayland: struct flCairoRegion *
|
||||||
|
\li Windows: HRGN
|
||||||
|
\li macOS: struct flCocoaRegion *
|
||||||
|
*/
|
||||||
|
typedef struct opaque *Fl_Region;
|
||||||
typedef opaque FL_SOCKET; /**< socket or file descriptor */
|
typedef opaque FL_SOCKET; /**< socket or file descriptor */
|
||||||
typedef opaque GLContext; /**< an OpenGL graphics context, into which all OpenGL calls are rendered */
|
/**
|
||||||
|
Pointer to a platform-specific structure representing the window's OpenGL rendering context.
|
||||||
|
\note This pointer can be safely cast to these types on each platform:
|
||||||
|
\li X11: GLXContext
|
||||||
|
\li Wayland: EGLContext
|
||||||
|
\li Windows: HGLRC
|
||||||
|
\li macOS: NSOpenGLContext *
|
||||||
|
*/
|
||||||
|
typedef struct opaque *GLContext;
|
||||||
|
|
||||||
# define FL_COMMAND opaque /**< An alias for FL_CTRL on Windows and X11, or FL_META on MacOS X */
|
# define FL_COMMAND opaque /**< An alias for FL_CTRL on Windows and X11, or FL_META on MacOS X */
|
||||||
# define FL_CONTROL opaque /**< An alias for FL_META on Windows and X11, or FL_CTRL on MacOS X */
|
# define FL_CONTROL opaque /**< An alias for FL_META on Windows and X11, or FL_CTRL on MacOS X */
|
||||||
|
|
||||||
#else
|
#else /* FL_DOXYGEN */
|
||||||
|
|
||||||
#ifndef FL_PLATFORM_TYPES_H
|
#ifndef FL_PLATFORM_TYPES_H
|
||||||
#define FL_PLATFORM_TYPES_H
|
#define FL_PLATFORM_TYPES_H
|
||||||
@@ -49,8 +74,7 @@ typedef opaque GLContext; /**< an OpenGL graphics context, into which all OpenGL
|
|||||||
|
|
||||||
/* Platform-dependent types are defined here.
|
/* Platform-dependent types are defined here.
|
||||||
These types must be defined by any platform:
|
These types must be defined by any platform:
|
||||||
Fl_Offscreen, Fl_Region, FL_SOCKET, GLContext, struct dirent, struct stat,
|
FL_SOCKET, struct dirent, fl_intptr_t, fl_uintptr_t
|
||||||
fl_intptr_t, fl_uintptr_t
|
|
||||||
|
|
||||||
NOTE: *FIXME* AlbrechtS 13 Apr 2016 (concerning FL_SOCKET)
|
NOTE: *FIXME* AlbrechtS 13 Apr 2016 (concerning FL_SOCKET)
|
||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
@@ -78,65 +102,29 @@ typedef unsigned long fl_uintptr_t;
|
|||||||
|
|
||||||
#endif /* _WIN64 */
|
#endif /* _WIN64 */
|
||||||
|
|
||||||
|
typedef void *GLContext;
|
||||||
|
typedef void *Fl_Region;
|
||||||
|
typedef fl_uintptr_t Fl_Offscreen;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
/* Allows all hybrid combinations except WIN32 + X11 with MSVC */
|
||||||
typedef struct CGContext* Fl_Offscreen;
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
typedef struct flCocoaRegion* Fl_Region;
|
struct dirent {char d_name[1];};
|
||||||
typedef int FL_SOCKET;
|
#else
|
||||||
#ifdef __OBJC__
|
|
||||||
@class NSOpenGLContext;
|
|
||||||
typedef NSOpenGLContext* GLContext;
|
|
||||||
#elif defined(__cplusplus)
|
|
||||||
typedef class NSOpenGLContext* GLContext;
|
|
||||||
#endif /* __OBJC__ */
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
# include <dirent.h>
|
# include <dirent.h>
|
||||||
# define FL_COMMAND FL_META
|
#endif
|
||||||
# define FL_CONTROL FL_CTRL
|
|
||||||
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
typedef struct HBITMAP__ *HBITMAP;
|
|
||||||
typedef HBITMAP Fl_Offscreen;
|
|
||||||
typedef struct HRGN__ *Fl_Region;
|
|
||||||
# if defined(_WIN64) && defined(_MSC_VER)
|
# if defined(_WIN64) && defined(_MSC_VER)
|
||||||
typedef unsigned __int64 FL_SOCKET; /* *FIXME* - FL_SOCKET (see above) */
|
typedef unsigned __int64 FL_SOCKET; /* *FIXME* - FL_SOCKET (see above) */
|
||||||
# else
|
# else
|
||||||
typedef int FL_SOCKET;
|
typedef int FL_SOCKET;
|
||||||
# endif
|
# endif
|
||||||
typedef struct HGLRC__ *GLContext;
|
|
||||||
#ifdef __MINGW32__
|
|
||||||
# include <dirent.h>
|
|
||||||
#else
|
|
||||||
struct dirent {char d_name[1];};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(FLTK_USE_WAYLAND)
|
#include <FL/Fl_Export.H>
|
||||||
typedef struct fl_wld_buffer *Fl_Offscreen; /**< an offscreen drawing buffer */
|
extern FL_EXPORT int fl_command_modifier();
|
||||||
typedef struct flCairoRegion* Fl_Region;
|
extern FL_EXPORT int fl_control_modifier();
|
||||||
typedef int FL_SOCKET; /**< socket or file descriptor */
|
# define FL_COMMAND fl_command_modifier()
|
||||||
typedef void *EGLContext;
|
# define FL_CONTROL fl_control_modifier()
|
||||||
typedef EGLContext GLContext;
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
|
|
||||||
#elif defined(FLTK_USE_X11)
|
|
||||||
|
|
||||||
typedef unsigned long Fl_Offscreen;
|
|
||||||
typedef struct _XRegion *Fl_Region;
|
|
||||||
typedef int FL_SOCKET;
|
|
||||||
typedef struct __GLXcontextRec *GLContext;
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
|
|
||||||
#endif /* __APPLE__ */
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef __APPLE__
|
|
||||||
# define FL_COMMAND FL_CTRL /**< An alias for FL_CTRL on Windows and X11, or FL_META on MacOS X */
|
|
||||||
# define FL_CONTROL FL_META /**< An alias for FL_META on Windows and X11, or FL_CTRL on MacOS X */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* FL_PLATFORM_TYPES_H */
|
#endif /* FL_PLATFORM_TYPES_H */
|
||||||
|
|
||||||
#endif // FL_DOXYGEN
|
#endif /* FL_DOXYGEN */
|
||||||
|
|||||||
+30
-11
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Wayland platform header file for the Fast Light Tool Kit (FLTK).
|
// Wayland/X11 hybrid platform header file for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
// Copyright 1998-2021 by Bill Spitzak and others.
|
// Copyright 1998-2022 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@@ -18,16 +18,35 @@
|
|||||||
# error "Never use <FL/wayland.H> directly; include <FL/platform.H> instead."
|
# error "Never use <FL/wayland.H> directly; include <FL/platform.H> instead."
|
||||||
#endif // !FL_PLATFORM_H
|
#endif // !FL_PLATFORM_H
|
||||||
|
|
||||||
typedef struct wld_window *Window;
|
/** \file
|
||||||
|
Definitions of functions specific to the Wayland platform.
|
||||||
|
*/
|
||||||
|
|
||||||
struct flCairoRegion {
|
// *********** for Wayland component ***********
|
||||||
int count;
|
|
||||||
struct _cairo_rectangle *rects;
|
|
||||||
}; // a region is the union of a series of rectangles
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
typedef struct _cairo cairo_t;
|
typedef struct _cairo cairo_t;
|
||||||
|
|
||||||
FL_EXPORT struct wl_display *fl_wl_display();
|
/** Returns the Wayland display in use */
|
||||||
FL_EXPORT struct wl_surface *fl_wl_surface(Window xid);
|
extern FL_EXPORT struct wl_display *fl_wl_display();
|
||||||
FL_EXPORT cairo_t *fl_wl_cairo();
|
/** Returns the wl_surface associated to a shown window */
|
||||||
|
extern FL_EXPORT struct wl_surface *fl_wl_surface(struct wld_window *xid);
|
||||||
|
/** Returns a platform-specific reference associated to a shown window */
|
||||||
|
extern FL_EXPORT struct wld_window *fl_wl_xid(const Fl_Window *win);
|
||||||
|
/** Returns the Fl_Window corresponding to a given the platform-specific window reference */
|
||||||
|
extern FL_EXPORT Fl_Window *fl_wl_find(struct wld_window *);
|
||||||
|
/** Returns the cairo context associated to the current window*/
|
||||||
|
extern FL_EXPORT cairo_t *fl_wl_cairo();
|
||||||
|
typedef void *EGLContext;
|
||||||
|
/** Returns the EGLContext corresponding to the given GLContext */
|
||||||
|
extern FL_EXPORT EGLContext fl_wl_glcontext(GLContext rc);
|
||||||
|
/** Prevent the FLTK library from using its wayland backend.
|
||||||
|
Call this early in your main(), before fl_open_display() runs. */
|
||||||
|
extern FL_EXPORT void fl_disable_wayland();
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FL_DOXYGEN
|
||||||
|
|
||||||
|
// *********** for X11 component ***********
|
||||||
|
# include "x11.H"
|
||||||
|
|
||||||
|
#endif // FL_DOXYGEN
|
||||||
|
|||||||
+26
-1
@@ -18,7 +18,25 @@
|
|||||||
// include this file if _WIN32 is defined. This is to encourage
|
// include this file if _WIN32 is defined. This is to encourage
|
||||||
// portability of even the system-specific code...
|
// portability of even the system-specific code...
|
||||||
|
|
||||||
#ifndef FL_DOXYGEN
|
#ifdef FL_DOXYGEN
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
Definitions of functions specific to the Windows platform.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Returns the Windows-specific window reference corresponding to the given Fl_Window object */
|
||||||
|
extern HWND fl_win32_xid(const Fl_Window *win);
|
||||||
|
/** Returns the Fl_Window corresponding to the given Windows-specific window reference */
|
||||||
|
extern Fl_Window *fl_win32_find(HWND);
|
||||||
|
/** Returns the Windows-specific GL rendering context corresponding to the given GLContext */
|
||||||
|
extern HGLRC fl_win32_glcontext(GLContext rc);
|
||||||
|
/** Returns the Windows-specific graphics context for the current window */
|
||||||
|
extern HDC fl_win32_gc();
|
||||||
|
/** Returns the Windows-specific display in use */
|
||||||
|
extern HINSTANCE fl_win32_display();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#ifndef FL_PLATFORM_H
|
#ifndef FL_PLATFORM_H
|
||||||
# error "Never use <FL/win32.H> directly; include <FL/platform.H> instead."
|
# error "Never use <FL/win32.H> directly; include <FL/platform.H> instead."
|
||||||
#endif // !FL_PLATFORM_H
|
#endif // !FL_PLATFORM_H
|
||||||
@@ -26,6 +44,11 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
typedef HWND Window;
|
typedef HWND Window;
|
||||||
|
|
||||||
|
typedef struct HGLRC__ *HGLRC;
|
||||||
|
extern FL_EXPORT HGLRC fl_win32_glcontext(GLContext rc);
|
||||||
|
extern FL_EXPORT HWND fl_win32_xid(const Fl_Window *win);
|
||||||
|
extern FL_EXPORT Fl_Window *fl_win32_find(HWND);
|
||||||
|
|
||||||
// this part is included only when compiling the FLTK library or if requested explicitly
|
// this part is included only when compiling the FLTK library or if requested explicitly
|
||||||
#if defined(FL_LIBRARY) || defined(FL_INTERNALS)
|
#if defined(FL_LIBRARY) || defined(FL_INTERNALS)
|
||||||
|
|
||||||
@@ -60,7 +83,9 @@ FL_EXPORT HBRUSH fl_brush(); // allocates a brush if necessary
|
|||||||
FL_EXPORT HBRUSH fl_brush_action(int); // now does the real work
|
FL_EXPORT HBRUSH fl_brush_action(int); // now does the real work
|
||||||
|
|
||||||
extern FL_EXPORT HINSTANCE fl_display;
|
extern FL_EXPORT HINSTANCE fl_display;
|
||||||
|
extern FL_EXPORT HINSTANCE fl_win32_display();
|
||||||
extern FL_EXPORT HDC fl_gc;
|
extern FL_EXPORT HDC fl_gc;
|
||||||
|
extern FL_EXPORT HDC fl_win32_gc();
|
||||||
extern FL_EXPORT MSG fl_msg;
|
extern FL_EXPORT MSG fl_msg;
|
||||||
extern FL_EXPORT HDC fl_GetDC(Window);
|
extern FL_EXPORT HDC fl_GetDC(Window);
|
||||||
extern FL_EXPORT HDC fl_makeDC(HBITMAP);
|
extern FL_EXPORT HDC fl_makeDC(HBITMAP);
|
||||||
|
|||||||
@@ -18,7 +18,22 @@
|
|||||||
// include this file if FLTK_USE_X11 is defined. This is to encourage
|
// include this file if FLTK_USE_X11 is defined. This is to encourage
|
||||||
// portability of even the system-specific code...
|
// portability of even the system-specific code...
|
||||||
|
|
||||||
#ifndef FL_DOXYGEN
|
#ifdef FL_DOXYGEN
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
Definitions of functions specific to the X11 platform.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Returns the X11 Display in use */
|
||||||
|
extern Display *fl_x11_display();
|
||||||
|
/** Returns the Window reference for the given Fl_Window, or zero if not \c shown(). */
|
||||||
|
extern Window fl_x11_xid(const Fl_Window *win);
|
||||||
|
/** Returns the Fl_Window corresponding to the given Window reference. */
|
||||||
|
extern Fl_Window *fl_x11_find(Window xid);
|
||||||
|
/** Returns the X11-specific currently active graphics context. */
|
||||||
|
extern GC fl_x11_gc();
|
||||||
|
|
||||||
|
#else // ! FL_DOXYGEN
|
||||||
|
|
||||||
#ifndef FL_PLATFORM_H
|
#ifndef FL_PLATFORM_H
|
||||||
# error "Never use <FL/x11.H> directly; include <FL/platform.H> instead."
|
# error "Never use <FL/x11.H> directly; include <FL/platform.H> instead."
|
||||||
@@ -36,14 +51,21 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
|
typedef struct __GLXcontextRec *GLXContext;
|
||||||
|
extern GLXContext fl_x11_glcontext(GLContext rc);
|
||||||
|
|
||||||
// constant info about the X server connection:
|
// constant info about the X server connection:
|
||||||
extern FL_EXPORT Display *fl_display;
|
extern FL_EXPORT Display *fl_display;
|
||||||
|
extern FL_EXPORT Display *fl_x11_display();
|
||||||
|
extern FL_EXPORT Window fl_x11_xid(const Fl_Window *win);
|
||||||
|
extern FL_EXPORT Fl_Window *fl_x11_find(Window);
|
||||||
extern FL_EXPORT int fl_screen;
|
extern FL_EXPORT int fl_screen;
|
||||||
extern FL_EXPORT XVisualInfo *fl_visual;
|
extern FL_EXPORT XVisualInfo *fl_visual;
|
||||||
extern FL_EXPORT Colormap fl_colormap;
|
extern FL_EXPORT Colormap fl_colormap;
|
||||||
|
|
||||||
// drawing functions:
|
// drawing functions:
|
||||||
extern FL_EXPORT GC fl_gc;
|
extern FL_EXPORT GC fl_gc;
|
||||||
|
extern FL_EXPORT GC fl_x11_gc();
|
||||||
FL_EXPORT ulong fl_xpixel(Fl_Color i);
|
FL_EXPORT ulong fl_xpixel(Fl_Color i);
|
||||||
FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
|
FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
|
||||||
|
|
||||||
|
|||||||
+15
-4
@@ -126,7 +126,8 @@ FLTK_BUILD_EXAMPLES - default OFF
|
|||||||
Builds the example programs in the 'examples' directory.
|
Builds the example programs in the 'examples' directory.
|
||||||
|
|
||||||
OPTION_CAIRO - default OFF
|
OPTION_CAIRO - default OFF
|
||||||
Enables libcairo support - see README.Cairo.txt.
|
Enables support of class Fl_Cairo_Window (all platforms, requires the
|
||||||
|
Cairo library) - see README.Cairo.txt.
|
||||||
|
|
||||||
OPTION_CAIROEXT - default OFF
|
OPTION_CAIROEXT - default OFF
|
||||||
Enables extended libcairo support - see README.Cairo.txt.
|
Enables extended libcairo support - see README.Cairo.txt.
|
||||||
@@ -148,7 +149,7 @@ OPTION_USE_SYSTEM_ZLIB - default ON
|
|||||||
any of these options to OFF, then the built in library will be used.
|
any of these options to OFF, then the built in library will be used.
|
||||||
|
|
||||||
OPTION_USE_SVG - default ON
|
OPTION_USE_SVG - default ON
|
||||||
FLTK has a built in SVG library and can create (write) SVG image files.
|
FLTK has a built-in SVG library and can create (write) SVG image files.
|
||||||
Turning this option off disables SVG (read and write) support.
|
Turning this option off disables SVG (read and write) support.
|
||||||
|
|
||||||
OPTION_USE_XINERAMA - default ON
|
OPTION_USE_XINERAMA - default ON
|
||||||
@@ -158,14 +159,21 @@ OPTION_USE_XRENDER - default ON
|
|||||||
These are X11 extended libraries. These libs are used if found on the
|
These are X11 extended libraries. These libs are used if found on the
|
||||||
build system unless the respective option is turned off.
|
build system unless the respective option is turned off.
|
||||||
|
|
||||||
|
OPTION_USE_CAIRO - default OFF
|
||||||
|
Makes all drawing operations use the Cairo library (rather than Xlib)
|
||||||
|
producing antialiased graphics (X11 platform, implies OPTION_USE_PANGO).
|
||||||
|
|
||||||
OPTION_USE_PANGO - default OFF
|
OPTION_USE_PANGO - default OFF
|
||||||
Enables use of the Pango library for drawing text. Pango supports all
|
Enables use of the Pango library for drawing text. Pango supports all
|
||||||
unicode-defined scripts with limited support of right-to-left scripts.
|
unicode-defined scripts with limited support of right-to-left scripts.
|
||||||
This option makes sense only under X11, and also requires Xft.
|
This option makes sense only under X11, and also requires Xft.
|
||||||
|
|
||||||
OPTION_USE_WAYLAND - default OFF
|
OPTION_USE_WAYLAND - default OFF
|
||||||
Enables use of the Wayland system for all window operations.
|
Enables the use of Wayland for all window operations, of Cairo for all
|
||||||
This option requires a Wayland-equipped system, i.e., Linux or FreeBSD.
|
graphics and of Pango for text drawing (Linux only). Resulting FLTK
|
||||||
|
apps use Wayland when a Wayland compositor is available at run-time,
|
||||||
|
and use X11 for their window operations otherwise, but keep using
|
||||||
|
Cairo and Pango - see README.Wayland.txt.
|
||||||
|
|
||||||
OPTION_ABI_VERSION - default EMPTY
|
OPTION_ABI_VERSION - default EMPTY
|
||||||
Use a numeric value corresponding to the FLTK ABI version you want to
|
Use a numeric value corresponding to the FLTK ABI version you want to
|
||||||
@@ -182,6 +190,9 @@ OPTION_PRINT_SUPPORT - default ON
|
|||||||
is somewhat smaller. This option makes sense only on the Unix/Linux
|
is somewhat smaller. This option makes sense only on the Unix/Linux
|
||||||
platform or when OPTION_APPLE_X11 is ON.
|
platform or when OPTION_APPLE_X11 is ON.
|
||||||
|
|
||||||
|
OPTION_USE_GDIPLUS - default ON
|
||||||
|
Makes FLTK use GDI+ to draw oblique lines and curves resulting in
|
||||||
|
antialiased graphics (Windows platform only).
|
||||||
|
|
||||||
Documentation options: these options are only available if `doxygen' is
|
Documentation options: these options are only available if `doxygen' is
|
||||||
installed and found by CMake. PDF related options require also `latex'.
|
installed and found by CMake. PDF related options require also `latex'.
|
||||||
|
|||||||
+9
-1
@@ -61,11 +61,19 @@ variable OPTION_CAIRO:BOOL=ON is set.
|
|||||||
transparently a Cairo context to your custom Fl_Window derived class.
|
transparently a Cairo context to your custom Fl_Window derived class.
|
||||||
This function is intended to be used in your overloaded draw() method.
|
This function is intended to be used in your overloaded draw() method.
|
||||||
|
|
||||||
(3) Adding an optional Cairo autolink context mode support which permits
|
(3) FLTK instrumentation for cairo extended use :
|
||||||
|
Adding an optional Cairo autolink context mode support which permits
|
||||||
complete and automatic synchronization of OS dependent graphical context
|
complete and automatic synchronization of OS dependent graphical context
|
||||||
and Cairo contexts, thus furthering a valid Cairo context anytime,
|
and Cairo contexts, thus furthering a valid Cairo context anytime,
|
||||||
in any current window.
|
in any current window.
|
||||||
|
|
||||||
|
Usage :
|
||||||
|
- Call Fl::cairo_autolink_context(true); before windows are shown.
|
||||||
|
- In an overridden widget draw method, do
|
||||||
|
cairo_t *cc = Fl::cairo_cc();
|
||||||
|
and obtain the cairo context value adequate to draw with cairo to
|
||||||
|
the current window.
|
||||||
|
|
||||||
This feature should be only necessary in the following cases:
|
This feature should be only necessary in the following cases:
|
||||||
- Intensive and almost systematic use of Cairo in an FLTK application
|
- Intensive and almost systematic use of Cairo in an FLTK application
|
||||||
- Creation of a new Cairo based scheme for FLTK
|
- Creation of a new Cairo based scheme for FLTK
|
||||||
|
|||||||
+83
-34
@@ -9,12 +9,17 @@ CONTENTS
|
|||||||
|
|
||||||
2 WAYLAND SUPPORT FOR FLTK
|
2 WAYLAND SUPPORT FOR FLTK
|
||||||
2.1 Configuration
|
2.1 Configuration
|
||||||
2.2 Known limitations
|
2.2 Known Limitations
|
||||||
|
|
||||||
3 PLATFORM SPECIFIC NOTES
|
3 PREPARING PLATFORM-SPECIFIC CODE FOR THE WAYLAND PLATFORM
|
||||||
3.1 Debian and Derivatives (like Ubuntu)
|
3.1 Handling X11-specific source code
|
||||||
3.2 Fedora
|
3.2 Handling X11- and Wayland-specific source code in the same app
|
||||||
3.3 FreeBSD
|
3.3 Forcing an app to always use the X11 mechanism
|
||||||
|
|
||||||
|
4 PLATFORM SPECIFIC NOTES
|
||||||
|
4.1 Debian and Derivatives (like Ubuntu)
|
||||||
|
4.2 Fedora
|
||||||
|
4.3 FreeBSD
|
||||||
|
|
||||||
|
|
||||||
1 INTRODUCTION
|
1 INTRODUCTION
|
||||||
@@ -33,12 +38,25 @@ CJK text-input methods, as well as dead and compose keys are supported.
|
|||||||
2 WAYLAND SUPPORT FOR FLTK
|
2 WAYLAND SUPPORT FOR FLTK
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
It is possible to have your FLTK application do all its windowing and drawing
|
On Linux and FreeBSD systems, and provided a Wayland compositor is available at run-time,
|
||||||
through the Wayland protocol on Linux or FreeBSD systems.
|
it is possible to have your FLTK application do all its windowing through the
|
||||||
All graphics is done via Cairo or EGL. All text-drawing is done via Pango.
|
Wayland protocol, all its graphics with Cairo or EGL, and all text-drawing with
|
||||||
|
Pango. If no Wayland compositor is available at run-time, FLTK falls back to
|
||||||
|
using X11 or OpenGL for its windowing. Cairo and Pango remain used for graphics
|
||||||
|
and text, respectively.
|
||||||
|
|
||||||
|
Environment variable FLTK_BACKEND can be used to control whether Wayland or
|
||||||
|
X11 is used at run time as follows:
|
||||||
|
- if FLTK_BACKEND is not defined, Wayland is used when possible, otherwise
|
||||||
|
X11 is used;
|
||||||
|
- if FLTK_BACKEND equals "wayland", the library stops with error if no
|
||||||
|
Wayland compositor is available;
|
||||||
|
- if FLTK_BACKEND equals "x11", the library uses X11 even if a Wayland
|
||||||
|
compositor is available;
|
||||||
|
- if FLTK_BACKEND has another value, the library stops with error.
|
||||||
|
|
||||||
2.1 Configuration
|
2.1 Configuration
|
||||||
---------------
|
------------------
|
||||||
|
|
||||||
* Configure-based build can be performed as follows:
|
* Configure-based build can be performed as follows:
|
||||||
Once after "git clone", create the configure file :
|
Once after "git clone", create the configure file :
|
||||||
@@ -55,14 +73,14 @@ cmake -S <path-to-source> -B <path-to-build> -DCMAKE_BUILD_TYPE=Release -DOPTION
|
|||||||
|
|
||||||
cd <path-to-build>; make
|
cd <path-to-build>; make
|
||||||
|
|
||||||
The FLTK wayland platform uses a library called libdecor which handles window decorations
|
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
|
(i.e., titlebars, shade). Libdecor is bundled in the FLTK source code and FLTK uses by default
|
||||||
this form of libdecor. Optionally, OPTION_USE_SYSTEM_LIBDECOR can be turned on to have FLTK
|
this form of libdecor. Optionally, 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.,
|
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).
|
Debian Bookworm or more recent in packages libdecor-0-0 and libdecor-0-plugin-1-cairo).
|
||||||
|
|
||||||
2.2 Known limitations
|
2.2 Known Limitations
|
||||||
-------------------------------
|
----------------------
|
||||||
|
|
||||||
* A deliberate design trait of Wayland makes application windows ignorant of their exact
|
* A deliberate design trait of Wayland makes application windows ignorant of their exact
|
||||||
placement on screen. It's possible, though, to position a popup window relatively to
|
placement on screen. It's possible, though, to position a popup window relatively to
|
||||||
@@ -86,41 +104,72 @@ tested in that situation.
|
|||||||
* Text input methods have been tested without any understanding of the writing systems,
|
* Text input methods have been tested without any understanding of the writing systems,
|
||||||
so feedback on this subject would be helpful.
|
so feedback on this subject would be helpful.
|
||||||
|
|
||||||
* While platform-independent source code prepared for FLTK 1.3 is expected to be compatible
|
|
||||||
with FLTK 1.4 and the Wayland platform, X11-specific code will not compile. In particular,
|
3 PREPARING PLATFORM-SPECIFIC CODE FOR THE WAYLAND PLATFORM
|
||||||
the common FLTK 1.3 construct :
|
===========================================================
|
||||||
|
|
||||||
|
While platform-independent source code prepared for FLTK 1.3 is expected
|
||||||
|
to be compatible with no change with FLTK 1.4 and the Wayland platform,
|
||||||
|
platform-specific code may require some attention.
|
||||||
|
|
||||||
|
3.1 Handling X11-specific source code
|
||||||
|
-------------------------------------
|
||||||
|
|
||||||
|
If an FLTK 1.4 application contains X11-specific code, execution of this code
|
||||||
|
in the context of an active Wayland session can produce malfunctions or program crashes.
|
||||||
|
To ensure that X11-specific code gets called only when an X11 connection is active,
|
||||||
|
check that function fl_x11_display() returns non-NULL before using any X11-specific
|
||||||
|
function or variable.
|
||||||
|
|
||||||
|
3.2 Handling X11- and Wayland-specific source code in the same app
|
||||||
|
------------------------------------------------------------------
|
||||||
|
|
||||||
|
The recommended way to prepare and use platform-specific code that would contain
|
||||||
|
both X11-specific and Wayland-specific parts is as follows :
|
||||||
|
|
||||||
|
a) Organize platform-specific code as follows :
|
||||||
|
|
||||||
|
#include <FL/platform.H>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
*** macOS-specific code ***
|
*** macOS-specific code ***
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
*** Windows-specific code ***
|
*** Windows-specific code ***
|
||||||
#else
|
#else
|
||||||
*** X11-specific code ***
|
*** X11-specific code ***
|
||||||
|
|
||||||
|
*** Wayland-specific code ***
|
||||||
#endif
|
#endif
|
||||||
will choke at compile time because it exposes X11-specific code to the non-X11, Wayland
|
|
||||||
environment. This should be written instead :
|
|
||||||
#include <FL/fl_config.h>
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
b) Make sure to use distinct names for global variables and functions
|
||||||
*** macOS-specific code ***
|
in the X11- and the Wayland-specific sections.
|
||||||
#elif defined(_WIN32)
|
|
||||||
*** Windows-specific code ***
|
c) Check that function fl_x11_display() returns non-NULL before using any X11-specific
|
||||||
#elif defined(FLTK_USE_X11)
|
function or variable, and that fl_wl_display() returns non-NULL before using any
|
||||||
*** X11-specific code ***
|
Wayland-specific function or variable. Make sure that fl_open_display() was called
|
||||||
#endif
|
directly or indirectly before using any such symbol.
|
||||||
Moreover, the new FLTK_USE_WAYLAND preprocessor variable is available to bracket
|
|
||||||
Wayland-specific source code.
|
3.3 Forcing an app to always use the X11 mechanism
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
|
Alternatively, it's possible to force an FLTK app to use X11 in all
|
||||||
|
situations by calling function fl_disable_wayland() early in main(), before
|
||||||
|
fl_open_display() runs. FLTK source code and also platform-specific
|
||||||
|
code conceived for FLTK 1.3 should run under 1.4 with that single change only.
|
||||||
|
|
||||||
|
|
||||||
3 PLATFORM SPECIFIC NOTES
|
4 PLATFORM SPECIFIC NOTES
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
The following are notes about building FLTK for the Wayland platform
|
The following are notes about building FLTK for the Wayland platform
|
||||||
on the various supported Linux distributions.
|
on the various supported Linux distributions/OS.
|
||||||
|
|
||||||
3.1 Debian and Derivatives (like Ubuntu)
|
4.1 Debian and Derivatives (like Ubuntu)
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
Under Debian, the Wayland platform requires version 11 (a.k.a. Bullseye) or more recent.
|
Under Debian, the Wayland platform requires version 11 (a.k.a. Bullseye) or more recent.
|
||||||
Under Ubuntu, the Wayland platform is known to work with version 20.04 (focal fossa) or more recent.
|
Under Ubuntu, the Wayland platform is known to work with version 20.04 (focal fossa) or
|
||||||
|
more recent.
|
||||||
|
|
||||||
These packages are necessary to build the FLTK library, in addition to those present
|
These packages are necessary to build the FLTK library, in addition to those present
|
||||||
in a basic Debian/Ubuntu distribution :
|
in a basic Debian/Ubuntu distribution :
|
||||||
@@ -148,7 +197,7 @@ These packages allow to run FLTK apps under the KDE/Plasma-Wayland desktop:
|
|||||||
- plasma-workspace-wayland
|
- plasma-workspace-wayland
|
||||||
|
|
||||||
|
|
||||||
3.2 Fedora
|
4.2 Fedora
|
||||||
----------
|
----------
|
||||||
|
|
||||||
The Wayland platform is known to work with Fedora version 35.
|
The Wayland platform is known to work with Fedora version 35.
|
||||||
@@ -172,7 +221,7 @@ in a Fedora 35 Workstation distribution :
|
|||||||
Package installation command: sudo yum install <package-name ...>
|
Package installation command: sudo yum install <package-name ...>
|
||||||
|
|
||||||
|
|
||||||
3.3 FreeBSD
|
4.3 FreeBSD
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
The Wayland platform is known to work with FreeBSD version 13.1 and the sway compositor.
|
The Wayland platform is known to work with FreeBSD version 13.1 and the sway compositor.
|
||||||
|
|||||||
+11
-10
@@ -21,17 +21,18 @@
|
|||||||
#include <FL/Fl_Window.H>
|
#include <FL/Fl_Window.H>
|
||||||
|
|
||||||
// Cairo is currently supported for the following platforms:
|
// Cairo is currently supported for the following platforms:
|
||||||
// Win32, Apple Quartz, X11
|
// Win32, Apple Quartz, X11, Wayland
|
||||||
|
|
||||||
#if defined(FLTK_USE_X11) // X11
|
#if defined(_WIN32) // Windows
|
||||||
# include <cairo-xlib.h>
|
|
||||||
#elif defined(_WIN32) // Windows
|
|
||||||
# include <cairo-win32.h>
|
# include <cairo-win32.h>
|
||||||
#elif defined(__APPLE__) // macOS
|
#elif defined(__APPLE__) // macOS
|
||||||
# include <cairo-quartz.h>
|
# include <cairo-quartz.h>
|
||||||
#elif defined(FLTK_USE_WAYLAND)
|
#elif defined(FLTK_USE_WAYLAND) // Wayland or hybrid
|
||||||
# include "../src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H"
|
# include "../src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H"
|
||||||
# include "../src/drivers/Wayland/Fl_Wayland_Window_Driver.H"
|
# include "../src/drivers/Wayland/Fl_Wayland_Window_Driver.H"
|
||||||
|
# include <cairo-xlib.h>
|
||||||
|
#elif defined(FLTK_USE_X11) // X11
|
||||||
|
# include <cairo-xlib.h>
|
||||||
#else
|
#else
|
||||||
# error Cairo is not supported on this platform.
|
# error Cairo is not supported on this platform.
|
||||||
#endif
|
#endif
|
||||||
@@ -73,11 +74,14 @@ cairo_t * Fl::cairo_make_current(Fl_Window* wi) {
|
|||||||
if (!wi) return NULL; // Precondition
|
if (!wi) return NULL; // Precondition
|
||||||
cairo_t * cairo_ctxt;
|
cairo_t * cairo_ctxt;
|
||||||
#if defined(FLTK_USE_WAYLAND)
|
#if defined(FLTK_USE_WAYLAND)
|
||||||
Window xid = fl_xid(wi);
|
if (fl_wl_display()) { // true means using wayland backend
|
||||||
|
struct wld_window *xid = fl_wl_xid(wi);
|
||||||
if (!xid->buffer) return NULL; // this may happen with GL windows
|
if (!xid->buffer) return NULL; // this may happen with GL windows
|
||||||
cairo_ctxt = xid->buffer->cairo_;
|
cairo_ctxt = xid->buffer->cairo_;
|
||||||
cairo_state_.cc(cairo_ctxt, false);
|
cairo_state_.cc(cairo_ctxt, false);
|
||||||
#else // !FLTK_USE_WAYLAND
|
return cairo_ctxt;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (fl_gc==0) { // means remove current cc
|
if (fl_gc==0) { // means remove current cc
|
||||||
Fl::cairo_cc(0); // destroy any previous cc
|
Fl::cairo_cc(0); // destroy any previous cc
|
||||||
cairo_state_.window(0);
|
cairo_state_.window(0);
|
||||||
@@ -102,11 +106,9 @@ cairo_t * Fl::cairo_make_current(Fl_Window* wi) {
|
|||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
cairo_scale(cairo_ctxt, scale, scale);
|
cairo_scale(cairo_ctxt, scale, scale);
|
||||||
#endif
|
#endif
|
||||||
#endif // FLTK_USE_WAYLAND
|
|
||||||
return cairo_ctxt;
|
return cairo_ctxt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(FLTK_USE_WAYLAND)
|
|
||||||
/*
|
/*
|
||||||
Creates transparently a cairo_surface_t object.
|
Creates transparently a cairo_surface_t object.
|
||||||
gc is an HDC context in Windows, a CGContext* in Quartz, and
|
gc is an HDC context in Windows, a CGContext* in Quartz, and
|
||||||
@@ -194,7 +196,6 @@ cairo_t * Fl::cairo_make_current(void *gc, int W, int H) {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !FLTK_USE_WAYLAND
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// just don't leave the libfltk_cairo lib empty to avoid warnings
|
// just don't leave the libfltk_cairo lib empty to avoid warnings
|
||||||
|
|||||||
+22
-3
@@ -85,7 +85,7 @@ AC_SUBST(OPTIM)
|
|||||||
|
|
||||||
|
|
||||||
dnl Other options
|
dnl Other options
|
||||||
AC_ARG_ENABLE([cairo], AS_HELP_STRING([--enable-cairo], [use Cairo library]))
|
AC_ARG_ENABLE([cairo], AS_HELP_STRING([--enable-cairo], [add support for Fl_Cairo_Window]))
|
||||||
AC_ARG_ENABLE([cairoext], AS_HELP_STRING([--enable-cairoext], [use FLTK code instrumentation for cairo extended use]))
|
AC_ARG_ENABLE([cairoext], AS_HELP_STRING([--enable-cairoext], [use FLTK code instrumentation for cairo extended use]))
|
||||||
|
|
||||||
AC_ARG_ENABLE([cp936], AS_HELP_STRING([--enable-cp936], [turn on CP936]))
|
AC_ARG_ENABLE([cp936], AS_HELP_STRING([--enable-cp936], [turn on CP936]))
|
||||||
@@ -112,6 +112,8 @@ AC_ARG_ENABLE([pango], AS_HELP_STRING([--enable-pango], [turn on Pango support])
|
|||||||
|
|
||||||
AC_ARG_ENABLE([wayland], AS_HELP_STRING([--enable-wayland], [turn on Wayland support]))
|
AC_ARG_ENABLE([wayland], AS_HELP_STRING([--enable-wayland], [turn on Wayland support]))
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([usecairo], AS_HELP_STRING([--enable-usecairo], [all drawing to X11 windows uses Cairo]))
|
||||||
|
|
||||||
AC_ARG_ENABLE([print], AS_HELP_STRING([--disable-print], [turn off print support (X11)]))
|
AC_ARG_ENABLE([print], AS_HELP_STRING([--disable-print], [turn off print support (X11)]))
|
||||||
AS_IF([test x$enable_print = xno], [
|
AS_IF([test x$enable_print = xno], [
|
||||||
AC_DEFINE([FL_NO_PRINT_SUPPORT], [Disable X11 print support?])
|
AC_DEFINE([FL_NO_PRINT_SUPPORT], [Disable X11 print support?])
|
||||||
@@ -985,12 +987,17 @@ AS_CASE([$host_os_gui], [cygwin* | mingw*], [
|
|||||||
AC_MSG_ERROR([Aborting.])
|
AC_MSG_ERROR([Aborting.])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl Turn option usecairo ON
|
||||||
|
AC_DEFINE([FLTK_USE_CAIRO])
|
||||||
|
AC_MSG_NOTICE([Turning on the usecairo option])
|
||||||
|
|
||||||
BUILD="WAYLAND"
|
BUILD="WAYLAND"
|
||||||
AC_DEFINE([FLTK_USE_WAYLAND])
|
AC_DEFINE([FLTK_USE_WAYLAND])
|
||||||
|
AC_DEFINE([FLTK_USE_X11]) # to build a hybrid Wayland/X11 library
|
||||||
CFLAGS="$CFLAGS -DUSE_SYSTEM_LIBDECOR=0"
|
CFLAGS="$CFLAGS -DUSE_SYSTEM_LIBDECOR=0"
|
||||||
CXXFLAGS="$CXXFLAGS -DUSE_SYSTEM_LIBDECOR=0"
|
CXXFLAGS="$CXXFLAGS -DUSE_SYSTEM_LIBDECOR=0"
|
||||||
graphics="Wayland"
|
graphics="Wayland or X11 with cairo"
|
||||||
LIBS="$LIBS $($PKGCONFIG --libs wayland-cursor) $($PKGCONFIG --libs wayland-client) $($PKGCONFIG --libs xkbcommon)"
|
LIBS="$LIBS $($PKGCONFIG --libs wayland-cursor) $($PKGCONFIG --libs wayland-client) $($PKGCONFIG --libs xkbcommon) $($PKGCONFIG --libs pangoxft) $($PKGCONFIG --libs x11)"
|
||||||
LIBS="$LIBS $($PKGCONFIG --libs dbus-1) -ldl"
|
LIBS="$LIBS $($PKGCONFIG --libs dbus-1) -ldl"
|
||||||
CXXFLAGS="$CXXFLAGS -I../libdecor/src"
|
CXXFLAGS="$CXXFLAGS -I../libdecor/src"
|
||||||
DSOFLAGS="$LIBS $DSOFLAGS"
|
DSOFLAGS="$LIBS $DSOFLAGS"
|
||||||
@@ -1174,6 +1181,15 @@ AS_CASE([$host_os_gui], [cygwin* | mingw*], [
|
|||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl Option usecairo
|
||||||
|
AS_IF([test x$enable_usecairo = xyes], [
|
||||||
|
enable_pango=yes
|
||||||
|
BUILD="CAIRO"
|
||||||
|
AC_DEFINE([FLTK_USE_CAIRO])
|
||||||
|
AC_MSG_NOTICE([Processing usecairo option])
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
dnl test if Pango is asked but xft was not found
|
dnl test if Pango is asked but xft was not found
|
||||||
AS_IF([test x$enable_pango = xyes -a x$xft_found = xno], [
|
AS_IF([test x$enable_pango = xyes -a x$xft_found = xno], [
|
||||||
AC_MSG_WARN([could not find the Xft headers and/or libraries required for Pango.])
|
AC_MSG_WARN([could not find the Xft headers and/or libraries required for Pango.])
|
||||||
@@ -1609,6 +1625,9 @@ AS_CASE([$host_os_gui], [cygwin* | mingw*], [
|
|||||||
AS_IF([test x$xrender_found = xyes], [
|
AS_IF([test x$xrender_found = xyes], [
|
||||||
graphics="$graphics + Xrender"
|
graphics="$graphics + Xrender"
|
||||||
])
|
])
|
||||||
|
AS_IF([test x$enable_usecairo = xyes], [
|
||||||
|
graphics="$graphics + Cairo"
|
||||||
|
])
|
||||||
AS_IF([test x$pango_found = xyes], [
|
AS_IF([test x$pango_found = xyes], [
|
||||||
graphics="$graphics + Pango"
|
graphics="$graphics + Pango"
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -143,7 +143,13 @@ the toolkit, which was already in use by several people, Bill
|
|||||||
came up with "FLTK", including a bogus excuse that it
|
came up with "FLTK", including a bogus excuse that it
|
||||||
stands for "The Fast Light Toolkit".
|
stands for "The Fast Light Toolkit".
|
||||||
|
|
||||||
\section intro_unix Building and Installing FLTK Under UNIX and Apple macOS
|
\section intro_cmake Building and Installing FLTK with CMake
|
||||||
|
|
||||||
|
Starting with version 1.4, the recommended FLTK building system
|
||||||
|
is CMake. See file README.CMake of the FLTK source tree for all information.
|
||||||
|
It's also possible to use \p configure and \p make as follows to build and install FLTK.
|
||||||
|
|
||||||
|
\section intro_unix Building and Installing FLTK Under UNIX and macOS with make
|
||||||
|
|
||||||
In most cases you can just type "make". This will run configure with
|
In most cases you can just type "make". This will run configure with
|
||||||
the default of no options and then compile everything.
|
the default of no options and then compile everything.
|
||||||
@@ -196,6 +202,9 @@ Enable debugging code & symbols
|
|||||||
\par --disable-gl
|
\par --disable-gl
|
||||||
Disable OpenGL support
|
Disable OpenGL support
|
||||||
|
|
||||||
|
\par --disable-svg
|
||||||
|
Disable support of reading and writing of Support Vector Graphics (.svg) files.
|
||||||
|
|
||||||
\par --disable-print
|
\par --disable-print
|
||||||
Disable print support for an X11 platform
|
Disable print support for an X11 platform
|
||||||
|
|
||||||
@@ -205,22 +214,39 @@ Enable generation of shared libraries
|
|||||||
\par --enable-threads
|
\par --enable-threads
|
||||||
Enable multithreading support
|
Enable multithreading support
|
||||||
|
|
||||||
\par --enable-xdbe
|
\par --enable-wayland
|
||||||
Enable the X double-buffer extension
|
Enable the use of Wayland for all window operations, of Cairo for all graphics
|
||||||
|
and of Pango for text drawing (Linux and FreeBSD only). Resulting FLTK apps
|
||||||
|
use Wayland if a Wayland compositor is available at run-time, and use
|
||||||
|
the equivalent of "--enable-x11 --enable-usecairo" otherwise.
|
||||||
|
|
||||||
\par --enable-xft
|
\par --disable-xft
|
||||||
Enable the Xft library for anti-aliased fonts under X11
|
Disables the Xft library, resulting in non anti-aliased fonts (X11 platform).
|
||||||
|
|
||||||
|
\par --enable-usecairo
|
||||||
|
All drawing operations use the Cairo library (rather than Xlib) producing
|
||||||
|
antialiased graphics (X11 platform, implies --enable-pango).
|
||||||
|
|
||||||
\par --enable-pango
|
\par --enable-pango
|
||||||
Enable the pango library for drawing any text in any script under X11.
|
Enable the Pango library for drawing any text in any script with any font under X11.
|
||||||
|
|
||||||
\par --enable-x11
|
\par --enable-x11
|
||||||
|
This is the default under Unix and Linux.
|
||||||
When targeting cygwin, build with X11 GUI instead of windows GDI.
|
When targeting cygwin, build with X11 GUI instead of windows GDI.
|
||||||
Also applicable to macOS platforms supplemented with XQuartz.
|
Also applicable to macOS platforms supplemented with XQuartz.
|
||||||
|
|
||||||
\par --enable-wayland
|
\par --enable-wayland
|
||||||
Enable use of the Wayland system for window handling.
|
Enable use of the Wayland system for window handling.
|
||||||
|
|
||||||
|
\par --enable-cairo
|
||||||
|
Enable support of class Fl_Cairo_Window (all platforms, requires the Cairo library).
|
||||||
|
|
||||||
|
\par --enable-cairoext
|
||||||
|
Enable the FLTK instrumentation for cairo extended use (requires --enable-cairo).
|
||||||
|
|
||||||
|
\par --disable-gdiplus
|
||||||
|
Don't use GDI+ when drawing curves and oblique lines (Windows platform).
|
||||||
|
|
||||||
\par --enable-cp936
|
\par --enable-cp936
|
||||||
Under X11, enable use of the GB2312 locale
|
Under X11, enable use of the GB2312 locale
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ Window fl_xid(const Fl_Window *)
|
|||||||
|
|
||||||
\par
|
\par
|
||||||
Returns the XID for a window, or zero if not \c shown().
|
Returns the XID for a window, or zero if not \c shown().
|
||||||
|
\deprecated Kept for compatibility with FLTK versions before 1.4.
|
||||||
|
Use preferentially fl_x11_xid(const Fl_Window *) with versions 1.4 and above.
|
||||||
|
|
||||||
Fl_Window *fl_find(ulong xid)
|
Fl_Window *fl_find(ulong xid)
|
||||||
|
|
||||||
@@ -96,6 +98,8 @@ Returns the Fl_Window that corresponds to the given
|
|||||||
XID, or \c NULL if not found. This function uses a cache
|
XID, or \c NULL if not found. This function uses a cache
|
||||||
so it is slightly faster than iterating through the windows
|
so it is slightly faster than iterating through the windows
|
||||||
yourself.
|
yourself.
|
||||||
|
\deprecated Kept for compatibility with FLTK versions before 1.4.
|
||||||
|
Use preferentially fl_x11_find(Window) with versions 1.4 and above.
|
||||||
|
|
||||||
int fl_handle(const XEvent &)
|
int fl_handle(const XEvent &)
|
||||||
|
|
||||||
@@ -124,9 +128,11 @@ The following global variables are set before
|
|||||||
Fl_Widget::draw() is called, or by Fl_Window::make_current():
|
Fl_Widget::draw() is called, or by Fl_Window::make_current():
|
||||||
|
|
||||||
\code
|
\code
|
||||||
extern Display *fl_display;
|
extern Display *fl_display; // for compatibility with previous FLTK versions
|
||||||
|
extern Display *fl_x11_display(); // preferred access starting with FLTK 1.4
|
||||||
extern Window fl_window;
|
extern Window fl_window;
|
||||||
extern GC fl_gc;
|
extern GC fl_gc; // for compatibility with previous FLTK versions
|
||||||
|
extern GC fl_x11_gc(); // preferred access starting with FLTK 1.4
|
||||||
extern int fl_screen;
|
extern int fl_screen;
|
||||||
extern XVisualInfo *fl_visual;
|
extern XVisualInfo *fl_visual;
|
||||||
extern Colormap fl_colormap;
|
extern Colormap fl_colormap;
|
||||||
@@ -559,9 +565,11 @@ called, FLTK stores all the extra arguments you need to
|
|||||||
make a proper GDI call in some global variables:
|
make a proper GDI call in some global variables:
|
||||||
|
|
||||||
\code
|
\code
|
||||||
extern HINSTANCE fl_display;
|
extern HINSTANCE fl_display; // for compatibility with previous FLTK versions
|
||||||
|
extern HINSTANCE fl_win32_display(); // preferred access starting with FLTK 1.4
|
||||||
extern HWND fl_window;
|
extern HWND fl_window;
|
||||||
extern HDC fl_gc;
|
extern HDC fl_gc; // for compatibility with previous FLTK versions
|
||||||
|
extern HDC fl_win32_gc(); // preferred access starting with FLTK 1.4
|
||||||
COLORREF fl_RGB();
|
COLORREF fl_RGB();
|
||||||
HPEN fl_pen();
|
HPEN fl_pen();
|
||||||
HBRUSH fl_brush();
|
HBRUSH fl_brush();
|
||||||
@@ -931,17 +939,8 @@ FLTK uses UTF-8-encoded UNIX-style filenames and paths.
|
|||||||
|
|
||||||
\section osissues_wayland The Wayland Interface
|
\section osissues_wayland The Wayland Interface
|
||||||
|
|
||||||
Wayland-specific source code can be organized as follows to be distinguished
|
See file README.Wayland.txt for details about how to organize platform-specific
|
||||||
from X11-specific source code :
|
source code for the Wayland platform.
|
||||||
\code
|
|
||||||
#include <FL/platform.H> // defines FLTK_USE_WAYLAND or FLTK_USE_X11 as appropriate
|
|
||||||
|
|
||||||
#if defined(FLTK_USE_WAYLAND)
|
|
||||||
… Wayland-specific source code …
|
|
||||||
#elif defined(FLTK_USE_X11)
|
|
||||||
… X11-specific source code …
|
|
||||||
#endif
|
|
||||||
\endcode
|
|
||||||
|
|
||||||
extern struct wl_display *fl_wl_display();
|
extern struct wl_display *fl_wl_display();
|
||||||
\par
|
\par
|
||||||
@@ -950,16 +949,16 @@ struct wl_display representing the connection between the application and Waylan
|
|||||||
For example, \c wl_display_get_fd(fl_wl_display()) gives the file descriptor one can
|
For example, \c wl_display_get_fd(fl_wl_display()) gives the file descriptor one can
|
||||||
use to communicate with the Wayland compositor according to the Wayland protocol.
|
use to communicate with the Wayland compositor according to the Wayland protocol.
|
||||||
|
|
||||||
Window fl_xid(const Fl_Window *)
|
struct wld_window *fl_wl_xid(const Fl_Window *)
|
||||||
\par
|
\par
|
||||||
Returns a pointer to an <u>FLTK-defined</u> structure holding Wayland-related
|
Returns a pointer to an <u>FLTK-defined</u> structure holding Wayland-related
|
||||||
data created when a window gets show()'n, or NULL if not show()'n.
|
data created when a window gets show()'n, or NULL if not show()'n.
|
||||||
|
|
||||||
Fl_Window *fl_find(Window wld_win)
|
Fl_Window *fl_wl_find(struct wld_window * wld_win)
|
||||||
\par
|
\par
|
||||||
Returns the Fl_Window that corresponds to the given Window, or NULL if not found.
|
Returns the Fl_Window that corresponds to the given Window, or NULL if not found.
|
||||||
|
|
||||||
struct wl_surface *fl_wl_surface(Window wld_win)
|
struct wl_surface *fl_wl_surface(struct wld_window *wld_win)
|
||||||
\par
|
\par
|
||||||
Returns a pointer to the struct wl_surface corresponding to a show()'n
|
Returns a pointer to the struct wl_surface corresponding to a show()'n
|
||||||
top-level window or subwindow.
|
top-level window or subwindow.
|
||||||
|
|||||||
@@ -56,6 +56,16 @@
|
|||||||
#cmakedefine FLTK_USE_X11 1
|
#cmakedefine FLTK_USE_X11 1
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FLTK_USE_CAIRO
|
||||||
|
*
|
||||||
|
* Do we use Cairo to draw to the display?
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#cmakedefine FLTK_USE_CAIRO 1
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FLTK_USE_WAYLAND
|
* FLTK_USE_WAYLAND
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -55,6 +55,16 @@
|
|||||||
#undef FLTK_USE_X11
|
#undef FLTK_USE_X11
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FLTK_USE_CAIRO
|
||||||
|
*
|
||||||
|
* Do we use Cairo to draw to the display?
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#undef FLTK_USE_CAIRO
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FLTK_USE_WAYLAND
|
* FLTK_USE_WAYLAND
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ CPPFILES_WIN = ExternalCodeEditor_WIN32.cxx
|
|||||||
CPPFILES_OSX = ExternalCodeEditor_UNIX.cxx
|
CPPFILES_OSX = ExternalCodeEditor_UNIX.cxx
|
||||||
CPPFILES_X11 = ExternalCodeEditor_UNIX.cxx
|
CPPFILES_X11 = ExternalCodeEditor_UNIX.cxx
|
||||||
CPPFILES_XFT = ExternalCodeEditor_UNIX.cxx
|
CPPFILES_XFT = ExternalCodeEditor_UNIX.cxx
|
||||||
|
CPPFILES_CAIRO = ExternalCodeEditor_UNIX.cxx
|
||||||
CPPFILES_WAYLAND = ExternalCodeEditor_UNIX.cxx
|
CPPFILES_WAYLAND = ExternalCodeEditor_UNIX.cxx
|
||||||
|
|
||||||
CPPFILES += $(CPPFILES_$(BUILD))
|
CPPFILES += $(CPPFILES_$(BUILD))
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ FL_ABI_VERSION = @FL_ABI_VERSION@
|
|||||||
|
|
||||||
FLTK_VERSION = @FLTK_VERSION@
|
FLTK_VERSION = @FLTK_VERSION@
|
||||||
|
|
||||||
# FLTK configuration options: BUILD = { WIN | OSX | X11 | XFT | WAYLAND }
|
# FLTK configuration options: BUILD = { WIN | OSX | X11 | XFT | CAIROXLIB | WAYLAND }
|
||||||
|
|
||||||
BUILD = @BUILD@
|
BUILD = @BUILD@
|
||||||
UNAME = @UNAME@
|
UNAME = @UNAME@
|
||||||
|
|||||||
+49
-15
@@ -191,7 +191,7 @@ endif (FLTK_USE_X11 AND NOT OPTION_PRINT_SUPPORT)
|
|||||||
|
|
||||||
set (DRIVER_FILES)
|
set (DRIVER_FILES)
|
||||||
|
|
||||||
if (FLTK_USE_X11)
|
if (FLTK_USE_X11 AND NOT OPTION_USE_WAYLAND)
|
||||||
|
|
||||||
# X11 (including APPLE with X11)
|
# X11 (including APPLE with X11)
|
||||||
|
|
||||||
@@ -202,13 +202,6 @@ if (FLTK_USE_X11)
|
|||||||
drivers/Posix/Fl_Posix_System_Driver.cxx
|
drivers/Posix/Fl_Posix_System_Driver.cxx
|
||||||
drivers/Unix/Fl_Unix_System_Driver.cxx
|
drivers/Unix/Fl_Unix_System_Driver.cxx
|
||||||
drivers/X11/Fl_X11_System_Driver.cxx
|
drivers/X11/Fl_X11_System_Driver.cxx
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
|
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx
|
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx
|
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
|
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx
|
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
|
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx
|
|
||||||
drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
|
drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
|
||||||
drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx
|
drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx
|
||||||
drivers/X11/fl_X11_platform_init.cxx
|
drivers/X11/fl_X11_platform_init.cxx
|
||||||
@@ -223,6 +216,12 @@ if (FLTK_USE_X11)
|
|||||||
set (DRIVER_FILES ${DRIVER_FILES} Fl_Native_File_Chooser_Kdialog.cxx)
|
set (DRIVER_FILES ${DRIVER_FILES} Fl_Native_File_Chooser_Kdialog.cxx)
|
||||||
endif (OPTION_USE_KDIALOG)
|
endif (OPTION_USE_KDIALOG)
|
||||||
|
|
||||||
|
if (FLTK_USE_CAIRO)
|
||||||
|
set (DRIVER_FILES ${DRIVER_FILES}
|
||||||
|
drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
|
||||||
|
drivers/Cairo/Fl_Display_Cairo_Graphics_Driver.cxx
|
||||||
|
)
|
||||||
|
else ()
|
||||||
if (USE_XFT)
|
if (USE_XFT)
|
||||||
set (DRIVER_FILES ${DRIVER_FILES}
|
set (DRIVER_FILES ${DRIVER_FILES}
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
|
||||||
@@ -235,17 +234,38 @@ if (FLTK_USE_X11)
|
|||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
|
||||||
)
|
)
|
||||||
endif (USE_XFT)
|
endif (USE_XFT)
|
||||||
|
set (DRIVER_FILES ${DRIVER_FILES}
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx
|
||||||
|
)
|
||||||
|
endif (FLTK_USE_CAIRO)
|
||||||
|
|
||||||
set (DRIVER_HEADER_FILES
|
set (DRIVER_HEADER_FILES
|
||||||
drivers/Posix/Fl_Posix_System_Driver.H
|
drivers/Posix/Fl_Posix_System_Driver.H
|
||||||
drivers/X11/Fl_X11_Screen_Driver.H
|
drivers/X11/Fl_X11_Screen_Driver.H
|
||||||
drivers/X11/Fl_X11_Window_Driver.H
|
drivers/X11/Fl_X11_Window_Driver.H
|
||||||
drivers/X11/Fl_X11_System_Driver.H
|
drivers/X11/Fl_X11_System_Driver.H
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver.H
|
||||||
drivers/Xlib/Fl_Font.H
|
drivers/Xlib/Fl_Font.H
|
||||||
drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.H
|
drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.H
|
||||||
drivers/Xlib/Fl_Xlib_Image_Surface_Driver.H
|
drivers/Xlib/Fl_Xlib_Image_Surface_Driver.H
|
||||||
drivers/Unix/Fl_Unix_System_Driver.H
|
drivers/Unix/Fl_Unix_System_Driver.H
|
||||||
)
|
)
|
||||||
|
if (FLTK_USE_CAIRO)
|
||||||
|
set (DRIVER_HEADER_FILES ${DRIVER_HEADER_FILES}
|
||||||
|
drivers/Cairo/Fl_Cairo_Graphics_Driver.H
|
||||||
|
drivers/Cairo/Fl_Display_Cairo_Graphics_Driver.H
|
||||||
|
)
|
||||||
|
elseif (USE_PANGO)
|
||||||
|
set (DRIVER_HEADER_FILES ${DRIVER_HEADER_FILES}
|
||||||
|
drivers/Cairo/Fl_Cairo_Graphics_Driver.H
|
||||||
|
)
|
||||||
|
endif (FLTK_USE_CAIRO)
|
||||||
|
|
||||||
elseif (OPTION_USE_WAYLAND)
|
elseif (OPTION_USE_WAYLAND)
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${CMAKE_CURRENT_BINARY_DIR}")
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
@@ -262,9 +282,18 @@ elseif (OPTION_USE_WAYLAND)
|
|||||||
drivers/Wayland/fl_wayland_clipboard_dnd.cxx
|
drivers/Wayland/fl_wayland_clipboard_dnd.cxx
|
||||||
drivers/Wayland/fl_wayland_platform_init.cxx
|
drivers/Wayland/fl_wayland_platform_init.cxx
|
||||||
drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
|
drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
|
||||||
|
drivers/Cairo/Fl_Display_Cairo_Graphics_Driver.cxx
|
||||||
Fl_Native_File_Chooser_FLTK.cxx
|
Fl_Native_File_Chooser_FLTK.cxx
|
||||||
Fl_Native_File_Chooser_GTK.cxx
|
Fl_Native_File_Chooser_GTK.cxx
|
||||||
Fl_Native_File_Chooser_Kdialog.cxx
|
Fl_Native_File_Chooser_Kdialog.cxx
|
||||||
|
drivers/X11/Fl_X11_Screen_Driver.cxx
|
||||||
|
drivers/X11/Fl_X11_Window_Driver.cxx
|
||||||
|
drivers/X11/Fl_X11_System_Driver.cxx
|
||||||
|
drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
|
||||||
|
drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx
|
||||||
|
Fl_x.cxx
|
||||||
|
fl_dnd_x.cxx
|
||||||
|
Fl_get_key.cxx
|
||||||
)
|
)
|
||||||
set (DRIVER_HEADER_FILES
|
set (DRIVER_HEADER_FILES
|
||||||
drivers/Posix/Fl_Posix_System_Driver.H
|
drivers/Posix/Fl_Posix_System_Driver.H
|
||||||
@@ -272,6 +301,8 @@ elseif (OPTION_USE_WAYLAND)
|
|||||||
drivers/Wayland/Fl_Wayland_Screen_Driver.H
|
drivers/Wayland/Fl_Wayland_Screen_Driver.H
|
||||||
drivers/Wayland/Fl_Wayland_Window_Driver.H
|
drivers/Wayland/Fl_Wayland_Window_Driver.H
|
||||||
drivers/Wayland/Fl_Wayland_Graphics_Driver.H
|
drivers/Wayland/Fl_Wayland_Graphics_Driver.H
|
||||||
|
drivers/Cairo/Fl_Cairo_Graphics_Driver.H
|
||||||
|
drivers/Cairo/Fl_Display_Cairo_Graphics_Driver.H
|
||||||
drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.H
|
drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.H
|
||||||
drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H
|
drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H
|
||||||
drivers/Unix/Fl_Unix_System_Driver.H
|
drivers/Unix/Fl_Unix_System_Driver.H
|
||||||
@@ -346,7 +377,7 @@ else ()
|
|||||||
drivers/GDI/Fl_GDI_Image_Surface_Driver.H
|
drivers/GDI/Fl_GDI_Image_Surface_Driver.H
|
||||||
)
|
)
|
||||||
|
|
||||||
endif (FLTK_USE_X11)
|
endif (FLTK_USE_X11 AND NOT OPTION_USE_WAYLAND)
|
||||||
|
|
||||||
source_group("Header Files" FILES ${HEADER_FILES})
|
source_group("Header Files" FILES ${HEADER_FILES})
|
||||||
source_group("Driver Source Files" FILES ${DRIVER_FILES})
|
source_group("Driver Source Files" FILES ${DRIVER_FILES})
|
||||||
@@ -392,19 +423,22 @@ set (GL_DRIVER_FILES
|
|||||||
drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx
|
drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx
|
||||||
drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx
|
drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx
|
||||||
)
|
)
|
||||||
if (FLTK_USE_X11)
|
if (OPTION_USE_WAYLAND)
|
||||||
|
set (GL_DRIVER_FILES ${GL_DRIVER_FILES}
|
||||||
|
drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx
|
||||||
|
drivers/X11/Fl_X11_Gl_Window_Driver.cxx
|
||||||
|
drivers/Wayland/fl_wayland_gl_platform_init.cxx)
|
||||||
|
set (GL_DRIVER_HEADER_FILES drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H drivers/X11/Fl_X11_Gl_Window_Driver.H)
|
||||||
|
elseif (FLTK_USE_X11)
|
||||||
set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/X11/Fl_X11_Gl_Window_Driver.cxx drivers/X11/fl_X11_gl_platform_init.cxx)
|
set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/X11/Fl_X11_Gl_Window_Driver.cxx drivers/X11/fl_X11_gl_platform_init.cxx)
|
||||||
set (GL_DRIVER_HEADER_FILES drivers/X11/Fl_X11_Gl_Window_Driver.H)
|
set (GL_DRIVER_HEADER_FILES drivers/X11/Fl_X11_Gl_Window_Driver.H)
|
||||||
elseif (OPTION_USE_WAYLAND)
|
|
||||||
set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx drivers/Wayland/fl_wayland_gl_platform_init.cxx)
|
|
||||||
set (GL_DRIVER_HEADER_FILES drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H)
|
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.cxx drivers/Cocoa/fl_macOS_gl_platform_init.cxx)
|
set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.cxx drivers/Cocoa/fl_macOS_gl_platform_init.cxx)
|
||||||
set (GL_DRIVER_HEADER_FILES drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.H)
|
set (GL_DRIVER_HEADER_FILES drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.H)
|
||||||
elseif (WIN32)
|
elseif (WIN32)
|
||||||
set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx drivers/WinAPI/fl_WinAPI_gl_platform_init.cxx)
|
set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx drivers/WinAPI/fl_WinAPI_gl_platform_init.cxx)
|
||||||
set (GL_DRIVER_HEADER_FILES drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H)
|
set (GL_DRIVER_HEADER_FILES drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H)
|
||||||
endif (FLTK_USE_X11)
|
endif (OPTION_USE_WAYLAND)
|
||||||
|
|
||||||
set (GL_DRIVER_HEADER_FILES ${GL_DRIVER_FILES}
|
set (GL_DRIVER_HEADER_FILES ${GL_DRIVER_FILES}
|
||||||
drivers/OpenGL/Fl_OpenGL_Display_Device.H
|
drivers/OpenGL/Fl_OpenGL_Display_Device.H
|
||||||
@@ -621,7 +655,7 @@ if (OPTION_USE_WAYLAND)
|
|||||||
if (OPTION_USE_SYSTEM_LIBDECOR)
|
if (OPTION_USE_SYSTEM_LIBDECOR)
|
||||||
list (APPEND OPTIONAL_LIBS "-ldecor-0")
|
list (APPEND OPTIONAL_LIBS "-ldecor-0")
|
||||||
endif (OPTION_USE_SYSTEM_LIBDECOR)
|
endif (OPTION_USE_SYSTEM_LIBDECOR)
|
||||||
list (APPEND OPTIONAL_LIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldl -ldbus-1")
|
list (APPEND OPTIONAL_LIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldl -ldbus-1 -lXcursor -lXrender -lXinerama -lXfixes -lXft -lXext -lX11")
|
||||||
if (GTK_FOUND)
|
if (GTK_FOUND)
|
||||||
list (APPEND OPTIONAL_LIBS ${GTK_LDFLAGS} )
|
list (APPEND OPTIONAL_LIBS ${GTK_LDFLAGS} )
|
||||||
endif (GTK_FOUND)
|
endif (GTK_FOUND)
|
||||||
|
|||||||
+14
-18
@@ -99,8 +99,10 @@ Fl_Screen_Driver *Fl::screen_driver()
|
|||||||
/** Returns a pointer to the unique Fl_System_Driver object of the platform */
|
/** Returns a pointer to the unique Fl_System_Driver object of the platform */
|
||||||
Fl_System_Driver *Fl::system_driver()
|
Fl_System_Driver *Fl::system_driver()
|
||||||
{
|
{
|
||||||
static Fl_System_Driver* system_driver_ = Fl_System_Driver::newSystemDriver();
|
if (!Fl_Screen_Driver::system_driver) {
|
||||||
return system_driver_;
|
Fl_Screen_Driver::system_driver = Fl_System_Driver::newSystemDriver();
|
||||||
|
}
|
||||||
|
return Fl_Screen_Driver::system_driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -578,21 +580,15 @@ int Fl::program_should_quit_ = 0;
|
|||||||
Fl_X* Fl_X::first;
|
Fl_X* Fl_X::first;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** Returns the Fl_Window that corresponds to the given window reference,
|
||||||
|
or \c NULL if not found.
|
||||||
|
\deprecated Kept in the X11, Windows, and macOS platforms for compatibility
|
||||||
|
with FLTK versions before 1.4.
|
||||||
|
Please use fl_x11_find(Window), fl_wl_find(struct wld_window*),
|
||||||
|
fl_win32_find(HWND) or fl_mac_find(FLWindow*) with FLTK 1.4.0 and above.
|
||||||
|
*/
|
||||||
Fl_Window* fl_find(Window xid) {
|
Fl_Window* fl_find(Window xid) {
|
||||||
Fl_X *window;
|
return Fl_Window_Driver::find((fl_uintptr_t)xid);
|
||||||
for (Fl_X **pp = &Fl_X::first; (window = *pp); pp = &window->next) {
|
|
||||||
if (window->xid == xid) {
|
|
||||||
if (window != Fl_X::first && !Fl::modal()) {
|
|
||||||
// make this window be first to speed up searches
|
|
||||||
// this is not done if modal is true to avoid messing up modal stack
|
|
||||||
*pp = window->next;
|
|
||||||
window->next = Fl_X::first;
|
|
||||||
Fl_X::first = window;
|
|
||||||
}
|
|
||||||
return window->w;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -630,7 +626,7 @@ Fl_Window* Fl::next_window(const Fl_Window* window) {
|
|||||||
*/
|
*/
|
||||||
void Fl::first_window(Fl_Window* window) {
|
void Fl::first_window(Fl_Window* window) {
|
||||||
if (!window || !window->shown()) return;
|
if (!window || !window->shown()) return;
|
||||||
fl_find( Fl_X::i(window)->xid );
|
Fl_Window_Driver::find( Fl_X::i(window)->xid );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2021,7 +2017,7 @@ void fl_close_display()
|
|||||||
|
|
||||||
FL_EXPORT Window fl_xid_(const Fl_Window *w) {
|
FL_EXPORT Window fl_xid_(const Fl_Window *w) {
|
||||||
Fl_X *temp = Fl_X::i(w);
|
Fl_X *temp = Fl_X::i(w);
|
||||||
return temp ? temp->xid : 0;
|
return temp ? (Window)temp->xid : 0;
|
||||||
}
|
}
|
||||||
/** \addtogroup group_macosx
|
/** \addtogroup group_macosx
|
||||||
\{ */
|
\{ */
|
||||||
|
|||||||
@@ -506,7 +506,7 @@ static int copy_rgb(double r, double g, double b) {
|
|||||||
|
|
||||||
int Fl_Color_Chooser::handle(int e) {
|
int Fl_Color_Chooser::handle(int e) {
|
||||||
|
|
||||||
unsigned int mods = Fl::event_state() & (FL_META | FL_CTRL | FL_ALT);
|
int mods = Fl::event_state() & (FL_META | FL_CTRL | FL_ALT);
|
||||||
unsigned int shift = Fl::event_state() & FL_SHIFT;
|
unsigned int shift = Fl::event_state() & FL_SHIFT;
|
||||||
|
|
||||||
switch (e) {
|
switch (e) {
|
||||||
|
|||||||
@@ -97,6 +97,10 @@ Fl_Surface_Device::~Fl_Surface_Device()
|
|||||||
if (surface_ == this) surface_ = NULL;
|
if (surface_ == this) surface_ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns non-NULL if this surface is an Fl_Image_Surface object
|
||||||
|
\version 1.4.0
|
||||||
|
*/
|
||||||
|
Fl_Image_Surface *Fl_Surface_Device::as_image_surface() { return NULL; }
|
||||||
|
|
||||||
/** A constructor that sets the graphics driver used by the display */
|
/** A constructor that sets the graphics driver used by the display */
|
||||||
Fl_Display_Device::Fl_Display_Device(Fl_Graphics_Driver *graphics_driver) : Fl_Surface_Device(graphics_driver) {
|
Fl_Display_Device::Fl_Display_Device(Fl_Graphics_Driver *graphics_driver) : Fl_Surface_Device(graphics_driver) {
|
||||||
|
|||||||
@@ -360,6 +360,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "flstring.h"
|
#include "flstring.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// File chooser label strings and sort function...
|
// File chooser label strings and sort function...
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
*/
|
*/
|
||||||
Fl_Image_Surface::Fl_Image_Surface(int w, int h, int high_res, Fl_Offscreen off) : Fl_Widget_Surface(NULL) {
|
Fl_Image_Surface::Fl_Image_Surface(int w, int h, int high_res, Fl_Offscreen off) : Fl_Widget_Surface(NULL) {
|
||||||
platform_surface = Fl_Image_Surface_Driver::newImageSurfaceDriver(w, h, high_res, off);
|
platform_surface = Fl_Image_Surface_Driver::newImageSurfaceDriver(w, h, high_res, off);
|
||||||
|
platform_surface->image_surface_ = this;
|
||||||
if (platform_surface) driver(platform_surface->driver());
|
if (platform_surface) driver(platform_surface->driver());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +89,10 @@ int Fl_Image_Surface_Driver::printable_rect(int *w, int *h) {
|
|||||||
*w = width; *h = height;
|
*w = width; *h = height;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Fl_Image_Surface *Fl_Image_Surface_Driver::as_image_surface() {
|
||||||
|
return image_surface_;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
\}
|
\}
|
||||||
\endcond
|
\endcond
|
||||||
@@ -149,6 +154,12 @@ void Fl_Image_Surface::rescale() {
|
|||||||
delete rgb;
|
delete rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Fl_Image_Surface *Fl_Image_Surface::as_image_surface() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// implementation of the fl_XXX_offscreen() functions
|
// implementation of the fl_XXX_offscreen() functions
|
||||||
|
|
||||||
static Fl_Image_Surface **offscreen_api_surface = NULL;
|
static Fl_Image_Surface **offscreen_api_surface = NULL;
|
||||||
|
|||||||
+1
-1
@@ -374,7 +374,7 @@ int Fl_Input::handle_key() {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int mods = Fl::event_state() & (FL_META|FL_CTRL|FL_ALT);
|
int mods = Fl::event_state() & (FL_META|FL_CTRL|FL_ALT);
|
||||||
unsigned int shift = Fl::event_state() & FL_SHIFT;
|
unsigned int shift = Fl::event_state() & FL_SHIFT;
|
||||||
unsigned int multiline = (input_type() == FL_MULTILINE_INPUT) ? 1 : 0;
|
unsigned int multiline = (input_type() == FL_MULTILINE_INPUT) ? 1 : 0;
|
||||||
//
|
//
|
||||||
|
|||||||
+1
-1
@@ -548,7 +548,7 @@ void Fl_Message::icon_label(const char *str) {
|
|||||||
// handle ctrl-c (command-c on macOS) to copy message text
|
// handle ctrl-c (command-c on macOS) to copy message text
|
||||||
|
|
||||||
int Fl_Message_Box::handle(int e) {
|
int Fl_Message_Box::handle(int e) {
|
||||||
unsigned int mods = Fl::event_state() & (FL_META|FL_CTRL|FL_ALT);
|
int mods = Fl::event_state() & (FL_META|FL_CTRL|FL_ALT);
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case FL_KEYBOARD:
|
case FL_KEYBOARD:
|
||||||
case FL_SHORTCUT:
|
case FL_SHORTCUT:
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
#include <FL/Fl_Native_File_Chooser.H>
|
#include <FL/Fl_Native_File_Chooser.H>
|
||||||
#include <FL/Fl_File_Chooser.H>
|
#include <FL/Fl_File_Chooser.H>
|
||||||
#include <FL/Fl_File_Icon.H>
|
#include <FL/Fl_File_Icon.H>
|
||||||
#include "Fl_System_Driver.H" // for struct stat
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class Fl_Window;
|
|||||||
class Fl_RGB_Image;
|
class Fl_RGB_Image;
|
||||||
class Fl_Group;
|
class Fl_Group;
|
||||||
class Fl_Input;
|
class Fl_Input;
|
||||||
|
class Fl_System_Driver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A base class describing the interface between FLTK and screen-related operations.
|
A base class describing the interface between FLTK and screen-related operations.
|
||||||
@@ -68,6 +69,7 @@ public:
|
|||||||
static char bg_set;
|
static char bg_set;
|
||||||
static char bg2_set;
|
static char bg2_set;
|
||||||
static char fg_set;
|
static char fg_set;
|
||||||
|
static Fl_System_Driver *system_driver;
|
||||||
|
|
||||||
virtual float scale(int) { return 1; }
|
virtual float scale(int) { return 1; }
|
||||||
virtual void scale(int /*n*/, float /*f*/) {}
|
virtual void scale(int /*n*/, float /*f*/) {}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
char Fl_Screen_Driver::bg_set = 0;
|
char Fl_Screen_Driver::bg_set = 0;
|
||||||
char Fl_Screen_Driver::bg2_set = 0;
|
char Fl_Screen_Driver::bg2_set = 0;
|
||||||
char Fl_Screen_Driver::fg_set = 0;
|
char Fl_Screen_Driver::fg_set = 0;
|
||||||
|
Fl_System_Driver *Fl_Screen_Driver::system_driver = NULL;
|
||||||
|
|
||||||
int Fl_Screen_Driver::keyboard_screen_scaling = 1;
|
int Fl_Screen_Driver::keyboard_screen_scaling = 1;
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ public:
|
|||||||
static const int fl_YValue;
|
static const int fl_YValue;
|
||||||
static const int fl_XNegative;
|
static const int fl_XNegative;
|
||||||
static const int fl_YNegative;
|
static const int fl_YNegative;
|
||||||
|
static int command_key;
|
||||||
|
static int control_key;
|
||||||
|
|
||||||
// implement if the system adds unwanted program argument(s)
|
// implement if the system adds unwanted program argument(s)
|
||||||
virtual int single_arg(const char *) { return 0; }
|
virtual int single_arg(const char *) { return 0; }
|
||||||
|
|||||||
@@ -83,11 +83,30 @@ static Fl_System_Driver::Keyname default_key_table[] = {
|
|||||||
{FL_Delete, "Delete"}
|
{FL_Delete, "Delete"}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int Fl_System_Driver::command_key = 0;
|
||||||
|
int Fl_System_Driver::control_key = 0;
|
||||||
|
|
||||||
|
|
||||||
|
int fl_command_modifier() {
|
||||||
|
if (!Fl_System_Driver::command_key) Fl::system_driver();
|
||||||
|
return Fl_System_Driver::command_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int fl_control_modifier() {
|
||||||
|
if (!Fl_System_Driver::control_key) Fl::system_driver();
|
||||||
|
return Fl_System_Driver::control_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Fl_System_Driver::Fl_System_Driver()
|
Fl_System_Driver::Fl_System_Driver()
|
||||||
{
|
{
|
||||||
// initialize default key table (used in fl_shortcut.cxx)
|
// initialize default key table (used in fl_shortcut.cxx)
|
||||||
key_table = default_key_table;
|
key_table = default_key_table;
|
||||||
key_table_size = sizeof(default_key_table)/sizeof(*default_key_table);
|
key_table_size = sizeof(default_key_table)/sizeof(*default_key_table);
|
||||||
|
command_key = FL_CTRL;
|
||||||
|
control_key = FL_META;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fl_System_Driver::~Fl_System_Driver()
|
Fl_System_Driver::~Fl_System_Driver()
|
||||||
|
|||||||
@@ -879,6 +879,8 @@ const Fl_Image* Fl_Window::shape() {return pWindowDriver->shape();}
|
|||||||
bool Fl_Window::is_a_rescale() {return Fl_Window_Driver::is_a_rescale_;}
|
bool Fl_Window::is_a_rescale() {return Fl_Window_Driver::is_a_rescale_;}
|
||||||
|
|
||||||
/** Returns a platform-specific identification of a shown window, or 0 if not shown.
|
/** Returns a platform-specific identification of a shown window, or 0 if not shown.
|
||||||
|
\note This identification may differ from the platform-specific reference of an
|
||||||
|
Fl_Window object used by functions fl_x11_xid(), fl_mac_xid(), fl_x11_find(), and fl_mac_find().
|
||||||
\li X11 platform: the window's XID.
|
\li X11 platform: the window's XID.
|
||||||
\li macOS platform: The window number of the window’s window device.
|
\li macOS platform: The window number of the window’s window device.
|
||||||
\li other platforms: 0.
|
\li other platforms: 0.
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ public:
|
|||||||
Fl_Window_Driver(Fl_Window *);
|
Fl_Window_Driver(Fl_Window *);
|
||||||
virtual ~Fl_Window_Driver();
|
virtual ~Fl_Window_Driver();
|
||||||
static Fl_Window_Driver *newWindowDriver(Fl_Window *);
|
static Fl_Window_Driver *newWindowDriver(Fl_Window *);
|
||||||
|
static fl_uintptr_t xid(const Fl_Window *win);
|
||||||
|
static Fl_Window *find(fl_uintptr_t xid);
|
||||||
int wait_for_expose_value;
|
int wait_for_expose_value;
|
||||||
Fl_Offscreen other_xid; // offscreen bitmap (overlay and double-buffered windows)
|
Fl_Offscreen other_xid; // offscreen bitmap (overlay and double-buffered windows)
|
||||||
virtual int screen_num();
|
virtual int screen_num();
|
||||||
|
|||||||
@@ -258,6 +258,32 @@ void Fl_Window_Driver::menu_window_area(int &X, int &Y, int &W, int &H, int nscr
|
|||||||
scr_driver->screen_work_area(X, Y, W, H, nscreen);
|
scr_driver->screen_work_area(X, Y, W, H, nscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the platform-specific reference of the given window, or NULL if that window isn't shown.
|
||||||
|
\version 1.4.0 */
|
||||||
|
fl_uintptr_t Fl_Window_Driver::xid(const Fl_Window *win) {
|
||||||
|
Fl_X *flx = win->i;
|
||||||
|
return flx ? flx->xid : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns a pointer to the Fl_Window corresponding to the platform-specific reference \p xid of a shown window.
|
||||||
|
\version 1.4.0 */
|
||||||
|
Fl_Window *Fl_Window_Driver::find(fl_uintptr_t xid) {
|
||||||
|
Fl_X *window;
|
||||||
|
for (Fl_X **pp = &Fl_X::first; (window = *pp); pp = &window->next) {
|
||||||
|
if (window->xid == xid) {
|
||||||
|
if (window != Fl_X::first && !Fl::modal()) {
|
||||||
|
// make this window be first to speed up searches
|
||||||
|
// this is not done if modal is true to avoid messing up modal stack
|
||||||
|
*pp = window->next;
|
||||||
|
window->next = Fl_X::first;
|
||||||
|
Fl_X::first = window;
|
||||||
|
}
|
||||||
|
return window->w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\}
|
\}
|
||||||
\endcond
|
\endcond
|
||||||
|
|||||||
+12
-12
@@ -81,7 +81,7 @@ int fl_mac_os_version = Fl_Darwin_System_Driver::calc_mac_os_version();
|
|||||||
|
|
||||||
// public variables
|
// public variables
|
||||||
void *fl_capture = 0; // (NSWindow*) we need this to compensate for a missing(?) mouse capture
|
void *fl_capture = 0; // (NSWindow*) we need this to compensate for a missing(?) mouse capture
|
||||||
Window fl_window;
|
FLWindow *fl_window;
|
||||||
|
|
||||||
// forward declarations of variables in this file
|
// forward declarations of variables in this file
|
||||||
static int main_screen_height; // height of menubar-containing screen used to convert between Cocoa and FLTK global screen coordinates
|
static int main_screen_height; // height of menubar-containing screen used to convert between Cocoa and FLTK global screen coordinates
|
||||||
@@ -803,7 +803,7 @@ static NSInteger max_normal_window_level(void)
|
|||||||
|
|
||||||
for (x = Fl_X::first;x;x = x->next) {
|
for (x = Fl_X::first;x;x = x->next) {
|
||||||
NSInteger level;
|
NSInteger level;
|
||||||
FLWindow *cw = x->xid;
|
FLWindow *cw = (FLWindow*)x->xid;
|
||||||
Fl_Window *win = x->w;
|
Fl_Window *win = x->w;
|
||||||
if (!win || !cw || ![cw isVisible])
|
if (!win || !cw || ![cw isVisible])
|
||||||
continue;
|
continue;
|
||||||
@@ -868,7 +868,7 @@ static void fixup_window_levels(void)
|
|||||||
prev_non_modal = NULL;
|
prev_non_modal = NULL;
|
||||||
|
|
||||||
for (x = Fl_X::first;x;x = x->next) {
|
for (x = Fl_X::first;x;x = x->next) {
|
||||||
FLWindow *cw = x->xid;
|
FLWindow *cw = (FLWindow*)x->xid;
|
||||||
Fl_Window *win = x->w;
|
Fl_Window *win = x->w;
|
||||||
if (!win || !cw || ![cw isVisible])
|
if (!win || !cw || ![cw isVisible])
|
||||||
continue;
|
continue;
|
||||||
@@ -1513,7 +1513,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
|||||||
FLWindow *top = 0;
|
FLWindow *top = 0;
|
||||||
// sort in all regular windows
|
// sort in all regular windows
|
||||||
for (x = Fl_X::first;x;x = x->next) {
|
for (x = Fl_X::first;x;x = x->next) {
|
||||||
FLWindow *cw = x->xid;
|
FLWindow *cw = (FLWindow*)x->xid;
|
||||||
Fl_Window *win = x->w;
|
Fl_Window *win = x->w;
|
||||||
if (win && cw) {
|
if (win && cw) {
|
||||||
if (win->modal()) {
|
if (win->modal()) {
|
||||||
@@ -1525,7 +1525,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
|||||||
}
|
}
|
||||||
// now sort in all modals
|
// now sort in all modals
|
||||||
for (x = Fl_X::first;x;x = x->next) {
|
for (x = Fl_X::first;x;x = x->next) {
|
||||||
FLWindow *cw = x->xid;
|
FLWindow *cw = (FLWindow*)x->xid;
|
||||||
Fl_Window *win = x->w;
|
Fl_Window *win = x->w;
|
||||||
if (win && cw && [cw isVisible]) {
|
if (win && cw && [cw isVisible]) {
|
||||||
if (win->modal()) {
|
if (win->modal()) {
|
||||||
@@ -1536,7 +1536,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
|||||||
}
|
}
|
||||||
// finally all non-modals
|
// finally all non-modals
|
||||||
for (x = Fl_X::first;x;x = x->next) {
|
for (x = Fl_X::first;x;x = x->next) {
|
||||||
FLWindow *cw = x->xid;
|
FLWindow *cw = (FLWindow*)x->xid;
|
||||||
Fl_Window *win = x->w;
|
Fl_Window *win = x->w;
|
||||||
if (win && cw && [cw isVisible]) {
|
if (win && cw && [cw isVisible]) {
|
||||||
if (win->non_modal()) {
|
if (win->non_modal()) {
|
||||||
@@ -1600,8 +1600,8 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
|||||||
{ // before 10.5, subwindows are lost when application is unhidden
|
{ // before 10.5, subwindows are lost when application is unhidden
|
||||||
fl_lock_function();
|
fl_lock_function();
|
||||||
for (Fl_X *x = Fl_X::first; x; x = x->next) {
|
for (Fl_X *x = Fl_X::first; x; x = x->next) {
|
||||||
if (![x->xid parentWindow]) {
|
if (![(FLWindow*)x->xid parentWindow]) {
|
||||||
orderfront_subwindows(x->xid);
|
orderfront_subwindows((FLWindow*)x->xid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fl_unlock_function();
|
fl_unlock_function();
|
||||||
@@ -3103,7 +3103,7 @@ Fl_X* Fl_Cocoa_Window_Driver::makeWindow()
|
|||||||
[cw setOpaque:NO]; // shaped windows must be non opaque
|
[cw setOpaque:NO]; // shaped windows must be non opaque
|
||||||
[cw setBackgroundColor:[NSColor clearColor]]; // and with transparent background color
|
[cw setBackgroundColor:[NSColor clearColor]]; // and with transparent background color
|
||||||
}
|
}
|
||||||
x->xid = cw;
|
x->xid = (fl_uintptr_t)cw;
|
||||||
x->w = w;
|
x->w = w;
|
||||||
i(x);
|
i(x);
|
||||||
wait_for_expose_value = 1;
|
wait_for_expose_value = 1;
|
||||||
@@ -3444,7 +3444,7 @@ void Fl_Cocoa_Window_Driver::make_current()
|
|||||||
q_release_context();
|
q_release_context();
|
||||||
Fl_X *i = Fl_X::i(pWindow);
|
Fl_X *i = Fl_X::i(pWindow);
|
||||||
//NSLog(@"region-count=%d damage=%u",i->region?i->region->count:0, pWindow->damage());
|
//NSLog(@"region-count=%d damage=%u",i->region?i->region->count:0, pWindow->damage());
|
||||||
fl_window = i->xid;
|
fl_window = (FLWindow*)i->xid;
|
||||||
((Fl_Quartz_Graphics_Driver&)Fl_Graphics_Driver::default_driver()).high_resolution( mapped_to_retina() );
|
((Fl_Quartz_Graphics_Driver&)Fl_Graphics_Driver::default_driver()).high_resolution( mapped_to_retina() );
|
||||||
|
|
||||||
if (pWindow->as_overlay_window() && other_xid && changed_resolution()) {
|
if (pWindow->as_overlay_window() && other_xid && changed_resolution()) {
|
||||||
@@ -3766,7 +3766,7 @@ void Fl_Cocoa_Window_Driver::destroy(FLWindow *xid) {
|
|||||||
|
|
||||||
|
|
||||||
void Fl_Cocoa_Window_Driver::map() {
|
void Fl_Cocoa_Window_Driver::map() {
|
||||||
Window xid = fl_xid(pWindow);
|
FLWindow *xid = fl_xid(pWindow);
|
||||||
if (pWindow && xid && ![xid parentWindow]) { // 10.2
|
if (pWindow && xid && ![xid parentWindow]) { // 10.2
|
||||||
// after a subwindow has been unmapped, it has lost its parent window and its frame may be wrong
|
// after a subwindow has been unmapped, it has lost its parent window and its frame may be wrong
|
||||||
[xid setSubwindowFrame];
|
[xid setSubwindowFrame];
|
||||||
@@ -3779,7 +3779,7 @@ void Fl_Cocoa_Window_Driver::map() {
|
|||||||
|
|
||||||
|
|
||||||
void Fl_Cocoa_Window_Driver::unmap() {
|
void Fl_Cocoa_Window_Driver::unmap() {
|
||||||
Window xid = fl_xid(pWindow);
|
FLWindow *xid = fl_xid(pWindow);
|
||||||
if (pWindow && xid) {
|
if (pWindow && xid) {
|
||||||
if (parent()) [[xid parentWindow] removeChildWindow:xid]; // necessary with at least 10.5
|
if (parent()) [[xid parentWindow] removeChildWindow:xid]; // necessary with at least 10.5
|
||||||
[xid orderOut:nil];
|
[xid orderOut:nil];
|
||||||
|
|||||||
+17
-15
@@ -636,7 +636,7 @@ void Fl_WinAPI_Screen_Driver::enable_im() {
|
|||||||
|
|
||||||
Fl_X *i = Fl_X::first;
|
Fl_X *i = Fl_X::first;
|
||||||
while (i) {
|
while (i) {
|
||||||
flImmAssociateContextEx(i->xid, 0, IACE_DEFAULT);
|
flImmAssociateContextEx((HWND)i->xid, 0, IACE_DEFAULT);
|
||||||
i = i->next;
|
i = i->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -648,7 +648,7 @@ void Fl_WinAPI_Screen_Driver::disable_im() {
|
|||||||
|
|
||||||
Fl_X *i = Fl_X::first;
|
Fl_X *i = Fl_X::first;
|
||||||
while (i) {
|
while (i) {
|
||||||
flImmAssociateContextEx(i->xid, 0, 0);
|
flImmAssociateContextEx((HWND)i->xid, 0, 0);
|
||||||
i = i->next;
|
i = i->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1288,7 +1288,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_PAINT: {
|
case WM_PAINT: {
|
||||||
Fl_Region R, R2;
|
HRGN R, R2;
|
||||||
Fl_X *i = Fl_X::i(window);
|
Fl_X *i = Fl_X::i(window);
|
||||||
Fl_Window_Driver::driver(window)->wait_for_expose_value = 0;
|
Fl_Window_Driver::driver(window)->wait_for_expose_value = 0;
|
||||||
char redraw_whole_window = false;
|
char redraw_whole_window = false;
|
||||||
@@ -1307,7 +1307,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||||||
}
|
}
|
||||||
|
|
||||||
// convert i->region in FLTK units to R2 in drawing units
|
// convert i->region in FLTK units to R2 in drawing units
|
||||||
R2 = Fl_GDI_Graphics_Driver::scale_region(i->region, scale, NULL);
|
R2 = Fl_GDI_Graphics_Driver::scale_region((HRGN)i->region, scale, NULL);
|
||||||
|
|
||||||
RECT r_box;
|
RECT r_box;
|
||||||
if (scale != 1 && GetRgnBox(R, &r_box) != NULLREGION) {
|
if (scale != 1 && GetRgnBox(R, &r_box) != NULLREGION) {
|
||||||
@@ -1316,10 +1316,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||||||
r_box.right = LONG(r_box.right / scale);
|
r_box.right = LONG(r_box.right / scale);
|
||||||
r_box.top = LONG(r_box.top / scale);
|
r_box.top = LONG(r_box.top / scale);
|
||||||
r_box.bottom = LONG(r_box.bottom / scale);
|
r_box.bottom = LONG(r_box.bottom / scale);
|
||||||
Fl_Region R3 = CreateRectRgn(r_box.left, r_box.top, r_box.right + 1, r_box.bottom + 1);
|
HRGN R3 = CreateRectRgn(r_box.left, r_box.top, r_box.right + 1, r_box.bottom + 1);
|
||||||
if (!i->region) i->region = R3;
|
if (!i->region) i->region = R3;
|
||||||
else {
|
else {
|
||||||
CombineRgn(i->region, i->region, R3, RGN_OR);
|
CombineRgn((HRGN)i->region, (HRGN)i->region, R3, RGN_OR);
|
||||||
DeleteObject(R3);
|
DeleteObject(R3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2185,7 +2185,7 @@ Fl_X *Fl_WinAPI_Window_Driver::makeWindow() {
|
|||||||
wlen = fl_utf8toUtf16(w->label(), (unsigned)l, (unsigned short *)lab, wlen);
|
wlen = fl_utf8toUtf16(w->label(), (unsigned)l, (unsigned short *)lab, wlen);
|
||||||
lab[wlen] = 0;
|
lab[wlen] = 0;
|
||||||
}
|
}
|
||||||
x->xid = CreateWindowExW(styleEx,
|
x->xid = (fl_uintptr_t)CreateWindowExW(styleEx,
|
||||||
class_namew, lab, style,
|
class_namew, lab, style,
|
||||||
xp, yp, wp, hp,
|
xp, yp, wp, hp,
|
||||||
parent,
|
parent,
|
||||||
@@ -2208,14 +2208,14 @@ Fl_X *Fl_WinAPI_Window_Driver::makeWindow() {
|
|||||||
for x and y. We can then use GetWindowRect to determine which
|
for x and y. We can then use GetWindowRect to determine which
|
||||||
monitor the window was placed on. */
|
monitor the window was placed on. */
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetWindowRect(x->xid, &rect);
|
GetWindowRect((HWND)x->xid, &rect);
|
||||||
make_fullscreen(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
|
make_fullscreen(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup clipboard monitor target if there are registered handlers and
|
// Setup clipboard monitor target if there are registered handlers and
|
||||||
// no window is targeted.
|
// no window is targeted.
|
||||||
if (!fl_clipboard_notify_empty() && clipboard_wnd == NULL)
|
if (!fl_clipboard_notify_empty() && clipboard_wnd == NULL)
|
||||||
fl_clipboard_notify_target(x->xid);
|
fl_clipboard_notify_target((HWND)x->xid);
|
||||||
|
|
||||||
wait_for_expose_value = 1;
|
wait_for_expose_value = 1;
|
||||||
if (show_iconic()) {
|
if (show_iconic()) {
|
||||||
@@ -2239,14 +2239,14 @@ Fl_X *Fl_WinAPI_Window_Driver::makeWindow() {
|
|||||||
|
|
||||||
// If we've captured the mouse, we dont want to activate any
|
// If we've captured the mouse, we dont want to activate any
|
||||||
// other windows from the code, or we lose the capture.
|
// other windows from the code, or we lose the capture.
|
||||||
ShowWindow(x->xid, !showit ? SW_SHOWMINNOACTIVE :
|
ShowWindow((HWND)x->xid, !showit ? SW_SHOWMINNOACTIVE :
|
||||||
(Fl::grab() || (styleEx & WS_EX_TOOLWINDOW)) ? SW_SHOWNOACTIVATE : SW_SHOWNORMAL);
|
(Fl::grab() || (styleEx & WS_EX_TOOLWINDOW)) ? SW_SHOWNOACTIVATE : SW_SHOWNORMAL);
|
||||||
|
|
||||||
// Register all windows for potential drag'n'drop operations
|
// Register all windows for potential drag'n'drop operations
|
||||||
RegisterDragDrop(x->xid, flIDropTarget);
|
RegisterDragDrop((HWND)x->xid, flIDropTarget);
|
||||||
|
|
||||||
if (!im_enabled)
|
if (!im_enabled)
|
||||||
flImmAssociateContextEx(x->xid, 0, 0);
|
flImmAssociateContextEx((HWND)x->xid, 0, 0);
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
@@ -2256,6 +2256,8 @@ Fl_X *Fl_WinAPI_Window_Driver::makeWindow() {
|
|||||||
|
|
||||||
HINSTANCE fl_display = GetModuleHandle(NULL);
|
HINSTANCE fl_display = GetModuleHandle(NULL);
|
||||||
|
|
||||||
|
HINSTANCE fl_win32_display() { return fl_display; }
|
||||||
|
|
||||||
void Fl_WinAPI_Window_Driver::set_minmax(LPMINMAXINFO minmax) {
|
void Fl_WinAPI_Window_Driver::set_minmax(LPMINMAXINFO minmax) {
|
||||||
int td, wd, hd, dummy_x, dummy_y;
|
int td, wd, hd, dummy_x, dummy_y;
|
||||||
|
|
||||||
@@ -2632,10 +2634,10 @@ void Fl_WinAPI_Window_Driver::show() {
|
|||||||
} else {
|
} else {
|
||||||
// Once again, we would lose the capture if we activated the window.
|
// Once again, we would lose the capture if we activated the window.
|
||||||
Fl_X *i = Fl_X::i(pWindow);
|
Fl_X *i = Fl_X::i(pWindow);
|
||||||
if (IsIconic(i->xid))
|
if (IsIconic((HWND)i->xid))
|
||||||
OpenIcon(i->xid);
|
OpenIcon((HWND)i->xid);
|
||||||
if (!fl_capture)
|
if (!fl_capture)
|
||||||
BringWindowToTop(i->xid);
|
BringWindowToTop((HWND)i->xid);
|
||||||
// ShowWindow(i->xid,fl_capture?SW_SHOWNOACTIVATE:SW_RESTORE);
|
// ShowWindow(i->xid,fl_capture?SW_SHOWNOACTIVATE:SW_RESTORE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-1
@@ -41,7 +41,11 @@
|
|||||||
# include "drivers/X11/Fl_X11_Screen_Driver.H"
|
# include "drivers/X11/Fl_X11_Screen_Driver.H"
|
||||||
# include "drivers/X11/Fl_X11_Window_Driver.H"
|
# include "drivers/X11/Fl_X11_Window_Driver.H"
|
||||||
# include "drivers/X11/Fl_X11_System_Driver.H"
|
# include "drivers/X11/Fl_X11_System_Driver.H"
|
||||||
|
#if FLTK_USE_CAIRO
|
||||||
|
# include "drivers/Cairo/Fl_Display_Cairo_Graphics_Driver.H"
|
||||||
|
#else
|
||||||
# include "drivers/Xlib/Fl_Xlib_Graphics_Driver.H"
|
# include "drivers/Xlib/Fl_Xlib_Graphics_Driver.H"
|
||||||
|
#endif
|
||||||
# include "print_button.h"
|
# include "print_button.h"
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <time.h>
|
# include <time.h>
|
||||||
@@ -53,6 +57,11 @@
|
|||||||
# include <X11/keysym.h>
|
# include <X11/keysym.h>
|
||||||
# include "Xutf8.h"
|
# include "Xutf8.h"
|
||||||
|
|
||||||
|
#if FLTK_USE_CAIRO
|
||||||
|
# include <cairo-xlib.h>
|
||||||
|
# include <cairo/cairo.h>
|
||||||
|
#endif // FLTK_USE_CAIRO
|
||||||
|
|
||||||
#define USE_XRANDR (HAVE_DLSYM && HAVE_DLFCN_H) // means attempt to dynamically load libXrandr.so
|
#define USE_XRANDR (HAVE_DLSYM && HAVE_DLFCN_H) // means attempt to dynamically load libXrandr.so
|
||||||
#if USE_XRANDR
|
#if USE_XRANDR
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
@@ -149,6 +158,7 @@ static void convert_crlf(unsigned char *string, long& len) {
|
|||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Display *fl_display;
|
Display *fl_display;
|
||||||
|
Display *fl_x11_display() { return fl_display; }
|
||||||
Window fl_message_window = 0;
|
Window fl_message_window = 0;
|
||||||
int fl_screen;
|
int fl_screen;
|
||||||
XVisualInfo *fl_visual;
|
XVisualInfo *fl_visual;
|
||||||
@@ -2117,7 +2127,15 @@ void Fl_X11_Window_Driver::resize(int X,int Y,int W,int H) {
|
|||||||
else if (!is_a_resize && !is_a_move) return;
|
else if (!is_a_resize && !is_a_move) return;
|
||||||
if (is_a_resize) {
|
if (is_a_resize) {
|
||||||
pWindow->Fl_Group::resize(X,Y,W,H);
|
pWindow->Fl_Group::resize(X,Y,W,H);
|
||||||
if (shown()) {pWindow->redraw();}
|
if (shown()) {
|
||||||
|
#if FLTK_USE_CAIRO
|
||||||
|
if (!pWindow->as_gl_window() && cairo_) {
|
||||||
|
float s = Fl::screen_driver()->scale(screen_num());
|
||||||
|
cairo_xlib_surface_set_size(cairo_get_target(cairo_), (W>0 ? int(W*s) : 1), (H>0 ? int(H*s) : 1));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
pWindow->redraw();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
x(X); y(Y);
|
x(X); y(Y);
|
||||||
if (Fl_X11_Screen_Driver::xim_win && Fl::focus()) {
|
if (Fl_X11_Screen_Driver::xim_win && Fl::focus()) {
|
||||||
@@ -2202,6 +2220,7 @@ static int xrender_supported() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ! FLTK_USE_CAIRO
|
||||||
char Fl_Xlib_Graphics_Driver::can_do_alpha_blending() {
|
char Fl_Xlib_Graphics_Driver::can_do_alpha_blending() {
|
||||||
#if HAVE_XRENDER
|
#if HAVE_XRENDER
|
||||||
static char result = (char)xrender_supported();
|
static char result = (char)xrender_supported();
|
||||||
@@ -2210,6 +2229,7 @@ char Fl_Xlib_Graphics_Driver::can_do_alpha_blending() {
|
|||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
extern Fl_Window *fl_xfocus;
|
extern Fl_Window *fl_xfocus;
|
||||||
|
|
||||||
|
|||||||
+31
-11
@@ -207,9 +207,11 @@ GLCPPFILES_OSX = drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.cxx \
|
|||||||
GLCPPFILES_X11 = drivers/X11/Fl_X11_Gl_Window_Driver.cxx \
|
GLCPPFILES_X11 = drivers/X11/Fl_X11_Gl_Window_Driver.cxx \
|
||||||
drivers/X11/fl_X11_gl_platform_init.cxx
|
drivers/X11/fl_X11_gl_platform_init.cxx
|
||||||
GLCPPFILES_XFT = $(GLCPPFILES_X11)
|
GLCPPFILES_XFT = $(GLCPPFILES_X11)
|
||||||
|
GLCPPFILES_CAIRO = $(GLCPPFILES_X11)
|
||||||
GLCPPFILES_WIN = drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx \
|
GLCPPFILES_WIN = drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx \
|
||||||
drivers/WinAPI/fl_WinAPI_gl_platform_init.cxx
|
drivers/WinAPI/fl_WinAPI_gl_platform_init.cxx
|
||||||
GLCPPFILES_WAYLAND = drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx \
|
GLCPPFILES_WAYLAND = drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx \
|
||||||
|
drivers/X11/Fl_X11_Gl_Window_Driver.cxx \
|
||||||
drivers/Wayland/fl_wayland_gl_platform_init.cxx
|
drivers/Wayland/fl_wayland_gl_platform_init.cxx
|
||||||
|
|
||||||
GLCPPFILES += $(GLCPPFILES_$(BUILD))
|
GLCPPFILES += $(GLCPPFILES_$(BUILD))
|
||||||
@@ -258,13 +260,6 @@ QUARTZCPPFILES = \
|
|||||||
|
|
||||||
# These C++ files are used under condition: BUILD_X11
|
# These C++ files are used under condition: BUILD_X11
|
||||||
XLIBCPPFILES = \
|
XLIBCPPFILES = \
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx \
|
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx \
|
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx \
|
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx \
|
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx \
|
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx \
|
|
||||||
drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx \
|
|
||||||
drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx \
|
drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx \
|
||||||
drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx \
|
drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx \
|
||||||
drivers/X11/Fl_X11_Window_Driver.cxx \
|
drivers/X11/Fl_X11_Window_Driver.cxx \
|
||||||
@@ -281,6 +276,20 @@ XLIBCPPFILES = \
|
|||||||
Fl_Native_File_Chooser_Kdialog.cxx \
|
Fl_Native_File_Chooser_Kdialog.cxx \
|
||||||
Fl_get_key.cxx
|
Fl_get_key.cxx
|
||||||
|
|
||||||
|
# These graphics driver files are used under condition: BUILD_CAIRO
|
||||||
|
CAIROGDFILES = \
|
||||||
|
drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx \
|
||||||
|
drivers/Cairo/Fl_Display_Cairo_Graphics_Driver.cxx
|
||||||
|
|
||||||
|
# These graphics driver files are used under condition: BUILD_X11 AND BUILD_XFT
|
||||||
|
XLIBGDFILES = drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx \
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx \
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx \
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx \
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx \
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx \
|
||||||
|
drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx
|
||||||
|
|
||||||
# These C++ files are used under condition: BUILD_WAYLAND
|
# These C++ files are used under condition: BUILD_WAYLAND
|
||||||
WLCPPFILES = \
|
WLCPPFILES = \
|
||||||
drivers/Posix/Fl_Posix_Printer_Driver.cxx \
|
drivers/Posix/Fl_Posix_Printer_Driver.cxx \
|
||||||
@@ -296,7 +305,16 @@ WLCPPFILES = \
|
|||||||
drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx \
|
drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx \
|
||||||
drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx \
|
drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx \
|
||||||
drivers/Wayland/fl_wayland_platform_init.cxx \
|
drivers/Wayland/fl_wayland_platform_init.cxx \
|
||||||
drivers/Wayland/fl_wayland_clipboard_dnd.cxx
|
drivers/Wayland/fl_wayland_clipboard_dnd.cxx \
|
||||||
|
drivers/X11/Fl_X11_Screen_Driver.cxx \
|
||||||
|
drivers/X11/Fl_X11_Window_Driver.cxx \
|
||||||
|
drivers/X11/Fl_X11_System_Driver.cxx \
|
||||||
|
drivers/Cairo/Fl_Display_Cairo_Graphics_Driver.cxx \
|
||||||
|
drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx \
|
||||||
|
drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx \
|
||||||
|
Fl_x.cxx \
|
||||||
|
fl_dnd_x.cxx \
|
||||||
|
Fl_get_key.cxx
|
||||||
|
|
||||||
|
|
||||||
# fl_dnd_x.cxx Fl_Native_File_Chooser_GTK.cxx
|
# fl_dnd_x.cxx Fl_Native_File_Chooser_GTK.cxx
|
||||||
@@ -364,7 +382,7 @@ FLTKFLAGS = -DFL_LIBRARY
|
|||||||
include ../makeinclude
|
include ../makeinclude
|
||||||
|
|
||||||
# makeinclude has set this variable:
|
# makeinclude has set this variable:
|
||||||
# BUILD = {WIN|X11|XFT|OSX|WAYLAND}
|
# BUILD = {WIN|X11|XFT|CAIRO|OSX|WAYLAND}
|
||||||
|
|
||||||
MMFILES_OSX = $(OBJCPPFILES)
|
MMFILES_OSX = $(OBJCPPFILES)
|
||||||
MMFILES = $(MMFILES_$(BUILD))
|
MMFILES = $(MMFILES_$(BUILD))
|
||||||
@@ -372,8 +390,9 @@ MMFILES = $(MMFILES_$(BUILD))
|
|||||||
CPPFILES += $(PSCPPFILES)
|
CPPFILES += $(PSCPPFILES)
|
||||||
CPPFILES_OSX = $(QUARTZCPPFILES)
|
CPPFILES_OSX = $(QUARTZCPPFILES)
|
||||||
|
|
||||||
CPPFILES_XFT = $(XLIBCPPFILES) $(XLIBXFTFILES)
|
CPPFILES_XFT = $(XLIBCPPFILES) $(XLIBGDFILES) $(XLIBXFTFILES)
|
||||||
CPPFILES_X11 = $(XLIBCPPFILES) $(XLIBFONTFILES)
|
CPPFILES_X11 = $(XLIBCPPFILES) $(XLIBGDFILES) $(XLIBFONTFILES)
|
||||||
|
CPPFILES_CAIRO = $(XLIBCPPFILES) $(CAIROGDFILES)
|
||||||
|
|
||||||
CPPFILES_WAYLAND = $(WLCPPFILES) $(WLXFTFILES)
|
CPPFILES_WAYLAND = $(WLCPPFILES) $(WLXFTFILES)
|
||||||
|
|
||||||
@@ -383,6 +402,7 @@ CPPFILES += $(CPPFILES_$(BUILD))
|
|||||||
|
|
||||||
|
|
||||||
CFILES_X11 = $(XLIBCFILES) $(XLIBXCFILES)
|
CFILES_X11 = $(XLIBCFILES) $(XLIBXCFILES)
|
||||||
|
CFILES_CAIRO = $(XLIBCFILES)
|
||||||
CFILES_XFT = $(XLIBCFILES)
|
CFILES_XFT = $(XLIBCFILES)
|
||||||
|
|
||||||
CFILES_WAYLAND = $(WLCFILES)
|
CFILES_WAYLAND = $(WLCFILES)
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
//
|
||||||
|
// Support for using Cairo to draw into X11 windows for the Fast Light Tool Kit (FLTK).
|
||||||
|
//
|
||||||
|
// Copyright 2022 by Bill Spitzak and others.
|
||||||
|
//
|
||||||
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
|
// file is missing or damaged, see the license at:
|
||||||
|
//
|
||||||
|
// https://www.fltk.org/COPYING.php
|
||||||
|
//
|
||||||
|
// Please see the following page on how to report bugs and issues:
|
||||||
|
//
|
||||||
|
// https://www.fltk.org/bugs.php
|
||||||
|
//
|
||||||
|
|
||||||
|
/* \file
|
||||||
|
Declaration of class Fl_Display_Cairo_Graphics_Driver.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FL_DISPLAY_CAIRO_GRAPHICS_DRIVER_H
|
||||||
|
# define FL_DISPLAY_CAIRO_GRAPHICS_DRIVER_H
|
||||||
|
|
||||||
|
#include "Fl_Cairo_Graphics_Driver.H"
|
||||||
|
|
||||||
|
class Fl_Display_Cairo_Graphics_Driver : public Fl_Cairo_Graphics_Driver {
|
||||||
|
private:
|
||||||
|
static void *gc_;
|
||||||
|
public:
|
||||||
|
virtual void scale(float f);
|
||||||
|
virtual float scale() {return Fl_Graphics_Driver::scale();}
|
||||||
|
virtual void gc(void *value);
|
||||||
|
virtual void* gc();
|
||||||
|
virtual void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FL_DISPLAY_CAIRO_GRAPHICS_DRIVER_H
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
//
|
||||||
|
// Support for using Cairo to draw into X11 windows for the Fast Light Tool Kit (FLTK).
|
||||||
|
//
|
||||||
|
// Copyright 2022 by Bill Spitzak and others.
|
||||||
|
//
|
||||||
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
|
// file is missing or damaged, see the license at:
|
||||||
|
//
|
||||||
|
// https://www.fltk.org/COPYING.php
|
||||||
|
//
|
||||||
|
// Please see the following page on how to report bugs and issues:
|
||||||
|
//
|
||||||
|
// https://www.fltk.org/bugs.php
|
||||||
|
//
|
||||||
|
|
||||||
|
/* \file
|
||||||
|
Implementation of class Fl_Display_Cairo_Graphics_Driver .
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Fl_Display_Cairo_Graphics_Driver.H"
|
||||||
|
#include <FL/platform.H>
|
||||||
|
#include <cairo/cairo.h>
|
||||||
|
#include <pango/pangocairo.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
void *Fl_Display_Cairo_Graphics_Driver::gc_ = NULL;
|
||||||
|
GC fl_gc;
|
||||||
|
|
||||||
|
|
||||||
|
ulong fl_xpixel(uchar r,uchar g,uchar b) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ulong fl_xpixel(Fl_Color i) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Fl_Display_Cairo_Graphics_Driver::scale(float f) {
|
||||||
|
Fl_Graphics_Driver::scale(f);
|
||||||
|
if (cairo_) {
|
||||||
|
cairo_restore(cairo_);
|
||||||
|
cairo_save(cairo_);
|
||||||
|
cairo_scale(cairo_, f, f);
|
||||||
|
cairo_translate(cairo_, 0.5, 0.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Fl_Display_Cairo_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) {
|
||||||
|
XCopyArea(fl_display, pixmap, fl_window, (GC)Fl_Graphics_Driver::default_driver().gc(), int(srcx*scale()), int(srcy*scale()), int(w*scale()), int(h*scale()), int(x*scale()), int(y*scale()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Fl_Display_Cairo_Graphics_Driver::gc(void *value) {
|
||||||
|
gc_ = value;
|
||||||
|
fl_gc = (GC)gc_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void *Fl_Display_Cairo_Graphics_Driver::gc() {
|
||||||
|
return gc_;
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Class Fl_Cocoa_Gl_Window_Driver for the Fast Light Tool Kit (FLTK).
|
// Class Fl_Cocoa_Gl_Window_Driver for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
// Copyright 2021 by Bill Spitzak and others.
|
// Copyright 2021-2022 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@@ -66,7 +66,7 @@ GLContext Fl_Cocoa_Gl_Window_Driver::create_gl_context(Fl_Window* window, const
|
|||||||
// resets the pile of string textures used to draw strings
|
// resets the pile of string textures used to draw strings
|
||||||
// necessary before the first context is created
|
// necessary before the first context is created
|
||||||
if (!shared_ctx) gl_texture_reset();
|
if (!shared_ctx) gl_texture_reset();
|
||||||
context = Fl_Cocoa_Window_Driver::create_GLcontext_for_window(((Fl_Cocoa_Gl_Choice*)g)->pixelformat, shared_ctx, window);
|
context = Fl_Cocoa_Window_Driver::create_GLcontext_for_window(((Fl_Cocoa_Gl_Choice*)g)->pixelformat, (NSOpenGLContext*)shared_ctx, window);
|
||||||
if (!context) return 0;
|
if (!context) return 0;
|
||||||
add_context(context);
|
add_context(context);
|
||||||
return (context);
|
return (context);
|
||||||
@@ -76,7 +76,7 @@ void Fl_Cocoa_Gl_Window_Driver::set_gl_context(Fl_Window* w, GLContext context)
|
|||||||
if (context != cached_context || w != cached_window) {
|
if (context != cached_context || w != cached_window) {
|
||||||
cached_context = context;
|
cached_context = context;
|
||||||
cached_window = w;
|
cached_window = w;
|
||||||
Fl_Cocoa_Window_Driver::GLcontext_makecurrent(context);
|
Fl_Cocoa_Window_Driver::GLcontext_makecurrent((NSOpenGLContext*)context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ void Fl_Cocoa_Gl_Window_Driver::delete_gl_context(GLContext context) {
|
|||||||
cached_window = 0;
|
cached_window = 0;
|
||||||
Fl_Cocoa_Window_Driver::GL_cleardrawable();
|
Fl_Cocoa_Window_Driver::GL_cleardrawable();
|
||||||
}
|
}
|
||||||
Fl_Cocoa_Window_Driver::GLcontext_release(context);
|
Fl_Cocoa_Window_Driver::GLcontext_release((NSOpenGLContext*)context);
|
||||||
del_context(context);
|
del_context(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ void Fl_Cocoa_Gl_Window_Driver::make_current_before() {
|
|||||||
if (d->changed_resolution()){
|
if (d->changed_resolution()){
|
||||||
d->changed_resolution(false);
|
d->changed_resolution(false);
|
||||||
pWindow->invalidate();
|
pWindow->invalidate();
|
||||||
Fl_Cocoa_Window_Driver::GLcontext_update(pWindow->context());
|
Fl_Cocoa_Window_Driver::GLcontext_update((NSOpenGLContext*)pWindow->context());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,13 +179,13 @@ void Fl_Cocoa_Gl_Window_Driver::swap_buffers() {
|
|||||||
glRasterPos3f(pos[0], pos[1], pos[2]); // restore original glRasterPos
|
glRasterPos3f(pos[0], pos[1], pos[2]); // restore original glRasterPos
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Fl_Cocoa_Window_Driver::flush_context(pWindow->context());//aglSwapBuffers((AGLContext)context_);
|
Fl_Cocoa_Window_Driver::flush_context((NSOpenGLContext*)pWindow->context());//aglSwapBuffers((AGLContext)context_);
|
||||||
}
|
}
|
||||||
|
|
||||||
char Fl_Cocoa_Gl_Window_Driver::swap_type() {return copy;}
|
char Fl_Cocoa_Gl_Window_Driver::swap_type() {return copy;}
|
||||||
|
|
||||||
void Fl_Cocoa_Gl_Window_Driver::resize(int is_a_resize, int w, int h) {
|
void Fl_Cocoa_Gl_Window_Driver::resize(int is_a_resize, int w, int h) {
|
||||||
Fl_Cocoa_Window_Driver::GLcontext_update(pWindow->context());
|
Fl_Cocoa_Window_Driver::GLcontext_update((NSOpenGLContext*)pWindow->context());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some old Apple hardware doesn't implement the GL_EXT_texture_rectangle extension.
|
/* Some old Apple hardware doesn't implement the GL_EXT_texture_rectangle extension.
|
||||||
@@ -202,7 +202,7 @@ char *Fl_Cocoa_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, i
|
|||||||
fl_draw(str, n, 0, fl_height() - fl_descent());
|
fl_draw(str, n, 0, fl_height() - fl_descent());
|
||||||
// get the alpha channel only of the bitmap
|
// get the alpha channel only of the bitmap
|
||||||
char *alpha_buf = new char[w*h], *r = alpha_buf, *q;
|
char *alpha_buf = new char[w*h], *r = alpha_buf, *q;
|
||||||
q = (char*)CGBitmapContextGetData(surf->offscreen());
|
q = (char*)CGBitmapContextGetData((CGContextRef)surf->offscreen());
|
||||||
for (int i = 0; i < h; i++) {
|
for (int i = 0; i < h; i++) {
|
||||||
for (int j = 0; j < w; j++) {
|
for (int j = 0; j < w; j++) {
|
||||||
*r++ = *(q+3);
|
*r++ = *(q+3);
|
||||||
@@ -215,7 +215,7 @@ char *Fl_Cocoa_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Cocoa_Gl_Window_Driver::gl_start() {
|
void Fl_Cocoa_Gl_Window_Driver::gl_start() {
|
||||||
Fl_Cocoa_Window_Driver::gl_start(gl_start_context);
|
Fl_Cocoa_Window_Driver::gl_start((NSOpenGLContext*)gl_start_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert BGRA to RGB and also exchange top and bottom
|
// convert BGRA to RGB and also exchange top and bottom
|
||||||
@@ -247,8 +247,8 @@ Fl_RGB_Image* Fl_Cocoa_Gl_Window_Driver::capture_gl_rectangle(int x, int y, int
|
|||||||
if (factor != 1) {
|
if (factor != 1) {
|
||||||
w *= factor; h *= factor; x *= factor; y *= factor;
|
w *= factor; h *= factor; x *= factor; y *= factor;
|
||||||
}
|
}
|
||||||
Fl_Cocoa_Window_Driver::GLcontext_makecurrent(glw->context());
|
Fl_Cocoa_Window_Driver::GLcontext_makecurrent((NSOpenGLContext*)glw->context());
|
||||||
Fl_Cocoa_Window_Driver::flush_context(glw->context()); // to capture also the overlay and for directGL demo
|
Fl_Cocoa_Window_Driver::flush_context((NSOpenGLContext*)glw->context()); // to capture also the overlay and for directGL demo
|
||||||
// Read OpenGL context pixels directly.
|
// Read OpenGL context pixels directly.
|
||||||
// For extra safety, save & restore OpenGL states that are changed
|
// For extra safety, save & restore OpenGL states that are changed
|
||||||
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
|
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
|
||||||
@@ -266,10 +266,16 @@ Fl_RGB_Image* Fl_Cocoa_Gl_Window_Driver::capture_gl_rectangle(int x, int y, int
|
|||||||
baseAddress = convert_BGRA_to_RGB(baseAddress, w, h, mByteWidth);
|
baseAddress = convert_BGRA_to_RGB(baseAddress, w, h, mByteWidth);
|
||||||
Fl_RGB_Image *img = new Fl_RGB_Image(baseAddress, w, h, 3, 3 * w);
|
Fl_RGB_Image *img = new Fl_RGB_Image(baseAddress, w, h, 3, 3 * w);
|
||||||
img->alloc_array = 1;
|
img->alloc_array = 1;
|
||||||
Fl_Cocoa_Window_Driver::flush_context(glw->context());
|
Fl_Cocoa_Window_Driver::flush_context((NSOpenGLContext*)glw->context());
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FL_EXPORT NSOpenGLContext *fl_mac_glcontext(GLContext rc) {
|
||||||
|
return (NSOpenGLContext*)rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Fl_Gl_Cocoa_Plugin : public Fl_Cocoa_Plugin {
|
class Fl_Gl_Cocoa_Plugin : public Fl_Cocoa_Plugin {
|
||||||
public:
|
public:
|
||||||
Fl_Gl_Cocoa_Plugin() : Fl_Cocoa_Plugin(name()) { }
|
Fl_Gl_Cocoa_Plugin() : Fl_Cocoa_Plugin(name()) { }
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ int Fl_Cocoa_Printer_Driver::begin_page (void)
|
|||||||
CGContextSaveGState(gc);
|
CGContextSaveGState(gc);
|
||||||
CGContextSaveGState(gc);
|
CGContextSaveGState(gc);
|
||||||
fl_line_style(FL_SOLID);
|
fl_line_style(FL_SOLID);
|
||||||
fl_window = (Window)1; // TODO: something better
|
fl_window = (FLWindow*)1; // TODO: something better
|
||||||
fl_clip_region(0);
|
fl_clip_region(0);
|
||||||
return status != noErr;
|
return status != noErr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ void Fl_Cocoa_Screen_Driver::grab(Fl_Window* win)
|
|||||||
{
|
{
|
||||||
if (win) {
|
if (win) {
|
||||||
if (!Fl::grab_) {
|
if (!Fl::grab_) {
|
||||||
fl_capture = Fl_X::i(Fl::first_window())->xid;
|
fl_capture = (FLWindow*)(Fl_X::i(Fl::first_window())->xid);
|
||||||
Fl_Cocoa_Window_Driver::driver(Fl::first_window())->set_key_window();
|
Fl_Cocoa_Window_Driver::driver(Fl::first_window())->set_key_window();
|
||||||
}
|
}
|
||||||
Fl::grab_ = win;
|
Fl::grab_ = win;
|
||||||
@@ -315,8 +315,8 @@ int Fl_Cocoa_Screen_Driver::input_widget_handle_key(int key, unsigned mods, unsi
|
|||||||
|
|
||||||
void Fl_Cocoa_Screen_Driver::offscreen_size(Fl_Offscreen off, int &width, int &height)
|
void Fl_Cocoa_Screen_Driver::offscreen_size(Fl_Offscreen off, int &width, int &height)
|
||||||
{
|
{
|
||||||
width = CGBitmapContextGetWidth(off);
|
width = CGBitmapContextGetWidth((CGContextRef)off);
|
||||||
height = CGBitmapContextGetHeight(off);
|
height = CGBitmapContextGetHeight((CGContextRef)off);
|
||||||
}
|
}
|
||||||
|
|
||||||
Fl_RGB_Image *Fl_Cocoa_Screen_Driver::read_win_rectangle(int X, int Y, int w, int h, Fl_Window *window,
|
Fl_RGB_Image *Fl_Cocoa_Screen_Driver::read_win_rectangle(int X, int Y, int w, int h, Fl_Window *window,
|
||||||
|
|||||||
@@ -224,10 +224,10 @@ void Fl_Cocoa_Window_Driver::hide() {
|
|||||||
if (ip && !parent()) pWindow->cursor(FL_CURSOR_DEFAULT);
|
if (ip && !parent()) pWindow->cursor(FL_CURSOR_DEFAULT);
|
||||||
if ( hide_common() ) return;
|
if ( hide_common() ) return;
|
||||||
q_release_context(this);
|
q_release_context(this);
|
||||||
if ( ip->xid == fl_window )
|
if ( ip->xid == (fl_uintptr_t)fl_window )
|
||||||
fl_window = 0;
|
fl_window = 0;
|
||||||
if (ip->region) Fl_Graphics_Driver::default_driver().XDestroyRegion(ip->region);
|
if (ip->region) Fl_Graphics_Driver::default_driver().XDestroyRegion(ip->region);
|
||||||
destroy(ip->xid);
|
destroy((FLWindow*)ip->xid);
|
||||||
delete subRect();
|
delete subRect();
|
||||||
delete ip;
|
delete ip;
|
||||||
}
|
}
|
||||||
@@ -338,3 +338,13 @@ int Fl_Cocoa_Window_Driver::screen_num() {
|
|||||||
if (pWindow->parent()) return pWindow->top_window()->screen_num();
|
if (pWindow->parent()) return pWindow->top_window()->screen_num();
|
||||||
else return screen_num_;
|
else return screen_num_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FLWindow *fl_mac_xid(const Fl_Window *win) {
|
||||||
|
return (FLWindow*)Fl_Window_Driver::xid(win);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Fl_Window *fl_mac_find(FLWindow *xid) {
|
||||||
|
return Fl_Window_Driver::find((fl_uintptr_t)xid);
|
||||||
|
}
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ Fl_Darwin_System_Driver::Fl_Darwin_System_Driver() : Fl_Posix_System_Driver() {
|
|||||||
// initialize key table
|
// initialize key table
|
||||||
key_table = darwin_key_table;
|
key_table = darwin_key_table;
|
||||||
key_table_size = sizeof(darwin_key_table)/sizeof(*darwin_key_table);
|
key_table_size = sizeof(darwin_key_table)/sizeof(*darwin_key_table);
|
||||||
|
command_key = FL_META;
|
||||||
|
control_key = FL_CTRL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Fl_Darwin_System_Driver::single_arg(const char *arg) {
|
int Fl_Darwin_System_Driver::single_arg(const char *arg) {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ Fl_GDI_Copy_Surface_Driver::~Fl_GDI_Copy_Surface_Driver() {
|
|||||||
fl_color(FL_WHITE); // draw white background
|
fl_color(FL_WHITE); // draw white background
|
||||||
fl_rectf(0, 0, W, H);
|
fl_rectf(0, 0, W, H);
|
||||||
PlayEnhMetaFile((HDC)surf->driver()->gc(), hmf, &rect); // draw metafile to offscreen buffer
|
PlayEnhMetaFile((HDC)surf->driver()->gc(), hmf, &rect); // draw metafile to offscreen buffer
|
||||||
SetClipboardData(CF_BITMAP, surf->offscreen());
|
SetClipboardData(CF_BITMAP, (HBITMAP)surf->offscreen());
|
||||||
Fl_Surface_Device::pop_current();
|
Fl_Surface_Device::pop_current();
|
||||||
delete surf;
|
delete surf;
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ Fl_GDI_Copy_Surface_Driver::~Fl_GDI_Copy_Surface_Driver() {
|
|||||||
|
|
||||||
void Fl_GDI_Copy_Surface_Driver::set_current() {
|
void Fl_GDI_Copy_Surface_Driver::set_current() {
|
||||||
driver()->gc(gc);
|
driver()->gc(gc);
|
||||||
fl_window = (Window)1;
|
fl_window = (HWND)1;
|
||||||
Fl_Surface_Device::set_current();
|
Fl_Surface_Device::set_current();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user