Skip to content

Commit

Permalink
Conditionally send focus and activate app messages
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Nov 8, 2024
1 parent ae384f8 commit 7ad2705
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 7307
#define BUILD_NUMBER 7308
16 changes: 11 additions & 5 deletions ddraw/IDirectDrawX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3110,6 +3110,9 @@ HRESULT m_IDirectDrawX::CreateD9Device(char* FunctionName)
// Store new focus window
hFocusWindow = hWnd;

// Check active
bool WndLastActive = (hWnd == GetForegroundWindow() && hWnd == GetFocus() && hWnd == GetActiveWindow());

// Hook WndProc before creating device
bool WndProcAdded = WndProc::AddWndProc(hWnd, true);

Expand Down Expand Up @@ -3389,13 +3392,16 @@ HRESULT m_IDirectDrawX::CreateD9Device(char* FunctionName)
}

// Window focus and activate app
PostMessage(hWnd, WM_IME_SETCONTEXT, TRUE, ISC_SHOWUIALL);
PostMessage(hWnd, WM_SETFOCUS, NULL, NULL);
PostMessage(hWnd, WM_SYNCPAINT, (WPARAM)32, NULL);
PostMessage(hWnd, WM_ACTIVATEAPP, TRUE, (LPARAM)GetWindowThreadProcessId(hWnd, nullptr));
if (!WndLastActive || LastHWnd != hFocusWindow)
{
PostMessage(hWnd, WM_IME_SETCONTEXT, TRUE, ISC_SHOWUIALL);
PostMessage(hWnd, WM_SETFOCUS, NULL, NULL);
PostMessage(hWnd, WM_SYNCPAINT, (WPARAM)32, NULL);
PostMessage(hWnd, WM_ACTIVATEAPP, TRUE, (LPARAM)GetWindowThreadProcessId(hWnd, nullptr));
#ifdef WM_DWMNCRENDERINGCHANGED
PostMessage(hWnd, WM_DWMNCRENDERINGCHANGED, FALSE, NULL);
PostMessage(hWnd, WM_DWMNCRENDERINGCHANGED, FALSE, NULL);
#endif
}
}

// Store display frequency
Expand Down

0 comments on commit 7ad2705

Please sign in to comment.