From 58ea37d01fce7c26d6da840078f91093c0ed45dd Mon Sep 17 00:00:00 2001 From: DavidXanatos Date: Thu, 15 Dec 2022 14:06:58 +0100 Subject: [PATCH] 1.6.1b --- CHANGELOG.md | 4 + SandboxiePlus/SandMan/Forms/SettingsWindow.ui | 215 +++++++++--------- SandboxiePlus/SandMan/Helpers/FullScreen.cpp | 106 +++++++++ SandboxiePlus/SandMan/Helpers/FullScreen.h | 3 + SandboxiePlus/SandMan/SandMan.cpp | 9 +- SandboxiePlus/SandMan/SandMan.h | 5 +- SandboxiePlus/SandMan/SandMan.pri | 2 + SandboxiePlus/SandMan/SandMan.vcxproj | 2 + SandboxiePlus/SandMan/SandMan.vcxproj.filters | 6 + .../SandMan/Windows/SettingsWindow.cpp | 2 + 10 files changed, 247 insertions(+), 107 deletions(-) create mode 100644 SandboxiePlus/SandMan/Helpers/FullScreen.cpp create mode 100644 SandboxiePlus/SandMan/Helpers/FullScreen.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 41058757..a89a1cd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,15 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [1.6.1b / 5.61.1] - 2022-12-?? +### Added +- added game/presentation mode [#2534](https://github.com/sandboxie-plus/Sandboxie/issues/2534) + ### Fixed - fixed support settign page not showing version updates properly + ## [1.6.1a / 5.61.1] - 2022-12-07 ### Added diff --git a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui index c0fa19bc..208df9bb 100644 --- a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui +++ b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui @@ -45,7 +45,7 @@ QTabWidget::North - 3 + 0 @@ -54,7 +54,110 @@ - + + + + UI Language: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Show first recovery window when emptying sandboxes + + + + + + + Show the Recovery Window as Always on Top + + + + + + + Run box operations asynchronously whenever possible (like content deletion) + + + + + + + Count and display the disk space occupied by each sandbox + + + + + + + + + + + true + true + + + + General Options + + + + + + + + true + true + + + + Recovery Options + + + + + + + Open urls from this ui sandboxed + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + Show Notifications for relevant log Messages @@ -64,10 +167,10 @@ - - + + - Run box operations asynchronously whenever possible (like content deletion) + Show recoverable files as notifications @@ -85,89 +188,6 @@ - - - - - true - true - - - - General Options - - - - - - - - true - true - - - - Recovery Options - - - - - - - Show recoverable files as notifications - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - UI Language: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Open urls from this ui sandboxed - - - true - - - - - - - Show the Recovery Window as Always on Top - - - - - - - Count and display the disk space occupied by each sandbox - - - - - - @@ -175,23 +195,10 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + + - Show first recovery window when emptying sandboxes + Suppress pop-up notifications when in game / presentation mode diff --git a/SandboxiePlus/SandMan/Helpers/FullScreen.cpp b/SandboxiePlus/SandMan/Helpers/FullScreen.cpp new file mode 100644 index 00000000..0898ee09 --- /dev/null +++ b/SandboxiePlus/SandMan/Helpers/FullScreen.cpp @@ -0,0 +1,106 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "stdafx.h" +#include "FullScreen.h" + +#include +#include + + +static bool IsPlatformFullScreenMode() +{ + // SHQueryUserNotificationState is only available for Vista and above. +#if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_VISTA) + + OSVERSIONINFO osvi; + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + if (GetVersionEx(&osvi) && osvi.dwMajorVersion < 6) + return false; + + + typedef HRESULT(WINAPI* SHQueryUserNotificationStatePtr)( + QUERY_USER_NOTIFICATION_STATE* state); + + HMODULE shell32_base = ::GetModuleHandle(L"shell32.dll"); + if (!shell32_base) { + return false; + } + SHQueryUserNotificationStatePtr query_user_notification_state_ptr = + reinterpret_cast + (::GetProcAddress(shell32_base, "SHQueryUserNotificationState")); + if (!query_user_notification_state_ptr) { + return false; + } + + QUERY_USER_NOTIFICATION_STATE state; + if (FAILED((*query_user_notification_state_ptr)(&state))) + return false; + return state == QUNS_RUNNING_D3D_FULL_SCREEN || + state == QUNS_PRESENTATION_MODE; +#else + return false; +#endif +} + +static bool IsFullScreenWindowMode() +{ + // Get the foreground window which the user is currently working on. + HWND wnd = ::GetForegroundWindow(); + if (!wnd) + return false; + + // Get the monitor where the window is located. + RECT wnd_rect; + if (!::GetWindowRect(wnd, &wnd_rect)) + return false; + HMONITOR monitor = ::MonitorFromRect(&wnd_rect, MONITOR_DEFAULTTONULL); + if (!monitor) + return false; + MONITORINFO monitor_info = { sizeof(monitor_info) }; + if (!::GetMonitorInfo(monitor, &monitor_info)) + return false; + + // It should be the main monitor. + if (!(monitor_info.dwFlags & MONITORINFOF_PRIMARY)) + return false; + + // The window should be at least as large as the monitor. + if (!::IntersectRect(&wnd_rect, &wnd_rect, &monitor_info.rcMonitor)) + return false; + if (!::EqualRect(&wnd_rect, &monitor_info.rcMonitor)) + return false; + + // At last, the window style should not have WS_DLGFRAME and WS_THICKFRAME and + // its extended style should not have WS_EX_WINDOWEDGE and WS_EX_TOOLWINDOW. + LONG style = ::GetWindowLong(wnd, GWL_STYLE); + LONG ext_style = ::GetWindowLong(wnd, GWL_EXSTYLE); + return !((style & (WS_DLGFRAME | WS_THICKFRAME)) || + (ext_style & (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW))); +} + +static bool IsFullScreenConsoleMode() +{ + // We detect this by attaching the current process to the console of the + // foreground window and then checking if it is in full screen mode. + DWORD pid = 0; + ::GetWindowThreadProcessId(::GetForegroundWindow(), &pid); + if (!pid) + return false; + + if (!::AttachConsole(pid)) + return false; + + DWORD modes = 0; + ::GetConsoleDisplayMode(&modes); + ::FreeConsole(); + + return (modes & (CONSOLE_FULLSCREEN | CONSOLE_FULLSCREEN_HARDWARE)) != 0; +} + +bool IsFullScreenMode() { + return IsPlatformFullScreenMode() + //|| IsFullScreenConsoleMode() + || IsFullScreenWindowMode(); +} \ No newline at end of file diff --git a/SandboxiePlus/SandMan/Helpers/FullScreen.h b/SandboxiePlus/SandMan/Helpers/FullScreen.h new file mode 100644 index 00000000..ee101b53 --- /dev/null +++ b/SandboxiePlus/SandMan/Helpers/FullScreen.h @@ -0,0 +1,3 @@ +#pragma once + +bool IsFullScreenMode(); \ No newline at end of file diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index 2edd13e7..625691c0 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -33,6 +33,7 @@ #include "../MiscHelpers/Common/NeonEffect.h" #include #include +#include "Helpers/FullScreen.h" CSbiePlusAPI* theAPI = NULL; @@ -518,7 +519,7 @@ void CSandMan::CreateMenus(bool bAdvanced) } m_pMenuView->addSeparator(); - m_pMenuBrowse = m_pMenuView->addAction(CSandMan::GetIcon("Tree"), tr("Show File Panel"), this, SLOT(OnProcView())); + m_pMenuBrowse = m_pMenuView->addAction(CSandMan::GetIcon("Folder"), tr("Show File Panel"), this, SLOT(OnProcView())); m_pMenuBrowse->setCheckable(true); m_pMenuBrowse->setShortcut(QKeySequence("Ctrl+D")); m_pMenuBrowse->setShortcutContext(Qt::WidgetWithChildrenShortcut); @@ -1243,6 +1244,12 @@ bool CSandMan::IsFullyPortable() return false; } +bool CSandMan::IsSilentMode() +{ + if (!theConf->GetBool("Options/CheckSilentMode", true)) + return false; + return IsFullScreenMode(); +} void CSandMan::OnMessage(const QString& MsgData) { QStringList Messages = MsgData.split("\n"); diff --git a/SandboxiePlus/SandMan/SandMan.h b/SandboxiePlus/SandMan/SandMan.h index 34d35609..a7b93f7e 100644 --- a/SandboxiePlus/SandMan/SandMan.h +++ b/SandboxiePlus/SandMan/SandMan.h @@ -56,8 +56,9 @@ public: bool IsShowHidden() { return m_pShowHidden && m_pShowHidden->isChecked(); } bool KeepTerminated() { return m_pKeepTerminated && m_pKeepTerminated->isChecked(); } bool ShowAllSessions() { return m_pShowAllSessions && m_pShowAllSessions->isChecked(); } - bool IsDisableRecovery() {return m_pDisableRecovery && m_pDisableRecovery->isChecked();} - bool IsDisableMessages() {return m_pDisableMessages && m_pDisableMessages->isChecked();} + bool IsSilentMode(); + bool IsDisableRecovery() {return IsSilentMode() || m_pDisableRecovery && m_pDisableRecovery->isChecked();} + bool IsDisableMessages() {return IsSilentMode() || m_pDisableMessages && m_pDisableMessages->isChecked();} CSbieView* GetBoxView() { return m_pBoxView; } CFileView* GetFileView() { return m_pFileView; } diff --git a/SandboxiePlus/SandMan/SandMan.pri b/SandboxiePlus/SandMan/SandMan.pri index faea4294..014a7e8a 100644 --- a/SandboxiePlus/SandMan/SandMan.pri +++ b/SandboxiePlus/SandMan/SandMan.pri @@ -17,6 +17,7 @@ HEADERS += ./stdafx.h \ ./Views/TraceView.h \ ./Dialogs/MultiErrorDialog.h \ ./Helpers/FindTool.h \ + ./Helpers/FullScreen.h \ ./Helpers/WinAdmin.h \ ./Helpers/ReadDirectoryChanges.h \ ./Helpers/ReadDirectoryChangesPrivate.h \ @@ -46,6 +47,7 @@ SOURCES += ./main.cpp \ ./Views/TraceView.cpp \ ./Dialogs/MultiErrorDialog.cpp \ ./Helpers/FindTool.cpp \ + ./Helpers/FullScreen.cpp \ ./Helpers/WinAdmin.cpp \ ./Helpers/ReadDirectoryChanges.cpp \ ./Helpers/ReadDirectoryChangesPrivate.cpp \ diff --git a/SandboxiePlus/SandMan/SandMan.vcxproj b/SandboxiePlus/SandMan/SandMan.vcxproj index 555431cd..04b57e9c 100644 --- a/SandboxiePlus/SandMan/SandMan.vcxproj +++ b/SandboxiePlus/SandMan/SandMan.vcxproj @@ -207,6 +207,7 @@ + @@ -338,6 +339,7 @@ + diff --git a/SandboxiePlus/SandMan/SandMan.vcxproj.filters b/SandboxiePlus/SandMan/SandMan.vcxproj.filters index ca9aeb25..fb3e4f5f 100644 --- a/SandboxiePlus/SandMan/SandMan.vcxproj.filters +++ b/SandboxiePlus/SandMan/SandMan.vcxproj.filters @@ -177,6 +177,9 @@ SandMan + + Helpers + @@ -203,6 +206,9 @@ Helpers + + Helpers + diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp index a54d58c5..befec71a 100644 --- a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp @@ -600,6 +600,7 @@ void CSettingsWindow::LoadSettings() //ui.cmbFontScale->setCurrentIndex(ui.cmbFontScale->findData(theConf->GetInt("Options/FontScaling", 100))); ui.cmbFontScale->setCurrentText(QString::number(theConf->GetInt("Options/FontScaling", 100))); + ui.chkSilentMode->setChecked(theConf->GetBool("Options/CheckSilentMode", true)); ui.chkNotifications->setChecked(theConf->GetBool("Options/ShowNotifications", true)); ui.chkSandboxUrls->setCheckState(CSettingsWindow__Int2Chk(theConf->GetInt("Options/OpenUrlsSandboxed", 2))); @@ -896,6 +897,7 @@ void CSettingsWindow::SaveSettings() theConf->SetValue("Options/RunInDefaultBox", ui.chkAlwaysDefault->isChecked()); + theConf->SetValue("Options/CheckSilentMode", ui.chkSilentMode->isChecked()); theConf->SetValue("Options/ShowNotifications", ui.chkNotifications->isChecked()); theConf->SetValue("Options/OpenUrlsSandboxed", CSettingsWindow__Chk2Int(ui.chkSandboxUrls->checkState()));