diff options
21 files changed, 205 insertions, 531 deletions
diff --git a/chrome/browser/ui/aura/tabs/dock_info_aurax11.cc b/chrome/browser/ui/aura/tabs/dock_info_aurax11.cc index 9247821..6f67476 100644 --- a/chrome/browser/ui/aura/tabs/dock_info_aurax11.cc +++ b/chrome/browser/ui/aura/tabs/dock_info_aurax11.cc @@ -7,7 +7,7 @@ #include "ui/aura/root_window.h" #include "ui/aura/window.h" #include "ui/base/x/x11_util.h" -#include "ui/views/widget/desktop_native_widget_helper_aura.h" +#include "ui/views/widget/desktop_root_window_host_linux.h" #if !defined(USE_ASH) @@ -187,17 +187,7 @@ gfx::NativeView DockInfo::GetLocalProcessWindowAtPoint( // is. XID xid = LocalProcessWindowFinder::GetProcessWindowAtPoint(screen_point, ignore); - aura::RootWindow* root_window = - aura::RootWindow::GetForAcceleratedWidget(xid); - - if (!root_window) - return NULL; - - // We now have the aura::RootWindow, but most of views isn't interested in - // that; instead it wants the aura::Window that is contained by the - // RootWindow. - return views::DesktopNativeWidgetHelperAura::GetViewsWindowForRootWindow( - root_window); + return views::DesktopRootWindowHostLinux::GetContentWindowForXID(xid); } bool DockInfo::GetWindowBounds(gfx::Rect* bounds) const { diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc index b07cfe8..26bba0f 100644 --- a/chrome/browser/ui/views/chrome_views_delegate.cc +++ b/chrome/browser/ui/views/chrome_views_delegate.cc @@ -29,10 +29,6 @@ #include "ui/views/widget/desktop_native_widget_aura.h" #endif -#if defined(USE_AURA) -#include "ui/views/widget/desktop_native_widget_helper_aura.h" -#endif - #if defined(USE_ASH) #include "ash/shell.h" #include "chrome/browser/ui/ash/ash_init.h" @@ -170,18 +166,6 @@ int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) { return chrome::DispositionFromEventFlags(event_flags); } -#if defined(USE_AURA) -views::NativeWidgetHelperAura* ChromeViewsDelegate::CreateNativeWidgetHelper( - views::NativeWidgetAura* native_widget) { -#if !defined(OS_CHROMEOS) && !defined(OS_WIN) - // TODO(erg): get rid of this, it's interfering with desktop-aura. - return new views::DesktopNativeWidgetHelperAura(native_widget); -#else - return NULL; -#endif -} -#endif - content::WebContents* ChromeViewsDelegate::CreateWebContents( content::BrowserContext* browser_context, content::SiteInstance* site_instance) { @@ -195,7 +179,7 @@ views::NativeWidget* ChromeViewsDelegate::CreateNativeWidget( #if defined(USE_AURA) && !defined(OS_CHROMEOS) if (parent && type != views::Widget::InitParams::TYPE_MENU) return new views::NativeWidgetAura(delegate); - if (parent && chrome::GetHostDesktopTypeForNativeView(parent) == + if (chrome::GetHostDesktopTypeForNativeView(parent) == chrome::HOST_DESKTOP_TYPE_NATIVE) return new views::DesktopNativeWidgetAura(delegate); #endif diff --git a/chrome/browser/ui/views/chrome_views_delegate.h b/chrome/browser/ui/views/chrome_views_delegate.h index 27682d0..fc33836 100644 --- a/chrome/browser/ui/views/chrome_views_delegate.h +++ b/chrome/browser/ui/views/chrome_views_delegate.h @@ -42,10 +42,6 @@ class ChromeViewsDelegate : public views::ViewsDelegate { virtual void AddRef() OVERRIDE; virtual void ReleaseRef() OVERRIDE; virtual int GetDispositionForEvent(int event_flags) OVERRIDE; -#if defined(USE_AURA) - virtual views::NativeWidgetHelperAura* CreateNativeWidgetHelper( - views::NativeWidgetAura* native_widget) OVERRIDE; -#endif virtual content::WebContents* CreateWebContents( content::BrowserContext* browser_context, content::SiteInstance* site_instance) OVERRIDE; diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 0a458ad..a4c7e02 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2226,6 +2226,8 @@ '../tools/json_schema_compiler/test/idl_schemas_unittest.cc', '../tools/json_schema_compiler/test/objects_unittest.cc', '../tools/json_schema_compiler/test/simple_api_unittest.cc', + '../ui/views/test/desktop_test_views_delegate.cc', + '../ui/views/test/desktop_test_views_delegate.h', '../ui/views/test/test_views_delegate.cc', '../ui/views/test/test_views_delegate.h', '../ui/views/test/views_test_base.cc', diff --git a/content/content_shell.gypi b/content/content_shell.gypi index 637986e..983cb3b 100644 --- a/content/content_shell.gypi +++ b/content/content_shell.gypi @@ -97,6 +97,8 @@ 'shell/shell_resource_context.h', 'shell/shell_resource_dispatcher_host_delegate.cc', 'shell/shell_resource_dispatcher_host_delegate.h', + 'shell/shell_stacking_client_chromeos.cc', + 'shell/shell_stacking_client_chromeos.h', 'shell/shell_switches.cc', 'shell/shell_switches.h', 'shell/shell_url_request_context_getter.cc', diff --git a/content/shell/shell_aura.cc b/content/shell/shell_aura.cc index 956bc7f..f88d37f2 100644 --- a/content/shell/shell_aura.cc +++ b/content/shell/shell_aura.cc @@ -7,7 +7,6 @@ #include "base/command_line.h" #include "base/utf_string_conversions.h" #include "ui/aura/desktop/desktop_screen.h" -#include "ui/aura/desktop/desktop_stacking_client.h" #include "ui/aura/display_manager.h" #include "ui/aura/env.h" #include "ui/aura/root_window.h" @@ -25,18 +24,19 @@ #include "ui/views/layout/fill_layout.h" #include "ui/views/layout/grid_layout.h" #include "ui/views/view.h" -#include "ui/views/test/test_views_delegate.h" -#include "ui/views/widget/desktop_native_widget_aura.h" -#include "ui/views/widget/desktop_native_widget_helper_aura.h" +#include "ui/views/test/desktop_test_views_delegate.h" #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" #if defined(OS_CHROMEOS) #include "chromeos/dbus/dbus_thread_manager.h" +#include "content/shell/shell_stacking_client_chromeos.h" +#else +#include "ui/aura/desktop/desktop_stacking_client.h" #endif // ViewDelegate implementation for aura content shell -class ShellViewsDelegateAura : public views::TestViewsDelegate { +class ShellViewsDelegateAura : public views::DesktopTestViewsDelegate { public: ShellViewsDelegateAura() : use_transparent_windows_(false) { } @@ -53,10 +53,6 @@ class ShellViewsDelegateAura : public views::TestViewsDelegate { virtual bool UseTransparentWindows() const OVERRIDE { return use_transparent_windows_; } - virtual views::NativeWidgetHelperAura* CreateNativeWidgetHelper( - views::NativeWidgetAura* native_widget) OVERRIDE { - return new views::DesktopNativeWidgetHelperAura(native_widget); - } private: bool use_transparent_windows_; @@ -287,20 +283,24 @@ void Shell::PlatformInitialize() { chromeos::DBusThreadManager::Initialize(); #endif aura::Env::GetInstance()->SetDisplayManager(new aura::SingleDisplayManager); +#if defined(OS_CHROMEOS) + stacking_client_ = new content::ShellStackingClientChromeos(); +#else stacking_client_ = new aura::DesktopStackingClient(); +#endif gfx::Screen::SetScreenInstance( gfx::SCREEN_TYPE_NATIVE, aura::CreateDesktopScreen()); views_delegate_ = new ShellViewsDelegateAura(); } void Shell::PlatformExit() { -#if defined(OS_CHROMEOS) - chromeos::DBusThreadManager::Shutdown(); -#endif if (stacking_client_) delete stacking_client_; if (views_delegate_) delete views_delegate_; +#if defined(OS_CHROMEOS) + chromeos::DBusThreadManager::Shutdown(); +#endif aura::Env::DeleteInstance(); } diff --git a/content/shell/shell_stacking_client_chromeos.cc b/content/shell/shell_stacking_client_chromeos.cc new file mode 100644 index 0000000..dddb6b5 --- /dev/null +++ b/content/shell/shell_stacking_client_chromeos.cc @@ -0,0 +1,56 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/shell/shell_stacking_client_chromeos.h" + +#include "ui/aura/focus_manager.h" +#include "ui/aura/root_window.h" +#include "ui/aura/shared/compound_event_filter.h" +#include "ui/aura/shared/input_method_event_filter.h" +#include "ui/aura/shared/root_window_capture_client.h" +#include "ui/aura/test/test_activation_client.h" + +namespace content { + +ShellStackingClientChromeos::ShellStackingClientChromeos() { + aura::client::SetStackingClient(this); +} + +ShellStackingClientChromeos::~ShellStackingClientChromeos() { + if (root_window_.get()) + root_window_event_filter_->RemoveFilter(input_method_filter_.get()); + + aura::client::SetStackingClient(NULL); +} + +aura::Window* ShellStackingClientChromeos::GetDefaultParent( + aura::Window* window, + const gfx::Rect& bounds) { + if (!root_window_.get()) { + aura::FocusManager* focus_manager = new aura::FocusManager; + + root_window_.reset(new aura::RootWindow( + aura::RootWindow::CreateParams(gfx::Rect(100, 100)))); + root_window_->Init(); + root_window_->set_focus_manager(focus_manager); + + root_window_event_filter_ = new aura::shared::CompoundEventFilter; + // Pass ownership of the filter to the root_window. + root_window_->SetEventFilter(root_window_event_filter_); + + input_method_filter_.reset(new aura::shared::InputMethodEventFilter()); + input_method_filter_->SetInputMethodPropertyInRootWindow( + root_window_.get()); + root_window_event_filter_->AddFilter(input_method_filter_.get()); + + test_activation_client_.reset( + new aura::test::TestActivationClient(root_window_.get())); + + capture_client_.reset( + new aura::shared::RootWindowCaptureClient(root_window_.get())); + } + return root_window_.get(); +} + +} // namespace content diff --git a/content/shell/shell_stacking_client_chromeos.h b/content/shell/shell_stacking_client_chromeos.h new file mode 100644 index 0000000..4a50c2b --- /dev/null +++ b/content/shell/shell_stacking_client_chromeos.h @@ -0,0 +1,58 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_SHELL_SHELL_STACKING_CLIENT_CHROMEOS_H_ +#define CONTENT_SHELL_SHELL_STACKING_CLIENT_CHROMEOS_H_ + +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "ui/aura/client/stacking_client.h" + +namespace aura { +class RootWindow; +class Window; +namespace shared { +class CompoundEventFilter; +class InputMethodEventFilter; +class RootWindowCaptureClient; +} +namespace test { +class TestActivationClient; +} +} + +namespace gfx { +class Rect; +} + +namespace content { + +// Creates a minimal environment for running the shell. We can't pull in all of +// ash here, but we can create attach several of the same things we'd find in +// the ash parts of the code. +class ShellStackingClientChromeos : public aura::client::StackingClient { + public: + ShellStackingClientChromeos(); + virtual ~ShellStackingClientChromeos(); + + // Overridden from client::StackingClient: + virtual aura::Window* GetDefaultParent(aura::Window* window, + const gfx::Rect& bounds) OVERRIDE; + + private: + scoped_ptr<aura::RootWindow> root_window_; + + // Owned by RootWindow + aura::shared::CompoundEventFilter* root_window_event_filter_; + + scoped_ptr<aura::shared::RootWindowCaptureClient> capture_client_; + scoped_ptr<aura::shared::InputMethodEventFilter> input_method_filter_; + scoped_ptr<aura::test::TestActivationClient> test_activation_client_; + + DISALLOW_COPY_AND_ASSIGN(ShellStackingClientChromeos); +}; + +} // namespace content; + +#endif // CONTENT_SHELL_SHELL_STACKING_CLIENT_CHROMEOS_H_ diff --git a/ui/views/examples/content_client/examples_browser_main_parts.cc b/ui/views/examples/content_client/examples_browser_main_parts.cc index 3c0b260..c31e999 100644 --- a/ui/views/examples/content_client/examples_browser_main_parts.cc +++ b/ui/views/examples/content_client/examples_browser_main_parts.cc @@ -16,7 +16,7 @@ #include "googleurl/src/gurl.h" #include "ui/views/examples/examples_window_with_content.h" #include "ui/views/focus/accelerator_handler.h" -#include "ui/views/test/test_views_delegate.h" +#include "ui/views/test/desktop_test_views_delegate.h" #if defined(USE_AURA) #include "ui/aura/desktop/desktop_screen.h" @@ -24,27 +24,12 @@ #include "ui/aura/env.h" #include "ui/aura/single_display_manager.h" #include "ui/gfx/screen.h" -#include "ui/views/widget/desktop_native_widget_helper_aura.h" #include "ui/views/widget/native_widget_aura.h" #endif namespace views { namespace examples { -namespace { - -class ExamplesViewsDelegate : public TestViewsDelegate { - public: -#if defined(USE_AURA) - virtual NativeWidgetHelperAura* CreateNativeWidgetHelper( - NativeWidgetAura* native_widget) OVERRIDE { - return new DesktopNativeWidgetHelperAura(native_widget); - } -#endif -}; - -} // namespace - ExamplesBrowserMainParts::ExamplesBrowserMainParts( const content::MainFunctionParams& parameters) { } @@ -61,7 +46,7 @@ void ExamplesBrowserMainParts::PreMainMessageLoopRun() { gfx::Screen::SetScreenInstance( gfx::SCREEN_TYPE_NATIVE, aura::CreateDesktopScreen()); #endif - views_delegate_.reset(new ExamplesViewsDelegate); + views_delegate_.reset(new DesktopTestViewsDelegate); ShowExamplesWindowWithContent(QUIT_ON_CLOSE, browser_context_.get()); } diff --git a/ui/views/test/desktop_test_views_delegate.cc b/ui/views/test/desktop_test_views_delegate.cc new file mode 100644 index 0000000..d70d622 --- /dev/null +++ b/ui/views/test/desktop_test_views_delegate.cc @@ -0,0 +1,31 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/views/test/desktop_test_views_delegate.h" + +#include "ui/views/widget/desktop_native_widget_aura.h" +#include "ui/views/widget/native_widget_aura.h" + +namespace views { + +DesktopTestViewsDelegate::DesktopTestViewsDelegate() {} + +DesktopTestViewsDelegate::~DesktopTestViewsDelegate() {} + +NativeWidget* DesktopTestViewsDelegate::CreateNativeWidget( + Widget::InitParams::Type type, + internal::NativeWidgetDelegate* delegate, + gfx::NativeView parent) { +#if defined(USE_AURA) && !defined(OS_CHROMEOS) + if (parent && type != views::Widget::InitParams::TYPE_MENU) + return new views::NativeWidgetAura(delegate); + + if (!parent) + return new views::DesktopNativeWidgetAura(delegate); +#endif + + return NULL; +} + +} // namespace views diff --git a/ui/views/test/desktop_test_views_delegate.h b/ui/views/test/desktop_test_views_delegate.h new file mode 100644 index 0000000..58dc829 --- /dev/null +++ b/ui/views/test/desktop_test_views_delegate.h @@ -0,0 +1,32 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_TEST_DESKTOP_TEST_VIEWS_DELEGATE_H_ +#define UI_VIEWS_TEST_DESKTOP_TEST_VIEWS_DELEGATE_H_ + +#include "ui/views/test/test_views_delegate.h" + +namespace views { + +// Most aura test code is written assuming a single RootWindow view, however, +// at higher levels like content_browsertests and +// views_examples_with_content_exe, we must use the Desktop variants. +class DesktopTestViewsDelegate : public TestViewsDelegate { + public: + DesktopTestViewsDelegate(); + virtual ~DesktopTestViewsDelegate(); + + // Overridden from ViewsDelegate: + virtual NativeWidget* CreateNativeWidget( + Widget::InitParams::Type type, + internal::NativeWidgetDelegate* delegate, + gfx::NativeView parent) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(DesktopTestViewsDelegate); +}; + +} // namespace views + +#endif diff --git a/ui/views/test/test_views_delegate.cc b/ui/views/test/test_views_delegate.cc index e39258ba..d1c8bc6 100644 --- a/ui/views/test/test_views_delegate.cc +++ b/ui/views/test/test_views_delegate.cc @@ -9,7 +9,7 @@ #include "content/public/test/web_contents_tester.h" #if defined(USE_AURA) && !defined(OS_CHROMEOS) -#include "ui/gfx/screen.h" +#include "ui/views/widget/native_widget_aura.h" #include "ui/views/widget/desktop_native_widget_aura.h" #endif @@ -55,13 +55,6 @@ int TestViewsDelegate::GetDispositionForEvent(int event_flags) { return 0; } -#if defined(USE_AURA) -views::NativeWidgetHelperAura* TestViewsDelegate::CreateNativeWidgetHelper( - views::NativeWidgetAura* native_widget) { - return NULL; -} -#endif - content::WebContents* TestViewsDelegate::CreateWebContents( content::BrowserContext* browser_context, content::SiteInstance* site_instance) { diff --git a/ui/views/test/test_views_delegate.h b/ui/views/test/test_views_delegate.h index 449ea8a..31076eb 100644 --- a/ui/views/test/test_views_delegate.h +++ b/ui/views/test/test_views_delegate.h @@ -56,10 +56,6 @@ class TestViewsDelegate : public ViewsDelegate { virtual void AddRef() OVERRIDE {} virtual void ReleaseRef() OVERRIDE {} virtual int GetDispositionForEvent(int event_flags) OVERRIDE; -#if defined(USE_AURA) - virtual views::NativeWidgetHelperAura* CreateNativeWidgetHelper( - views::NativeWidgetAura* native_widget) OVERRIDE; -#endif virtual content::WebContents* CreateWebContents( content::BrowserContext* browser_context, content::SiteInstance* site_instance) OVERRIDE; diff --git a/ui/views/views.gyp b/ui/views/views.gyp index dbff51b..95466b5 100644 --- a/ui/views/views.gyp +++ b/ui/views/views.gyp @@ -318,8 +318,6 @@ 'widget/desktop_layout_manager.h', 'widget/desktop_native_widget_aura.cc', 'widget/desktop_native_widget_aura.h', - 'widget/desktop_native_widget_helper_aura.cc', - 'widget/desktop_native_widget_helper_aura.h', 'widget/desktop_root_window_host.h', 'widget/desktop_root_window_host_linux.cc', 'widget/desktop_root_window_host_linux.h', @@ -347,7 +345,6 @@ 'widget/native_widget_aura_window_observer.cc', 'widget/native_widget_aura_window_observer.h', 'widget/native_widget_delegate.h', - 'widget/native_widget_helper_aura.h', 'widget/native_widget_private.h', 'widget/native_widget_win.cc', 'widget/native_widget_win.h', @@ -447,10 +444,6 @@ ['chromeos==1', { 'sources/': [ ['exclude', '/desktop_[^/]*\\.cc$'], - ['include', 'widget/desktop_native_widget_helper_aura.cc'], - ['include', 'widget/desktop_native_widget_helper_aura.h'], - ['include', 'widget/desktop_screen_position_client.cc'], - ['include', 'widget/desktop_screen_position_client.h'], ], }], ['use_aura==0 and OS=="win"', { @@ -520,6 +513,8 @@ '..', ], 'sources': [ + 'test/desktop_test_views_delegate.cc', + 'test/desktop_test_views_delegate.h', 'test/test_views_delegate.cc', 'test/test_views_delegate.h', 'test/views_test_base.cc', @@ -840,6 +835,7 @@ '../ui.gyp:ui_resources', 'views', 'views_examples_with_content_lib', + 'views_test_support' ], 'include_dirs': [ '../..', @@ -853,8 +849,6 @@ 'examples/content_client/examples_main_delegate.cc', 'examples/content_client/examples_main_delegate.h', 'examples/examples_main.cc', - 'test/test_views_delegate.cc', - 'test/test_views_delegate.h', ], 'conditions': [ ['OS=="win"', { diff --git a/ui/views/views_delegate.h b/ui/views/views_delegate.h index c49bf9b..1a726ad 100644 --- a/ui/views/views_delegate.h +++ b/ui/views/views_delegate.h @@ -34,10 +34,6 @@ class NativeWidget; class NonClientFrameView; class View; class Widget; -#if defined(USE_AURA) -class NativeWidgetAura; -class NativeWidgetHelperAura; -#endif namespace internal { class NativeWidgetDelegate; } @@ -105,13 +101,6 @@ class VIEWS_EXPORT ViewsDelegate { // Converts ui::Event::flags to a WindowOpenDisposition. virtual int GetDispositionForEvent(int event_flags) = 0; -#if defined(USE_AURA) - // Creates an object that implements desktop integration behavior. Returned - // object is owned by the NativeWidgetAura passed in. May return NULL. - virtual NativeWidgetHelperAura* CreateNativeWidgetHelper( - NativeWidgetAura* native_widget) = 0; -#endif - // Creates a web contents. This will return NULL unless overriden. virtual content::WebContents* CreateWebContents( content::BrowserContext* browser_context, diff --git a/ui/views/widget/desktop_native_widget_helper_aura.cc b/ui/views/widget/desktop_native_widget_helper_aura.cc deleted file mode 100644 index 3eba111..0000000 --- a/ui/views/widget/desktop_native_widget_helper_aura.cc +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/views/widget/desktop_native_widget_helper_aura.h" - -#include "ui/aura/client/dispatcher_client.h" -#include "ui/aura/desktop/desktop_activation_client.h" -#include "ui/aura/desktop/desktop_cursor_client.h" -#include "ui/aura/desktop/desktop_dispatcher_client.h" -#include "ui/aura/focus_manager.h" -#include "ui/aura/root_window.h" -#include "ui/aura/shared/compound_event_filter.h" -#include "ui/aura/shared/input_method_event_filter.h" -#include "ui/aura/shared/root_window_capture_client.h" -#include "ui/aura/window_property.h" -#include "ui/views/widget/desktop_screen_position_client.h" -#include "ui/views/widget/native_widget_aura.h" - -#if defined(OS_WIN) -#include "ui/base/win/hwnd_subclass.h" -#include "ui/views/widget/widget_message_filter.h" -#elif defined(USE_X11) -#include "ui/base/x/x11_util.h" -#include "ui/views/widget/x11_desktop_handler.h" -#include "ui/views/widget/x11_desktop_window_move_client.h" -#include "ui/views/widget/x11_window_event_filter.h" -#endif - -namespace views { - -DEFINE_WINDOW_PROPERTY_KEY( - aura::Window*, kViewsWindowForRootWindow, NULL); - -DesktopNativeWidgetHelperAura::DesktopNativeWidgetHelperAura( - NativeWidgetAura* widget) - : widget_(widget), - window_(NULL), - root_window_event_filter_(NULL), - is_embedded_window_(false) { -} - -DesktopNativeWidgetHelperAura::~DesktopNativeWidgetHelperAura() { - if (window_) - window_->RemoveObserver(this); - - if (root_window_event_filter_) { -#if defined(USE_X11) - root_window_event_filter_->RemoveFilter(x11_window_move_client_.get()); - root_window_event_filter_->RemoveFilter(x11_window_event_filter_.get()); -#endif - - root_window_event_filter_->RemoveFilter(input_method_filter_.get()); - } -} - -// static -aura::Window* DesktopNativeWidgetHelperAura::GetViewsWindowForRootWindow( - aura::RootWindow* root) { - return root ? root->GetProperty(kViewsWindowForRootWindow) : NULL; -} - -void DesktopNativeWidgetHelperAura::PreInitialize( - aura::Window* window, - const Widget::InitParams& params) { -#if !defined(OS_WIN) - // We don't want the status bubble or the omnibox to get their own root - // window on the desktop; on Linux - // - // TODO(erg): This doesn't map perfectly to what I want to do. TYPE_POPUP is - // used for lots of stuff, like dragged tabs, and I only want this to trigger - // for the status bubble and the omnibox. - if (params.type == Widget::InitParams::TYPE_POPUP || - params.type == Widget::InitParams::TYPE_BUBBLE) { - is_embedded_window_ = true; - return; - } else if (params.type == Widget::InitParams::TYPE_CONTROL) { - return; - } -#endif - - gfx::Rect bounds = params.bounds; - if (bounds.IsEmpty()) { - // We must pass some non-zero value when we initialize a RootWindow. This - // will probably be SetBounds()ed soon. - bounds.set_size(gfx::Size(100, 100)); - } - - aura::FocusManager* focus_manager = NULL; - aura::DesktopActivationClient* activation_client = NULL; -#if defined(USE_X11) - focus_manager = X11DesktopHandler::get()->get_focus_manager(); - activation_client = X11DesktopHandler::get()->get_activation_client(); -#else - // TODO(ben): This is almost certainly wrong; I suspect that the windows - // build will need a singleton like above. - focus_manager = new aura::FocusManager; - activation_client = new aura::DesktopActivationClient(focus_manager); -#endif - - root_window_.reset( - new aura::RootWindow(aura::RootWindow::CreateParams(bounds))); - root_window_->SetProperty(kViewsWindowForRootWindow, window); - root_window_->Init(); - root_window_->set_focus_manager(focus_manager); - - // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow. - root_window_event_filter_ = new aura::shared::CompoundEventFilter; - // Pass ownership of the filter to the root_window. - root_window_->SetEventFilter(root_window_event_filter_); - - input_method_filter_.reset(new aura::shared::InputMethodEventFilter()); - input_method_filter_->SetInputMethodPropertyInRootWindow(root_window_.get()); - root_window_event_filter_->AddFilter(input_method_filter_.get()); - - capture_client_.reset( - new aura::shared::RootWindowCaptureClient(root_window_.get())); - -#if defined(USE_X11) - x11_window_event_filter_.reset( - new X11WindowEventFilter(root_window_.get(), activation_client)); - x11_window_event_filter_->SetUseHostWindowBorders(false); - root_window_event_filter_->AddFilter(x11_window_event_filter_.get()); - - if (params.type == Widget::InitParams::TYPE_MENU) { - ::Window window = root_window_->GetAcceleratedWidget(); - XSetWindowAttributes attributes; - memset(&attributes, 0, sizeof(attributes)); - attributes.override_redirect = True; - XChangeWindowAttributes(ui::GetXDisplay(), window, CWOverrideRedirect, - &attributes); - } -#endif - - root_window_->AddRootWindowObserver(this); - - window_ = window; - window_->AddObserver(this); - - aura::client::SetActivationClient(root_window_.get(), activation_client); - aura::client::SetDispatcherClient(root_window_.get(), - new aura::DesktopDispatcherClient); -#if defined(USE_X11) - // TODO(ben): A window implementation of this will need to be written. - x11_window_move_client_.reset(new X11DesktopWindowMoveClient); - root_window_event_filter_->AddFilter(x11_window_move_client_.get()); - aura::client::SetWindowMoveClient(root_window_.get(), - x11_window_move_client_.get()); -#endif - -#if !defined(OS_WIN) // Windows does this in DesktopRootWindowHostWin. - cursor_client_.reset(new aura::DesktopCursorClient(root_window_.get())); - aura::client::SetCursorClient(root_window_.get(), cursor_client_.get()); - - position_client_.reset(new DesktopScreenPositionClient()); - aura::client::SetScreenPositionClient(root_window_.get(), - position_client_.get()); -#endif -} - -void DesktopNativeWidgetHelperAura::PostInitialize() { -#if defined(OS_WIN) - DCHECK(root_window_->GetAcceleratedWidget()); - hwnd_message_filter_.reset(new WidgetMessageFilter(root_window_.get(), - widget_->GetWidget())); - ui::HWNDSubclass::AddFilterToTarget(root_window_->GetAcceleratedWidget(), - hwnd_message_filter_.get()); -#endif -} - -aura::RootWindow* DesktopNativeWidgetHelperAura::GetRootWindow() { - return root_window_.get(); -} - -void DesktopNativeWidgetHelperAura::OnWindowDestroying(aura::Window* window) { - window_->RemoveObserver(this); - window_ = NULL; -} - -gfx::Rect DesktopNativeWidgetHelperAura::ModifyAndSetBounds( - const gfx::Rect& bounds) { - gfx::Rect out_bounds = bounds; - if (root_window_.get() && !out_bounds.IsEmpty()) { - // TODO(scottmg): This avoids the AdjustWindowRect that ash wants to - // adjust the top level on Windows. -#if !defined(OS_WIN) - root_window_->SetHostBounds(out_bounds); -#endif - out_bounds.set_x(0); - out_bounds.set_y(0); - } else if (is_embedded_window_) { - // The caller expects windows we consider "embedded" to be placed in the - // screen coordinate system. So we need to offset the root window's - // position (which is in screen coordinates) from these bounds. - aura::RootWindow* root = - widget_->GetNativeWindow()->GetRootWindow()->GetRootWindow(); - gfx::Point point = root->GetHostOrigin(); - out_bounds.set_x(out_bounds.x() - point.x()); - out_bounds.set_y(out_bounds.y() - point.y()); - } - - return out_bounds; -} - -//////////////////////////////////////////////////////////////////////////////// -// DesktopNativeWidgetHelperAura, aura::WindowObserver implementation: -void DesktopNativeWidgetHelperAura::OnWindowVisibilityChanged( - aura::Window* window, - bool visible) { - DCHECK_EQ(window, window_); - - // Since we're trying to hide the main window, hide the OS level root as well. - if (visible) - root_window_->ShowRootWindow(); - else - root_window_->HideRootWindow(); -} - -//////////////////////////////////////////////////////////////////////////////// -// DesktopNativeWidgetHelperAura, aura::RootWindowObserver implementation: - -void DesktopNativeWidgetHelperAura::OnRootWindowResized( - const aura::RootWindow* root, - const gfx::Size& old_size) { - DCHECK_EQ(root, root_window_.get()); - widget_->SetBounds(gfx::Rect(root->GetHostOrigin(), - root->GetHostSize())); -} - -void DesktopNativeWidgetHelperAura::OnRootWindowHostCloseRequested( - const aura::RootWindow* root) { - DCHECK_EQ(root, root_window_.get()); - widget_->GetWidget()->Close(); -} - -void DesktopNativeWidgetHelperAura::OnRootWindowMoved( - const aura::RootWindow* root, - const gfx::Point& new_origin) { - widget_->GetWidget()->OnNativeWidgetMove(); -} - -} // namespace views diff --git a/ui/views/widget/desktop_native_widget_helper_aura.h b/ui/views/widget/desktop_native_widget_helper_aura.h deleted file mode 100644 index 88381df..0000000 --- a/ui/views/widget/desktop_native_widget_helper_aura.h +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_VIEWS_WIDGET_DESKTOP_NATIVE_WIDGET_HELPER_AURA_H_ -#define UI_VIEWS_WIDGET_DESKTOP_NATIVE_WIDGET_HELPER_AURA_H_ - -#include "ui/aura/root_window_observer.h" -#include "ui/aura/window_observer.h" -#include "ui/gfx/rect.h" -#include "ui/views/views_export.h" -#include "ui/views/widget/native_widget_helper_aura.h" -#include "ui/views/widget/widget.h" - -namespace aura { -class RootWindow; -class DesktopCursorClient; -class DesktopWindowMoveClient; -namespace client { -class ScreenPositionClient; -} -namespace shared { -class CompoundEventFilter; -class InputMethodEventFilter; -class RootWindowCaptureClient; -} -} - -namespace ui { -#if defined(OS_WIN) -class HWNDMessageFilter; -#endif -} - -namespace views { -class NativeWidgetAura; -class WidgetMessageFilter; -#if defined(USE_X11) -class X11DesktopWindowMoveClient; -class X11WindowEventFilter; -#endif - -// Implementation of non-Ash desktop integration code, allowing -// NativeWidgetAuras to work in a traditional desktop environment. -class VIEWS_EXPORT DesktopNativeWidgetHelperAura - : public NativeWidgetHelperAura, - public aura::WindowObserver, - public aura::RootWindowObserver { - public: - explicit DesktopNativeWidgetHelperAura(NativeWidgetAura* widget); - virtual ~DesktopNativeWidgetHelperAura(); - - // In general, views/ does not care about the aura::RootWindow, even though - // at any join point with the native OS, we're going to be dealing in - // RootWindows. - static aura::Window* GetViewsWindowForRootWindow(aura::RootWindow* root); - - // Overridden from aura::NativeWidgetHelperAura: - virtual void PreInitialize(aura::Window* window, - const Widget::InitParams& params) OVERRIDE; - virtual void PostInitialize() OVERRIDE; - virtual aura::RootWindow* GetRootWindow() OVERRIDE; - virtual gfx::Rect ModifyAndSetBounds(const gfx::Rect& bounds) OVERRIDE; - - // Overridden from aura::RootWindowObserver: - virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; - - // Overridden from aura::RootWindowObserver: - virtual void OnRootWindowResized(const aura::RootWindow* root, - const gfx::Size& old_size) OVERRIDE; - virtual void OnRootWindowMoved(const aura::RootWindow* root, - const gfx::Point& new_origin) OVERRIDE; - virtual void OnWindowVisibilityChanged(aura::Window* window, - bool visible) OVERRIDE; - virtual void OnRootWindowHostCloseRequested( - const aura::RootWindow* root) OVERRIDE; - - private: - // A weak pointer back to our owning widget. - NativeWidgetAura* widget_; - - // The window from the NativeWidgetAura. We observe events on it, and proxy - // visibility stuff to it. - aura::Window* window_; - - // Optionally, a RootWindow that we attach ourselves to. - scoped_ptr<aura::RootWindow> root_window_; - - // Toplevel event filter which dispatches to other event filters. - aura::shared::CompoundEventFilter* root_window_event_filter_; - - // An event filter that pre-handles all key events to send them to an IME. - scoped_ptr<aura::shared::InputMethodEventFilter> input_method_filter_; - - // TODO(erg): This is temporary. Find out what needs to be done for desktop - // environment. - scoped_ptr<aura::shared::RootWindowCaptureClient> capture_client_; - - // We want some windows (omnibox, status bar) to have their own - // NativeWidgetAura, but still act as if they're screen bounded toplevel - // windows. - bool is_embedded_window_; - - // In some cases, we set a screen position client on |root_window_|. If we - // do, we're responsible for the lifetime. - scoped_ptr<aura::client::ScreenPositionClient> position_client_; - - // A simple cursor client which just forwards events to the RootWindow. - scoped_ptr<aura::DesktopCursorClient> cursor_client_; - - // Handles spinning up the nested run loop for tab dragging. - -#if defined(OS_WIN) - scoped_ptr<ui::HWNDMessageFilter> hwnd_message_filter_; -#elif defined(USE_X11) - scoped_ptr<X11WindowEventFilter> x11_window_event_filter_; - scoped_ptr<X11DesktopWindowMoveClient> x11_window_move_client_; -#endif - - DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetHelperAura); -}; - -} // namespace views - -#endif // UI_VIEWS_WIDGET_DESKTOP_NATIVE_WIDGET_HELPER_AURA_H_ diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 2ed70d2..a37ebd2 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -35,7 +35,6 @@ #include "ui/views/widget/drop_helper.h" #include "ui/views/widget/native_widget_aura_window_observer.h" #include "ui/views/widget/native_widget_delegate.h" -#include "ui/views/widget/native_widget_helper_aura.h" #include "ui/views/widget/root_view.h" #include "ui/views/widget/tooltip_manager_aura.h" #include "ui/views/widget/widget_aura_utils.h" @@ -62,10 +61,6 @@ void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) : delegate_(delegate), - ALLOW_THIS_IN_INITIALIZER_LIST(desktop_helper_( - ViewsDelegate::views_delegate ? - ViewsDelegate::views_delegate->CreateNativeWidgetHelper(this): - NULL)), ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), @@ -94,9 +89,6 @@ gfx::Font NativeWidgetAura::GetWindowTitleFont() { void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { ownership_ = params.ownership; - if (desktop_helper_.get()) - desktop_helper_->PreInitialize(window_, params); - window_->set_user_data(this); window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); window_->SetProperty(aura::client::kShowStateKey, params.show_state); @@ -110,12 +102,7 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { delegate_->OnNativeWidgetCreated(); gfx::Rect window_bounds = params.bounds; - if (desktop_helper_.get() && desktop_helper_->GetRootWindow()) { - if (!params.child && params.GetParent()) - params.GetParent()->AddTransientChild(window_); - - window_->SetParent(desktop_helper_->GetRootWindow()); - } else if (params.child) { + if (params.child) { window_->SetParent(params.GetParent()); } else { // Set up the transient child before the window is added. This way the @@ -167,9 +154,6 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { aura::client::SetActivationDelegate(window_, this); - if (desktop_helper_.get()) - desktop_helper_->PostInitialize(); - window_->SetProperty(aura::client::kCanMaximizeKey, GetWidget()->widget_delegate()->CanMaximize()); } diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index f59b4f8..1011f61 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -26,7 +26,6 @@ namespace views { class DropHelper; class NativeWidgetAuraWindowObserver; -class NativeWidgetHelperAura; class TooltipManagerAura; class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, @@ -180,8 +179,6 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, internal::NativeWidgetDelegate* delegate_; - scoped_ptr<NativeWidgetHelperAura> desktop_helper_; - aura::Window* window_; // See class documentation for Widget in widget.h for a note about ownership. diff --git a/ui/views/widget/native_widget_helper_aura.h b/ui/views/widget/native_widget_helper_aura.h deleted file mode 100644 index 54da578..0000000 --- a/ui/views/widget/native_widget_helper_aura.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_VIEWS_WIDGET_NATIVE_WIDGET_HELPER_AURA_H_ -#define UI_VIEWS_WIDGET_NATIVE_WIDGET_HELPER_AURA_H_ - -#include "ui/views/views_export.h" -#include "ui/views/widget/widget.h" - -namespace views { - -// A special delegate that encapsulates all logic for use of NativeWidgetAura -// on the desktop. -class VIEWS_EXPORT NativeWidgetHelperAura { - public: - virtual ~NativeWidgetHelperAura() {} - - // Called at the start of InitNativeWidget; determines whether we should - // set up a root_window_ for this widget/window pair. - virtual void PreInitialize(aura::Window* window, - const Widget::InitParams& params) = 0; - - // Called at the end of InitNativeWidget; i.e. after the NativeWidgetAura's - // aura::Window has been initialized. - virtual void PostInitialize() = 0; - - // If we own a RootWindow, return it. Otherwise NULL. - virtual aura::RootWindow* GetRootWindow() = 0; - - // If this NativeWidgetAura has its own RootWindow, sets the position at the - // |root_window_|, and returns modified bounds to set the origin to - // zero. Otherwise, pass through in_bounds. - virtual gfx::Rect ModifyAndSetBounds(const gfx::Rect& bounds) = 0; -}; - -} // namespace views - -#endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_HELPER_AURA_H_ diff --git a/ui/views/widget/x11_desktop_handler.cc b/ui/views/widget/x11_desktop_handler.cc index 044b56c..3e13600 100644 --- a/ui/views/widget/x11_desktop_handler.cc +++ b/ui/views/widget/x11_desktop_handler.cc @@ -13,7 +13,6 @@ #if !defined(OS_CHROMEOS) #include "ui/views/ime/input_method.h" -#include "ui/views/widget/desktop_native_widget_helper_aura.h" #include "ui/views/widget/desktop_root_window_host_linux.h" #endif @@ -101,17 +100,9 @@ void X11DesktopHandler::OnActiveWindowChanged(::Window xid) { #else aura::RootWindow* root_window = aura::RootWindow::GetForAcceleratedWidget(xid); - // TODO(erg): Rip out DesktopNativeWidgetHelperAura and replace with the if - // block below. aura::Window* window = root_window ? - views::DesktopNativeWidgetHelperAura::GetViewsWindowForRootWindow( - root_window) : NULL; - - if (!window) { - window = root_window ? - views::DesktopRootWindowHostLinux::GetContentWindowForXID(xid) : - NULL; - } + views::DesktopRootWindowHostLinux::GetContentWindowForXID(xid) : + NULL; #endif desktop_activation_client_->ActivateWindow(window); |