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.
|
|
|
|
//
|
|
|
|
//========================================================================
|
|
|
|
|
2015-06-07 17:32:24 +00:00
|
|
|
#ifndef _glfw3_wayland_platform_h_
|
|
|
|
#define _glfw3_wayland_platform_h_
|
2014-03-17 21:53:43 +00:00
|
|
|
|
2014-03-19 12:21:19 +00:00
|
|
|
#include <wayland-client.h>
|
2014-06-29 21:09:21 +00:00
|
|
|
#include <xkbcommon/xkbcommon.h>
|
2015-08-10 18:19:04 +00:00
|
|
|
#include <dlfcn.h>
|
|
|
|
|
|
|
|
typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
|
|
|
|
|
|
|
|
typedef struct VkWaylandSurfaceCreateInfoKHR
|
|
|
|
{
|
|
|
|
VkStructureType sType;
|
|
|
|
const void* pNext;
|
|
|
|
VkWaylandSurfaceCreateFlagsKHR flags;
|
|
|
|
struct wl_display* display;
|
|
|
|
struct wl_surface* surface;
|
|
|
|
} VkWaylandSurfaceCreateInfoKHR;
|
|
|
|
|
|
|
|
typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
|
|
|
typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*);
|
2014-03-19 12:21:19 +00:00
|
|
|
|
2015-05-27 13:06:52 +00:00
|
|
|
#include "posix_tls.h"
|
|
|
|
#include "posix_time.h"
|
|
|
|
#include "linux_joystick.h"
|
|
|
|
#include "xkb_unicode.h"
|
2016-03-28 11:19:31 +00:00
|
|
|
#include "egl_context.h"
|
2014-03-17 21:53:43 +00:00
|
|
|
|
2015-12-09 07:29:37 +00:00
|
|
|
#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
|
|
|
|
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
|
|
|
|
|
2015-08-10 18:19:04 +00:00
|
|
|
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
|
|
|
#define _glfw_dlclose(handle) dlclose(handle)
|
|
|
|
#define _glfw_dlsym(handle, name) dlsym(handle, name)
|
|
|
|
|
2015-12-02 22:53:50 +00:00
|
|
|
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->wl.native)
|
|
|
|
#define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.wl.display)
|
2014-03-17 21:53:43 +00:00
|
|
|
|
2014-03-19 15:20:32 +00:00
|
|
|
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl
|
|
|
|
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl
|
|
|
|
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl
|
2014-03-27 16:29:22 +00:00
|
|
|
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl
|
2014-03-17 21:53:43 +00:00
|
|
|
|
2016-03-28 11:19:31 +00:00
|
|
|
#define _GLFW_PLATFORM_CONTEXT_STATE
|
|
|
|
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
|
|
|
|
|
2014-03-17 21:53:43 +00:00
|
|
|
|
2014-09-02 17:42:43 +00:00
|
|
|
// Wayland-specific video mode data
|
|
|
|
//
|
2014-03-17 21:53:43 +00:00
|
|
|
typedef struct _GLFWvidmodeWayland _GLFWvidmodeWayland;
|
|
|
|
|
2014-09-02 17:42:43 +00:00
|
|
|
// Wayland-specific per-window data
|
|
|
|
//
|
2014-03-17 21:53:43 +00:00
|
|
|
typedef struct _GLFWwindowWayland
|
|
|
|
{
|
|
|
|
int width, height;
|
2015-08-23 17:30:04 +00:00
|
|
|
GLFWbool visible;
|
2016-04-08 23:54:23 +00:00
|
|
|
GLFWbool maximized;
|
2014-03-17 21:53:43 +00:00
|
|
|
struct wl_surface* surface;
|
|
|
|
struct wl_egl_window* native;
|
|
|
|
struct wl_shell_surface* shell_surface;
|
|
|
|
struct wl_callback* callback;
|
2015-10-10 15:35:06 +00:00
|
|
|
|
2014-09-09 14:37:55 +00:00
|
|
|
_GLFWcursor* currentCursor;
|
2015-04-15 16:18:42 +00:00
|
|
|
double cursorPosX, cursorPosY;
|
2015-10-10 15:35:06 +00:00
|
|
|
|
2016-04-08 23:51:48 +00:00
|
|
|
char* title;
|
|
|
|
|
2015-10-10 15:35:06 +00:00
|
|
|
// We need to track the monitors the window spans on to calculate the
|
|
|
|
// optimal scaling factor.
|
|
|
|
int scale;
|
|
|
|
_GLFWmonitor** monitors;
|
|
|
|
int monitorsCount;
|
|
|
|
int monitorsSize;
|
2015-08-10 18:19:04 +00:00
|
|
|
|
2015-12-09 07:29:37 +00:00
|
|
|
struct {
|
|
|
|
struct zwp_relative_pointer_v1* relativePointer;
|
|
|
|
struct zwp_locked_pointer_v1* lockedPointer;
|
|
|
|
} pointerLock;
|
2014-03-17 21:53:43 +00:00
|
|
|
} _GLFWwindowWayland;
|
|
|
|
|
2014-09-02 17:42:43 +00:00
|
|
|
// Wayland-specific global data
|
|
|
|
//
|
2014-03-17 21:53:43 +00:00
|
|
|
typedef struct _GLFWlibraryWayland
|
|
|
|
{
|
|
|
|
struct wl_display* display;
|
|
|
|
struct wl_registry* registry;
|
|
|
|
struct wl_compositor* compositor;
|
|
|
|
struct wl_shell* shell;
|
2014-09-09 14:37:55 +00:00
|
|
|
struct wl_shm* shm;
|
2014-06-29 10:29:00 +00:00
|
|
|
struct wl_seat* seat;
|
|
|
|
struct wl_pointer* pointer;
|
|
|
|
struct wl_keyboard* keyboard;
|
2015-12-09 07:29:37 +00:00
|
|
|
struct zwp_relative_pointer_manager_v1* relativePointerManager;
|
|
|
|
struct zwp_pointer_constraints_v1* pointerConstraints;
|
2014-03-17 21:53:43 +00:00
|
|
|
|
2015-12-27 02:42:45 +00:00
|
|
|
int wl_compositor_version;
|
|
|
|
|
2014-09-09 14:37:55 +00:00
|
|
|
struct wl_cursor_theme* cursorTheme;
|
|
|
|
struct wl_surface* cursorSurface;
|
|
|
|
uint32_t pointerSerial;
|
|
|
|
|
2014-03-17 21:53:43 +00:00
|
|
|
_GLFWmonitor** monitors;
|
|
|
|
int monitorsCount;
|
|
|
|
int monitorsSize;
|
|
|
|
|
2015-11-12 14:06:46 +00:00
|
|
|
short int publicKeys[256];
|
|
|
|
|
2014-06-29 21:09:21 +00:00
|
|
|
struct {
|
|
|
|
struct xkb_context* context;
|
|
|
|
struct xkb_keymap* keymap;
|
|
|
|
struct xkb_state* state;
|
|
|
|
xkb_mod_mask_t control_mask;
|
|
|
|
xkb_mod_mask_t alt_mask;
|
|
|
|
xkb_mod_mask_t shift_mask;
|
|
|
|
xkb_mod_mask_t super_mask;
|
|
|
|
unsigned int modifiers;
|
|
|
|
} xkb;
|
|
|
|
|
2014-06-29 10:29:00 +00:00
|
|
|
_GLFWwindow* pointerFocus;
|
|
|
|
_GLFWwindow* keyboardFocus;
|
2014-09-02 17:42:43 +00:00
|
|
|
|
2014-03-17 21:53:43 +00:00
|
|
|
} _GLFWlibraryWayland;
|
|
|
|
|
2014-09-02 17:42:43 +00:00
|
|
|
// Wayland-specific per-monitor data
|
|
|
|
//
|
2014-03-17 21:53:43 +00:00
|
|
|
typedef struct _GLFWmonitorWayland
|
|
|
|
{
|
|
|
|
struct wl_output* output;
|
|
|
|
|
|
|
|
_GLFWvidmodeWayland* modes;
|
|
|
|
int modesCount;
|
|
|
|
int modesSize;
|
2015-08-23 17:30:04 +00:00
|
|
|
GLFWbool done;
|
2014-03-17 21:53:43 +00:00
|
|
|
|
|
|
|
int x;
|
|
|
|
int y;
|
2015-10-10 15:35:06 +00:00
|
|
|
int scale;
|
2014-03-17 21:53:43 +00:00
|
|
|
} _GLFWmonitorWayland;
|
|
|
|
|
2014-09-02 17:42:43 +00:00
|
|
|
// Wayland-specific per-cursor data
|
|
|
|
//
|
2014-03-27 16:29:22 +00:00
|
|
|
typedef struct _GLFWcursorWayland
|
|
|
|
{
|
2015-10-22 23:28:16 +00:00
|
|
|
struct wl_cursor_image* image;
|
2014-09-09 14:37:55 +00:00
|
|
|
struct wl_buffer* buffer;
|
|
|
|
int width, height;
|
|
|
|
int xhot, yhot;
|
2014-09-02 17:42:43 +00:00
|
|
|
} _GLFWcursorWayland;
|
2014-03-17 21:53:43 +00:00
|
|
|
|
|
|
|
|
2015-12-03 17:16:46 +00:00
|
|
|
void _glfwAddOutputWayland(uint32_t name, uint32_t version);
|
2014-03-17 21:53:43 +00:00
|
|
|
|
2015-06-07 17:32:24 +00:00
|
|
|
#endif // _glfw3_wayland_platform_h_
|