| 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 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| 11 #import "base/mac/sdk_forward_declarations.h" | 11 #import "base/mac/sdk_forward_declarations.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "ui/base/ime/input_method.h" | 13 #include "ui/base/ime/input_method.h" |
| 14 #include "ui/base/ime/input_method_factory.h" | 14 #include "ui/base/ime/input_method_factory.h" |
| 15 #include "ui/base/ui_base_switches_util.h" | 15 #include "ui/base/ui_base_switches_util.h" |
| 16 #include "ui/gfx/display.h" | 16 #include "ui/gfx/display.h" |
| 17 #include "ui/gfx/geometry/dip_util.h" | 17 #include "ui/gfx/geometry/dip_util.h" |
| 18 #import "ui/gfx/mac/coordinate_conversion.h" | 18 #import "ui/gfx/mac/coordinate_conversion.h" |
| 19 #import "ui/gfx/mac/nswindow_frame_controls.h" |
| 19 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 20 #import "ui/views/cocoa/cocoa_mouse_capture.h" | 21 #import "ui/views/cocoa/cocoa_mouse_capture.h" |
| 21 #import "ui/views/cocoa/bridged_content_view.h" | 22 #import "ui/views/cocoa/bridged_content_view.h" |
| 22 #import "ui/views/cocoa/views_nswindow_delegate.h" | 23 #import "ui/views/cocoa/views_nswindow_delegate.h" |
| 23 #include "ui/views/widget/native_widget_mac.h" | 24 #include "ui/views/widget/native_widget_mac.h" |
| 24 #include "ui/views/ime/input_method_bridge.h" | 25 #include "ui/views/ime/input_method_bridge.h" |
| 25 #include "ui/views/ime/null_input_method.h" | 26 #include "ui/views/ime/null_input_method.h" |
| 26 #include "ui/views/view.h" | 27 #include "ui/views/view.h" |
| 27 #include "ui/views/views_delegate.h" | 28 #include "ui/views/views_delegate.h" |
| 28 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
| 29 #include "ui/views/widget/widget_aura_utils.h" | 30 #include "ui/views/widget/widget_aura_utils.h" |
| 31 #include "ui/views/widget/widget_delegate.h" |
| 30 | 32 |
| 31 // The NSView that hosts the composited CALayer drawing the UI. It fills the | 33 // The NSView that hosts the composited CALayer drawing the UI. It fills the |
| 32 // window but is not hittable so that accessibility hit tests always go to the | 34 // window but is not hittable so that accessibility hit tests always go to the |
| 33 // BridgedContentView. | 35 // BridgedContentView. |
| 34 @interface ViewsCompositorSuperview : NSView | 36 @interface ViewsCompositorSuperview : NSView |
| 35 @end | 37 @end |
| 36 | 38 |
| 37 @implementation ViewsCompositorSuperview | 39 @implementation ViewsCompositorSuperview |
| 38 - (NSView*)hitTest:(NSPoint)aPoint { | 40 - (NSView*)hitTest:(NSPoint)aPoint { |
| 39 return nil; | 41 return nil; |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 if (is_key) { | 483 if (is_key) { |
| 482 widget->OnNativeFocus(); | 484 widget->OnNativeFocus(); |
| 483 widget->GetFocusManager()->RestoreFocusedView(); | 485 widget->GetFocusManager()->RestoreFocusedView(); |
| 484 } else { | 486 } else { |
| 485 widget->OnNativeBlur(); | 487 widget->OnNativeBlur(); |
| 486 widget->GetFocusManager()->StoreFocusedView(true); | 488 widget->GetFocusManager()->StoreFocusedView(true); |
| 487 } | 489 } |
| 488 } | 490 } |
| 489 } | 491 } |
| 490 | 492 |
| 493 void BridgedNativeWidget::OnSizeConstraintsChanged() { |
| 494 NSWindow* window = ns_window(); |
| 495 Widget* widget = native_widget_mac()->GetWidget(); |
| 496 gfx::Size min_size = widget->GetMinimumSize(); |
| 497 gfx::Size max_size = widget->GetMaximumSize(); |
| 498 bool is_resizable = widget->widget_delegate()->CanResize(); |
| 499 bool shows_resize_controls = |
| 500 is_resizable && (min_size.IsEmpty() || min_size != max_size); |
| 501 bool shows_fullscreen_controls = |
| 502 is_resizable && widget->widget_delegate()->CanMaximize(); |
| 503 |
| 504 gfx::ApplyNSWindowSizeConstraints(window, min_size, max_size, |
| 505 shows_resize_controls, |
| 506 shows_fullscreen_controls); |
| 507 } |
| 508 |
| 491 InputMethod* BridgedNativeWidget::CreateInputMethod() { | 509 InputMethod* BridgedNativeWidget::CreateInputMethod() { |
| 492 if (switches::IsTextInputFocusManagerEnabled()) | 510 if (switches::IsTextInputFocusManagerEnabled()) |
| 493 return new NullInputMethod(); | 511 return new NullInputMethod(); |
| 494 | 512 |
| 495 return new InputMethodBridge(this, GetHostInputMethod(), true); | 513 return new InputMethodBridge(this, GetHostInputMethod(), true); |
| 496 } | 514 } |
| 497 | 515 |
| 498 ui::InputMethod* BridgedNativeWidget::GetHostInputMethod() { | 516 ui::InputMethod* BridgedNativeWidget::GetHostInputMethod() { |
| 499 if (!input_method_) { | 517 if (!input_method_) { |
| 500 // Delegate is NULL because Mac IME does not need DispatchKeyEventPostIME | 518 // Delegate is NULL because Mac IME does not need DispatchKeyEventPostIME |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 window_, &kWindowPropertiesKey); | 802 window_, &kWindowPropertiesKey); |
| 785 if (!properties) { | 803 if (!properties) { |
| 786 properties = [NSMutableDictionary dictionary]; | 804 properties = [NSMutableDictionary dictionary]; |
| 787 objc_setAssociatedObject(window_, &kWindowPropertiesKey, | 805 objc_setAssociatedObject(window_, &kWindowPropertiesKey, |
| 788 properties, OBJC_ASSOCIATION_RETAIN); | 806 properties, OBJC_ASSOCIATION_RETAIN); |
| 789 } | 807 } |
| 790 return properties; | 808 return properties; |
| 791 } | 809 } |
| 792 | 810 |
| 793 } // namespace views | 811 } // namespace views |
| OLD | NEW |