Browse files

Refactor into a new HotInputLevelAllowsFiring function that can be us…

…ed for

both hotkeys and hotstrings.
  • Loading branch information...
1 parent d388d46 commit c08aa1778bb6059d5ab2c03c186cf2f4c04c23b4 @russelldavis committed Nov 26, 2011
Showing with 17 additions and 11 deletions.
  1. +16 −11 source/hotkey.cpp
  2. +1 −0 source/hotkey.h
View
27 source/hotkey.cpp
@@ -586,6 +586,21 @@ HotkeyVariant *Hotkey::CriterionAllowsFiring(HWND *aFoundHWND)
return vp_to_fire; // Either NULL or the variant found by the loop.
}
+bool HotInputLevelAllowsFiring(SendLevelType inputLevel, ULONG_PTR aEventExtraInfo, LPTSTR aKeyHistoryChar)
+{
+ if (aEventExtraInfo >= KEY_IGNORE_MIN && aEventExtraInfo <= KEY_IGNORE_MAX)
+ {
+ // We can safely cast here since aExtraInfo is constrained above
+ int eventInputLevel = (int)(KEY_IGNORE_LEVEL(0) - aEventExtraInfo);
+ if (eventInputLevel <= inputLevel) {
+ if (aKeyHistoryChar)
+ *aKeyHistoryChar = 'z'; // Mark as ignored in KeyHistory
+ return false;
+ }
+ }
+ return true;
+}
+
HotkeyVariant *Hotkey::CriterionFiringIsCertain(HotkeyIDType &aHotkeyIDwithFlags, bool aKeyUp, ULONG_PTR aExtraInfo
, UCHAR &aNoSuppress, bool &aFireWithNoSuppress, LPTSTR aSingleChar)
@@ -594,17 +609,7 @@ HotkeyVariant *Hotkey::CriterionFiringIsCertain(HotkeyIDType &aHotkeyIDwithFlags
if (!hkv)
return NULL;
- if (aExtraInfo >= KEY_IGNORE_MIN && aExtraInfo <= KEY_IGNORE_MAX)
- {
- // We can safely cast here since aExtraInfo is constrained above
- int level = (int)(KEY_IGNORE_LEVEL(0) - aExtraInfo);
- if (level <= hkv->mInputLevel) {
- if (aSingleChar)
- *aSingleChar = 'z'; // Mark as ignored in KeyHistory
- return NULL;
- }
- }
- return hkv;
+ return HotInputLevelAllowsFiring(hkv->mInputLevel, aExtraInfo, aSingleChar) ? hkv : NULL;
}
View
1 source/hotkey.h
@@ -61,6 +61,7 @@ typedef UCHAR HotCriterionType;
// L4: Added HOT_IF_EXPR and aHotExprIndex for #if (expression).
enum HotCriterionEnum {HOT_NO_CRITERION, HOT_IF_ACTIVE, HOT_IF_NOT_ACTIVE, HOT_IF_EXIST, HOT_IF_NOT_EXIST, HOT_IF_EXPR}; // HOT_NO_CRITERION must be zero.
HWND HotCriterionAllowsFiring(HotCriterionType aHotCriterion, LPTSTR aWinTitle, LPTSTR aWinText, int aHotExprIndex, LPTSTR aHotkeyName); // Used by hotkeys and hotstrings.
+bool HotInputLevelAllowsFiring(SendLevelType inputLevel, ULONG_PTR aEventExtraInfo, LPTSTR aKeyHistoryChar);
ResultType SetGlobalHotTitleText(LPTSTR aWinTitle, LPTSTR aWinText);

0 comments on commit c08aa17

Please sign in to comment.