mirror of
https://github.com/glfw/glfw.git
synced 2025-07-12 18:50:04 +00:00
Compare commits
3 Commits
03dcd8a251
...
edf77065db
Author | SHA1 | Date | |
---|---|---|---|
|
edf77065db | ||
|
d11cb3779b | ||
|
11d96a4ab4 |
@ -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
|
||||
|
@ -153,17 +153,31 @@ the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and
|
||||
`GLFW_FALSE`. This is ignored on other platforms.
|
||||
|
||||
|
||||
#### Windows specific init hints {#init_hints_windows}
|
||||
|
||||
@anchor GLFW_WIN32_MESSAGES_IN_FIBER_hint
|
||||
__GLFW_WIN32_MESSAGES_IN_FIBER__ specifies whether to use separate fiber for
|
||||
processing Windows message, and not the main thread. This allows to unblock
|
||||
window move and resize operations, and application can do updates and rendering
|
||||
in its main loop. __Warning__ - setting this hint is not safe for environments
|
||||
or frameworks where stack inspection is required (for example, moving garbage
|
||||
collected languages such as Java or C#). Set this with @ref glfwInitHint.
|
||||
|
||||
|
||||
#### Supported and default values {#init_hints_values}
|
||||
|
||||
Initialization hint | Default value | Supported values
|
||||
-------------------------------- | ------------------------------- | ----------------
|
||||
@ref GLFW_PLATFORM | `GLFW_ANY_PLATFORM` | `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`
|
||||
@ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||
@ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL`
|
||||
@ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||
@ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||
@ref GLFW_WAYLAND_LIBDECOR | `GLFW_WAYLAND_PREFER_LIBDECOR` | `GLFW_WAYLAND_PREFER_LIBDECOR` or `GLFW_WAYLAND_DISABLE_LIBDECOR`
|
||||
@ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||
Initialization hint | Default value | Supported values
|
||||
--------------------------------- | ------------------------------- | ----------------
|
||||
|
||||
--------------------------------- | ------------------------------- | ----------------
|
||||
@ref GLFW_PLATFORM | `GLFW_ANY_PLATFORM` | `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`
|
||||
@ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||
@ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL`
|
||||
@ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||
@ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||
@ref GLFW_WAYLAND_LIBDECOR | `GLFW_WAYLAND_PREFER_LIBDECOR` | `GLFW_WAYLAND_PREFER_LIBDECOR` or `GLFW_WAYLAND_DISABLE_LIBDECOR`
|
||||
@ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||
@ref GLFW_WIN32_MESSAGES_IN_FIBER | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||
|
||||
|
||||
### Runtime platform selection {#platform}
|
||||
|
@ -20,6 +20,12 @@ this.
|
||||
|
||||
## 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.
|
||||
|
@ -1328,6 +1328,11 @@ extern "C" {
|
||||
* Wayland specific [init hint](@ref GLFW_WAYLAND_LIBDECOR_hint).
|
||||
*/
|
||||
#define GLFW_WAYLAND_LIBDECOR 0x00053001
|
||||
/*! @brief Windows specific init hint.
|
||||
*
|
||||
* Windows specific [init hint](@ref GLFW_WIN32_MESSAGES_IN_FIBER_hint).
|
||||
*/
|
||||
#define GLFW_WIN32_MESSAGES_IN_FIBER 0x00054001
|
||||
/*! @} */
|
||||
|
||||
/*! @addtogroup init
|
||||
@ -1604,6 +1609,10 @@ typedef void (* GLFWerrorfun)(int error_code, const char* description);
|
||||
* @param[in] ypos The new y-coordinate, in screen coordinates, of the
|
||||
* upper-left corner of the content area of the window.
|
||||
*
|
||||
* @remark @win32 On Windows moving or resizing of window will block event
|
||||
* processing. Workaround for this is @ref GLFW_WIN32_MESSAGES_IN_FIBER init
|
||||
* hint.
|
||||
*
|
||||
* @sa @ref window_pos
|
||||
* @sa @ref glfwSetWindowPosCallback
|
||||
*
|
||||
@ -1625,6 +1634,10 @@ typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos);
|
||||
* @param[in] width The new width, in screen coordinates, of the window.
|
||||
* @param[in] height The new height, in screen coordinates, of the window.
|
||||
*
|
||||
* @remark @win32 On Windows moving or resizing of window will block event
|
||||
* processing. Workaround for this is @ref GLFW_WIN32_MESSAGES_IN_FIBER init
|
||||
* hint.
|
||||
*
|
||||
* @sa @ref window_size
|
||||
* @sa @ref glfwSetWindowSizeCallback
|
||||
*
|
||||
|
@ -66,6 +66,10 @@ static _GLFWinitconfig _glfwInitHints =
|
||||
{
|
||||
.libdecorMode = GLFW_WAYLAND_PREFER_LIBDECOR
|
||||
},
|
||||
.win32 =
|
||||
{
|
||||
.msgInFiber = GLFW_FALSE,
|
||||
}
|
||||
};
|
||||
|
||||
// The allocation function used when no custom allocator is set
|
||||
@ -462,6 +466,9 @@ GLFWAPI void glfwInitHint(int hint, int value)
|
||||
case GLFW_WAYLAND_LIBDECOR:
|
||||
_glfwInitHints.wl.libdecorMode = value;
|
||||
return;
|
||||
case GLFW_WIN32_MESSAGES_IN_FIBER:
|
||||
_glfwInitHints.win32.msgInFiber = value;
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwInputError(GLFW_INVALID_ENUM,
|
||||
|
@ -388,6 +388,9 @@ struct _GLFWinitconfig
|
||||
struct {
|
||||
int libdecorMode;
|
||||
} wl;
|
||||
struct {
|
||||
GLFWbool msgInFiber;
|
||||
} win32;
|
||||
};
|
||||
|
||||
// Window configuration
|
||||
|
@ -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)
|
||||
@ -370,7 +366,6 @@ static LRESULT CALLBACK helperWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
|
||||
//
|
||||
static GLFWbool createHelperWindow(void)
|
||||
{
|
||||
MSG msg;
|
||||
WNDCLASSEXW wc = { sizeof(wc) };
|
||||
|
||||
wc.style = CS_OWNDC;
|
||||
@ -421,10 +416,18 @@ static GLFWbool createHelperWindow(void)
|
||||
DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
}
|
||||
|
||||
while (PeekMessageW(&msg, _glfw.win32.helperWindowHandle, 0, 0, PM_REMOVE))
|
||||
if (_glfw.hints.init.win32.msgInFiber)
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
SwitchToFiber(_glfw.win32.messageFiber);
|
||||
}
|
||||
else
|
||||
{
|
||||
MSG msg;
|
||||
while (PeekMessageW(&msg, _glfw.win32.helperWindowHandle, 0, 0, PM_REMOVE))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
return GLFW_TRUE;
|
||||
@ -598,6 +601,45 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
|
||||
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
|
||||
}
|
||||
|
||||
void _glfwPollMessageLoopWin32(void)
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
MSG msg;
|
||||
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
if (msg.message == WM_QUIT)
|
||||
{
|
||||
// NOTE: While GLFW does not itself post WM_QUIT, other processes
|
||||
// may post it to this one, for example Task Manager
|
||||
// HACK: Treat WM_QUIT as a close on all windows
|
||||
|
||||
window = _glfw.windowListHead;
|
||||
while (window)
|
||||
{
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
window = window->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Windows message dispatch fiber
|
||||
void CALLBACK messageFiberProc(LPVOID lpFiberParameter)
|
||||
{
|
||||
(void)lpFiberParameter;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
_glfwPollMessageLoopWin32();
|
||||
SwitchToFiber(_glfw.win32.mainFiber);
|
||||
}
|
||||
}
|
||||
|
||||
GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
|
||||
{
|
||||
const _GLFWplatform win32 =
|
||||
@ -692,9 +734,20 @@ 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 (_glfw.hints.init.win32.msgInFiber)
|
||||
{
|
||||
_glfw.win32.mainFiber = ConvertThreadToFiber(NULL);
|
||||
if (!_glfw.win32.mainFiber)
|
||||
return GLFW_FALSE;
|
||||
|
||||
_glfw.win32.messageFiber = CreateFiber(0, &messageFiberProc, NULL);
|
||||
if (!_glfw.win32.messageFiber)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
if (!createHelperWindow())
|
||||
return GLFW_FALSE;
|
||||
|
||||
@ -717,6 +770,12 @@ void _glfwTerminateWin32(void)
|
||||
if (_glfw.win32.mainWindowClass)
|
||||
UnregisterClassW(MAKEINTATOM(_glfw.win32.mainWindowClass), _glfw.win32.instance);
|
||||
|
||||
if (_glfw.hints.init.win32.msgInFiber)
|
||||
{
|
||||
DeleteFiber(_glfw.win32.messageFiber);
|
||||
ConvertFiberToThread();
|
||||
}
|
||||
|
||||
_glfw_free(_glfw.win32.clipboardString);
|
||||
_glfw_free(_glfw.win32.rawInput);
|
||||
|
||||
|
@ -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_
|
||||
@ -418,6 +375,11 @@ typedef struct _GLFWwindowWin32
|
||||
int lastCursorPosX, lastCursorPosY;
|
||||
// The last received high surrogate when decoding pairs of UTF-16 messages
|
||||
WCHAR highSurrogate;
|
||||
|
||||
// If user pressed mouse button on window title bar
|
||||
UINT ncMouseButton;
|
||||
LPARAM ncMousePos;
|
||||
|
||||
} _GLFWwindowWin32;
|
||||
|
||||
// Win32-specific global data
|
||||
@ -446,6 +408,9 @@ typedef struct _GLFWlibraryWin32
|
||||
// The cursor handle to use to hide the cursor (NULL or a transparent cursor)
|
||||
HCURSOR blankCursor;
|
||||
|
||||
LPVOID messageFiber;
|
||||
LPVOID mainFiber;
|
||||
|
||||
struct {
|
||||
HINSTANCE instance;
|
||||
PFN_DirectInput8Create Create;
|
||||
@ -460,8 +425,6 @@ typedef struct _GLFWlibraryWin32
|
||||
|
||||
struct {
|
||||
HINSTANCE instance;
|
||||
PFN_SetProcessDPIAware SetProcessDPIAware_;
|
||||
PFN_ChangeWindowMessageFilterEx ChangeWindowMessageFilterEx_;
|
||||
PFN_EnableNonClientDpiScaling EnableNonClientDpiScaling_;
|
||||
PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
|
||||
PFN_GetDpiForWindow GetDpiForWindow_;
|
||||
@ -564,6 +527,7 @@ void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity);
|
||||
void _glfwSetRawMouseMotionWin32(_GLFWwindow *window, GLFWbool enabled);
|
||||
GLFWbool _glfwRawMouseMotionSupportedWin32(void);
|
||||
|
||||
void _glfwPollMessageLoopWin32(void);
|
||||
void _glfwPollEventsWin32(void);
|
||||
void _glfwWaitEventsWin32(void);
|
||||
void _glfwWaitEventsTimeoutWin32(double timeout);
|
||||
|
@ -374,9 +374,6 @@ static void updateFramebufferTransparency(const _GLFWwindow* window)
|
||||
BOOL composition, opaque;
|
||||
DWORD color;
|
||||
|
||||
if (!IsWindowsVistaOrGreater())
|
||||
return;
|
||||
|
||||
if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
|
||||
return;
|
||||
|
||||
@ -856,11 +853,46 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||
return 0;
|
||||
}
|
||||
|
||||
case WM_NCLBUTTONDOWN:
|
||||
{
|
||||
if (wParam == HTCAPTION)
|
||||
{
|
||||
window->win32.ncMouseButton = uMsg;
|
||||
window->win32.ncMousePos = lParam;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_NCMOUSEMOVE:
|
||||
{
|
||||
if (window->win32.ncMouseButton)
|
||||
{
|
||||
if (GET_X_LPARAM(window->win32.ncMousePos) != GET_X_LPARAM(lParam) ||
|
||||
GET_Y_LPARAM(window->win32.ncMousePos) != GET_Y_LPARAM(lParam))
|
||||
{
|
||||
DefWindowProcW(hWnd, window->win32.ncMouseButton, HTCAPTION, window->win32.ncMousePos);
|
||||
window->win32.ncMouseButton = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
const int x = GET_X_LPARAM(lParam);
|
||||
const int y = GET_Y_LPARAM(lParam);
|
||||
|
||||
if (window->win32.ncMouseButton)
|
||||
{
|
||||
if (GET_X_LPARAM(window->win32.ncMousePos) != x ||
|
||||
GET_Y_LPARAM(window->win32.ncMousePos) != y)
|
||||
{
|
||||
DefWindowProcW(hWnd, window->win32.ncMouseButton, HTCAPTION, window->win32.ncMousePos);
|
||||
window->win32.ncMouseButton = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!window->win32.cursorTracked)
|
||||
{
|
||||
TRACKMOUSEEVENT tme;
|
||||
@ -983,7 +1015,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;
|
||||
@ -1002,6 +1033,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||
releaseCursor();
|
||||
|
||||
if (_glfw.hints.init.win32.msgInFiber)
|
||||
SetTimer(hWnd, 1, 1, NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1018,6 +1051,15 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||
captureCursor(window);
|
||||
|
||||
if (_glfw.hints.init.win32.msgInFiber)
|
||||
KillTimer(hWnd, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_TIMER:
|
||||
{
|
||||
if (_glfw.hints.init.win32.msgInFiber && wParam == 1)
|
||||
SwitchToFiber(_glfw.win32.mainFiber);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1407,15 +1449,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 +2017,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;
|
||||
|
||||
@ -2101,31 +2134,13 @@ GLFWbool _glfwRawMouseMotionSupportedWin32(void)
|
||||
|
||||
void _glfwPollEventsWin32(void)
|
||||
{
|
||||
MSG msg;
|
||||
HWND handle;
|
||||
_GLFWwindow* window;
|
||||
|
||||
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
if (msg.message == WM_QUIT)
|
||||
{
|
||||
// NOTE: While GLFW does not itself post WM_QUIT, other processes
|
||||
// may post it to this one, for example Task Manager
|
||||
// HACK: Treat WM_QUIT as a close on all windows
|
||||
|
||||
window = _glfw.windowListHead;
|
||||
while (window)
|
||||
{
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
window = window->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
}
|
||||
if (_glfw.hints.init.win32.msgInFiber)
|
||||
SwitchToFiber(_glfw.win32.messageFiber);
|
||||
else
|
||||
_glfwPollMessageLoopWin32();
|
||||
|
||||
// HACK: Release modifier keys that the system did not emit KEYUP for
|
||||
// NOTE: Shift keys on Windows tend to "stick" when both are pressed as
|
||||
|
Loading…
Reference in New Issue
Block a user