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 31, 2024
1 parent eada184 commit 2e1800f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/Magpie.Core/OverlayDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static SmallVector<uint32_t> GenerateTimelineColors(const std::vector<Renderer::
}

OverlayDrawer::~OverlayDrawer() {
if (ScalingWindow::Get().Options().Is3DGameMode() && IsUIVisible()) {
if (_openWith3DGameMode && IsUIVisible()) {
HWND hwndSrc = ScalingWindow::Get().HwndSrc();
EnableWindow(hwndSrc, TRUE);
// 此时用户通过热键退出缩放,应激活源窗口
Expand Down 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 2e1800f

Please sign in to comment.