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

Side by Side Diff: ui/base/cocoa/appkit_utils.mm

Issue 1888343002: Mac: Honour the user preference for triggering QuickLook with Force Click (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: be explicit Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « ui/base/cocoa/appkit_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ui/base/cocoa/appkit_utils.h" 5 #import "ui/base/cocoa/appkit_utils.h"
6 6
7 #include "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "ui/base/resource/resource_bundle.h" 8 #include "ui/base/resource/resource_bundle.h"
9 9
10 namespace { 10 namespace {
11 11
12 // Gets an NSImage given an image id.
13 NSImage* GetImage(int image_id) {
14 return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(image_id)
15 .ToNSImage();
16 }
17
18 // Double-click in window title bar actions. 12 // Double-click in window title bar actions.
19 enum class DoubleClickAction { 13 enum class DoubleClickAction {
20 NONE, 14 NONE,
21 MINIMIZE, 15 MINIMIZE,
22 MAXIMIZE, 16 MAXIMIZE,
23 }; 17 };
24 18
19 // Values of com.apple.trackpad.forceClick corresponding to "Look up & data
20 // detectors" in System Preferences -> Trackpad -> Point & Click.
21 enum class ForceTouchAction {
22 NONE = 0, // Unchecked or set to "Tap with three fingers".
23 QUICK_LOOK = 1, // Set to "Force Click with one finger".
24 };
25
26 // Gets an NSImage given an image id.
27 NSImage* GetImage(int image_id) {
28 return ui::ResourceBundle::GetSharedInstance()
29 .GetNativeImageNamed(image_id)
30 .ToNSImage();
31 }
32
25 // The action to take when the user double-clicks in the window title bar. 33 // The action to take when the user double-clicks in the window title bar.
26 DoubleClickAction WindowTitleBarDoubleClickAction() { 34 DoubleClickAction WindowTitleBarDoubleClickAction() {
27 // El Capitan introduced a Dock preference to configure the window title bar 35 // El Capitan introduced a Dock preference to configure the window title bar
28 // double-click action (Minimize, Maximize, or nothing). 36 // double-click action (Minimize, Maximize, or nothing).
29 if (base::mac::IsOSElCapitanOrLater()) { 37 if (base::mac::IsOSElCapitanOrLater()) {
30 NSString* doubleClickAction = [[NSUserDefaults standardUserDefaults] 38 NSString* doubleClickAction = [[NSUserDefaults standardUserDefaults]
31 objectForKey:@"AppleActionOnDoubleClick"]; 39 objectForKey:@"AppleActionOnDoubleClick"];
32 40
33 if ([doubleClickAction isEqualToString:@"Minimize"]) { 41 if ([doubleClickAction isEqualToString:@"Minimize"]) {
34 return DoubleClickAction::MINIMIZE; 42 return DoubleClickAction::MINIMIZE;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 96
89 case DoubleClickAction::MAXIMIZE: 97 case DoubleClickAction::MAXIMIZE:
90 [window performZoom:sender]; 98 [window performZoom:sender];
91 break; 99 break;
92 100
93 case DoubleClickAction::NONE: 101 case DoubleClickAction::NONE:
94 break; 102 break;
95 } 103 }
96 } 104 }
97 105
106 bool ForceClickInvokesQuickLook() {
107 return [[NSUserDefaults standardUserDefaults]
108 integerForKey:@"com.apple.trackpad.forceClick"] ==
109 static_cast<NSInteger>(ForceTouchAction::QUICK_LOOK);
110 }
111
98 } // namespace ui 112 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/cocoa/appkit_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698