|
@@ -38,6 +38,8 @@
|
|
|
|
|
|
|
|
#include "DebugNew.h"
|
|
#include "DebugNew.h"
|
|
|
|
|
|
|
|
|
|
+// Require a click inside window before re-hiding mouse cursor on OSX, otherwise dragging the window
|
|
|
|
|
+// can be incorrectly interpreted as mouse movement inside the window
|
|
|
#if defined(__APPLE__) && !defined(IOS)
|
|
#if defined(__APPLE__) && !defined(IOS)
|
|
|
#define REQUIRE_CLICK_TO_FOCUS
|
|
#define REQUIRE_CLICK_TO_FOCUS
|
|
|
#endif
|
|
#endif
|
|
@@ -124,11 +126,13 @@ void Input::Update()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Check for SDL events
|
|
// Check for SDL events
|
|
|
|
|
+ SDL_PumpEvents();
|
|
|
|
|
+
|
|
|
{
|
|
{
|
|
|
MutexLock lock(GetStaticMutex());
|
|
MutexLock lock(GetStaticMutex());
|
|
|
|
|
|
|
|
SDL_Event evt;
|
|
SDL_Event evt;
|
|
|
- while (SDL_PollEvent(&evt))
|
|
|
|
|
|
|
+ while (SDL_PeepEvents(&evt, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) > 0)
|
|
|
{
|
|
{
|
|
|
// If only one instance, can handle event directly. Otherwise put to the correct input instance's event queue
|
|
// If only one instance, can handle event directly. Otherwise put to the correct input instance's event queue
|
|
|
if (inputInstances.Size() > 1)
|
|
if (inputInstances.Size() > 1)
|
|
@@ -170,6 +174,10 @@ void Input::Update()
|
|
|
case SDL_WINDOWEVENT:
|
|
case SDL_WINDOWEVENT:
|
|
|
storeEvent = evt.window.windowID == (*i)->windowID_;
|
|
storeEvent = evt.window.windowID == (*i)->windowID_;
|
|
|
break;
|
|
break;
|
|
|
|
|
+
|
|
|
|
|
+ case SDL_QUIT:
|
|
|
|
|
+ storeEvent = true;
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (storeEvent)
|
|
if (storeEvent)
|
|
@@ -587,8 +595,6 @@ void Input::SendInputFocusEvent()
|
|
|
void Input::SetMouseButton(int button, bool newState)
|
|
void Input::SetMouseButton(int button, bool newState)
|
|
|
{
|
|
{
|
|
|
#ifdef REQUIRE_CLICK_TO_FOCUS
|
|
#ifdef REQUIRE_CLICK_TO_FOCUS
|
|
|
- // OSX only: after losing focus in windowed hidden mouse mode, regain focus only after a left-click inside the window.
|
|
|
|
|
- // This allows glitchfree window dragging
|
|
|
|
|
if (!mouseVisible_ && !graphics_->GetFullscreen())
|
|
if (!mouseVisible_ && !graphics_->GetFullscreen())
|
|
|
{
|
|
{
|
|
|
if (!inputFocus_ && newState && button == MOUSEB_LEFT)
|
|
if (!inputFocus_ && newState && button == MOUSEB_LEFT)
|
|
@@ -875,7 +881,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
|
|
|
switch (evt.window.event)
|
|
switch (evt.window.event)
|
|
|
{
|
|
{
|
|
|
case SDL_WINDOWEVENT_CLOSE:
|
|
case SDL_WINDOWEVENT_CLOSE:
|
|
|
- graphics_->Close();
|
|
|
|
|
|
|
+ SendEvent(E_EXITREQUESTED);
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case SDL_WINDOWEVENT_MINIMIZED:
|
|
case SDL_WINDOWEVENT_MINIMIZED:
|
|
@@ -914,6 +920,10 @@ void Input::HandleSDLEvent(void* sdlEvent)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
+
|
|
|
|
|
+ case SDL_QUIT:
|
|
|
|
|
+ SendEvent(E_EXITREQUESTED);
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|