| OLD | NEW |
| 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 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #import "base/mac/foundation_util.h" | 12 #import "base/mac/foundation_util.h" |
| 13 #include "base/mac/mac_util.h" | 13 #include "base/mac/mac_util.h" |
| 14 #import "base/mac/sdk_forward_declarations.h" | 14 #import "base/mac/sdk_forward_declarations.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" | 17 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" |
| 18 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" | 18 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" |
| 19 #include "ui/base/hit_test.h" | 19 #include "ui/base/hit_test.h" |
| 20 #include "ui/base/ime/input_method.h" | 20 #include "ui/base/ime/input_method.h" |
| 21 #include "ui/base/ime/input_method_factory.h" | 21 #include "ui/base/ime/input_method_factory.h" |
| 22 #include "ui/display/display.h" | 22 #include "ui/base/layout.h" |
| 23 #include "ui/display/screen.h" | |
| 24 #include "ui/gfx/geometry/dip_util.h" | 23 #include "ui/gfx/geometry/dip_util.h" |
| 25 #import "ui/gfx/mac/coordinate_conversion.h" | 24 #import "ui/gfx/mac/coordinate_conversion.h" |
| 26 #import "ui/gfx/mac/nswindow_frame_controls.h" | 25 #import "ui/gfx/mac/nswindow_frame_controls.h" |
| 27 #import "ui/native_theme/native_theme_mac.h" | 26 #import "ui/native_theme/native_theme_mac.h" |
| 28 #import "ui/views/cocoa/bridged_content_view.h" | 27 #import "ui/views/cocoa/bridged_content_view.h" |
| 29 #import "ui/views/cocoa/drag_drop_client_mac.h" | |
| 30 #import "ui/views/cocoa/cocoa_mouse_capture.h" | 28 #import "ui/views/cocoa/cocoa_mouse_capture.h" |
| 31 #import "ui/views/cocoa/cocoa_window_move_loop.h" | 29 #import "ui/views/cocoa/cocoa_window_move_loop.h" |
| 30 #import "ui/views/cocoa/drag_drop_client_mac.h" |
| 32 #include "ui/views/cocoa/tooltip_manager_mac.h" | 31 #include "ui/views/cocoa/tooltip_manager_mac.h" |
| 33 #import "ui/views/cocoa/views_nswindow_delegate.h" | 32 #import "ui/views/cocoa/views_nswindow_delegate.h" |
| 34 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h" | 33 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h" |
| 35 #include "ui/views/view.h" | 34 #include "ui/views/view.h" |
| 36 #include "ui/views/views_delegate.h" | 35 #include "ui/views/views_delegate.h" |
| 37 #include "ui/views/widget/native_widget_mac.h" | 36 #include "ui/views/widget/native_widget_mac.h" |
| 38 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
| 39 #include "ui/views/widget/widget_aura_utils.h" | 38 #include "ui/views/widget/widget_aura_utils.h" |
| 40 #include "ui/views/widget/widget_delegate.h" | 39 #include "ui/views/widget/widget_delegate.h" |
| 41 | 40 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 const int kYosemiteMenuBlur = 80; | 103 const int kYosemiteMenuBlur = 80; |
| 105 | 104 |
| 106 // Margin at edge and corners of the window that trigger resizing. These match | 105 // Margin at edge and corners of the window that trigger resizing. These match |
| 107 // actual Cocoa resize margins. | 106 // actual Cocoa resize margins. |
| 108 const int kResizeAreaEdgeSize = 3; | 107 const int kResizeAreaEdgeSize = 3; |
| 109 const int kResizeAreaCornerSize = 12; | 108 const int kResizeAreaCornerSize = 12; |
| 110 | 109 |
| 111 int kWindowPropertiesKey; | 110 int kWindowPropertiesKey; |
| 112 | 111 |
| 113 float GetDeviceScaleFactorFromView(NSView* view) { | 112 float GetDeviceScaleFactorFromView(NSView* view) { |
| 114 display::Display display = | 113 return ui::GetScaleFactorForNativeView(view); |
| 115 display::Screen::GetScreen()->GetDisplayNearestWindow(view); | |
| 116 DCHECK(display.is_valid()); | |
| 117 return display.device_scale_factor(); | |
| 118 } | 114 } |
| 119 | 115 |
| 120 // Returns true if bounds passed to window in SetBounds should be treated as | 116 // Returns true if bounds passed to window in SetBounds should be treated as |
| 121 // though they are in screen coordinates. | 117 // though they are in screen coordinates. |
| 122 bool PositionWindowInScreenCoordinates(views::Widget* widget, | 118 bool PositionWindowInScreenCoordinates(views::Widget* widget, |
| 123 views::Widget::InitParams::Type type) { | 119 views::Widget::InitParams::Type type) { |
| 124 // Replicate the logic in desktop_aura/desktop_screen_position_client.cc. | 120 // Replicate the logic in desktop_aura/desktop_screen_position_client.cc. |
| 125 if (views::GetAuraWindowTypeForWidgetType(type) == ui::wm::WINDOW_TYPE_POPUP) | 121 if (views::GetAuraWindowTypeForWidgetType(type) == ui::wm::WINDOW_TYPE_POPUP) |
| 126 return true; | 122 return true; |
| 127 | 123 |
| (...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 [bridged_view_ setMouseDownCanMoveWindow:draggable]; | 1427 [bridged_view_ setMouseDownCanMoveWindow:draggable]; |
| 1432 // AppKit will not update its cache of mouseDownCanMoveWindow unless something | 1428 // AppKit will not update its cache of mouseDownCanMoveWindow unless something |
| 1433 // changes. Previously we tried adding an NSView and removing it, but for some | 1429 // changes. Previously we tried adding an NSView and removing it, but for some |
| 1434 // reason it required reposting the mouse-down event, and didn't always work. | 1430 // reason it required reposting the mouse-down event, and didn't always work. |
| 1435 // Calling the below seems to be an effective solution. | 1431 // Calling the below seems to be an effective solution. |
| 1436 [window_ setMovableByWindowBackground:NO]; | 1432 [window_ setMovableByWindowBackground:NO]; |
| 1437 [window_ setMovableByWindowBackground:YES]; | 1433 [window_ setMovableByWindowBackground:YES]; |
| 1438 } | 1434 } |
| 1439 | 1435 |
| 1440 } // namespace views | 1436 } // namespace views |
| OLD | NEW |