Skip to content

Commit

Permalink
Add option 'ignore too large'.
Browse files Browse the repository at this point in the history
  • Loading branch information
tarao committed Mar 19, 2011
1 parent aa776fd commit a1b687b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
12 changes: 12 additions & 0 deletions mmwnd/mmwnd/mmwnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions mmwnd/mmwnd/mmwnd.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions mmwnd/mmwnd/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion mmwnd/mmwnd/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions mmwnd/mmwndhook/mmwndhook_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a1b687b

Please sign in to comment.