This commit is contained in:
DavidXanatos 2022-06-29 08:40:58 +02:00
parent e372da76ad
commit c9fbb20918
3 changed files with 15 additions and 15 deletions

View File

@ -1,6 +1,6 @@
/* /*
* *
* Copyright (c) 2020, David Xanatos * Copyright (c) 2020-2022, David Xanatos
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -53,6 +53,8 @@ const WCHAR *Sandboxie_WindowClassName = L"Sandboxie_BorderWindow";
CBoxBorder::CBoxBorder(CSbieAPI* pApi, QObject* parent) : QThread(parent) CBoxBorder::CBoxBorder(CSbieAPI* pApi, QObject* parent) : QThread(parent)
{ {
m = NULL;
m_Api = pApi; m_Api = pApi;
m_Running = true; m_Running = true;
@ -186,6 +188,7 @@ void CBoxBorder::run()
m->ActiveWnd = NULL; m->ActiveWnd = NULL;
m->ActivePid = 0; m->ActivePid = 0;
hide:
if (m->IsBorderVisible) if (m->IsBorderVisible)
{ {
::ShowWindow(m->BorderWnd, SW_HIDE); ::ShowWindow(m->BorderWnd, SW_HIDE);
@ -199,35 +202,31 @@ void CBoxBorder::run()
if (NothingChanged(hWnd, &rect, pid)) if (NothingChanged(hWnd, &rect, pid))
continue; continue;
if (m->IsBorderVisible)
::ShowWindow(m->BorderWnd, SW_HIDE);
m->IsBorderVisible = FALSE;
m->ActiveWnd = hWnd; m->ActiveWnd = hWnd;
m->ActivePid = pid; m->ActivePid = pid;
memcpy(&m->ActiveRect, &rect, sizeof(RECT)); memcpy(&m->ActiveRect, &rect, sizeof(RECT));
m->TitleState = 0; m->TitleState = 0;
if (rect.right - rect.left <= 2 || rect.bottom - rect.top <= 2) if (rect.right - rect.left <= 2 || rect.bottom - rect.top <= 2)
continue; goto hide;
HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL); HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL);
if (!hMonitor) if (!hMonitor)
continue; goto hide;
MONITORINFO Monitor; MONITORINFO Monitor;
memset(&Monitor, 0, sizeof(MONITORINFO)); memset(&Monitor, 0, sizeof(MONITORINFO));
Monitor.cbSize = sizeof(MONITORINFO); Monitor.cbSize = sizeof(MONITORINFO);
if (!GetMonitorInfo(hMonitor, &Monitor)) if (!GetMonitorInfo(hMonitor, &Monitor))
continue; goto hide;
const RECT *Desktop = &Monitor.rcMonitor; const RECT *Desktop = &Monitor.rcMonitor;
if (rect.left <= Desktop->left && rect.top <= Desktop->top && if (rect.left <= Desktop->left && rect.top <= Desktop->top &&
rect.right >= Desktop->right && rect.bottom >= Desktop->bottom && rect.right >= Desktop->right && rect.bottom >= Desktop->bottom &&
(Style & WS_CAPTION) != WS_CAPTION) (Style & WS_CAPTION) != WS_CAPTION)
continue; goto hide;
if (m->BorderMode == 2) { if (m->BorderMode == 2) {
if(!IsMounseOnTitle(hWnd, &rect, Desktop)) if(!IsMounseOnTitle(hWnd, &rect, Desktop))
continue; goto hide;
} }
@ -261,7 +260,6 @@ void CBoxBorder::run()
if (rect.bottom == Monitor.rcWork.bottom) if (rect.bottom == Monitor.rcWork.bottom)
ah -= 1; ah -= 1;
POINT Points[10]; POINT Points[10];
int PointCount = 0; int PointCount = 0;
@ -282,8 +280,9 @@ void CBoxBorder::run()
HRGN hrgn = CreatePolygonRgn(Points, PointCount, ALTERNATE); HRGN hrgn = CreatePolygonRgn(Points, PointCount, ALTERNATE);
SetWindowRgn(m->BorderWnd, hrgn, TRUE); SetWindowRgn(m->BorderWnd, hrgn, TRUE);
SetWindowPos(m->BorderWnd, NULL, ax, ay, aw, ah, SWP_SHOWWINDOW | SWP_NOACTIVATE); DeleteObject(hrgn);
SetWindowPos(m->BorderWnd, NULL, ax, ay, aw, ah, SWP_SHOWWINDOW | SWP_NOACTIVATE);
m->IsBorderVisible = TRUE; m->IsBorderVisible = TRUE;
} }
} }
@ -296,6 +295,7 @@ void CBoxBorder::run()
} }
delete m; delete m;
m = NULL;
} }

View File

@ -1,6 +1,6 @@
/* /*
* *
* Copyright (c) 2020, David Xanatos * Copyright (c) 2020-2022, David Xanatos
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View File

@ -741,7 +741,7 @@ void CSettingsWindow::OnTab()
QSharedPointer<CSbieIni> pTemplate = QSharedPointer<CSbieIni>(new CSbieIni("Template_" + I.key(), theAPI)); QSharedPointer<CSbieIni> pTemplate = QSharedPointer<CSbieIni>(new CSbieIni("Template_" + I.key(), theAPI));
QString Title = pTemplate->GetText("Tmpl.Title"); QString Title = pTemplate->GetText("Tmpl.Title", "", false, true, true);
if (Title.left(1) == "#") if (Title.left(1) == "#")
{ {
int End = Title.mid(1).indexOf(","); int End = Title.mid(1).indexOf(",");