diff --git a/mmwnd/mmwnd/mmwnd.cpp b/mmwnd/mmwnd/mmwnd.cpp index 2b1d48e..904c089 100644 --- a/mmwnd/mmwnd/mmwnd.cpp +++ b/mmwnd/mmwnd/mmwnd.cpp @@ -107,6 +107,14 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM param1, LPARAM param2) { log(_T("hook reinstalled")); break; } + case ID_POPUP_IGNORETOOLARGE: { + bool ignore_too_large = false; + profile() >> PROFILE_ENTRY_IGNORETOOLARGE >> ignore_too_large; + ignore_too_large = !ignore_too_large; + profile() << PROFILE_ENTRY_IGNORETOOLARGE << ignore_too_large; + log() << _T("toggle ignore too large: ") + << ignore_too_large << std::endl; + } case ID_POPUP_SHOWTRAYICON: log(_T("hide tray icon")); if (the_notify_icon().uninstall()) { @@ -133,6 +141,10 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM param1, LPARAM param2) { profile() >> PROFILE_ENTRY_RESTRICTMOVEMENT >> restrict_movement; ::CheckMenuItem(popup, ID_POPUP_RESTRICTMOVEMENT, restrict_movement ? MF_CHECKED : MF_UNCHECKED); + bool ignore_too_large = false; + profile() >> PROFILE_ENTRY_IGNORETOOLARGE >> ignore_too_large; + ::CheckMenuItem(popup, ID_POPUP_IGNORETOOLARGE, + ignore_too_large ? MF_CHECKED : MF_UNCHECKED); ::SetForegroundWindow(hwnd); POINT pt; diff --git a/mmwnd/mmwnd/mmwnd.rc b/mmwnd/mmwnd/mmwnd.rc index 5c60479..5720b12 100644 --- a/mmwnd/mmwnd/mmwnd.rc +++ b/mmwnd/mmwnd/mmwnd.rc @@ -57,6 +57,7 @@ BEGIN POPUP "popup" BEGIN MENUITEM "restrict &movement", ID_POPUP_RESTRICTMOVEMENT, CHECKED + MENUITEM "ignore too large", ID_POPUP_IGNORETOOLARGE, CHECKED MENUITEM "show &tray icon", ID_POPUP_SHOWTRAYICON, CHECKED MENUITEM "&reset", ID_POPUP_RESET MENUITEM "e&xit", ID_POPUP_EXIT diff --git a/mmwnd/mmwnd/profile.h b/mmwnd/mmwnd/profile.h index bfe080c..66201c3 100644 --- a/mmwnd/mmwnd/profile.h +++ b/mmwnd/mmwnd/profile.h @@ -2,9 +2,11 @@ #define MMWND_PROFILE_H_INCLUDED #include "../common/profile.hpp" -#define PROFILE_ENTRY_NOTIFYICON \ +#define PROFILE_ENTRY_NOTIFYICON \ gnn::ini_profile::entry(_T("settings"), _T("notify_icon")) -#define PROFILE_ENTRY_RESTRICTMOVEMENT \ +#define PROFILE_ENTRY_RESTRICTMOVEMENT \ gnn::ini_profile::entry(_T("settings"), _T("restrict_movement")) +#define PROFILE_ENTRY_IGNORETOOLARGE \ + gnn::ini_profile::entry(_T("settings"), _T("ignore_too_large")) #endif // !MMWND_PROFILE_H_INCLUDED diff --git a/mmwnd/mmwnd/resource.h b/mmwnd/mmwnd/resource.h index 25092ba..599d7b7 100644 --- a/mmwnd/mmwnd/resource.h +++ b/mmwnd/mmwnd/resource.h @@ -8,13 +8,14 @@ #define ID_POPUP_SHOWTRAYICON 40002 #define ID_POPUP_RESTRICTMOVEMENT 40003 #define ID_POPUP_RESET 40004 +#define ID_POPUP_IGNORETOOLARGE 40005 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 103 -#define _APS_NEXT_COMMAND_VALUE 40005 +#define _APS_NEXT_COMMAND_VALUE 40006 #define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/mmwnd/mmwndhook/mmwndhook_impl.h b/mmwnd/mmwndhook/mmwndhook_impl.h index cb4ff33..a2e3533 100644 --- a/mmwnd/mmwndhook/mmwndhook_impl.h +++ b/mmwnd/mmwndhook/mmwndhook_impl.h @@ -125,6 +125,22 @@ bool adjust_pos(HWND hwnd, UINT msg) { if (pt.x == rect.left && pt.y == rect.top) return false; // no change + bool ignore_too_large = false; + profile() >> PROFILE_ENTRY_IGNORETOOLARGE >> ignore_too_large; + if (ignore_too_large) { + POINT mtl = { mi.rcWork.left, mi.rcWork.top }; + POINT mbr = { mi.rcWork.right, mi.rcWork.bottom }; + + // ignore too large window + if (::PtInRect(&rect, mtl) && ::PtInRect(&rect, mbr)) return false; + + // ignore if the window cannot be fit in the monitor + if (mi.rcWork.right < pt.x + width || + mi.rcWork.bottom < pt.y + height) return false; + + log() << _T("ignore_too_large did not ignore") << std::endl; + } + // ignore specific window class TCHAR class_name[_MAX_PATH]; ::GetClassName(hwnd, class_name, _MAX_PATH);