From 2f71bfc15258dcea5219d91395c670fd82f36298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sun, 29 Jun 2014 23:01:11 +0200 Subject: [PATCH] x11: Move KeySym to unicode converter out of x11 backend To be used by the Wayland backend. --- src/CMakeLists.txt | 4 ++-- src/x11_platform.h | 4 +--- src/{x11_unicode.c => xkb_unicode.c} | 4 ++-- src/xkb_unicode.h | 33 ++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 7 deletions(-) rename src/{x11_unicode.c => xkb_unicode.c} (99%) create mode 100644 src/xkb_unicode.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8604518a..595fb0b8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,8 +27,8 @@ elseif (_GLFW_X11) set(glfw_HEADERS ${common_HEADERS} x11_platform.h linux_joystick.h posix_time.h posix_tls.h) set(glfw_SOURCES ${common_SOURCES} x11_clipboard.c x11_gamma.c x11_init.c - x11_monitor.c x11_window.c x11_unicode.c linux_joystick.c - posix_time.c posix_tls.c) + x11_monitor.c x11_window.c xkb_unicode.c xkb_unicode.h + linux_joystick.c posix_time.c posix_tls.c) elseif (_GLFW_WAYLAND) set(glfw_HEADERS ${common_HEADERS} wl_platform.h linux_joystick.h posix_time.h posix_tls.h) diff --git a/src/x11_platform.h b/src/x11_platform.h index 7109d900..4ac4992b 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -64,6 +64,7 @@ #include "posix_time.h" #include "linux_joystick.h" +#include "xkb_unicode.h" #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 x11 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11 @@ -248,9 +249,6 @@ void _glfwInitGammaRamp(void); GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoMode(_GLFWmonitor* monitor); -// Unicode support -long _glfwKeySym2Unicode(KeySym keysym); - // Clipboard handling void _glfwHandleSelectionClear(XEvent* event); void _glfwHandleSelectionRequest(XEvent* event); diff --git a/src/x11_unicode.c b/src/xkb_unicode.c similarity index 99% rename from src/x11_unicode.c rename to src/xkb_unicode.c index 7d4c8a06..fbc25a27 100644 --- a/src/x11_unicode.c +++ b/src/xkb_unicode.c @@ -852,9 +852,9 @@ static const struct codepair { ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// -// Convert X11 KeySym to Unicode +// Convert XKB KeySym to Unicode // -long _glfwKeySym2Unicode(KeySym keysym) +long _glfwKeySym2Unicode(unsigned int keysym) { int min = 0; int max = sizeof(keysymtab) / sizeof(struct codepair) - 1; diff --git a/src/xkb_unicode.h b/src/xkb_unicode.h new file mode 100644 index 00000000..f043781b --- /dev/null +++ b/src/xkb_unicode.h @@ -0,0 +1,33 @@ +//======================================================================== +// GLFW 3.1 Linux - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2014 Jonas Ã…dahl +// +// 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. +// +//======================================================================== + +#ifndef _xkb_unicode_h_ +#define _xkb_unicode_h_ + +// Unicode support +long _glfwKeySym2Unicode(unsigned int keysym); + +#endif // _xkb_unicode_h_