2014-03-17 21:53:43 +00:00
|
|
|
|
//========================================================================
|
2016-08-18 21:42:15 +00:00
|
|
|
|
// GLFW 3.3 Wayland - www.glfw.org
|
2014-03-17 21:53:43 +00:00
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
|
|
|
|
|
//
|
|
|
|
|
// This software is provided 'as-is', without any express or implied
|
|
|
|
|
// warranty. In no event will the authors be held liable for any damages
|
|
|
|
|
// arising from the use of this software.
|
|
|
|
|
//
|
|
|
|
|
// Permission is granted to anyone to use this software for any purpose,
|
|
|
|
|
// including commercial applications, and to alter it and redistribute it
|
|
|
|
|
// freely, subject to the following restrictions:
|
|
|
|
|
//
|
|
|
|
|
// 1. The origin of this software must not be misrepresented; you must not
|
|
|
|
|
// claim that you wrote the original software. If you use this software
|
|
|
|
|
// in a product, an acknowledgment in the product documentation would
|
|
|
|
|
// be appreciated but is not required.
|
|
|
|
|
//
|
|
|
|
|
// 2. Altered source versions must be plainly marked as such, and must not
|
|
|
|
|
// be misrepresented as being the original software.
|
|
|
|
|
//
|
|
|
|
|
// 3. This notice may not be removed or altered from any source
|
|
|
|
|
// distribution.
|
|
|
|
|
//
|
|
|
|
|
//========================================================================
|
2019-05-20 13:24:14 +00:00
|
|
|
|
// It is fine to use C99 in this file because it will not be built with VS
|
|
|
|
|
//========================================================================
|
2014-03-17 21:53:43 +00:00
|
|
|
|
|
2021-06-21 22:25:42 +00:00
|
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
|
|
2014-03-17 21:53:43 +00:00
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
2017-11-16 17:21:59 +00:00
|
|
|
|
#include <assert.h>
|
2018-10-10 19:49:23 +00:00
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <limits.h>
|
2014-06-29 10:29:00 +00:00
|
|
|
|
#include <linux/input.h>
|
2014-03-17 21:53:43 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2014-06-29 21:09:21 +00:00
|
|
|
|
#include <sys/mman.h>
|
2018-01-30 15:22:25 +00:00
|
|
|
|
#include <sys/timerfd.h>
|
2014-06-29 21:09:21 +00:00
|
|
|
|
#include <unistd.h>
|
2014-03-17 21:53:43 +00:00
|
|
|
|
#include <wayland-client.h>
|
|
|
|
|
|
|
|
|
|
|
2015-10-10 15:35:06 +00:00
|
|
|
|
static inline int min(int n1, int n2)
|
|
|
|
|
{
|
|
|
|
|
return n1 < n2 ? n1 : n2;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 16:11:11 +00:00
|
|
|
|
static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface,
|
|
|
|
|
int* which)
|
2017-12-19 19:58:03 +00:00
|
|
|
|
{
|
|
|
|
|
int focus;
|
|
|
|
|
_GLFWwindow* window = _glfw.windowListHead;
|
|
|
|
|
if (!which)
|
|
|
|
|
which = &focus;
|
|
|
|
|
while (window)
|
|
|
|
|
{
|
|
|
|
|
if (surface == window->wl.decorations.top.surface)
|
|
|
|
|
{
|
|
|
|
|
*which = topDecoration;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (surface == window->wl.decorations.left.surface)
|
|
|
|
|
{
|
|
|
|
|
*which = leftDecoration;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (surface == window->wl.decorations.right.surface)
|
|
|
|
|
{
|
|
|
|
|
*which = rightDecoration;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (surface == window->wl.decorations.bottom.surface)
|
|
|
|
|
{
|
|
|
|
|
*which = bottomDecoration;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
window = window->next;
|
|
|
|
|
}
|
|
|
|
|
return window;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 10:29:00 +00:00
|
|
|
|
static void pointerHandleEnter(void* data,
|
|
|
|
|
struct wl_pointer* pointer,
|
|
|
|
|
uint32_t serial,
|
|
|
|
|
struct wl_surface* surface,
|
|
|
|
|
wl_fixed_t sx,
|
|
|
|
|
wl_fixed_t sy)
|
|
|
|
|
{
|
2018-01-24 12:36:01 +00:00
|
|
|
|
// Happens in the case we just destroyed the surface.
|
|
|
|
|
if (!surface)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-12-19 19:58:03 +00:00
|
|
|
|
int focus = 0;
|
2014-06-29 10:29:00 +00:00
|
|
|
|
_GLFWwindow* window = wl_surface_get_user_data(surface);
|
2017-12-19 18:06:40 +00:00
|
|
|
|
if (!window)
|
2017-12-19 19:58:03 +00:00
|
|
|
|
{
|
|
|
|
|
window = findWindowFromDecorationSurface(surface, &focus);
|
|
|
|
|
if (!window)
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-06-29 10:29:00 +00:00
|
|
|
|
|
2017-12-19 19:58:03 +00:00
|
|
|
|
window->wl.decorations.focus = focus;
|
2014-09-23 17:24:33 +00:00
|
|
|
|
_glfw.wl.serial = serial;
|
2021-05-12 07:30:14 +00:00
|
|
|
|
_glfw.wl.pointerEnterSerial = serial;
|
2014-06-29 10:29:00 +00:00
|
|
|
|
_glfw.wl.pointerFocus = window;
|
2014-09-09 14:37:55 +00:00
|
|
|
|
|
2018-01-04 12:50:58 +00:00
|
|
|
|
window->wl.hovered = GLFW_TRUE;
|
|
|
|
|
|
2014-09-09 14:37:55 +00:00
|
|
|
|
_glfwPlatformSetCursor(window, window->wl.currentCursor);
|
2015-08-23 17:30:04 +00:00
|
|
|
|
_glfwInputCursorEnter(window, GLFW_TRUE);
|
2014-06-29 10:29:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void pointerHandleLeave(void* data,
|
|
|
|
|
struct wl_pointer* pointer,
|
|
|
|
|
uint32_t serial,
|
|
|
|
|
struct wl_surface* surface)
|
|
|
|
|
{
|
2014-07-26 20:55:43 +00:00
|
|
|
|
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
|
|
|
|
|
|
|
|
|
if (!window)
|
|
|
|
|
return;
|
2014-06-29 10:29:00 +00:00
|
|
|
|
|
2018-01-04 12:50:58 +00:00
|
|
|
|
window->wl.hovered = GLFW_FALSE;
|
|
|
|
|
|
2014-09-23 17:24:33 +00:00
|
|
|
|
_glfw.wl.serial = serial;
|
2014-06-29 10:29:00 +00:00
|
|
|
|
_glfw.wl.pointerFocus = NULL;
|
2015-08-23 17:30:04 +00:00
|
|
|
|
_glfwInputCursorEnter(window, GLFW_FALSE);
|
2019-11-28 14:47:09 +00:00
|
|
|
|
_glfw.wl.cursorPreviousName = NULL;
|
2014-06-29 10:29:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-11 12:20:02 +00:00
|
|
|
|
static void setCursor(_GLFWwindow* window, const char* name)
|
2017-12-19 19:58:03 +00:00
|
|
|
|
{
|
|
|
|
|
struct wl_buffer* buffer;
|
|
|
|
|
struct wl_cursor* cursor;
|
|
|
|
|
struct wl_cursor_image* image;
|
|
|
|
|
struct wl_surface* surface = _glfw.wl.cursorSurface;
|
2018-09-11 12:20:02 +00:00
|
|
|
|
struct wl_cursor_theme* theme = _glfw.wl.cursorTheme;
|
|
|
|
|
int scale = 1;
|
2017-12-19 19:58:03 +00:00
|
|
|
|
|
2018-09-11 12:20:02 +00:00
|
|
|
|
if (window->wl.scale > 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cursor = wl_cursor_theme_get_cursor(theme, name);
|
2017-12-19 19:58:03 +00:00
|
|
|
|
if (!cursor)
|
|
|
|
|
{
|
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
|
"Wayland: Standard cursor not found");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-09-08 18:05:40 +00:00
|
|
|
|
// TODO: handle animated cursors too.
|
2017-12-19 19:58:03 +00:00
|
|
|
|
image = cursor->images[0];
|
|
|
|
|
|
|
|
|
|
if (!image)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
buffer = wl_cursor_image_get_buffer(image);
|
|
|
|
|
if (!buffer)
|
|
|
|
|
return;
|
2021-05-12 07:30:14 +00:00
|
|
|
|
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
|
2017-12-19 19:58:03 +00:00
|
|
|
|
surface,
|
2018-09-11 12:20:02 +00:00
|
|
|
|
image->hotspot_x / scale,
|
|
|
|
|
image->hotspot_y / scale);
|
|
|
|
|
wl_surface_set_buffer_scale(surface, scale);
|
2017-12-19 19:58:03 +00:00
|
|
|
|
wl_surface_attach(surface, buffer, 0, 0);
|
|
|
|
|
wl_surface_damage(surface, 0, 0,
|
|
|
|
|
image->width, image->height);
|
|
|
|
|
wl_surface_commit(surface);
|
2019-11-15 14:30:41 +00:00
|
|
|
|
_glfw.wl.cursorPreviousName = name;
|
2017-12-19 19:58:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 10:29:00 +00:00
|
|
|
|
static void pointerHandleMotion(void* data,
|
|
|
|
|
struct wl_pointer* pointer,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
wl_fixed_t sx,
|
|
|
|
|
wl_fixed_t sy)
|
|
|
|
|
{
|
|
|
|
|
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
2019-11-15 14:30:41 +00:00
|
|
|
|
const char* cursorName = NULL;
|
2019-11-21 12:46:18 +00:00
|
|
|
|
double x, y;
|
2014-06-29 10:29:00 +00:00
|
|
|
|
|
2014-07-26 20:55:43 +00:00
|
|
|
|
if (!window)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-06-29 10:29:00 +00:00
|
|
|
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
|
|
|
|
return;
|
2019-11-21 12:46:18 +00:00
|
|
|
|
x = wl_fixed_to_double(sx);
|
|
|
|
|
y = wl_fixed_to_double(sy);
|
2021-12-30 18:04:10 +00:00
|
|
|
|
window->wl.cursorPosX = x;
|
|
|
|
|
window->wl.cursorPosY = y;
|
2014-06-29 10:29:00 +00:00
|
|
|
|
|
2017-12-19 19:58:03 +00:00
|
|
|
|
switch (window->wl.decorations.focus)
|
|
|
|
|
{
|
|
|
|
|
case mainWindow:
|
2019-11-21 12:46:18 +00:00
|
|
|
|
_glfwInputCursorPos(window, x, y);
|
2019-11-28 14:47:09 +00:00
|
|
|
|
_glfw.wl.cursorPreviousName = NULL;
|
2017-12-19 19:58:03 +00:00
|
|
|
|
return;
|
|
|
|
|
case topDecoration:
|
2019-11-21 12:46:18 +00:00
|
|
|
|
if (y < _GLFW_DECORATION_WIDTH)
|
2017-12-19 19:58:03 +00:00
|
|
|
|
cursorName = "n-resize";
|
|
|
|
|
else
|
|
|
|
|
cursorName = "left_ptr";
|
|
|
|
|
break;
|
|
|
|
|
case leftDecoration:
|
2019-11-21 12:46:18 +00:00
|
|
|
|
if (y < _GLFW_DECORATION_WIDTH)
|
2017-12-19 19:58:03 +00:00
|
|
|
|
cursorName = "nw-resize";
|
|
|
|
|
else
|
|
|
|
|
cursorName = "w-resize";
|
|
|
|
|
break;
|
|
|
|
|
case rightDecoration:
|
2019-11-21 12:46:18 +00:00
|
|
|
|
if (y < _GLFW_DECORATION_WIDTH)
|
2017-12-19 19:58:03 +00:00
|
|
|
|
cursorName = "ne-resize";
|
|
|
|
|
else
|
|
|
|
|
cursorName = "e-resize";
|
|
|
|
|
break;
|
|
|
|
|
case bottomDecoration:
|
2019-11-21 12:46:18 +00:00
|
|
|
|
if (x < _GLFW_DECORATION_WIDTH)
|
2017-12-19 19:58:03 +00:00
|
|
|
|
cursorName = "sw-resize";
|
2019-11-21 12:46:18 +00:00
|
|
|
|
else if (x > window->wl.width + _GLFW_DECORATION_WIDTH)
|
2017-12-19 19:58:03 +00:00
|
|
|
|
cursorName = "se-resize";
|
|
|
|
|
else
|
|
|
|
|
cursorName = "s-resize";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
assert(0);
|
|
|
|
|
}
|
2019-11-15 14:30:41 +00:00
|
|
|
|
if (_glfw.wl.cursorPreviousName != cursorName)
|
|
|
|
|
setCursor(window, cursorName);
|
2014-06-29 10:29:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void pointerHandleButton(void* data,
|
2017-12-19 18:08:51 +00:00
|
|
|
|
struct wl_pointer* pointer,
|
2014-06-29 10:29:00 +00:00
|
|
|
|
uint32_t serial,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
uint32_t button,
|
|
|
|
|
uint32_t state)
|
|
|
|
|
{
|
|
|
|
|
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
|
|
|
|
int glfwButton;
|
|
|
|
|
|
2018-01-29 03:45:27 +00:00
|
|
|
|
// Both xdg-shell and wl_shell use the same values.
|
|
|
|
|
uint32_t edges = WL_SHELL_SURFACE_RESIZE_NONE;
|
|
|
|
|
|
2014-07-26 20:55:43 +00:00
|
|
|
|
if (!window)
|
|
|
|
|
return;
|
2018-01-29 03:45:27 +00:00
|
|
|
|
if (button == BTN_LEFT)
|
2017-12-19 19:58:03 +00:00
|
|
|
|
{
|
2018-01-29 03:45:27 +00:00
|
|
|
|
switch (window->wl.decorations.focus)
|
|
|
|
|
{
|
|
|
|
|
case mainWindow:
|
|
|
|
|
break;
|
|
|
|
|
case topDecoration:
|
|
|
|
|
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
|
|
|
|
edges = WL_SHELL_SURFACE_RESIZE_TOP;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (window->wl.xdg.toplevel)
|
|
|
|
|
xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
|
|
|
|
|
else
|
|
|
|
|
wl_shell_surface_move(window->wl.shellSurface, _glfw.wl.seat, serial);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case leftDecoration:
|
|
|
|
|
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
|
|
|
|
edges = WL_SHELL_SURFACE_RESIZE_TOP_LEFT;
|
|
|
|
|
else
|
|
|
|
|
edges = WL_SHELL_SURFACE_RESIZE_LEFT;
|
|
|
|
|
break;
|
|
|
|
|
case rightDecoration:
|
|
|
|
|
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
|
|
|
|
edges = WL_SHELL_SURFACE_RESIZE_TOP_RIGHT;
|
|
|
|
|
else
|
|
|
|
|
edges = WL_SHELL_SURFACE_RESIZE_RIGHT;
|
|
|
|
|
break;
|
|
|
|
|
case bottomDecoration:
|
|
|
|
|
if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
|
|
|
|
|
edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT;
|
|
|
|
|
else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
|
|
|
|
|
edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT;
|
|
|
|
|
else
|
|
|
|
|
edges = WL_SHELL_SURFACE_RESIZE_BOTTOM;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
assert(0);
|
|
|
|
|
}
|
|
|
|
|
if (edges != WL_SHELL_SURFACE_RESIZE_NONE)
|
|
|
|
|
{
|
|
|
|
|
if (window->wl.xdg.toplevel)
|
|
|
|
|
xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat,
|
|
|
|
|
serial, edges);
|
2017-12-19 19:58:03 +00:00
|
|
|
|
else
|
|
|
|
|
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
2018-01-29 03:45:27 +00:00
|
|
|
|
serial, edges);
|
2021-12-30 18:04:10 +00:00
|
|
|
|
return;
|
2018-01-29 03:45:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (button == BTN_RIGHT)
|
|
|
|
|
{
|
|
|
|
|
if (window->wl.decorations.focus != mainWindow && window->wl.xdg.toplevel)
|
|
|
|
|
{
|
|
|
|
|
xdg_toplevel_show_window_menu(window->wl.xdg.toplevel,
|
|
|
|
|
_glfw.wl.seat, serial,
|
|
|
|
|
window->wl.cursorPosX,
|
|
|
|
|
window->wl.cursorPosY);
|
2017-12-19 19:58:03 +00:00
|
|
|
|
return;
|
2018-01-29 03:45:27 +00:00
|
|
|
|
}
|
2017-12-19 19:58:03 +00:00
|
|
|
|
}
|
2014-07-26 20:55:43 +00:00
|
|
|
|
|
2018-01-29 03:45:27 +00:00
|
|
|
|
// Don’t pass the button to the user if it was related to a decoration.
|
|
|
|
|
if (window->wl.decorations.focus != mainWindow)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-09-23 17:24:33 +00:00
|
|
|
|
_glfw.wl.serial = serial;
|
2017-04-13 01:59:49 +00:00
|
|
|
|
|
2014-06-29 10:29:00 +00:00
|
|
|
|
/* Makes left, right and middle 0, 1 and 2. Overall order follows evdev
|
|
|
|
|
* codes. */
|
|
|
|
|
glfwButton = button - BTN_LEFT;
|
|
|
|
|
|
|
|
|
|
_glfwInputMouseClick(window,
|
|
|
|
|
glfwButton,
|
|
|
|
|
state == WL_POINTER_BUTTON_STATE_PRESSED
|
|
|
|
|
? GLFW_PRESS
|
|
|
|
|
: GLFW_RELEASE,
|
2014-06-29 21:09:21 +00:00
|
|
|
|
_glfw.wl.xkb.modifiers);
|
2014-06-29 10:29:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void pointerHandleAxis(void* data,
|
2017-12-19 18:08:51 +00:00
|
|
|
|
struct wl_pointer* pointer,
|
2014-06-29 10:29:00 +00:00
|
|
|
|
uint32_t time,
|
|
|
|
|
uint32_t axis,
|
|
|
|
|
wl_fixed_t value)
|
|
|
|
|
{
|
|
|
|
|
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
2017-11-29 17:00:04 +00:00
|
|
|
|
double x = 0.0, y = 0.0;
|
|
|
|
|
// Wayland scroll events are in pointer motion coordinate space (think two
|
|
|
|
|
// finger scroll). The factor 10 is commonly used to convert to "scroll
|
|
|
|
|
// step means 1.0.
|
|
|
|
|
const double scrollFactor = 1.0 / 10.0;
|
2014-06-29 10:29:00 +00:00
|
|
|
|
|
2014-07-26 20:55:43 +00:00
|
|
|
|
if (!window)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-12-13 20:55:53 +00:00
|
|
|
|
assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL ||
|
|
|
|
|
axis == WL_POINTER_AXIS_VERTICAL_SCROLL);
|
|
|
|
|
|
2017-11-29 17:00:04 +00:00
|
|
|
|
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
|
2020-07-15 21:11:19 +00:00
|
|
|
|
x = -wl_fixed_to_double(value) * scrollFactor;
|
2017-11-29 17:00:04 +00:00
|
|
|
|
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
|
2020-07-15 21:11:19 +00:00
|
|
|
|
y = -wl_fixed_to_double(value) * scrollFactor;
|
2014-06-29 10:29:00 +00:00
|
|
|
|
|
|
|
|
|
_glfwInputScroll(window, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct wl_pointer_listener pointerListener = {
|
|
|
|
|
pointerHandleEnter,
|
|
|
|
|
pointerHandleLeave,
|
|
|
|
|
pointerHandleMotion,
|
|
|
|
|
pointerHandleButton,
|
|
|
|
|
pointerHandleAxis,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void keyboardHandleKeymap(void* data,
|
|
|
|
|
struct wl_keyboard* keyboard,
|
|
|
|
|
uint32_t format,
|
|
|
|
|
int fd,
|
|
|
|
|
uint32_t size)
|
|
|
|
|
{
|
2014-06-29 21:09:21 +00:00
|
|
|
|
struct xkb_keymap* keymap;
|
|
|
|
|
struct xkb_state* state;
|
2017-11-16 16:42:11 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
2016-10-10 23:02:15 +00:00
|
|
|
|
struct xkb_compose_table* composeTable;
|
|
|
|
|
struct xkb_compose_state* composeState;
|
2017-11-16 16:42:11 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2014-06-29 21:09:21 +00:00
|
|
|
|
char* mapStr;
|
2016-10-10 23:02:15 +00:00
|
|
|
|
const char* locale;
|
2014-06-29 21:09:21 +00:00
|
|
|
|
|
|
|
|
|
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
|
|
|
|
|
{
|
|
|
|
|
close(fd);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
|
|
|
|
|
if (mapStr == MAP_FAILED) {
|
|
|
|
|
close(fd);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-11 00:44:22 +00:00
|
|
|
|
keymap = xkb_keymap_new_from_string(_glfw.wl.xkb.context,
|
|
|
|
|
mapStr,
|
|
|
|
|
XKB_KEYMAP_FORMAT_TEXT_V1,
|
|
|
|
|
0);
|
2014-06-29 21:09:21 +00:00
|
|
|
|
munmap(mapStr, size);
|
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
|
|
if (!keymap)
|
|
|
|
|
{
|
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
|
"Wayland: Failed to compile keymap");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
state = xkb_state_new(keymap);
|
|
|
|
|
if (!state)
|
|
|
|
|
{
|
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
|
"Wayland: Failed to create XKB state");
|
2016-10-11 00:44:22 +00:00
|
|
|
|
xkb_keymap_unref(keymap);
|
2014-06-29 21:09:21 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-10 23:02:15 +00:00
|
|
|
|
// Look up the preferred locale, falling back to "C" as default.
|
|
|
|
|
locale = getenv("LC_ALL");
|
|
|
|
|
if (!locale)
|
|
|
|
|
locale = getenv("LC_CTYPE");
|
|
|
|
|
if (!locale)
|
|
|
|
|
locale = getenv("LANG");
|
|
|
|
|
if (!locale)
|
|
|
|
|
locale = "C";
|
|
|
|
|
|
2017-11-16 16:42:11 +00:00
|
|
|
|
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
2016-10-10 23:02:15 +00:00
|
|
|
|
composeTable =
|
|
|
|
|
xkb_compose_table_new_from_locale(_glfw.wl.xkb.context, locale,
|
|
|
|
|
XKB_COMPOSE_COMPILE_NO_FLAGS);
|
|
|
|
|
if (composeTable)
|
|
|
|
|
{
|
|
|
|
|
composeState =
|
|
|
|
|
xkb_compose_state_new(composeTable, XKB_COMPOSE_STATE_NO_FLAGS);
|
|
|
|
|
xkb_compose_table_unref(composeTable);
|
|
|
|
|
if (composeState)
|
|
|
|
|
_glfw.wl.xkb.composeState = composeState;
|
|
|
|
|
else
|
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
|
"Wayland: Failed to create XKB compose state");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
|
"Wayland: Failed to create XKB compose table");
|
|
|
|
|
}
|
2017-11-16 16:42:11 +00:00
|
|
|
|
#endif
|
2016-10-10 23:02:15 +00:00
|
|
|
|
|
2014-06-29 21:09:21 +00:00
|
|
|
|
xkb_keymap_unref(_glfw.wl.xkb.keymap);
|
|
|
|
|
xkb_state_unref(_glfw.wl.xkb.state);
|
|
|
|
|
_glfw.wl.xkb.keymap = keymap;
|
|
|
|
|
_glfw.wl.xkb.state = state;
|
|
|
|
|
|
2016-10-01 19:05:29 +00:00
|
|
|
|
_glfw.wl.xkb.controlMask =
|
2016-10-11 00:44:22 +00:00
|
|
|
|
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Control");
|
2016-10-01 19:05:29 +00:00
|
|
|
|
_glfw.wl.xkb.altMask =
|
2016-10-11 00:44:22 +00:00
|
|
|
|
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod1");
|
2016-10-01 19:05:29 +00:00
|
|
|
|
_glfw.wl.xkb.shiftMask =
|
2016-10-11 00:44:22 +00:00
|
|
|
|
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Shift");
|
2016-10-01 19:05:29 +00:00
|
|
|
|
_glfw.wl.xkb.superMask =
|
2016-10-11 00:44:22 +00:00
|
|
|
|
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4");
|
2017-11-29 19:42:37 +00:00
|
|
|
|
_glfw.wl.xkb.capsLockMask =
|
|
|
|
|
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Lock");
|
|
|
|
|
_glfw.wl.xkb.numLockMask =
|
|
|
|
|
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2");
|
2014-06-29 10:29:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void keyboardHandleEnter(void* data,
|
|
|
|
|
struct wl_keyboard* keyboard,
|
|
|
|
|
uint32_t serial,
|
|
|
|
|
struct wl_surface* surface,
|
|
|
|
|
struct wl_array* keys)
|
|
|
|
|
{
|
2018-01-24 12:36:01 +00:00
|
|
|
|
// Happens in the case we just destroyed the surface.
|
|
|
|
|
if (!surface)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-06-29 21:09:21 +00:00
|
|
|
|
_GLFWwindow* window = wl_surface_get_user_data(surface);
|
2017-12-19 18:06:40 +00:00
|
|
|
|
if (!window)
|
2017-12-19 19:58:03 +00:00
|
|
|
|
{
|
|
|
|
|
window = findWindowFromDecorationSurface(surface, NULL);
|
|
|
|
|
if (!window)
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-06-29 21:09:21 +00:00
|
|
|
|
|
2014-09-23 17:24:33 +00:00
|
|
|
|
_glfw.wl.serial = serial;
|
2014-06-29 21:09:21 +00:00
|
|
|
|
_glfw.wl.keyboardFocus = window;
|
2015-08-23 17:30:04 +00:00
|
|
|
|
_glfwInputWindowFocus(window, GLFW_TRUE);
|
2014-06-29 10:29:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void keyboardHandleLeave(void* data,
|
|
|
|
|
struct wl_keyboard* keyboard,
|
|
|
|
|
uint32_t serial,
|
|
|
|
|
struct wl_surface* surface)
|
|
|
|
|
{
|
2014-06-29 21:09:21 +00:00
|
|
|
|
_GLFWwindow* window = _glfw.wl.keyboardFocus;
|
|
|
|
|
|
2014-07-26 20:55:43 +00:00
|
|
|
|
if (!window)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-12-26 23:52:24 +00:00
|
|
|
|
struct itimerspec timer = {};
|
|
|
|
|
timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL);
|
|
|
|
|
|
2014-09-23 17:24:33 +00:00
|
|
|
|
_glfw.wl.serial = serial;
|
2014-06-29 21:09:21 +00:00
|
|
|
|
_glfw.wl.keyboardFocus = NULL;
|
2015-08-23 17:30:04 +00:00
|
|
|
|
_glfwInputWindowFocus(window, GLFW_FALSE);
|
2014-06-29 21:09:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int toGLFWKeyCode(uint32_t key)
|
|
|
|
|
{
|
2016-09-07 13:43:39 +00:00
|
|
|
|
if (key < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0]))
|
|
|
|
|
return _glfw.wl.keycodes[key];
|
2015-11-12 14:06:46 +00:00
|
|
|
|
|
|
|
|
|
return GLFW_KEY_UNKNOWN;
|
2014-06-29 10:29:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-16 16:42:11 +00:00
|
|
|
|
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
2016-10-10 23:02:15 +00:00
|
|
|
|
static xkb_keysym_t composeSymbol(xkb_keysym_t sym)
|
|
|
|
|
{
|
2017-08-07 23:33:20 +00:00
|
|
|
|
if (sym == XKB_KEY_NoSymbol || !_glfw.wl.xkb.composeState)
|
2016-10-10 23:02:15 +00:00
|
|
|
|
return sym;
|
|
|
|
|
if (xkb_compose_state_feed(_glfw.wl.xkb.composeState, sym)
|
|
|
|
|
!= XKB_COMPOSE_FEED_ACCEPTED)
|
|
|
|
|
return sym;
|
|
|
|
|
switch (xkb_compose_state_get_status(_glfw.wl.xkb.composeState))
|
|
|
|
|
{
|
|
|
|
|
case XKB_COMPOSE_COMPOSED:
|
|
|
|
|
return xkb_compose_state_get_one_sym(_glfw.wl.xkb.composeState);
|
|
|
|
|
case XKB_COMPOSE_COMPOSING:
|
|
|
|
|
case XKB_COMPOSE_CANCELLED:
|
|
|
|
|
return XKB_KEY_NoSymbol;
|
|
|
|
|
case XKB_COMPOSE_NOTHING:
|
|
|
|
|
default:
|
|
|
|
|
return sym;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-16 16:42:11 +00:00
|
|
|
|
#endif
|
2016-10-10 23:02:15 +00:00
|
|
|
|
|
2018-02-12 08:32:34 +00:00
|
|
|
|
static GLFWbool inputChar(_GLFWwindow* window, uint32_t key)
|
2016-09-11 05:17:59 +00:00
|
|
|
|
{
|
2021-12-30 18:09:53 +00:00
|
|
|
|
uint32_t code, numSyms, codepoint;
|
2016-09-11 05:17:59 +00:00
|
|
|
|
const xkb_keysym_t *syms;
|
2016-10-10 23:02:15 +00:00
|
|
|
|
xkb_keysym_t sym;
|
2016-09-11 05:17:59 +00:00
|
|
|
|
|
|
|
|
|
code = key + 8;
|
2016-10-01 19:05:29 +00:00
|
|
|
|
numSyms = xkb_state_key_get_syms(_glfw.wl.xkb.state, code, &syms);
|
2016-09-11 05:17:59 +00:00
|
|
|
|
|
2016-10-01 19:05:29 +00:00
|
|
|
|
if (numSyms == 1)
|
2016-09-11 05:17:59 +00:00
|
|
|
|
{
|
2017-11-16 16:42:11 +00:00
|
|
|
|
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
2016-10-10 23:02:15 +00:00
|
|
|
|
sym = composeSymbol(syms[0]);
|
2017-11-16 16:42:11 +00:00
|
|
|
|
#else
|
|
|
|
|
sym = syms[0];
|
|
|
|
|
#endif
|
2021-12-30 18:09:53 +00:00
|
|
|
|
codepoint = _glfwKeySym2Unicode(sym);
|
|
|
|
|
if (codepoint != GLFW_INVALID_CODEPOINT)
|
2016-09-11 05:17:59 +00:00
|
|
|
|
{
|
|
|
|
|
const int mods = _glfw.wl.xkb.modifiers;
|
|
|
|
|
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
|
2021-12-30 18:09:53 +00:00
|
|
|
|
_glfwInputChar(window, codepoint, mods, plain);
|
2016-09-11 05:17:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-12 08:32:34 +00:00
|
|
|
|
|
2021-06-01 20:40:44 +00:00
|
|
|
|
return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, code);
|
2016-09-11 05:17:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 10:29:00 +00:00
|
|
|
|
static void keyboardHandleKey(void* data,
|
|
|
|
|
struct wl_keyboard* keyboard,
|
|
|
|
|
uint32_t serial,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
uint32_t key,
|
|
|
|
|
uint32_t state)
|
|
|
|
|
{
|
2014-06-29 21:09:21 +00:00
|
|
|
|
int keyCode;
|
|
|
|
|
int action;
|
|
|
|
|
_GLFWwindow* window = _glfw.wl.keyboardFocus;
|
2018-02-12 08:32:34 +00:00
|
|
|
|
GLFWbool shouldRepeat;
|
2018-01-30 15:22:25 +00:00
|
|
|
|
struct itimerspec timer = {};
|
2014-06-29 21:09:21 +00:00
|
|
|
|
|
2014-07-26 20:55:43 +00:00
|
|
|
|
if (!window)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-06-29 21:09:21 +00:00
|
|
|
|
keyCode = toGLFWKeyCode(key);
|
|
|
|
|
action = state == WL_KEYBOARD_KEY_STATE_PRESSED
|
|
|
|
|
? GLFW_PRESS : GLFW_RELEASE;
|
|
|
|
|
|
2014-09-23 17:24:33 +00:00
|
|
|
|
_glfw.wl.serial = serial;
|
2014-06-29 21:09:21 +00:00
|
|
|
|
_glfwInputKey(window, keyCode, key, action,
|
|
|
|
|
_glfw.wl.xkb.modifiers);
|
|
|
|
|
|
2016-09-11 05:17:59 +00:00
|
|
|
|
if (action == GLFW_PRESS)
|
2018-01-30 15:22:25 +00:00
|
|
|
|
{
|
2018-02-12 08:32:34 +00:00
|
|
|
|
shouldRepeat = inputChar(window, key);
|
2018-01-30 15:22:25 +00:00
|
|
|
|
|
2018-02-12 08:32:34 +00:00
|
|
|
|
if (shouldRepeat && _glfw.wl.keyboardRepeatRate > 0)
|
2018-01-30 15:22:25 +00:00
|
|
|
|
{
|
|
|
|
|
_glfw.wl.keyboardLastKey = keyCode;
|
|
|
|
|
_glfw.wl.keyboardLastScancode = key;
|
2019-02-20 14:56:04 +00:00
|
|
|
|
if (_glfw.wl.keyboardRepeatRate > 1)
|
|
|
|
|
timer.it_interval.tv_nsec = 1000000000 / _glfw.wl.keyboardRepeatRate;
|
|
|
|
|
else
|
|
|
|
|
timer.it_interval.tv_sec = 1;
|
2018-01-30 15:22:25 +00:00
|
|
|
|
timer.it_value.tv_sec = _glfw.wl.keyboardRepeatDelay / 1000;
|
|
|
|
|
timer.it_value.tv_nsec = (_glfw.wl.keyboardRepeatDelay % 1000) * 1000000;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL);
|
2014-06-29 10:29:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void keyboardHandleModifiers(void* data,
|
|
|
|
|
struct wl_keyboard* keyboard,
|
|
|
|
|
uint32_t serial,
|
|
|
|
|
uint32_t modsDepressed,
|
|
|
|
|
uint32_t modsLatched,
|
|
|
|
|
uint32_t modsLocked,
|
|
|
|
|
uint32_t group)
|
|
|
|
|
{
|
2014-06-29 21:09:21 +00:00
|
|
|
|
xkb_mod_mask_t mask;
|
|
|
|
|
unsigned int modifiers = 0;
|
|
|
|
|
|
2014-09-23 17:24:33 +00:00
|
|
|
|
_glfw.wl.serial = serial;
|
|
|
|
|
|
2014-06-29 21:09:21 +00:00
|
|
|
|
if (!_glfw.wl.xkb.keymap)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
xkb_state_update_mask(_glfw.wl.xkb.state,
|
|
|
|
|
modsDepressed,
|
|
|
|
|
modsLatched,
|
|
|
|
|
modsLocked,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
group);
|
|
|
|
|
|
|
|
|
|
mask = xkb_state_serialize_mods(_glfw.wl.xkb.state,
|
2016-10-11 00:44:22 +00:00
|
|
|
|
XKB_STATE_MODS_DEPRESSED |
|
|
|
|
|
XKB_STATE_LAYOUT_DEPRESSED |
|
|
|
|
|
XKB_STATE_MODS_LATCHED |
|
|
|
|
|
XKB_STATE_LAYOUT_LATCHED);
|
2016-10-01 19:05:29 +00:00
|
|
|
|
if (mask & _glfw.wl.xkb.controlMask)
|
2014-06-29 21:09:21 +00:00
|
|
|
|
modifiers |= GLFW_MOD_CONTROL;
|
2016-10-01 19:05:29 +00:00
|
|
|
|
if (mask & _glfw.wl.xkb.altMask)
|
2014-06-29 21:09:21 +00:00
|
|
|
|
modifiers |= GLFW_MOD_ALT;
|
2016-10-01 19:05:29 +00:00
|
|
|
|
if (mask & _glfw.wl.xkb.shiftMask)
|
2014-06-29 21:09:21 +00:00
|
|
|
|
modifiers |= GLFW_MOD_SHIFT;
|
2016-10-01 19:05:29 +00:00
|
|
|
|
if (mask & _glfw.wl.xkb.superMask)
|
2014-06-29 21:09:21 +00:00
|
|
|
|
modifiers |= GLFW_MOD_SUPER;
|
2017-11-29 19:42:37 +00:00
|
|
|
|
if (mask & _glfw.wl.xkb.capsLockMask)
|
|
|
|
|
modifiers |= GLFW_MOD_CAPS_LOCK;
|
|
|
|
|
if (mask & _glfw.wl.xkb.numLockMask)
|
|
|
|
|
modifiers |= GLFW_MOD_NUM_LOCK;
|
2014-06-29 21:09:21 +00:00
|
|
|
|
_glfw.wl.xkb.modifiers = modifiers;
|
2014-06-29 10:29:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-11 20:24:38 +00:00
|
|
|
|
#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
|
2017-11-17 01:24:01 +00:00
|
|
|
|
static void keyboardHandleRepeatInfo(void* data,
|
|
|
|
|
struct wl_keyboard* keyboard,
|
|
|
|
|
int32_t rate,
|
|
|
|
|
int32_t delay)
|
|
|
|
|
{
|
|
|
|
|
if (keyboard != _glfw.wl.keyboard)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_glfw.wl.keyboardRepeatRate = rate;
|
|
|
|
|
_glfw.wl.keyboardRepeatDelay = delay;
|
|
|
|
|
}
|
2018-02-11 20:24:38 +00:00
|
|
|
|
#endif
|
2017-11-17 01:24:01 +00:00
|
|
|
|
|
2014-06-29 10:29:00 +00:00
|
|
|
|
static const struct wl_keyboard_listener keyboardListener = {
|
|
|
|
|
keyboardHandleKeymap,
|
|
|
|
|
keyboardHandleEnter,
|
|
|
|
|
keyboardHandleLeave,
|
|
|
|
|
keyboardHandleKey,
|
|
|
|
|
keyboardHandleModifiers,
|
2018-02-11 20:24:38 +00:00
|
|
|
|
#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
|
2017-11-17 01:24:01 +00:00
|
|
|
|
keyboardHandleRepeatInfo,
|
2018-02-11 20:24:38 +00:00
|
|
|
|
#endif
|
2014-06-29 10:29:00 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void seatHandleCapabilities(void* data,
|
|
|
|
|
struct wl_seat* seat,
|
|
|
|
|
enum wl_seat_capability caps)
|
|
|
|
|
{
|
|
|
|
|
if ((caps & WL_SEAT_CAPABILITY_POINTER) && !_glfw.wl.pointer)
|
|
|
|
|
{
|
|
|
|
|
_glfw.wl.pointer = wl_seat_get_pointer(seat);
|
|
|
|
|
wl_pointer_add_listener(_glfw.wl.pointer, &pointerListener, NULL);
|
|
|
|
|
}
|
|
|
|
|
else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer)
|
|
|
|
|
{
|
|
|
|
|
wl_pointer_destroy(_glfw.wl.pointer);
|
|
|
|
|
_glfw.wl.pointer = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !_glfw.wl.keyboard)
|
|
|
|
|
{
|
|
|
|
|
_glfw.wl.keyboard = wl_seat_get_keyboard(seat);
|
|
|
|
|
wl_keyboard_add_listener(_glfw.wl.keyboard, &keyboardListener, NULL);
|
|
|
|
|
}
|
|
|
|
|
else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard)
|
|
|
|
|
{
|
|
|
|
|
wl_keyboard_destroy(_glfw.wl.keyboard);
|
|
|
|
|
_glfw.wl.keyboard = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-17 01:24:01 +00:00
|
|
|
|
static void seatHandleName(void* data,
|
|
|
|
|
struct wl_seat* seat,
|
|
|
|
|
const char* name)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 10:29:00 +00:00
|
|
|
|
static const struct wl_seat_listener seatListener = {
|
2017-11-17 01:24:01 +00:00
|
|
|
|
seatHandleCapabilities,
|
|
|
|
|
seatHandleName,
|
2014-06-29 10:29:00 +00:00
|
|
|
|
};
|
|
|
|
|
|
2018-10-10 17:06:11 +00:00
|
|
|
|
static void dataOfferHandleOffer(void* data,
|
|
|
|
|
struct wl_data_offer* dataOffer,
|
|
|
|
|
const char* mimeType)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct wl_data_offer_listener dataOfferListener = {
|
|
|
|
|
dataOfferHandleOffer,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void dataDeviceHandleDataOffer(void* data,
|
|
|
|
|
struct wl_data_device* dataDevice,
|
|
|
|
|
struct wl_data_offer* id)
|
|
|
|
|
{
|
|
|
|
|
if (_glfw.wl.dataOffer)
|
|
|
|
|
wl_data_offer_destroy(_glfw.wl.dataOffer);
|
|
|
|
|
|
|
|
|
|
_glfw.wl.dataOffer = id;
|
|
|
|
|
wl_data_offer_add_listener(_glfw.wl.dataOffer, &dataOfferListener, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void dataDeviceHandleEnter(void* data,
|
|
|
|
|
struct wl_data_device* dataDevice,
|
|
|
|
|
uint32_t serial,
|
|
|
|
|
struct wl_surface *surface,
|
|
|
|
|
wl_fixed_t x,
|
|
|
|
|
wl_fixed_t y,
|
|
|
|
|
struct wl_data_offer *id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void dataDeviceHandleLeave(void* data,
|
|
|
|
|
struct wl_data_device* dataDevice)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void dataDeviceHandleMotion(void* data,
|
|
|
|
|
struct wl_data_device* dataDevice,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
wl_fixed_t x,
|
|
|
|
|
wl_fixed_t y)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void dataDeviceHandleDrop(void* data,
|
|
|
|
|
struct wl_data_device* dataDevice)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void dataDeviceHandleSelection(void* data,
|
|
|
|
|
struct wl_data_device* dataDevice,
|
|
|
|
|
struct wl_data_offer* id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct wl_data_device_listener dataDeviceListener = {
|
|
|
|
|
dataDeviceHandleDataOffer,
|
|
|
|
|
dataDeviceHandleEnter,
|
|
|
|
|
dataDeviceHandleLeave,
|
|
|
|
|
dataDeviceHandleMotion,
|
|
|
|
|
dataDeviceHandleDrop,
|
|
|
|
|
dataDeviceHandleSelection,
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-03 02:59:48 +00:00
|
|
|
|
static void wmBaseHandlePing(void* data,
|
|
|
|
|
struct xdg_wm_base* wmBase,
|
|
|
|
|
uint32_t serial)
|
|
|
|
|
{
|
|
|
|
|
xdg_wm_base_pong(wmBase, serial);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct xdg_wm_base_listener wmBaseListener = {
|
|
|
|
|
wmBaseHandlePing
|
|
|
|
|
};
|
|
|
|
|
|
2014-03-17 21:53:43 +00:00
|
|
|
|
static void registryHandleGlobal(void* data,
|
|
|
|
|
struct wl_registry* registry,
|
|
|
|
|
uint32_t name,
|
|
|
|
|
const char* interface,
|
|
|
|
|
uint32_t version)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(interface, "wl_compositor") == 0)
|
|
|
|
|
{
|
2016-10-01 19:05:29 +00:00
|
|
|
|
_glfw.wl.compositorVersion = min(3, version);
|
2014-03-19 15:20:32 +00:00
|
|
|
|
_glfw.wl.compositor =
|
2015-10-10 15:35:06 +00:00
|
|
|
|
wl_registry_bind(registry, name, &wl_compositor_interface,
|
2016-10-01 19:05:29 +00:00
|
|
|
|
_glfw.wl.compositorVersion);
|
2014-03-17 21:53:43 +00:00
|
|
|
|
}
|
2017-12-19 18:04:52 +00:00
|
|
|
|
else if (strcmp(interface, "wl_subcompositor") == 0)
|
|
|
|
|
{
|
|
|
|
|
_glfw.wl.subcompositor =
|
|
|
|
|
wl_registry_bind(registry, name, &wl_subcompositor_interface, 1);
|
|
|
|
|
}
|
2014-09-09 14:37:55 +00:00
|
|
|
|
else if (strcmp(interface, "wl_shm") == 0)
|
|
|
|
|
{
|
|
|
|
|
_glfw.wl.shm =
|
|
|
|
|
wl_registry_bind(registry, name, &wl_shm_interface, 1);
|
|
|
|
|
}
|
2014-03-17 21:53:43 +00:00
|
|
|
|
else if (strcmp(interface, "wl_shell") == 0)
|
|
|
|
|
{
|
2014-03-19 15:20:32 +00:00
|
|
|
|
_glfw.wl.shell =
|
2014-06-29 10:22:23 +00:00
|
|
|
|
wl_registry_bind(registry, name, &wl_shell_interface, 1);
|
2014-03-17 21:53:43 +00:00
|
|
|
|
}
|
|
|
|
|
else if (strcmp(interface, "wl_output") == 0)
|
|
|
|
|
{
|
2015-12-03 17:16:46 +00:00
|
|
|
|
_glfwAddOutputWayland(name, version);
|
2014-03-17 21:53:43 +00:00
|
|
|
|
}
|
2014-06-29 10:29:00 +00:00
|
|
|
|
else if (strcmp(interface, "wl_seat") == 0)
|
|
|
|
|
{
|
|
|
|
|
if (!_glfw.wl.seat)
|
|
|
|
|
{
|
2017-11-17 01:24:01 +00:00
|
|
|
|
_glfw.wl.seatVersion = min(4, version);
|
2014-06-29 10:29:00 +00:00
|
|
|
|
_glfw.wl.seat =
|
2017-11-17 01:24:01 +00:00
|
|
|
|
wl_registry_bind(registry, name, &wl_seat_interface,
|
|
|
|
|
_glfw.wl.seatVersion);
|
2014-06-29 10:29:00 +00:00
|
|
|
|
wl_seat_add_listener(_glfw.wl.seat, &seatListener, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-10 17:06:11 +00:00
|
|
|
|
else if (strcmp(interface, "wl_data_device_manager") == 0)
|
|
|
|
|
{
|
|
|
|
|
if (!_glfw.wl.dataDeviceManager)
|
|
|
|
|
{
|
|
|
|
|
_glfw.wl.dataDeviceManager =
|
|
|
|
|
wl_registry_bind(registry, name,
|
|
|
|
|
&wl_data_device_manager_interface, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-03 02:59:48 +00:00
|
|
|
|
else if (strcmp(interface, "xdg_wm_base") == 0)
|
|
|
|
|
{
|
|
|
|
|
_glfw.wl.wmBase =
|
|
|
|
|
wl_registry_bind(registry, name, &xdg_wm_base_interface, 1);
|
|
|
|
|
xdg_wm_base_add_listener(_glfw.wl.wmBase, &wmBaseListener, NULL);
|
|
|
|
|
}
|
2018-10-01 13:05:55 +00:00
|
|
|
|
else if (strcmp(interface, "zxdg_decoration_manager_v1") == 0)
|
|
|
|
|
{
|
|
|
|
|
_glfw.wl.decorationManager =
|
|
|
|
|
wl_registry_bind(registry, name,
|
|
|
|
|
&zxdg_decoration_manager_v1_interface,
|
|
|
|
|
1);
|
|
|
|
|
}
|
2017-12-19 18:04:28 +00:00
|
|
|
|
else if (strcmp(interface, "wp_viewporter") == 0)
|
|
|
|
|
{
|
|
|
|
|
_glfw.wl.viewporter =
|
|
|
|
|
wl_registry_bind(registry, name, &wp_viewporter_interface, 1);
|
|
|
|
|
}
|
2015-12-09 07:29:37 +00:00
|
|
|
|
else if (strcmp(interface, "zwp_relative_pointer_manager_v1") == 0)
|
|
|
|
|
{
|
|
|
|
|
_glfw.wl.relativePointerManager =
|
|
|
|
|
wl_registry_bind(registry, name,
|
|
|
|
|
&zwp_relative_pointer_manager_v1_interface,
|
|
|
|
|
1);
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(interface, "zwp_pointer_constraints_v1") == 0)
|
|
|
|
|
{
|
|
|
|
|
_glfw.wl.pointerConstraints =
|
|
|
|
|
wl_registry_bind(registry, name,
|
|
|
|
|
&zwp_pointer_constraints_v1_interface,
|
|
|
|
|
1);
|
|
|
|
|
}
|
2017-02-17 15:52:50 +00:00
|
|
|
|
else if (strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0)
|
|
|
|
|
{
|
|
|
|
|
_glfw.wl.idleInhibitManager =
|
|
|
|
|
wl_registry_bind(registry, name,
|
|
|
|
|
&zwp_idle_inhibit_manager_v1_interface,
|
|
|
|
|
1);
|
|
|
|
|
}
|
2014-03-17 21:53:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void registryHandleGlobalRemove(void *data,
|
|
|
|
|
struct wl_registry *registry,
|
|
|
|
|
uint32_t name)
|
|
|
|
|
{
|
2018-02-24 21:18:39 +00:00
|
|
|
|
int i;
|
|
|
|
|
_GLFWmonitor* monitor;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < _glfw.monitorCount; ++i)
|
|
|
|
|
{
|
|
|
|
|
monitor = _glfw.monitors[i];
|
|
|
|
|
if (monitor->wl.name == name)
|
|
|
|
|
{
|
|
|
|
|
_glfwInputMonitor(monitor, GLFW_DISCONNECTED, 0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-17 21:53:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const struct wl_registry_listener registryListener = {
|
|
|
|
|
registryHandleGlobal,
|
|
|
|
|
registryHandleGlobalRemove
|
|
|
|
|
};
|
|
|
|
|
|
2015-11-12 14:06:46 +00:00
|
|
|
|
// Create key code translation tables
|
|
|
|
|
//
|
|
|
|
|
static void createKeyTables(void)
|
|
|
|
|
{
|
2016-08-14 12:42:47 +00:00
|
|
|
|
int scancode;
|
|
|
|
|
|
2016-09-07 13:43:39 +00:00
|
|
|
|
memset(_glfw.wl.keycodes, -1, sizeof(_glfw.wl.keycodes));
|
|
|
|
|
memset(_glfw.wl.scancodes, -1, sizeof(_glfw.wl.scancodes));
|
|
|
|
|
|
|
|
|
|
_glfw.wl.keycodes[KEY_GRAVE] = GLFW_KEY_GRAVE_ACCENT;
|
|
|
|
|
_glfw.wl.keycodes[KEY_1] = GLFW_KEY_1;
|
|
|
|
|
_glfw.wl.keycodes[KEY_2] = GLFW_KEY_2;
|
|
|
|
|
_glfw.wl.keycodes[KEY_3] = GLFW_KEY_3;
|
|
|
|
|
_glfw.wl.keycodes[KEY_4] = GLFW_KEY_4;
|
|
|
|
|
_glfw.wl.keycodes[KEY_5] = GLFW_KEY_5;
|
|
|
|
|
_glfw.wl.keycodes[KEY_6] = GLFW_KEY_6;
|
|
|
|
|
_glfw.wl.keycodes[KEY_7] = GLFW_KEY_7;
|
|
|
|
|
_glfw.wl.keycodes[KEY_8] = GLFW_KEY_8;
|
|
|
|
|
_glfw.wl.keycodes[KEY_9] = GLFW_KEY_9;
|
|
|
|
|
_glfw.wl.keycodes[KEY_0] = GLFW_KEY_0;
|
2017-01-26 16:00:57 +00:00
|
|
|
|
_glfw.wl.keycodes[KEY_SPACE] = GLFW_KEY_SPACE;
|
2016-09-07 13:43:39 +00:00
|
|
|
|
_glfw.wl.keycodes[KEY_MINUS] = GLFW_KEY_MINUS;
|
|
|
|
|
_glfw.wl.keycodes[KEY_EQUAL] = GLFW_KEY_EQUAL;
|
|
|
|
|
_glfw.wl.keycodes[KEY_Q] = GLFW_KEY_Q;
|
|
|
|
|
_glfw.wl.keycodes[KEY_W] = GLFW_KEY_W;
|
|
|
|
|
_glfw.wl.keycodes[KEY_E] = GLFW_KEY_E;
|
|
|
|
|
_glfw.wl.keycodes[KEY_R] = GLFW_KEY_R;
|
|
|
|
|
_glfw.wl.keycodes[KEY_T] = GLFW_KEY_T;
|
|
|
|
|
_glfw.wl.keycodes[KEY_Y] = GLFW_KEY_Y;
|
|
|
|
|
_glfw.wl.keycodes[KEY_U] = GLFW_KEY_U;
|
|
|
|
|
_glfw.wl.keycodes[KEY_I] = GLFW_KEY_I;
|
|
|
|
|
_glfw.wl.keycodes[KEY_O] = GLFW_KEY_O;
|
|
|
|
|
_glfw.wl.keycodes[KEY_P] = GLFW_KEY_P;
|
|
|
|
|
_glfw.wl.keycodes[KEY_LEFTBRACE] = GLFW_KEY_LEFT_BRACKET;
|
|
|
|
|
_glfw.wl.keycodes[KEY_RIGHTBRACE] = GLFW_KEY_RIGHT_BRACKET;
|
|
|
|
|
_glfw.wl.keycodes[KEY_A] = GLFW_KEY_A;
|
|
|
|
|
_glfw.wl.keycodes[KEY_S] = GLFW_KEY_S;
|
|
|
|
|
_glfw.wl.keycodes[KEY_D] = GLFW_KEY_D;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F] = GLFW_KEY_F;
|
|
|
|
|
_glfw.wl.keycodes[KEY_G] = GLFW_KEY_G;
|
|
|
|
|
_glfw.wl.keycodes[KEY_H] = GLFW_KEY_H;
|
|
|
|
|
_glfw.wl.keycodes[KEY_J] = GLFW_KEY_J;
|
|
|
|
|
_glfw.wl.keycodes[KEY_K] = GLFW_KEY_K;
|
|
|
|
|
_glfw.wl.keycodes[KEY_L] = GLFW_KEY_L;
|
|
|
|
|
_glfw.wl.keycodes[KEY_SEMICOLON] = GLFW_KEY_SEMICOLON;
|
|
|
|
|
_glfw.wl.keycodes[KEY_APOSTROPHE] = GLFW_KEY_APOSTROPHE;
|
|
|
|
|
_glfw.wl.keycodes[KEY_Z] = GLFW_KEY_Z;
|
|
|
|
|
_glfw.wl.keycodes[KEY_X] = GLFW_KEY_X;
|
|
|
|
|
_glfw.wl.keycodes[KEY_C] = GLFW_KEY_C;
|
|
|
|
|
_glfw.wl.keycodes[KEY_V] = GLFW_KEY_V;
|
|
|
|
|
_glfw.wl.keycodes[KEY_B] = GLFW_KEY_B;
|
|
|
|
|
_glfw.wl.keycodes[KEY_N] = GLFW_KEY_N;
|
|
|
|
|
_glfw.wl.keycodes[KEY_M] = GLFW_KEY_M;
|
|
|
|
|
_glfw.wl.keycodes[KEY_COMMA] = GLFW_KEY_COMMA;
|
|
|
|
|
_glfw.wl.keycodes[KEY_DOT] = GLFW_KEY_PERIOD;
|
|
|
|
|
_glfw.wl.keycodes[KEY_SLASH] = GLFW_KEY_SLASH;
|
|
|
|
|
_glfw.wl.keycodes[KEY_BACKSLASH] = GLFW_KEY_BACKSLASH;
|
|
|
|
|
_glfw.wl.keycodes[KEY_ESC] = GLFW_KEY_ESCAPE;
|
|
|
|
|
_glfw.wl.keycodes[KEY_TAB] = GLFW_KEY_TAB;
|
|
|
|
|
_glfw.wl.keycodes[KEY_LEFTSHIFT] = GLFW_KEY_LEFT_SHIFT;
|
|
|
|
|
_glfw.wl.keycodes[KEY_RIGHTSHIFT] = GLFW_KEY_RIGHT_SHIFT;
|
|
|
|
|
_glfw.wl.keycodes[KEY_LEFTCTRL] = GLFW_KEY_LEFT_CONTROL;
|
|
|
|
|
_glfw.wl.keycodes[KEY_RIGHTCTRL] = GLFW_KEY_RIGHT_CONTROL;
|
|
|
|
|
_glfw.wl.keycodes[KEY_LEFTALT] = GLFW_KEY_LEFT_ALT;
|
|
|
|
|
_glfw.wl.keycodes[KEY_RIGHTALT] = GLFW_KEY_RIGHT_ALT;
|
|
|
|
|
_glfw.wl.keycodes[KEY_LEFTMETA] = GLFW_KEY_LEFT_SUPER;
|
|
|
|
|
_glfw.wl.keycodes[KEY_RIGHTMETA] = GLFW_KEY_RIGHT_SUPER;
|
2021-12-30 01:59:15 +00:00
|
|
|
|
_glfw.wl.keycodes[KEY_COMPOSE] = GLFW_KEY_MENU;
|
2016-09-07 13:43:39 +00:00
|
|
|
|
_glfw.wl.keycodes[KEY_NUMLOCK] = GLFW_KEY_NUM_LOCK;
|
|
|
|
|
_glfw.wl.keycodes[KEY_CAPSLOCK] = GLFW_KEY_CAPS_LOCK;
|
|
|
|
|
_glfw.wl.keycodes[KEY_PRINT] = GLFW_KEY_PRINT_SCREEN;
|
|
|
|
|
_glfw.wl.keycodes[KEY_SCROLLLOCK] = GLFW_KEY_SCROLL_LOCK;
|
|
|
|
|
_glfw.wl.keycodes[KEY_PAUSE] = GLFW_KEY_PAUSE;
|
|
|
|
|
_glfw.wl.keycodes[KEY_DELETE] = GLFW_KEY_DELETE;
|
|
|
|
|
_glfw.wl.keycodes[KEY_BACKSPACE] = GLFW_KEY_BACKSPACE;
|
|
|
|
|
_glfw.wl.keycodes[KEY_ENTER] = GLFW_KEY_ENTER;
|
|
|
|
|
_glfw.wl.keycodes[KEY_HOME] = GLFW_KEY_HOME;
|
|
|
|
|
_glfw.wl.keycodes[KEY_END] = GLFW_KEY_END;
|
|
|
|
|
_glfw.wl.keycodes[KEY_PAGEUP] = GLFW_KEY_PAGE_UP;
|
|
|
|
|
_glfw.wl.keycodes[KEY_PAGEDOWN] = GLFW_KEY_PAGE_DOWN;
|
|
|
|
|
_glfw.wl.keycodes[KEY_INSERT] = GLFW_KEY_INSERT;
|
|
|
|
|
_glfw.wl.keycodes[KEY_LEFT] = GLFW_KEY_LEFT;
|
|
|
|
|
_glfw.wl.keycodes[KEY_RIGHT] = GLFW_KEY_RIGHT;
|
|
|
|
|
_glfw.wl.keycodes[KEY_DOWN] = GLFW_KEY_DOWN;
|
|
|
|
|
_glfw.wl.keycodes[KEY_UP] = GLFW_KEY_UP;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F1] = GLFW_KEY_F1;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F2] = GLFW_KEY_F2;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F3] = GLFW_KEY_F3;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F4] = GLFW_KEY_F4;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F5] = GLFW_KEY_F5;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F6] = GLFW_KEY_F6;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F7] = GLFW_KEY_F7;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F8] = GLFW_KEY_F8;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F9] = GLFW_KEY_F9;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F10] = GLFW_KEY_F10;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F11] = GLFW_KEY_F11;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F12] = GLFW_KEY_F12;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F13] = GLFW_KEY_F13;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F14] = GLFW_KEY_F14;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F15] = GLFW_KEY_F15;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F16] = GLFW_KEY_F16;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F17] = GLFW_KEY_F17;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F18] = GLFW_KEY_F18;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F19] = GLFW_KEY_F19;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F20] = GLFW_KEY_F20;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F21] = GLFW_KEY_F21;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F22] = GLFW_KEY_F22;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F23] = GLFW_KEY_F23;
|
|
|
|
|
_glfw.wl.keycodes[KEY_F24] = GLFW_KEY_F24;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KPSLASH] = GLFW_KEY_KP_DIVIDE;
|
2021-12-30 01:59:15 +00:00
|
|
|
|
_glfw.wl.keycodes[KEY_KPASTERISK] = GLFW_KEY_KP_MULTIPLY;
|
2016-09-07 13:43:39 +00:00
|
|
|
|
_glfw.wl.keycodes[KEY_KPMINUS] = GLFW_KEY_KP_SUBTRACT;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KPPLUS] = GLFW_KEY_KP_ADD;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KP0] = GLFW_KEY_KP_0;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KP1] = GLFW_KEY_KP_1;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KP2] = GLFW_KEY_KP_2;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KP3] = GLFW_KEY_KP_3;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KP4] = GLFW_KEY_KP_4;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KP5] = GLFW_KEY_KP_5;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KP6] = GLFW_KEY_KP_6;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KP7] = GLFW_KEY_KP_7;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KP8] = GLFW_KEY_KP_8;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KP9] = GLFW_KEY_KP_9;
|
2021-12-30 01:59:15 +00:00
|
|
|
|
_glfw.wl.keycodes[KEY_KPDOT] = GLFW_KEY_KP_DECIMAL;
|
2016-09-07 13:43:39 +00:00
|
|
|
|
_glfw.wl.keycodes[KEY_KPEQUAL] = GLFW_KEY_KP_EQUAL;
|
|
|
|
|
_glfw.wl.keycodes[KEY_KPENTER] = GLFW_KEY_KP_ENTER;
|
2021-12-30 01:59:15 +00:00
|
|
|
|
_glfw.wl.keycodes[KEY_102ND] = GLFW_KEY_WORLD_2;
|
2016-08-14 12:42:47 +00:00
|
|
|
|
|
|
|
|
|
for (scancode = 0; scancode < 256; scancode++)
|
|
|
|
|
{
|
2016-09-07 13:43:39 +00:00
|
|
|
|
if (_glfw.wl.keycodes[scancode] > 0)
|
|
|
|
|
_glfw.wl.scancodes[_glfw.wl.keycodes[scancode]] = scancode;
|
2016-08-14 12:42:47 +00:00
|
|
|
|
}
|
2015-11-12 14:06:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-17 21:53:43 +00:00
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
////// GLFW platform API //////
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
int _glfwPlatformInit(void)
|
|
|
|
|
{
|
2018-10-10 19:49:23 +00:00
|
|
|
|
const char *cursorTheme;
|
|
|
|
|
const char *cursorSizeStr;
|
|
|
|
|
char *cursorSizeEnd;
|
|
|
|
|
long cursorSizeLong;
|
|
|
|
|
int cursorSize;
|
|
|
|
|
|
2018-01-05 20:58:10 +00:00
|
|
|
|
_glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
|
|
|
|
|
if (!_glfw.wl.cursor.handle)
|
|
|
|
|
{
|
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
2018-01-29 01:30:10 +00:00
|
|
|
|
"Wayland: Failed to open libwayland-cursor");
|
2018-01-05 20:58:10 +00:00
|
|
|
|
return GLFW_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_glfw.wl.cursor.theme_load = (PFN_wl_cursor_theme_load)
|
|
|
|
|
_glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_load");
|
|
|
|
|
_glfw.wl.cursor.theme_destroy = (PFN_wl_cursor_theme_destroy)
|
|
|
|
|
_glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy");
|
|
|
|
|
_glfw.wl.cursor.theme_get_cursor = (PFN_wl_cursor_theme_get_cursor)
|
|
|
|
|
_glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor");
|
|
|
|
|
_glfw.wl.cursor.image_get_buffer = (PFN_wl_cursor_image_get_buffer)
|
|
|
|
|
_glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer");
|
|
|
|
|
|
2018-01-05 20:33:40 +00:00
|
|
|
|
_glfw.wl.egl.handle = _glfw_dlopen("libwayland-egl.so.1");
|
|
|
|
|
if (!_glfw.wl.egl.handle)
|
|
|
|
|
{
|
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
2018-01-29 01:30:10 +00:00
|
|
|
|
"Wayland: Failed to open libwayland-egl");
|
2018-01-05 20:33:40 +00:00
|
|
|
|
return GLFW_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_glfw.wl.egl.window_create = (PFN_wl_egl_window_create)
|
|
|
|
|
_glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_create");
|
|
|
|
|
_glfw.wl.egl.window_destroy = (PFN_wl_egl_window_destroy)
|
|
|
|
|
_glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_destroy");
|
|
|
|
|
_glfw.wl.egl.window_resize = (PFN_wl_egl_window_resize)
|
|
|
|
|
_glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_resize");
|
|
|
|
|
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw.wl.xkb.handle = _glfw_dlopen("libxkbcommon.so.0");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
if (!_glfw.wl.xkb.handle)
|
|
|
|
|
{
|
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
2018-01-29 01:30:10 +00:00
|
|
|
|
"Wayland: Failed to open libxkbcommon");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
return GLFW_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_glfw.wl.xkb.context_new = (PFN_xkb_context_new)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_new");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.context_unref = (PFN_xkb_context_unref)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_unref");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.keymap_new_from_string = (PFN_xkb_keymap_new_from_string)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.keymap_unref = (PFN_xkb_keymap_unref)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_unref");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.keymap_mod_get_index = (PFN_xkb_keymap_mod_get_index)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index");
|
2018-02-12 08:32:13 +00:00
|
|
|
|
_glfw.wl.xkb.keymap_key_repeats = (PFN_xkb_keymap_key_repeats)
|
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats");
|
2021-12-29 22:45:06 +00:00
|
|
|
|
_glfw.wl.xkb.keymap_key_get_syms_by_level = (PFN_xkb_keymap_key_get_syms_by_level)
|
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_key_get_syms_by_level");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.state_new = (PFN_xkb_state_new)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_new");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.state_unref = (PFN_xkb_state_unref)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_unref");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.state_key_get_syms = (PFN_xkb_state_key_get_syms)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_syms");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_update_mask");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_serialize_mods");
|
2021-12-29 22:45:06 +00:00
|
|
|
|
_glfw.wl.xkb.state_key_get_layout = (PFN_xkb_state_key_get_layout)
|
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_layout");
|
2017-11-16 16:42:11 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.compose_table_unref = (PFN_xkb_compose_table_unref)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_unref");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.compose_state_new = (PFN_xkb_compose_state_new)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_new");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.compose_state_unref = (PFN_xkb_compose_state_unref)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_unref");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.compose_state_feed = (PFN_xkb_compose_state_feed)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_feed");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.compose_state_get_status = (PFN_xkb_compose_state_get_status)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_status");
|
2017-08-26 18:25:24 +00:00
|
|
|
|
_glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym)
|
2018-01-05 20:20:40 +00:00
|
|
|
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym");
|
2017-11-16 16:42:11 +00:00
|
|
|
|
#endif
|
2017-08-26 18:25:24 +00:00
|
|
|
|
|
2014-03-19 15:20:32 +00:00
|
|
|
|
_glfw.wl.display = wl_display_connect(NULL);
|
|
|
|
|
if (!_glfw.wl.display)
|
2014-03-19 15:32:50 +00:00
|
|
|
|
{
|
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
|
"Wayland: Failed to connect to display");
|
2015-08-23 17:30:04 +00:00
|
|
|
|
return GLFW_FALSE;
|
2014-03-19 15:32:50 +00:00
|
|
|
|
}
|
2014-03-17 21:53:43 +00:00
|
|
|
|
|
2014-03-19 15:20:32 +00:00
|
|
|
|
_glfw.wl.registry = wl_display_get_registry(_glfw.wl.display);
|
|
|
|
|
wl_registry_add_listener(_glfw.wl.registry, ®istryListener, NULL);
|
2014-03-17 21:53:43 +00:00
|
|
|
|
|
2015-11-12 14:06:46 +00:00
|
|
|
|
createKeyTables();
|
|
|
|
|
|
2014-06-29 21:09:21 +00:00
|
|
|
|
_glfw.wl.xkb.context = xkb_context_new(0);
|
|
|
|
|
if (!_glfw.wl.xkb.context)
|
|
|
|
|
{
|
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
|
"Wayland: Failed to initialize xkb context");
|
2015-08-23 17:30:04 +00:00
|
|
|
|
return GLFW_FALSE;
|
2014-06-29 21:09:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-19 15:11:19 +00:00
|
|
|
|
// Sync so we got all registry objects
|
2014-03-19 15:20:32 +00:00
|
|
|
|
wl_display_roundtrip(_glfw.wl.display);
|
2014-03-17 21:53:43 +00:00
|
|
|
|
|
2014-03-19 15:11:19 +00:00
|
|
|
|
// Sync so we got all initial output events
|
2014-03-19 15:20:32 +00:00
|
|
|
|
wl_display_roundtrip(_glfw.wl.display);
|
2014-03-17 21:53:43 +00:00
|
|
|
|
|
2018-03-19 19:08:22 +00:00
|
|
|
|
#ifdef __linux__
|
2015-12-10 16:02:35 +00:00
|
|
|
|
if (!_glfwInitJoysticksLinux())
|
|
|
|
|
return GLFW_FALSE;
|
2018-03-19 19:08:22 +00:00
|
|
|
|
#endif
|
2015-12-10 16:02:35 +00:00
|
|
|
|
|
2015-12-03 17:16:46 +00:00
|
|
|
|
_glfwInitTimerPOSIX();
|
2014-03-17 21:53:43 +00:00
|
|
|
|
|
2018-01-30 15:22:25 +00:00
|
|
|
|
_glfw.wl.timerfd = -1;
|
|
|
|
|
if (_glfw.wl.seatVersion >= 4)
|
2020-06-05 03:51:25 +00:00
|
|
|
|
_glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
2018-01-30 15:22:25 +00:00
|
|
|
|
|
2014-09-28 19:54:09 +00:00
|
|
|
|
if (_glfw.wl.pointer && _glfw.wl.shm)
|
|
|
|
|
{
|
2018-10-10 19:49:23 +00:00
|
|
|
|
cursorTheme = getenv("XCURSOR_THEME");
|
|
|
|
|
cursorSizeStr = getenv("XCURSOR_SIZE");
|
|
|
|
|
cursorSize = 32;
|
|
|
|
|
if (cursorSizeStr)
|
|
|
|
|
{
|
|
|
|
|
errno = 0;
|
|
|
|
|
cursorSizeLong = strtol(cursorSizeStr, &cursorSizeEnd, 10);
|
|
|
|
|
if (!*cursorSizeEnd && !errno && cursorSizeLong > 0 && cursorSizeLong <= INT_MAX)
|
|
|
|
|
cursorSize = (int)cursorSizeLong;
|
|
|
|
|
}
|
|
|
|
|
_glfw.wl.cursorTheme =
|
|
|
|
|
wl_cursor_theme_load(cursorTheme, cursorSize, _glfw.wl.shm);
|
2014-09-28 19:54:09 +00:00
|
|
|
|
if (!_glfw.wl.cursorTheme)
|
|
|
|
|
{
|
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
2018-01-29 01:30:10 +00:00
|
|
|
|
"Wayland: Unable to load default cursor theme");
|
2015-08-23 17:30:04 +00:00
|
|
|
|
return GLFW_FALSE;
|
2014-09-09 14:37:55 +00:00
|
|
|
|
}
|
2018-09-11 12:18:52 +00:00
|
|
|
|
// If this happens to be NULL, we just fallback to the scale=1 version.
|
2018-10-10 19:49:23 +00:00
|
|
|
|
_glfw.wl.cursorThemeHiDPI =
|
|
|
|
|
wl_cursor_theme_load(cursorTheme, 2 * cursorSize, _glfw.wl.shm);
|
2014-09-28 19:54:09 +00:00
|
|
|
|
_glfw.wl.cursorSurface =
|
|
|
|
|
wl_compositor_create_surface(_glfw.wl.compositor);
|
2020-06-05 03:51:25 +00:00
|
|
|
|
_glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
2014-09-09 14:37:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-10 17:06:11 +00:00
|
|
|
|
if (_glfw.wl.seat && _glfw.wl.dataDeviceManager)
|
|
|
|
|
{
|
|
|
|
|
_glfw.wl.dataDevice =
|
|
|
|
|
wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager,
|
|
|
|
|
_glfw.wl.seat);
|
|
|
|
|
wl_data_device_add_listener(_glfw.wl.dataDevice, &dataDeviceListener, NULL);
|
2018-10-10 17:21:26 +00:00
|
|
|
|
_glfw.wl.clipboardString = malloc(4096);
|
|
|
|
|
if (!_glfw.wl.clipboardString)
|
|
|
|
|
{
|
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
|
"Wayland: Unable to allocate clipboard memory");
|
|
|
|
|
return GLFW_FALSE;
|
|
|
|
|
}
|
|
|
|
|
_glfw.wl.clipboardSize = 4096;
|
2018-10-10 17:06:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-23 17:30:04 +00:00
|
|
|
|
return GLFW_TRUE;
|
2014-03-17 21:53:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _glfwPlatformTerminate(void)
|
|
|
|
|
{
|
2018-03-19 19:08:22 +00:00
|
|
|
|
#ifdef __linux__
|
2015-12-03 17:16:46 +00:00
|
|
|
|
_glfwTerminateJoysticksLinux();
|
2018-03-19 19:08:22 +00:00
|
|
|
|
#endif
|
2018-01-29 03:55:55 +00:00
|
|
|
|
_glfwTerminateEGL();
|
|
|
|
|
if (_glfw.wl.egl.handle)
|
|
|
|
|
{
|
|
|
|
|
_glfw_dlclose(_glfw.wl.egl.handle);
|
|
|
|
|
_glfw.wl.egl.handle = NULL;
|
|
|
|
|
}
|
2014-03-17 21:53:43 +00:00
|
|
|
|
|
2017-11-16 16:42:11 +00:00
|
|
|
|
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
2018-01-05 20:56:27 +00:00
|
|
|
|
if (_glfw.wl.xkb.composeState)
|
|
|
|
|
xkb_compose_state_unref(_glfw.wl.xkb.composeState);
|
2017-11-16 16:42:11 +00:00
|
|
|
|
#endif
|
2018-01-05 20:56:27 +00:00
|
|
|
|
if (_glfw.wl.xkb.keymap)
|
|
|
|
|
xkb_keymap_unref(_glfw.wl.xkb.keymap);
|
|
|
|
|
if (_glfw.wl.xkb.state)
|
|
|
|
|
xkb_state_unref(_glfw.wl.xkb.state);
|
|
|
|
|
if (_glfw.wl.xkb.context)
|
|
|
|
|
xkb_context_unref(_glfw.wl.xkb.context);
|
|
|
|
|
if (_glfw.wl.xkb.handle)
|
|
|
|
|
{
|
|
|
|
|
_glfw_dlclose(_glfw.wl.xkb.handle);
|
|
|
|
|
_glfw.wl.xkb.handle = NULL;
|
|
|
|
|
}
|
2018-01-29 03:55:55 +00:00
|
|
|
|
|
|
|
|
|
if (_glfw.wl.cursorTheme)
|
|
|
|
|
wl_cursor_theme_destroy(_glfw.wl.cursorTheme);
|
2018-09-11 12:18:52 +00:00
|
|
|
|
if (_glfw.wl.cursorThemeHiDPI)
|
|
|
|
|
wl_cursor_theme_destroy(_glfw.wl.cursorThemeHiDPI);
|
2018-01-05 20:58:10 +00:00
|
|
|
|
if (_glfw.wl.cursor.handle)
|
|
|
|
|
{
|
|
|
|
|
_glfw_dlclose(_glfw.wl.cursor.handle);
|
|
|
|
|
_glfw.wl.cursor.handle = NULL;
|
|
|
|
|
}
|
2017-08-26 18:25:24 +00:00
|
|
|
|
|
2014-09-09 14:37:55 +00:00
|
|
|
|
if (_glfw.wl.cursorSurface)
|
|
|
|
|
wl_surface_destroy(_glfw.wl.cursorSurface);
|
2018-02-24 20:45:39 +00:00
|
|
|
|
if (_glfw.wl.subcompositor)
|
|
|
|
|
wl_subcompositor_destroy(_glfw.wl.subcompositor);
|
2016-10-01 19:01:01 +00:00
|
|
|
|
if (_glfw.wl.compositor)
|
|
|
|
|
wl_compositor_destroy(_glfw.wl.compositor);
|
|
|
|
|
if (_glfw.wl.shm)
|
|
|
|
|
wl_shm_destroy(_glfw.wl.shm);
|
|
|
|
|
if (_glfw.wl.shell)
|
|
|
|
|
wl_shell_destroy(_glfw.wl.shell);
|
2018-02-24 20:45:39 +00:00
|
|
|
|
if (_glfw.wl.viewporter)
|
|
|
|
|
wp_viewporter_destroy(_glfw.wl.viewporter);
|
2018-10-01 13:05:55 +00:00
|
|
|
|
if (_glfw.wl.decorationManager)
|
|
|
|
|
zxdg_decoration_manager_v1_destroy(_glfw.wl.decorationManager);
|
2017-12-03 02:59:48 +00:00
|
|
|
|
if (_glfw.wl.wmBase)
|
|
|
|
|
xdg_wm_base_destroy(_glfw.wl.wmBase);
|
2018-10-10 18:31:26 +00:00
|
|
|
|
if (_glfw.wl.dataSource)
|
|
|
|
|
wl_data_source_destroy(_glfw.wl.dataSource);
|
2018-10-10 17:06:11 +00:00
|
|
|
|
if (_glfw.wl.dataDevice)
|
|
|
|
|
wl_data_device_destroy(_glfw.wl.dataDevice);
|
|
|
|
|
if (_glfw.wl.dataOffer)
|
|
|
|
|
wl_data_offer_destroy(_glfw.wl.dataOffer);
|
|
|
|
|
if (_glfw.wl.dataDeviceManager)
|
|
|
|
|
wl_data_device_manager_destroy(_glfw.wl.dataDeviceManager);
|
2016-10-01 19:01:01 +00:00
|
|
|
|
if (_glfw.wl.pointer)
|
|
|
|
|
wl_pointer_destroy(_glfw.wl.pointer);
|
|
|
|
|
if (_glfw.wl.keyboard)
|
|
|
|
|
wl_keyboard_destroy(_glfw.wl.keyboard);
|
|
|
|
|
if (_glfw.wl.seat)
|
|
|
|
|
wl_seat_destroy(_glfw.wl.seat);
|
|
|
|
|
if (_glfw.wl.relativePointerManager)
|
|
|
|
|
zwp_relative_pointer_manager_v1_destroy(_glfw.wl.relativePointerManager);
|
|
|
|
|
if (_glfw.wl.pointerConstraints)
|
|
|
|
|
zwp_pointer_constraints_v1_destroy(_glfw.wl.pointerConstraints);
|
2017-02-17 15:52:50 +00:00
|
|
|
|
if (_glfw.wl.idleInhibitManager)
|
|
|
|
|
zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager);
|
2014-03-19 15:20:32 +00:00
|
|
|
|
if (_glfw.wl.registry)
|
|
|
|
|
wl_registry_destroy(_glfw.wl.registry);
|
|
|
|
|
if (_glfw.wl.display)
|
2016-10-01 19:01:01 +00:00
|
|
|
|
{
|
2014-03-19 15:20:32 +00:00
|
|
|
|
wl_display_flush(_glfw.wl.display);
|
|
|
|
|
wl_display_disconnect(_glfw.wl.display);
|
2016-10-01 19:01:01 +00:00
|
|
|
|
}
|
2018-09-08 17:38:51 +00:00
|
|
|
|
|
|
|
|
|
if (_glfw.wl.timerfd >= 0)
|
|
|
|
|
close(_glfw.wl.timerfd);
|
2018-09-08 18:01:04 +00:00
|
|
|
|
if (_glfw.wl.cursorTimerfd >= 0)
|
|
|
|
|
close(_glfw.wl.cursorTimerfd);
|
2018-10-10 17:21:26 +00:00
|
|
|
|
|
|
|
|
|
if (_glfw.wl.clipboardString)
|
|
|
|
|
free(_glfw.wl.clipboardString);
|
2018-10-10 18:31:26 +00:00
|
|
|
|
if (_glfw.wl.clipboardSendString)
|
|
|
|
|
free(_glfw.wl.clipboardSendString);
|
2014-03-17 21:53:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* _glfwPlatformGetVersionString(void)
|
|
|
|
|
{
|
2019-04-08 18:51:05 +00:00
|
|
|
|
return _GLFW_VERSION_NUMBER " Wayland EGL OSMesa"
|
2014-03-17 21:53:43 +00:00
|
|
|
|
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
|
|
|
|
" clock_gettime"
|
2015-06-01 17:15:55 +00:00
|
|
|
|
#else
|
|
|
|
|
" gettimeofday"
|
|
|
|
|
#endif
|
2017-08-07 09:34:06 +00:00
|
|
|
|
" evdev"
|
2014-03-17 21:53:43 +00:00
|
|
|
|
#if defined(_GLFW_BUILD_DLL)
|
|
|
|
|
" shared"
|
|
|
|
|
#endif
|
|
|
|
|
;
|
|
|
|
|
}
|