Skip to content

Commit

Permalink
fix for dynamic changing 3d mode
Browse files Browse the repository at this point in the history
  • Loading branch information
eriforce committed Aug 28, 2024
1 parent 6496e97 commit 3961ec1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/Magpie.Core/OverlayDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ void OverlayDrawer::SetUIVisibility(bool value, bool noSetForeground) noexcept {
_isUIVisiable = value;

if (value) {
if (ScalingWindow::Get().Options().Is3DGameMode()) {
_openWith3DGameMode = ScalingWindow::Get().Options().Is3DGameMode();
if (_openWith3DGameMode) {
// 使全屏窗口不透明且可以接收焦点
HWND hwndHost = ScalingWindow::Get().Handle();
INT_PTR style = GetWindowLongPtr(hwndHost, GWL_EXSTYLE);
Expand All @@ -278,7 +279,7 @@ void OverlayDrawer::SetUIVisibility(bool value, bool noSetForeground) noexcept {
_imguiImpl.ClearStates();
}

if (ScalingWindow::Get().Options().Is3DGameMode()) {
if (_openWith3DGameMode) {
// 还原全屏窗口样式
HWND hwndHost = ScalingWindow::Get().Handle();
INT_PTR style = GetWindowLongPtr(hwndHost, GWL_EXSTYLE);
Expand Down
1 change: 1 addition & 0 deletions src/Magpie.Core/OverlayDrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class OverlayDrawer {

bool _isUIVisiable = false;
bool _isFirstFrame = true;
bool _openWith3DGameMode;
};

}
6 changes: 3 additions & 3 deletions src/Magpie.Core/ScalingWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,9 @@ int ScalingWindow::_CheckSrcState() const noexcept {
HWND hwndForeground = GetForegroundWindow();

// 3D 游戏模式下打开叠加层后如果源窗口意外回到前台应关闭叠加层
// if (_options.Is3DGameMode() && _renderer->IsOverlayVisible() && hwndForeground == _hwndSrc) {
// _renderer->SetOverlayVisibility(false, true);
// }
if (_options.Is3DGameMode() && _renderer->IsOverlayVisible() && hwndForeground == _hwndSrc) {
_renderer->SetOverlayVisibility(false, true);
}

// 在 3D 游戏模式下打开叠加层则全屏窗口可以接收焦点
if (!_options.Is3DGameMode() || !_renderer->IsOverlayVisible() || hwndForeground != _hWnd) {
Expand Down

0 comments on commit 3961ec1

Please sign in to comment.