mirror of
https://github.com/glfw/glfw.git
synced 2025-12-19 21:51:56 +00:00
Compare commits
6 Commits
4ed42912b3
...
d2935d5d4d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2935d5d4d | ||
|
|
d11cb3779b | ||
|
|
06f21df20e | ||
|
|
c31de75111 | ||
|
|
f269a6af97 | ||
|
|
f1f869acf7 |
@ -295,6 +295,7 @@ video tutorials.
|
||||
- Jonas Ådahl
|
||||
- Lasse Öörni
|
||||
- Leonard König
|
||||
- Alex Sanchez-Stern
|
||||
- All the unmentioned and anonymous contributors in the GLFW community, for bug
|
||||
reports, patches, feedback, testing and encouragement
|
||||
|
||||
|
||||
10
README.md
10
README.md
@ -79,7 +79,7 @@ more information.
|
||||
|
||||
## System requirements
|
||||
|
||||
GLFW supports Windows XP and later and macOS 10.11 and later. Linux and other
|
||||
GLFW supports Windows 7 and later and macOS 10.11 and later. Linux and other
|
||||
Unix-like systems running the X Window System are supported even without
|
||||
a desktop environment or modern extensions, although some features require
|
||||
a running window or clipboard manager. The OSMesa backend requires Mesa 6.3.
|
||||
@ -125,6 +125,7 @@ information on what to include when reporting a bug.
|
||||
the limit of the mouse button tokens to be reported (#2423)
|
||||
- Updated minimum CMake version to 3.16 (#2541)
|
||||
- Removed support for building with original MinGW (#2540)
|
||||
- [Win32] Removed support for Windows XP and Vista (#2505)
|
||||
- [Cocoa] Added `QuartzCore` framework as link-time dependency
|
||||
- [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506)
|
||||
- [Wayland] Bugfix: The fractional scaling related objects were not destroyed
|
||||
@ -136,7 +137,11 @@ information on what to include when reporting a bug.
|
||||
- [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`
|
||||
- [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to
|
||||
`GLFW_NATIVE_CONTEXT_API` (#2518)
|
||||
|
||||
- [X11] Added `getSelectionRequestHandler`, `setSelectionRequestHander`,
|
||||
`getGLFWDisplay`, and `getGLFWHelperWindow` functions. to allow
|
||||
clients to implement more X clipboard functionality than is
|
||||
built-in; with these primitives clients can add copy paste support
|
||||
for files, images, colors, and other non-text data types.
|
||||
|
||||
## Contact
|
||||
|
||||
@ -152,4 +157,3 @@ request, please file it in the
|
||||
|
||||
Finally, if you're interested in helping out with the development of GLFW or
|
||||
porting it to your favorite platform, join us on the forum or GitHub.
|
||||
|
||||
|
||||
@ -973,6 +973,53 @@ The contents of the system clipboard can be set to a UTF-8 encoded string with
|
||||
glfwSetClipboardString(NULL, "A string with words in it");
|
||||
```
|
||||
|
||||
\par Advanced Usage
|
||||
While GLFW does not directly support using other data types with the
|
||||
system clipboard, on many platforms this is possible using platform
|
||||
specific code. If you are primarily targetting a small set of
|
||||
platforms, this may be viable for your application.
|
||||
|
||||
\par
|
||||
On Windows, you can do clipboard operations directly using <a
|
||||
href="https://learn.microsoft.com/en-us/windows/win32/api/winuser/">winuser.h</a>,
|
||||
allowing you to copy and paste datatypes other than text. On X11 you
|
||||
can also use the platform specific API to get this functionality, but
|
||||
you must hook into GLFW's X11 event handling code to allow copying
|
||||
<i>out</i> of your application. Example code for most of this functionality
|
||||
can be found in general X11 documentation like <a
|
||||
href="http://www.uninformativ.de/blog/postings/2017-04-02/0/POSTING-en.html">this
|
||||
page</a>; the GLFW-specific part is including
|
||||
|
||||
\par
|
||||
@code
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <X11/Xlib.h>
|
||||
#define GLFW_EXPOSE_NATIVE_X11
|
||||
#include <GLFW/glfw3native.h>
|
||||
@endcode
|
||||
|
||||
\par
|
||||
At the top of your file (guarded by platform), and then running
|
||||
|
||||
\par
|
||||
@code
|
||||
setSelectionRequestHandler(myHandler);
|
||||
@endcode
|
||||
|
||||
\par
|
||||
on initialization. Your selection handler must have the signature:
|
||||
|
||||
\par
|
||||
@code
|
||||
void myHandler(XEvent*);
|
||||
@endcode
|
||||
|
||||
\par
|
||||
and it will receive all X Selection events. To ensure compatibility
|
||||
use `getGLFWDisplay()` to get a display object instead of
|
||||
`XOpenDisplay()` and use the result of `getGLFWHelperWindow()` as the
|
||||
target window for the selection.
|
||||
|
||||
|
||||
## Path drop input {#path_drop}
|
||||
|
||||
|
||||
31
docs/news.md
31
docs/news.md
@ -14,12 +14,37 @@ values over 8. For compatibility with older versions, the
|
||||
@ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode needs to be set to make use of
|
||||
this.
|
||||
|
||||
|
||||
### Support for custom X11 clipboard functionality {#x11_custom_selection}
|
||||
|
||||
This change allows clients to implement custom X11 clipboard
|
||||
functionality like the copying and pasting of files across
|
||||
applications.
|
||||
|
||||
GLFW itself only allows plain text to be copied to the
|
||||
clipboard and back on all platforms. On some platforms, like Windows,
|
||||
you can use platform specific APIs to add extra clipboard
|
||||
functionality like copying of other data types. However, on X11, this
|
||||
was previously not fully possible due to the fact that GLFW internal
|
||||
code has full control over the X11 event queue.
|
||||
|
||||
This change exposes several new symbols that allow you to get and set
|
||||
the handler for X11 selection events that GLFW will use. It also
|
||||
allows getting the internal display connection and selection helper
|
||||
window, for use in that kind of code.
|
||||
|
||||
## Caveats {#caveats}
|
||||
|
||||
## Deprecations {#deprecations}
|
||||
|
||||
## Removals {#removals}
|
||||
|
||||
### Windows XP and Vista support has been removed {#winxp_vista}
|
||||
|
||||
Support for Windows XP and Vista has been removed. Windows XP has been out of extended
|
||||
support since 2014.
|
||||
|
||||
|
||||
### Original MinGW support has been removed {#original_mingw}
|
||||
|
||||
Support for the now unmaintained original MinGW distribution has been removed.
|
||||
@ -33,6 +58,12 @@ actively maintained and available on many platforms.
|
||||
|
||||
### New functions {#new_functions}
|
||||
|
||||
#### X11-specific
|
||||
- @ref getSelectionRequestHandler
|
||||
- @ref setSelectionRequestHanddler
|
||||
- @ref getGLFWDisplay
|
||||
- @ref getGLFWHelperWindow
|
||||
|
||||
### New types {#new_types}
|
||||
|
||||
### New constants {#new_constants}
|
||||
|
||||
@ -442,6 +442,13 @@ GLFWAPI void glfwSetX11SelectionString(const char* string);
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI const char* glfwGetX11SelectionString(void);
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
void (*getSelectionRequestHandler(void))(XEvent*);
|
||||
void setSelectionRequestHandler(void (*handler)(XEvent*));
|
||||
Display* getGLFWDisplay(void);
|
||||
Window getGLFWHelperWindow(void);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
||||
|
||||
@ -327,8 +327,8 @@ static void swapBuffersWGL(_GLFWwindow* window)
|
||||
{
|
||||
if (!window->monitor)
|
||||
{
|
||||
// HACK: Use DwmFlush when desktop composition is enabled on Windows Vista and 7
|
||||
if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater())
|
||||
// HACK: Use DwmFlush when desktop composition is enabled on Windows 7
|
||||
if (!IsWindows8OrGreater())
|
||||
{
|
||||
BOOL enabled = FALSE;
|
||||
|
||||
@ -353,9 +353,9 @@ static void swapIntervalWGL(int interval)
|
||||
|
||||
if (!window->monitor)
|
||||
{
|
||||
// HACK: Disable WGL swap interval when desktop composition is enabled on Windows
|
||||
// Vista and 7 to avoid interfering with DWM vsync
|
||||
if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater())
|
||||
// HACK: Disable WGL swap interval when desktop composition is enabled on
|
||||
// Windows 7 to avoid interfering with DWM vsync
|
||||
if (!IsWindows8OrGreater())
|
||||
{
|
||||
BOOL enabled = FALSE;
|
||||
|
||||
|
||||
@ -89,10 +89,6 @@ static GLFWbool loadLibraries(void)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
_glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDPIAware");
|
||||
_glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
|
||||
_glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
|
||||
_glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext)
|
||||
@ -692,7 +688,7 @@ int _glfwInitWin32(void)
|
||||
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
else if (IsWindows8Point1OrGreater())
|
||||
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
|
||||
else if (IsWindowsVistaOrGreater())
|
||||
else
|
||||
SetProcessDPIAware();
|
||||
|
||||
if (!createHelperWindow())
|
||||
|
||||
@ -48,14 +48,14 @@
|
||||
#define UNICODE
|
||||
#endif
|
||||
|
||||
// GLFW requires Windows XP or later
|
||||
#if WINVER < 0x0501
|
||||
// GLFW requires Windows 7 or later
|
||||
#if WINVER < 0x0601
|
||||
#undef WINVER
|
||||
#define WINVER 0x0501
|
||||
#define WINVER 0x0601
|
||||
#endif
|
||||
#if _WIN32_WINNT < 0x0501
|
||||
#if _WIN32_WINNT < 0x0601
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#define _WIN32_WINNT 0x0601
|
||||
#endif
|
||||
|
||||
// GLFW uses DirectInput8 interfaces
|
||||
@ -66,20 +66,12 @@
|
||||
|
||||
#include <wctype.h>
|
||||
#include <windows.h>
|
||||
#include <dwmapi.h>
|
||||
#include <dinput.h>
|
||||
#include <xinput.h>
|
||||
#include <dbt.h>
|
||||
|
||||
// HACK: Define macros that some windows.h variants don't
|
||||
#ifndef WM_MOUSEHWHEEL
|
||||
#define WM_MOUSEHWHEEL 0x020E
|
||||
#endif
|
||||
#ifndef WM_DWMCOMPOSITIONCHANGED
|
||||
#define WM_DWMCOMPOSITIONCHANGED 0x031E
|
||||
#endif
|
||||
#ifndef WM_DWMCOLORIZATIONCOLORCHANGED
|
||||
#define WM_DWMCOLORIZATIONCOLORCHANGED 0x0320
|
||||
#endif
|
||||
#ifndef WM_COPYGLOBALDATA
|
||||
#define WM_COPYGLOBALDATA 0x0049
|
||||
#endif
|
||||
@ -102,31 +94,6 @@
|
||||
#define USER_DEFAULT_SCREEN_DPI 96
|
||||
#endif
|
||||
|
||||
#if WINVER < 0x0601
|
||||
typedef struct
|
||||
{
|
||||
DWORD cbSize;
|
||||
DWORD ExtStatus;
|
||||
} CHANGEFILTERSTRUCT;
|
||||
#ifndef MSGFLT_ALLOW
|
||||
#define MSGFLT_ALLOW 1
|
||||
#endif
|
||||
#endif /*Windows 7*/
|
||||
|
||||
#if WINVER < 0x0600
|
||||
#define DWM_BB_ENABLE 0x00000001
|
||||
#define DWM_BB_BLURREGION 0x00000002
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwFlags;
|
||||
BOOL fEnable;
|
||||
HRGN hRgnBlur;
|
||||
BOOL fTransitionOnMaximized;
|
||||
} DWM_BLURBEHIND;
|
||||
#else
|
||||
#include <dwmapi.h>
|
||||
#endif /*Windows Vista*/
|
||||
|
||||
#ifndef DPI_ENUMS_DECLARED
|
||||
typedef enum
|
||||
{
|
||||
@ -150,12 +117,6 @@ typedef enum
|
||||
// Replacement for versionhelpers.h macros, as we cannot rely on the
|
||||
// application having a correct embedded manifest
|
||||
//
|
||||
#define IsWindowsVistaOrGreater() \
|
||||
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \
|
||||
LOBYTE(_WIN32_WINNT_VISTA), 0)
|
||||
#define IsWindows7OrGreater() \
|
||||
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN7), \
|
||||
LOBYTE(_WIN32_WINNT_WIN7), 0)
|
||||
#define IsWindows8OrGreater() \
|
||||
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8), \
|
||||
LOBYTE(_WIN32_WINNT_WIN8), 0)
|
||||
@ -266,15 +227,11 @@ typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID*
|
||||
#define DirectInput8Create _glfw.win32.dinput8.Create
|
||||
|
||||
// user32.dll function pointer typedefs
|
||||
typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void);
|
||||
typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,CHANGEFILTERSTRUCT*);
|
||||
typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND);
|
||||
typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
|
||||
typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
|
||||
typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
|
||||
typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT);
|
||||
#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
|
||||
#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
|
||||
#define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
|
||||
#define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
|
||||
#define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
|
||||
@ -460,8 +417,6 @@ typedef struct _GLFWlibraryWin32
|
||||
|
||||
struct {
|
||||
HINSTANCE instance;
|
||||
PFN_SetProcessDPIAware SetProcessDPIAware_;
|
||||
PFN_ChangeWindowMessageFilterEx ChangeWindowMessageFilterEx_;
|
||||
PFN_EnableNonClientDpiScaling EnableNonClientDpiScaling_;
|
||||
PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
|
||||
PFN_GetDpiForWindow GetDpiForWindow_;
|
||||
|
||||
@ -374,9 +374,6 @@ static void updateFramebufferTransparency(const _GLFWwindow* window)
|
||||
BOOL composition, opaque;
|
||||
DWORD color;
|
||||
|
||||
if (!IsWindowsVistaOrGreater())
|
||||
return;
|
||||
|
||||
if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
|
||||
return;
|
||||
|
||||
@ -983,7 +980,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||
|
||||
case WM_MOUSEHWHEEL:
|
||||
{
|
||||
// This message is only sent on Windows Vista and later
|
||||
// NOTE: The X-axis is inverted for consistency with macOS and X11
|
||||
_glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0);
|
||||
return 0;
|
||||
@ -1407,15 +1403,9 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||
|
||||
SetPropW(window->win32.handle, L"GLFW", window);
|
||||
|
||||
if (IsWindows7OrGreater())
|
||||
{
|
||||
ChangeWindowMessageFilterEx(window->win32.handle,
|
||||
WM_DROPFILES, MSGFLT_ALLOW, NULL);
|
||||
ChangeWindowMessageFilterEx(window->win32.handle,
|
||||
WM_COPYDATA, MSGFLT_ALLOW, NULL);
|
||||
ChangeWindowMessageFilterEx(window->win32.handle,
|
||||
WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
|
||||
}
|
||||
ChangeWindowMessageFilterEx(window->win32.handle, WM_DROPFILES, MSGFLT_ALLOW, NULL);
|
||||
ChangeWindowMessageFilterEx(window->win32.handle, WM_COPYDATA, MSGFLT_ALLOW, NULL);
|
||||
ChangeWindowMessageFilterEx(window->win32.handle, WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
|
||||
|
||||
window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
|
||||
window->win32.keymenu = wndconfig->win32.keymenu;
|
||||
@ -1981,9 +1971,6 @@ GLFWbool _glfwFramebufferTransparentWin32(_GLFWwindow* window)
|
||||
if (!window->win32.transparent)
|
||||
return GLFW_FALSE;
|
||||
|
||||
if (!IsWindowsVistaOrGreater())
|
||||
return GLFW_FALSE;
|
||||
|
||||
if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
|
||||
return GLFW_FALSE;
|
||||
|
||||
|
||||
@ -1315,6 +1315,8 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
|
||||
_glfw.x11.xlib.handle = module;
|
||||
|
||||
*platform = x11;
|
||||
|
||||
handleSelectionRequest = handleSelectionRequest_;
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -896,6 +896,8 @@ typedef struct _GLFWcursorX11
|
||||
Cursor handle;
|
||||
} _GLFWcursorX11;
|
||||
|
||||
extern void (*handleSelectionRequest)(XEvent*);
|
||||
void handleSelectionRequest_(XEvent* event);
|
||||
|
||||
GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform);
|
||||
int _glfwInitX11(void);
|
||||
|
||||
@ -921,7 +921,8 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
||||
return None;
|
||||
}
|
||||
|
||||
static void handleSelectionRequest(XEvent* event)
|
||||
void (*handleSelectionRequest)(XEvent*);
|
||||
void handleSelectionRequest_(XEvent* event)
|
||||
{
|
||||
const XSelectionRequestEvent* request = &event->xselectionrequest;
|
||||
|
||||
@ -3356,6 +3357,18 @@ GLFWAPI const char* glfwGetX11SelectionString(void)
|
||||
|
||||
return getSelectionString(_glfw.x11.PRIMARY);
|
||||
}
|
||||
void (*getSelectionRequestHandler(void))(XEvent*) {
|
||||
return handleSelectionRequest;
|
||||
}
|
||||
void setSelectionRequestHandler(void (*handler)(XEvent*)) {
|
||||
handleSelectionRequest = handler;
|
||||
}
|
||||
Display* getGLFWDisplay(void) {
|
||||
return _glfw.x11.display;
|
||||
}
|
||||
|
||||
Window getGLFWHelperWindow(void) {
|
||||
return _glfw.x11.helperWindowHandle;
|
||||
}
|
||||
|
||||
#endif // _GLFW_X11
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user