mirror of
https://github.com/glfw/glfw.git
synced 2025-12-21 22:52:07 +00:00
Compare commits
4 Commits
622229e34f
...
c959407ecd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c959407ecd | ||
|
|
63a7e8b7f8 | ||
|
|
c8bb716886 | ||
|
|
127ae123fe |
@ -55,6 +55,7 @@ video tutorials.
|
|||||||
- Jason Daly
|
- Jason Daly
|
||||||
- danhambleton
|
- danhambleton
|
||||||
- Jarrod Davis
|
- Jarrod Davis
|
||||||
|
- decce
|
||||||
- Olivier Delannoy
|
- Olivier Delannoy
|
||||||
- Paul R. Deppe
|
- Paul R. Deppe
|
||||||
- Michael Dickens
|
- Michael Dickens
|
||||||
|
|||||||
@ -255,3 +255,7 @@ hardware gamma correction, which today is typically an approximation of sRGB
|
|||||||
gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will
|
gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will
|
||||||
produce the default (usually sRGB-like) behavior.
|
produce the default (usually sRGB-like) behavior.
|
||||||
|
|
||||||
|
@note @wayland An application cannot read or modify the monitor gamma ramp. The
|
||||||
|
@ref glfwGetGammaRamp, @ref glfwSetGammaRamp and @ref glfwSetGamma functions
|
||||||
|
emit @ref GLFW_FEATURE_UNAVAILABLE.
|
||||||
|
|
||||||
|
|||||||
@ -262,6 +262,11 @@ This is the new name, introduced in GLFW 3.4. The older
|
|||||||
`GLFW_COCOA_RETINA_FRAMEBUFFER` name is also available for compatibility. Both
|
`GLFW_COCOA_RETINA_FRAMEBUFFER` name is also available for compatibility. Both
|
||||||
names modify the same hint value.
|
names modify the same hint value.
|
||||||
|
|
||||||
|
@anchor GLFW_THEME
|
||||||
|
__GLFW_THEME__ specifies whether the window should use light theme or not.
|
||||||
|
Possible values are `GLFW_THEME_AUTO`, `GLFW_THEME_DARK`, and `GLFW_THEME_LIGHT`. This hint only has effect
|
||||||
|
on windows operating system.
|
||||||
|
|
||||||
@anchor GLFW_MOUSE_PASSTHROUGH_hint
|
@anchor GLFW_MOUSE_PASSTHROUGH_hint
|
||||||
__GLFW_MOUSE_PASSTHROUGH__ specifies whether the window is transparent to mouse
|
__GLFW_MOUSE_PASSTHROUGH__ specifies whether the window is transparent to mouse
|
||||||
input, letting any mouse events pass through to whatever window is behind it.
|
input, letting any mouse events pass through to whatever window is behind it.
|
||||||
@ -893,6 +898,12 @@ int xpos, ypos;
|
|||||||
glfwGetWindowPos(window, &xpos, &ypos);
|
glfwGetWindowPos(window, &xpos, &ypos);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@note @wayland An applications cannot know the positions of its windows or
|
||||||
|
whether one has been moved. The @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y
|
||||||
|
window hints are ignored. The @ref glfwGetWindowPos and @ref glfwSetWindowPos
|
||||||
|
functions emit @ref GLFW_FEATURE_UNAVAILABLE. The window position callback will
|
||||||
|
not be called.
|
||||||
|
|
||||||
|
|
||||||
### Window title {#window_title}
|
### Window title {#window_title}
|
||||||
|
|
||||||
@ -1038,6 +1049,12 @@ You can also get the current iconification state with @ref glfwGetWindowAttrib.
|
|||||||
int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED);
|
int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@note @wayland An application cannot know if any of its windows have been
|
||||||
|
iconified or restore one from iconification. The @ref glfwRestoreWindow
|
||||||
|
function can only restore windows from maximization and the iconify callback
|
||||||
|
will not be called. The [GLFW_ICONIFIED](@ref GLFW_ICONIFIED_attrib) attribute
|
||||||
|
will be false. The @ref glfwIconifyWindow function works normally.
|
||||||
|
|
||||||
|
|
||||||
### Window maximization {#window_maximize}
|
### Window maximization {#window_maximize}
|
||||||
|
|
||||||
|
|||||||
@ -1108,6 +1108,11 @@ extern "C" {
|
|||||||
* [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) window hint for
|
* [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) window hint for
|
||||||
* compatibility with earlier versions.
|
* compatibility with earlier versions.
|
||||||
*/
|
*/
|
||||||
|
#define GLFW_THEME 0x0002200E
|
||||||
|
/*! @brief windows specific
|
||||||
|
*
|
||||||
|
* Allows specifying whether light or dark theme should be used.
|
||||||
|
*/
|
||||||
#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
|
#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
|
||||||
/*! @brief macOS specific
|
/*! @brief macOS specific
|
||||||
* [window hint](@ref GLFW_COCOA_FRAME_NAME_hint).
|
* [window hint](@ref GLFW_COCOA_FRAME_NAME_hint).
|
||||||
@ -1182,6 +1187,10 @@ extern "C" {
|
|||||||
|
|
||||||
#define GLFW_ANY_POSITION 0x80000000
|
#define GLFW_ANY_POSITION 0x80000000
|
||||||
|
|
||||||
|
#define GLFW_THEME_AUTO 0x00000000
|
||||||
|
#define GLFW_THEME_DARK 0x00000001
|
||||||
|
#define GLFW_THEME_LIGHT 0x00000002
|
||||||
|
|
||||||
/*! @defgroup shapes Standard cursor shapes
|
/*! @defgroup shapes Standard cursor shapes
|
||||||
* @brief Standard system cursor shapes.
|
* @brief Standard system cursor shapes.
|
||||||
*
|
*
|
||||||
@ -2915,8 +2924,8 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
|
|||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE,
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE,
|
||||||
* @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
* @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||||
*
|
*
|
||||||
* @remark @wayland Gamma handling is a privileged protocol, this function
|
* @remark @wayland Monitor gamma is a privileged protocol, so this function
|
||||||
* will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
|
* cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
|
||||||
*
|
*
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
@ -2939,8 +2948,8 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
|
|||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR
|
||||||
* and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
* and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||||
*
|
*
|
||||||
* @remark @wayland Gamma handling is a privileged protocol, this function
|
* @remark @wayland Monitor gamma is a privileged protocol, so this function
|
||||||
* will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while
|
* cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while
|
||||||
* returning `NULL`.
|
* returning `NULL`.
|
||||||
*
|
*
|
||||||
* @pointer_lifetime The returned structure and its arrays are allocated and
|
* @pointer_lifetime The returned structure and its arrays are allocated and
|
||||||
@ -2983,8 +2992,8 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
|
|||||||
*
|
*
|
||||||
* @remark @win32 The gamma ramp size must be 256.
|
* @remark @win32 The gamma ramp size must be 256.
|
||||||
*
|
*
|
||||||
* @remark @wayland Gamma handling is a privileged protocol, this function
|
* @remark @wayland Monitor gamma is a privileged protocol, so this function
|
||||||
* will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
|
* cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
|
||||||
*
|
*
|
||||||
* @pointer_lifetime The specified gamma ramp is copied before this function
|
* @pointer_lifetime The specified gamma ramp is copied before this function
|
||||||
* returns.
|
* returns.
|
||||||
@ -3430,8 +3439,8 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* i
|
|||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||||
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||||
*
|
*
|
||||||
* @remark @wayland There is no way for an application to retrieve the global
|
* @remark @wayland Window positions are not currently part of any common
|
||||||
* position of its windows. This function will emit @ref
|
* Wayland protocol, so this function cannot be implemented and will emit @ref
|
||||||
* GLFW_FEATURE_UNAVAILABLE.
|
* GLFW_FEATURE_UNAVAILABLE.
|
||||||
*
|
*
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
@ -3464,8 +3473,8 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
|
|||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||||
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||||
*
|
*
|
||||||
* @remark @wayland There is no way for an application to set the global
|
* @remark @wayland Window positions are not currently part of any common
|
||||||
* position of its windows. This function will emit @ref
|
* Wayland protocol, so this function cannot be implemented and will emit @ref
|
||||||
* GLFW_FEATURE_UNAVAILABLE.
|
* GLFW_FEATURE_UNAVAILABLE.
|
||||||
*
|
*
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
@ -3480,6 +3489,8 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
|
GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
|
||||||
|
|
||||||
|
GLFWAPI int glfwIsWindowLightTheme(GLFWwindow* window);
|
||||||
|
|
||||||
/*! @brief Retrieves the size of the content area of the specified window.
|
/*! @brief Retrieves the size of the content area of the specified window.
|
||||||
*
|
*
|
||||||
* This function retrieves the size, in screen coordinates, of the content area
|
* This function retrieves the size, in screen coordinates, of the content area
|
||||||
@ -3807,10 +3818,6 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
|
|||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||||
* GLFW_PLATFORM_ERROR.
|
* GLFW_PLATFORM_ERROR.
|
||||||
*
|
*
|
||||||
* @remark @wayland Once a window is iconified, @ref glfwRestoreWindow won’t
|
|
||||||
* be able to restore it. This is a design decision of the xdg-shell
|
|
||||||
* protocol.
|
|
||||||
*
|
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
* @sa @ref window_iconify
|
* @sa @ref window_iconify
|
||||||
@ -3838,6 +3845,10 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
|
|||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||||
* GLFW_PLATFORM_ERROR.
|
* GLFW_PLATFORM_ERROR.
|
||||||
*
|
*
|
||||||
|
* @remark @wayland Restoring a window from maximization is not currently part
|
||||||
|
* of any common Wayland protocol, so this function can only restore windows
|
||||||
|
* from maximization.
|
||||||
|
*
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
* @sa @ref window_iconify
|
* @sa @ref window_iconify
|
||||||
@ -4058,8 +4069,8 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
|
|||||||
* affected by any resizing or mode switching, although you may need to update
|
* affected by any resizing or mode switching, although you may need to update
|
||||||
* your viewport if the framebuffer size has changed.
|
* your viewport if the framebuffer size has changed.
|
||||||
*
|
*
|
||||||
* @remark @wayland The desired window position is ignored, as there is no way
|
* @remark @wayland Window positions are not currently part of any common
|
||||||
* for an application to set this property.
|
* Wayland protocol. The window position arguments are ignored.
|
||||||
*
|
*
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
@ -4096,8 +4107,9 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int
|
|||||||
* errors. However, this function should not fail as long as it is passed
|
* errors. However, this function should not fail as long as it is passed
|
||||||
* valid arguments and the library has been [initialized](@ref intro_init).
|
* valid arguments and the library has been [initialized](@ref intro_init).
|
||||||
*
|
*
|
||||||
* @remark @wayland The Wayland protocol provides no way to check whether a
|
* @remark @wayland Checking whether a window is iconified is not currently
|
||||||
* window is iconfied, so @ref GLFW_ICONIFIED always returns `GLFW_FALSE`.
|
* part of any common Wayland protocol, so the @ref GLFW_ICONIFIED attribute
|
||||||
|
* cannot be implemented and is always `GLFW_FALSE`.
|
||||||
*
|
*
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
@ -4219,8 +4231,8 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
|
|||||||
*
|
*
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
*
|
*
|
||||||
* @remark @wayland This callback will never be called, as there is no way for
|
* @remark @wayland This callback will not be called. The Wayland protocol
|
||||||
* an application to know its global position.
|
* provides no way to be notified of when a window is moved.
|
||||||
*
|
*
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
@ -4395,6 +4407,10 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi
|
|||||||
*
|
*
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
*
|
*
|
||||||
|
* @remark @wayland This callback will not be called. The Wayland protocol
|
||||||
|
* provides no way to be notified of when a window is iconified, and no way to
|
||||||
|
* check whether a window is currently iconified.
|
||||||
|
*
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
* @sa @ref window_iconify
|
* @sa @ref window_iconify
|
||||||
|
|||||||
107
premake5.lua
Normal file
107
premake5.lua
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
project "GLFW"
|
||||||
|
kind "StaticLib"
|
||||||
|
language "C"
|
||||||
|
|
||||||
|
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
|
||||||
|
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
|
||||||
|
|
||||||
|
files
|
||||||
|
{
|
||||||
|
"include/GLFW/glfw3.h",
|
||||||
|
"include/GLFW/glfw3native.h",
|
||||||
|
"src/glfw_config.h",
|
||||||
|
"src/context.c",
|
||||||
|
"src/init.c",
|
||||||
|
"src/input.c",
|
||||||
|
"src/monitor.c",
|
||||||
|
|
||||||
|
"src/null_init.c",
|
||||||
|
"src/null_joystick.c",
|
||||||
|
"src/null_monitor.c",
|
||||||
|
"src/null_window.c",
|
||||||
|
|
||||||
|
"src/platform.c",
|
||||||
|
"src/vulkan.c",
|
||||||
|
"src/window.c"
|
||||||
|
}
|
||||||
|
filter "system:linux"
|
||||||
|
pic "On"
|
||||||
|
|
||||||
|
systemversion "latest"
|
||||||
|
staticruntime "On"
|
||||||
|
|
||||||
|
files
|
||||||
|
{
|
||||||
|
"src/x11_init.c",
|
||||||
|
"src/x11_monitor.c",
|
||||||
|
"src/x11_window.c",
|
||||||
|
"src/xkb_unicode.c",
|
||||||
|
"src/posix_module.c",
|
||||||
|
"src/posix_time.c",
|
||||||
|
"src/posix_thread.c",
|
||||||
|
"src/posix_module.c",
|
||||||
|
"src/posix_poll.c",
|
||||||
|
"src/glx_context.c",
|
||||||
|
"src/egl_context.c",
|
||||||
|
"src/osmesa_context.c",
|
||||||
|
"src/linux_joystick.c"
|
||||||
|
}
|
||||||
|
|
||||||
|
defines
|
||||||
|
{
|
||||||
|
"_GLFW_X11"
|
||||||
|
}
|
||||||
|
|
||||||
|
filter "system:macosx"
|
||||||
|
pic "On"
|
||||||
|
|
||||||
|
files
|
||||||
|
{
|
||||||
|
"src/cocoa_init.m",
|
||||||
|
"src/cocoa_monitor.m",
|
||||||
|
"src/cocoa_window.m",
|
||||||
|
"src/cocoa_joystick.m",
|
||||||
|
"src/cocoa_time.c",
|
||||||
|
"src/nsgl_context.m",
|
||||||
|
"src/posix_thread.c",
|
||||||
|
"src/posix_module.c",
|
||||||
|
"src/osmesa_context.c",
|
||||||
|
"src/egl_context.c"
|
||||||
|
}
|
||||||
|
|
||||||
|
defines
|
||||||
|
{
|
||||||
|
"_GLFW_COCOA"
|
||||||
|
}
|
||||||
|
|
||||||
|
filter "system:windows"
|
||||||
|
systemversion "latest"
|
||||||
|
staticruntime "On"
|
||||||
|
|
||||||
|
files
|
||||||
|
{
|
||||||
|
"src/win32_init.c",
|
||||||
|
"src/win32_joystick.c",
|
||||||
|
"src/win32_module.c",
|
||||||
|
"src/win32_monitor.c",
|
||||||
|
"src/win32_time.c",
|
||||||
|
"src/win32_thread.c",
|
||||||
|
"src/win32_window.c",
|
||||||
|
"src/wgl_context.c",
|
||||||
|
"src/egl_context.c",
|
||||||
|
"src/osmesa_context.c"
|
||||||
|
}
|
||||||
|
|
||||||
|
defines
|
||||||
|
{
|
||||||
|
"_GLFW_WIN32",
|
||||||
|
"_CRT_SECURE_NO_WARNINGS"
|
||||||
|
}
|
||||||
|
|
||||||
|
filter "configurations:Debug"
|
||||||
|
runtime "Debug"
|
||||||
|
symbols "on"
|
||||||
|
|
||||||
|
filter "configurations:Release"
|
||||||
|
runtime "Release"
|
||||||
|
optimize "on"
|
||||||
@ -415,6 +415,7 @@ struct _GLFWwndconfig
|
|||||||
GLFWbool mousePassthrough;
|
GLFWbool mousePassthrough;
|
||||||
GLFWbool scaleToMonitor;
|
GLFWbool scaleToMonitor;
|
||||||
GLFWbool scaleFramebuffer;
|
GLFWbool scaleFramebuffer;
|
||||||
|
int theme;
|
||||||
struct {
|
struct {
|
||||||
char frameName[256];
|
char frameName[256];
|
||||||
} ns;
|
} ns;
|
||||||
@ -539,6 +540,7 @@ struct _GLFWwindow
|
|||||||
GLFWbool focusOnShow;
|
GLFWbool focusOnShow;
|
||||||
GLFWbool mousePassthrough;
|
GLFWbool mousePassthrough;
|
||||||
GLFWbool shouldClose;
|
GLFWbool shouldClose;
|
||||||
|
GLFWbool isLightTheme;
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
GLFWbool doublebuffer;
|
GLFWbool doublebuffer;
|
||||||
GLFWvidmode videoMode;
|
GLFWvidmode videoMode;
|
||||||
|
|||||||
@ -145,6 +145,8 @@ static GLFWbool loadLibraries(void)
|
|||||||
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow");
|
||||||
_glfw.win32.dwmapi.GetColorizationColor = (PFN_DwmGetColorizationColor)
|
_glfw.win32.dwmapi.GetColorizationColor = (PFN_DwmGetColorizationColor)
|
||||||
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
|
||||||
|
_glfw.win32.dwmapi.DwmSetWindowAttribute = (PFN_DwmSetWindowAttribute)
|
||||||
|
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmSetWindowAttribute");
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.win32.shcore.instance = _glfwPlatformLoadModule("shcore.dll");
|
_glfw.win32.shcore.instance = _glfwPlatformLoadModule("shcore.dll");
|
||||||
@ -563,6 +565,14 @@ void _glfwUpdateKeyNamesWin32(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwSetWindowTheme(BOOL dark, HWND hwnd)
|
||||||
|
{
|
||||||
|
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
||||||
|
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
||||||
|
#endif
|
||||||
|
_glfw.win32.dwmapi.DwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &dark, sizeof(dark));
|
||||||
|
}
|
||||||
|
|
||||||
// Replacement for IsWindowsVersionOrGreater, as we cannot rely on the
|
// Replacement for IsWindowsVersionOrGreater, as we cannot rely on the
|
||||||
// application having a correct embedded manifest
|
// application having a correct embedded manifest
|
||||||
//
|
//
|
||||||
|
|||||||
@ -241,8 +241,9 @@ typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT);
|
|||||||
// dwmapi.dll function pointer typedefs
|
// dwmapi.dll function pointer typedefs
|
||||||
typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*);
|
typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*);
|
||||||
typedef HRESULT (WINAPI * PFN_DwmFlush)(VOID);
|
typedef HRESULT (WINAPI * PFN_DwmFlush)(VOID);
|
||||||
typedef HRESULT(WINAPI * PFN_DwmEnableBlurBehindWindow)(HWND,const DWM_BLURBEHIND*);
|
typedef HRESULT (WINAPI * PFN_DwmEnableBlurBehindWindow)(HWND,const DWM_BLURBEHIND*);
|
||||||
typedef HRESULT (WINAPI * PFN_DwmGetColorizationColor)(DWORD*,BOOL*);
|
typedef HRESULT (WINAPI * PFN_DwmGetColorizationColor)(DWORD*,BOOL*);
|
||||||
|
typedef HRESULT (WINAPI * PFN_DwmSetWindowAttribute)(HWND, DWORD, LPCVOID, DWORD);
|
||||||
#define DwmIsCompositionEnabled _glfw.win32.dwmapi.IsCompositionEnabled
|
#define DwmIsCompositionEnabled _glfw.win32.dwmapi.IsCompositionEnabled
|
||||||
#define DwmFlush _glfw.win32.dwmapi.Flush
|
#define DwmFlush _glfw.win32.dwmapi.Flush
|
||||||
#define DwmEnableBlurBehindWindow _glfw.win32.dwmapi.EnableBlurBehindWindow
|
#define DwmEnableBlurBehindWindow _glfw.win32.dwmapi.EnableBlurBehindWindow
|
||||||
@ -430,6 +431,7 @@ typedef struct _GLFWlibraryWin32
|
|||||||
PFN_DwmFlush Flush;
|
PFN_DwmFlush Flush;
|
||||||
PFN_DwmEnableBlurBehindWindow EnableBlurBehindWindow;
|
PFN_DwmEnableBlurBehindWindow EnableBlurBehindWindow;
|
||||||
PFN_DwmGetColorizationColor GetColorizationColor;
|
PFN_DwmGetColorizationColor GetColorizationColor;
|
||||||
|
PFN_DwmSetWindowAttribute DwmSetWindowAttribute;
|
||||||
} dwmapi;
|
} dwmapi;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@ -476,6 +478,7 @@ BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp);
|
|||||||
BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build);
|
BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build);
|
||||||
void _glfwInputErrorWin32(int error, const char* description);
|
void _glfwInputErrorWin32(int error, const char* description);
|
||||||
void _glfwUpdateKeyNamesWin32(void);
|
void _glfwUpdateKeyNamesWin32(void);
|
||||||
|
void _glfwSetWindowTheme(BOOL dark, HWND hwnd);
|
||||||
|
|
||||||
void _glfwPollMonitorsWin32(void);
|
void _glfwPollMonitorsWin32(void);
|
||||||
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||||
|
|||||||
@ -1392,6 +1392,36 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
_glfw.win32.instance,
|
_glfw.win32.instance,
|
||||||
(LPVOID) wndconfig);
|
(LPVOID) wndconfig);
|
||||||
|
|
||||||
|
BOOL should_use_light_mode;
|
||||||
|
if (wndconfig->theme == GLFW_THEME_AUTO)
|
||||||
|
{
|
||||||
|
BOOL success = FALSE;
|
||||||
|
HKEY hRootKey = HKEY_CURRENT_USER;
|
||||||
|
const wchar_t* lpSubKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
|
||||||
|
const wchar_t* lpValueName = L"AppsUseLightTheme";
|
||||||
|
DWORD result;
|
||||||
|
{
|
||||||
|
HKEY hKey = 0;
|
||||||
|
if (RegOpenKeyExW(hRootKey, lpSubKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
DWORD dwBufferSize = sizeof(DWORD);
|
||||||
|
DWORD dwData = 0;
|
||||||
|
if (RegQueryValueExW(hKey, lpValueName, 0, NULL, (LPBYTE)(&dwData), &dwBufferSize) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
result = dwData;
|
||||||
|
success = TRUE;
|
||||||
|
}
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
should_use_light_mode = success && result != 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
should_use_light_mode = wndconfig->theme == GLFW_THEME_LIGHT;
|
||||||
|
|
||||||
|
_glfwSetWindowTheme(!should_use_light_mode, window->win32.handle);
|
||||||
|
window->isLightTheme = should_use_light_mode ? GLFW_TRUE : GLFW_FALSE;
|
||||||
|
|
||||||
_glfw_free(wideTitle);
|
_glfw_free(wideTitle);
|
||||||
|
|
||||||
if (!window->win32.handle)
|
if (!window->win32.handle)
|
||||||
|
|||||||
11
src/window.c
11
src/window.c
@ -388,6 +388,8 @@ GLFWAPI void glfwWindowHint(int hint, int value)
|
|||||||
case GLFW_SCALE_FRAMEBUFFER:
|
case GLFW_SCALE_FRAMEBUFFER:
|
||||||
case GLFW_COCOA_RETINA_FRAMEBUFFER:
|
case GLFW_COCOA_RETINA_FRAMEBUFFER:
|
||||||
_glfw.hints.window.scaleFramebuffer = value ? GLFW_TRUE : GLFW_FALSE;
|
_glfw.hints.window.scaleFramebuffer = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
|
case GLFW_THEME:
|
||||||
|
_glfw.hints.window.theme = value;
|
||||||
return;
|
return;
|
||||||
case GLFW_CENTER_CURSOR:
|
case GLFW_CENTER_CURSOR:
|
||||||
_glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE;
|
_glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
@ -607,6 +609,15 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
|||||||
_glfw.platform.setWindowPos(window, xpos, ypos);
|
_glfw.platform.setWindowPos(window, xpos, ypos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI int glfwIsWindowLightTheme(GLFWwindow* handle)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*)handle;
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
||||||
|
return window->isLightTheme;
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
||||||
{
|
{
|
||||||
if (width)
|
if (width)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user