| Index: ui/views/widget/native_widget_mac.mm
|
| diff --git a/ui/views/widget/native_widget_mac.mm b/ui/views/widget/native_widget_mac.mm
|
| index 8dc3c40dc1144a08e4f53d4a102cf289137f443f..77d84c95d4c432272adf485025c39a2e6d4d8815 100644
|
| --- a/ui/views/widget/native_widget_mac.mm
|
| +++ b/ui/views/widget/native_widget_mac.mm
|
| @@ -4,17 +4,51 @@
|
|
|
| #include "ui/views/widget/native_widget_mac.h"
|
|
|
| -#include <Cocoa/Cocoa.h>
|
| +#import <Cocoa/Cocoa.h>
|
|
|
| +#include "base/mac/scoped_nsobject.h"
|
| #include "ui/gfx/font_list.h"
|
| +#include "ui/gfx/canvas_paint_mac.h"
|
| +#include "ui/gfx/mac/point_utils.h"
|
| +#include "ui/native_theme/native_theme.h"
|
| +#import "ui/views/cocoa/bridged_content_view.h"
|
| +#import "ui/views/cocoa/bridged_native_widget.h"
|
| +
|
| +#include "ui/views/ime/input_method_base.h"
|
| +#include "ui/base/ime/text_input_mode.h"
|
|
|
| namespace views {
|
|
|
| +namespace {
|
| +
|
| +class StubInputMethod : public views::InputMethodBase {
|
| + virtual void OnFocus() OVERRIDE {}
|
| + virtual void OnBlur() OVERRIDE {}
|
| +
|
| + virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event,
|
| + NativeEventResult* result) OVERRIDE {
|
| + return false;
|
| + }
|
| + virtual void DispatchKeyEvent(const ui::KeyEvent& event) OVERRIDE {}
|
| + virtual void OnCaretBoundsChanged(views::View* view) OVERRIDE {}
|
| + virtual void CancelComposition(views::View* view) OVERRIDE {}
|
| + virtual void OnInputLocaleChanged() OVERRIDE {}
|
| + virtual std::string GetInputLocale() OVERRIDE { return ""; }
|
| + virtual bool IsActive() OVERRIDE { return false; }
|
| + virtual bool IsCandidatePopupOpen() const OVERRIDE { return false; }
|
| + virtual void ShowImeIfNeeded() OVERRIDE {}
|
| +};
|
| +
|
| +}
|
| +
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // NativeWidgetMac, public:
|
|
|
| NativeWidgetMac::NativeWidgetMac(internal::NativeWidgetDelegate* delegate)
|
| - : delegate_(delegate), window_(nil) {
|
| + : delegate_(delegate),
|
| + bridge_(new BridgedNativeWidget),
|
| + ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) {
|
| }
|
|
|
| NativeWidgetMac::~NativeWidgetMac() {
|
| @@ -24,16 +58,21 @@ NativeWidgetMac::~NativeWidgetMac() {
|
| // NativeWidgetMac, internal::NativeWidgetPrivate implementation:
|
|
|
| void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) {
|
| + ownership_ = params.ownership;
|
| +
|
| // TODO(tapted): Convert position into Cocoa's flipped coordinate space.
|
| NSRect content_rect =
|
| NSMakeRect(0, 0, params.bounds.width(), params.bounds.height());
|
| // TODO(tapted): Determine a good initial style mask from |params|.
|
| NSInteger style_mask = NSTitledWindowMask | NSClosableWindowMask |
|
| NSMiniaturizableWindowMask | NSResizableWindowMask;
|
| - window_.reset([[NSWindow alloc] initWithContentRect:content_rect
|
| - styleMask:style_mask
|
| - backing:NSBackingStoreBuffered
|
| - defer:NO]);
|
| + base::scoped_nsobject<NSWindow> window(
|
| + [[NSWindow alloc] initWithContentRect:content_rect
|
| + styleMask:style_mask
|
| + backing:NSBackingStoreBuffered
|
| + defer:NO]);
|
| + bridge_->Init(window);
|
| + delegate_->OnNativeWidgetCreated(true);
|
| }
|
|
|
| NonClientFrameView* NativeWidgetMac::CreateNonClientFrameView() {
|
| @@ -62,11 +101,11 @@ const Widget* NativeWidgetMac::GetWidget() const {
|
| }
|
|
|
| gfx::NativeView NativeWidgetMac::GetNativeView() const {
|
| - return [window_ contentView];
|
| + return bridge_->ns_view();
|
| }
|
|
|
| gfx::NativeWindow NativeWidgetMac::GetNativeWindow() const {
|
| - return window_;
|
| + return bridge_->ns_window();
|
| }
|
|
|
| Widget* NativeWidgetMac::GetTopLevelWidget() {
|
| @@ -90,7 +129,7 @@ ui::Layer* NativeWidgetMac::GetLayer() {
|
| }
|
|
|
| void NativeWidgetMac::ReorderNativeViews() {
|
| - NOTIMPLEMENTED();
|
| + bridge_->SetRootView(GetWidget()->GetRootView());
|
| }
|
|
|
| void NativeWidgetMac::ViewRemoved(View* view) {
|
| @@ -121,10 +160,11 @@ void NativeWidgetMac::ReleaseCapture() {
|
|
|
| bool NativeWidgetMac::HasCapture() const {
|
| NOTIMPLEMENTED();
|
| - return false;
|
| + return true;
|
| }
|
|
|
| InputMethod* NativeWidgetMac::CreateInputMethod() {
|
| + return new StubInputMethod(); // FIXME
|
| NOTIMPLEMENTED();
|
| return NULL;
|
| }
|
| @@ -178,11 +218,13 @@ gfx::Rect NativeWidgetMac::GetRestoredBounds() const {
|
| }
|
|
|
| void NativeWidgetMac::SetBounds(const gfx::Rect& bounds) {
|
| - NOTIMPLEMENTED();
|
| + NSRect frame_rect = [bridge_->ns_window()
|
| + frameRectForContentRect:gfx::ScreenRectToNSRect(bounds)];
|
| + [bridge_->ns_window() setFrame:frame_rect display:YES animate:NO];
|
| }
|
|
|
| void NativeWidgetMac::SetSize(const gfx::Size& size) {
|
| - [window_ setContentSize:NSMakeSize(size.width(), size.height())];
|
| + [bridge_->ns_window() setContentSize:NSMakeSize(size.width(), size.height())];
|
| }
|
|
|
| void NativeWidgetMac::StackAbove(gfx::NativeView native_view) {
|
| @@ -224,6 +266,7 @@ void NativeWidgetMac::ShowMaximizedWithBounds(
|
|
|
| void NativeWidgetMac::ShowWithWindowState(ui::WindowShowState state) {
|
| NOTIMPLEMENTED();
|
| + Activate();
|
| }
|
|
|
| bool NativeWidgetMac::IsVisible() const {
|
| @@ -232,7 +275,8 @@ bool NativeWidgetMac::IsVisible() const {
|
| }
|
|
|
| void NativeWidgetMac::Activate() {
|
| - NOTIMPLEMENTED();
|
| + [bridge_->ns_window() makeKeyAndOrderFront:nil];
|
| + [NSApp activateIgnoringOtherApps:YES];
|
| }
|
|
|
| void NativeWidgetMac::Deactivate() {
|
| @@ -309,7 +353,7 @@ void NativeWidgetMac::RunShellDrag(View* view,
|
| }
|
|
|
| void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) {
|
| - NOTIMPLEMENTED();
|
| + [bridge_->ns_view() setNeedsDisplay:YES];
|
| }
|
|
|
| void NativeWidgetMac::SetCursor(gfx::NativeCursor cursor) {
|
| @@ -347,8 +391,7 @@ void NativeWidgetMac::SetVisibilityChangedAnimationsEnabled(bool value) {
|
| }
|
|
|
| ui::NativeTheme* NativeWidgetMac::GetNativeTheme() const {
|
| - NOTIMPLEMENTED();
|
| - return NULL;
|
| + return ui::NativeTheme::instance();
|
| }
|
|
|
| void NativeWidgetMac::OnRootViewLayout() const {
|
| @@ -376,8 +419,8 @@ namespace internal {
|
| // static
|
| NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
|
| internal::NativeWidgetDelegate* delegate) {
|
| - NOTIMPLEMENTED();
|
| - return NULL;
|
| + // Called e.g. via CreateBubbleWidget().
|
| + return new NativeWidgetMac(delegate);
|
| }
|
|
|
| // static
|
|
|