Skip to content

Commit 80913b6

Browse files
authored
Merge pull request #3 from ErrorFlynn/v1.1-changes-1
Add files via upload
2 parents dd5c8b1 + ece89a0 commit 80913b6

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

Borderless Window Helper/main.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ void mon_timer_fn()
392392
if(!win.borderless) // remove borders
393393
{
394394
MONITORINFO mi = {sizeof(mi)};
395-
GetMonitorInfoW(MonitorFromWindow(win.hwnd, MONITOR_DEFAULTTOPRIMARY), &mi);
395+
GetMonitorInfoW(win.monitor, &mi);
396396
SetWindowLongPtr(win.hwnd, GWL_STYLE, (monwin.second.style & ~(WS_CAPTION|WS_THICKFRAME)) | WS_POPUP);
397397
SetWindowPos(win.hwnd, HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right - mi.rcMonitor.left,
398398
mi.rcMonitor.bottom - mi.rcMonitor.top, SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
@@ -401,10 +401,15 @@ void mon_timer_fn()
401401
HWND fghwnd = GetForegroundWindow();
402402
if(monwin.second.active)
403403
{
404-
if(fghwnd != win.hwnd)
404+
if(fghwnd != win.hwnd && win.monitor == MonitorFromWindow(fghwnd, MONITOR_DEFAULTTOPRIMARY))
405405
{
406-
monwin.second.active = false;
407-
PostMessage(win.hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
406+
string fgclassname(1024, '\0');
407+
fgclassname.resize(GetClassNameA(fghwnd, &fgclassname.front(), fgclassname.size()));
408+
if(fgclassname != "TaskSwitcherWnd")
409+
{
410+
monwin.second.active = false;
411+
PostMessage(win.hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
412+
}
408413
}
409414
}
410415
else if(fghwnd == win.hwnd) monwin.second.active = true;
@@ -499,6 +504,7 @@ void enum_windows()
499504
filepath procpath(procname);
500505
win.procnamew = procpath.fullnamew();
501506
win.hwnd = hwnd;
507+
win.monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY);
502508
win.captionw = caption;
503509
if(!(style & (WS_CAPTION|WS_THICKFRAME))) win.borderless = true;
504510
windows[procpath.fullname()] = win;
@@ -590,4 +596,4 @@ void SaveSettings()
590596
ini.WriteString(s, "p", monwin.first);
591597
ini.WriteInt(s, "s", monwin.second.style);
592598
}
593-
}
599+
}

Borderless Window Helper/main.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,22 @@
55

66
#include "util.h"
77
#include <string>
8-
#include <cassert>
98
#include <map>
109

1110
#pragma warning( disable : 4800 4267 4996)
1211
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
1312
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
1413

15-
#define TITLE "Borderless Window Helper 1.0"
16-
#define TITLEW L"Borderless Window Helper 1.0"
14+
#define TITLE "Borderless Window Helper 1.1"
15+
#define TITLEW L"Borderless Window Helper 1.1"
1716

1817
using namespace std;
1918
using namespace nana;
2019

2120
string last;
2221
wstring inifile;
2322
filepath self_path;
24-
HWND hwnd, balloon(0);
23+
HWND hwnd;
2524
bool mintray(true);
2625

2726
struct monwin
@@ -36,7 +35,12 @@ map<string, monwin> monwins;
3635

3736
struct enumwin
3837
{
39-
DWORD procid = 0; wstring procnamew; HWND hwnd; wstring captionw; bool borderless = false;
38+
DWORD procid = 0;
39+
wstring procnamew;
40+
HWND hwnd = nullptr;
41+
HMONITOR monitor = nullptr;
42+
wstring captionw;
43+
bool borderless = false;
4044
};
4145

4246
map<string, enumwin> windows;

0 commit comments

Comments
 (0)