| Index: chrome/browser/ui/cocoa/event_utils.mm
|
| diff --git a/chrome/browser/ui/cocoa/event_utils.mm b/chrome/browser/ui/cocoa/event_utils.mm
|
| index 32ad8f80c649cc2995b0335adc66fd225b714a37..5b7723225c172e0cd850a56cb3314471c33cffc5 100644
|
| --- a/chrome/browser/ui/cocoa/event_utils.mm
|
| +++ b/chrome/browser/ui/cocoa/event_utils.mm
|
| @@ -5,9 +5,53 @@
|
| #import "chrome/browser/ui/cocoa/event_utils.h"
|
|
|
| #include "content/browser/disposition_utils.h"
|
| +#include "ui/base/events.h"
|
| +
|
| +namespace {
|
| + bool isLeftButtonEvent(NSEvent* event) {
|
| + NSEventType type = [event type];
|
| + return type == NSLeftMouseDown ||
|
| + type == NSLeftMouseDragged ||
|
| + type == NSLeftMouseUp;
|
| + }
|
| +
|
| + bool isRightButtonEvent(NSEvent* event) {
|
| + NSEventType type = [event type];
|
| + return type == NSRightMouseDown ||
|
| + type == NSRightMouseDragged ||
|
| + type == NSRightMouseUp;
|
| + }
|
| +
|
| + bool isMiddleButtonEvent(NSEvent* event) {
|
| + if ([event buttonNumber] != 2)
|
| + return false;
|
| +
|
| + NSEventType type = [event type];
|
| + return type == NSOtherMouseDown ||
|
| + type == NSOtherMouseDragged ||
|
| + type == NSOtherMouseUp;
|
| + }
|
| +}
|
|
|
| namespace event_utils {
|
|
|
| +// Retrieves a bitsum of ui::EventFlags from NSEvent.
|
| +int EventFlagsFromNSEvent(NSEvent* event) {
|
| + NSUInteger modifiers = [event modifierFlags];
|
| +
|
| + int flags = 0;
|
| + flags |= (modifiers & NSAlphaShiftKeyMask) ? ui::EF_CAPS_LOCK_DOWN : 0;
|
| + flags |= (modifiers & NSShiftKeyMask) ? ui::EF_SHIFT_DOWN : 0;
|
| + flags |= (modifiers & NSControlKeyMask) ? ui::EF_CONTROL_DOWN : 0;
|
| + flags |= (modifiers & NSAlternateKeyMask) ? ui::EF_ALT_DOWN : 0;
|
| + flags |= (modifiers & NSCommandKeyMask) ? ui::EF_COMMAND_DOWN : 0;
|
| + flags |= isLeftButtonEvent(event) ? ui::EF_LEFT_BUTTON_DOWN : 0;
|
| + flags |= isRightButtonEvent(event) ? ui::EF_RIGHT_BUTTON_DOWN : 0;
|
| + flags |= isMiddleButtonEvent(event) ? ui::EF_MIDDLE_BUTTON_DOWN : 0;
|
| + return flags;
|
| +}
|
| +
|
| +
|
| WindowOpenDisposition WindowOpenDispositionFromNSEvent(NSEvent* event) {
|
| NSUInteger modifiers = [event modifierFlags];
|
| return WindowOpenDispositionFromNSEventWithFlags(event, modifiers);
|
|
|