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

Side by Side Diff: ui/views/cocoa/bridged_native_widget.mm

Issue 2688413007: Add display::GetDisplayNearestView (Closed)
Patch Set: test GetDisplayNearestView Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/views/cocoa/bridged_native_widget.h" 5 #import "ui/views/cocoa/bridged_native_widget.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 // Margin at edge and corners of the window that trigger resizing. These match 106 // Margin at edge and corners of the window that trigger resizing. These match
107 // actual Cocoa resize margins. 107 // actual Cocoa resize margins.
108 const int kResizeAreaEdgeSize = 3; 108 const int kResizeAreaEdgeSize = 3;
109 const int kResizeAreaCornerSize = 12; 109 const int kResizeAreaCornerSize = 12;
110 110
111 int kWindowPropertiesKey; 111 int kWindowPropertiesKey;
112 112
113 float GetDeviceScaleFactorFromView(NSView* view) { 113 float GetDeviceScaleFactorFromView(NSView* view) {
114 display::Display display = 114 display::Display display =
115 display::Screen::GetScreen()->GetDisplayNearestWindow(view); 115 display::Screen::GetScreen()->GetDisplayNearestView(view);
116 DCHECK(display.is_valid()); 116 DCHECK(display.is_valid());
117 return display.device_scale_factor(); 117 return display.device_scale_factor();
118 } 118 }
119 119
120 // Returns true if bounds passed to window in SetBounds should be treated as 120 // Returns true if bounds passed to window in SetBounds should be treated as
121 // though they are in screen coordinates. 121 // though they are in screen coordinates.
122 bool PositionWindowInScreenCoordinates(views::Widget* widget, 122 bool PositionWindowInScreenCoordinates(views::Widget* widget,
123 views::Widget::InitParams::Type type) { 123 views::Widget::InitParams::Type type) {
124 // Replicate the logic in desktop_aura/desktop_screen_position_client.cc. 124 // Replicate the logic in desktop_aura/desktop_screen_position_client.cc.
125 if (views::GetAuraWindowTypeForWidgetType(type) == ui::wm::WINDOW_TYPE_POPUP) 125 if (views::GetAuraWindowTypeForWidgetType(type) == ui::wm::WINDOW_TYPE_POPUP)
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 [bridged_view_ setMouseDownCanMoveWindow:draggable]; 1426 [bridged_view_ setMouseDownCanMoveWindow:draggable];
1427 // AppKit will not update its cache of mouseDownCanMoveWindow unless something 1427 // AppKit will not update its cache of mouseDownCanMoveWindow unless something
1428 // changes. Previously we tried adding an NSView and removing it, but for some 1428 // changes. Previously we tried adding an NSView and removing it, but for some
1429 // reason it required reposting the mouse-down event, and didn't always work. 1429 // reason it required reposting the mouse-down event, and didn't always work.
1430 // Calling the below seems to be an effective solution. 1430 // Calling the below seems to be an effective solution.
1431 [window_ setMovableByWindowBackground:NO]; 1431 [window_ setMovableByWindowBackground:NO];
1432 [window_ setMovableByWindowBackground:YES]; 1432 [window_ setMovableByWindowBackground:YES];
1433 } 1433 }
1434 1434
1435 } // namespace views 1435 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698