mirror of
https://github.com/glfw/glfw.git
synced 2025-12-21 14:42:06 +00:00
Compare commits
17 Commits
6e58523ec7
...
b151a2ad4a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b151a2ad4a | ||
|
|
0d2d85d19c | ||
|
|
768e81a0eb | ||
|
|
161fb1b6f6 | ||
|
|
645a35a38e | ||
|
|
7523b0e6bd | ||
|
|
5190a30d8a | ||
|
|
ddbb8e0f2c | ||
|
|
5245180c56 | ||
|
|
1bd20df533 | ||
|
|
475ba17351 | ||
|
|
cac3fd18a0 | ||
|
|
2c28530875 | ||
|
|
dc7c52ed31 | ||
|
|
456bb88748 | ||
|
|
f447b250bf | ||
|
|
49d8b1ff11 |
@ -68,6 +68,7 @@ video tutorials.
|
|||||||
- Jan Ekström
|
- Jan Ekström
|
||||||
- Siavash Eliasi
|
- Siavash Eliasi
|
||||||
- er-azh
|
- er-azh
|
||||||
|
- Jan Hendrik Farr
|
||||||
- Ahmad Fatoum
|
- Ahmad Fatoum
|
||||||
- Nikita Fediuchin
|
- Nikita Fediuchin
|
||||||
- Felipe Ferreira
|
- Felipe Ferreira
|
||||||
@ -290,6 +291,7 @@ video tutorials.
|
|||||||
- Ryogo Yoshimura
|
- Ryogo Yoshimura
|
||||||
- Lukas Zanner
|
- Lukas Zanner
|
||||||
- Andrey Zholos
|
- Andrey Zholos
|
||||||
|
- Tianlan Zhou
|
||||||
- Aihui Zhu
|
- Aihui Zhu
|
||||||
- Santi Zupancic
|
- Santi Zupancic
|
||||||
- Jonas Ådahl
|
- Jonas Ådahl
|
||||||
|
|||||||
@ -135,11 +135,16 @@ information on what to include when reporting a bug.
|
|||||||
- [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727)
|
- [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727)
|
||||||
- [Wayland] Bugfix: Memory would leak if reading a data offer failed midway
|
- [Wayland] Bugfix: Memory would leak if reading a data offer failed midway
|
||||||
- [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736)
|
- [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736)
|
||||||
|
- [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over
|
||||||
|
fallback decorations
|
||||||
|
- [Wayland] Bugfix: Fallback decorations would report scroll events
|
||||||
|
- [Wayland] Bugfix: Keyboard repeat events halted when any key is released (#2568)
|
||||||
- [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631)
|
- [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631)
|
||||||
- [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface`
|
- [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface`
|
||||||
- [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`
|
- [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
|
- [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to
|
||||||
`GLFW_NATIVE_CONTEXT_API` (#2518)
|
`GLFW_NATIVE_CONTEXT_API` (#2518)
|
||||||
|
- Added `GLFW_ACCELERATION` window hint for hardware acceleration (#2491)
|
||||||
|
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
|
|||||||
18
docs/news.md
18
docs/news.md
@ -14,8 +14,25 @@ values over 8. For compatibility with older versions, the
|
|||||||
@ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode needs to be set to make use of
|
@ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode needs to be set to make use of
|
||||||
this.
|
this.
|
||||||
|
|
||||||
|
### Window hint for hardware acceleration {#acceleration}
|
||||||
|
|
||||||
|
You can use window hint [GLFW_ACCELERATION](@ref GLFW_ACCELERATION_hint) to
|
||||||
|
specify whether hardware acceleration is preferred or not. The default value
|
||||||
|
is to prefer hardware acceleration. You can get whether hardware acceleration
|
||||||
|
is enabled with the window attribute
|
||||||
|
[GLFW_ACCELERATION](@ref GLFW_ACCELERATION_attrib). This feature is only
|
||||||
|
available on WGL currently.
|
||||||
|
|
||||||
|
|
||||||
## Caveats {#caveats}
|
## Caveats {#caveats}
|
||||||
|
|
||||||
|
### Microsoft GDI software OpenGL ICD support {#gdi_opengl_icd}
|
||||||
|
|
||||||
|
GLFW now supports creating window when the Microsoft GDI software OpenGL ICD is
|
||||||
|
the only available implementation.
|
||||||
|
See [GLFW_ACCELERATION](@ref GLFW_ACCELERATION_hint) for more details.
|
||||||
|
|
||||||
|
|
||||||
## Deprecations {#deprecations}
|
## Deprecations {#deprecations}
|
||||||
|
|
||||||
## Removals {#removals}
|
## Removals {#removals}
|
||||||
@ -52,4 +69,3 @@ actively maintained and available on many platforms.
|
|||||||
- [Release notes for 3.2](https://www.glfw.org/docs/3.2/news.html)
|
- [Release notes for 3.2](https://www.glfw.org/docs/3.2/news.html)
|
||||||
- [Release notes for 3.1](https://www.glfw.org/docs/3.1/news.html)
|
- [Release notes for 3.1](https://www.glfw.org/docs/3.1/news.html)
|
||||||
- [Release notes for 3.0](https://www.glfw.org/docs/3.0/news.html)
|
- [Release notes for 3.0](https://www.glfw.org/docs/3.0/news.html)
|
||||||
|
|
||||||
|
|||||||
@ -336,6 +336,15 @@ __GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double
|
|||||||
buffered. You nearly always want to use double buffering. This is a hard
|
buffered. You nearly always want to use double buffering. This is a hard
|
||||||
constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
||||||
|
|
||||||
|
@anchor GLFW_ACCELERATION
|
||||||
|
@anchor GLFW_ACCELERATION_hint
|
||||||
|
__GLFW_ACCELERATION__ specifies whether the hardware acceleration should be
|
||||||
|
preferred. By default, hardware acceleration is preferred, and will fallback
|
||||||
|
to no acceleration if hardware acceleration is unavailable. Possible values
|
||||||
|
are `GLFW_TRUE` and `GLFW_FALSE`.
|
||||||
|
|
||||||
|
This hint only has an effect on WGL.
|
||||||
|
|
||||||
|
|
||||||
#### Monitor related hints {#window_hints_mtr}
|
#### Monitor related hints {#window_hints_mtr}
|
||||||
|
|
||||||
@ -1487,6 +1496,11 @@ __GLFW_DOUBLEBUFFER__ indicates whether the specified window is double-buffered
|
|||||||
when rendering with OpenGL or OpenGL ES. This can be set before creation with
|
when rendering with OpenGL or OpenGL ES. This can be set before creation with
|
||||||
the [GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_hint) window hint.
|
the [GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_hint) window hint.
|
||||||
|
|
||||||
|
@anchor GLFW_ACCELERATION_attrib
|
||||||
|
__GLFW_ACCELERATION__ indicates whether the specified window is hardware
|
||||||
|
accelerated when rendering with OpenGL or OpenGL ES. This can be set before
|
||||||
|
creation with the [GLFW_ACCELERATION](@ref GLFW_ACCELERATION_hint) window hint.
|
||||||
|
|
||||||
|
|
||||||
## Buffer swapping {#buffer_swap}
|
## Buffer swapping {#buffer_swap}
|
||||||
|
|
||||||
|
|||||||
@ -1022,6 +1022,14 @@ extern "C" {
|
|||||||
* [attribute](@ref GLFW_DOUBLEBUFFER_attrib).
|
* [attribute](@ref GLFW_DOUBLEBUFFER_attrib).
|
||||||
*/
|
*/
|
||||||
#define GLFW_DOUBLEBUFFER 0x00021010
|
#define GLFW_DOUBLEBUFFER 0x00021010
|
||||||
|
/*! @brief Hardware acceleration hint.
|
||||||
|
*
|
||||||
|
* Hardware acceleration [hint](@ref GLFW_ACCELERATION_hint) and
|
||||||
|
* [attribute](@ref GLFW_ACCELERATION_attrib).
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*/
|
||||||
|
#define GLFW_ACCELERATION 0x00021011
|
||||||
|
|
||||||
/*! @brief Context client API hint and attribute.
|
/*! @brief Context client API hint and attribute.
|
||||||
*
|
*
|
||||||
@ -3159,9 +3167,6 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
|
|||||||
* GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref
|
* GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref
|
||||||
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
|
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
|
||||||
*
|
*
|
||||||
* @remark @win32 Window creation will fail if the Microsoft GDI software
|
|
||||||
* OpenGL implementation is the only one available.
|
|
||||||
*
|
|
||||||
* @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
|
* @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
|
||||||
* will be set as the initial icon for the window. If no such icon is present,
|
* will be set as the initial icon for the window. If no such icon is present,
|
||||||
* the `IDI_APPLICATION` icon will be used instead. To set a different icon,
|
* the `IDI_APPLICATION` icon will be used instead. To set a different icon,
|
||||||
|
|||||||
@ -28,10 +28,10 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -185,6 +185,7 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
unsigned int count)
|
unsigned int count)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
bool accelerationMatch, closestAccelerationMatch = false;
|
||||||
unsigned int missing, leastMissing = UINT_MAX;
|
unsigned int missing, leastMissing = UINT_MAX;
|
||||||
unsigned int colorDiff, leastColorDiff = UINT_MAX;
|
unsigned int colorDiff, leastColorDiff = UINT_MAX;
|
||||||
unsigned int extraDiff, leastExtraDiff = UINT_MAX;
|
unsigned int extraDiff, leastExtraDiff = UINT_MAX;
|
||||||
@ -201,6 +202,8 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
accelerationMatch = desired->acceleration == current->acceleration;
|
||||||
|
|
||||||
// Count number of missing buffers
|
// Count number of missing buffers
|
||||||
{
|
{
|
||||||
missing = 0;
|
missing = 0;
|
||||||
@ -318,19 +321,25 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
// Least number of missing buffers is the most important heuristic,
|
// Least number of missing buffers is the most important heuristic,
|
||||||
// then color buffer size match and lastly size match for other buffers
|
// then color buffer size match and lastly size match for other buffers
|
||||||
|
|
||||||
if (missing < leastMissing)
|
if (accelerationMatch && !closestAccelerationMatch)
|
||||||
closest = current;
|
closest = current;
|
||||||
else if (missing == leastMissing)
|
else if (accelerationMatch == closestAccelerationMatch)
|
||||||
{
|
{
|
||||||
if ((colorDiff < leastColorDiff) ||
|
if (missing < leastMissing)
|
||||||
(colorDiff == leastColorDiff && extraDiff < leastExtraDiff))
|
|
||||||
{
|
|
||||||
closest = current;
|
closest = current;
|
||||||
|
else if (missing == leastMissing)
|
||||||
|
{
|
||||||
|
if ((colorDiff < leastColorDiff) ||
|
||||||
|
(colorDiff == leastColorDiff && extraDiff < leastExtraDiff))
|
||||||
|
{
|
||||||
|
closest = current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current == closest)
|
if (current == closest)
|
||||||
{
|
{
|
||||||
|
closestAccelerationMatch = accelerationMatch;
|
||||||
leastMissing = missing;
|
leastMissing = missing;
|
||||||
leastColorDiff = colorDiff;
|
leastColorDiff = colorDiff;
|
||||||
leastExtraDiff = extraDiff;
|
leastExtraDiff = extraDiff;
|
||||||
|
|||||||
@ -481,6 +481,7 @@ struct _GLFWfbconfig
|
|||||||
GLFWbool sRGB;
|
GLFWbool sRGB;
|
||||||
GLFWbool doublebuffer;
|
GLFWbool doublebuffer;
|
||||||
GLFWbool transparent;
|
GLFWbool transparent;
|
||||||
|
GLFWbool acceleration;
|
||||||
uintptr_t handle;
|
uintptr_t handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -541,6 +542,7 @@ struct _GLFWwindow
|
|||||||
GLFWbool shouldClose;
|
GLFWbool shouldClose;
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
GLFWbool doublebuffer;
|
GLFWbool doublebuffer;
|
||||||
|
GLFWbool acceleration;
|
||||||
GLFWvidmode videoMode;
|
GLFWvidmode videoMode;
|
||||||
_GLFWmonitor* monitor;
|
_GLFWmonitor* monitor;
|
||||||
_GLFWcursor* cursor;
|
_GLFWcursor* cursor;
|
||||||
|
|||||||
@ -145,6 +145,8 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
// Get pixel format attributes through "modern" extension
|
// Get pixel format attributes through "modern" extension
|
||||||
|
|
||||||
|
int acceleration;
|
||||||
|
|
||||||
if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
|
if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
|
||||||
pixelFormat, 0,
|
pixelFormat, 0,
|
||||||
attribCount,
|
attribCount,
|
||||||
@ -166,12 +168,11 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
|
|||||||
if (FIND_ATTRIB_VALUE(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB)
|
if (FIND_ATTRIB_VALUE(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (FIND_ATTRIB_VALUE(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (FIND_ATTRIB_VALUE(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
|
if (FIND_ATTRIB_VALUE(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
acceleration = FIND_ATTRIB_VALUE(WGL_ACCELERATION_ARB);
|
||||||
|
|
||||||
u->redBits = FIND_ATTRIB_VALUE(WGL_RED_BITS_ARB);
|
u->redBits = FIND_ATTRIB_VALUE(WGL_RED_BITS_ARB);
|
||||||
u->greenBits = FIND_ATTRIB_VALUE(WGL_GREEN_BITS_ARB);
|
u->greenBits = FIND_ATTRIB_VALUE(WGL_GREEN_BITS_ARB);
|
||||||
u->blueBits = FIND_ATTRIB_VALUE(WGL_BLUE_BITS_ARB);
|
u->blueBits = FIND_ATTRIB_VALUE(WGL_BLUE_BITS_ARB);
|
||||||
@ -210,6 +211,10 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
|
|||||||
u->sRGB = GLFW_TRUE;
|
u->sRGB = GLFW_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u->acceleration =
|
||||||
|
acceleration == WGL_GENERIC_ACCELERATION_ARB ||
|
||||||
|
acceleration == WGL_FULL_ACCELERATION_ARB;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -235,12 +240,6 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) &&
|
|
||||||
(pfd.dwFlags & PFD_GENERIC_FORMAT))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pfd.iPixelType != PFD_TYPE_RGBA)
|
if (pfd.iPixelType != PFD_TYPE_RGBA)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -264,6 +263,10 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (pfd.dwFlags & PFD_STEREO)
|
if (pfd.dwFlags & PFD_STEREO)
|
||||||
u->stereo = GLFW_TRUE;
|
u->stereo = GLFW_TRUE;
|
||||||
|
|
||||||
|
u->acceleration =
|
||||||
|
(pfd.dwFlags & PFD_GENERIC_ACCELERATED) ||
|
||||||
|
!(pfd.dwFlags & PFD_GENERIC_FORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
u->handle = pixelFormat;
|
u->handle = pixelFormat;
|
||||||
@ -437,8 +440,6 @@ GLFWbool _glfwInitWGL(void)
|
|||||||
|
|
||||||
// NOTE: A dummy context has to be created for opengl32.dll to load the
|
// NOTE: A dummy context has to be created for opengl32.dll to load the
|
||||||
// OpenGL ICD, from which we can then query WGL extensions
|
// OpenGL ICD, from which we can then query WGL extensions
|
||||||
// NOTE: This code will accept the Microsoft GDI ICD; accelerated context
|
|
||||||
// creation failure occurs during manual pixel format enumeration
|
|
||||||
|
|
||||||
dc = GetDC(_glfw.win32.helperWindowHandle);
|
dc = GetDC(_glfw.win32.helperWindowHandle);
|
||||||
|
|
||||||
|
|||||||
@ -172,6 +172,8 @@ typedef enum
|
|||||||
#define WGL_TYPE_RGBA_ARB 0x202b
|
#define WGL_TYPE_RGBA_ARB 0x202b
|
||||||
#define WGL_ACCELERATION_ARB 0x2003
|
#define WGL_ACCELERATION_ARB 0x2003
|
||||||
#define WGL_NO_ACCELERATION_ARB 0x2025
|
#define WGL_NO_ACCELERATION_ARB 0x2025
|
||||||
|
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
|
||||||
|
#define WGL_FULL_ACCELERATION_ARB 0x2027
|
||||||
#define WGL_RED_BITS_ARB 0x2015
|
#define WGL_RED_BITS_ARB 0x2015
|
||||||
#define WGL_RED_SHIFT_ARB 0x2016
|
#define WGL_RED_SHIFT_ARB 0x2016
|
||||||
#define WGL_GREEN_BITS_ARB 0x2017
|
#define WGL_GREEN_BITS_ARB 0x2017
|
||||||
|
|||||||
@ -235,6 +235,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
window->cursorMode = GLFW_CURSOR_NORMAL;
|
window->cursorMode = GLFW_CURSOR_NORMAL;
|
||||||
|
|
||||||
window->doublebuffer = fbconfig.doublebuffer;
|
window->doublebuffer = fbconfig.doublebuffer;
|
||||||
|
window->acceleration = fbconfig.acceleration;
|
||||||
|
|
||||||
window->minwidth = GLFW_DONT_CARE;
|
window->minwidth = GLFW_DONT_CARE;
|
||||||
window->minheight = GLFW_DONT_CARE;
|
window->minheight = GLFW_DONT_CARE;
|
||||||
@ -287,6 +288,7 @@ void glfwDefaultWindowHints(void)
|
|||||||
_glfw.hints.framebuffer.depthBits = 24;
|
_glfw.hints.framebuffer.depthBits = 24;
|
||||||
_glfw.hints.framebuffer.stencilBits = 8;
|
_glfw.hints.framebuffer.stencilBits = 8;
|
||||||
_glfw.hints.framebuffer.doublebuffer = GLFW_TRUE;
|
_glfw.hints.framebuffer.doublebuffer = GLFW_TRUE;
|
||||||
|
_glfw.hints.framebuffer.acceleration = GLFW_TRUE;
|
||||||
|
|
||||||
// The default is to select the highest available refresh rate
|
// The default is to select the highest available refresh rate
|
||||||
_glfw.hints.refreshRate = GLFW_DONT_CARE;
|
_glfw.hints.refreshRate = GLFW_DONT_CARE;
|
||||||
@ -346,6 +348,9 @@ GLFWAPI void glfwWindowHint(int hint, int value)
|
|||||||
case GLFW_SRGB_CAPABLE:
|
case GLFW_SRGB_CAPABLE:
|
||||||
_glfw.hints.framebuffer.sRGB = value ? GLFW_TRUE : GLFW_FALSE;
|
_glfw.hints.framebuffer.sRGB = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
return;
|
return;
|
||||||
|
case GLFW_ACCELERATION:
|
||||||
|
_glfw.hints.framebuffer.acceleration = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
|
return;
|
||||||
case GLFW_RESIZABLE:
|
case GLFW_RESIZABLE:
|
||||||
_glfw.hints.window.resizable = value ? GLFW_TRUE : GLFW_FALSE;
|
_glfw.hints.window.resizable = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
return;
|
return;
|
||||||
@ -912,6 +917,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
|||||||
return window->autoIconify;
|
return window->autoIconify;
|
||||||
case GLFW_DOUBLEBUFFER:
|
case GLFW_DOUBLEBUFFER:
|
||||||
return window->doublebuffer;
|
return window->doublebuffer;
|
||||||
|
case GLFW_ACCELERATION:
|
||||||
|
return window->acceleration;
|
||||||
case GLFW_CLIENT_API:
|
case GLFW_CLIENT_API:
|
||||||
return window->context.client;
|
return window->context.client;
|
||||||
case GLFW_CONTEXT_CREATION_API:
|
case GLFW_CONTEXT_CREATION_API:
|
||||||
|
|||||||
@ -217,62 +217,62 @@ struct libdecor_configuration;
|
|||||||
|
|
||||||
enum libdecor_error
|
enum libdecor_error
|
||||||
{
|
{
|
||||||
LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE,
|
LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE,
|
||||||
LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION,
|
LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum libdecor_window_state
|
enum libdecor_window_state
|
||||||
{
|
{
|
||||||
LIBDECOR_WINDOW_STATE_NONE = 0,
|
LIBDECOR_WINDOW_STATE_NONE = 0,
|
||||||
LIBDECOR_WINDOW_STATE_ACTIVE = 1,
|
LIBDECOR_WINDOW_STATE_ACTIVE = 1,
|
||||||
LIBDECOR_WINDOW_STATE_MAXIMIZED = 2,
|
LIBDECOR_WINDOW_STATE_MAXIMIZED = 2,
|
||||||
LIBDECOR_WINDOW_STATE_FULLSCREEN = 4,
|
LIBDECOR_WINDOW_STATE_FULLSCREEN = 4,
|
||||||
LIBDECOR_WINDOW_STATE_TILED_LEFT = 8,
|
LIBDECOR_WINDOW_STATE_TILED_LEFT = 8,
|
||||||
LIBDECOR_WINDOW_STATE_TILED_RIGHT = 16,
|
LIBDECOR_WINDOW_STATE_TILED_RIGHT = 16,
|
||||||
LIBDECOR_WINDOW_STATE_TILED_TOP = 32,
|
LIBDECOR_WINDOW_STATE_TILED_TOP = 32,
|
||||||
LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 64
|
LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 64
|
||||||
};
|
};
|
||||||
|
|
||||||
enum libdecor_capabilities
|
enum libdecor_capabilities
|
||||||
{
|
{
|
||||||
LIBDECOR_ACTION_MOVE = 1,
|
LIBDECOR_ACTION_MOVE = 1,
|
||||||
LIBDECOR_ACTION_RESIZE = 2,
|
LIBDECOR_ACTION_RESIZE = 2,
|
||||||
LIBDECOR_ACTION_MINIMIZE = 4,
|
LIBDECOR_ACTION_MINIMIZE = 4,
|
||||||
LIBDECOR_ACTION_FULLSCREEN = 8,
|
LIBDECOR_ACTION_FULLSCREEN = 8,
|
||||||
LIBDECOR_ACTION_CLOSE = 16
|
LIBDECOR_ACTION_CLOSE = 16
|
||||||
};
|
};
|
||||||
|
|
||||||
struct libdecor_interface
|
struct libdecor_interface
|
||||||
{
|
{
|
||||||
void (* error)(struct libdecor*,enum libdecor_error,const char*);
|
void (* error)(struct libdecor*,enum libdecor_error,const char*);
|
||||||
void (* reserved0)(void);
|
void (* reserved0)(void);
|
||||||
void (* reserved1)(void);
|
void (* reserved1)(void);
|
||||||
void (* reserved2)(void);
|
void (* reserved2)(void);
|
||||||
void (* reserved3)(void);
|
void (* reserved3)(void);
|
||||||
void (* reserved4)(void);
|
void (* reserved4)(void);
|
||||||
void (* reserved5)(void);
|
void (* reserved5)(void);
|
||||||
void (* reserved6)(void);
|
void (* reserved6)(void);
|
||||||
void (* reserved7)(void);
|
void (* reserved7)(void);
|
||||||
void (* reserved8)(void);
|
void (* reserved8)(void);
|
||||||
void (* reserved9)(void);
|
void (* reserved9)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct libdecor_frame_interface
|
struct libdecor_frame_interface
|
||||||
{
|
{
|
||||||
void (* configure)(struct libdecor_frame*,struct libdecor_configuration*,void*);
|
void (* configure)(struct libdecor_frame*,struct libdecor_configuration*,void*);
|
||||||
void (* close)(struct libdecor_frame*,void*);
|
void (* close)(struct libdecor_frame*,void*);
|
||||||
void (* commit)(struct libdecor_frame*,void*);
|
void (* commit)(struct libdecor_frame*,void*);
|
||||||
void (* dismiss_popup)(struct libdecor_frame*,const char*,void*);
|
void (* dismiss_popup)(struct libdecor_frame*,const char*,void*);
|
||||||
void (* reserved0)(void);
|
void (* reserved0)(void);
|
||||||
void (* reserved1)(void);
|
void (* reserved1)(void);
|
||||||
void (* reserved2)(void);
|
void (* reserved2)(void);
|
||||||
void (* reserved3)(void);
|
void (* reserved3)(void);
|
||||||
void (* reserved4)(void);
|
void (* reserved4)(void);
|
||||||
void (* reserved5)(void);
|
void (* reserved5)(void);
|
||||||
void (* reserved6)(void);
|
void (* reserved6)(void);
|
||||||
void (* reserved7)(void);
|
void (* reserved7)(void);
|
||||||
void (* reserved8)(void);
|
void (* reserved8)(void);
|
||||||
void (* reserved9)(void);
|
void (* reserved9)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct libdecor* (* PFN_libdecor_new)(struct wl_display*,const struct libdecor_interface*);
|
typedef struct libdecor* (* PFN_libdecor_new)(struct wl_display*,const struct libdecor_interface*);
|
||||||
@ -413,6 +413,8 @@ typedef struct _GLFWwindowWayland
|
|||||||
struct wl_buffer* buffer;
|
struct wl_buffer* buffer;
|
||||||
_GLFWfallbackEdgeWayland top, left, right, bottom;
|
_GLFWfallbackEdgeWayland top, left, right, bottom;
|
||||||
struct wl_surface* focus;
|
struct wl_surface* focus;
|
||||||
|
wl_fixed_t pointerX, pointerY;
|
||||||
|
const char* cursorName;
|
||||||
} fallback;
|
} fallback;
|
||||||
} _GLFWwindowWayland;
|
} _GLFWwindowWayland;
|
||||||
|
|
||||||
@ -454,7 +456,6 @@ typedef struct _GLFWlibraryWayland
|
|||||||
struct wl_cursor_theme* cursorTheme;
|
struct wl_cursor_theme* cursorTheme;
|
||||||
struct wl_cursor_theme* cursorThemeHiDPI;
|
struct wl_cursor_theme* cursorThemeHiDPI;
|
||||||
struct wl_surface* cursorSurface;
|
struct wl_surface* cursorSurface;
|
||||||
const char* cursorPreviousName;
|
|
||||||
int cursorTimerfd;
|
int cursorTimerfd;
|
||||||
uint32_t serial;
|
uint32_t serial;
|
||||||
uint32_t pointerEnterSerial;
|
uint32_t pointerEnterSerial;
|
||||||
|
|||||||
333
src/wl_window.c
333
src/wl_window.c
@ -275,6 +275,146 @@ static void destroyFallbackDecorations(_GLFWwindow* window)
|
|||||||
destroyFallbackEdge(&window->wl.fallback.bottom);
|
destroyFallbackEdge(&window->wl.fallback.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void updateFallbackDecorationCursor(_GLFWwindow* window,
|
||||||
|
wl_fixed_t sx,
|
||||||
|
wl_fixed_t sy)
|
||||||
|
{
|
||||||
|
window->wl.fallback.pointerX = sx;
|
||||||
|
window->wl.fallback.pointerY = sy;
|
||||||
|
|
||||||
|
const double xpos = wl_fixed_to_double(sx);
|
||||||
|
const double ypos = wl_fixed_to_double(sy);
|
||||||
|
const char* cursorName = "left_ptr";
|
||||||
|
|
||||||
|
if (window->resizable)
|
||||||
|
{
|
||||||
|
if (window->wl.fallback.focus == window->wl.fallback.top.surface)
|
||||||
|
{
|
||||||
|
if (ypos < GLFW_BORDER_SIZE)
|
||||||
|
cursorName = "n-resize";
|
||||||
|
}
|
||||||
|
else if (window->wl.fallback.focus == window->wl.fallback.left.surface)
|
||||||
|
{
|
||||||
|
if (ypos < GLFW_BORDER_SIZE)
|
||||||
|
cursorName = "nw-resize";
|
||||||
|
else
|
||||||
|
cursorName = "w-resize";
|
||||||
|
}
|
||||||
|
else if (window->wl.fallback.focus == window->wl.fallback.right.surface)
|
||||||
|
{
|
||||||
|
if (ypos < GLFW_BORDER_SIZE)
|
||||||
|
cursorName = "ne-resize";
|
||||||
|
else
|
||||||
|
cursorName = "e-resize";
|
||||||
|
}
|
||||||
|
else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface)
|
||||||
|
{
|
||||||
|
if (xpos < GLFW_BORDER_SIZE)
|
||||||
|
cursorName = "sw-resize";
|
||||||
|
else if (xpos > window->wl.width + GLFW_BORDER_SIZE)
|
||||||
|
cursorName = "se-resize";
|
||||||
|
else
|
||||||
|
cursorName = "s-resize";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->wl.fallback.cursorName != cursorName)
|
||||||
|
{
|
||||||
|
struct wl_surface* surface = _glfw.wl.cursorSurface;
|
||||||
|
struct wl_cursor_theme* theme = _glfw.wl.cursorTheme;
|
||||||
|
int scale = 1;
|
||||||
|
|
||||||
|
if (window->wl.bufferScale > 1 && _glfw.wl.cursorThemeHiDPI)
|
||||||
|
{
|
||||||
|
// We only support up to scale=2 for now, since libwayland-cursor
|
||||||
|
// requires us to load a different theme for each size.
|
||||||
|
scale = 2;
|
||||||
|
theme = _glfw.wl.cursorThemeHiDPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName);
|
||||||
|
if (!cursor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// TODO: handle animated cursors too.
|
||||||
|
struct wl_cursor_image* image = cursor->images[0];
|
||||||
|
if (!image)
|
||||||
|
return;
|
||||||
|
|
||||||
|
struct wl_buffer* buffer = wl_cursor_image_get_buffer(image);
|
||||||
|
if (!buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
|
||||||
|
surface,
|
||||||
|
image->hotspot_x / scale,
|
||||||
|
image->hotspot_y / scale);
|
||||||
|
wl_surface_set_buffer_scale(surface, scale);
|
||||||
|
wl_surface_attach(surface, buffer, 0, 0);
|
||||||
|
wl_surface_damage(surface, 0, 0, image->width, image->height);
|
||||||
|
wl_surface_commit(surface);
|
||||||
|
|
||||||
|
window->wl.fallback.cursorName = cursorName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handleFallbackDecorationButton(_GLFWwindow* window,
|
||||||
|
uint32_t serial,
|
||||||
|
uint32_t button)
|
||||||
|
{
|
||||||
|
const double xpos = wl_fixed_to_double(window->wl.fallback.pointerX);
|
||||||
|
const double ypos = wl_fixed_to_double(window->wl.fallback.pointerY);
|
||||||
|
|
||||||
|
if (button == BTN_LEFT)
|
||||||
|
{
|
||||||
|
uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
|
||||||
|
|
||||||
|
if (window->wl.fallback.focus == window->wl.fallback.top.surface)
|
||||||
|
{
|
||||||
|
if (ypos < GLFW_BORDER_SIZE)
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP;
|
||||||
|
else
|
||||||
|
xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
|
||||||
|
}
|
||||||
|
else if (window->wl.fallback.focus == window->wl.fallback.left.surface)
|
||||||
|
{
|
||||||
|
if (ypos < GLFW_BORDER_SIZE)
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT;
|
||||||
|
else
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
|
||||||
|
}
|
||||||
|
else if (window->wl.fallback.focus == window->wl.fallback.right.surface)
|
||||||
|
{
|
||||||
|
if (ypos < GLFW_BORDER_SIZE)
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT;
|
||||||
|
else
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
|
||||||
|
}
|
||||||
|
else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface)
|
||||||
|
{
|
||||||
|
if (xpos < GLFW_BORDER_SIZE)
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT;
|
||||||
|
else if (xpos > window->wl.width + GLFW_BORDER_SIZE)
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT;
|
||||||
|
else
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE)
|
||||||
|
xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, serial, edges);
|
||||||
|
}
|
||||||
|
else if (button == BTN_RIGHT)
|
||||||
|
{
|
||||||
|
if (window->wl.xdg.toplevel)
|
||||||
|
{
|
||||||
|
xdg_toplevel_show_window_menu(window->wl.xdg.toplevel,
|
||||||
|
_glfw.wl.seat, serial,
|
||||||
|
window->wl.cursorPosX,
|
||||||
|
window->wl.cursorPosY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void xdgDecorationHandleConfigure(void* userData,
|
static void xdgDecorationHandleConfigure(void* userData,
|
||||||
struct zxdg_toplevel_decoration_v1* decoration,
|
struct zxdg_toplevel_decoration_v1* decoration,
|
||||||
uint32_t mode)
|
uint32_t mode)
|
||||||
@ -1417,7 +1557,6 @@ static void pointerHandleLeave(void* userData,
|
|||||||
|
|
||||||
_glfw.wl.serial = serial;
|
_glfw.wl.serial = serial;
|
||||||
_glfw.wl.pointerFocus = NULL;
|
_glfw.wl.pointerFocus = NULL;
|
||||||
_glfw.wl.cursorPreviousName = NULL;
|
|
||||||
|
|
||||||
if (window->wl.hovered)
|
if (window->wl.hovered)
|
||||||
{
|
{
|
||||||
@ -1427,7 +1566,10 @@ static void pointerHandleLeave(void* userData,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (window->wl.fallback.decorations)
|
if (window->wl.fallback.decorations)
|
||||||
|
{
|
||||||
window->wl.fallback.focus = NULL;
|
window->wl.fallback.focus = NULL;
|
||||||
|
window->wl.fallback.cursorName = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1444,92 +1586,16 @@ static void pointerHandleMotion(void* userData,
|
|||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const double xpos = wl_fixed_to_double(sx);
|
|
||||||
const double ypos = wl_fixed_to_double(sy);
|
|
||||||
window->wl.cursorPosX = xpos;
|
|
||||||
window->wl.cursorPosY = ypos;
|
|
||||||
|
|
||||||
if (window->wl.hovered)
|
if (window->wl.hovered)
|
||||||
{
|
{
|
||||||
_glfw.wl.cursorPreviousName = NULL;
|
window->wl.cursorPosX = wl_fixed_to_double(sx);
|
||||||
_glfwInputCursorPos(window, xpos, ypos);
|
window->wl.cursorPosY = wl_fixed_to_double(sy);
|
||||||
return;
|
_glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (window->wl.fallback.decorations)
|
|
||||||
{
|
{
|
||||||
const char* cursorName = "left_ptr";
|
if (window->wl.fallback.decorations)
|
||||||
|
updateFallbackDecorationCursor(window, sx, sy);
|
||||||
if (window->resizable)
|
|
||||||
{
|
|
||||||
if (window->wl.fallback.focus == window->wl.fallback.top.surface)
|
|
||||||
{
|
|
||||||
if (ypos < GLFW_BORDER_SIZE)
|
|
||||||
cursorName = "n-resize";
|
|
||||||
}
|
|
||||||
else if (window->wl.fallback.focus == window->wl.fallback.left.surface)
|
|
||||||
{
|
|
||||||
if (ypos < GLFW_BORDER_SIZE)
|
|
||||||
cursorName = "nw-resize";
|
|
||||||
else
|
|
||||||
cursorName = "w-resize";
|
|
||||||
}
|
|
||||||
else if (window->wl.fallback.focus == window->wl.fallback.right.surface)
|
|
||||||
{
|
|
||||||
if (ypos < GLFW_BORDER_SIZE)
|
|
||||||
cursorName = "ne-resize";
|
|
||||||
else
|
|
||||||
cursorName = "e-resize";
|
|
||||||
}
|
|
||||||
else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface)
|
|
||||||
{
|
|
||||||
if (xpos < GLFW_BORDER_SIZE)
|
|
||||||
cursorName = "sw-resize";
|
|
||||||
else if (xpos > window->wl.width + GLFW_BORDER_SIZE)
|
|
||||||
cursorName = "se-resize";
|
|
||||||
else
|
|
||||||
cursorName = "s-resize";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_glfw.wl.cursorPreviousName != cursorName)
|
|
||||||
{
|
|
||||||
struct wl_surface* surface = _glfw.wl.cursorSurface;
|
|
||||||
struct wl_cursor_theme* theme = _glfw.wl.cursorTheme;
|
|
||||||
int scale = 1;
|
|
||||||
|
|
||||||
if (window->wl.bufferScale > 1 && _glfw.wl.cursorThemeHiDPI)
|
|
||||||
{
|
|
||||||
// We only support up to scale=2 for now, since libwayland-cursor
|
|
||||||
// requires us to load a different theme for each size.
|
|
||||||
scale = 2;
|
|
||||||
theme = _glfw.wl.cursorThemeHiDPI;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName);
|
|
||||||
if (!cursor)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// TODO: handle animated cursors too.
|
|
||||||
struct wl_cursor_image* image = cursor->images[0];
|
|
||||||
if (!image)
|
|
||||||
return;
|
|
||||||
|
|
||||||
struct wl_buffer* buffer = wl_cursor_image_get_buffer(image);
|
|
||||||
if (!buffer)
|
|
||||||
return;
|
|
||||||
|
|
||||||
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
|
|
||||||
surface,
|
|
||||||
image->hotspot_x / scale,
|
|
||||||
image->hotspot_y / scale);
|
|
||||||
wl_surface_set_buffer_scale(surface, scale);
|
|
||||||
wl_surface_attach(surface, buffer, 0, 0);
|
|
||||||
wl_surface_damage(surface, 0, 0, image->width, image->height);
|
|
||||||
wl_surface_commit(surface);
|
|
||||||
|
|
||||||
_glfw.wl.cursorPreviousName = cursorName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1552,62 +1618,11 @@ static void pointerHandleButton(void* userData,
|
|||||||
button - BTN_LEFT,
|
button - BTN_LEFT,
|
||||||
state == WL_POINTER_BUTTON_STATE_PRESSED,
|
state == WL_POINTER_BUTTON_STATE_PRESSED,
|
||||||
_glfw.wl.xkb.modifiers);
|
_glfw.wl.xkb.modifiers);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (window->wl.fallback.decorations)
|
|
||||||
{
|
{
|
||||||
if (button == BTN_LEFT)
|
if (window->wl.fallback.decorations)
|
||||||
{
|
handleFallbackDecorationButton(window, serial, button);
|
||||||
uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
|
|
||||||
|
|
||||||
if (window->wl.fallback.focus == window->wl.fallback.top.surface)
|
|
||||||
{
|
|
||||||
if (window->wl.cursorPosY < GLFW_BORDER_SIZE)
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP;
|
|
||||||
else
|
|
||||||
xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
|
|
||||||
}
|
|
||||||
else if (window->wl.fallback.focus == window->wl.fallback.left.surface)
|
|
||||||
{
|
|
||||||
if (window->wl.cursorPosY < GLFW_BORDER_SIZE)
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT;
|
|
||||||
else
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
|
|
||||||
}
|
|
||||||
else if (window->wl.fallback.focus == window->wl.fallback.right.surface)
|
|
||||||
{
|
|
||||||
if (window->wl.cursorPosY < GLFW_BORDER_SIZE)
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT;
|
|
||||||
else
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
|
|
||||||
}
|
|
||||||
else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface)
|
|
||||||
{
|
|
||||||
if (window->wl.cursorPosX < GLFW_BORDER_SIZE)
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT;
|
|
||||||
else if (window->wl.cursorPosX > window->wl.width + GLFW_BORDER_SIZE)
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT;
|
|
||||||
else
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE)
|
|
||||||
{
|
|
||||||
xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat,
|
|
||||||
serial, edges);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (button == BTN_RIGHT)
|
|
||||||
{
|
|
||||||
if (window->wl.xdg.toplevel)
|
|
||||||
{
|
|
||||||
xdg_toplevel_show_window_menu(window->wl.xdg.toplevel,
|
|
||||||
_glfw.wl.seat, serial,
|
|
||||||
window->wl.cursorPosX,
|
|
||||||
window->wl.cursorPosY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1621,11 +1636,14 @@ static void pointerHandleAxis(void* userData,
|
|||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// NOTE: 10 units of motion per mouse wheel step seems to be a common ratio
|
if (window->wl.hovered)
|
||||||
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
|
{
|
||||||
_glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0);
|
// NOTE: 10 units of motion per mouse wheel step seems to be a common ratio
|
||||||
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
|
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
|
||||||
_glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0);
|
_glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0);
|
||||||
|
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
|
||||||
|
_glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_pointer_listener pointerListener =
|
static const struct wl_pointer_listener pointerListener =
|
||||||
@ -1760,24 +1778,6 @@ static void keyboardHandleLeave(void* userData,
|
|||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Handle any key repeats up to this point. We don't poll as this should be infrequent.
|
|
||||||
uint64_t repeats;
|
|
||||||
if (read(_glfw.wl.keyRepeatTimerfd, &repeats, sizeof(repeats)) == 8)
|
|
||||||
{
|
|
||||||
if(_glfw.wl.keyboardFocus)
|
|
||||||
{
|
|
||||||
for (uint64_t i = 0; i < repeats; i++)
|
|
||||||
{
|
|
||||||
_glfwInputKey(_glfw.wl.keyboardFocus,
|
|
||||||
translateKey(_glfw.wl.keyRepeatScancode),
|
|
||||||
_glfw.wl.keyRepeatScancode,
|
|
||||||
GLFW_PRESS,
|
|
||||||
_glfw.wl.xkb.modifiers);
|
|
||||||
inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct itimerspec timer = {0};
|
struct itimerspec timer = {0};
|
||||||
timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
|
timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
|
||||||
|
|
||||||
@ -1820,11 +1820,12 @@ static void keyboardHandleKey(void* userData,
|
|||||||
|
|
||||||
timer.it_value.tv_sec = _glfw.wl.keyRepeatDelay / 1000;
|
timer.it_value.tv_sec = _glfw.wl.keyRepeatDelay / 1000;
|
||||||
timer.it_value.tv_nsec = (_glfw.wl.keyRepeatDelay % 1000) * 1000000;
|
timer.it_value.tv_nsec = (_glfw.wl.keyRepeatDelay % 1000) * 1000000;
|
||||||
|
timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
|
||||||
}
|
}
|
||||||
|
} else if (scancode == _glfw.wl.keyRepeatScancode) {
|
||||||
|
timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
|
|
||||||
|
|
||||||
_glfwInputKey(window, key, scancode, action, _glfw.wl.xkb.modifiers);
|
_glfwInputKey(window, key, scancode, action, _glfw.wl.xkb.modifiers);
|
||||||
|
|
||||||
if (action == GLFW_PRESS)
|
if (action == GLFW_PRESS)
|
||||||
@ -2207,12 +2208,12 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window)
|
|||||||
_glfw.wl.pointerFocus = NULL;
|
_glfw.wl.pointerFocus = NULL;
|
||||||
|
|
||||||
if (window == _glfw.wl.keyboardFocus)
|
if (window == _glfw.wl.keyboardFocus)
|
||||||
{
|
{
|
||||||
struct itimerspec timer = {0};
|
struct itimerspec timer = {0};
|
||||||
timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
|
timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
|
||||||
|
|
||||||
_glfw.wl.keyboardFocus = NULL;
|
_glfw.wl.keyboardFocus = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->wl.fractionalScale)
|
if (window->wl.fractionalScale)
|
||||||
wp_fractional_scale_v1_destroy(window->wl.fractionalScale);
|
wp_fractional_scale_v1_destroy(window->wl.fractionalScale);
|
||||||
|
|||||||
@ -383,6 +383,7 @@ int main(int argc, char** argv)
|
|||||||
int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE;
|
int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE;
|
||||||
bool cocoa_graphics_switching = false;
|
bool cocoa_graphics_switching = false;
|
||||||
bool disable_xcb_surface = false;
|
bool disable_xcb_surface = false;
|
||||||
|
bool acceleration = true;
|
||||||
|
|
||||||
enum { PLATFORM, CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
|
enum { PLATFORM, CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
|
||||||
EXTENSIONS, LAYERS,
|
EXTENSIONS, LAYERS,
|
||||||
@ -390,7 +391,7 @@ int main(int argc, char** argv)
|
|||||||
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
|
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
|
||||||
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
|
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
|
||||||
AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY,
|
AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY,
|
||||||
ANGLE_TYPE, GRAPHICS_SWITCHING, XCB_SURFACE };
|
ANGLE_TYPE, GRAPHICS_SWITCHING, XCB_SURFACE, NO_ACCELERATION };
|
||||||
const struct option options[] =
|
const struct option options[] =
|
||||||
{
|
{
|
||||||
{ "platform", 1, NULL, PLATFORM },
|
{ "platform", 1, NULL, PLATFORM },
|
||||||
@ -426,6 +427,7 @@ int main(int argc, char** argv)
|
|||||||
{ "angle-type", 1, NULL, ANGLE_TYPE },
|
{ "angle-type", 1, NULL, ANGLE_TYPE },
|
||||||
{ "graphics-switching", 0, NULL, GRAPHICS_SWITCHING },
|
{ "graphics-switching", 0, NULL, GRAPHICS_SWITCHING },
|
||||||
{ "vk-xcb-surface", 0, NULL, XCB_SURFACE },
|
{ "vk-xcb-surface", 0, NULL, XCB_SURFACE },
|
||||||
|
{ "no-acceleration", 0, NULL, NO_ACCELERATION },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -654,6 +656,9 @@ int main(int argc, char** argv)
|
|||||||
case XCB_SURFACE:
|
case XCB_SURFACE:
|
||||||
disable_xcb_surface = true;
|
disable_xcb_surface = true;
|
||||||
break;
|
break;
|
||||||
|
case NO_ACCELERATION:
|
||||||
|
acceleration = false;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -708,6 +713,7 @@ int main(int argc, char** argv)
|
|||||||
glfwWindowHint(GLFW_STEREO, fb_stereo);
|
glfwWindowHint(GLFW_STEREO, fb_stereo);
|
||||||
glfwWindowHint(GLFW_SRGB_CAPABLE, fb_srgb);
|
glfwWindowHint(GLFW_SRGB_CAPABLE, fb_srgb);
|
||||||
glfwWindowHint(GLFW_DOUBLEBUFFER, fb_doublebuffer);
|
glfwWindowHint(GLFW_DOUBLEBUFFER, fb_doublebuffer);
|
||||||
|
glfwWindowHint(GLFW_ACCELERATION, acceleration);
|
||||||
|
|
||||||
glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, cocoa_graphics_switching);
|
glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, cocoa_graphics_switching);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user