summaryrefslogtreecommitdiffstats
path: root/ui/views
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-30 23:14:03 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-30 23:14:03 +0000
commitde4ec531ed531ea578a783f7da16f67ce0f6d658 (patch)
tree4ec6d291f8da0240e153e4ce126d625d5fe89c5d /ui/views
parent6a73c3006dde579493a5b070fe9bd3008608d5b1 (diff)
downloadchromium_src-de4ec531ed531ea578a783f7da16f67ce0f6d658.zip
chromium_src-de4ec531ed531ea578a783f7da16f67ce0f6d658.tar.gz
chromium_src-de4ec531ed531ea578a783f7da16f67ce0f6d658.tar.bz2
Ash/aura split: Get views_examples_exe semi-running on linux/X11.
This adds tons of hacks, most of which should be clearly labeled with TODOs. BUG=119759 TEST= Review URL: http://codereview.chromium.org/9873035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r--ui/views/examples/examples_main.cc53
-rw-r--r--ui/views/views.gyp6
-rw-r--r--ui/views/widget/native_widget_aura.cc57
-rw-r--r--ui/views/widget/native_widget_aura.h6
4 files changed, 118 insertions, 4 deletions
diff --git a/ui/views/examples/examples_main.cc b/ui/views/examples/examples_main.cc
index f27a3e8..cd48f6b 100644
--- a/ui/views/examples/examples_main.cc
+++ b/ui/views/examples/examples_main.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/i18n/icu_util.h"
#include "base/logging.h"
+#include "base/message_loop.h"
#include "base/process_util.h"
#include "base/stl_util.h"
#include "base/utf_string_conversions.h"
@@ -20,6 +21,37 @@
#include "ui/base/win/scoped_ole_initializer.h"
#endif
+#if defined(USE_AURA)
+#include "ui/aura/client/stacking_client.h"
+#include "ui/aura/env.h"
+#include "ui/aura/window.h"
+#include "ui/aura/root_window.h"
+#include "ui/gfx/compositor/compositor.h"
+#include "ui/gfx/compositor/test/compositor_test_support.h"
+#include "ui/views/widget/native_widget_aura.h"
+#endif
+
+#if defined(USE_AURA)
+class RootWindowStackingClient : public aura::client::StackingClient {
+ public:
+ explicit RootWindowStackingClient() {
+ aura::client::SetStackingClient(this);
+ }
+
+ virtual ~RootWindowStackingClient() {
+ aura::client::SetStackingClient(NULL);
+ }
+
+ // Overridden from aura::client::StackingClient:
+ virtual aura::Window* GetDefaultParent(aura::Window* window) OVERRIDE {
+ return window->GetRootWindow();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(RootWindowStackingClient);
+};
+#endif
+
int main(int argc, char** argv) {
#if defined(OS_WIN)
ui::ScopedOleInitializer ole_initializer;
@@ -43,13 +75,34 @@ int main(int argc, char** argv) {
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US");
MessageLoop main_message_loop(MessageLoop::TYPE_UI);
+#if defined(USE_AURA)
+
+ // TURN ON THE HAX.
+ views::NativeWidgetAura::set_aura_desktop_hax();
+
+ ui::CompositorTestSupport::Initialize();
+
+ {
+ RootWindowStackingClient root_window_stacking_client;
+#endif
views::TestViewsDelegate delegate;
views::examples::ShowExamplesWindow(true);
+ // xxx: Hax here because this kills event handling.
+#if !defined(USE_AURA)
views::AcceleratorHandler accelerator_handler;
MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler);
+#else
+ MessageLoopForUI::current()->Run();
+#endif
+
+#if defined(USE_AURA)
+ }
+ aura::Env::DeleteInstance();
+ ui::CompositorTestSupport::Terminate();
+#endif
return 0;
}
diff --git a/ui/views/views.gyp b/ui/views/views.gyp
index 64db0ec..ca86f19 100644
--- a/ui/views/views.gyp
+++ b/ui/views/views.gyp
@@ -650,6 +650,12 @@
},
},
}],
+ ['use_aura==1', {
+ 'dependencies': [
+ '../gfx/compositor/compositor.gyp:compositor',
+ '../gfx/compositor/compositor.gyp:compositor_test_support',
+ ],
+ }],
],
}, # target_name: views_examples_lib
],
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc
index 44f1926..19292d5 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -9,9 +9,13 @@
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/client/dispatcher_client.h"
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/client/window_move_client.h"
#include "ui/aura/client/window_types.h"
+#include "ui/aura/desktop/desktop_activation_client.h"
+#include "ui/aura/desktop/desktop_dispatcher_client.h"
+#include "ui/aura/desktop/desktop_root_window_event_filter.h"
#include "ui/aura/env.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
@@ -38,6 +42,8 @@
namespace views {
+bool NativeWidgetAura::g_aura_desktop_hax = false;
+
namespace {
aura::client::WindowType GetAuraWindowTypeForWidgetType(
@@ -127,6 +133,7 @@ class NativeWidgetAura::ActiveWindowObserver : public aura::WindowObserver {
NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate)
: delegate_(delegate),
+ root_window_(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)),
@@ -160,6 +167,25 @@ gfx::Font NativeWidgetAura::GetWindowTitleFont() {
void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
ownership_ = params.ownership;
+ // TODO(erg): What kind of windows do we want to have their own root windows?
+ if (g_aura_desktop_hax) {
+ 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));
+ }
+ root_window_.reset(new aura::RootWindow(bounds));
+ root_window_->SetEventFilter(
+ new aura::DesktopRootWindowEventFilter(root_window_.get()));
+
+ aura::client::SetActivationClient(
+ root_window_.get(),
+ new aura::DesktopActivationClient(root_window_.get()));
+ aura::client::SetDispatcherClient(root_window_.get(),
+ new aura::DesktopDispatcherClient);
+ }
+
window_->set_user_data(this);
window_->SetType(GetAuraWindowTypeForWidgetType(params.type));
window_->SetProperty(aura::client::kShowStateKey, params.show_state);
@@ -171,7 +197,9 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
window_->Show();
delegate_->OnNativeWidgetCreated();
- if (params.child) {
+ if (root_window_.get()) {
+ window_->SetParent(root_window_.get());
+ } else if (params.child) {
window_->SetParent(params.GetParent());
} else {
// Set up the transient child before the window is added. This way the
@@ -179,19 +207,29 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
gfx::NativeView parent = params.GetParent();
if (parent && parent->type() != aura::client::WINDOW_TYPE_UNKNOWN) {
parent->AddTransientChild(window_);
- parent = NULL;
+
+ // TODO(erg): The StackingClient interface implies that there is only a
+ // single root window. Solving this would require setting a stacking
+ // client per root window instead. For now, we hax our way around this by
+ // forcing the parent to be the root window instead of passing NULL as
+ // the parent which will dispatch to the stacking client.
+ if (g_aura_desktop_hax)
+ parent = parent->GetRootWindow();
+ else
+ parent = NULL;
}
// SetAlwaysOnTop before SetParent so that always-on-top container is used.
SetAlwaysOnTop(params.keep_on_top);
window_->SetParent(parent);
}
+
// Wait to set the bounds until we have a parent. That way we can know our
// true state/bounds (the LayoutManager may enforce a particular
// state/bounds).
if (IsMaximized())
SetRestoreBounds(window_, params.bounds);
else
- window_->SetBounds(params.bounds);
+ SetBounds(params.bounds);
window_->set_ignore_events(!params.accept_events);
can_activate_ = params.can_activate;
DCHECK(GetWidget()->GetRootView());
@@ -207,6 +245,9 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
}
aura::client::SetActivationDelegate(window_, this);
+
+ if (root_window_.get())
+ root_window_->ShowRootWindow();
}
NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() {
@@ -407,7 +448,15 @@ gfx::Rect NativeWidgetAura::GetRestoredBounds() const {
return restore_bounds ? *restore_bounds : window_->bounds();
}
-void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) {
+void NativeWidgetAura::SetBounds(const gfx::Rect& in_bounds) {
+ gfx::Rect bounds = in_bounds;
+
+ if (root_window_.get() && !bounds.IsEmpty()) {
+ root_window_->SetHostBounds(bounds);
+ bounds.set_x(0);
+ bounds.set_y(0);
+ }
+
window_->SetBounds(bounds);
}
diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h
index 8ba42f3..2621918 100644
--- a/ui/views/widget/native_widget_aura.h
+++ b/ui/views/widget/native_widget_aura.h
@@ -16,6 +16,7 @@
#include "ui/views/widget/native_widget_private.h"
namespace aura {
+class RootWindow;
class Window;
}
namespace gfx {
@@ -35,6 +36,8 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate,
explicit NativeWidgetAura(internal::NativeWidgetDelegate* delegate);
virtual ~NativeWidgetAura();
+ static void set_aura_desktop_hax() { g_aura_desktop_hax = true; }
+
// TODO(beng): Find a better place for this, and the similar method on
// NativeWidgetWin.
static gfx::Font GetWindowTitleFont();
@@ -167,6 +170,7 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate,
internal::NativeWidgetDelegate* delegate_;
+ scoped_ptr<aura::RootWindow> root_window_;
aura::Window* window_;
// See class documentation for Widget in widget.h for a note about ownership.
@@ -191,6 +195,8 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate,
scoped_ptr<DropHelper> drop_helper_;
int last_drop_operation_;
+ static bool g_aura_desktop_hax;
+
DISALLOW_COPY_AND_ASSIGN(NativeWidgetAura);
};