summaryrefslogtreecommitdiffstats
path: root/ui/aura/desktop.cc
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-23 06:58:59 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-23 06:58:59 +0000
commitc06186d9e84ef974d5784414b983b0bb9a343903 (patch)
tree181759e9169abaa99a55890e4e34e2ac76da736c /ui/aura/desktop.cc
parent1219d90f11ee6196c9b9b94f140c86437dad8d88 (diff)
downloadchromium_src-c06186d9e84ef974d5784414b983b0bb9a343903.zip
chromium_src-c06186d9e84ef974d5784414b983b0bb9a343903.tar.gz
chromium_src-c06186d9e84ef974d5784414b983b0bb9a343903.tar.bz2
DefaultDispatcher for MessagePumpX
MPX itself doesn't know how to handle events and we've been converting MessageLoop::Run() -> Desktop::Run() or RunAllPending to use ui_test_utils::RunAllPendingInMessageLoop(). It's no longer necessary with this CL. Windows's message pump can dispatch events without dispatcher. BUG=none TEST=none, but I believe some of browser_tests on aura is flaky because of this, and this CL should make them less/non flaky. Review URL: http://codereview.chromium.org/8635014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111324 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura/desktop.cc')
-rw-r--r--ui/aura/desktop.cc105
1 files changed, 61 insertions, 44 deletions
diff --git a/ui/aura/desktop.cc b/ui/aura/desktop.cc
index b3a8b8a..90ee171 100644
--- a/ui/aura/desktop.cc
+++ b/ui/aura/desktop.cc
@@ -32,6 +32,10 @@
#include "ui/gfx/compositor/compositor_cc.h"
#endif
+#if defined(USE_X11)
+#include "base/message_pump_x.h"
+#endif
+
using std::string;
using std::vector;
@@ -101,48 +105,8 @@ void GetEventFiltersToNotify(Window* target, EventFilters* filters) {
Desktop* Desktop::instance_ = NULL;
bool Desktop::use_fullscreen_host_window_ = false;
-Desktop::Desktop()
- : Window(NULL),
- host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- stacking_client_(new DefaultStackingClient(this))),
- ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)),
- active_window_(NULL),
- mouse_button_flags_(0),
- last_cursor_(kCursorNull),
- in_destructor_(false),
- screen_(new ScreenAura),
- capture_window_(NULL),
- mouse_pressed_handler_(NULL),
- mouse_moved_handler_(NULL),
- focused_window_(NULL),
- touch_event_handler_(NULL) {
- set_name("RootWindow");
- gfx::Screen::SetInstance(screen_);
- host_->SetDesktop(this);
- last_mouse_location_ = host_->QueryMouseLocation();
-
- if (ui::Compositor::compositor_factory()) {
- compositor_ = (*ui::Compositor::compositor_factory())(this);
- } else {
-#ifdef USE_WEBKIT_COMPOSITOR
- ui::CompositorCC::Initialize(false);
-#endif
- compositor_ = ui::Compositor::Create(this, host_->GetAcceleratedWidget(),
- host_->GetSize());
- }
- DCHECK(compositor_.get());
-}
-
-Desktop::~Desktop() {
- in_destructor_ = true;
-#ifdef USE_WEBKIT_COMPOSITOR
- if (!ui::Compositor::compositor_factory())
- ui::CompositorCC::Terminate();
-#endif
- if (instance_ == this)
- instance_ = NULL;
-}
+////////////////////////////////////////////////////////////////////////////////
+// Desktop, public:
// static
Desktop* Desktop::GetInstance() {
@@ -154,7 +118,7 @@ Desktop* Desktop::GetInstance() {
}
// static
-void Desktop::DeleteInstanceForTesting() {
+void Desktop::DeleteInstance() {
delete instance_;
instance_ = NULL;
}
@@ -188,7 +152,7 @@ void Desktop::SetCursor(gfx::NativeCursor cursor) {
void Desktop::Run() {
ShowDesktop();
- MessageLoopForUI::current()->RunWithDispatcher(host_.get());
+ MessageLoopForUI::current()->Run();
}
void Desktop::Draw() {
@@ -426,6 +390,59 @@ void Desktop::ToggleFullScreen() {
}
#endif
+////////////////////////////////////////////////////////////////////////////////
+// Desktop, private:
+
+Desktop::Desktop()
+ : Window(NULL),
+ host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())),
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ stacking_client_(new DefaultStackingClient(this))),
+ ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)),
+ active_window_(NULL),
+ mouse_button_flags_(0),
+ last_cursor_(kCursorNull),
+ in_destructor_(false),
+ screen_(new ScreenAura),
+ capture_window_(NULL),
+ mouse_pressed_handler_(NULL),
+ mouse_moved_handler_(NULL),
+ focused_window_(NULL),
+ touch_event_handler_(NULL) {
+ set_name("RootWindow");
+ gfx::Screen::SetInstance(screen_);
+ host_->SetDesktop(this);
+ last_mouse_location_ = host_->QueryMouseLocation();
+
+ if (ui::Compositor::compositor_factory()) {
+ compositor_ = (*ui::Compositor::compositor_factory())(this);
+ } else {
+#ifdef USE_WEBKIT_COMPOSITOR
+ ui::CompositorCC::Initialize(false);
+#endif
+ compositor_ = ui::Compositor::Create(this, host_->GetAcceleratedWidget(),
+ host_->GetSize());
+ }
+ DCHECK(compositor_.get());
+#if defined(USE_X11)
+ base::MessagePumpX::SetDefaultDispatcher(host_.get());
+#endif
+}
+
+Desktop::~Desktop() {
+#if defined(USE_X11)
+ base::MessagePumpX::SetDefaultDispatcher(NULL);
+#endif
+
+ in_destructor_ = true;
+#ifdef USE_WEBKIT_COMPOSITOR
+ if (!ui::Compositor::compositor_factory())
+ ui::CompositorCC::Terminate();
+#endif
+ if (instance_ == this)
+ instance_ = NULL;
+}
+
void Desktop::HandleMouseMoved(const MouseEvent& event, Window* target) {
if (target == mouse_moved_handler_)
return;