| 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/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 16 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" | 16 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" |
| 17 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" | 17 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" |
| 18 #include "ui/base/hit_test.h" | 18 #include "ui/base/hit_test.h" |
| 19 #include "ui/base/ime/input_method.h" | 19 #include "ui/base/ime/input_method.h" |
| 20 #include "ui/base/ime/input_method_factory.h" | 20 #include "ui/base/ime/input_method_factory.h" |
| 21 #include "ui/gfx/display.h" | 21 #include "ui/display/display.h" |
| 22 #include "ui/display/screen.h" |
| 22 #include "ui/gfx/geometry/dip_util.h" | 23 #include "ui/gfx/geometry/dip_util.h" |
| 23 #import "ui/gfx/mac/coordinate_conversion.h" | 24 #import "ui/gfx/mac/coordinate_conversion.h" |
| 24 #import "ui/gfx/mac/nswindow_frame_controls.h" | 25 #import "ui/gfx/mac/nswindow_frame_controls.h" |
| 25 #include "ui/gfx/screen.h" | |
| 26 #import "ui/views/cocoa/bridged_content_view.h" | 26 #import "ui/views/cocoa/bridged_content_view.h" |
| 27 #import "ui/views/cocoa/cocoa_mouse_capture.h" | 27 #import "ui/views/cocoa/cocoa_mouse_capture.h" |
| 28 #include "ui/views/cocoa/tooltip_manager_mac.h" | 28 #include "ui/views/cocoa/tooltip_manager_mac.h" |
| 29 #import "ui/views/cocoa/views_nswindow_delegate.h" | 29 #import "ui/views/cocoa/views_nswindow_delegate.h" |
| 30 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h" | 30 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h" |
| 31 #include "ui/views/view.h" | 31 #include "ui/views/view.h" |
| 32 #include "ui/views/views_delegate.h" | 32 #include "ui/views/views_delegate.h" |
| 33 #include "ui/views/widget/native_widget_mac.h" | 33 #include "ui/views/widget/native_widget_mac.h" |
| 34 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
| 35 #include "ui/views/widget/widget_aura_utils.h" | 35 #include "ui/views/widget/widget_aura_utils.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 const int kYosemiteMenuBlur = 80; | 100 const int kYosemiteMenuBlur = 80; |
| 101 | 101 |
| 102 // Margin at edge and corners of the window that trigger resizing. These match | 102 // Margin at edge and corners of the window that trigger resizing. These match |
| 103 // actual Cocoa resize margins. | 103 // actual Cocoa resize margins. |
| 104 const int kResizeAreaEdgeSize = 3; | 104 const int kResizeAreaEdgeSize = 3; |
| 105 const int kResizeAreaCornerSize = 12; | 105 const int kResizeAreaCornerSize = 12; |
| 106 | 106 |
| 107 int kWindowPropertiesKey; | 107 int kWindowPropertiesKey; |
| 108 | 108 |
| 109 float GetDeviceScaleFactorFromView(NSView* view) { | 109 float GetDeviceScaleFactorFromView(NSView* view) { |
| 110 gfx::Display display = | 110 display::Display display = |
| 111 gfx::Screen::GetScreen()->GetDisplayNearestWindow(view); | 111 display::Screen::GetScreen()->GetDisplayNearestWindow(view); |
| 112 DCHECK(display.is_valid()); | 112 DCHECK(display.is_valid()); |
| 113 return display.device_scale_factor(); | 113 return display.device_scale_factor(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 // 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 |
| 117 // though they are in screen coordinates. | 117 // though they are in screen coordinates. |
| 118 bool PositionWindowInScreenCoordinates(views::Widget* widget, | 118 bool PositionWindowInScreenCoordinates(views::Widget* widget, |
| 119 views::Widget::InitParams::Type type) { | 119 views::Widget::InitParams::Type type) { |
| 120 // Replicate the logic in desktop_aura/desktop_screen_position_client.cc. | 120 // Replicate the logic in desktop_aura/desktop_screen_position_client.cc. |
| 121 if (views::GetAuraWindowTypeForWidgetType(type) == ui::wm::WINDOW_TYPE_POPUP) | 121 if (views::GetAuraWindowTypeForWidgetType(type) == ui::wm::WINDOW_TYPE_POPUP) |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 [bridged_view_ setMouseDownCanMoveWindow:draggable]; | 1300 [bridged_view_ setMouseDownCanMoveWindow:draggable]; |
| 1301 // AppKit will not update its cache of mouseDownCanMoveWindow unless something | 1301 // AppKit will not update its cache of mouseDownCanMoveWindow unless something |
| 1302 // changes. Previously we tried adding an NSView and removing it, but for some | 1302 // changes. Previously we tried adding an NSView and removing it, but for some |
| 1303 // reason it required reposting the mouse-down event, and didn't always work. | 1303 // reason it required reposting the mouse-down event, and didn't always work. |
| 1304 // Calling the below seems to be an effective solution. | 1304 // Calling the below seems to be an effective solution. |
| 1305 [window_ setMovableByWindowBackground:NO]; | 1305 [window_ setMovableByWindowBackground:NO]; |
| 1306 [window_ setMovableByWindowBackground:YES]; | 1306 [window_ setMovableByWindowBackground:YES]; |
| 1307 } | 1307 } |
| 1308 | 1308 |
| 1309 } // namespace views | 1309 } // namespace views |
| OLD | NEW |