Skip to content

Commit

Permalink
Windows: Track minimize as lost focus.
Browse files Browse the repository at this point in the history
It makes sense if we have the other feature.  Fixes #9918.
  • Loading branch information
unknownbrackets committed Dec 25, 2017
1 parent 9b909b4 commit 8c1c0e1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Windows/MainWindow.cpp
Expand Up @@ -116,6 +116,7 @@ namespace MainWindow
static bool g_IgnoreWM_SIZE = false;
static bool inFullscreenResize = false;
static bool inResizeMove = false;
static bool hasFocus = true;

// gross hack
bool noFocusPause = false; // TOGGLE_PAUSE state to override pause on lost focus
Expand Down Expand Up @@ -379,6 +380,7 @@ namespace MainWindow

void Minimize() {
ShowWindow(hwndMain, SW_MINIMIZE);
InputDevice::LoseFocus();
}

RECT DetermineWindowRectangle() {
Expand Down Expand Up @@ -688,7 +690,9 @@ namespace MainWindow
bool pause = true;
if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
WindowsRawInput::GainFocus();
InputDevice::GainFocus();
if (!IsIconic(GetHWND())) {
InputDevice::GainFocus();
}
g_activeWindow = WINDOW_MAINWINDOW;
pause = false;
}
Expand All @@ -701,14 +705,16 @@ namespace MainWindow
}
}

if (wParam == WA_ACTIVE) {
if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
NativeMessageReceived("got_focus", "");
hasFocus = true;
trapMouse = true;
}
if (wParam == WA_INACTIVE) {
NativeMessageReceived("lost_focus", "");
WindowsRawInput::LoseFocus();
InputDevice::LoseFocus();
hasFocus = false;
trapMouse = false;
}
}
Expand Down Expand Up @@ -740,13 +746,17 @@ namespace MainWindow
} else if (!inResizeMove) {
HandleSizeChange(wParam);
}
if (hasFocus) {
InputDevice::GainFocus();
}
break;

case SIZE_MINIMIZED:
Core_NotifyWindowHidden(true);
if (!g_Config.bPauseWhenMinimized) {
NativeMessageReceived("window minimized", "true");
}
InputDevice::LoseFocus();
break;
default:
break;
Expand Down

0 comments on commit 8c1c0e1

Please sign in to comment.