mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-02-16 10:40:59 +00:00
Partially unrevert 05e82c24 for macOS which still needs it
This commit is contained in:
@@ -19,6 +19,7 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int s
|
||||
m_StreamHeight(streamHeight),
|
||||
m_AbsoluteMouseMode(prefs.absoluteMouseMode),
|
||||
m_AbsoluteTouchMode(prefs.absoluteTouchMode),
|
||||
m_PendingFocusGain(false),
|
||||
m_LeftButtonReleaseTimer(0),
|
||||
m_RightButtonReleaseTimer(0),
|
||||
m_DragTimer(0),
|
||||
@@ -192,6 +193,30 @@ void SdlInputHandler::raiseAllKeys()
|
||||
m_KeysDown.clear();
|
||||
}
|
||||
|
||||
void SdlInputHandler::notifyFocusGained()
|
||||
{
|
||||
#if defined(Q_OS_DARWIN)
|
||||
int mouseX, mouseY;
|
||||
Uint32 mouseState = SDL_GetGlobalMouseState(&mouseX, &mouseY);
|
||||
if (mouseState & SDL_BUTTON_LMASK) {
|
||||
int x, y, width, height;
|
||||
SDL_GetWindowPosition(m_Window, &x, &y);
|
||||
SDL_GetWindowSize(m_Window, &width, &height);
|
||||
if (mouseX > x && mouseX < x+width && mouseY > y && mouseY < y+height) {
|
||||
if (m_AbsoluteMouseMode) {
|
||||
// Send synthetic mouse motion until the button is lifted
|
||||
m_PendingFocusGain = true;
|
||||
}
|
||||
else {
|
||||
// Recapture the mouse
|
||||
// FIXME: Why is this necessary with SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH?
|
||||
setCaptureActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SdlInputHandler::notifyFocusLost()
|
||||
{
|
||||
// Release mouse cursor when another window is activated (e.g. by using ALT+TAB).
|
||||
|
||||
Reference in New Issue
Block a user