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

Side by Side Diff: ui/base/test/ui_controls_mac.mm

Issue 1380083005: Mac: Use [NSArray firstObject] for [NSScreen screens] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
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 #include "ui/base/test/ui_controls.h" 5 #include "ui/base/test/ui_controls.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return SendMouseMoveNotifyWhenDone(x, y, base::Closure()); 228 return SendMouseMoveNotifyWhenDone(x, y, base::Closure());
229 } 229 }
230 230
231 // Input position is in screen coordinates. However, NSMouseMoved 231 // Input position is in screen coordinates. However, NSMouseMoved
232 // events require them window-relative, so we adjust. We *DO* flip 232 // events require them window-relative, so we adjust. We *DO* flip
233 // the coordinate space, so input events can be the same for all 233 // the coordinate space, so input events can be the same for all
234 // platforms. E.g. (0,0) is upper-left. 234 // platforms. E.g. (0,0) is upper-left.
235 bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) { 235 bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) {
236 CHECK(g_ui_controls_enabled); 236 CHECK(g_ui_controls_enabled);
237 CGFloat screenHeight = 237 CGFloat screenHeight =
238 [[[NSScreen screens] objectAtIndex:0] frame].size.height; 238 [[[NSScreen screens] firstObject] frame].size.height;
239 g_mouse_location = NSMakePoint(x, screenHeight - y); // flip! 239 g_mouse_location = NSMakePoint(x, screenHeight - y); // flip!
240 240
241 NSWindow* window = WindowAtCurrentMouseLocation(); 241 NSWindow* window = WindowAtCurrentMouseLocation();
242 242
243 NSPoint pointInWindow = g_mouse_location; 243 NSPoint pointInWindow = g_mouse_location;
244 if (window) 244 if (window)
245 pointInWindow = [window convertScreenToBase:pointInWindow]; 245 pointInWindow = [window convertScreenToBase:pointInWindow];
246 NSTimeInterval timestamp = TimeIntervalSinceSystemStartup(); 246 NSTimeInterval timestamp = TimeIntervalSinceSystemStartup();
247 247
248 NSEvent* event = 248 NSEvent* event =
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) { 334 void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) {
335 base::MessageLoop::current()->PostTask( 335 base::MessageLoop::current()->PostTask(
336 FROM_HERE, base::Bind(&EventQueueWatcher, closure)); 336 FROM_HERE, base::Bind(&EventQueueWatcher, closure));
337 } 337 }
338 338
339 bool IsFullKeyboardAccessEnabled() { 339 bool IsFullKeyboardAccessEnabled() {
340 return [NSApp isFullKeyboardAccessEnabled]; 340 return [NSApp isFullKeyboardAccessEnabled];
341 } 341 }
342 342
343 } // namespace ui_controls 343 } // namespace ui_controls
OLDNEW
« no previous file with comments | « content/public/test/content_browser_test_utils_mac.mm ('k') | ui/events/cocoa/events_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698