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 #include "ui/views/widget/native_widget_mac.h" | 5 #include "ui/views/widget/native_widget_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 NonClientFrameView* NativeWidgetMac::CreateNonClientFrameView() { | 123 NonClientFrameView* NativeWidgetMac::CreateNonClientFrameView() { |
124 return new NativeFrameView(GetWidget()); | 124 return new NativeFrameView(GetWidget()); |
125 } | 125 } |
126 | 126 |
127 bool NativeWidgetMac::ShouldUseNativeFrame() const { | 127 bool NativeWidgetMac::ShouldUseNativeFrame() const { |
128 return true; | 128 return true; |
129 } | 129 } |
130 | 130 |
131 bool NativeWidgetMac::ShouldWindowContentsBeTransparent() const { | 131 bool NativeWidgetMac::ShouldWindowContentsBeTransparent() const { |
132 NOTIMPLEMENTED(); | 132 return true; |
133 return false; | |
134 } | 133 } |
135 | 134 |
136 void NativeWidgetMac::FrameTypeChanged() { | 135 void NativeWidgetMac::FrameTypeChanged() { |
137 NOTIMPLEMENTED(); | 136 NOTIMPLEMENTED(); |
138 } | 137 } |
139 | 138 |
140 Widget* NativeWidgetMac::GetWidget() { | 139 Widget* NativeWidgetMac::GetWidget() { |
141 return delegate_->AsWidget(); | 140 return delegate_->AsWidget(); |
142 } | 141 } |
143 | 142 |
144 const Widget* NativeWidgetMac::GetWidget() const { | 143 const Widget* NativeWidgetMac::GetWidget() const { |
145 return delegate_->AsWidget(); | 144 return delegate_->AsWidget(); |
146 } | 145 } |
147 | 146 |
148 gfx::NativeView NativeWidgetMac::GetNativeView() const { | 147 gfx::NativeView NativeWidgetMac::GetNativeView() const { |
149 // Returns a BridgedContentView, unless there is no views::RootView set. | 148 // Returns a BridgedContentView, unless there is no views::RootView set. |
150 return [GetNativeWindow() contentView]; | 149 return [GetNativeWindow() contentView]; |
151 } | 150 } |
152 | 151 |
153 gfx::NativeWindow NativeWidgetMac::GetNativeWindow() const { | 152 gfx::NativeWindow NativeWidgetMac::GetNativeWindow() const { |
154 return bridge_ ? bridge_->ns_window() : nil; | 153 return bridge_ ? bridge_->ns_window() : nil; |
155 } | 154 } |
156 | 155 |
157 Widget* NativeWidgetMac::GetTopLevelWidget() { | 156 Widget* NativeWidgetMac::GetTopLevelWidget() { |
158 NativeWidgetPrivate* native_widget = GetTopLevelNativeWidget(GetNativeView()); | 157 NativeWidgetPrivate* native_widget = GetTopLevelNativeWidget(GetNativeView()); |
159 return native_widget ? native_widget->GetWidget() : NULL; | 158 return native_widget ? native_widget->GetWidget() : NULL; |
160 } | 159 } |
161 | 160 |
162 const ui::Compositor* NativeWidgetMac::GetCompositor() const { | 161 const ui::Compositor* NativeWidgetMac::GetCompositor() const { |
163 NOTIMPLEMENTED(); | 162 return bridge_->layer() ? bridge_->layer()->GetCompositor() : NULL; |
164 return NULL; | |
165 } | 163 } |
166 | 164 |
167 ui::Compositor* NativeWidgetMac::GetCompositor() { | 165 ui::Compositor* NativeWidgetMac::GetCompositor() { |
168 NOTIMPLEMENTED(); | 166 return bridge_->layer() ? bridge_->layer()->GetCompositor() : NULL; |
169 return NULL; | |
170 } | 167 } |
171 | 168 |
172 ui::Layer* NativeWidgetMac::GetLayer() { | 169 ui::Layer* NativeWidgetMac::GetLayer() { |
173 NOTIMPLEMENTED(); | 170 return bridge_->GetOrCreateLayer(); |
174 return NULL; | |
175 } | 171 } |
176 | 172 |
177 void NativeWidgetMac::ReorderNativeViews() { | 173 void NativeWidgetMac::ReorderNativeViews() { |
178 if (bridge_) | 174 if (bridge_) |
179 bridge_->SetRootView(GetWidget()->GetRootView()); | 175 bridge_->SetRootView(GetWidget()->GetRootView()); |
180 } | 176 } |
181 | 177 |
182 void NativeWidgetMac::ViewRemoved(View* view) { | 178 void NativeWidgetMac::ViewRemoved(View* view) { |
183 NOTIMPLEMENTED(); | 179 NOTIMPLEMENTED(); |
184 } | 180 } |
185 | 181 |
186 void NativeWidgetMac::SetNativeWindowProperty(const char* name, void* value) { | 182 void NativeWidgetMac::SetNativeWindowProperty(const char* name, void* value) { |
187 NOTIMPLEMENTED(); | 183 NOTIMPLEMENTED(); |
188 } | 184 } |
189 | 185 |
190 void* NativeWidgetMac::GetNativeWindowProperty(const char* name) const { | 186 void* NativeWidgetMac::GetNativeWindowProperty(const char* name) const { |
191 NOTIMPLEMENTED(); | 187 NOTIMPLEMENTED(); |
192 return NULL; | 188 return NULL; |
193 } | 189 } |
194 | 190 |
195 TooltipManager* NativeWidgetMac::GetTooltipManager() const { | 191 TooltipManager* NativeWidgetMac::GetTooltipManager() const { |
196 NOTIMPLEMENTED(); | 192 NOTIMPLEMENTED(); |
197 return NULL; | 193 return NULL; |
198 } | 194 } |
199 | 195 |
200 void NativeWidgetMac::SetCapture() { | 196 void NativeWidgetMac::SetCapture() { |
201 NOTIMPLEMENTED(); | 197 // Basic mouse capture to simulate ::SetCapture() from Windows. Capture on OSX |
| 198 // is automatic for mouse drag events. This allows mouse move events to also |
| 199 // be sent to responders, but only when the mouse is over the window. To get |
| 200 // move events outside the window, Mac will need an event tap. |
| 201 [GetNativeWindow() setAcceptsMouseMovedEvents:YES]; |
202 } | 202 } |
203 | 203 |
204 void NativeWidgetMac::ReleaseCapture() { | 204 void NativeWidgetMac::ReleaseCapture() { |
205 NOTIMPLEMENTED(); | 205 [GetNativeWindow() setAcceptsMouseMovedEvents:NO]; |
206 } | 206 } |
207 | 207 |
208 bool NativeWidgetMac::HasCapture() const { | 208 bool NativeWidgetMac::HasCapture() const { |
209 NOTIMPLEMENTED(); | 209 return [GetNativeWindow() acceptsMouseMovedEvents]; |
210 return false; | |
211 } | 210 } |
212 | 211 |
213 InputMethod* NativeWidgetMac::CreateInputMethod() { | 212 InputMethod* NativeWidgetMac::CreateInputMethod() { |
214 return bridge_ ? bridge_->CreateInputMethod() : NULL; | 213 return bridge_ ? bridge_->CreateInputMethod() : NULL; |
215 } | 214 } |
216 | 215 |
217 internal::InputMethodDelegate* NativeWidgetMac::GetInputMethodDelegate() { | 216 internal::InputMethodDelegate* NativeWidgetMac::GetInputMethodDelegate() { |
218 return bridge_.get(); | 217 return bridge_.get(); |
219 } | 218 } |
220 | 219 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 return gfx::ScreenRectFromNSRect( | 263 return gfx::ScreenRectFromNSRect( |
265 [window contentRectForFrameRect:[window frame]]); | 264 [window contentRectForFrameRect:[window frame]]); |
266 } | 265 } |
267 | 266 |
268 gfx::Rect NativeWidgetMac::GetRestoredBounds() const { | 267 gfx::Rect NativeWidgetMac::GetRestoredBounds() const { |
269 NOTIMPLEMENTED(); | 268 NOTIMPLEMENTED(); |
270 return gfx::Rect(); | 269 return gfx::Rect(); |
271 } | 270 } |
272 | 271 |
273 void NativeWidgetMac::SetBounds(const gfx::Rect& bounds) { | 272 void NativeWidgetMac::SetBounds(const gfx::Rect& bounds) { |
274 [GetNativeWindow() setFrame:gfx::ScreenRectToNSRect(bounds) | 273 if (bridge_) |
275 display:YES | 274 bridge_->SetBounds(bounds); |
276 animate:NO]; | |
277 } | 275 } |
278 | 276 |
279 void NativeWidgetMac::SetSize(const gfx::Size& size) { | 277 void NativeWidgetMac::SetSize(const gfx::Size& size) { |
280 // Ensure the top-left corner stays in-place (rather than the bottom-left, | 278 // Ensure the top-left corner stays in-place (rather than the bottom-left, |
281 // which -[NSWindow setContentSize:] would do). | 279 // which -[NSWindow setContentSize:] would do). |
282 SetBounds(gfx::Rect(GetWindowBoundsInScreen().origin(), size)); | 280 SetBounds(gfx::Rect(GetWindowBoundsInScreen().origin(), size)); |
283 } | 281 } |
284 | 282 |
285 void NativeWidgetMac::StackAbove(gfx::NativeView native_view) { | 283 void NativeWidgetMac::StackAbove(gfx::NativeView native_view) { |
286 NOTIMPLEMENTED(); | 284 NOTIMPLEMENTED(); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 const gfx::Point& location, | 447 const gfx::Point& location, |
450 int operation, | 448 int operation, |
451 ui::DragDropTypes::DragEventSource source) { | 449 ui::DragDropTypes::DragEventSource source) { |
452 NOTIMPLEMENTED(); | 450 NOTIMPLEMENTED(); |
453 } | 451 } |
454 | 452 |
455 void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) { | 453 void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) { |
456 // TODO(tapted): This should use setNeedsDisplayInRect:, once the coordinate | 454 // TODO(tapted): This should use setNeedsDisplayInRect:, once the coordinate |
457 // system of |rect| has been converted. | 455 // system of |rect| has been converted. |
458 [GetNativeView() setNeedsDisplay:YES]; | 456 [GetNativeView() setNeedsDisplay:YES]; |
| 457 if (bridge_ && bridge_->layer()) { |
| 458 bridge_->layer()->SchedulePaint(rect); |
| 459 } |
459 } | 460 } |
460 | 461 |
461 void NativeWidgetMac::SetCursor(gfx::NativeCursor cursor) { | 462 void NativeWidgetMac::SetCursor(gfx::NativeCursor cursor) { |
462 NOTIMPLEMENTED(); | 463 NOTIMPLEMENTED(); |
463 } | 464 } |
464 | 465 |
465 bool NativeWidgetMac::IsMouseEventsEnabled() const { | 466 bool NativeWidgetMac::IsMouseEventsEnabled() const { |
466 NOTIMPLEMENTED(); | 467 NOTIMPLEMENTED(); |
467 return true; | 468 return true; |
468 } | 469 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 } | 597 } |
597 | 598 |
598 // static | 599 // static |
599 gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() { | 600 gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() { |
600 NOTIMPLEMENTED(); | 601 NOTIMPLEMENTED(); |
601 return gfx::FontList(); | 602 return gfx::FontList(); |
602 } | 603 } |
603 | 604 |
604 } // namespace internal | 605 } // namespace internal |
605 } // namespace views | 606 } // namespace views |
OLD | NEW |