Skip to content

Commit

Permalink
Merge pull request #3 from ErrorFlynn/v1.1-changes-1
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
ErrorFlynn authored May 23, 2017
2 parents dd5c8b1 + ece89a0 commit 80913b6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
16 changes: 11 additions & 5 deletions Borderless Window Helper/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ void mon_timer_fn()
if(!win.borderless) // remove borders
{
MONITORINFO mi = {sizeof(mi)};
GetMonitorInfoW(MonitorFromWindow(win.hwnd, MONITOR_DEFAULTTOPRIMARY), &mi);
GetMonitorInfoW(win.monitor, &mi);
SetWindowLongPtr(win.hwnd, GWL_STYLE, (monwin.second.style & ~(WS_CAPTION|WS_THICKFRAME)) | WS_POPUP);
SetWindowPos(win.hwnd, HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right - mi.rcMonitor.left,
mi.rcMonitor.bottom - mi.rcMonitor.top, SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
Expand All @@ -401,10 +401,15 @@ void mon_timer_fn()
HWND fghwnd = GetForegroundWindow();
if(monwin.second.active)
{
if(fghwnd != win.hwnd)
if(fghwnd != win.hwnd && win.monitor == MonitorFromWindow(fghwnd, MONITOR_DEFAULTTOPRIMARY))
{
monwin.second.active = false;
PostMessage(win.hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
string fgclassname(1024, '\0');
fgclassname.resize(GetClassNameA(fghwnd, &fgclassname.front(), fgclassname.size()));
if(fgclassname != "TaskSwitcherWnd")
{
monwin.second.active = false;
PostMessage(win.hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
}
}
}
else if(fghwnd == win.hwnd) monwin.second.active = true;
Expand Down Expand Up @@ -499,6 +504,7 @@ void enum_windows()
filepath procpath(procname);
win.procnamew = procpath.fullnamew();
win.hwnd = hwnd;
win.monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY);
win.captionw = caption;
if(!(style & (WS_CAPTION|WS_THICKFRAME))) win.borderless = true;
windows[procpath.fullname()] = win;
Expand Down Expand Up @@ -590,4 +596,4 @@ void SaveSettings()
ini.WriteString(s, "p", monwin.first);
ini.WriteInt(s, "s", monwin.second.style);
}
}
}
14 changes: 9 additions & 5 deletions Borderless Window Helper/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@

#include "util.h"
#include <string>
#include <cassert>
#include <map>

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

#define TITLE "Borderless Window Helper 1.0"
#define TITLEW L"Borderless Window Helper 1.0"
#define TITLE "Borderless Window Helper 1.1"
#define TITLEW L"Borderless Window Helper 1.1"

using namespace std;
using namespace nana;

string last;
wstring inifile;
filepath self_path;
HWND hwnd, balloon(0);
HWND hwnd;
bool mintray(true);

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

struct enumwin
{
DWORD procid = 0; wstring procnamew; HWND hwnd; wstring captionw; bool borderless = false;
DWORD procid = 0;
wstring procnamew;
HWND hwnd = nullptr;
HMONITOR monitor = nullptr;
wstring captionw;
bool borderless = false;
};

map<string, enumwin> windows;
Expand Down

0 comments on commit 80913b6

Please sign in to comment.