| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/desktop_aura/desktop_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/aura/client/activation_client.h" | 8 #include "ui/aura/client/activation_client.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 //////////////////////////////////////////////////////////////////////////////// | 175 //////////////////////////////////////////////////////////////////////////////// |
| 176 // DesktopNativeWidgetAura, public: | 176 // DesktopNativeWidgetAura, public: |
| 177 | 177 |
| 178 DesktopNativeWidgetAura::DesktopNativeWidgetAura( | 178 DesktopNativeWidgetAura::DesktopNativeWidgetAura( |
| 179 internal::NativeWidgetDelegate* delegate) | 179 internal::NativeWidgetDelegate* delegate) |
| 180 : ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 180 : ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 181 close_widget_factory_(this), | 181 close_widget_factory_(this), |
| 182 can_activate_(true), | 182 can_activate_(true), |
| 183 desktop_root_window_host_(NULL), | 183 desktop_root_window_host_(NULL), |
| 184 window_(new aura::Window(this)), | |
| 185 content_window_container_(NULL), | 184 content_window_container_(NULL), |
| 185 content_window_(new aura::Window(this)), |
| 186 native_widget_delegate_(delegate), | 186 native_widget_delegate_(delegate), |
| 187 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), | 187 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), |
| 188 restore_focus_on_activate_(false), | 188 restore_focus_on_activate_(false), |
| 189 cursor_(gfx::kNullCursor), | 189 cursor_(gfx::kNullCursor), |
| 190 widget_type_(Widget::InitParams::TYPE_WINDOW) { | 190 widget_type_(Widget::InitParams::TYPE_WINDOW) { |
| 191 window_->SetProperty(kDesktopNativeWidgetAuraKey, this); | 191 content_window_->SetProperty(kDesktopNativeWidgetAuraKey, this); |
| 192 aura::client::SetFocusChangeObserver(window_, this); | 192 aura::client::SetFocusChangeObserver(content_window_, this); |
| 193 aura::client::SetActivationChangeObserver(window_, this); | 193 aura::client::SetActivationChangeObserver(content_window_, this); |
| 194 } | 194 } |
| 195 | 195 |
| 196 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { | 196 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { |
| 197 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 197 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 198 delete native_widget_delegate_; | 198 delete native_widget_delegate_; |
| 199 else | 199 else |
| 200 CloseNow(); | 200 CloseNow(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 // static | 203 // static |
| (...skipping 30 matching lines...) Expand all Loading... |
| 234 root_window_event_filter_->RemoveHandler(input_method_event_filter_.get()); | 234 root_window_event_filter_->RemoveHandler(input_method_event_filter_.get()); |
| 235 | 235 |
| 236 stacking_client_.reset(); // Uses root_window_ at destruction. | 236 stacking_client_.reset(); // Uses root_window_ at destruction. |
| 237 | 237 |
| 238 capture_client_.reset(); // Uses root_window_ at destruction. | 238 capture_client_.reset(); // Uses root_window_ at destruction. |
| 239 | 239 |
| 240 root_window_->RemoveRootWindowObserver(this); | 240 root_window_->RemoveRootWindowObserver(this); |
| 241 root_window_.reset(); // Uses input_method_event_filter_ at destruction. | 241 root_window_.reset(); // Uses input_method_event_filter_ at destruction. |
| 242 // RootWindow owns |desktop_root_window_host_|. | 242 // RootWindow owns |desktop_root_window_host_|. |
| 243 desktop_root_window_host_ = NULL; | 243 desktop_root_window_host_ = NULL; |
| 244 window_ = NULL; | 244 content_window_ = NULL; |
| 245 | 245 |
| 246 native_widget_delegate_->OnNativeWidgetDestroyed(); | 246 native_widget_delegate_->OnNativeWidgetDestroyed(); |
| 247 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 247 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 248 delete this; | 248 delete this; |
| 249 } | 249 } |
| 250 | 250 |
| 251 void DesktopNativeWidgetAura::InstallInputMethodEventFilter( | 251 void DesktopNativeWidgetAura::InstallInputMethodEventFilter( |
| 252 aura::RootWindow* root) { | 252 aura::RootWindow* root) { |
| 253 DCHECK(!input_method_event_filter_.get()); | 253 DCHECK(!input_method_event_filter_.get()); |
| 254 | 254 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 } | 313 } |
| 314 | 314 |
| 315 //////////////////////////////////////////////////////////////////////////////// | 315 //////////////////////////////////////////////////////////////////////////////// |
| 316 // DesktopNativeWidgetAura, internal::NativeWidgetPrivate implementation: | 316 // DesktopNativeWidgetAura, internal::NativeWidgetPrivate implementation: |
| 317 | 317 |
| 318 void DesktopNativeWidgetAura::InitNativeWidget( | 318 void DesktopNativeWidgetAura::InitNativeWidget( |
| 319 const Widget::InitParams& params) { | 319 const Widget::InitParams& params) { |
| 320 ownership_ = params.ownership; | 320 ownership_ = params.ownership; |
| 321 widget_type_ = params.type; | 321 widget_type_ = params.type; |
| 322 | 322 |
| 323 NativeWidgetAura::RegisterNativeWidgetForWindow(this, window_); | 323 NativeWidgetAura::RegisterNativeWidgetForWindow(this, content_window_); |
| 324 // Animations on TYPE_WINDOW are handled by the OS. Additionally if we animate | 324 // Animations on TYPE_WINDOW are handled by the OS. Additionally if we animate |
| 325 // these windows the size of the window gets augmented, effecting restore | 325 // these windows the size of the window gets augmented, effecting restore |
| 326 // bounds and maximized windows in bad ways. | 326 // bounds and maximized windows in bad ways. |
| 327 if (params.type == Widget::InitParams::TYPE_WINDOW && | 327 if (params.type == Widget::InitParams::TYPE_WINDOW && |
| 328 !params.remove_standard_frame) { | 328 !params.remove_standard_frame) { |
| 329 window_->SetProperty(aura::client::kAnimationsDisabledKey, true); | 329 content_window_->SetProperty(aura::client::kAnimationsDisabledKey, true); |
| 330 } | 330 } |
| 331 window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); | 331 content_window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); |
| 332 window_->Init(params.layer_type); | 332 content_window_->Init(params.layer_type); |
| 333 corewm::SetShadowType(window_, corewm::SHADOW_TYPE_NONE); | 333 corewm::SetShadowType(content_window_, corewm::SHADOW_TYPE_NONE); |
| 334 #if defined(OS_LINUX) // TODO(scottmg): http://crbug.com/180071 | 334 #if defined(OS_LINUX) // TODO(scottmg): http://crbug.com/180071 |
| 335 window_->Show(); | 335 content_window_->Show(); |
| 336 #endif | 336 #endif |
| 337 | 337 |
| 338 desktop_root_window_host_ = params.desktop_root_window_host ? | 338 desktop_root_window_host_ = params.desktop_root_window_host ? |
| 339 params.desktop_root_window_host : | 339 params.desktop_root_window_host : |
| 340 DesktopRootWindowHost::Create(native_widget_delegate_, | 340 DesktopRootWindowHost::Create(native_widget_delegate_, |
| 341 this, params.bounds); | 341 this, params.bounds); |
| 342 root_window_.reset( | 342 root_window_.reset( |
| 343 desktop_root_window_host_->Init(window_, params)); | 343 desktop_root_window_host_->Init(content_window_, params)); |
| 344 | 344 |
| 345 UpdateWindowTransparency(); | 345 UpdateWindowTransparency(); |
| 346 | 346 |
| 347 content_window_container_ = new aura::Window(NULL); | 347 content_window_container_ = new aura::Window(NULL); |
| 348 content_window_container_->Init(ui::LAYER_NOT_DRAWN); | 348 content_window_container_->Init(ui::LAYER_NOT_DRAWN); |
| 349 content_window_container_->Show(); | 349 content_window_container_->Show(); |
| 350 content_window_container_->AddChild(window_); | 350 content_window_container_->AddChild(content_window_); |
| 351 root_window_->AddChild(content_window_container_); | 351 root_window_->AddChild(content_window_container_); |
| 352 OnRootWindowHostResized(root_window_.get()); | 352 OnRootWindowHostResized(root_window_.get()); |
| 353 | 353 |
| 354 root_window_->AddRootWindowObserver(this); | 354 root_window_->AddRootWindowObserver(this); |
| 355 | 355 |
| 356 stacking_client_.reset( | 356 stacking_client_.reset( |
| 357 new DesktopNativeWidgetAuraStackingClient(root_window_.get())); | 357 new DesktopNativeWidgetAuraStackingClient(root_window_.get())); |
| 358 drop_helper_.reset(new DropHelper( | 358 drop_helper_.reset(new DropHelper( |
| 359 static_cast<internal::RootView*>(GetWidget()->GetRootView()))); | 359 static_cast<internal::RootView*>(GetWidget()->GetRootView()))); |
| 360 aura::client::SetDragDropDelegate(window_, this); | 360 aura::client::SetDragDropDelegate(content_window_, this); |
| 361 | 361 |
| 362 tooltip_manager_.reset(new views::TooltipManagerAura(window_, GetWidget())); | 362 tooltip_manager_.reset(new views::TooltipManagerAura(content_window_, |
| 363 GetWidget())); |
| 363 | 364 |
| 364 tooltip_controller_.reset( | 365 tooltip_controller_.reset( |
| 365 new corewm::TooltipController( | 366 new corewm::TooltipController( |
| 366 desktop_root_window_host_->CreateTooltip())); | 367 desktop_root_window_host_->CreateTooltip())); |
| 367 aura::client::SetTooltipClient(root_window_.get(), tooltip_controller_.get()); | 368 aura::client::SetTooltipClient(root_window_.get(), tooltip_controller_.get()); |
| 368 root_window_->AddPreTargetHandler(tooltip_controller_.get()); | 369 root_window_->AddPreTargetHandler(tooltip_controller_.get()); |
| 369 | 370 |
| 370 if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) { | 371 if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) { |
| 371 visibility_controller_.reset(new views::corewm::VisibilityController); | 372 visibility_controller_.reset(new views::corewm::VisibilityController); |
| 372 aura::client::SetVisibilityClient(GetNativeView()->GetRootWindow(), | 373 aura::client::SetVisibilityClient(root_window_.get(), |
| 373 visibility_controller_.get()); | 374 visibility_controller_.get()); |
| 374 views::corewm::SetChildWindowVisibilityChangesAnimated( | 375 views::corewm::SetChildWindowVisibilityChangesAnimated(root_window_.get()); |
| 375 GetNativeView()->GetRootWindow()); | |
| 376 views::corewm::SetChildWindowVisibilityChangesAnimated( | 376 views::corewm::SetChildWindowVisibilityChangesAnimated( |
| 377 content_window_container_); | 377 content_window_container_); |
| 378 } | 378 } |
| 379 | 379 |
| 380 if (params.type == Widget::InitParams::TYPE_WINDOW) { | 380 if (params.type == Widget::InitParams::TYPE_WINDOW) { |
| 381 FocusManager* focus_manager = | 381 FocusManager* focus_manager = |
| 382 native_widget_delegate_->AsWidget()->GetFocusManager(); | 382 native_widget_delegate_->AsWidget()->GetFocusManager(); |
| 383 root_window_->AddPreTargetHandler(focus_manager->GetEventHandler()); | 383 root_window_->AddPreTargetHandler(focus_manager->GetEventHandler()); |
| 384 } | 384 } |
| 385 | 385 |
| 386 window_->Show(); | 386 content_window_->Show(); |
| 387 desktop_root_window_host_->InitFocus(window_); | 387 aura::client::GetFocusClient(content_window_)->FocusWindow(content_window_); |
| 388 | 388 |
| 389 aura::client::SetActivationDelegate(window_, this); | 389 aura::client::SetActivationDelegate(content_window_, this); |
| 390 | 390 |
| 391 shadow_controller_.reset( | 391 shadow_controller_.reset( |
| 392 new corewm::ShadowController( | 392 new corewm::ShadowController( |
| 393 aura::client::GetActivationClient(root_window_.get()))); | 393 aura::client::GetActivationClient(root_window_.get()))); |
| 394 | 394 |
| 395 window_reorderer_.reset(new WindowReorderer(window_, | 395 window_reorderer_.reset(new WindowReorderer(content_window_, |
| 396 GetWidget()->GetRootView())); | 396 GetWidget()->GetRootView())); |
| 397 } | 397 } |
| 398 | 398 |
| 399 NonClientFrameView* DesktopNativeWidgetAura::CreateNonClientFrameView() { | 399 NonClientFrameView* DesktopNativeWidgetAura::CreateNonClientFrameView() { |
| 400 return desktop_root_window_host_->CreateNonClientFrameView(); | 400 return desktop_root_window_host_->CreateNonClientFrameView(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 bool DesktopNativeWidgetAura::ShouldUseNativeFrame() const { | 403 bool DesktopNativeWidgetAura::ShouldUseNativeFrame() const { |
| 404 return desktop_root_window_host_->ShouldUseNativeFrame(); | 404 return desktop_root_window_host_->ShouldUseNativeFrame(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 void DesktopNativeWidgetAura::FrameTypeChanged() { | 407 void DesktopNativeWidgetAura::FrameTypeChanged() { |
| 408 desktop_root_window_host_->FrameTypeChanged(); | 408 desktop_root_window_host_->FrameTypeChanged(); |
| 409 UpdateWindowTransparency(); | 409 UpdateWindowTransparency(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 Widget* DesktopNativeWidgetAura::GetWidget() { | 412 Widget* DesktopNativeWidgetAura::GetWidget() { |
| 413 return native_widget_delegate_->AsWidget(); | 413 return native_widget_delegate_->AsWidget(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 const Widget* DesktopNativeWidgetAura::GetWidget() const { | 416 const Widget* DesktopNativeWidgetAura::GetWidget() const { |
| 417 return native_widget_delegate_->AsWidget(); | 417 return native_widget_delegate_->AsWidget(); |
| 418 } | 418 } |
| 419 | 419 |
| 420 gfx::NativeView DesktopNativeWidgetAura::GetNativeView() const { | 420 gfx::NativeView DesktopNativeWidgetAura::GetNativeView() const { |
| 421 return window_; | 421 return content_window_; |
| 422 } | 422 } |
| 423 | 423 |
| 424 gfx::NativeWindow DesktopNativeWidgetAura::GetNativeWindow() const { | 424 gfx::NativeWindow DesktopNativeWidgetAura::GetNativeWindow() const { |
| 425 return window_; | 425 return content_window_; |
| 426 } | 426 } |
| 427 | 427 |
| 428 Widget* DesktopNativeWidgetAura::GetTopLevelWidget() { | 428 Widget* DesktopNativeWidgetAura::GetTopLevelWidget() { |
| 429 return GetWidget(); | 429 return GetWidget(); |
| 430 } | 430 } |
| 431 | 431 |
| 432 const ui::Compositor* DesktopNativeWidgetAura::GetCompositor() const { | 432 const ui::Compositor* DesktopNativeWidgetAura::GetCompositor() const { |
| 433 return window_ ? window_->layer()->GetCompositor() : NULL; | 433 return content_window_ ? content_window_->layer()->GetCompositor() : NULL; |
| 434 } | 434 } |
| 435 | 435 |
| 436 ui::Compositor* DesktopNativeWidgetAura::GetCompositor() { | 436 ui::Compositor* DesktopNativeWidgetAura::GetCompositor() { |
| 437 return const_cast<ui::Compositor*>( | 437 return const_cast<ui::Compositor*>( |
| 438 const_cast<const DesktopNativeWidgetAura*>(this)->GetCompositor()); | 438 const_cast<const DesktopNativeWidgetAura*>(this)->GetCompositor()); |
| 439 } | 439 } |
| 440 | 440 |
| 441 ui::Layer* DesktopNativeWidgetAura::GetLayer() { | 441 ui::Layer* DesktopNativeWidgetAura::GetLayer() { |
| 442 return window_ ? window_->layer() : NULL; | 442 return content_window_ ? content_window_->layer() : NULL; |
| 443 } | 443 } |
| 444 | 444 |
| 445 void DesktopNativeWidgetAura::ReorderNativeViews() { | 445 void DesktopNativeWidgetAura::ReorderNativeViews() { |
| 446 window_reorderer_->ReorderChildWindows(); | 446 window_reorderer_->ReorderChildWindows(); |
| 447 } | 447 } |
| 448 | 448 |
| 449 void DesktopNativeWidgetAura::ViewRemoved(View* view) { | 449 void DesktopNativeWidgetAura::ViewRemoved(View* view) { |
| 450 } | 450 } |
| 451 | 451 |
| 452 void DesktopNativeWidgetAura::SetNativeWindowProperty(const char* name, | 452 void DesktopNativeWidgetAura::SetNativeWindowProperty(const char* name, |
| 453 void* value) { | 453 void* value) { |
| 454 if (window_) | 454 if (content_window_) |
| 455 window_->SetNativeWindowProperty(name, value); | 455 content_window_->SetNativeWindowProperty(name, value); |
| 456 } | 456 } |
| 457 | 457 |
| 458 void* DesktopNativeWidgetAura::GetNativeWindowProperty(const char* name) const { | 458 void* DesktopNativeWidgetAura::GetNativeWindowProperty(const char* name) const { |
| 459 return window_ ? window_->GetNativeWindowProperty(name) : NULL; | 459 return content_window_ ? |
| 460 content_window_->GetNativeWindowProperty(name) : NULL; |
| 460 } | 461 } |
| 461 | 462 |
| 462 TooltipManager* DesktopNativeWidgetAura::GetTooltipManager() const { | 463 TooltipManager* DesktopNativeWidgetAura::GetTooltipManager() const { |
| 463 return tooltip_manager_.get(); | 464 return tooltip_manager_.get(); |
| 464 } | 465 } |
| 465 | 466 |
| 466 void DesktopNativeWidgetAura::SetCapture() { | 467 void DesktopNativeWidgetAura::SetCapture() { |
| 467 if (!window_) | 468 if (!content_window_) |
| 468 return; | 469 return; |
| 469 | 470 |
| 470 window_->SetCapture(); | 471 content_window_->SetCapture(); |
| 471 } | 472 } |
| 472 | 473 |
| 473 void DesktopNativeWidgetAura::ReleaseCapture() { | 474 void DesktopNativeWidgetAura::ReleaseCapture() { |
| 474 if (!window_) | 475 if (!content_window_) |
| 475 return; | 476 return; |
| 476 | 477 |
| 477 window_->ReleaseCapture(); | 478 content_window_->ReleaseCapture(); |
| 478 } | 479 } |
| 479 | 480 |
| 480 bool DesktopNativeWidgetAura::HasCapture() const { | 481 bool DesktopNativeWidgetAura::HasCapture() const { |
| 481 return window_ && window_->HasCapture() && | 482 return content_window_ && content_window_->HasCapture() && |
| 482 desktop_root_window_host_->HasCapture(); | 483 desktop_root_window_host_->HasCapture(); |
| 483 } | 484 } |
| 484 | 485 |
| 485 InputMethod* DesktopNativeWidgetAura::CreateInputMethod() { | 486 InputMethod* DesktopNativeWidgetAura::CreateInputMethod() { |
| 486 ui::InputMethod* host = input_method_event_filter_->input_method(); | 487 ui::InputMethod* host = input_method_event_filter_->input_method(); |
| 487 return new InputMethodBridge(this, host, false); | 488 return new InputMethodBridge(this, host, false); |
| 488 } | 489 } |
| 489 | 490 |
| 490 internal::InputMethodDelegate* | 491 internal::InputMethodDelegate* |
| 491 DesktopNativeWidgetAura::GetInputMethodDelegate() { | 492 DesktopNativeWidgetAura::GetInputMethodDelegate() { |
| 492 return this; | 493 return this; |
| 493 } | 494 } |
| 494 | 495 |
| 495 void DesktopNativeWidgetAura::CenterWindow(const gfx::Size& size) { | 496 void DesktopNativeWidgetAura::CenterWindow(const gfx::Size& size) { |
| 496 if (window_) | 497 if (content_window_) |
| 497 desktop_root_window_host_->CenterWindow(size); | 498 desktop_root_window_host_->CenterWindow(size); |
| 498 } | 499 } |
| 499 | 500 |
| 500 void DesktopNativeWidgetAura::GetWindowPlacement( | 501 void DesktopNativeWidgetAura::GetWindowPlacement( |
| 501 gfx::Rect* bounds, | 502 gfx::Rect* bounds, |
| 502 ui::WindowShowState* maximized) const { | 503 ui::WindowShowState* maximized) const { |
| 503 if (window_) | 504 if (content_window_) |
| 504 desktop_root_window_host_->GetWindowPlacement(bounds, maximized); | 505 desktop_root_window_host_->GetWindowPlacement(bounds, maximized); |
| 505 } | 506 } |
| 506 | 507 |
| 507 void DesktopNativeWidgetAura::SetWindowTitle(const string16& title) { | 508 void DesktopNativeWidgetAura::SetWindowTitle(const string16& title) { |
| 508 if (window_) | 509 if (content_window_) |
| 509 desktop_root_window_host_->SetWindowTitle(title); | 510 desktop_root_window_host_->SetWindowTitle(title); |
| 510 } | 511 } |
| 511 | 512 |
| 512 void DesktopNativeWidgetAura::SetWindowIcons(const gfx::ImageSkia& window_icon, | 513 void DesktopNativeWidgetAura::SetWindowIcons(const gfx::ImageSkia& window_icon, |
| 513 const gfx::ImageSkia& app_icon) { | 514 const gfx::ImageSkia& app_icon) { |
| 514 if (window_) | 515 if (content_window_) |
| 515 desktop_root_window_host_->SetWindowIcons(window_icon, app_icon); | 516 desktop_root_window_host_->SetWindowIcons(window_icon, app_icon); |
| 516 } | 517 } |
| 517 | 518 |
| 518 void DesktopNativeWidgetAura::InitModalType(ui::ModalType modal_type) { | 519 void DesktopNativeWidgetAura::InitModalType(ui::ModalType modal_type) { |
| 519 // 99% of the time, we should not be asked to create a | 520 // 99% of the time, we should not be asked to create a |
| 520 // DesktopNativeWidgetAura that is modal. We only support window modal | 521 // DesktopNativeWidgetAura that is modal. We only support window modal |
| 521 // dialogs on the same lines as non AURA. | 522 // dialogs on the same lines as non AURA. |
| 522 desktop_root_window_host_->InitModalType(modal_type); | 523 desktop_root_window_host_->InitModalType(modal_type); |
| 523 } | 524 } |
| 524 | 525 |
| 525 gfx::Rect DesktopNativeWidgetAura::GetWindowBoundsInScreen() const { | 526 gfx::Rect DesktopNativeWidgetAura::GetWindowBoundsInScreen() const { |
| 526 return window_ ? desktop_root_window_host_->GetWindowBoundsInScreen() : | 527 return content_window_ ? |
| 527 gfx::Rect(); | 528 desktop_root_window_host_->GetWindowBoundsInScreen() : gfx::Rect(); |
| 528 } | 529 } |
| 529 | 530 |
| 530 gfx::Rect DesktopNativeWidgetAura::GetClientAreaBoundsInScreen() const { | 531 gfx::Rect DesktopNativeWidgetAura::GetClientAreaBoundsInScreen() const { |
| 531 return window_ ? desktop_root_window_host_->GetClientAreaBoundsInScreen() : | 532 return content_window_ ? |
| 532 gfx::Rect(); | 533 desktop_root_window_host_->GetClientAreaBoundsInScreen() : gfx::Rect(); |
| 533 } | 534 } |
| 534 | 535 |
| 535 gfx::Rect DesktopNativeWidgetAura::GetRestoredBounds() const { | 536 gfx::Rect DesktopNativeWidgetAura::GetRestoredBounds() const { |
| 536 return window_ ? desktop_root_window_host_->GetRestoredBounds() : gfx::Rect(); | 537 return content_window_ ? |
| 538 desktop_root_window_host_->GetRestoredBounds() : gfx::Rect(); |
| 537 } | 539 } |
| 538 | 540 |
| 539 void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) { | 541 void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) { |
| 540 if (!window_) | 542 if (!content_window_) |
| 541 return; | 543 return; |
| 542 // TODO(ananta) | 544 // TODO(ananta) |
| 543 // This code by default scales the bounds rectangle by 1. | 545 // This code by default scales the bounds rectangle by 1. |
| 544 // We could probably get rid of this and similar logic from | 546 // We could probably get rid of this and similar logic from |
| 545 // the DesktopNativeWidgetAura::OnRootWindowHostResized function. | 547 // the DesktopNativeWidgetAura::OnRootWindowHostResized function. |
| 546 float scale = 1; | 548 float scale = 1; |
| 547 aura::RootWindow* root = root_window_.get(); | 549 aura::RootWindow* root = root_window_.get(); |
| 548 if (root) { | 550 if (root) { |
| 549 scale = gfx::Screen::GetScreenFor(root)-> | 551 scale = gfx::Screen::GetScreenFor(root)-> |
| 550 GetDisplayNearestWindow(root).device_scale_factor(); | 552 GetDisplayNearestWindow(root).device_scale_factor(); |
| 551 } | 553 } |
| 552 gfx::Rect bounds_in_pixels( | 554 gfx::Rect bounds_in_pixels( |
| 553 gfx::ToCeiledPoint(gfx::ScalePoint(bounds.origin(), scale)), | 555 gfx::ToCeiledPoint(gfx::ScalePoint(bounds.origin(), scale)), |
| 554 gfx::ToFlooredSize(gfx::ScaleSize(bounds.size(), scale))); | 556 gfx::ToFlooredSize(gfx::ScaleSize(bounds.size(), scale))); |
| 555 desktop_root_window_host_->AsRootWindowHost()->SetBounds(bounds_in_pixels); | 557 desktop_root_window_host_->AsRootWindowHost()->SetBounds(bounds_in_pixels); |
| 556 } | 558 } |
| 557 | 559 |
| 558 void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) { | 560 void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) { |
| 559 if (window_) | 561 if (content_window_) |
| 560 desktop_root_window_host_->SetSize(size); | 562 desktop_root_window_host_->SetSize(size); |
| 561 } | 563 } |
| 562 | 564 |
| 563 void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) { | 565 void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) { |
| 564 } | 566 } |
| 565 | 567 |
| 566 void DesktopNativeWidgetAura::StackAtTop() { | 568 void DesktopNativeWidgetAura::StackAtTop() { |
| 567 } | 569 } |
| 568 | 570 |
| 569 void DesktopNativeWidgetAura::StackBelow(gfx::NativeView native_view) { | 571 void DesktopNativeWidgetAura::StackBelow(gfx::NativeView native_view) { |
| 570 } | 572 } |
| 571 | 573 |
| 572 void DesktopNativeWidgetAura::SetShape(gfx::NativeRegion shape) { | 574 void DesktopNativeWidgetAura::SetShape(gfx::NativeRegion shape) { |
| 573 if (window_) | 575 if (content_window_) |
| 574 desktop_root_window_host_->SetShape(shape); | 576 desktop_root_window_host_->SetShape(shape); |
| 575 } | 577 } |
| 576 | 578 |
| 577 void DesktopNativeWidgetAura::Close() { | 579 void DesktopNativeWidgetAura::Close() { |
| 578 if (!window_) | 580 if (!content_window_) |
| 579 return; | 581 return; |
| 580 desktop_root_window_host_->Close(); | 582 desktop_root_window_host_->Close(); |
| 581 window_->SuppressPaint(); | 583 content_window_->SuppressPaint(); |
| 582 } | 584 } |
| 583 | 585 |
| 584 void DesktopNativeWidgetAura::CloseNow() { | 586 void DesktopNativeWidgetAura::CloseNow() { |
| 585 if (window_) | 587 if (content_window_) |
| 586 desktop_root_window_host_->CloseNow(); | 588 desktop_root_window_host_->CloseNow(); |
| 587 } | 589 } |
| 588 | 590 |
| 589 void DesktopNativeWidgetAura::Show() { | 591 void DesktopNativeWidgetAura::Show() { |
| 590 if (!window_) | 592 if (!content_window_) |
| 591 return; | 593 return; |
| 592 desktop_root_window_host_->AsRootWindowHost()->Show(); | 594 desktop_root_window_host_->AsRootWindowHost()->Show(); |
| 593 window_->Show(); | 595 content_window_->Show(); |
| 594 } | 596 } |
| 595 | 597 |
| 596 void DesktopNativeWidgetAura::Hide() { | 598 void DesktopNativeWidgetAura::Hide() { |
| 597 if (!window_) | 599 if (!content_window_) |
| 598 return; | 600 return; |
| 599 desktop_root_window_host_->AsRootWindowHost()->Hide(); | 601 desktop_root_window_host_->AsRootWindowHost()->Hide(); |
| 600 window_->Hide(); | 602 content_window_->Hide(); |
| 601 } | 603 } |
| 602 | 604 |
| 603 void DesktopNativeWidgetAura::ShowMaximizedWithBounds( | 605 void DesktopNativeWidgetAura::ShowMaximizedWithBounds( |
| 604 const gfx::Rect& restored_bounds) { | 606 const gfx::Rect& restored_bounds) { |
| 605 if (!window_) | 607 if (!content_window_) |
| 606 return; | 608 return; |
| 607 desktop_root_window_host_->ShowMaximizedWithBounds(restored_bounds); | 609 desktop_root_window_host_->ShowMaximizedWithBounds(restored_bounds); |
| 608 window_->Show(); | 610 content_window_->Show(); |
| 609 } | 611 } |
| 610 | 612 |
| 611 void DesktopNativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { | 613 void DesktopNativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { |
| 612 if (!window_) | 614 if (!content_window_) |
| 613 return; | 615 return; |
| 614 desktop_root_window_host_->ShowWindowWithState(state); | 616 desktop_root_window_host_->ShowWindowWithState(state); |
| 615 window_->Show(); | 617 content_window_->Show(); |
| 616 } | 618 } |
| 617 | 619 |
| 618 bool DesktopNativeWidgetAura::IsVisible() const { | 620 bool DesktopNativeWidgetAura::IsVisible() const { |
| 619 return window_ && desktop_root_window_host_->IsVisible(); | 621 return content_window_ && desktop_root_window_host_->IsVisible(); |
| 620 } | 622 } |
| 621 | 623 |
| 622 void DesktopNativeWidgetAura::Activate() { | 624 void DesktopNativeWidgetAura::Activate() { |
| 623 if (window_) | 625 if (content_window_) |
| 624 desktop_root_window_host_->Activate(); | 626 desktop_root_window_host_->Activate(); |
| 625 } | 627 } |
| 626 | 628 |
| 627 void DesktopNativeWidgetAura::Deactivate() { | 629 void DesktopNativeWidgetAura::Deactivate() { |
| 628 if (window_) | 630 if (content_window_) |
| 629 desktop_root_window_host_->Deactivate(); | 631 desktop_root_window_host_->Deactivate(); |
| 630 } | 632 } |
| 631 | 633 |
| 632 bool DesktopNativeWidgetAura::IsActive() const { | 634 bool DesktopNativeWidgetAura::IsActive() const { |
| 633 return window_ && desktop_root_window_host_->IsActive(); | 635 return content_window_ && desktop_root_window_host_->IsActive(); |
| 634 } | 636 } |
| 635 | 637 |
| 636 void DesktopNativeWidgetAura::SetAlwaysOnTop(bool always_on_top) { | 638 void DesktopNativeWidgetAura::SetAlwaysOnTop(bool always_on_top) { |
| 637 if (window_) | 639 if (content_window_) |
| 638 desktop_root_window_host_->SetAlwaysOnTop(always_on_top); | 640 desktop_root_window_host_->SetAlwaysOnTop(always_on_top); |
| 639 } | 641 } |
| 640 | 642 |
| 641 bool DesktopNativeWidgetAura::IsAlwaysOnTop() const { | 643 bool DesktopNativeWidgetAura::IsAlwaysOnTop() const { |
| 642 return window_ && desktop_root_window_host_->IsAlwaysOnTop(); | 644 return content_window_ && desktop_root_window_host_->IsAlwaysOnTop(); |
| 643 } | 645 } |
| 644 | 646 |
| 645 void DesktopNativeWidgetAura::Maximize() { | 647 void DesktopNativeWidgetAura::Maximize() { |
| 646 if (window_) | 648 if (content_window_) |
| 647 desktop_root_window_host_->Maximize(); | 649 desktop_root_window_host_->Maximize(); |
| 648 } | 650 } |
| 649 | 651 |
| 650 void DesktopNativeWidgetAura::Minimize() { | 652 void DesktopNativeWidgetAura::Minimize() { |
| 651 if (window_) | 653 if (content_window_) |
| 652 desktop_root_window_host_->Minimize(); | 654 desktop_root_window_host_->Minimize(); |
| 653 } | 655 } |
| 654 | 656 |
| 655 bool DesktopNativeWidgetAura::IsMaximized() const { | 657 bool DesktopNativeWidgetAura::IsMaximized() const { |
| 656 return window_ && desktop_root_window_host_->IsMaximized(); | 658 return content_window_ && desktop_root_window_host_->IsMaximized(); |
| 657 } | 659 } |
| 658 | 660 |
| 659 bool DesktopNativeWidgetAura::IsMinimized() const { | 661 bool DesktopNativeWidgetAura::IsMinimized() const { |
| 660 return window_ && desktop_root_window_host_->IsMinimized(); | 662 return content_window_ && desktop_root_window_host_->IsMinimized(); |
| 661 } | 663 } |
| 662 | 664 |
| 663 void DesktopNativeWidgetAura::Restore() { | 665 void DesktopNativeWidgetAura::Restore() { |
| 664 if (window_) | 666 if (content_window_) |
| 665 desktop_root_window_host_->Restore(); | 667 desktop_root_window_host_->Restore(); |
| 666 } | 668 } |
| 667 | 669 |
| 668 void DesktopNativeWidgetAura::SetFullscreen(bool fullscreen) { | 670 void DesktopNativeWidgetAura::SetFullscreen(bool fullscreen) { |
| 669 if (window_) | 671 if (content_window_) |
| 670 desktop_root_window_host_->SetFullscreen(fullscreen); | 672 desktop_root_window_host_->SetFullscreen(fullscreen); |
| 671 } | 673 } |
| 672 | 674 |
| 673 bool DesktopNativeWidgetAura::IsFullscreen() const { | 675 bool DesktopNativeWidgetAura::IsFullscreen() const { |
| 674 return window_ && desktop_root_window_host_->IsFullscreen(); | 676 return content_window_ && desktop_root_window_host_->IsFullscreen(); |
| 675 } | 677 } |
| 676 | 678 |
| 677 void DesktopNativeWidgetAura::SetOpacity(unsigned char opacity) { | 679 void DesktopNativeWidgetAura::SetOpacity(unsigned char opacity) { |
| 678 if (window_) | 680 if (content_window_) |
| 679 desktop_root_window_host_->SetOpacity(opacity); | 681 desktop_root_window_host_->SetOpacity(opacity); |
| 680 } | 682 } |
| 681 | 683 |
| 682 void DesktopNativeWidgetAura::SetUseDragFrame(bool use_drag_frame) { | 684 void DesktopNativeWidgetAura::SetUseDragFrame(bool use_drag_frame) { |
| 683 } | 685 } |
| 684 | 686 |
| 685 void DesktopNativeWidgetAura::FlashFrame(bool flash_frame) { | 687 void DesktopNativeWidgetAura::FlashFrame(bool flash_frame) { |
| 686 if (window_) | 688 if (content_window_) |
| 687 desktop_root_window_host_->FlashFrame(flash_frame); | 689 desktop_root_window_host_->FlashFrame(flash_frame); |
| 688 } | 690 } |
| 689 | 691 |
| 690 void DesktopNativeWidgetAura::RunShellDrag( | 692 void DesktopNativeWidgetAura::RunShellDrag( |
| 691 View* view, | 693 View* view, |
| 692 const ui::OSExchangeData& data, | 694 const ui::OSExchangeData& data, |
| 693 const gfx::Point& location, | 695 const gfx::Point& location, |
| 694 int operation, | 696 int operation, |
| 695 ui::DragDropTypes::DragEventSource source) { | 697 ui::DragDropTypes::DragEventSource source) { |
| 696 views::RunShellDrag(window_, data, location, operation, source); | 698 views::RunShellDrag(content_window_, data, location, operation, source); |
| 697 } | 699 } |
| 698 | 700 |
| 699 void DesktopNativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { | 701 void DesktopNativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { |
| 700 if (window_) | 702 if (content_window_) |
| 701 window_->SchedulePaintInRect(rect); | 703 content_window_->SchedulePaintInRect(rect); |
| 702 } | 704 } |
| 703 | 705 |
| 704 void DesktopNativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { | 706 void DesktopNativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { |
| 705 cursor_ = cursor; | 707 cursor_ = cursor; |
| 706 aura::client::CursorClient* cursor_client = | 708 aura::client::CursorClient* cursor_client = |
| 707 aura::client::GetCursorClient(window_->GetRootWindow()); | 709 aura::client::GetCursorClient(root_window_.get()); |
| 708 if (cursor_client) | 710 if (cursor_client) |
| 709 cursor_client->SetCursor(cursor); | 711 cursor_client->SetCursor(cursor); |
| 710 } | 712 } |
| 711 | 713 |
| 712 bool DesktopNativeWidgetAura::IsMouseEventsEnabled() const { | 714 bool DesktopNativeWidgetAura::IsMouseEventsEnabled() const { |
| 713 if (!window_) | 715 if (!content_window_) |
| 714 return false; | 716 return false; |
| 715 aura::client::CursorClient* cursor_client = | 717 aura::client::CursorClient* cursor_client = |
| 716 aura::client::GetCursorClient(window_->GetRootWindow()); | 718 aura::client::GetCursorClient(root_window_.get()); |
| 717 return cursor_client ? cursor_client->IsMouseEventsEnabled() : true; | 719 return cursor_client ? cursor_client->IsMouseEventsEnabled() : true; |
| 718 } | 720 } |
| 719 | 721 |
| 720 void DesktopNativeWidgetAura::ClearNativeFocus() { | 722 void DesktopNativeWidgetAura::ClearNativeFocus() { |
| 721 desktop_root_window_host_->ClearNativeFocus(); | 723 desktop_root_window_host_->ClearNativeFocus(); |
| 722 | 724 |
| 723 if (ShouldActivate()) { | 725 if (ShouldActivate()) { |
| 724 aura::client::GetFocusClient(window_)-> | 726 aura::client::GetFocusClient(content_window_)-> |
| 725 ResetFocusWithinActiveWindow(window_); | 727 ResetFocusWithinActiveWindow(content_window_); |
| 726 } | 728 } |
| 727 } | 729 } |
| 728 | 730 |
| 729 gfx::Rect DesktopNativeWidgetAura::GetWorkAreaBoundsInScreen() const { | 731 gfx::Rect DesktopNativeWidgetAura::GetWorkAreaBoundsInScreen() const { |
| 730 return desktop_root_window_host_ ? | 732 return desktop_root_window_host_ ? |
| 731 desktop_root_window_host_->GetWorkAreaBoundsInScreen() : gfx::Rect(); | 733 desktop_root_window_host_->GetWorkAreaBoundsInScreen() : gfx::Rect(); |
| 732 } | 734 } |
| 733 | 735 |
| 734 void DesktopNativeWidgetAura::SetInactiveRenderingDisabled(bool value) { | 736 void DesktopNativeWidgetAura::SetInactiveRenderingDisabled(bool value) { |
| 735 if (!window_) | 737 if (!content_window_) |
| 736 return; | 738 return; |
| 737 | 739 |
| 738 if (!value) { | 740 if (!value) { |
| 739 active_window_observer_.reset(); | 741 active_window_observer_.reset(); |
| 740 } else { | 742 } else { |
| 741 active_window_observer_.reset( | 743 active_window_observer_.reset( |
| 742 new NativeWidgetAuraWindowObserver(window_, native_widget_delegate_)); | 744 new NativeWidgetAuraWindowObserver(content_window_, |
| 745 native_widget_delegate_)); |
| 743 } | 746 } |
| 744 } | 747 } |
| 745 | 748 |
| 746 Widget::MoveLoopResult DesktopNativeWidgetAura::RunMoveLoop( | 749 Widget::MoveLoopResult DesktopNativeWidgetAura::RunMoveLoop( |
| 747 const gfx::Vector2d& drag_offset, | 750 const gfx::Vector2d& drag_offset, |
| 748 Widget::MoveLoopSource source, | 751 Widget::MoveLoopSource source, |
| 749 Widget::MoveLoopEscapeBehavior escape_behavior) { | 752 Widget::MoveLoopEscapeBehavior escape_behavior) { |
| 750 if (!window_) | 753 if (!content_window_) |
| 751 return Widget::MOVE_LOOP_CANCELED; | 754 return Widget::MOVE_LOOP_CANCELED; |
| 752 return desktop_root_window_host_->RunMoveLoop(drag_offset, source, | 755 return desktop_root_window_host_->RunMoveLoop(drag_offset, source, |
| 753 escape_behavior); | 756 escape_behavior); |
| 754 } | 757 } |
| 755 | 758 |
| 756 void DesktopNativeWidgetAura::EndMoveLoop() { | 759 void DesktopNativeWidgetAura::EndMoveLoop() { |
| 757 if (window_) | 760 if (content_window_) |
| 758 desktop_root_window_host_->EndMoveLoop(); | 761 desktop_root_window_host_->EndMoveLoop(); |
| 759 } | 762 } |
| 760 | 763 |
| 761 void DesktopNativeWidgetAura::SetVisibilityChangedAnimationsEnabled( | 764 void DesktopNativeWidgetAura::SetVisibilityChangedAnimationsEnabled( |
| 762 bool value) { | 765 bool value) { |
| 763 if (window_) | 766 if (content_window_) |
| 764 desktop_root_window_host_->SetVisibilityChangedAnimationsEnabled(value); | 767 desktop_root_window_host_->SetVisibilityChangedAnimationsEnabled(value); |
| 765 } | 768 } |
| 766 | 769 |
| 767 ui::NativeTheme* DesktopNativeWidgetAura::GetNativeTheme() const { | 770 ui::NativeTheme* DesktopNativeWidgetAura::GetNativeTheme() const { |
| 768 return DesktopRootWindowHost::GetNativeTheme(window_); | 771 return DesktopRootWindowHost::GetNativeTheme(content_window_); |
| 769 } | 772 } |
| 770 | 773 |
| 771 void DesktopNativeWidgetAura::OnRootViewLayout() const { | 774 void DesktopNativeWidgetAura::OnRootViewLayout() const { |
| 772 if (window_) | 775 if (content_window_) |
| 773 desktop_root_window_host_->OnRootViewLayout(); | 776 desktop_root_window_host_->OnRootViewLayout(); |
| 774 } | 777 } |
| 775 | 778 |
| 776 //////////////////////////////////////////////////////////////////////////////// | 779 //////////////////////////////////////////////////////////////////////////////// |
| 777 // DesktopNativeWidgetAura, aura::WindowDelegate implementation: | 780 // DesktopNativeWidgetAura, aura::WindowDelegate implementation: |
| 778 | 781 |
| 779 gfx::Size DesktopNativeWidgetAura::GetMinimumSize() const { | 782 gfx::Size DesktopNativeWidgetAura::GetMinimumSize() const { |
| 780 return native_widget_delegate_->GetMinimumSize(); | 783 return native_widget_delegate_->GetMinimumSize(); |
| 781 } | 784 } |
| 782 | 785 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 | 818 |
| 816 void DesktopNativeWidgetAura::OnDeviceScaleFactorChanged( | 819 void DesktopNativeWidgetAura::OnDeviceScaleFactorChanged( |
| 817 float device_scale_factor) { | 820 float device_scale_factor) { |
| 818 } | 821 } |
| 819 | 822 |
| 820 void DesktopNativeWidgetAura::OnWindowDestroying() { | 823 void DesktopNativeWidgetAura::OnWindowDestroying() { |
| 821 // Cleanup happens in OnHostClosed(). | 824 // Cleanup happens in OnHostClosed(). |
| 822 } | 825 } |
| 823 | 826 |
| 824 void DesktopNativeWidgetAura::OnWindowDestroyed() { | 827 void DesktopNativeWidgetAura::OnWindowDestroyed() { |
| 825 // Cleanup happens in OnHostClosed(). We own |window_| (indirectly by way of | 828 // Cleanup happens in OnHostClosed(). We own |content_window_| (indirectly by |
| 826 // |root_window_|) so there should be no need to do any processing here. | 829 // way of |root_window_|) so there should be no need to do any processing |
| 830 // here. |
| 827 } | 831 } |
| 828 | 832 |
| 829 void DesktopNativeWidgetAura::OnWindowTargetVisibilityChanged(bool visible) { | 833 void DesktopNativeWidgetAura::OnWindowTargetVisibilityChanged(bool visible) { |
| 830 } | 834 } |
| 831 | 835 |
| 832 bool DesktopNativeWidgetAura::HasHitTestMask() const { | 836 bool DesktopNativeWidgetAura::HasHitTestMask() const { |
| 833 return native_widget_delegate_->HasHitTestMask(); | 837 return native_widget_delegate_->HasHitTestMask(); |
| 834 } | 838 } |
| 835 | 839 |
| 836 void DesktopNativeWidgetAura::GetHitTestMask(gfx::Path* mask) const { | 840 void DesktopNativeWidgetAura::GetHitTestMask(gfx::Path* mask) const { |
| 837 native_widget_delegate_->GetHitTestMask(mask); | 841 native_widget_delegate_->GetHitTestMask(mask); |
| 838 } | 842 } |
| 839 | 843 |
| 840 void DesktopNativeWidgetAura::DidRecreateLayer(ui::Layer* old_layer, | 844 void DesktopNativeWidgetAura::DidRecreateLayer(ui::Layer* old_layer, |
| 841 ui::Layer* new_layer) {} | 845 ui::Layer* new_layer) {} |
| 842 | 846 |
| 843 //////////////////////////////////////////////////////////////////////////////// | 847 //////////////////////////////////////////////////////////////////////////////// |
| 844 // DesktopNativeWidgetAura, ui::EventHandler implementation: | 848 // DesktopNativeWidgetAura, ui::EventHandler implementation: |
| 845 | 849 |
| 846 void DesktopNativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { | 850 void DesktopNativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { |
| 847 if (event->is_char()) { | 851 if (event->is_char()) { |
| 848 // If a ui::InputMethod object is attached to the root window, character | 852 // If a ui::InputMethod object is attached to the root window, character |
| 849 // events are handled inside the object and are not passed to this function. | 853 // events are handled inside the object and are not passed to this function. |
| 850 // If such object is not attached, character events might be sent (e.g. on | 854 // If such object is not attached, character events might be sent (e.g. on |
| 851 // Windows). In this case, we just skip these. | 855 // Windows). In this case, we just skip these. |
| 852 return; | 856 return; |
| 853 } | 857 } |
| 854 // Renderer may send a key event back to us if the key event wasn't handled, | 858 // Renderer may send a key event back to us if the key event wasn't handled, |
| 855 // and the window may be invisible by that time. | 859 // and the window may be invisible by that time. |
| 856 if (!window_->IsVisible()) | 860 if (!content_window_->IsVisible()) |
| 857 return; | 861 return; |
| 858 | 862 |
| 859 native_widget_delegate_->OnKeyEvent(event); | 863 native_widget_delegate_->OnKeyEvent(event); |
| 860 if (event->handled()) | 864 if (event->handled()) |
| 861 return; | 865 return; |
| 862 | 866 |
| 863 if (GetWidget()->HasFocusManager() && | 867 if (GetWidget()->HasFocusManager() && |
| 864 !GetWidget()->GetFocusManager()->OnKeyEvent(*event)) | 868 !GetWidget()->GetFocusManager()->OnKeyEvent(*event)) |
| 865 event->SetHandled(); | 869 event->SetHandled(); |
| 866 } | 870 } |
| 867 | 871 |
| 868 void DesktopNativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { | 872 void DesktopNativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { |
| 869 DCHECK(window_->IsVisible()); | 873 DCHECK(content_window_->IsVisible()); |
| 870 if (tooltip_manager_.get()) | 874 if (tooltip_manager_.get()) |
| 871 tooltip_manager_->UpdateTooltip(); | 875 tooltip_manager_->UpdateTooltip(); |
| 872 native_widget_delegate_->OnMouseEvent(event); | 876 native_widget_delegate_->OnMouseEvent(event); |
| 873 // WARNING: we may have been deleted. | 877 // WARNING: we may have been deleted. |
| 874 } | 878 } |
| 875 | 879 |
| 876 void DesktopNativeWidgetAura::OnScrollEvent(ui::ScrollEvent* event) { | 880 void DesktopNativeWidgetAura::OnScrollEvent(ui::ScrollEvent* event) { |
| 877 if (event->type() == ui::ET_SCROLL) { | 881 if (event->type() == ui::ET_SCROLL) { |
| 878 native_widget_delegate_->OnScrollEvent(event); | 882 native_widget_delegate_->OnScrollEvent(event); |
| 879 if (event->handled()) | 883 if (event->handled()) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 903 bool DesktopNativeWidgetAura::ShouldActivate() const { | 907 bool DesktopNativeWidgetAura::ShouldActivate() const { |
| 904 return can_activate_ && native_widget_delegate_->CanActivate(); | 908 return can_activate_ && native_widget_delegate_->CanActivate(); |
| 905 } | 909 } |
| 906 | 910 |
| 907 //////////////////////////////////////////////////////////////////////////////// | 911 //////////////////////////////////////////////////////////////////////////////// |
| 908 // DesktopNativeWidgetAura, aura::client::ActivationChangeObserver | 912 // DesktopNativeWidgetAura, aura::client::ActivationChangeObserver |
| 909 // implementation: | 913 // implementation: |
| 910 | 914 |
| 911 void DesktopNativeWidgetAura::OnWindowActivated(aura::Window* gained_active, | 915 void DesktopNativeWidgetAura::OnWindowActivated(aura::Window* gained_active, |
| 912 aura::Window* lost_active) { | 916 aura::Window* lost_active) { |
| 913 DCHECK(window_ == gained_active || window_ == lost_active); | 917 DCHECK(content_window_ == gained_active || content_window_ == lost_active); |
| 914 if ((window_ == gained_active || window_ == lost_active) && | 918 if ((content_window_ == gained_active || content_window_ == lost_active) && |
| 915 IsVisible() && GetWidget()->non_client_view()) { | 919 IsVisible() && GetWidget()->non_client_view()) { |
| 916 GetWidget()->non_client_view()->SchedulePaint(); | 920 GetWidget()->non_client_view()->SchedulePaint(); |
| 917 } | 921 } |
| 918 if (gained_active == window_ && restore_focus_on_activate_) { | 922 if (gained_active == content_window_ && restore_focus_on_activate_) { |
| 919 restore_focus_on_activate_ = false; | 923 restore_focus_on_activate_ = false; |
| 920 GetWidget()->GetFocusManager()->RestoreFocusedView(); | 924 GetWidget()->GetFocusManager()->RestoreFocusedView(); |
| 921 } else if (lost_active == window_ && GetWidget()->HasFocusManager()) { | 925 } else if (lost_active == content_window_ && GetWidget()->HasFocusManager()) { |
| 922 DCHECK(!restore_focus_on_activate_); | 926 DCHECK(!restore_focus_on_activate_); |
| 923 restore_focus_on_activate_ = true; | 927 restore_focus_on_activate_ = true; |
| 924 // Pass in false so that ClearNativeFocus() isn't invoked. | 928 // Pass in false so that ClearNativeFocus() isn't invoked. |
| 925 GetWidget()->GetFocusManager()->StoreFocusedView(false); | 929 GetWidget()->GetFocusManager()->StoreFocusedView(false); |
| 926 } | 930 } |
| 927 } | 931 } |
| 928 | 932 |
| 929 //////////////////////////////////////////////////////////////////////////////// | 933 //////////////////////////////////////////////////////////////////////////////// |
| 930 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: | 934 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: |
| 931 | 935 |
| 932 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, | 936 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, |
| 933 aura::Window* lost_focus) { | 937 aura::Window* lost_focus) { |
| 934 if (window_ == gained_focus) { | 938 if (content_window_ == gained_focus) { |
| 935 desktop_root_window_host_->OnNativeWidgetFocus(); | 939 desktop_root_window_host_->OnNativeWidgetFocus(); |
| 936 native_widget_delegate_->OnNativeFocus(lost_focus); | 940 native_widget_delegate_->OnNativeFocus(lost_focus); |
| 937 | 941 |
| 938 // If focus is moving from a descendant Window to |window_| then native | 942 // If focus is moving from a descendant Window to |content_window_| then |
| 939 // activation hasn't changed. We still need to inform the InputMethod we've | 943 // native activation hasn't changed. We still need to inform the InputMethod |
| 940 // been focused though. | 944 // we've been focused though. |
| 941 InputMethod* input_method = GetWidget()->GetInputMethod(); | 945 InputMethod* input_method = GetWidget()->GetInputMethod(); |
| 942 if (input_method) | 946 if (input_method) |
| 943 input_method->OnFocus(); | 947 input_method->OnFocus(); |
| 944 } else if (window_ == lost_focus) { | 948 } else if (content_window_ == lost_focus) { |
| 945 desktop_root_window_host_->OnNativeWidgetBlur(); | 949 desktop_root_window_host_->OnNativeWidgetBlur(); |
| 946 native_widget_delegate_->OnNativeBlur( | 950 native_widget_delegate_->OnNativeBlur( |
| 947 aura::client::GetFocusClient(window_)->GetFocusedWindow()); | 951 aura::client::GetFocusClient(content_window_)->GetFocusedWindow()); |
| 948 } | 952 } |
| 949 } | 953 } |
| 950 | 954 |
| 951 //////////////////////////////////////////////////////////////////////////////// | 955 //////////////////////////////////////////////////////////////////////////////// |
| 952 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate: | 956 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate: |
| 953 | 957 |
| 954 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { | 958 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { |
| 955 FocusManager* focus_manager = | 959 FocusManager* focus_manager = |
| 956 native_widget_delegate_->AsWidget()->GetFocusManager(); | 960 native_widget_delegate_->AsWidget()->GetFocusManager(); |
| 957 native_widget_delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); | 961 native_widget_delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 const aura::RootWindow* root) { | 1003 const aura::RootWindow* root) { |
| 1000 gfx::Rect new_bounds = gfx::Rect(root->bounds().size()); | 1004 gfx::Rect new_bounds = gfx::Rect(root->bounds().size()); |
| 1001 // TODO(ananta) | 1005 // TODO(ananta) |
| 1002 // This code by default scales the bounds rectangle by 1. | 1006 // This code by default scales the bounds rectangle by 1. |
| 1003 // We could probably get rid of this and similar logic from | 1007 // We could probably get rid of this and similar logic from |
| 1004 // the DesktopNativeWidgetAura::SetBounds function. | 1008 // the DesktopNativeWidgetAura::SetBounds function. |
| 1005 #if defined(OS_WIN) | 1009 #if defined(OS_WIN) |
| 1006 gfx::Size dip_size = gfx::win::ScreenToDIPSize(new_bounds.size()); | 1010 gfx::Size dip_size = gfx::win::ScreenToDIPSize(new_bounds.size()); |
| 1007 new_bounds = gfx::Rect(dip_size); | 1011 new_bounds = gfx::Rect(dip_size); |
| 1008 #endif | 1012 #endif |
| 1009 window_->SetBounds(new_bounds); | 1013 content_window_->SetBounds(new_bounds); |
| 1010 // Can be NULL at start. | 1014 // Can be NULL at start. |
| 1011 if (content_window_container_) | 1015 if (content_window_container_) |
| 1012 content_window_container_->SetBounds(new_bounds); | 1016 content_window_container_->SetBounds(new_bounds); |
| 1013 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); | 1017 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); |
| 1014 } | 1018 } |
| 1015 | 1019 |
| 1016 void DesktopNativeWidgetAura::OnRootWindowHostMoved( | 1020 void DesktopNativeWidgetAura::OnRootWindowHostMoved( |
| 1017 const aura::RootWindow* root, | 1021 const aura::RootWindow* root, |
| 1018 const gfx::Point& new_origin) { | 1022 const gfx::Point& new_origin) { |
| 1019 native_widget_delegate_->OnNativeWidgetMove(); | 1023 native_widget_delegate_->OnNativeWidgetMove(); |
| 1020 } | 1024 } |
| 1021 | 1025 |
| 1022 //////////////////////////////////////////////////////////////////////////////// | 1026 //////////////////////////////////////////////////////////////////////////////// |
| 1023 // DesktopNativeWidgetAura, NativeWidget implementation: | 1027 // DesktopNativeWidgetAura, NativeWidget implementation: |
| 1024 | 1028 |
| 1025 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { | 1029 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { |
| 1026 return this; | 1030 return this; |
| 1027 } | 1031 } |
| 1028 | 1032 |
| 1029 void DesktopNativeWidgetAura::UpdateWindowTransparency() { | 1033 void DesktopNativeWidgetAura::UpdateWindowTransparency() { |
| 1030 window_->SetTransparent(ShouldUseNativeFrame()); | 1034 content_window_->SetTransparent(ShouldUseNativeFrame()); |
| 1031 } | 1035 } |
| 1032 | 1036 |
| 1033 } // namespace views | 1037 } // namespace views |
| OLD | NEW |