1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 18:58:52 -05:00
glfw/src/wl_platform.h

169 lines
5.7 KiB
C
Raw Normal View History

//========================================================================
2016-08-18 17:42:15 -04:00
// GLFW 3.3 Wayland - www.glfw.org
//------------------------------------------------------------------------
// 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.
//
//========================================================================
#include <wayland-client.h>
#include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-compose.h>
#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*);
#include "posix_thread.h"
2015-05-27 09:06:52 -04:00
#include "posix_time.h"
#include "linux_joystick.h"
#include "xkb_unicode.h"
#include "egl_context.h"
#include "osmesa_context.h"
#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
#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 17:53:50 -05:00
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->wl.native)
#define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.wl.display)
2014-03-19 11:20:32 -04: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 12:29:22 -04:00
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl
#define _GLFW_PLATFORM_CONTEXT_STATE
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
2014-09-02 13:42:43 -04:00
// Wayland-specific per-window data
//
typedef struct _GLFWwindowWayland
{
int width, height;
2015-08-23 13:30:04 -04:00
GLFWbool visible;
2016-04-08 19:54:23 -04:00
GLFWbool maximized;
struct wl_surface* surface;
struct wl_egl_window* native;
struct wl_shell_surface* shellSurface;
struct wl_callback* callback;
_GLFWcursor* currentCursor;
double cursorPosX, cursorPosY;
char* title;
// We need to track the monitors the window spans on to calculate the
// optimal scaling factor.
int scale;
_GLFWmonitor** monitors;
int monitorsCount;
int monitorsSize;
struct {
struct zwp_relative_pointer_v1* relativePointer;
struct zwp_locked_pointer_v1* lockedPointer;
} pointerLock;
} _GLFWwindowWayland;
2014-09-02 13:42:43 -04:00
// Wayland-specific global data
//
typedef struct _GLFWlibraryWayland
{
struct wl_display* display;
struct wl_registry* registry;
struct wl_compositor* compositor;
struct wl_shell* shell;
struct wl_shm* shm;
2014-06-29 06:29:00 -04:00
struct wl_seat* seat;
struct wl_pointer* pointer;
struct wl_keyboard* keyboard;
struct zwp_relative_pointer_manager_v1* relativePointerManager;
struct zwp_pointer_constraints_v1* pointerConstraints;
int compositorVersion;
struct wl_cursor_theme* cursorTheme;
struct wl_surface* cursorSurface;
uint32_t pointerSerial;
2016-09-07 09:43:39 -04:00
short int keycodes[256];
short int scancodes[GLFW_KEY_LAST + 1];
struct {
struct xkb_context* context;
struct xkb_keymap* keymap;
struct xkb_state* state;
struct xkb_compose_state* composeState;
xkb_mod_mask_t controlMask;
xkb_mod_mask_t altMask;
xkb_mod_mask_t shiftMask;
xkb_mod_mask_t superMask;
unsigned int modifiers;
} xkb;
2014-06-29 06:29:00 -04:00
_GLFWwindow* pointerFocus;
_GLFWwindow* keyboardFocus;
2014-09-02 13:42:43 -04:00
} _GLFWlibraryWayland;
2014-09-02 13:42:43 -04:00
// Wayland-specific per-monitor data
//
typedef struct _GLFWmonitorWayland
{
struct wl_output* output;
int currentMode;
int x;
int y;
int scale;
} _GLFWmonitorWayland;
2014-09-02 13:42:43 -04:00
// Wayland-specific per-cursor data
//
2014-03-27 12:29:22 -04:00
typedef struct _GLFWcursorWayland
{
struct wl_cursor_image* image;
struct wl_buffer* buffer;
int width, height;
int xhot, yhot;
2014-09-02 13:42:43 -04:00
} _GLFWcursorWayland;
void _glfwAddOutputWayland(uint32_t name, uint32_t version);