Merge pull request #333 from ricardomv/fix-reopen

wayland: Release input focus when window is destroyed.
This commit is contained in:
Camilla Berglund 2014-08-13 08:59:25 +02:00
commit 26f86ac50a
2 changed files with 30 additions and 2 deletions

View File

@ -33,7 +33,6 @@
#include <sys/mman.h>
#include <unistd.h>
#include <wayland-client.h>
#include <wayland-client-protocol.h>
#include <wayland-cursor.h>
#include "xkb_unicode.h"
@ -56,7 +55,10 @@ static void pointerHandleLeave(void* data,
uint32_t serial,
struct wl_surface* surface)
{
_GLFWwindow* window = wl_surface_get_user_data(surface);
_GLFWwindow* window = _glfw.wl.pointerFocus;
if (!window)
return;
_glfw.wl.pointerFocus = NULL;
_glfwInputCursorEnter(window, GL_FALSE);
@ -70,6 +72,9 @@ static void pointerHandleMotion(void* data,
{
_GLFWwindow* window = _glfw.wl.pointerFocus;
if (!window)
return;
if (window->cursorMode == GLFW_CURSOR_DISABLED)
{
/* TODO */
@ -93,6 +98,9 @@ static void pointerHandleButton(void* data,
_GLFWwindow* window = _glfw.wl.pointerFocus;
int glfwButton;
if (!window)
return;
/* Makes left, right and middle 0, 1 and 2. Overall order follows evdev
* codes. */
glfwButton = button - BTN_LEFT;
@ -115,6 +123,9 @@ static void pointerHandleAxis(void* data,
double scroll_factor;
double x, y;
if (!window)
return;
/* 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. */
@ -224,6 +235,9 @@ static void keyboardHandleLeave(void* data,
{
_GLFWwindow* window = _glfw.wl.keyboardFocus;
if (!window)
return;
_glfw.wl.keyboardFocus = NULL;
_glfwInputWindowFocus(window, GL_FALSE);
}
@ -366,6 +380,9 @@ static void keyboardHandleKey(void* data,
const xkb_keysym_t *syms;
_GLFWwindow* window = _glfw.wl.keyboardFocus;
if (!window)
return;
keyCode = toGLFWKeyCode(key);
action = state == WL_KEYBOARD_KEY_STATE_PRESSED
? GLFW_PRESS : GLFW_RELEASE;

View File

@ -127,6 +127,17 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
{
if (window == _glfw.wl.pointerFocus)
{
_glfw.wl.pointerFocus = NULL;
_glfwInputCursorEnter(window, GL_FALSE);
}
if (window == _glfw.wl.keyboardFocus)
{
_glfw.wl.keyboardFocus = NULL;
_glfwInputWindowFocus(window, GL_FALSE);
}
_glfwDestroyContext(window);
if (window->wl.native)