Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Unified Diff: ui/base/cocoa/cocoa_event_utils.mm

Issue 160083003: Split cocoa_event_utils in two parts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: still works? Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/cocoa/cocoa_event_utils.h ('k') | ui/base/cocoa/cocoa_event_utils_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/cocoa/cocoa_event_utils.mm
diff --git a/ui/base/cocoa/cocoa_event_utils.mm b/ui/base/cocoa/cocoa_event_utils.mm
deleted file mode 100644
index 87165f4370c2aa47ca8e497d20ecef64e27f84a0..0000000000000000000000000000000000000000
--- a/ui/base/cocoa/cocoa_event_utils.mm
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "ui/base/cocoa/cocoa_event_utils.h"
-
-#include "ui/base/window_open_disposition.h"
-#include "ui/events/event_constants.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
-
-namespace ui {
-
-// Retrieves a bitsum of ui::EventFlags from NSEvent.
-int EventFlagsFromNSEvent(NSEvent* event) {
- NSUInteger modifiers = [event modifierFlags];
- return EventFlagsFromNSEventWithModifiers(event, modifiers);
-}
-
-int EventFlagsFromModifiers(NSUInteger modifiers) {
- 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;
- return flags;
-}
-
-int EventFlagsFromNSEventWithModifiers(NSEvent* event, NSUInteger modifiers) {
- int flags = EventFlagsFromModifiers(modifiers);
- flags |= isLeftButtonEvent(event) ? ui::EF_LEFT_MOUSE_BUTTON : 0;
- flags |= isRightButtonEvent(event) ? ui::EF_RIGHT_MOUSE_BUTTON : 0;
- flags |= isMiddleButtonEvent(event) ? ui::EF_MIDDLE_MOUSE_BUTTON : 0;
- return flags;
-}
-
-WindowOpenDisposition WindowOpenDispositionFromNSEvent(NSEvent* event) {
- NSUInteger modifiers = [event modifierFlags];
- return WindowOpenDispositionFromNSEventWithFlags(event, modifiers);
-}
-
-WindowOpenDisposition WindowOpenDispositionFromNSEventWithFlags(
- NSEvent* event, NSUInteger modifiers) {
- int event_flags = EventFlagsFromNSEventWithModifiers(event, modifiers);
- return ui::DispositionFromEventFlags(event_flags);
-}
-
-} // namespace ui
« no previous file with comments | « ui/base/cocoa/cocoa_event_utils.h ('k') | ui/base/cocoa/cocoa_event_utils_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698