OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/widget/widget_impl.h" | 5 #include "views/widget/widget_impl.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "views/focus/focus_manager.h" | 9 #include "views/focus/focus_manager.h" |
| 10 #include "views/focus/view_storage.h" |
10 #include "views/view.h" | 11 #include "views/view.h" |
11 #include "views/widget/native_widget.h" | 12 #include "views/widget/native_widget.h" |
12 #include "views/widget/root_view.h" | 13 #include "views/widget/root_view.h" |
13 | 14 |
14 namespace views { | 15 namespace views { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 // TODO(beng): move to platform file | 19 // TODO(beng): move to platform file |
19 int GetHorizontalDragThreshold() { | 20 int GetHorizontalDragThreshold() { |
(...skipping 26 matching lines...) Expand all Loading... |
46 // WidgetImpl, public: | 47 // WidgetImpl, public: |
47 | 48 |
48 WidgetImpl::WidgetImpl(View* contents_view) | 49 WidgetImpl::WidgetImpl(View* contents_view) |
49 : ALLOW_THIS_IN_INITIALIZER_LIST( | 50 : ALLOW_THIS_IN_INITIALIZER_LIST( |
50 native_widget_(NativeWidget::CreateNativeWidget(this))), | 51 native_widget_(NativeWidget::CreateNativeWidget(this))), |
51 ALLOW_THIS_IN_INITIALIZER_LIST(root_view_(new RootView(this))), | 52 ALLOW_THIS_IN_INITIALIZER_LIST(root_view_(new RootView(this))), |
52 contents_view_(contents_view), | 53 contents_view_(contents_view), |
53 is_mouse_button_pressed_(false), | 54 is_mouse_button_pressed_(false), |
54 last_mouse_event_was_move_(false), | 55 last_mouse_event_was_move_(false), |
55 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), | 56 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), |
56 delete_on_destroy_(true) { | 57 delete_on_destroy_(true), |
| 58 dragged_view_(NULL) { |
57 } | 59 } |
58 | 60 |
59 WidgetImpl::~WidgetImpl() { | 61 WidgetImpl::~WidgetImpl() { |
60 } | 62 } |
61 | 63 |
62 void WidgetImpl::InitWithNativeViewParent(gfx::NativeView parent, | 64 void WidgetImpl::InitWithNativeViewParent(gfx::NativeView parent, |
63 const gfx::Rect& bounds) { | 65 const gfx::Rect& bounds) { |
64 native_widget_->InitWithNativeViewParent(parent, bounds); | 66 native_widget_->InitWithNativeViewParent(parent, bounds); |
65 } | 67 } |
66 | 68 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 void* WidgetImpl::GetNativeWindowProperty(const char* name) { | 360 void* WidgetImpl::GetNativeWindowProperty(const char* name) { |
359 return native_widget_->GetNativeWindowProperty(name); | 361 return native_widget_->GetNativeWindowProperty(name); |
360 } | 362 } |
361 | 363 |
362 ThemeProvider* WidgetImpl::GetDefaultThemeProvider() const { | 364 ThemeProvider* WidgetImpl::GetDefaultThemeProvider() const { |
363 NOTIMPLEMENTED(); | 365 NOTIMPLEMENTED(); |
364 return NULL; | 366 return NULL; |
365 } | 367 } |
366 | 368 |
367 void WidgetImpl::ViewHierarchyChanged(bool is_add, View* parent, View* child) { | 369 void WidgetImpl::ViewHierarchyChanged(bool is_add, View* parent, View* child) { |
368 NOTIMPLEMENTED(); | 370 if (!is_add) { |
| 371 if (child == dragged_view_) |
| 372 dragged_view_ = NULL; |
| 373 FocusManager* focus_manager = GetFocusManager(); |
| 374 if (focus_manager) |
| 375 focus_manager->ViewRemoved(parent, child); |
| 376 ViewStorage::GetInstance()->ViewRemoved(parent, child); |
| 377 } |
369 } | 378 } |
370 | 379 |
371 bool WidgetImpl::ContainsNativeView(gfx::NativeView native_view) { | 380 bool WidgetImpl::ContainsNativeView(gfx::NativeView native_view) { |
372 NOTIMPLEMENTED(); | 381 NOTIMPLEMENTED(); |
373 return false; | 382 return false; |
374 } | 383 } |
375 | 384 |
| 385 void WidgetImpl::StartDragForViewFromMouseEvent( |
| 386 View* view, |
| 387 const OSExchangeData& data, |
| 388 int operation) { |
| 389 // NOTE: view may be NULL. |
| 390 dragged_view_ = view; |
| 391 native_widget_->RunShellDrag(data, operation); |
| 392 |
| 393 // If the view is removed during the drag operation, dragged_view_ is set to |
| 394 // NULL. |
| 395 if (view && dragged_view_ == view) { |
| 396 dragged_view_ = NULL; |
| 397 view->OnDragDone(); |
| 398 } |
| 399 } |
| 400 |
| 401 View* WidgetImpl::GetDraggedView() { |
| 402 return dragged_view_; |
| 403 } |
| 404 |
376 //////////////////////////////////////////////////////////////////////////////// | 405 //////////////////////////////////////////////////////////////////////////////// |
377 // WidgetImpl, private: | 406 // WidgetImpl, private: |
378 | 407 |
379 void WidgetImpl::CloseNow() { | 408 void WidgetImpl::CloseNow() { |
380 native_widget_->Close(); | 409 native_widget_->Close(); |
381 } | 410 } |
382 | 411 |
383 #if !defined(OS_WIN) | 412 #if !defined(OS_WIN) |
384 | 413 |
385 //////////////////////////////////////////////////////////////////////////////// | 414 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 20 matching lines...) Expand all Loading... |
406 // static | 435 // static |
407 NativeWidget* NativeWidget::GetTopLevelNativeWidget( | 436 NativeWidget* NativeWidget::GetTopLevelNativeWidget( |
408 gfx::NativeView native_view) { | 437 gfx::NativeView native_view) { |
409 return NULL; | 438 return NULL; |
410 } | 439 } |
411 | 440 |
412 #endif // !defined(OS_WIN) | 441 #endif // !defined(OS_WIN) |
413 | 442 |
414 } // namespace views | 443 } // namespace views |
415 | 444 |
OLD | NEW |