From 75504052d661c021e87c49d9b2ffc6d0f491c23f Mon Sep 17 00:00:00 2001 From: John Scipione Date: Mon, 9 Jan 2017 23:05:20 -0800 Subject: [PATCH] DefaultWindowBehavior: Emulate right click and middle click ... based on mouse type setting in Mouse Preferences. for (default) 3 button mouse, nothing changes. #important for 1 button mouse, emulate right click by ctrl+click. This replicates Tracker behavior everwhere for 2 button mouse, add todo to emulate middle click by pushing both buttons at the same time. Unfortunately I was unsucessful getting this feature to work. Change-Id: I5377ed5b4967483096f7f185f434bced3f86cdb9 Reviewed-on: https://review.haiku-os.org/c/303 Reviewed-by: Adrien Destugues --- .../app/decorator/DefaultWindowBehaviour.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/servers/app/decorator/DefaultWindowBehaviour.cpp b/src/servers/app/decorator/DefaultWindowBehaviour.cpp index 4c6d35e3f2..8027483e08 100644 --- a/src/servers/app/decorator/DefaultWindowBehaviour.cpp +++ b/src/servers/app/decorator/DefaultWindowBehaviour.cpp @@ -704,6 +704,27 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where, fLastModifiers = message->FindInt32("modifiers"); int32 buttons = message->FindInt32("buttons"); + int32 numButtons; + if (get_mouse_type(&numButtons) == B_OK) { + switch (numButtons) { + case 1: + // 1 button mouse + if ((fLastModifiers & B_CONTROL_KEY) != 0) { + // emulate right click by holding control + buttons = B_SECONDARY_MOUSE_BUTTON; + message->ReplaceInt32("buttons", buttons); + } + break; + + case 2: + // TODO: 2 button mouse, pressing both buttons simultaneously + // emulates middle click + + default: + break; + } + } + // if a state is active, let it do the job if (fState != NULL) { bool unhandled = false;