Skip to content

Commit

Permalink
Fix mouse during fade and window foreground
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Jan 12, 2025
1 parent 6bdf2cb commit 80913b1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Common/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void UpdateConfigDefaults()
}

// Set shaders default
EnableCustomShaders = ((EnableSMAA || RestoreBrightnessSelector || EnableCRTShader) && d3d8to9);
EnableCustomShaders = ((EnableSMAA || EnableCRTShader) && d3d8to9);

// Set Input Tweaks default
EnableInputTweaks = (EnableToggleSprint || EnableEnhancedMouse || EnableMouseWheelSwap || MemoScreenFix || EnhanceMouseCursor || AutoHideMouseCursor || CenterPuzzleCursor);
Expand Down
2 changes: 1 addition & 1 deletion Patches/InputTweaks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int32_t CanSave_Hook()

void DrawCursor_Hook()
{
if (HideMouseCursor)
if (HideMouseCursor || GetTransitionState() != FADE_NONE)
return;

orgDrawCursor.fun();
Expand Down
2 changes: 1 addition & 1 deletion Resources/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 2223
#define BUILD_NUMBER 2224
34 changes: 22 additions & 12 deletions Wrappers/d3d8/IDirect3D8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Patches\InputTweaks.h"

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void SetWindowToTop(HWND MainhWnd);

WNDPROC OriginalWndProc = nullptr;
HWND DeviceWindow = nullptr;
Expand Down Expand Up @@ -249,6 +250,9 @@ HRESULT m_IDirect3D8::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFo
// Update presentation parameters
UpdatePresentParameter(pPresentationParameters, hFocusWindow);

// Bring window to the forefront
SetWindowToTop(DeviceWindow);

// Get WndProc
if (HookWndProc && DeviceWindow && !OriginalWndProc)
{
Expand Down Expand Up @@ -495,18 +499,8 @@ void SetScreenAndWindowSize()
WindowInChange = false;
}

// Adjusting the window position for WindowMode
void AdjustWindow(HWND MainhWnd, LONG displayWidth, LONG displayHeight)
void SetWindowToTop(HWND MainhWnd)
{
if (!IsWindow(MainhWnd) || !displayWidth || !displayHeight)
{
LOG_LIMIT(100, __FUNCTION__ << " Error: could not set window size, nullptr.");
return;
}

// Remember first run
static bool FirstRun = true;

// Set topmost
LONG lExStyle = GetWindowLong(MainhWnd, GWL_EXSTYLE);
SetWindowLong(MainhWnd, GWL_EXSTYLE, lExStyle | WS_EX_TOPMOST);
Expand Down Expand Up @@ -543,6 +537,22 @@ void AdjustWindow(HWND MainhWnd, LONG displayWidth, LONG displayHeight)
AttachThreadInput(currentThreadId, foregroundThreadId, FALSE);
}
}
}

// Adjusting the window position for WindowMode
void AdjustWindow(HWND MainhWnd, LONG displayWidth, LONG displayHeight)
{
if (!IsWindow(MainhWnd) || !displayWidth || !displayHeight)
{
LOG_LIMIT(100, __FUNCTION__ << " Error: could not set window size, nullptr.");
return;
}

// Remember first run
static bool FirstRun = true;

// Bring window to the forefront
SetWindowToTop(MainhWnd);

// Get screen width and height
LONG screenWidth = 0, screenHeight = 0;
Expand All @@ -560,7 +570,7 @@ void AdjustWindow(HWND MainhWnd, LONG displayWidth, LONG displayHeight)

// Get window style
LONG lStyle = GetWindowLong(MainhWnd, GWL_STYLE) | WS_VISIBLE;
lExStyle = GetWindowLong(MainhWnd, GWL_EXSTYLE);
LONG lExStyle = GetWindowLong(MainhWnd, GWL_EXSTYLE);

// Get new style
LONG lNewStyle = (lStyle | WS_OVERLAPPEDWINDOW) & ~(WS_MAXIMIZEBOX | WS_THICKFRAME);
Expand Down

0 comments on commit 80913b1

Please sign in to comment.