This commit is contained in:
DavidXanatos 2022-01-14 17:00:03 +01:00
parent 1780e93b81
commit 401e3d3357
4 changed files with 110 additions and 57 deletions

View File

@ -29,14 +29,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- fixed issue with Util_GetProcessPidByName that should resolve the driver sometimes failing to start at boot - fixed issue with Util_GetProcessPidByName that should resolve the driver sometimes failing to start at boot
- when starting sandman because of a boxed process start it now starts in background like sbiectrl did - when starting sandman because of a boxed process start it now starts in background like sbiectrl did
- fixed taskbar not showing with persistent box border in full screen - fixed taskbar not showing with persistent box border in full screen
- fixed box border not spaning across multiple monitors - fixed box border not spaning across multiple monitors [#1512](https://github.com/sandboxie-plus/Sandboxie/issues/1512)
- fixed issues with border when using different DPI scaling on multiple monitors [#1512](https://github.com/sandboxie-plus/Sandboxie/issues/1512) [#1506](https://github.com/sandboxie-plus/Sandboxie/issues/1506) - fixed issues with border when using DPI scaling [#1506](https://github.com/sandboxie-plus/Sandboxie/issues/1506)
- fixed dpi issues with Qt [#1368](https://github.com/sandboxie-plus/Sandboxie/issues/1368) - fixed dpi issues with Qt [#1368](https://github.com/sandboxie-plus/Sandboxie/issues/1368)
- fixed issue with bright flashing on window creation when in dark mode [#1231](https://github.com/sandboxie-plus/Sandboxie/issues/1231) - fixed issue with bright flashing on window creation when in dark mode [#1231](https://github.com/sandboxie-plus/Sandboxie/issues/1231)
- fixed issues with the PortableRootDir setting [#1509](https://github.com/sandboxie-plus/Sandboxie/issues/1509) - fixed issues with the PortableRootDir setting [#1509](https://github.com/sandboxie-plus/Sandboxie/issues/1509)
## [1.0.7 / 5.55.7] - 2022-01-06 ## [1.0.7 / 5.55.7] - 2022-01-06
### Added ### Added

View File

@ -450,24 +450,28 @@ void CBorderGuard::RefreshBorder(
desktop = &monitor.rcWork; desktop = &monitor.rcWork;
int ax = rect->left; int ax = rect->left;
if (ax < desktop->left) //if (ax < desktop->left)
ax = desktop->left; // ax = desktop->left;
int ay = rect->top; int ay = rect->top;
if (ay < desktop->top) //if (ay < desktop->top)
ay = desktop->top; // ay = desktop->top;
int aw = -ax; int aw = -ax;
if (rect->right <= desktop->right) //if (rect->right <= desktop->right)
aw += rect->right; aw += rect->right;
else //else
aw += desktop->right; // aw += desktop->right;
int ah = -ay; int ah = -ay;
if (rect->bottom <= desktop->bottom) //if (rect->bottom <= desktop->bottom)
ah += rect->bottom; ah += rect->bottom;
else //else
ah += desktop->bottom; // ah += desktop->bottom;
if (rect->bottom == desktop->bottom)
ah -= 1;
//int bb = 6; //int bb = 6;
//if (rect->left <= desktop->left && //if (rect->left <= desktop->left &&

View File

@ -233,30 +233,12 @@ void CBoxBorder::timerEvent(QTimerEvent* pEvent)
return; return;
} }
Desktop = &Monitor.rcWork;
int ax = rect.left; int ax = rect.left;
//if (ax < Desktop->left)
// ax = Desktop->left;
int ay = rect.top; int ay = rect.top;
//if (ay < Desktop->top)
// ay = Desktop->top;
//if (ax == Monitor.rcMonitor.left)
// ax += 1;
//if (ay == Monitor.rcMonitor.top)
// ay += 1;
int aw = -ax; int aw = -ax;
//if (rect.right <= Desktop->right)
aw += rect.right; aw += rect.right;
//else
// aw += Desktop->right;
int ah = -ay; int ah = -ay;
//if (rect.bottom <= Desktop->bottom)
ah += rect.bottom; ah += rect.bottom;
//else
// ah += Desktop->bottom;
// //
// in windows 10 and 11 if this is truly fullscreen the taskbar does not appear when hidden // in windows 10 and 11 if this is truly fullscreen the taskbar does not appear when hidden
@ -264,9 +246,7 @@ void CBoxBorder::timerEvent(QTimerEvent* pEvent)
// but with the taskbar to the side it woudl also work // but with the taskbar to the side it woudl also work
// //
//if (rect.right == Desktop->right) if (rect.bottom == Monitor.rcWork.bottom)
// aw -= 1;
if (rect.bottom == Desktop->bottom)
ah -= 1; ah -= 1;

View File

@ -289,7 +289,7 @@ CSandMan::CSandMan(QWidget *parent)
m_pKeepTerminated->setChecked(theConf->GetBool("Options/KeepTerminated")); m_pKeepTerminated->setChecked(theConf->GetBool("Options/KeepTerminated"));
m_pShowAllSessions->setChecked(theConf->GetBool("Options/ShowAllSessions")); m_pShowAllSessions->setChecked(theConf->GetBool("Options/ShowAllSessions"));
m_pProgressDialog = new CProgressDialog("", this); m_pProgressDialog = new CProgressDialog("");
m_pProgressDialog->setWindowModality(Qt::ApplicationModal); m_pProgressDialog->setWindowModality(Qt::ApplicationModal);
connect(m_pProgressDialog, SIGNAL(Cancel()), this, SLOT(OnCancelAsync())); connect(m_pProgressDialog, SIGNAL(Cancel()), this, SLOT(OnCancelAsync()));
m_pProgressModal = false; m_pProgressModal = false;
@ -300,6 +300,8 @@ CSandMan::CSandMan(QWidget *parent)
m_pWndTopMost->setChecked(bAlwaysOnTop); m_pWndTopMost->setChecked(bAlwaysOnTop);
this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop); this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
m_pPopUpWindow->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop); m_pPopUpWindow->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
m_pProgressDialog->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
if (!bAutoRun && g_PendingMessage.isEmpty()) if (!bAutoRun && g_PendingMessage.isEmpty())
show(); show();
@ -723,7 +725,7 @@ void CSandMan::RunSandboxed(const QStringList& Commands, const QString& BoxName,
{ {
CSelectBoxWindow* pSelectBoxWindow = new CSelectBoxWindow(Commands, BoxName, WrkDir); CSelectBoxWindow* pSelectBoxWindow = new CSelectBoxWindow(Commands, BoxName, WrkDir);
//pSelectBoxWindow->show(); //pSelectBoxWindow->show();
pSelectBoxWindow->exec(); SafeExec(pSelectBoxWindow);
} }
void CSandMan::dropEvent(QDropEvent* e) void CSandMan::dropEvent(QDropEvent* e)
@ -1549,7 +1551,7 @@ void CSandMan::OnMaintenance()
if (Status.GetStatus() == OP_ASYNC) { if (Status.GetStatus() == OP_ASYNC) {
//statusBar()->showMessage(tr("Executing maintenance operation, please wait...")); //statusBar()->showMessage(tr("Executing maintenance operation, please wait..."));
m_pProgressDialog->OnStatusMessage(tr("Executing maintenance operation, please wait...")); m_pProgressDialog->OnStatusMessage(tr("Executing maintenance operation, please wait..."));
m_pProgressDialog->show(); SafeShow(m_pProgressDialog);
return; return;
} }
@ -1570,6 +1572,7 @@ void CSandMan::OnAlwaysTop()
this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop); this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
this->show(); // why is this needed? this->show(); // why is this needed?
m_pPopUpWindow->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop); m_pPopUpWindow->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
m_pProgressDialog->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
} }
void CSandMan::SetViewMode(bool bAdvanced) void CSandMan::SetViewMode(bool bAdvanced)
@ -1636,7 +1639,7 @@ void CSandMan::OnSettings()
connect(pSettingsWindow, &CSettingsWindow::Closed, [this]() { connect(pSettingsWindow, &CSettingsWindow::Closed, [this]() {
pSettingsWindow = NULL; pSettingsWindow = NULL;
}); });
pSettingsWindow->show(); SafeShow(pSettingsWindow);
} }
} }
@ -1761,11 +1764,11 @@ bool CSandMan::AddAsyncOp(const CSbieProgressPtr& pProgress, bool bWait)
m_pProgressDialog->OnStatusMessage(""); m_pProgressDialog->OnStatusMessage("");
if (bWait) { if (bWait) {
m_pProgressModal = true; m_pProgressModal = true;
m_pProgressDialog->exec(); SafeExec(m_pProgressDialog);
m_pProgressModal = false; m_pProgressModal = false;
} }
else else
m_pProgressDialog->show(); SafeShow(m_pProgressDialog);
if (pProgress->IsFinished()) // Note: since the operation runs asynchronously, it may have already finished, so we need to test for that if (pProgress->IsFinished()) // Note: since the operation runs asynchronously, it may have already finished, so we need to test for that
OnAsyncFinished(pProgress.data()); OnAsyncFinished(pProgress.data());
@ -2324,7 +2327,7 @@ void CSandMan::OnAbout()
QIcon ico(QLatin1String(":/SandMan.png")); QIcon ico(QLatin1String(":/SandMan.png"));
msgBox->setIconPixmap(ico.pixmap(128, 128)); msgBox->setIconPixmap(ico.pixmap(128, 128));
msgBox->exec(); SafeExec(msgBox);
} }
else if (sender() == m_pAboutQt) else if (sender() == m_pAboutQt)
QMessageBox::aboutQt(this); QMessageBox::aboutQt(this);
@ -2550,11 +2553,63 @@ QT_TRANSLATE_NOOP("CSandBox", "Finishing Snapshot Merge..."),
#include <windows.h> #include <windows.h>
#include "Helpers/FindTool.h" #include "Helpers/FindTool.h"
typedef enum DEVICE_SCALE_FACTOR {
DEVICE_SCALE_FACTOR_INVALID = 0,
SCALE_100_PERCENT = 100,
SCALE_120_PERCENT = 120,
SCALE_125_PERCENT = 125,
SCALE_140_PERCENT = 140,
SCALE_150_PERCENT = 150,
SCALE_160_PERCENT = 160,
SCALE_175_PERCENT = 175,
SCALE_180_PERCENT = 180,
SCALE_200_PERCENT = 200,
SCALE_225_PERCENT = 225,
SCALE_250_PERCENT = 250,
SCALE_300_PERCENT = 300,
SCALE_350_PERCENT = 350,
SCALE_400_PERCENT = 400,
SCALE_450_PERCENT = 450,
SCALE_500_PERCENT = 500
} DEVICE_SCALE_FACTOR;
typedef HRESULT (CALLBACK *P_GetScaleFactorForMonitor)(HMONITOR, DEVICE_SCALE_FACTOR*);
UINT GetMonitorScaling(HWND hwnd)
{
static HINSTANCE shcore = LoadLibrary(L"Shcore.dll");
if (shcore != nullptr)
{
if (auto getScaleFactorForMonitor =
P_GetScaleFactorForMonitor(GetProcAddress(shcore, "GetScaleFactorForMonitor")))
{
HMONITOR monitor =
MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
DEVICE_SCALE_FACTOR Scale;
getScaleFactorForMonitor(monitor, &Scale);
return Scale;
}
}
return 0;
}
#define IDD_FINDER_TOOL 111 #define IDD_FINDER_TOOL 111
#define ID_FINDER_TARGET 112 #define ID_FINDER_TARGET 112
#define ID_FINDER_EXPLAIN 113 #define ID_FINDER_EXPLAIN 113
#define ID_FINDER_RESULT 114 #define ID_FINDER_RESULT 114
struct SFinderWndData {
int Scale;
HFONT hFont;
};
#define DS(x) ((x) * WndData.Scale / 100)
UINT CALLBACK FindProc(HWND hwndTool, UINT uCode, HWND hwnd) UINT CALLBACK FindProc(HWND hwndTool, UINT uCode, HWND hwnd)
{ {
ULONG pid; ULONG pid;
@ -2565,12 +2620,14 @@ UINT CALLBACK FindProc(HWND hwndTool, UINT uCode, HWND hwnd)
hwndTool = GetParent(hwndTool); hwndTool = GetParent(hwndTool);
SFinderWndData &WndData = *(SFinderWndData*)GetWindowLongPtr(hwndTool, 0);
if (pid && pid != GetCurrentProcessId()) if (pid && pid != GetCurrentProcessId())
{ {
RECT rc; RECT rc;
GetWindowRect(hwndTool, &rc); GetWindowRect(hwndTool, &rc);
if (rc.bottom - rc.top <= 150) if (rc.bottom - rc.top <= DS(150))
SetWindowPos(hwndTool, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top + 70, SWP_SHOWWINDOW | SWP_NOMOVE); SetWindowPos(hwndTool, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top + DS(70), SWP_SHOWWINDOW | SWP_NOMOVE);
CBoxedProcessPtr pProcess = theAPI->GetProcessById(pid); CBoxedProcessPtr pProcess = theAPI->GetProcessById(pid);
if (!pProcess.isNull()) if (!pProcess.isNull())
@ -2593,8 +2650,8 @@ UINT CALLBACK FindProc(HWND hwndTool, UINT uCode, HWND hwnd)
{ {
RECT rc; RECT rc;
GetWindowRect(hwndTool, &rc); GetWindowRect(hwndTool, &rc);
if (rc.bottom - rc.top > 150) if (rc.bottom - rc.top > DS(150))
SetWindowPos(hwndTool, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top - 70, SWP_SHOWWINDOW | SWP_NOMOVE); SetWindowPos(hwndTool, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top - DS(70), SWP_SHOWWINDOW | SWP_NOMOVE);
//::ShowWindow(GetDlgItem(hwndTool, ID_FINDER_YES_BOXED), SW_HIDE); //::ShowWindow(GetDlgItem(hwndTool, ID_FINDER_YES_BOXED), SW_HIDE);
//::ShowWindow(GetDlgItem(hwndTool, ID_FINDER_NOT_BOXED), SW_HIDE); //::ShowWindow(GetDlgItem(hwndTool, ID_FINDER_NOT_BOXED), SW_HIDE);
@ -2617,11 +2674,21 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
case WM_CREATE: case WM_CREATE:
{ {
CREATESTRUCT* createStruct = (CREATESTRUCT*)lParam;
SFinderWndData &WndData = *(SFinderWndData*)createStruct->lpCreateParams;
SetWindowLongPtr(hwnd, 0, (LONG_PTR)&WndData);
wstring info = CSandMan::tr("Drag the Finder Tool over a window to select it, then release the mouse to check if the window is sandboxed.").toStdWString(); wstring info = CSandMan::tr("Drag the Finder Tool over a window to select it, then release the mouse to check if the window is sandboxed.").toStdWString();
CreateWindow(L"Static", L"", SS_BITMAP | SS_NOTIFY | WS_VISIBLE | WS_CHILD, 10, 10, 32, 32, hwnd, (HMENU)ID_FINDER_TARGET, NULL, NULL); CreateWindow(L"Static", L"", SS_BITMAP | SS_NOTIFY | WS_VISIBLE | WS_CHILD, DS(10), DS(10), DS(32), DS(32), hwnd, (HMENU)ID_FINDER_TARGET, NULL, NULL);
CreateWindow(L"Static", info.c_str(), WS_VISIBLE | WS_CHILD, 60, 10, 180, 65, hwnd, (HMENU)ID_FINDER_EXPLAIN, NULL, NULL); CreateWindow(L"Static", info.c_str(), WS_VISIBLE | WS_CHILD, DS(60), DS(10), DS(180), DS(85), hwnd, (HMENU)ID_FINDER_EXPLAIN, NULL, NULL);
CreateWindow(L"Static", L"", WS_CHILD, 60, 80, 180, 50, hwnd, (HMENU)ID_FINDER_RESULT, NULL, NULL); CreateWindow(L"Static", L"", WS_CHILD, DS(60), DS(100), DS(180), DS(50), hwnd, (HMENU)ID_FINDER_RESULT, NULL, NULL);
WndData.hFont = CreateFont(DS(13), 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma"));
SendMessage(GetDlgItem(hwnd, ID_FINDER_EXPLAIN), WM_SETFONT, (WPARAM)WndData.hFont, TRUE);
SendMessage(GetDlgItem(hwnd, ID_FINDER_RESULT), WM_SETFONT, (WPARAM)WndData.hFont, TRUE);
MakeFinderTool(GetDlgItem(hwnd, ID_FINDER_TARGET), FindProc); MakeFinderTool(GetDlgItem(hwnd, ID_FINDER_TARGET), FindProc);
@ -2629,7 +2696,10 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
} }
case WM_CLOSE: case WM_CLOSE:
SFinderWndData &WndData = *(SFinderWndData*)GetWindowLongPtr(hwnd, 0);
//DestroyWindow(hwnd); //DestroyWindow(hwnd);
DeleteObject(WndData.hFont);
PostQuitMessage(0); PostQuitMessage(0);
break; break;
} }
@ -2654,6 +2724,8 @@ DWORD WINAPI FinderThreadFunc(LPVOID lpParam)
mainWindowClass.lpfnWndProc = WndProc; mainWindowClass.lpfnWndProc = WndProc;
mainWindowClass.hCursor = LoadCursor(0, IDC_ARROW); mainWindowClass.hCursor = LoadCursor(0, IDC_ARROW);
mainWindowClass.cbWndExtra = sizeof(void*);
RegisterClass(&mainWindowClass); RegisterClass(&mainWindowClass);
// Notes: // Notes:
@ -2672,13 +2744,11 @@ DWORD WINAPI FinderThreadFunc(LPVOID lpParam)
// identifier; it must be unique for all // identifier; it must be unique for all
// child windows with the same parent window. // child windows with the same parent window.
SFinderWndData WndData;
WndData.Scale = GetMonitorScaling(MainWndHandle);
HWND hwnd = CreateWindow(mainWindowClass.lpszClassName, CSandMan::tr("Sandboxie-Plus - Window Finder").toStdWString().c_str() HWND hwnd = CreateWindow(mainWindowClass.lpszClassName, CSandMan::tr("Sandboxie-Plus - Window Finder").toStdWString().c_str()
, WS_SYSMENU | WS_CAPTION | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 275, 115, NULL, 0, hInstance, NULL); , WS_SYSMENU | WS_CAPTION | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, DS(275), DS(135), NULL, 0, hInstance, &WndData);
HFONT hFont = CreateFont(13, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma"));
SendMessage(GetDlgItem(hwnd, ID_FINDER_EXPLAIN), WM_SETFONT, (WPARAM)hFont, TRUE);
SendMessage(GetDlgItem(hwnd, ID_FINDER_RESULT), WM_SETFONT, (WPARAM)hFont, TRUE);
while (GetMessage(&msg, NULL, 0, 0)) while (GetMessage(&msg, NULL, 0, 0))
{ {
@ -2686,8 +2756,6 @@ DWORD WINAPI FinderThreadFunc(LPVOID lpParam)
DispatchMessage(&msg); DispatchMessage(&msg);
} }
DeleteObject(hFont);
return (int)msg.wParam; return (int)msg.wParam;
} }