Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-03-02 07:07:00 +0300
committerCampbell Barton <campbell@blender.org>2022-03-02 07:31:50 +0300
commit4986f718482b061082936f1f6aa13929741093a2 (patch)
tree21ea0b78e1182d35b44b4955ff308b8df1148b19 /source/blender/windowmanager/intern/wm_keymap.c
parent426ff481a789017bd5810a2064ec06a298a6f2dc (diff)
Event System: remove tweak events in favor of click-drag
Supporting two kinds of dragging is redundant, remove tweak events as they only supported 3 mouse buttons and added complexity from using the 'value' to store directions. Support only click-drag events (KM_CLICK_DRAG) which can be used with any keyboard or mouse button. Details: - A "direction" member has been added to keymap items and events which can be used when the event value is set to KM_CLICK_DRAG. - Keymap items are version patched. - Loading older key-maps are also updated. - Currently the key-maps stored in ./release/scripts/presets/keyconfig/ still reference tweak events & need updating. For now they are updated on load. Note that in general this wont impact add-ons as modal operators don't receive tweak events. Reviewed By: brecht Ref D14214
Diffstat (limited to 'source/blender/windowmanager/intern/wm_keymap.c')
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index f7bc138f163..ffac585cde7 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -169,6 +169,7 @@ static bool wm_keymap_item_equals(wmKeyMapItem *a, wmKeyMapItem *b)
return (wm_keymap_item_equals_result(a, b) && a->type == b->type && a->val == b->val &&
a->shift == b->shift && a->ctrl == b->ctrl && a->alt == b->alt && a->oskey == b->oskey &&
a->keymodifier == b->keymodifier && a->maptype == b->maptype &&
+ ((a->val != KM_CLICK_DRAG) || (a->direction == b->direction)) &&
((ISKEYBOARD(a->type) == 0) ||
(a->flag & KMI_REPEAT_IGNORE) == (b->flag & KMI_REPEAT_IGNORE)));
}
@@ -195,9 +196,6 @@ int WM_keymap_item_map_type_get(const wmKeyMapItem *kmi)
if (ISKEYBOARD(kmi->type)) {
return KMI_TYPE_KEYBOARD;
}
- if (ISTWEAK(kmi->type)) {
- return KMI_TYPE_TWEAK;
- }
if (ISMOUSE(kmi->type)) {
return KMI_TYPE_MOUSE;
}
@@ -459,11 +457,12 @@ bool WM_keymap_poll(bContext *C, wmKeyMap *keymap)
}
static void keymap_event_set(
- wmKeyMapItem *kmi, short type, short val, int modifier, short keymodifier)
+ wmKeyMapItem *kmi, short type, short val, int modifier, short keymodifier, int direction)
{
kmi->type = type;
kmi->val = val;
kmi->keymodifier = keymodifier;
+ kmi->direction = direction;
if (modifier == KM_ANY) {
kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = KM_ANY;
@@ -497,15 +496,20 @@ static void keymap_item_set_id(wmKeyMap *keymap, wmKeyMapItem *kmi)
}
}
-wmKeyMapItem *WM_keymap_add_item(
- wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
+wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap,
+ const char *idname,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction)
{
wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
BLI_addtail(&keymap->items, kmi);
BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME);
- keymap_event_set(kmi, type, val, modifier, keymodifier);
+ keymap_event_set(kmi, type, val, modifier, keymodifier, direction);
wm_keymap_item_properties_set(kmi);
keymap_item_set_id(keymap, kmi);
@@ -919,14 +923,14 @@ wmKeyMap *WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
}
wmKeyMapItem *WM_modalkeymap_add_item(
- wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value)
+ wmKeyMap *km, int type, int val, int modifier, int keymodifier, int direction, int value)
{
wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
BLI_addtail(&km->items, kmi);
kmi->propvalue = value;
- keymap_event_set(kmi, type, val, modifier, keymodifier);
+ keymap_event_set(kmi, type, val, modifier, keymodifier, direction);
keymap_item_set_id(km, kmi);
@@ -935,15 +939,20 @@ wmKeyMapItem *WM_modalkeymap_add_item(
return kmi;
}
-wmKeyMapItem *WM_modalkeymap_add_item_str(
- wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value)
+wmKeyMapItem *WM_modalkeymap_add_item_str(wmKeyMap *km,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction,
+ const char *value)
{
wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
BLI_addtail(&km->items, kmi);
BLI_strncpy(kmi->propvalue_str, value, sizeof(kmi->propvalue_str));
- keymap_event_set(kmi, type, val, modifier, keymodifier);
+ keymap_event_set(kmi, type, val, modifier, keymodifier, direction);
keymap_item_set_id(km, kmi);
@@ -1730,6 +1739,9 @@ bool WM_keymap_item_compare(const wmKeyMapItem *k1, const wmKeyMapItem *k2)
if (k1->val != k2->val) {
return 0;
}
+ if (k1->val == KM_CLICK_DRAG && (k1->direction != k2->direction)) {
+ return 0;
+ }
}
if (k1->shift != KM_ANY && k2->shift != KM_ANY && k1->shift != k2->shift) {