| 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" | |
| 20 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
| 21 #import "ui/views/cocoa/cocoa_mouse_capture.h" | 20 #import "ui/views/cocoa/cocoa_mouse_capture.h" |
| 22 #import "ui/views/cocoa/bridged_content_view.h" | 21 #import "ui/views/cocoa/bridged_content_view.h" |
| 23 #import "ui/views/cocoa/views_nswindow_delegate.h" | 22 #import "ui/views/cocoa/views_nswindow_delegate.h" |
| 24 #include "ui/views/widget/native_widget_mac.h" | 23 #include "ui/views/widget/native_widget_mac.h" |
| 25 #include "ui/views/ime/input_method_bridge.h" | 24 #include "ui/views/ime/input_method_bridge.h" |
| 26 #include "ui/views/ime/null_input_method.h" | 25 #include "ui/views/ime/null_input_method.h" |
| 27 #include "ui/views/view.h" | 26 #include "ui/views/view.h" |
| 28 #include "ui/views/views_delegate.h" | 27 #include "ui/views/views_delegate.h" |
| 29 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
| 30 #include "ui/views/widget/widget_aura_utils.h" | 29 #include "ui/views/widget/widget_aura_utils.h" |
| 31 #include "ui/views/widget/widget_delegate.h" | |
| 32 | 30 |
| 33 // The NSView that hosts the composited CALayer drawing the UI. It fills the | 31 // The NSView that hosts the composited CALayer drawing the UI. It fills the |
| 34 // window but is not hittable so that accessibility hit tests always go to the | 32 // window but is not hittable so that accessibility hit tests always go to the |
| 35 // BridgedContentView. | 33 // BridgedContentView. |
| 36 @interface ViewsCompositorSuperview : NSView | 34 @interface ViewsCompositorSuperview : NSView |
| 37 @end | 35 @end |
| 38 | 36 |
| 39 @implementation ViewsCompositorSuperview | 37 @implementation ViewsCompositorSuperview |
| 40 - (NSView*)hitTest:(NSPoint)aPoint { | 38 - (NSView*)hitTest:(NSPoint)aPoint { |
| 41 return nil; | 39 return nil; |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 if (is_key) { | 481 if (is_key) { |
| 484 widget->OnNativeFocus(); | 482 widget->OnNativeFocus(); |
| 485 widget->GetFocusManager()->RestoreFocusedView(); | 483 widget->GetFocusManager()->RestoreFocusedView(); |
| 486 } else { | 484 } else { |
| 487 widget->OnNativeBlur(); | 485 widget->OnNativeBlur(); |
| 488 widget->GetFocusManager()->StoreFocusedView(true); | 486 widget->GetFocusManager()->StoreFocusedView(true); |
| 489 } | 487 } |
| 490 } | 488 } |
| 491 } | 489 } |
| 492 | 490 |
| 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 | |
| 509 InputMethod* BridgedNativeWidget::CreateInputMethod() { | 491 InputMethod* BridgedNativeWidget::CreateInputMethod() { |
| 510 if (switches::IsTextInputFocusManagerEnabled()) | 492 if (switches::IsTextInputFocusManagerEnabled()) |
| 511 return new NullInputMethod(); | 493 return new NullInputMethod(); |
| 512 | 494 |
| 513 return new InputMethodBridge(this, GetHostInputMethod(), true); | 495 return new InputMethodBridge(this, GetHostInputMethod(), true); |
| 514 } | 496 } |
| 515 | 497 |
| 516 ui::InputMethod* BridgedNativeWidget::GetHostInputMethod() { | 498 ui::InputMethod* BridgedNativeWidget::GetHostInputMethod() { |
| 517 if (!input_method_) { | 499 if (!input_method_) { |
| 518 // Delegate is NULL because Mac IME does not need DispatchKeyEventPostIME | 500 // Delegate is NULL because Mac IME does not need DispatchKeyEventPostIME |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 window_, &kWindowPropertiesKey); | 784 window_, &kWindowPropertiesKey); |
| 803 if (!properties) { | 785 if (!properties) { |
| 804 properties = [NSMutableDictionary dictionary]; | 786 properties = [NSMutableDictionary dictionary]; |
| 805 objc_setAssociatedObject(window_, &kWindowPropertiesKey, | 787 objc_setAssociatedObject(window_, &kWindowPropertiesKey, |
| 806 properties, OBJC_ASSOCIATION_RETAIN); | 788 properties, OBJC_ASSOCIATION_RETAIN); |
| 807 } | 789 } |
| 808 return properties; | 790 return properties; |
| 809 } | 791 } |
| 810 | 792 |
| 811 } // namespace views | 793 } // namespace views |
| OLD | NEW |