Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc

Issue 196063002: Move wm/core to wm namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "ui/aura/client/activation_client.h" 9 #include "ui/aura/client/activation_client.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 236
237 DISALLOW_COPY_AND_ASSIGN(RootWindowDestructionObserver); 237 DISALLOW_COPY_AND_ASSIGN(RootWindowDestructionObserver);
238 }; 238 };
239 239
240 //////////////////////////////////////////////////////////////////////////////// 240 ////////////////////////////////////////////////////////////////////////////////
241 // DesktopNativeWidgetAura, public: 241 // DesktopNativeWidgetAura, public:
242 242
243 int DesktopNativeWidgetAura::cursor_reference_count_ = 0; 243 int DesktopNativeWidgetAura::cursor_reference_count_ = 0;
244 DesktopNativeCursorManager* DesktopNativeWidgetAura::native_cursor_manager_ = 244 DesktopNativeCursorManager* DesktopNativeWidgetAura::native_cursor_manager_ =
245 NULL; 245 NULL;
246 views::corewm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL; 246 wm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL;
247 247
248 DesktopNativeWidgetAura::DesktopNativeWidgetAura( 248 DesktopNativeWidgetAura::DesktopNativeWidgetAura(
249 internal::NativeWidgetDelegate* delegate) 249 internal::NativeWidgetDelegate* delegate)
250 : desktop_window_tree_host_(NULL), 250 : desktop_window_tree_host_(NULL),
251 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 251 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
252 close_widget_factory_(this), 252 close_widget_factory_(this),
253 can_activate_(true), 253 can_activate_(true),
254 content_window_container_(NULL), 254 content_window_container_(NULL),
255 content_window_(new aura::Window(this)), 255 content_window_(new aura::Window(this)),
256 native_widget_delegate_(delegate), 256 native_widget_delegate_(delegate),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 NativeWidgetAura::RegisterNativeWidgetForWindow(this, content_window_); 394 NativeWidgetAura::RegisterNativeWidgetForWindow(this, content_window_);
395 // Animations on TYPE_WINDOW are handled by the OS. Additionally if we animate 395 // Animations on TYPE_WINDOW are handled by the OS. Additionally if we animate
396 // these windows the size of the window gets augmented, effecting restore 396 // these windows the size of the window gets augmented, effecting restore
397 // bounds and maximized windows in bad ways. 397 // bounds and maximized windows in bad ways.
398 if (params.type == Widget::InitParams::TYPE_WINDOW && 398 if (params.type == Widget::InitParams::TYPE_WINDOW &&
399 !params.remove_standard_frame) { 399 !params.remove_standard_frame) {
400 content_window_->SetProperty(aura::client::kAnimationsDisabledKey, true); 400 content_window_->SetProperty(aura::client::kAnimationsDisabledKey, true);
401 } 401 }
402 content_window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); 402 content_window_->SetType(GetAuraWindowTypeForWidgetType(params.type));
403 content_window_->Init(params.layer_type); 403 content_window_->Init(params.layer_type);
404 corewm::SetShadowType(content_window_, corewm::SHADOW_TYPE_NONE); 404 wm::SetShadowType(content_window_, wm::SHADOW_TYPE_NONE);
405 405
406 content_window_container_ = new aura::Window(NULL); 406 content_window_container_ = new aura::Window(NULL);
407 content_window_container_->Init(aura::WINDOW_LAYER_NOT_DRAWN); 407 content_window_container_->Init(aura::WINDOW_LAYER_NOT_DRAWN);
408 content_window_container_->Show(); 408 content_window_container_->Show();
409 content_window_container_->AddChild(content_window_); 409 content_window_container_->AddChild(content_window_);
410 410
411 desktop_window_tree_host_ = params.desktop_window_tree_host ? 411 desktop_window_tree_host_ = params.desktop_window_tree_host ?
412 params.desktop_window_tree_host : 412 params.desktop_window_tree_host :
413 DesktopWindowTreeHost::Create(native_widget_delegate_, this); 413 DesktopWindowTreeHost::Create(native_widget_delegate_, this);
414 host_.reset(desktop_window_tree_host_->AsWindowTreeHost()); 414 host_.reset(desktop_window_tree_host_->AsWindowTreeHost());
415 desktop_window_tree_host_->Init(content_window_, params); 415 desktop_window_tree_host_->Init(content_window_, params);
416 416
417 // Mark this window as Desktop root window. 417 // Mark this window as Desktop root window.
418 host_->window()->SetProperty(views::kDesktopRootWindow, true); 418 host_->window()->SetProperty(views::kDesktopRootWindow, true);
419 419
420 host_->InitHost(); 420 host_->InitHost();
421 host_->window()->AddChild(content_window_container_); 421 host_->window()->AddChild(content_window_container_);
422 host_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this); 422 host_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this);
423 423
424 host_->window()->AddObserver(new RootWindowDestructionObserver(this)); 424 host_->window()->AddObserver(new RootWindowDestructionObserver(this));
425 425
426 // The WindowsModalityController event filter should be at the head of the 426 // The WindowsModalityController event filter should be at the head of the
427 // pre target handlers list. This ensures that it handles input events first 427 // pre target handlers list. This ensures that it handles input events first
428 // when modal windows are at the top of the Zorder. 428 // when modal windows are at the top of the Zorder.
429 if (widget_type_ == Widget::InitParams::TYPE_WINDOW) 429 if (widget_type_ == Widget::InitParams::TYPE_WINDOW)
430 window_modality_controller_.reset( 430 window_modality_controller_.reset(
431 new views::corewm::WindowModalityController(host_->window())); 431 new wm::WindowModalityController(host_->window()));
432 432
433 // |root_window_event_filter_| must be created before 433 // |root_window_event_filter_| must be created before
434 // OnWindowTreeHostCreated() is invoked. 434 // OnWindowTreeHostCreated() is invoked.
435 435
436 // CEF sets focus to the window the user clicks down on. 436 // CEF sets focus to the window the user clicks down on.
437 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- 437 // TODO(beng): see if we can't do this some other way. CEF seems a heavy-
438 // handed way of accomplishing focus. 438 // handed way of accomplishing focus.
439 // No event filter for aura::Env. Create CompoundEvnetFilter per 439 // No event filter for aura::Env. Create CompoundEvnetFilter per
440 // WindowEventDispatcher. 440 // WindowEventDispatcher.
441 root_window_event_filter_ = new corewm::CompoundEventFilter; 441 root_window_event_filter_ = new wm::CompoundEventFilter;
442 // Pass ownership of the filter to the root_window. 442 // Pass ownership of the filter to the root_window.
443 host_->window()->SetEventFilter(root_window_event_filter_); 443 host_->window()->SetEventFilter(root_window_event_filter_);
444 444
445 // The host's dispatcher must be added to |native_cursor_manager_| before 445 // The host's dispatcher must be added to |native_cursor_manager_| before
446 // OnNativeWidgetCreated() is called. 446 // OnNativeWidgetCreated() is called.
447 cursor_reference_count_++; 447 cursor_reference_count_++;
448 if (!native_cursor_manager_) { 448 if (!native_cursor_manager_) {
449 native_cursor_manager_ = new DesktopNativeCursorManager( 449 native_cursor_manager_ = new DesktopNativeCursorManager(
450 DesktopCursorLoaderUpdater::Create()); 450 DesktopCursorLoaderUpdater::Create());
451 } 451 }
452 if (!cursor_manager_) { 452 if (!cursor_manager_) {
453 cursor_manager_ = new views::corewm::CursorManager( 453 cursor_manager_ = new wm::CursorManager(
454 scoped_ptr<corewm::NativeCursorManager>(native_cursor_manager_)); 454 scoped_ptr<wm::NativeCursorManager>(native_cursor_manager_));
455 } 455 }
456 native_cursor_manager_->AddHost(host()); 456 native_cursor_manager_->AddHost(host());
457 aura::client::SetCursorClient(host_->window(), cursor_manager_); 457 aura::client::SetCursorClient(host_->window(), cursor_manager_);
458 458
459 desktop_window_tree_host_->OnNativeWidgetCreated(params); 459 desktop_window_tree_host_->OnNativeWidgetCreated(params);
460 460
461 UpdateWindowTransparency(); 461 UpdateWindowTransparency();
462 462
463 capture_client_.reset(new DesktopCaptureClient(host_->window())); 463 capture_client_.reset(new DesktopCaptureClient(host_->window()));
464 464
465 corewm::FocusController* focus_controller = 465 wm::FocusController* focus_controller =
466 new corewm::FocusController(new DesktopFocusRules(content_window_)); 466 new wm::FocusController(new DesktopFocusRules(content_window_));
467 focus_client_.reset(focus_controller); 467 focus_client_.reset(focus_controller);
468 aura::client::SetFocusClient(host_->window(), focus_controller); 468 aura::client::SetFocusClient(host_->window(), focus_controller);
469 aura::client::SetActivationClient(host_->window(), focus_controller); 469 aura::client::SetActivationClient(host_->window(), focus_controller);
470 host_->window()->AddPreTargetHandler(focus_controller); 470 host_->window()->AddPreTargetHandler(focus_controller);
471 471
472 dispatcher_client_.reset(new DesktopDispatcherClient); 472 dispatcher_client_.reset(new DesktopDispatcherClient);
473 aura::client::SetDispatcherClient(host_->window(), 473 aura::client::SetDispatcherClient(host_->window(),
474 dispatcher_client_.get()); 474 dispatcher_client_.get());
475 475
476 position_client_.reset(new DesktopScreenPositionClient(host_->window())); 476 position_client_.reset(new DesktopScreenPositionClient(host_->window()));
(...skipping 21 matching lines...) Expand all
498 tooltip_manager_.reset(new TooltipManagerAura(GetWidget())); 498 tooltip_manager_.reset(new TooltipManagerAura(GetWidget()));
499 499
500 tooltip_controller_.reset( 500 tooltip_controller_.reset(
501 new corewm::TooltipController( 501 new corewm::TooltipController(
502 desktop_window_tree_host_->CreateTooltip())); 502 desktop_window_tree_host_->CreateTooltip()));
503 aura::client::SetTooltipClient(host_->window(), 503 aura::client::SetTooltipClient(host_->window(),
504 tooltip_controller_.get()); 504 tooltip_controller_.get());
505 host_->window()->AddPreTargetHandler(tooltip_controller_.get()); 505 host_->window()->AddPreTargetHandler(tooltip_controller_.get());
506 506
507 if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) { 507 if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) {
508 visibility_controller_.reset(new views::corewm::VisibilityController); 508 visibility_controller_.reset(new wm::VisibilityController);
509 aura::client::SetVisibilityClient(host_->window(), 509 aura::client::SetVisibilityClient(host_->window(),
510 visibility_controller_.get()); 510 visibility_controller_.get());
511 views::corewm::SetChildWindowVisibilityChangesAnimated(host_->window()); 511 wm::SetChildWindowVisibilityChangesAnimated(host_->window());
512 views::corewm::SetChildWindowVisibilityChangesAnimated( 512 wm::SetChildWindowVisibilityChangesAnimated(
513 content_window_container_); 513 content_window_container_);
514 } 514 }
515 515
516 if (params.type == Widget::InitParams::TYPE_WINDOW) { 516 if (params.type == Widget::InitParams::TYPE_WINDOW) {
517 focus_manager_event_handler_.reset(new FocusManagerEventHandler(this)); 517 focus_manager_event_handler_.reset(new FocusManagerEventHandler(this));
518 host_->window()->AddPreTargetHandler(focus_manager_event_handler_.get()); 518 host_->window()->AddPreTargetHandler(focus_manager_event_handler_.get());
519 } 519 }
520 520
521 event_client_.reset(new DesktopEventClient); 521 event_client_.reset(new DesktopEventClient);
522 aura::client::SetEventClient(host_->window(), event_client_.get()); 522 aura::client::SetEventClient(host_->window(), event_client_.get());
523 523
524 aura::client::GetFocusClient(content_window_)->FocusWindow(content_window_); 524 aura::client::GetFocusClient(content_window_)->FocusWindow(content_window_);
525 525
526 aura::client::SetActivationDelegate(content_window_, this); 526 aura::client::SetActivationDelegate(content_window_, this);
527 527
528 shadow_controller_.reset(new corewm::ShadowController( 528 shadow_controller_.reset(new wm::ShadowController(
529 aura::client::GetActivationClient(host_->window()))); 529 aura::client::GetActivationClient(host_->window())));
530 530
531 content_window_->SetProperty(aura::client::kCanMaximizeKey, 531 content_window_->SetProperty(aura::client::kCanMaximizeKey,
532 GetWidget()->widget_delegate()->CanMaximize()); 532 GetWidget()->widget_delegate()->CanMaximize());
533 content_window_->SetProperty(aura::client::kCanResizeKey, 533 content_window_->SetProperty(aura::client::kCanResizeKey,
534 GetWidget()->widget_delegate()->CanResize()); 534 GetWidget()->widget_delegate()->CanResize());
535 535
536 window_reorderer_.reset(new WindowReorderer(content_window_, 536 window_reorderer_.reset(new WindowReorderer(content_window_,
537 GetWidget()->GetRootView())); 537 GetWidget()->GetRootView()));
538 } 538 }
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 //////////////////////////////////////////////////////////////////////////////// 1166 ////////////////////////////////////////////////////////////////////////////////
1167 // DesktopNativeWidgetAura, NativeWidget implementation: 1167 // DesktopNativeWidgetAura, NativeWidget implementation:
1168 1168
1169 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { 1169 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() {
1170 return this; 1170 return this;
1171 } 1171 }
1172 1172
1173 void DesktopNativeWidgetAura::InstallInputMethodEventFilter() { 1173 void DesktopNativeWidgetAura::InstallInputMethodEventFilter() {
1174 DCHECK(!input_method_event_filter_.get()); 1174 DCHECK(!input_method_event_filter_.get());
1175 1175
1176 input_method_event_filter_.reset(new corewm::InputMethodEventFilter( 1176 input_method_event_filter_.reset(new wm::InputMethodEventFilter(
1177 host_->GetAcceleratedWidget())); 1177 host_->GetAcceleratedWidget()));
1178 input_method_event_filter_->SetInputMethodPropertyInRootWindow( 1178 input_method_event_filter_->SetInputMethodPropertyInRootWindow(
1179 host_->window()); 1179 host_->window());
1180 root_window_event_filter_->AddHandler(input_method_event_filter_.get()); 1180 root_window_event_filter_->AddHandler(input_method_event_filter_.get());
1181 } 1181 }
1182 1182
1183 void DesktopNativeWidgetAura::UpdateWindowTransparency() { 1183 void DesktopNativeWidgetAura::UpdateWindowTransparency() {
1184 content_window_->SetTransparent( 1184 content_window_->SetTransparent(
1185 desktop_window_tree_host_->ShouldWindowContentsBeTransparent()); 1185 desktop_window_tree_host_->ShouldWindowContentsBeTransparent());
1186 } 1186 }
1187 1187
1188 void DesktopNativeWidgetAura::RootWindowDestroyed() { 1188 void DesktopNativeWidgetAura::RootWindowDestroyed() {
1189 cursor_reference_count_--; 1189 cursor_reference_count_--;
1190 if (cursor_reference_count_ == 0) { 1190 if (cursor_reference_count_ == 0) {
1191 // We are the last DesktopNativeWidgetAura instance, and we are responsible 1191 // We are the last DesktopNativeWidgetAura instance, and we are responsible
1192 // for cleaning up |cursor_manager_|. 1192 // for cleaning up |cursor_manager_|.
1193 delete cursor_manager_; 1193 delete cursor_manager_;
1194 native_cursor_manager_ = NULL; 1194 native_cursor_manager_ = NULL;
1195 cursor_manager_ = NULL; 1195 cursor_manager_ = NULL;
1196 } 1196 }
1197 } 1197 }
1198 1198
1199 } // namespace views 1199 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura.h ('k') | ui/views/widget/desktop_aura/desktop_window_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698