From 43ee3f4040a41c637b6eceda4c3aa1046f8a13a5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 17 May 2015 15:43:42 +0200 Subject: Fix T44739: OS X RMB emulation giving wrong mouse button release event. --- .../blender/windowmanager/intern/wm_event_system.c | 43 ++++++++-------------- 1 file changed, 16 insertions(+), 27 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 42fc0267625..658fb317688 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2886,52 +2886,41 @@ static int convert_key(GHOST_TKey key) static void wm_eventemulation(wmEvent *event) { - /* Store last mmb event value to make emulation work when modifier keys are released first. */ - static int mmb_emulated = 0; /* this should be in a data structure somwhere */ + /* Store last mmb/rmb event value to make emulation work when modifier keys + * are released first. This really should be in a data structure somwhere. */ + static int emulating_event = EVENT_NONE; - /* middlemouse emulation */ + /* middlemouse and rightmouse emulation */ if (U.flag & USER_TWOBUTTONMOUSE) { if (event->type == LEFTMOUSE) { if (event->val == KM_PRESS && event->alt) { event->type = MIDDLEMOUSE; event->alt = 0; - mmb_emulated = 1; + emulating_event = MIDDLEMOUSE; } - else if (event->val == KM_RELEASE) { - /* only send middle-mouse release if emulated */ - if (mmb_emulated) { - event->type = MIDDLEMOUSE; - event->alt = 0; - } - mmb_emulated = 0; - } - } - - } - #ifdef __APPLE__ - - /* rightmouse emulation */ - if (U.flag & USER_TWOBUTTONMOUSE) { - if (event->type == LEFTMOUSE) { - - if (event->val == KM_PRESS && event->oskey) { + else if (event->val == KM_PRESS && event->oskey) { event->type = RIGHTMOUSE; event->oskey = 0; - mmb_emulated = 1; + emulating_event = RIGHTMOUSE; } +#endif else if (event->val == KM_RELEASE) { - if (mmb_emulated) { - event->oskey = RIGHTMOUSE; + /* only send middle-mouse release if emulated */ + if (emulating_event == MIDDLEMOUSE) { + event->type = MIDDLEMOUSE; event->alt = 0; } - mmb_emulated = 0; + else if (emulating_event == RIGHTMOUSE) { + event->type = RIGHTMOUSE; + event->oskey = 0; + } + emulating_event = EVENT_NONE; } } } -#endif /* numpad emulation */ if (U.flag & USER_NONUMPAD) { -- cgit v1.2.3