mirror of
https://github.com/glfw/glfw.git
synced 2025-12-21 06:31:58 +00:00
Compare commits
17 Commits
8437607736
...
b986082804
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b986082804 | ||
|
|
161fb1b6f6 | ||
|
|
645a35a38e | ||
|
|
7523b0e6bd | ||
|
|
5190a30d8a | ||
|
|
ddbb8e0f2c | ||
|
|
5245180c56 | ||
|
|
7b51a8eb31 | ||
|
|
c371f4cb7d | ||
|
|
845f0bd901 | ||
|
|
955e8b0fa4 | ||
|
|
8c3f416c3b | ||
|
|
77fae536a9 | ||
|
|
1b5c120205 | ||
|
|
bb4ba846da | ||
|
|
618532218e | ||
|
|
98019fbe98 |
@ -134,6 +134,10 @@ information on what to include when reporting a bug.
|
|||||||
- [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727)
|
- [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727)
|
||||||
- [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: Retrieved cursor position would be incorrect when hovering over
|
||||||
|
fallback decorations
|
||||||
|
- [Wayland] Bugfix: Fallback decorations would report scroll events
|
||||||
- [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`
|
||||||
|
|||||||
@ -1102,6 +1102,7 @@ extern "C" {
|
|||||||
* [window hint](@ref GLFW_SCALE_FRAMEBUFFER_hint).
|
* [window hint](@ref GLFW_SCALE_FRAMEBUFFER_hint).
|
||||||
*/
|
*/
|
||||||
#define GLFW_SCALE_FRAMEBUFFER 0x0002200D
|
#define GLFW_SCALE_FRAMEBUFFER 0x0002200D
|
||||||
|
#define GLFW_FULLSCREEN 0x0002200E
|
||||||
/*! @brief Legacy name for compatibility.
|
/*! @brief Legacy name for compatibility.
|
||||||
*
|
*
|
||||||
* This is an alias for the
|
* This is an alias for the
|
||||||
|
|||||||
@ -555,6 +555,7 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
|
|||||||
.setWindowFloating = _glfwSetWindowFloatingCocoa,
|
.setWindowFloating = _glfwSetWindowFloatingCocoa,
|
||||||
.setWindowOpacity = _glfwSetWindowOpacityCocoa,
|
.setWindowOpacity = _glfwSetWindowOpacityCocoa,
|
||||||
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughCocoa,
|
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughCocoa,
|
||||||
|
.getWindowIsFullscreen = _glfwGetWindowIsFullscreenNull,
|
||||||
.pollEvents = _glfwPollEventsCocoa,
|
.pollEvents = _glfwPollEventsCocoa,
|
||||||
.waitEvents = _glfwWaitEventsCocoa,
|
.waitEvents = _glfwWaitEventsCocoa,
|
||||||
.waitEventsTimeout = _glfwWaitEventsTimeoutCocoa,
|
.waitEventsTimeout = _glfwWaitEventsTimeoutCocoa,
|
||||||
|
|||||||
@ -247,6 +247,7 @@ void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled);
|
|||||||
float _glfwGetWindowOpacityCocoa(_GLFWwindow* window);
|
float _glfwGetWindowOpacityCocoa(_GLFWwindow* window);
|
||||||
void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity);
|
void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity);
|
||||||
void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
GLFWbool _glfwGetWindowIsFullscreenCocoa(_GLFWwindow* window);
|
||||||
|
|
||||||
void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled);
|
void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled);
|
||||||
GLFWbool _glfwRawMouseMotionSupportedCocoa(void);
|
GLFWbool _glfwRawMouseMotionSupportedCocoa(void);
|
||||||
|
|||||||
@ -747,6 +747,7 @@ struct _GLFWplatform
|
|||||||
void (*setWindowFloating)(_GLFWwindow*,GLFWbool);
|
void (*setWindowFloating)(_GLFWwindow*,GLFWbool);
|
||||||
void (*setWindowOpacity)(_GLFWwindow*,float);
|
void (*setWindowOpacity)(_GLFWwindow*,float);
|
||||||
void (*setWindowMousePassthrough)(_GLFWwindow*,GLFWbool);
|
void (*setWindowMousePassthrough)(_GLFWwindow*,GLFWbool);
|
||||||
|
GLFWbool (*getWindowIsFullscreen) (_GLFWwindow*);
|
||||||
void (*pollEvents)(void);
|
void (*pollEvents)(void);
|
||||||
void (*waitEvents)(void);
|
void (*waitEvents)(void);
|
||||||
void (*waitEventsTimeout)(double);
|
void (*waitEventsTimeout)(double);
|
||||||
|
|||||||
@ -243,6 +243,8 @@ void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled);
|
|||||||
void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
GLFWbool _glfwGetWindowIsFullscreenNull(_GLFWwindow* window);
|
||||||
|
|
||||||
float _glfwGetWindowOpacityNull(_GLFWwindow* window);
|
float _glfwGetWindowOpacityNull(_GLFWwindow* window);
|
||||||
void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity);
|
void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity);
|
||||||
void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled);
|
void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled);
|
||||||
|
|||||||
@ -408,6 +408,11 @@ void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWbool _glfwGetWindowIsFullscreenNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
float _glfwGetWindowOpacityNull(_GLFWwindow* window)
|
float _glfwGetWindowOpacityNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->null.opacity;
|
return window->null.opacity;
|
||||||
|
|||||||
@ -660,6 +660,7 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
|
|||||||
.setWindowFloating = _glfwSetWindowFloatingWin32,
|
.setWindowFloating = _glfwSetWindowFloatingWin32,
|
||||||
.setWindowOpacity = _glfwSetWindowOpacityWin32,
|
.setWindowOpacity = _glfwSetWindowOpacityWin32,
|
||||||
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughWin32,
|
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughWin32,
|
||||||
|
.getWindowIsFullscreen = _glfwGetWindowIsFullscreenNull,
|
||||||
.pollEvents = _glfwPollEventsWin32,
|
.pollEvents = _glfwPollEventsWin32,
|
||||||
.waitEvents = _glfwWaitEventsWin32,
|
.waitEvents = _glfwWaitEventsWin32,
|
||||||
.waitEventsTimeout = _glfwWaitEventsTimeoutWin32,
|
.waitEventsTimeout = _glfwWaitEventsTimeoutWin32,
|
||||||
|
|||||||
@ -513,6 +513,7 @@ void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled);
|
|||||||
void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowMousePassthroughWin32(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowMousePassthroughWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
GLFWbool _glfwGetWindowIsFullscreenWin32(_GLFWwindow* window);
|
||||||
float _glfwGetWindowOpacityWin32(_GLFWwindow* window);
|
float _glfwGetWindowOpacityWin32(_GLFWwindow* window);
|
||||||
void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity);
|
void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity);
|
||||||
|
|
||||||
|
|||||||
@ -900,6 +900,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
|||||||
return window->focusOnShow;
|
return window->focusOnShow;
|
||||||
case GLFW_MOUSE_PASSTHROUGH:
|
case GLFW_MOUSE_PASSTHROUGH:
|
||||||
return window->mousePassthrough;
|
return window->mousePassthrough;
|
||||||
|
case GLFW_FULLSCREEN:
|
||||||
|
return _glfw.platform.getWindowIsFullscreen(window);
|
||||||
case GLFW_TRANSPARENT_FRAMEBUFFER:
|
case GLFW_TRANSPARENT_FRAMEBUFFER:
|
||||||
return _glfw.platform.framebufferTransparent(window);
|
return _glfw.platform.framebufferTransparent(window);
|
||||||
case GLFW_RESIZABLE:
|
case GLFW_RESIZABLE:
|
||||||
|
|||||||
@ -506,6 +506,7 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
|
|||||||
.setWindowFloating = _glfwSetWindowFloatingWayland,
|
.setWindowFloating = _glfwSetWindowFloatingWayland,
|
||||||
.setWindowOpacity = _glfwSetWindowOpacityWayland,
|
.setWindowOpacity = _glfwSetWindowOpacityWayland,
|
||||||
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughWayland,
|
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughWayland,
|
||||||
|
.getWindowIsFullscreen = _glfwGetWindowIsFullscreenNull,
|
||||||
.pollEvents = _glfwPollEventsWayland,
|
.pollEvents = _glfwPollEventsWayland,
|
||||||
.waitEvents = _glfwWaitEventsWayland,
|
.waitEvents = _glfwWaitEventsWayland,
|
||||||
.waitEventsTimeout = _glfwWaitEventsTimeoutWayland,
|
.waitEventsTimeout = _glfwWaitEventsTimeoutWayland,
|
||||||
|
|||||||
@ -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;
|
||||||
@ -648,6 +649,7 @@ void _glfwSetWindowFloatingWayland(_GLFWwindow* window, GLFWbool enabled);
|
|||||||
float _glfwGetWindowOpacityWayland(_GLFWwindow* window);
|
float _glfwGetWindowOpacityWayland(_GLFWwindow* window);
|
||||||
void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity);
|
void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity);
|
||||||
void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
GLFWbool _glfwGetWindowIsFullscreenWayland(_GLFWwindow* window);
|
||||||
|
|
||||||
void _glfwSetRawMouseMotionWayland(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetRawMouseMotionWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||||
GLFWbool _glfwRawMouseMotionSupportedWayland(void);
|
GLFWbool _glfwRawMouseMotionSupportedWayland(void);
|
||||||
|
|||||||
310
src/wl_window.c
310
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)
|
if (window->wl.fallback.decorations)
|
||||||
{
|
updateFallbackDecorationCursor(window, sx, 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 (_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 (window->wl.fallback.decorations)
|
||||||
{
|
handleFallbackDecorationButton(window, serial, button);
|
||||||
if (button == BTN_LEFT)
|
|
||||||
{
|
|
||||||
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,12 +1636,15 @@ static void pointerHandleAxis(void* userData,
|
|||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (window->wl.hovered)
|
||||||
|
{
|
||||||
// NOTE: 10 units of motion per mouse wheel step seems to be a common ratio
|
// NOTE: 10 units of motion per mouse wheel step seems to be a common ratio
|
||||||
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
|
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
|
||||||
_glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0);
|
_glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0);
|
||||||
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
|
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
|
||||||
_glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0);
|
_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,6 +1778,24 @@ 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);
|
||||||
|
|
||||||
|
|||||||
@ -1237,6 +1237,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
|
|||||||
.setWindowFloating = _glfwSetWindowFloatingX11,
|
.setWindowFloating = _glfwSetWindowFloatingX11,
|
||||||
.setWindowOpacity = _glfwSetWindowOpacityX11,
|
.setWindowOpacity = _glfwSetWindowOpacityX11,
|
||||||
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughX11,
|
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughX11,
|
||||||
|
.getWindowIsFullscreen = _glfwGetWindowIsFullscreenX11,
|
||||||
.pollEvents = _glfwPollEventsX11,
|
.pollEvents = _glfwPollEventsX11,
|
||||||
.waitEvents = _glfwWaitEventsX11,
|
.waitEvents = _glfwWaitEventsX11,
|
||||||
.waitEventsTimeout = _glfwWaitEventsTimeoutX11,
|
.waitEventsTimeout = _glfwWaitEventsTimeoutX11,
|
||||||
|
|||||||
@ -934,6 +934,7 @@ void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled);
|
|||||||
float _glfwGetWindowOpacityX11(_GLFWwindow* window);
|
float _glfwGetWindowOpacityX11(_GLFWwindow* window);
|
||||||
void _glfwSetWindowOpacityX11(_GLFWwindow* window, float opacity);
|
void _glfwSetWindowOpacityX11(_GLFWwindow* window, float opacity);
|
||||||
void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
GLFWbool _glfwGetWindowIsFullscreenX11(_GLFWwindow* window);
|
||||||
|
|
||||||
void _glfwSetRawMouseMotionX11(_GLFWwindow *window, GLFWbool enabled);
|
void _glfwSetRawMouseMotionX11(_GLFWwindow *window, GLFWbool enabled);
|
||||||
GLFWbool _glfwRawMouseMotionSupportedX11(void);
|
GLFWbool _glfwRawMouseMotionSupportedX11(void);
|
||||||
|
|||||||
@ -2729,6 +2729,51 @@ void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWbool _glfwGetWindowIsFullscreenX11(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
Atom wm_state = XInternAtom(_glfw.x11.display, "_NET_WM_STATE", True);
|
||||||
|
Atom wm_state_fullscreen = XInternAtom(_glfw.x11.display, "_NET_WM_STATE_FULLSCREEN", True);
|
||||||
|
|
||||||
|
Atom type = XA_ATOM;
|
||||||
|
int format;
|
||||||
|
size_t nItems;
|
||||||
|
size_t bytesAfterReturn;
|
||||||
|
Atom* prop;
|
||||||
|
|
||||||
|
int result = XGetWindowProperty(
|
||||||
|
_glfw.x11.display,
|
||||||
|
window->x11.handle,
|
||||||
|
wm_state,
|
||||||
|
0,
|
||||||
|
~0L,
|
||||||
|
False,
|
||||||
|
AnyPropertyType,
|
||||||
|
&type,
|
||||||
|
&format,
|
||||||
|
&nItems,
|
||||||
|
&bytesAfterReturn,
|
||||||
|
(unsigned char**)&prop
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(result == Success);
|
||||||
|
assert(nItems > 0);
|
||||||
|
|
||||||
|
if (!prop) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWbool isFullscreen = 0;
|
||||||
|
for (int i = 0; i < nItems; i++) {
|
||||||
|
if (prop[i] == wm_state_fullscreen) {
|
||||||
|
isFullscreen = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XFree(prop);
|
||||||
|
|
||||||
|
return isFullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
float _glfwGetWindowOpacityX11(_GLFWwindow* window)
|
float _glfwGetWindowOpacityX11(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
float opacity = 1.f;
|
float opacity = 1.f;
|
||||||
|
|||||||
@ -441,6 +441,7 @@ int main(int argc, char** argv)
|
|||||||
nk_value_bool(nk, "Visible", glfwGetWindowAttrib(window, GLFW_VISIBLE));
|
nk_value_bool(nk, "Visible", glfwGetWindowAttrib(window, GLFW_VISIBLE));
|
||||||
nk_value_bool(nk, "Iconified", glfwGetWindowAttrib(window, GLFW_ICONIFIED));
|
nk_value_bool(nk, "Iconified", glfwGetWindowAttrib(window, GLFW_ICONIFIED));
|
||||||
nk_value_bool(nk, "Maximized", glfwGetWindowAttrib(window, GLFW_MAXIMIZED));
|
nk_value_bool(nk, "Maximized", glfwGetWindowAttrib(window, GLFW_MAXIMIZED));
|
||||||
|
nk_value_bool(nk, "Fullscreen", glfwGetWindowAttrib(window, GLFW_FULLSCREEN));
|
||||||
}
|
}
|
||||||
nk_end(nk);
|
nk_end(nk);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user