| 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.h" | 5 #include "views/widget/widget.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/utf_string_conversions.h" |
| 9 #include "ui/gfx/compositor/compositor.h" | 10 #include "ui/gfx/compositor/compositor.h" |
| 10 #include "views/focus/view_storage.h" | 11 #include "views/focus/view_storage.h" |
| 11 #include "views/ime/input_method.h" | 12 #include "views/ime/input_method.h" |
| 12 #include "views/views_delegate.h" | 13 #include "views/views_delegate.h" |
| 13 #include "views/widget/default_theme_provider.h" | 14 #include "views/widget/default_theme_provider.h" |
| 14 #include "views/widget/root_view.h" | 15 #include "views/widget/root_view.h" |
| 15 #include "views/widget/native_widget.h" | 16 #include "views/widget/native_widget.h" |
| 16 #include "views/widget/widget_delegate.h" | 17 #include "views/widget/widget_delegate.h" |
| 17 #include "views/window/custom_frame_view.h" | 18 #include "views/window/custom_frame_view.h" |
| 18 | 19 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 84 |
| 84 // static | 85 // static |
| 85 Widget::InitParams Widget::WindowInitParams() { | 86 Widget::InitParams Widget::WindowInitParams() { |
| 86 return InitParams(InitParams::TYPE_WINDOW); | 87 return InitParams(InitParams::TYPE_WINDOW); |
| 87 } | 88 } |
| 88 | 89 |
| 89 Widget::Widget() | 90 Widget::Widget() |
| 90 : is_mouse_button_pressed_(false), | 91 : is_mouse_button_pressed_(false), |
| 91 last_mouse_event_was_move_(false), | 92 last_mouse_event_was_move_(false), |
| 92 native_widget_(NULL), | 93 native_widget_(NULL), |
| 93 type_(InitParams::TYPE_WINDOW), | |
| 94 widget_delegate_(NULL), | 94 widget_delegate_(NULL), |
| 95 non_client_view_(NULL), | 95 non_client_view_(NULL), |
| 96 dragged_view_(NULL), | 96 dragged_view_(NULL), |
| 97 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 97 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 98 is_secondary_widget_(true), | 98 is_secondary_widget_(true), |
| 99 frame_type_(FRAME_TYPE_DEFAULT) { | 99 frame_type_(FRAME_TYPE_DEFAULT), |
| 100 disable_inactive_rendering_(false), |
| 101 widget_closed_(false) { |
| 100 } | 102 } |
| 101 | 103 |
| 102 Widget::~Widget() { | 104 Widget::~Widget() { |
| 103 DestroyRootView(); | 105 DestroyRootView(); |
| 104 | 106 |
| 105 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) | 107 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) |
| 106 delete native_widget_; | 108 delete native_widget_; |
| 107 } | 109 } |
| 108 | 110 |
| 109 // static | 111 // static |
| 110 void Widget::SetPureViews(bool pure) { | 112 void Widget::SetPureViews(bool pure) { |
| 111 use_pure_views = pure; | 113 use_pure_views = pure; |
| 112 } | 114 } |
| 113 | 115 |
| 114 // static | 116 // static |
| 115 bool Widget::IsPureViews() { | 117 bool Widget::IsPureViews() { |
| 116 return use_pure_views; | 118 return use_pure_views; |
| 117 } | 119 } |
| 118 | 120 |
| 119 // static | 121 // static |
| 120 Widget* Widget::GetWidgetForNativeView(gfx::NativeView native_view) { | 122 Widget* Widget::GetWidgetForNativeView(gfx::NativeView native_view) { |
| 121 NativeWidget* native_widget = | 123 NativeWidget* native_widget = |
| 122 NativeWidget::GetNativeWidgetForNativeView(native_view); | 124 NativeWidget::GetNativeWidgetForNativeView(native_view); |
| 123 return native_widget ? native_widget->GetWidget() : NULL; | 125 return native_widget ? native_widget->GetWidget() : NULL; |
| 124 } | 126 } |
| 125 | 127 |
| 126 void Widget::Init(const InitParams& params) { | 128 void Widget::Init(const InitParams& params) { |
| 127 type_ = params.type; | |
| 128 widget_delegate_ = | 129 widget_delegate_ = |
| 129 params.delegate ? params.delegate : new DefaultWidgetDelegate; | 130 params.delegate ? params.delegate : new DefaultWidgetDelegate; |
| 130 ownership_ = params.ownership; | 131 ownership_ = params.ownership; |
| 131 native_widget_ = | 132 native_widget_ = |
| 132 params.native_widget ? params.native_widget | 133 params.native_widget ? params.native_widget |
| 133 : NativeWidget::CreateNativeWidget(this); | 134 : NativeWidget::CreateNativeWidget(this); |
| 134 GetRootView(); | 135 GetRootView(); |
| 135 default_theme_provider_.reset(new DefaultThemeProvider); | 136 default_theme_provider_.reset(new DefaultThemeProvider); |
| 136 if (params.type == InitParams::TYPE_MENU) | 137 if (params.type == InitParams::TYPE_MENU) |
| 137 is_mouse_button_pressed_ = native_widget_->IsMouseButtonDown(); | 138 is_mouse_button_pressed_ = native_widget_->IsMouseButtonDown(); |
| 138 native_widget_->InitNativeWidget(params); | 139 native_widget_->InitNativeWidget(params); |
| 139 if (type_ == InitParams::TYPE_WINDOW) { | 140 if (params.type == InitParams::TYPE_WINDOW) { |
| 140 non_client_view_ = new NonClientView; | 141 non_client_view_ = new NonClientView; |
| 141 non_client_view_->SetFrameView(CreateNonClientFrameView()); | 142 non_client_view_->SetFrameView(CreateNonClientFrameView()); |
| 143 // Create the ClientView, add it to the NonClientView and add the |
| 144 // NonClientView to the RootView. This will cause everything to be parented. |
| 145 non_client_view_->set_client_view(widget_delegate_->CreateClientView(this)); |
| 146 SetContentsView(non_client_view_); |
| 142 } | 147 } |
| 143 } | 148 } |
| 144 | 149 |
| 145 // Unconverted methods (see header) -------------------------------------------- | 150 // Unconverted methods (see header) -------------------------------------------- |
| 146 | 151 |
| 147 gfx::NativeView Widget::GetNativeView() const { | 152 gfx::NativeView Widget::GetNativeView() const { |
| 148 return native_widget_->GetNativeView(); | 153 return native_widget_->GetNativeView(); |
| 149 } | 154 } |
| 150 | 155 |
| 151 gfx::NativeWindow Widget::GetNativeWindow() const { | 156 gfx::NativeWindow Widget::GetNativeWindow() const { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 182 if (!attached) { | 187 if (!attached) { |
| 183 FocusManager* focus_manager = GetFocusManager(); | 188 FocusManager* focus_manager = GetFocusManager(); |
| 184 // We are being removed from a window hierarchy. Treat this as | 189 // We are being removed from a window hierarchy. Treat this as |
| 185 // the root_view_ being removed. | 190 // the root_view_ being removed. |
| 186 if (focus_manager) | 191 if (focus_manager) |
| 187 focus_manager->ViewRemoved(root_view_.get()); | 192 focus_manager->ViewRemoved(root_view_.get()); |
| 188 } | 193 } |
| 189 root_view_->NotifyNativeViewHierarchyChanged(attached, native_view); | 194 root_view_->NotifyNativeViewHierarchyChanged(attached, native_view); |
| 190 } | 195 } |
| 191 | 196 |
| 197 Window* Widget::AsWindow() { |
| 198 return NULL; |
| 199 } |
| 200 |
| 201 const Window* Widget::AsWindow() const { |
| 202 return NULL; |
| 203 } |
| 204 |
| 192 // Converted methods (see header) ---------------------------------------------- | 205 // Converted methods (see header) ---------------------------------------------- |
| 193 | 206 |
| 194 Widget* Widget::GetTopLevelWidget() { | 207 Widget* Widget::GetTopLevelWidget() { |
| 195 return const_cast<Widget*>( | 208 return const_cast<Widget*>( |
| 196 const_cast<const Widget*>(this)->GetTopLevelWidget()); | 209 const_cast<const Widget*>(this)->GetTopLevelWidget()); |
| 197 } | 210 } |
| 198 | 211 |
| 199 const Widget* Widget::GetTopLevelWidget() const { | 212 const Widget* Widget::GetTopLevelWidget() const { |
| 200 NativeWidget* native_widget = | 213 NativeWidget* native_widget = |
| 201 NativeWidget::GetTopLevelNativeWidget(GetNativeView()); | 214 NativeWidget::GetTopLevelNativeWidget(GetNativeView()); |
| 202 return native_widget ? native_widget->GetWidget() : NULL; | 215 return native_widget ? native_widget->GetWidget() : NULL; |
| 203 } | 216 } |
| 204 | 217 |
| 205 void Widget::SetContentsView(View* view) { | 218 void Widget::SetContentsView(View* view) { |
| 206 root_view_->SetContentsView(view); | 219 root_view_->SetContentsView(view); |
| 207 } | 220 } |
| 208 | 221 |
| 209 gfx::Rect Widget::GetWindowScreenBounds() const { | 222 gfx::Rect Widget::GetWindowScreenBounds() const { |
| 210 return native_widget_->GetWindowScreenBounds(); | 223 return native_widget_->GetWindowScreenBounds(); |
| 211 } | 224 } |
| 212 | 225 |
| 213 gfx::Rect Widget::GetClientAreaScreenBounds() const { | 226 gfx::Rect Widget::GetClientAreaScreenBounds() const { |
| 214 return native_widget_->GetClientAreaScreenBounds(); | 227 return native_widget_->GetClientAreaScreenBounds(); |
| 215 } | 228 } |
| 216 | 229 |
| 230 gfx::Rect Widget::GetRestoredBounds() const { |
| 231 return native_widget_->GetRestoredBounds(); |
| 232 } |
| 233 |
| 217 void Widget::SetBounds(const gfx::Rect& bounds) { | 234 void Widget::SetBounds(const gfx::Rect& bounds) { |
| 218 native_widget_->SetBounds(bounds); | 235 native_widget_->SetBounds(bounds); |
| 219 } | 236 } |
| 220 | 237 |
| 221 void Widget::SetSize(const gfx::Size& size) { | 238 void Widget::SetSize(const gfx::Size& size) { |
| 222 native_widget_->SetSize(size); | 239 native_widget_->SetSize(size); |
| 223 } | 240 } |
| 224 | 241 |
| 225 void Widget::SetBoundsConstrained(const gfx::Rect& bounds, | 242 void Widget::SetBoundsConstrained(const gfx::Rect& bounds, |
| 226 Widget* other_widget) { | 243 Widget* other_widget) { |
| 227 native_widget_->SetBoundsConstrained(bounds, other_widget); | 244 native_widget_->SetBoundsConstrained(bounds, other_widget); |
| 228 } | 245 } |
| 229 | 246 |
| 230 void Widget::MoveAboveWidget(Widget* widget) { | 247 void Widget::MoveAboveWidget(Widget* widget) { |
| 231 native_widget_->MoveAbove(widget->GetNativeView()); | 248 native_widget_->MoveAbove(widget->GetNativeView()); |
| 232 } | 249 } |
| 233 | 250 |
| 234 void Widget::MoveAbove(gfx::NativeView native_view) { | 251 void Widget::MoveAbove(gfx::NativeView native_view) { |
| 235 native_widget_->MoveAbove(native_view); | 252 native_widget_->MoveAbove(native_view); |
| 236 } | 253 } |
| 237 | 254 |
| 238 void Widget::SetShape(gfx::NativeRegion shape) { | 255 void Widget::SetShape(gfx::NativeRegion shape) { |
| 239 native_widget_->SetShape(shape); | 256 native_widget_->SetShape(shape); |
| 240 } | 257 } |
| 241 | 258 |
| 242 void Widget::Close() { | 259 void Widget::Close() { |
| 243 native_widget_->Close(); | 260 if (widget_closed_) { |
| 261 // It appears we can hit this code path if you close a modal dialog then |
| 262 // close the last browser before the destructor is hit, which triggers |
| 263 // invoking Close again. |
| 264 return; |
| 265 } |
| 266 |
| 267 bool can_close = true; |
| 268 if (non_client_view_) |
| 269 can_close = non_client_view_->CanClose(); |
| 270 if (can_close) { |
| 271 SaveWindowPosition(); |
| 272 native_widget_->Close(); |
| 273 widget_closed_ = true; |
| 274 } |
| 244 } | 275 } |
| 245 | 276 |
| 246 void Widget::CloseNow() { | 277 void Widget::CloseNow() { |
| 247 native_widget_->CloseNow(); | 278 native_widget_->CloseNow(); |
| 248 } | 279 } |
| 249 | 280 |
| 281 void Widget::EnableClose(bool enable) { |
| 282 non_client_view_->EnableClose(enable); |
| 283 native_widget_->EnableClose(enable); |
| 284 } |
| 285 |
| 250 void Widget::Show() { | 286 void Widget::Show() { |
| 251 native_widget_->Show(); | 287 native_widget_->Show(); |
| 252 } | 288 } |
| 253 | 289 |
| 254 void Widget::Hide() { | 290 void Widget::Hide() { |
| 255 native_widget_->Hide(); | 291 native_widget_->Hide(); |
| 256 } | 292 } |
| 257 | 293 |
| 294 void Widget::ShowInactive() { |
| 295 native_widget_->ShowNativeWidget(NativeWidget::SHOW_INACTIVE); |
| 296 } |
| 297 |
| 258 void Widget::Activate() { | 298 void Widget::Activate() { |
| 259 native_widget_->Activate(); | 299 native_widget_->Activate(); |
| 260 } | 300 } |
| 261 | 301 |
| 262 void Widget::Deactivate() { | 302 void Widget::Deactivate() { |
| 263 native_widget_->Deactivate(); | 303 native_widget_->Deactivate(); |
| 264 } | 304 } |
| 265 | 305 |
| 266 bool Widget::IsActive() const { | 306 bool Widget::IsActive() const { |
| 267 return native_widget_->IsActive(); | 307 return native_widget_->IsActive(); |
| 268 } | 308 } |
| 269 | 309 |
| 310 void Widget::DisableInactiveRendering() { |
| 311 disable_inactive_rendering_ = true; |
| 312 non_client_view_->DisableInactiveRendering(disable_inactive_rendering_); |
| 313 } |
| 314 |
| 270 void Widget::SetAlwaysOnTop(bool on_top) { | 315 void Widget::SetAlwaysOnTop(bool on_top) { |
| 271 native_widget_->SetAlwaysOnTop(on_top); | 316 native_widget_->SetAlwaysOnTop(on_top); |
| 272 } | 317 } |
| 273 | 318 |
| 274 void Widget::Maximize() { | 319 void Widget::Maximize() { |
| 275 native_widget_->Maximize(); | 320 native_widget_->Maximize(); |
| 276 } | 321 } |
| 277 | 322 |
| 278 void Widget::Minimize() { | 323 void Widget::Minimize() { |
| 279 native_widget_->Minimize(); | 324 native_widget_->Minimize(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 } | 425 } |
| 381 | 426 |
| 382 void Widget::SetCursor(gfx::NativeCursor cursor) { | 427 void Widget::SetCursor(gfx::NativeCursor cursor) { |
| 383 native_widget_->SetCursor(cursor); | 428 native_widget_->SetCursor(cursor); |
| 384 } | 429 } |
| 385 | 430 |
| 386 void Widget::ResetLastMouseMoveFlag() { | 431 void Widget::ResetLastMouseMoveFlag() { |
| 387 last_mouse_event_was_move_ = false; | 432 last_mouse_event_was_move_ = false; |
| 388 } | 433 } |
| 389 | 434 |
| 435 void Widget::UpdateWindowTitle() { |
| 436 // If the non-client view is rendering its own title, it'll need to relayout |
| 437 // now. |
| 438 non_client_view_->Layout(); |
| 439 |
| 440 // Update the native frame's text. We do this regardless of whether or not |
| 441 // the native frame is being used, since this also updates the taskbar, etc. |
| 442 string16 window_title; |
| 443 if (native_widget_->IsScreenReaderActive()) { |
| 444 window_title = WideToUTF16(widget_delegate_->GetAccessibleWindowTitle()); |
| 445 } else { |
| 446 window_title = WideToUTF16(widget_delegate_->GetWindowTitle()); |
| 447 } |
| 448 base::i18n::AdjustStringForLocaleDirection(&window_title); |
| 449 native_widget_->SetWindowTitle(UTF16ToWide(window_title)); |
| 450 } |
| 451 |
| 452 void Widget::UpdateWindowIcon() { |
| 453 non_client_view_->UpdateWindowIcon(); |
| 454 native_widget_->SetWindowIcons(widget_delegate_->GetWindowIcon(), |
| 455 widget_delegate_->GetWindowAppIcon()); |
| 456 } |
| 457 |
| 390 FocusTraversable* Widget::GetFocusTraversable() { | 458 FocusTraversable* Widget::GetFocusTraversable() { |
| 391 return static_cast<internal::RootView*>(root_view_.get()); | 459 return static_cast<internal::RootView*>(root_view_.get()); |
| 392 } | 460 } |
| 393 | 461 |
| 394 void Widget::ThemeChanged() { | 462 void Widget::ThemeChanged() { |
| 395 root_view_->ThemeChanged(); | 463 root_view_->ThemeChanged(); |
| 396 } | 464 } |
| 397 | 465 |
| 398 void Widget::LocaleChanged() { | 466 void Widget::LocaleChanged() { |
| 399 root_view_->LocaleChanged(); | 467 root_view_->LocaleChanged(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 if (ViewsDelegate::views_delegate) | 515 if (ViewsDelegate::views_delegate) |
| 448 ViewsDelegate::views_delegate->NotifyAccessibilityEvent(view, event_type); | 516 ViewsDelegate::views_delegate->NotifyAccessibilityEvent(view, event_type); |
| 449 | 517 |
| 450 if (send_native_event) | 518 if (send_native_event) |
| 451 native_widget_->SendNativeAccessibilityEvent(view, event_type); | 519 native_widget_->SendNativeAccessibilityEvent(view, event_type); |
| 452 } | 520 } |
| 453 | 521 |
| 454 //////////////////////////////////////////////////////////////////////////////// | 522 //////////////////////////////////////////////////////////////////////////////// |
| 455 // Widget, NativeWidgetDelegate implementation: | 523 // Widget, NativeWidgetDelegate implementation: |
| 456 | 524 |
| 525 bool Widget::CanActivate() const { |
| 526 return widget_delegate_->CanActivate(); |
| 527 } |
| 528 |
| 529 bool Widget::IsInactiveRenderingDisabled() const { |
| 530 return disable_inactive_rendering_; |
| 531 } |
| 532 |
| 533 void Widget::EnableInactiveRendering() { |
| 534 disable_inactive_rendering_ = false; |
| 535 non_client_view_->DisableInactiveRendering(false); |
| 536 } |
| 537 |
| 538 void Widget::OnNativeWidgetActivationChanged(bool active) { |
| 539 if (!active) |
| 540 SaveWindowPosition(); |
| 541 |
| 542 // TODO(beng): merge these two. |
| 543 widget_delegate_->OnWidgetActivated(active); |
| 544 widget_delegate_->OnWindowActivationChanged(active); |
| 545 } |
| 546 |
| 457 void Widget::OnNativeFocus(gfx::NativeView focused_view) { | 547 void Widget::OnNativeFocus(gfx::NativeView focused_view) { |
| 458 GetFocusManager()->GetWidgetFocusManager()->OnWidgetFocusEvent( | 548 GetFocusManager()->GetWidgetFocusManager()->OnWidgetFocusEvent( |
| 459 focused_view, | 549 focused_view, |
| 460 GetNativeView()); | 550 GetNativeView()); |
| 461 } | 551 } |
| 462 | 552 |
| 463 void Widget::OnNativeBlur(gfx::NativeView focused_view) { | 553 void Widget::OnNativeBlur(gfx::NativeView focused_view) { |
| 464 GetFocusManager()->GetWidgetFocusManager()->OnWidgetFocusEvent( | 554 GetFocusManager()->GetWidgetFocusManager()->OnWidgetFocusEvent( |
| 465 GetNativeView(), | 555 GetNativeView(), |
| 466 focused_view); | 556 focused_view); |
| 467 } | 557 } |
| 468 | 558 |
| 469 void Widget::OnNativeWidgetCreated() { | 559 void Widget::OnNativeWidgetCreated() { |
| 470 if (GetTopLevelWidget() == this) { | 560 if (GetTopLevelWidget() == this) { |
| 471 // Only the top level Widget in a native widget hierarchy has a focus | 561 // Only the top level Widget in a native widget hierarchy has a focus |
| 472 // manager. | 562 // manager. |
| 473 focus_manager_.reset(new FocusManager(this)); | 563 focus_manager_.reset(new FocusManager(this)); |
| 474 } | 564 } |
| 475 EnsureCompositor(); | 565 EnsureCompositor(); |
| 566 |
| 567 native_widget_->SetAccessibleRole( |
| 568 widget_delegate_->GetAccessibleWindowRole()); |
| 569 native_widget_->SetAccessibleState( |
| 570 widget_delegate_->GetAccessibleWindowState()); |
| 571 } |
| 572 |
| 573 void Widget::OnNativeWidgetDestroying() { |
| 574 if (non_client_view_) |
| 575 non_client_view_->WindowClosing(); |
| 576 widget_delegate_->WindowClosing(); |
| 476 } | 577 } |
| 477 | 578 |
| 478 void Widget::OnNativeWidgetDestroyed() { | 579 void Widget::OnNativeWidgetDestroyed() { |
| 479 widget_delegate_->DeleteDelegate(); | 580 widget_delegate_->DeleteDelegate(); |
| 480 widget_delegate_ = NULL; | 581 widget_delegate_ = NULL; |
| 481 } | 582 } |
| 482 | 583 |
| 483 void Widget::OnSizeChanged(const gfx::Size& new_size) { | 584 gfx::Size Widget::GetMinimumSize() { |
| 585 return non_client_view_->GetMinimumSize(); |
| 586 } |
| 587 |
| 588 void Widget::OnNativeWidgetSizeChanged(const gfx::Size& new_size) { |
| 484 root_view_->SetSize(new_size); | 589 root_view_->SetSize(new_size); |
| 485 } | 590 } |
| 486 | 591 |
| 592 void Widget::OnNativeWidgetBeginUserBoundsChange() { |
| 593 widget_delegate_->OnWindowBeginUserBoundsChange(); |
| 594 } |
| 595 |
| 596 void Widget::OnNativeWidgetEndUserBoundsChange() { |
| 597 widget_delegate_->OnWindowEndUserBoundsChange(); |
| 598 } |
| 599 |
| 487 bool Widget::HasFocusManager() const { | 600 bool Widget::HasFocusManager() const { |
| 488 return !!focus_manager_.get(); | 601 return !!focus_manager_.get(); |
| 489 } | 602 } |
| 490 | 603 |
| 491 bool Widget::OnNativeWidgetPaintAccelerated(const gfx::Rect& dirty_region) { | 604 bool Widget::OnNativeWidgetPaintAccelerated(const gfx::Rect& dirty_region) { |
| 492 #if !defined(COMPOSITOR_2) | 605 #if !defined(COMPOSITOR_2) |
| 493 return false; | 606 return false; |
| 494 #else | 607 #else |
| 495 if (!compositor_.get()) | 608 if (!compositor_.get()) |
| 496 return false; | 609 return false; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 507 GetRootView()->Paint(canvas); | 620 GetRootView()->Paint(canvas); |
| 508 #if !defined(COMPOSITOR_2) | 621 #if !defined(COMPOSITOR_2) |
| 509 if (compositor_.get()) { | 622 if (compositor_.get()) { |
| 510 compositor_->NotifyStart(); | 623 compositor_->NotifyStart(); |
| 511 root_view_->PaintComposite(compositor_.get()); | 624 root_view_->PaintComposite(compositor_.get()); |
| 512 compositor_->NotifyEnd(); | 625 compositor_->NotifyEnd(); |
| 513 } | 626 } |
| 514 #endif | 627 #endif |
| 515 } | 628 } |
| 516 | 629 |
| 630 int Widget::GetNonClientComponent(const gfx::Point& point) { |
| 631 return non_client_view_->NonClientHitTest(point); |
| 632 } |
| 633 |
| 517 bool Widget::OnKeyEvent(const KeyEvent& event) { | 634 bool Widget::OnKeyEvent(const KeyEvent& event) { |
| 518 return static_cast<internal::RootView*>(GetRootView())->OnKeyEvent(event); | 635 return static_cast<internal::RootView*>(GetRootView())->OnKeyEvent(event); |
| 519 } | 636 } |
| 520 | 637 |
| 521 bool Widget::OnMouseEvent(const MouseEvent& event) { | 638 bool Widget::OnMouseEvent(const MouseEvent& event) { |
| 522 switch (event.type()) { | 639 switch (event.type()) { |
| 523 case ui::ET_MOUSE_PRESSED: | 640 case ui::ET_MOUSE_PRESSED: |
| 524 last_mouse_event_was_move_ = false; | 641 last_mouse_event_was_move_ = false; |
| 525 if (GetRootView()->OnMousePressed(event)) { | 642 if (GetRootView()->OnMousePressed(event)) { |
| 526 is_mouse_button_pressed_ = true; | 643 is_mouse_button_pressed_ = true; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 } | 680 } |
| 564 return true; | 681 return true; |
| 565 } | 682 } |
| 566 | 683 |
| 567 void Widget::OnMouseCaptureLost() { | 684 void Widget::OnMouseCaptureLost() { |
| 568 if (is_mouse_button_pressed_) | 685 if (is_mouse_button_pressed_) |
| 569 GetRootView()->OnMouseCaptureLost(); | 686 GetRootView()->OnMouseCaptureLost(); |
| 570 is_mouse_button_pressed_ = false; | 687 is_mouse_button_pressed_ = false; |
| 571 } | 688 } |
| 572 | 689 |
| 690 bool Widget::ExecuteCommand(int command_id) { |
| 691 return widget_delegate_->ExecuteWindowsCommand(command_id); |
| 692 } |
| 693 |
| 573 Widget* Widget::AsWidget() { | 694 Widget* Widget::AsWidget() { |
| 574 return this; | 695 return this; |
| 575 } | 696 } |
| 576 | 697 |
| 577 const Widget* Widget::AsWidget() const { | 698 const Widget* Widget::AsWidget() const { |
| 578 return this; | 699 return this; |
| 579 } | 700 } |
| 580 | 701 |
| 581 //////////////////////////////////////////////////////////////////////////////// | 702 //////////////////////////////////////////////////////////////////////////////// |
| 582 // Widget, FocusTraversable implementation: | 703 // Widget, FocusTraversable implementation: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 // instead of creating a new one here. | 756 // instead of creating a new one here. |
| 636 gfx::AcceleratedWidget widget = native_widget_->GetAcceleratedWidget(); | 757 gfx::AcceleratedWidget widget = native_widget_->GetAcceleratedWidget(); |
| 637 if (widget != gfx::kNullAcceleratedWidget) | 758 if (widget != gfx::kNullAcceleratedWidget) |
| 638 compositor_ = ui::Compositor::Create(widget); | 759 compositor_ = ui::Compositor::Create(widget); |
| 639 } | 760 } |
| 640 | 761 |
| 641 bool Widget::ShouldReleaseCaptureOnMouseReleased() const { | 762 bool Widget::ShouldReleaseCaptureOnMouseReleased() const { |
| 642 return true; | 763 return true; |
| 643 } | 764 } |
| 644 | 765 |
| 766 void Widget::SaveWindowPosition() { |
| 767 // The window delegate does the actual saving for us. It seems like (judging |
| 768 // by go/crash) that in some circumstances we can end up here after |
| 769 // WM_DESTROY, at which point the window delegate is likely gone. So just |
| 770 // bail. |
| 771 if (!widget_delegate_) |
| 772 return; |
| 773 |
| 774 bool maximized; |
| 775 gfx::Rect bounds; |
| 776 native_widget_->GetWindowBoundsAndMaximizedState(&bounds, &maximized); |
| 777 widget_delegate_->SaveWindowPlacement(bounds, maximized); |
| 778 } |
| 779 |
| 780 |
| 781 |
| 645 } // namespace views | 782 } // namespace views |
| OLD | NEW |