Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_event_system.c
| Show First 20 Lines • Show All 2,031 Lines • ▼ Show 20 Lines | static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi) | ||||
| if (kmi->val == KM_CLICK_DRAG) { | if (kmi->val == KM_CLICK_DRAG) { | ||||
| if (kmi->direction != KM_ANY) { | if (kmi->direction != KM_ANY) { | ||||
| if (kmi->direction != winevent->direction) { | if (kmi->direction != winevent->direction) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| const bool shift = (winevent->modifier & KM_SHIFT) != 0; | /* Account for rare case of when these keys are used as the 'type' not as modifiers. */ | ||||
| const bool ctrl = (winevent->modifier & KM_CTRL) != 0; | |||||
| const bool alt = (winevent->modifier & KM_ALT) != 0; | |||||
| const bool oskey = (winevent->modifier & KM_OSKEY) != 0; | |||||
| /* Modifiers also check bits, so it allows modifier order. | |||||
| * Account for rare case of when these keys are used as the 'type' not as modifiers. */ | |||||
| if (kmi->shift != KM_ANY) { | if (kmi->shift != KM_ANY) { | ||||
| if ((shift != kmi->shift) && !(shift & kmi->shift) && | const bool shift = (winevent->modifier & KM_SHIFT) != 0; | ||||
| !ELEM(winevent->type, EVT_LEFTSHIFTKEY, EVT_RIGHTSHIFTKEY)) { | if ((shift != kmi->shift) && !ELEM(winevent->type, EVT_LEFTSHIFTKEY, EVT_RIGHTSHIFTKEY)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| if (kmi->ctrl != KM_ANY) { | if (kmi->ctrl != KM_ANY) { | ||||
| if (ctrl != kmi->ctrl && !(ctrl & kmi->ctrl) && | const bool ctrl = (winevent->modifier & KM_CTRL) != 0; | ||||
| !ELEM(winevent->type, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY)) { | if (ctrl != kmi->ctrl && !ELEM(winevent->type, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| if (kmi->alt != KM_ANY) { | if (kmi->alt != KM_ANY) { | ||||
| if (alt != kmi->alt && !(alt & kmi->alt) && | const bool alt = (winevent->modifier & KM_ALT) != 0; | ||||
| !ELEM(winevent->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY)) { | if (alt != kmi->alt && !ELEM(winevent->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| if (kmi->oskey != KM_ANY) { | if (kmi->oskey != KM_ANY) { | ||||
| if (oskey != kmi->oskey && !(oskey & kmi->oskey) && (winevent->type != EVT_OSKEY)) { | const bool oskey = (winevent->modifier & KM_OSKEY) != 0; | ||||
| if ((oskey != kmi->oskey) && (winevent->type != EVT_OSKEY)) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| /* Only keymap entry with keymodifier is checked, | /* Only keymap entry with keymodifier is checked, | ||||
| * means all keys without modifier get handled too. */ | * means all keys without modifier get handled too. */ | ||||
| /* That is currently needed to make overlapping events work (when you press A - G fast or so). */ | /* That is currently needed to make overlapping events work (when you press A - G fast or so). */ | ||||
| if (kmi->keymodifier) { | if (kmi->keymodifier) { | ||||
| ▲ Show 20 Lines • Show All 3,583 Lines • Show Last 20 Lines | |||||