summaryrefslogtreecommitdiff
path: root/chromium/ui/aura
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/aura')
-rw-r--r--chromium/ui/aura/aura.gyp14
-rw-r--r--chromium/ui/aura/bench/DEPS1
-rw-r--r--chromium/ui/aura/bench/bench_main.cc46
-rw-r--r--chromium/ui/aura/client/cursor_client.h7
-rw-r--r--chromium/ui/aura/demo/demo_main.cc17
-rw-r--r--chromium/ui/aura/device_list_updater_aurax11.cc2
-rw-r--r--chromium/ui/aura/env.cc10
-rw-r--r--chromium/ui/aura/env.h6
-rw-r--r--chromium/ui/aura/gestures/gesture_recognizer_unittest.cc83
-rw-r--r--chromium/ui/aura/remote_root_window_host_win.cc46
-rw-r--r--chromium/ui/aura/remote_root_window_host_win.h19
-rw-r--r--chromium/ui/aura/root_window.cc139
-rw-r--r--chromium/ui/aura/root_window.h27
-rw-r--r--chromium/ui/aura/root_window_host.h11
-rw-r--r--chromium/ui/aura/root_window_host_mac.h29
-rw-r--r--chromium/ui/aura/root_window_host_mac.mm218
-rw-r--r--chromium/ui/aura/root_window_host_ozone.cc13
-rw-r--r--chromium/ui/aura/root_window_host_ozone.h5
-rw-r--r--chromium/ui/aura/root_window_host_win.cc9
-rw-r--r--chromium/ui/aura/root_window_host_win.h7
-rw-r--r--chromium/ui/aura/root_window_host_x11.cc97
-rw-r--r--chromium/ui/aura/root_window_host_x11.h8
-rw-r--r--chromium/ui/aura/root_window_mac.h37
-rw-r--r--chromium/ui/aura/root_window_mac.mm35
-rw-r--r--chromium/ui/aura/root_window_unittest.cc177
-rw-r--r--chromium/ui/aura/root_window_view_mac.h21
-rw-r--r--chromium/ui/aura/root_window_view_mac.mm16
-rw-r--r--chromium/ui/aura/window.cc47
-rw-r--r--chromium/ui/aura/window.h4
-rw-r--r--chromium/ui/aura/window_delegate.h14
-rw-r--r--chromium/ui/aura/window_unittest.cc12
31 files changed, 462 insertions, 715 deletions
diff --git a/chromium/ui/aura/aura.gyp b/chromium/ui/aura/aura.gyp
index a4fe8612de6..c2983e921a6 100644
--- a/chromium/ui/aura/aura.gyp
+++ b/chromium/ui/aura/aura.gyp
@@ -83,19 +83,13 @@
'remote_root_window_host_win.h',
'root_window_host.h',
'root_window_host_delegate.h',
- 'root_window_host_mac.h',
- 'root_window_host_mac.mm',
'root_window_host_ozone.cc',
'root_window_host_ozone.h',
'root_window_host_win.cc',
'root_window_host_win.h',
'root_window_host_x11.cc',
'root_window_host_x11.h',
- 'root_window_mac.h',
- 'root_window_mac.mm',
'root_window_transformer.h',
- 'root_window_view_mac.h',
- 'root_window_view_mac.mm',
'root_window.cc',
'root_window.h',
'window.cc',
@@ -106,12 +100,6 @@
'window_tracker.h',
],
'conditions': [
- ['OS=="mac"', {
- 'sources/': [
- ['exclude', 'client/dispatcher_client.cc'],
- ['exclude', 'client/dispatcher_client.h'],
- ],
- }],
['use_x11==1', {
'link_settings': {
'libraries': [
@@ -181,6 +169,7 @@
'target_name': 'aura_test_support_pak',
'type': 'none',
'dependencies': [
+ '<(DEPTH)/ui/base/strings/ui_strings.gyp:ui_strings',
'<(DEPTH)/ui/ui.gyp:ui_resources',
],
'variables': {
@@ -191,6 +180,7 @@
'action_name': 'repack_aura_test_support_pack',
'variables': {
'pak_inputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/ui/app_locale_settings/app_locale_settings_en-US.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources_100_percent.pak',
],
},
diff --git a/chromium/ui/aura/bench/DEPS b/chromium/ui/aura/bench/DEPS
index 69deb976808..1fda55436bc 100644
--- a/chromium/ui/aura/bench/DEPS
+++ b/chromium/ui/aura/bench/DEPS
@@ -1,4 +1,5 @@
include_rules = [
+ "+cc",
"+third_party/khronos",
"+third_party/WebKit/public/platform",
]
diff --git a/chromium/ui/aura/bench/bench_main.cc b/chromium/ui/aura/bench/bench_main.cc
index aee7e79c83a..f344854ea1a 100644
--- a/chromium/ui/aura/bench/bench_main.cc
+++ b/chromium/ui/aura/bench/bench_main.cc
@@ -10,6 +10,7 @@
#include "base/message_loop/message_loop.h"
#include "base/strings/string_split.h"
#include "base/time/time.h"
+#include "cc/output/context_provider.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/skia/include/core/SkXfermode.h"
#include "ui/aura/client/default_capture_client.h"
@@ -35,7 +36,7 @@
#include "third_party/khronos/GLES2/gl2ext.h"
#if defined(USE_X11)
-#include "base/message_loop/message_pump_aurax11.h"
+#include "base/message_loop/message_pump_x11.h"
#endif
using base::TimeTicks;
@@ -181,7 +182,7 @@ class WebGLBench : public BenchCompositorObserver {
parent_(parent),
webgl_(ui::LAYER_TEXTURED),
compositor_(compositor),
- context_(),
+ context_provider_(),
texture_(),
fbo_(0),
do_draw_(true) {
@@ -207,24 +208,26 @@ class WebGLBench : public BenchCompositorObserver {
webgl_.SetBounds(bounds);
parent_->Add(&webgl_);
- context_ = ui::ContextFactory::GetInstance()->CreateOffscreenContext();
- context_->makeContextCurrent();
- texture_ = new WebGLTexture(context_.get(), bounds.size());
- fbo_ = context_->createFramebuffer();
+ context_provider_ = ui::ContextFactory::GetInstance()
+ ->OffscreenContextProviderForMainThread();
+ WebKit::WebGraphicsContext3D* context = context_provider_->Context3d();
+ context->makeContextCurrent();
+ texture_ = new WebGLTexture(context, bounds.size());
+ fbo_ = context->createFramebuffer();
compositor->AddObserver(this);
webgl_.SetExternalTexture(texture_.get());
- context_->bindFramebuffer(GL_FRAMEBUFFER, fbo_);
- context_->framebufferTexture2D(
+ context->bindFramebuffer(GL_FRAMEBUFFER, fbo_);
+ context->framebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, texture_->PrepareTexture(), 0);
- context_->clearColor(0.f, 1.f, 0.f, 1.f);
- context_->clear(GL_COLOR_BUFFER_BIT);
- context_->flush();
+ context->clearColor(0.f, 1.f, 0.f, 1.f);
+ context->clear(GL_COLOR_BUFFER_BIT);
+ context->flush();
}
virtual ~WebGLBench() {
- context_->makeContextCurrent();
- context_->deleteFramebuffer(fbo_);
+ context_provider_->Context3d()->makeContextCurrent();
+ context_provider_->Context3d()->deleteFramebuffer(fbo_);
webgl_.SetExternalTexture(NULL);
texture_ = NULL;
compositor_->RemoveObserver(this);
@@ -232,10 +235,11 @@ class WebGLBench : public BenchCompositorObserver {
virtual void Draw() OVERRIDE {
if (do_draw_) {
- context_->makeContextCurrent();
- context_->clearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f);
- context_->clear(GL_COLOR_BUFFER_BIT);
- context_->flush();
+ WebKit::WebGraphicsContext3D* context = context_provider_->Context3d();
+ context->makeContextCurrent();
+ context->clearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f);
+ context->clear(GL_COLOR_BUFFER_BIT);
+ context->flush();
}
webgl_.SetExternalTexture(texture_.get());
webgl_.SchedulePaint(gfx::Rect(webgl_.bounds().size()));
@@ -246,7 +250,7 @@ class WebGLBench : public BenchCompositorObserver {
Layer* parent_;
Layer webgl_;
Compositor* compositor_;
- scoped_ptr<WebGraphicsContext3D> context_;
+ scoped_refptr<cc::ContextProvider> context_provider_;
scoped_refptr<WebGLTexture> texture_;
// The FBO that is used to render to the texture.
@@ -296,8 +300,12 @@ int main(int argc, char** argv) {
base::AtExitManager exit_manager;
+ // The ContextFactory must exist before any Compositors are created.
+ bool allow_test_contexts = false;
+ ui::Compositor::InitializeContextFactoryForTests(allow_test_contexts);
+
ui::RegisterPathProvider();
- icu_util::Initialize();
+ base::i18n::InitializeICU();
ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);
base::MessageLoop message_loop(base::MessageLoop::TYPE_UI);
diff --git a/chromium/ui/aura/client/cursor_client.h b/chromium/ui/aura/client/cursor_client.h
index acdf255b850..e8740ac1704 100644
--- a/chromium/ui/aura/client/cursor_client.h
+++ b/chromium/ui/aura/client/cursor_client.h
@@ -7,6 +7,7 @@
#include "base/strings/string16.h"
#include "ui/aura/aura_export.h"
+#include "ui/base/cursor/cursor.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
@@ -34,6 +35,9 @@ class AURA_EXPORT CursorClient {
// Sets the scale of the mouse cursor icon.
virtual void SetScale(float scale) = 0;
+ // Sets the type of the mouse cursor icon.
+ virtual void SetCursorSet(ui::CursorSetType cursor_set) = 0;
+
// Gets whether the cursor is visible.
virtual bool IsCursorVisible() const = 0;
@@ -60,6 +64,9 @@ class AURA_EXPORT CursorClient {
// EnableMouseEvents/DisableMouseEvents.
virtual void UnlockCursor() = 0;
+ // Returns true if the cursor is locked.
+ virtual bool IsCursorLocked() const = 0;
+
// Used to add or remove a CursorClientObserver.
virtual void AddObserver(CursorClientObserver* observer) = 0;
virtual void RemoveObserver(CursorClientObserver* observer) = 0;
diff --git a/chromium/ui/aura/demo/demo_main.cc b/chromium/ui/aura/demo/demo_main.cc
index 06938d87419..dbf1c80b7a6 100644
--- a/chromium/ui/aura/demo/demo_main.cc
+++ b/chromium/ui/aura/demo/demo_main.cc
@@ -16,15 +16,16 @@
#include "ui/aura/test/test_screen.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
-#include "ui/base/events/event.h"
#include "ui/base/hit_test.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
+#include "ui/compositor/compositor.h"
+#include "ui/events/event.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/rect.h"
#if defined(USE_X11)
-#include "base/message_loop/message_pump_aurax11.h"
+#include "base/message_loop/message_pump_x11.h"
#endif
namespace {
@@ -67,9 +68,8 @@ class DemoWindowDelegate : public aura::WindowDelegate {
virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE {}
virtual bool HasHitTestMask() const OVERRIDE { return false; }
virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {}
- virtual scoped_refptr<ui::Texture> CopyTexture() OVERRIDE {
- return scoped_refptr<ui::Texture>();
- }
+ virtual void DidRecreateLayer(ui::Layer* old_layer,
+ ui::Layer* new_layer) OVERRIDE {}
private:
SkColor color_;
@@ -110,6 +110,11 @@ class DemoStackingClient : public aura::client::StackingClient {
int DemoMain() {
// Create the message-loop here before creating the root window.
base::MessageLoop message_loop(base::MessageLoop::TYPE_UI);
+
+ // The ContextFactory must exist before any Compositors are created.
+ bool allow_test_contexts = false;
+ ui::Compositor::InitializeContextFactoryForTests(allow_test_contexts);
+
aura::Env::GetInstance();
scoped_ptr<aura::TestScreen> test_screen(aura::TestScreen::Create());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen.get());
@@ -160,7 +165,7 @@ int main(int argc, char** argv) {
base::AtExitManager exit_manager;
ui::RegisterPathProvider();
- icu_util::Initialize();
+ base::i18n::InitializeICU();
ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);
return DemoMain();
diff --git a/chromium/ui/aura/device_list_updater_aurax11.cc b/chromium/ui/aura/device_list_updater_aurax11.cc
index 0671dfecbfd..8240cb495c3 100644
--- a/chromium/ui/aura/device_list_updater_aurax11.cc
+++ b/chromium/ui/aura/device_list_updater_aurax11.cc
@@ -6,7 +6,7 @@
#include <X11/extensions/XInput2.h>
-#include "ui/base/events/event_utils.h"
+#include "ui/events/event_utils.h"
namespace aura {
diff --git a/chromium/ui/aura/env.cc b/chromium/ui/aura/env.cc
index 6b2b3e023a3..a4cf8151e24 100644
--- a/chromium/ui/aura/env.cc
+++ b/chromium/ui/aura/env.cc
@@ -12,7 +12,7 @@
#include "ui/compositor/compositor_switches.h"
#if defined(USE_X11)
-#include "base/message_loop/message_pump_aurax11.h"
+#include "base/message_loop/message_pump_x11.h"
#endif
namespace aura {
@@ -30,7 +30,7 @@ Env::Env()
Env::~Env() {
#if defined(USE_X11)
- base::MessagePumpAuraX11::Current()->RemoveObserver(
+ base::MessagePumpX11::Current()->RemoveObserver(
&device_list_updater_aurax11_);
#endif
@@ -62,15 +62,13 @@ void Env::RemoveObserver(EnvObserver* observer) {
observers_.RemoveObserver(observer);
}
-#if !defined(OS_MACOSX)
base::MessageLoop::Dispatcher* Env::GetDispatcher() {
#if defined(USE_X11)
- return base::MessagePumpAuraX11::Current();
+ return base::MessagePumpX11::Current();
#else
return dispatcher_.get();
#endif
}
-#endif
void Env::RootWindowActivated(RootWindow* root_window) {
FOR_EACH_OBSERVER(EnvObserver, observers_,
@@ -87,7 +85,7 @@ void Env::Init() {
#if defined(USE_X11)
// We can't do this with a root window listener because XI_HierarchyChanged
// messages don't have a target window.
- base::MessagePumpAuraX11::Current()->AddObserver(
+ base::MessagePumpX11::Current()->AddObserver(
&device_list_updater_aurax11_);
#endif
ui::Compositor::Initialize();
diff --git a/chromium/ui/aura/env.h b/chromium/ui/aura/env.h
index ad31cd57ac5..c52b892d573 100644
--- a/chromium/ui/aura/env.h
+++ b/chromium/ui/aura/env.h
@@ -9,8 +9,8 @@
#include "base/message_loop/message_loop.h"
#include "base/observer_list.h"
#include "ui/aura/aura_export.h"
-#include "ui/base/events/event_handler.h"
-#include "ui/base/events/event_target.h"
+#include "ui/events/event_handler.h"
+#include "ui/events/event_target.h"
#include "ui/gfx/point.h"
#if defined(USE_X11)
@@ -60,9 +60,7 @@ class AURA_EXPORT Env : public ui::EventTarget {
// Returns the native event dispatcher. The result should only be passed to
// base::RunLoop(dispatcher), or used to dispatch an event by
// |Dispatch(const NativeEvent&)| on it. It must never be stored.
-#if !defined(OS_MACOSX)
base::MessageLoop::Dispatcher* GetDispatcher();
-#endif
// Invoked by RootWindow when its host is activated.
void RootWindowActivated(RootWindow* root_window);
diff --git a/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc b/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc
index d377ef458a3..f17a32045ec 100644
--- a/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -14,14 +14,14 @@
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h"
-#include "ui/base/events/event.h"
-#include "ui/base/events/event_utils.h"
#include "ui/base/gestures/gesture_configuration.h"
#include "ui/base/gestures/gesture_recognizer_impl.h"
#include "ui/base/gestures/gesture_sequence.h"
#include "ui/base/gestures/gesture_types.h"
#include "ui/base/hit_test.h"
#include "ui/base/ui_base_switches.h"
+#include "ui/events/event.h"
+#include "ui/events/event_utils.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
@@ -2908,9 +2908,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) {
tes.SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get());
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
- // TODO(rbyers): Really we should get the TapCancel here instead of below,
- // but this is a symptom of a larger issue: crbug.com/146397.
- EXPECT_FALSE(delegate->tap_cancel());
+ EXPECT_TRUE(delegate->tap_cancel());
EXPECT_FALSE(delegate->begin());
EXPECT_FALSE(delegate->scroll_begin());
EXPECT_FALSE(delegate->scroll_update());
@@ -2924,7 +2922,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) {
root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
- EXPECT_TRUE(delegate->tap_cancel());
+ EXPECT_FALSE(delegate->tap_cancel());
EXPECT_FALSE(delegate->begin());
EXPECT_TRUE(delegate->end());
EXPECT_FALSE(delegate->scroll_begin());
@@ -3059,9 +3057,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
tes.SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get());
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
- // TODO(rbyers): Really we should get the TapCancel here instead of below,
- // but this is a symptom of a larger issue: crbug.com/146397.
- EXPECT_FALSE(delegate->tap_cancel());
+ EXPECT_TRUE(delegate->tap_cancel());
EXPECT_FALSE(delegate->begin());
EXPECT_FALSE(delegate->scroll_begin());
EXPECT_FALSE(delegate->scroll_update());
@@ -3072,21 +3068,18 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
tes.SendScrollEvent(root_window(), 159, 259, kTouchId, delegate.get());
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
- EXPECT_TRUE(delegate->tap_cancel());
+ EXPECT_FALSE(delegate->tap_cancel());
EXPECT_FALSE(delegate->begin());
- EXPECT_TRUE(delegate->scroll_begin());
- EXPECT_TRUE(delegate->scroll_update());
+ EXPECT_FALSE(delegate->scroll_begin());
+ EXPECT_FALSE(delegate->scroll_update());
EXPECT_FALSE(delegate->scroll_end());
- // Consuming move events doesn't effect what the ultimate scroll position
- // will be if scrolling is later allowed to happen.
- EXPECT_EQ(58, delegate->scroll_x());
- EXPECT_EQ(58, delegate->scroll_y());
- EXPECT_EQ(gfx::Point(1, 1).ToString(),
+ // No scroll has occurred, because an early touch move was consumed.
+ EXPECT_EQ(0, delegate->scroll_x());
+ EXPECT_EQ(0, delegate->scroll_y());
+ EXPECT_EQ(gfx::Point(0, 0).ToString(),
delegate->scroll_begin_position().ToString());
- // Start consuming touch-move events again. However, since gesture-scroll has
- // already started, the touch-move events should still result in scroll-update
- // gestures.
+ // Start consuming touch-move events again.
delegate->set_consume_touch_move(true);
// Move some more to generate a few more scroll updates.
@@ -3096,10 +3089,10 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
EXPECT_FALSE(delegate->tap_cancel());
EXPECT_FALSE(delegate->begin());
EXPECT_FALSE(delegate->scroll_begin());
- EXPECT_TRUE(delegate->scroll_update());
+ EXPECT_FALSE(delegate->scroll_update());
EXPECT_FALSE(delegate->scroll_end());
- EXPECT_EQ(-49, delegate->scroll_x());
- EXPECT_EQ(-48, delegate->scroll_y());
+ EXPECT_EQ(0, delegate->scroll_x());
+ EXPECT_EQ(0, delegate->scroll_y());
tes.SendScrollEvent(root_window(), 140, 215, kTouchId, delegate.get());
EXPECT_FALSE(delegate->tap());
@@ -3107,12 +3100,12 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
EXPECT_FALSE(delegate->tap_cancel());
EXPECT_FALSE(delegate->begin());
EXPECT_FALSE(delegate->scroll_begin());
- EXPECT_TRUE(delegate->scroll_update());
+ EXPECT_FALSE(delegate->scroll_update());
EXPECT_FALSE(delegate->scroll_end());
- EXPECT_EQ(30, delegate->scroll_x());
- EXPECT_EQ(4, delegate->scroll_y());
+ EXPECT_EQ(0, delegate->scroll_x());
+ EXPECT_EQ(0, delegate->scroll_y());
- // Release the touch. This should end the scroll.
+ // Release the touch.
delegate->Reset();
ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
kTouchId, tes.LeapForward(50));
@@ -3125,8 +3118,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
EXPECT_FALSE(delegate->scroll_begin());
EXPECT_FALSE(delegate->scroll_update());
EXPECT_FALSE(delegate->scroll_end());
- // Moves arrive without delays and hence have high velocity.
- EXPECT_TRUE(delegate->fling());
+ EXPECT_FALSE(delegate->fling());
}
// Check that appropriate touch events generate double tap gesture events.
@@ -3418,5 +3410,38 @@ TEST_F(GestureRecognizerTest, NoDriftInScroll) {
delegate->Reset();
}
+// Ensure that move events which are preventDefaulted will cause a tap
+// cancel gesture event to be fired if the move would normally cause a
+// scroll. See bug http://crbug.com/146397.
+TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) {
+ scoped_ptr<ConsumesTouchMovesDelegate> delegate(
+ new ConsumesTouchMovesDelegate());
+ const int kTouchId = 5;
+ gfx::Rect bounds(100, 200, 123, 45);
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
+ delegate.get(), -1234, bounds, root_window()));
+ TimedEvents tes;
+
+ delegate->Reset();
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
+ kTouchId, tes.Now());
+
+ delegate->set_consume_touch_move(false);
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
+ delegate->set_consume_touch_move(true);
+ delegate->Reset();
+ // Move the touch-point enough so that it would normally be considered a
+ // scroll. But since the touch-moves will be consumed, the scroll should not
+ // start.
+ tes.SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get());
+ EXPECT_FALSE(delegate->tap());
+ EXPECT_FALSE(delegate->tap_down());
+ EXPECT_TRUE(delegate->tap_cancel());
+ EXPECT_FALSE(delegate->begin());
+ EXPECT_FALSE(delegate->scroll_begin());
+ EXPECT_FALSE(delegate->scroll_update());
+ EXPECT_FALSE(delegate->scroll_end());
+}
+
} // namespace test
} // namespace aura
diff --git a/chromium/ui/aura/remote_root_window_host_win.cc b/chromium/ui/aura/remote_root_window_host_win.cc
index f5dc26bff55..9d5cb8cf93a 100644
--- a/chromium/ui/aura/remote_root_window_host_win.cc
+++ b/chromium/ui/aura/remote_root_window_host_win.cc
@@ -15,8 +15,8 @@
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/root_window.h"
#include "ui/base/cursor/cursor_loader_win.h"
-#include "ui/base/events/event_utils.h"
-#include "ui/base/keycodes/keyboard_code_conversion_win.h"
+#include "ui/events/event_utils.h"
+#include "ui/events/keycodes/keyboard_code_conversion_win.h"
#include "ui/base/view_prop.h"
#include "ui/gfx/insets.h"
#include "ui/metro_viewer/metro_viewer_messages.h"
@@ -108,33 +108,39 @@ void HandleSelectFolder(const base::string16& title,
RemoteRootWindowHostWin* g_instance = NULL;
RemoteRootWindowHostWin* RemoteRootWindowHostWin::Instance() {
- return g_instance;
+ if (g_instance)
+ return g_instance;
+ return Create(gfx::Rect());
}
RemoteRootWindowHostWin* RemoteRootWindowHostWin::Create(
const gfx::Rect& bounds) {
- g_instance = new RemoteRootWindowHostWin(bounds);
+ g_instance = g_instance ? g_instance : new RemoteRootWindowHostWin(bounds);
return g_instance;
}
RemoteRootWindowHostWin::RemoteRootWindowHostWin(const gfx::Rect& bounds)
- : delegate_(NULL),
+ : remote_window_(NULL),
+ delegate_(NULL),
host_(NULL),
ignore_mouse_moves_until_set_cursor_ack_(false) {
prop_.reset(new ui::ViewProp(NULL, kRootWindowHostWinKey, this));
}
RemoteRootWindowHostWin::~RemoteRootWindowHostWin() {
+ g_instance = NULL;
}
-void RemoteRootWindowHostWin::Connected(IPC::Sender* host) {
+void RemoteRootWindowHostWin::Connected(IPC::Sender* host, HWND remote_window) {
CHECK(host_ == NULL);
host_ = host;
+ remote_window_ = remote_window;
}
void RemoteRootWindowHostWin::Disconnected() {
CHECK(host_ != NULL);
host_ = NULL;
+ remote_window_ = NULL;
}
bool RemoteRootWindowHostWin::OnMessageReceived(const IPC::Message& message) {
@@ -161,8 +167,6 @@ bool RemoteRootWindowHostWin::OnMessageReceived(const IPC::Message& message) {
OnMultiFileOpenDone)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SelectFolderDone,
OnSelectFolderDone)
- IPC_MESSAGE_HANDLER(MetroViewerHostMsg_WindowActivated,
- OnWindowActivated)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursorPosAck,
OnSetCursorPosAck)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_WindowSizeChanged,
@@ -172,6 +176,14 @@ bool RemoteRootWindowHostWin::OnMessageReceived(const IPC::Message& message) {
return handled;
}
+void RemoteRootWindowHostWin::HandleOpenURLOnDesktop(
+ const base::FilePath& shortcut,
+ const base::string16& url) {
+ if (!host_)
+ return;
+ host_->Send(new MetroViewerHostMsg_OpenURLOnDesktop(shortcut, url));
+}
+
void RemoteRootWindowHostWin::HandleOpenFile(
const base::string16& title,
const base::FilePath& default_path,
@@ -271,10 +283,9 @@ RootWindow* RemoteRootWindowHostWin::GetRootWindow() {
}
gfx::AcceleratedWidget RemoteRootWindowHostWin::GetAcceleratedWidget() {
- // TODO(cpu): This is bad. Chrome's compositor needs a valid window
- // initially and then later on we swap it. Since the compositor never
- // uses this initial window we tell ourselves this hack is ok to get
- // thing off the ground.
+ if (remote_window_)
+ return remote_window_;
+ // Getting here should only happen for ash_unittests.exe and related code.
return ::GetDesktopWindow();
}
@@ -339,13 +350,6 @@ bool RemoteRootWindowHostWin::ConfineCursorToRootWindow() {
return true;
}
-bool RemoteRootWindowHostWin::CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
- const gfx::Point& dest_offset,
- SkCanvas* canvas) {
- NOTIMPLEMENTED();
- return false;
-}
-
void RemoteRootWindowHostWin::UnConfineCursor() {
}
@@ -538,10 +542,6 @@ void RemoteRootWindowHostWin::OnSelectFolderDone(
failure_callback_.Reset();
}
-void RemoteRootWindowHostWin::OnWindowActivated(bool active) {
- active ? GetRootWindow()->Focus() : GetRootWindow()->Blur();
-}
-
void RemoteRootWindowHostWin::OnSetCursorPosAck() {
DCHECK(ignore_mouse_moves_until_set_cursor_ack_);
ignore_mouse_moves_until_set_cursor_ack_ = false;
diff --git a/chromium/ui/aura/remote_root_window_host_win.h b/chromium/ui/aura/remote_root_window_host_win.h
index 132f0f236f0..e92a5add625 100644
--- a/chromium/ui/aura/remote_root_window_host_win.h
+++ b/chromium/ui/aura/remote_root_window_host_win.h
@@ -11,8 +11,8 @@
#include "base/compiler_specific.h"
#include "base/strings/string16.h"
#include "ui/aura/root_window_host.h"
-#include "ui/base/events/event.h"
-#include "ui/base/events/event_constants.h"
+#include "ui/events/event.h"
+#include "ui/events/event_constants.h"
#include "ui/gfx/native_widget_types.h"
namespace base {
@@ -86,18 +86,24 @@ AURA_EXPORT void HandleSelectFolder(const base::string16& title,
// frontend process, which forwards input events to this class.
class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost {
public:
+ // Returns the only RemoteRootWindowHostWin, if this is the first time
+ // this function is called, it will call Create() wiht empty bounds.
static RemoteRootWindowHostWin* Instance();
static RemoteRootWindowHostWin* Create(const gfx::Rect& bounds);
// Called when the remote process has established its IPC connection.
- // The |host| can be used when we need to send a message to it.
- void Connected(IPC::Sender* host);
+ // The |host| can be used when we need to send a message to it and
+ // |remote_window| is the actual window owned by the viewer process.
+ void Connected(IPC::Sender* host, HWND remote_window);
// Called when the remote process has closed its IPC connection.
void Disconnected();
// Called when we have a message from the remote process.
bool OnMessageReceived(const IPC::Message& message);
+ void HandleOpenURLOnDesktop(const base::FilePath& shortcut,
+ const base::string16& url);
+
void HandleOpenFile(const base::string16& title,
const base::FilePath& default_path,
const base::string16& filter,
@@ -159,7 +165,6 @@ class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost {
void OnMultiFileOpenDone(bool success,
const std::vector<base::FilePath>& files);
void OnSelectFolderDone(bool success, const base::FilePath& folder);
- void OnWindowActivated(bool active);
void OnSetCursorPosAck();
void OnWindowSizeChanged(uint32 width, uint32 height);
@@ -184,9 +189,6 @@ class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost {
virtual void OnCursorVisibilityChanged(bool show) OVERRIDE;
virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE;
- virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
- const gfx::Point& dest_offset,
- SkCanvas* canvas) OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void PrepareForShutdown() OVERRIDE;
@@ -203,6 +205,7 @@ class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost {
uint32 flags,
bool is_character);
+ HWND remote_window_;
RootWindowHostDelegate* delegate_;
IPC::Sender* host_;
scoped_ptr<ui::ViewProp> prop_;
diff --git a/chromium/ui/aura/root_window.cc b/chromium/ui/aura/root_window.cc
index 43366f001aa..303ec90f18e 100644
--- a/chromium/ui/aura/root_window.cc
+++ b/chromium/ui/aura/root_window.cc
@@ -6,7 +6,6 @@
#include <vector>
-#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/debug/trace_event.h"
@@ -25,7 +24,6 @@
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_tracker.h"
-#include "ui/base/events/event.h"
#include "ui/base/gestures/gesture_recognizer.h"
#include "ui/base/gestures/gesture_types.h"
#include "ui/base/hit_test.h"
@@ -34,6 +32,7 @@
#include "ui/compositor/dip_util.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animator.h"
+#include "ui/events/event.h"
#include "ui/gfx/display.h"
#include "ui/gfx/point3_f.h"
#include "ui/gfx/point_conversions.h"
@@ -149,7 +148,6 @@ RootWindow::RootWindow(const CreateParams& params)
last_cursor_(ui::kCursorNull),
mouse_pressed_handler_(NULL),
mouse_moved_handler_(NULL),
- mouse_event_dispatch_target_(NULL),
event_dispatch_target_(NULL),
gesture_recognizer_(ui::GestureRecognizer::Create(this)),
synthesize_mouse_move_(false),
@@ -171,6 +169,8 @@ RootWindow::RootWindow(const CreateParams& params)
}
RootWindow::~RootWindow() {
+ TRACE_EVENT0("shutdown", "RootWindow::Destructor");
+
compositor_->RemoveObserver(this);
// Make sure to destroy the compositor before terminating so that state is
// cleared and we don't hit asserts.
@@ -216,6 +216,8 @@ void RootWindow::PrepareForShutdown() {
}
void RootWindow::RepostEvent(const ui::LocatedEvent& event) {
+ DCHECK(event.type() == ui::ET_MOUSE_PRESSED ||
+ event.type() == ui::ET_GESTURE_TAP_DOWN);
// We allow for only one outstanding repostable event. This is used
// in exiting context menus. A dropped repost request is allowed.
if (event.type() == ui::ET_MOUSE_PRESSED) {
@@ -231,7 +233,8 @@ void RootWindow::RepostEvent(const ui::LocatedEvent& event) {
} else {
DCHECK(event.type() == ui::ET_GESTURE_TAP_DOWN);
held_repostable_event_.reset();
- // TODO(sschmitz): add similar code for gesture events.
+ // TODO(rbyers): Reposing of gestures is tricky to get
+ // right, so it's not yet supported. crbug.com/170987.
}
}
@@ -276,6 +279,13 @@ void RootWindow::SetCursor(gfx::NativeCursor cursor) {
}
void RootWindow::OnCursorVisibilityChanged(bool show) {
+ // Clear any existing mouse hover effects when the cursor becomes invisible.
+ // Note we do not need to dispatch a mouse enter when the cursor becomes
+ // visible because that can only happen in response to a mouse event, which
+ // will trigger its own mouse enter.
+ if (!show)
+ DispatchMouseExitAtPoint(GetLastMouseLocationInRoot());
+
host_->OnCursorVisibilityChanged(show);
}
@@ -378,13 +388,13 @@ void RootWindow::DispatchMouseExitToHidingWindow(Window* window) {
// |window| is the capture window.
gfx::Point last_mouse_location = GetLastMouseLocationInRoot();
if (window->Contains(mouse_moved_handler_) &&
- window->ContainsPointInRoot(last_mouse_location)) {
- ui::MouseEvent event(ui::ET_MOUSE_EXITED,
- last_mouse_location,
- last_mouse_location,
- ui::EF_NONE);
- DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED);
- }
+ window->ContainsPointInRoot(last_mouse_location))
+ DispatchMouseExitAtPoint(last_mouse_location);
+}
+
+void RootWindow::DispatchMouseExitAtPoint(const gfx::Point& point) {
+ ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EF_NONE);
+ DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED);
}
void RootWindow::OnWindowVisibilityChanged(Window* window, bool is_visible) {
@@ -422,9 +432,7 @@ void RootWindow::RemoveRootWindowObserver(RootWindowObserver* observer) {
}
void RootWindow::PostNativeEvent(const base::NativeEvent& native_event) {
-#if !defined(OS_MACOSX)
host_->PostNativeEvent(native_event);
-#endif
}
void RootWindow::ConvertPointToNativeScreen(gfx::Point* point) const {
@@ -441,13 +449,13 @@ void RootWindow::ConvertPointFromNativeScreen(gfx::Point* point) const {
void RootWindow::ConvertPointToHost(gfx::Point* point) const {
gfx::Point3F point_3f(*point);
- GetRootTransform().TransformPoint(point_3f);
+ GetRootTransform().TransformPoint(&point_3f);
*point = gfx::ToFlooredPoint(point_3f.AsPointF());
}
void RootWindow::ConvertPointFromHost(gfx::Point* point) const {
gfx::Point3F point_3f(*point);
- GetInverseRootTransform().TransformPoint(point_3f);
+ GetInverseRootTransform().TransformPoint(&point_3f);
*point = gfx::ToFlooredPoint(point_3f.AsPointF());
}
@@ -499,15 +507,6 @@ void RootWindow::SetFocusWhenShown(bool focused) {
host_->SetFocusWhenShown(focused);
}
-bool RootWindow::CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
- const gfx::Point& dest_offset,
- SkCanvas* canvas) {
- DCHECK(canvas);
- DCHECK(bounds().Contains(source_bounds));
- gfx::Rect source_pixels = ui::ConvertRectToPixel(layer(), source_bounds);
- return host_->CopyAreaToSkCanvas(source_pixels, dest_offset, canvas);
-}
-
gfx::Point RootWindow::GetLastMouseLocationInRoot() const {
gfx::Point location = Env::GetInstance()->last_mouse_location();
client::ScreenPositionClient* client = client::GetScreenPositionClient(this);
@@ -654,6 +653,14 @@ bool RootWindow::CanReceiveEvents() const {
void RootWindow::UpdateCapture(Window* old_capture,
Window* new_capture) {
+ if (!new_capture && old_capture && old_capture->GetRootWindow() != this) {
+ // If we no longer contain the window that had capture make sure we clean
+ // state in the GestureRecognizer. Since we don't contain the window we'll
+ // never get notification of its destruction and clean up state.
+ // We do this early on as OnCaptureLost() may delete |old_capture|.
+ gesture_recognizer_->CleanupStateForConsumer(old_capture);
+ }
+
if (old_capture && old_capture->GetRootWindow() == this &&
old_capture->delegate()) {
// Send a capture changed event with bogus location data.
@@ -674,9 +681,8 @@ void RootWindow::UpdateCapture(Window* old_capture,
}
if (new_capture) {
- // Make all subsequent mouse events and touch go to the capture window. We
- // shouldn't need to send an event here as OnCaptureLost should take care of
- // that.
+ // Make all subsequent mouse events go to the capture window. We shouldn't
+ // need to send an event here as OnCaptureLost() should take care of that.
if (mouse_moved_handler_ || Env::GetInstance()->is_mouse_button_down())
mouse_moved_handler_ = new_capture;
} else {
@@ -698,12 +704,6 @@ bool RootWindow::QueryMouseLocationForTest(gfx::Point* point) const {
return host_->QueryMouseLocation(point);
}
-void RootWindow::ClearMouseHandlers() {
- mouse_pressed_handler_ = NULL;
- mouse_moved_handler_ = NULL;
- mouse_event_dispatch_target_ = NULL;
-}
-
////////////////////////////////////////////////////////////////////////////////
// RootWindow, private:
@@ -724,22 +724,6 @@ void RootWindow::MoveCursorToInternal(const gfx::Point& root_location,
synthesize_mouse_move_ = false;
}
-void RootWindow::HandleMouseMoved(const ui::MouseEvent& event, Window* target) {
- if (target == mouse_moved_handler_)
- return;
-
- DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED);
-
- if (mouse_event_dispatch_target_ != target) {
- mouse_moved_handler_ = NULL;
- return;
- }
-
- mouse_moved_handler_ = target;
-
- DispatchMouseEnterOrExit(event, ui::ET_MOUSE_ENTERED);
-}
-
void RootWindow::DispatchMouseEnterOrExit(const ui::MouseEvent& event,
ui::EventType type) {
if (!mouse_moved_handler_ || !mouse_moved_handler_->delegate())
@@ -825,15 +809,13 @@ void RootWindow::OnWindowHidden(Window* invisible, WindowHiddenReason reason) {
mouse_pressed_handler_ = NULL;
if (invisible->Contains(mouse_moved_handler_))
mouse_moved_handler_ = NULL;
- if (invisible->Contains(mouse_event_dispatch_target_))
- mouse_event_dispatch_target_ = NULL;
CleanupGestureRecognizerState(invisible);
}
void RootWindow::CleanupGestureRecognizerState(Window* window) {
gesture_recognizer_->CleanupStateForConsumer(window);
- Windows windows = window->children();
+ const Windows& windows = window->children();
for (Windows::const_iterator iter = windows.begin();
iter != windows.end();
++iter) {
@@ -973,7 +955,8 @@ void RootWindow::OnHostLostWindowCapture() {
}
void RootWindow::OnHostLostMouseGrab() {
- ClearMouseHandlers();
+ mouse_pressed_handler_ = NULL;
+ mouse_moved_handler_ = NULL;
}
void RootWindow::OnHostPaint(const gfx::Rect& damage_rect) {
@@ -1038,21 +1021,46 @@ bool RootWindow::DispatchMouseEventToTarget(ui::MouseEvent* event,
ui::EF_LEFT_MOUSE_BUTTON |
ui::EF_MIDDLE_MOUSE_BUTTON |
ui::EF_RIGHT_MOUSE_BUTTON;
- base::AutoReset<Window*> reset(&mouse_event_dispatch_target_, target);
+ // WARNING: because of nested message loops |this| may be deleted after
+ // dispatching any event. Do not use AutoReset or the like here.
+ WindowTracker destroyed_tracker;
+ destroyed_tracker.Add(this);
SetLastMouseLocation(this, event->location());
synthesize_mouse_move_ = false;
switch (event->type()) {
case ui::ET_MOUSE_EXITED:
if (!target) {
DispatchMouseEnterOrExit(*event, ui::ET_MOUSE_EXITED);
+ if (!destroyed_tracker.Contains(this))
+ return false;
mouse_moved_handler_ = NULL;
}
break;
case ui::ET_MOUSE_MOVED:
- mouse_event_dispatch_target_ = target;
- HandleMouseMoved(*event, target);
- if (mouse_event_dispatch_target_ != target)
- return false;
+ // Send an exit to the current |mouse_moved_handler_| and an enter to
+ // |target|. Take care that both us and |target| aren't destroyed during
+ // dispatch.
+ if (target != mouse_moved_handler_) {
+ aura::Window* old_mouse_moved_handler = mouse_moved_handler_;
+ if (target)
+ destroyed_tracker.Add(target);
+ DispatchMouseEnterOrExit(*event, ui::ET_MOUSE_EXITED);
+ if (!destroyed_tracker.Contains(this))
+ return false;
+ // If the |mouse_moved_handler_| changes out from under us, assume a
+ // nested message loop ran and we don't need to do anything.
+ if (mouse_moved_handler_ != old_mouse_moved_handler)
+ return false;
+ if (destroyed_tracker.Contains(target)) {
+ destroyed_tracker.Remove(target);
+ mouse_moved_handler_ = target;
+ DispatchMouseEnterOrExit(*event, ui::ET_MOUSE_ENTERED);
+ if (!destroyed_tracker.Contains(this))
+ return false;
+ } else {
+ mouse_moved_handler_ = NULL;
+ }
+ }
break;
case ui::ET_MOUSE_PRESSED:
// Don't set the mouse pressed handler for non client mouse down events.
@@ -1072,14 +1080,19 @@ bool RootWindow::DispatchMouseEventToTarget(ui::MouseEvent* event,
default:
break;
}
+ bool result;
if (target) {
event->ConvertLocationToTarget(static_cast<Window*>(this), target);
if (IsNonClientLocation(target, event->location()))
event->set_flags(event->flags() | ui::EF_IS_NON_CLIENT);
ProcessEvent(target, event);
- return event->handled();
+ if (!destroyed_tracker.Contains(this))
+ return false;
+ result = event->handled();
+ } else {
+ result = false;
}
- return false;
+ return result;
}
bool RootWindow::DispatchTouchEventImpl(ui::TouchEvent* event) {
@@ -1153,11 +1166,11 @@ void RootWindow::DispatchHeldEvents() {
if (held_repostable_event_->type() == ui::ET_MOUSE_PRESSED) {
ui::MouseEvent mouse_event(
static_cast<const ui::MouseEvent&>(*held_repostable_event_.get()));
- held_repostable_event_.reset(); // must be reset before dispatch
+ held_repostable_event_.reset(); // must be reset before dispatch
DispatchMouseEventRepost(&mouse_event);
} else {
- DCHECK(held_repostable_event_->type() == ui::ET_GESTURE_TAP_DOWN);
- // TODO(sschmitz): add similar code for gesture events
+ // TODO(rbyers): GESTURE_TAP_DOWN not yet supported: crbug.com/170987.
+ NOTREACHED();
}
held_repostable_event_.reset();
}
diff --git a/chromium/ui/aura/root_window.h b/chromium/ui/aura/root_window.h
index e8a6b260f85..10ce2d507bf 100644
--- a/chromium/ui/aura/root_window.h
+++ b/chromium/ui/aura/root_window.h
@@ -18,19 +18,17 @@
#include "ui/aura/root_window_host_delegate.h"
#include "ui/aura/window.h"
#include "ui/base/cursor/cursor.h"
-#include "ui/base/events/event_constants.h"
-#include "ui/base/events/event_dispatcher.h"
#include "ui/base/gestures/gesture_recognizer.h"
#include "ui/base/gestures/gesture_types.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/compositor_observer.h"
#include "ui/compositor/layer_animation_observer.h"
+#include "ui/events/event_constants.h"
+#include "ui/events/event_dispatcher.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/point.h"
#include "ui/gfx/transform.h"
-class SkCanvas;
-
namespace gfx {
class Size;
class Transform;
@@ -86,6 +84,7 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
ui::Compositor* compositor() { return compositor_.get(); }
gfx::NativeCursor last_cursor() const { return last_cursor_; }
Window* mouse_pressed_handler() { return mouse_pressed_handler_; }
+ Window* mouse_moved_handler() { return mouse_moved_handler_; }
// Initializes the root window.
void Init();
@@ -100,6 +99,8 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
void PrepareForShutdown();
// Repost event for re-processing. Used when exiting context menus.
+ // We only support the ET_MOUSE_PRESSED and ET_GESTURE_TAP_DOWN event
+ // types (although the latter is currently a no-op).
void RepostEvent(const ui::LocatedEvent& event);
RootWindowHostDelegate* AsRootWindowHostDelegate();
@@ -162,6 +163,9 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
// Dispatches OnMouseExited to the |window| which is hiding if nessessary.
void DispatchMouseExitToHidingWindow(Window* window);
+ // Dispatches a ui::ET_MOUSE_EXITED event at |point|.
+ void DispatchMouseExitAtPoint(const gfx::Point& point);
+
// Invoked when |window|'s visibility has changed.
void OnWindowVisibilityChanged(Window* window, bool is_visible);
@@ -239,12 +243,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
// Sets if the window should be focused when shown.
void SetFocusWhenShown(bool focus_when_shown);
- // Copies |source_bounds| from the root window (as displayed on the host
- // machine) to |canvas| at offset |dest_offset|.
- bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
- const gfx::Point& dest_offset,
- SkCanvas* canvas);
-
// Gets the last location seen in a mouse event in this root window's
// coordinates. This may return a point outside the root window's bounds.
gfx::Point GetLastMouseLocationInRoot() const;
@@ -286,10 +284,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
// Exposes RootWindowHost::QueryMouseLocation() for test purposes.
bool QueryMouseLocationForTest(gfx::Point* point) const;
- // Clears internal mouse state (such as mouse ups should be sent to the same
- // window that ate mouse downs).
- void ClearMouseHandlers();
-
void SetRootWindowTransformer(scoped_ptr<RootWindowTransformer> transformer);
gfx::Transform GetRootTransform() const;
@@ -319,10 +313,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
void MoveCursorToInternal(const gfx::Point& root_location,
const gfx::Point& host_location);
- // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|,
- // sending exited and entered events as its value changes.
- void HandleMouseMoved(const ui::MouseEvent& event, Window* target);
-
// Dispatches the specified event type (intended for enter/exit) to the
// |mouse_moved_handler_|.
void DispatchMouseEnterOrExit(const ui::MouseEvent& event,
@@ -426,7 +416,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
Window* mouse_pressed_handler_;
Window* mouse_moved_handler_;
- Window* mouse_event_dispatch_target_;
Window* event_dispatch_target_;
// The gesture_recognizer_ for this.
diff --git a/chromium/ui/aura/root_window_host.h b/chromium/ui/aura/root_window_host.h
index 09e48fad817..0528ae179a1 100644
--- a/chromium/ui/aura/root_window_host.h
+++ b/chromium/ui/aura/root_window_host.h
@@ -12,8 +12,6 @@
#include "ui/base/cursor/cursor.h"
#include "ui/gfx/native_widget_types.h"
-class SkCanvas;
-
namespace gfx {
class Insets;
class Point;
@@ -99,17 +97,8 @@ class AURA_EXPORT RootWindowHost {
// Sets if the window should be focused when shown.
virtual void SetFocusWhenShown(bool focus_when_shown) = 0;
- // Copies |source_bounds| from the root window (as displayed on the host
- // machine) to |canvas| at offset |dest_offset|. The bounds need to be in
- // physical pixels.
- virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
- const gfx::Point& dest_offset,
- SkCanvas* canvas) = 0;
-
// Posts |native_event| to the platform's event queue.
-#if !defined(OS_MACOSX)
virtual void PostNativeEvent(const base::NativeEvent& native_event) = 0;
-#endif
// Called when the device scale factor of the root window has chagned.
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) = 0;
diff --git a/chromium/ui/aura/root_window_host_mac.h b/chromium/ui/aura/root_window_host_mac.h
deleted file mode 100644
index e7c26c35482..00000000000
--- a/chromium/ui/aura/root_window_host_mac.h
+++ /dev/null
@@ -1,29 +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_AURA_ROOT_WINDOW_HOST_MAC_H_
-#define UI_AURA_ROOT_WINDOW_HOST_MAC_H_
-
-#include "base/basictypes.h"
-#include "base/event_types.h"
-
-namespace aura {
-
-// An interface establishing event dispatch from the Mac native window and the
-// Aura host.
-class RootWindowHostMacDelegate {
- public:
- RootWindowHostMacDelegate();
- virtual ~RootWindowHostMacDelegate();
-
- // Route events from platform code to the RootWindowHost.
- virtual void SendEvent(const base::NativeEvent& native_event) = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RootWindowHostMacDelegate);
-};
-
-} // namespace aura
-
-#endif // UI_AURA_ROOT_WINDOW_HOST_MAC_H_
diff --git a/chromium/ui/aura/root_window_host_mac.mm b/chromium/ui/aura/root_window_host_mac.mm
deleted file mode 100644
index 28943a958f9..00000000000
--- a/chromium/ui/aura/root_window_host_mac.mm
+++ /dev/null
@@ -1,218 +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/aura/root_window_host_mac.h"
-
-#import <Cocoa/Cocoa.h>
-
-#include "base/compiler_specific.h"
-#include "base/mac/bundle_locations.h"
-#include "base/mac/scoped_nsobject.h"
-#include "ui/aura/event.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/root_window_host.h"
-#include "ui/aura/root_window_mac.h"
-#include "ui/aura/root_window_view_mac.h"
-#include "ui/base/events/event_utils.h"
-#include "ui/gfx/point.h"
-
-namespace aura {
-
-// The Mac-specific implementation of the RootWindowHost interface. This class
-// acts at an intermediary between the Aura shell and an NSWindow. The
-// association between the Aura compositor and the native window's view is
-// established with this class as is the association between the native window's
-// event dispatch and the Aura event processing.
-class RootWindowHostMac : public RootWindowHost,
- public RootWindowHostMacDelegate {
- public:
- explicit RootWindowHostMac(const gfx::Rect& bounds);
- virtual ~RootWindowHostMac();
-
- // RootWindowHost:
- virtual void SetRootWindow(RootWindow* root_window) OVERRIDE;
- virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
- virtual void Show() OVERRIDE;
- virtual void ToggleFullScreen() OVERRIDE;
- virtual gfx::Size GetSize() const OVERRIDE;
- virtual void SetSize(const gfx::Size& size) OVERRIDE;
- virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
- virtual void SetCapture() OVERRIDE;
- virtual void ReleaseCapture() OVERRIDE;
- virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE;
- virtual void ShowCursor(bool show) OVERRIDE;
- virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
- virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
- virtual bool ConfineCursorToRootWindow() OVERRIDE;
- virtual void UnConfineCursor() OVERRIDE;
- virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
- const gfx::Point& dest_offset,
- SkCanvas* canvas) OVERRIDE;
- // RootWindowHostMacDelegate:
- virtual void SendEvent(const base::NativeEvent& native_event) OVERRIDE;
-
- // Set the initial location of the root window. The origin of |bounds| is
- // top-left. This gets converted to bottom-left to match Mac coordinates on
- // the main screen.
- void SetLocation(const gfx::Rect& bounds);
-
- private:
- // Weak reference.
- RootWindow* root_window_;
-
- // The bounds of the Aura desktop. Relative to Aura's coordinate system.
- // This is currently used only for size information, not location.
- gfx::Rect bounds_;
-
- // An NSWindowController for the root window. Controls the actual Cocoa
- // window on Mac.
- base::scoped_nsobject<NSWindowController> controller_;
-
- DISALLOW_COPY_AND_ASSIGN(RootWindowHostMac);
-};
-
-RootWindowHostMacDelegate::RootWindowHostMacDelegate() {
-}
-
-RootWindowHostMacDelegate::~RootWindowHostMacDelegate() {
-}
-
-RootWindowHostMac::RootWindowHostMac(const gfx::Rect& bounds)
- : root_window_(NULL), bounds_(bounds) {
- NSString* nibpath = [base::mac::FrameworkBundle()
- pathForResource:@"RootWindow"
- ofType:@"nib"];
- NSWindowController* controller = [NSWindowController alloc];
- controller_.reset([controller initWithWindowNibPath:nibpath
- owner:controller]);
- SetSize(bounds.size());
- SetLocation(bounds);
-}
-
-RootWindowHostMac::~RootWindowHostMac() {
- RootWindowView* view = [[controller_ window] contentView];
- [view setCompositor:NULL];
- [controller_ close];
-}
-
-// static
-RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
- return new RootWindowHostMac(bounds);
-}
-
-// static
-gfx::Size RootWindowHost::GetNativeScreenSize() {
- NSRect screen = [[NSScreen mainScreen] visibleFrame];
- return gfx::Size(NSSizeToCGSize(screen.size));
-}
-
-void RootWindowHostMac::SetRootWindow(RootWindow* root_window) {
- root_window_ = root_window;
-
- RootWindowView* view = [[controller_ window] contentView];
- DCHECK([view respondsToSelector:@selector(setCompositor:)]);
- [view setCompositor:root_window->compositor()];
-
- RootWindowMac* window = static_cast<RootWindowMac*>([controller_ window]);
- DCHECK([window respondsToSelector:@selector(setHostDelegate:)]);
- [window setHostDelegate:this];
-}
-
-gfx::AcceleratedWidget RootWindowHostMac::GetAcceleratedWidget() {
- return [[controller_ window] contentView];
-}
-
-void RootWindowHostMac::Show() {
- [controller_ showWindow:controller_];
-}
-
-void RootWindowHostMac::ToggleFullScreen() {
-}
-
-gfx::Size RootWindowHostMac::GetSize() const {
- NSSize size = [[[controller_ window] contentView] bounds].size;
- return gfx::Size(NSSizeToCGSize(size));
-}
-
-void RootWindowHostMac::SetSize(const gfx::Size& size) {
- NSSize nssize = NSSizeFromCGSize(size.ToCGSize());
- [[controller_ window] setContentSize:nssize];
- [[controller_ window] setContentMaxSize:nssize];
- [[controller_ window] setContentMinSize:nssize];
-}
-
-gfx::Point RootWindowHostMac::GetLocationOnNativeScreen() const {
- return gfx::Point();
-}
-
-void RootWindowHostMac::SetCapture() {
-}
-
-void RootWindowHostMac::ReleaseCapture() {
-}
-
-void RootWindowHostMac::SetCursor(gfx::NativeCursor cursor) {
-}
-
-void RootWindowHostMac::ShowCursor(bool show) {
-}
-
-bool RootWindowHostMac::QueryMouseLocation(gfx::Point* location_return) {
- *location_return = gfx::Point();
- return true;
-}
-
-void RootWindowHostMac::MoveCursorTo(const gfx::Point& location) {
-}
-
-bool RootWindowHostMac::ConfineCursorToRootWindow() {
- return false;
-}
-
-void RootWindowHostMac::UnConfineCursor() {
-}
-
-void RootWindowHostMac::SendEvent(const base::NativeEvent& native_event) {
- ui::EventType type = ui::EventTypeFromNative(native_event);
- switch (type) {
- case ui::ET_MOUSE_PRESSED:
- case ui::ET_MOUSE_DRAGGED:
- case ui::ET_MOUSE_RELEASED:
- case ui::ET_MOUSE_MOVED:
- case ui::ET_MOUSE_ENTERED:
- case ui::ET_MOUSE_EXITED: {
- MouseEvent mouse_event(native_event);
- root_window_->DispatchMouseEvent(&mouse_event);
- break;
- }
- case ui::ET_KEY_PRESSED:
- case ui::ET_KEY_RELEASED: {
- KeyEvent key_event(native_event, false);
- root_window_->DispatchKeyEvent(&key_event);
- break;
- }
- case ui::ET_MOUSEWHEEL:
- case ui::ET_TOUCH_RELEASED:
- case ui::ET_TOUCH_PRESSED:
- case ui::ET_TOUCH_MOVED:
- case ui::ET_TOUCH_STATIONARY:
- case ui::ET_TOUCH_CANCELLED:
- case ui::ET_DROP_TARGET_EVENT:
- case ui::ET_FOCUS_CHANGE:
- case ui::ET_SCROLL:
- case ui::ET_UNKNOWN:
- default:
- break;
- }
-}
-
-void RootWindowHostMac::SetLocation(const gfx::Rect& bounds) {
- NSRect screen = [[NSScreen mainScreen] visibleFrame];
- NSPoint origin = NSMakePoint(screen.origin.x + bounds.x(),
- screen.origin.y + screen.size.height -
- bounds.y() - bounds.height());
- [[controller_ window] setFrameOrigin:origin];
-}
-
-} // namespace aura
diff --git a/chromium/ui/aura/root_window_host_ozone.cc b/chromium/ui/aura/root_window_host_ozone.cc
index 28c8d0c4807..3af82898e79 100644
--- a/chromium/ui/aura/root_window_host_ozone.cc
+++ b/chromium/ui/aura/root_window_host_ozone.cc
@@ -5,7 +5,7 @@
#include "ui/aura/root_window_host_ozone.h"
#include "ui/aura/root_window.h"
-#include "ui/base/ozone/surface_factory_ozone.h"
+#include "ui/gfx/ozone/surface_factory_ozone.h"
namespace aura {
@@ -15,8 +15,8 @@ RootWindowHostOzone::RootWindowHostOzone(const gfx::Rect& bounds)
bounds_(bounds),
factory_(new ui::EventFactoryOzone()) {
factory_->CreateStartupEventConverters();
- ui::SurfaceFactoryOzone* surface_factory =
- ui::SurfaceFactoryOzone::GetInstance();
+ gfx::SurfaceFactoryOzone* surface_factory =
+ gfx::SurfaceFactoryOzone::GetInstance();
widget_ = surface_factory->GetAcceleratedWidget();
surface_factory->AttemptToResizeAcceleratedWidget(widget_, bounds_);
@@ -106,13 +106,6 @@ void RootWindowHostOzone::SetFocusWhenShown(bool focus_when_shown) {
NOTIMPLEMENTED();
}
-bool RootWindowHostOzone::CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
- const gfx::Point& dest_offset,
- SkCanvas* canvas) {
- NOTIMPLEMENTED();
- return false;
-}
-
void RootWindowHostOzone::PostNativeEvent(
const base::NativeEvent& native_event) {
NOTIMPLEMENTED();
diff --git a/chromium/ui/aura/root_window_host_ozone.h b/chromium/ui/aura/root_window_host_ozone.h
index 6acd1a2c0ce..8be9e484fc3 100644
--- a/chromium/ui/aura/root_window_host_ozone.h
+++ b/chromium/ui/aura/root_window_host_ozone.h
@@ -10,7 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "ui/aura/root_window_host.h"
-#include "ui/base/ozone/event_factory_ozone.h"
+#include "ui/events/ozone/event_factory_ozone.h"
#include "ui/gfx/rect.h"
namespace aura {
@@ -46,9 +46,6 @@ class RootWindowHostOzone : public RootWindowHost,
virtual void OnCursorVisibilityChanged(bool show) OVERRIDE;
virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE;
- virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
- const gfx::Point& dest_offset,
- SkCanvas* canvas) OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void PrepareForShutdown() OVERRIDE;
diff --git a/chromium/ui/aura/root_window_host_win.cc b/chromium/ui/aura/root_window_host_win.cc
index 5c67b776d07..e5658f76447 100644
--- a/chromium/ui/aura/root_window_host_win.cc
+++ b/chromium/ui/aura/root_window_host_win.cc
@@ -13,7 +13,7 @@
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/root_window.h"
#include "ui/base/cursor/cursor_loader_win.h"
-#include "ui/base/events/event.h"
+#include "ui/events/event.h"
#include "ui/base/view_prop.h"
#include "ui/gfx/display.h"
#include "ui/gfx/insets.h"
@@ -210,13 +210,6 @@ bool RootWindowHostWin::ConfineCursorToRootWindow() {
return ClipCursor(&window_rect) != 0;
}
-bool RootWindowHostWin::CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
- const gfx::Point& dest_offset,
- SkCanvas* canvas) {
- NOTIMPLEMENTED();
- return false;
-}
-
void RootWindowHostWin::UnConfineCursor() {
ClipCursor(NULL);
}
diff --git a/chromium/ui/aura/root_window_host_win.h b/chromium/ui/aura/root_window_host_win.h
index 491ab903445..42c8ada89ca 100644
--- a/chromium/ui/aura/root_window_host_win.h
+++ b/chromium/ui/aura/root_window_host_win.h
@@ -8,11 +8,11 @@
#include "base/compiler_specific.h"
#include "ui/aura/root_window_host.h"
#include "ui/base/ui_export.h"
-#include "ui/base/win/window_impl.h"
+#include "ui/gfx/win/window_impl.h"
namespace aura {
-class RootWindowHostWin : public RootWindowHost, public ui::WindowImpl {
+class RootWindowHostWin : public RootWindowHost, public gfx::WindowImpl {
public:
RootWindowHostWin(const gfx::Rect& bounds);
virtual ~RootWindowHostWin();
@@ -37,9 +37,6 @@ class RootWindowHostWin : public RootWindowHost, public ui::WindowImpl {
virtual void OnCursorVisibilityChanged(bool show) OVERRIDE;
virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE;
- virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
- const gfx::Point& dest_offset,
- SkCanvas* canvas) OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void PrepareForShutdown() OVERRIDE;
diff --git a/chromium/ui/aura/root_window_host_x11.cc b/chromium/ui/aura/root_window_host_x11.cc
index f69a54a8898..abf1da06b9d 100644
--- a/chromium/ui/aura/root_window_host_x11.cc
+++ b/chromium/ui/aura/root_window_host_x11.cc
@@ -20,14 +20,11 @@
#include "base/command_line.h"
#include "base/debug/trace_event.h"
#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_pump_aurax11.h"
+#include "base/message_loop/message_pump_x11.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "third_party/skia/include/core/SkCanvas.h"
-#include "third_party/skia/include/core/SkPostConfig.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/screen_position_client.h"
@@ -35,9 +32,6 @@
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/base/cursor/cursor.h"
-#include "ui/base/events/event.h"
-#include "ui/base/events/event_utils.h"
-#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/base/touch/touch_factory_x11.h"
#include "ui/base/ui_base_switches.h"
#include "ui/base/view_prop.h"
@@ -45,7 +39,9 @@
#include "ui/base/x/x11_util.h"
#include "ui/compositor/dip_util.h"
#include "ui/compositor/layer.h"
-#include "ui/gfx/codec/png_codec.h"
+#include "ui/events/event.h"
+#include "ui/events/event_utils.h"
+#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/screen.h"
#if defined(OS_CHROMEOS)
@@ -91,7 +87,7 @@ bool IsSideBezelsEnabled() {
#endif
void SelectEventsForRootWindow() {
- Display* display = ui::GetXDisplay();
+ XDisplay* display = gfx::GetXDisplay();
::Window root_window = ui::GetX11RootWindow();
// Receive resize events for the root-window so |x_root_bounds_| can be
@@ -367,7 +363,7 @@ class RootWindowHostX11::MouseMoveFilter {
RootWindowHostX11::RootWindowHostX11(const gfx::Rect& bounds)
: delegate_(NULL),
- xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()),
+ xdisplay_(gfx::GetXDisplay()),
xwindow_(0),
x_root_window_(DefaultRootWindow(xdisplay_)),
current_cursor_(ui::kCursorNull),
@@ -377,7 +373,8 @@ RootWindowHostX11::RootWindowHostX11(const gfx::Rect& bounds)
focus_when_shown_(false),
touch_calibrate_(new internal::TouchEventCalibrate),
mouse_move_filter_(new MouseMoveFilter),
- atom_cache_(xdisplay_, kAtomsToCache) {
+ atom_cache_(xdisplay_, kAtomsToCache),
+ bezel_tracking_ids_(0) {
XSetWindowAttributes swa;
memset(&swa, 0, sizeof(swa));
swa.background_pixmap = None;
@@ -391,8 +388,8 @@ RootWindowHostX11::RootWindowHostX11(const gfx::Rect& bounds)
CopyFromParent, // visual
CWBackPixmap | CWOverrideRedirect,
&swa);
- base::MessagePumpAuraX11::Current()->AddDispatcherForWindow(this, xwindow_);
- base::MessagePumpAuraX11::Current()->AddDispatcherForRootWindow(this);
+ base::MessagePumpX11::Current()->AddDispatcherForWindow(this, xwindow_);
+ base::MessagePumpX11::Current()->AddDispatcherForRootWindow(this);
long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask |
KeyPressMask | KeyReleaseMask |
@@ -443,8 +440,8 @@ RootWindowHostX11::RootWindowHostX11(const gfx::Rect& bounds)
RootWindowHostX11::~RootWindowHostX11() {
Env::GetInstance()->RemoveObserver(this);
- base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow(this);
- base::MessagePumpAuraX11::Current()->RemoveDispatcherForWindow(xwindow_);
+ base::MessagePumpX11::Current()->RemoveDispatcherForRootWindow(this);
+ base::MessagePumpX11::Current()->RemoveDispatcherForWindow(xwindow_);
UnConfineCursor();
@@ -633,7 +630,7 @@ void RootWindowHostX11::Show() {
// We now block until our window is mapped. Some X11 APIs will crash and
// burn if passed |xwindow_| before the window is mapped, and XMapWindow is
// asynchronous.
- base::MessagePumpAuraX11::Current()->BlockUntilWindowMapped(xwindow_);
+ base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_);
window_mapped_ = true;
}
}
@@ -819,51 +816,6 @@ void RootWindowHostX11::SetFocusWhenShown(bool focus_when_shown) {
}
}
-bool RootWindowHostX11::CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
- const gfx::Point& dest_offset,
- SkCanvas* canvas) {
- ui::XScopedImage scoped_image(
- XGetImage(xdisplay_, xwindow_,
- source_bounds.x(), source_bounds.y(),
- source_bounds.width(), source_bounds.height(),
- AllPlanes, ZPixmap));
- XImage* image = scoped_image.get();
- if (!image) {
- LOG(ERROR) << "XGetImage failed";
- return false;
- }
-
- if (image->bits_per_pixel == 32) {
- if ((0xff << SK_R32_SHIFT) != image->red_mask ||
- (0xff << SK_G32_SHIFT) != image->green_mask ||
- (0xff << SK_B32_SHIFT) != image->blue_mask) {
- LOG(WARNING) << "XImage and Skia byte orders differ";
- return false;
- }
-
- // Set the alpha channel before copying to the canvas. Otherwise, areas of
- // the framebuffer that were cleared by ply-image rather than being obscured
- // by an image during boot may end up transparent.
- // TODO(derat|marcheu): Remove this if/when ply-image has been updated to
- // set the framebuffer's alpha channel regardless of whether the device
- // claims to support alpha or not.
- for (int i = 0; i < image->width * image->height * 4; i += 4)
- image->data[i + 3] = 0xff;
-
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config,
- image->width, image->height,
- image->bytes_per_line);
- bitmap.setPixels(image->data);
- canvas->drawBitmap(bitmap, SkIntToScalar(0), SkIntToScalar(0), NULL);
- } else {
- NOTIMPLEMENTED() << "Unsupported bits-per-pixel " << image->bits_per_pixel;
- return false;
- }
-
- return true;
-}
-
void RootWindowHostX11::PostNativeEvent(
const base::NativeEvent& native_event) {
DCHECK(xwindow_);
@@ -902,7 +854,7 @@ void RootWindowHostX11::OnDeviceScaleFactorChanged(
}
void RootWindowHostX11::PrepareForShutdown() {
- base::MessagePumpAuraX11::Current()->RemoveDispatcherForWindow(xwindow_);
+ base::MessagePumpX11::Current()->RemoveDispatcherForWindow(xwindow_);
}
void RootWindowHostX11::OnWindowInitialized(Window* window) {
@@ -961,15 +913,22 @@ void RootWindowHostX11::DispatchXI2Event(const base::NativeEvent& event) {
case ui::ET_TOUCH_PRESSED:
case ui::ET_TOUCH_CANCELLED:
case ui::ET_TOUCH_RELEASED: {
+ ui::TouchEvent touchev(xev);
#if defined(USE_XI2_MT)
- // Ignore events from the bezel when the side bezel flag is not explicitly
- // enabled.
- if (!IsSideBezelsEnabled() &&
- touch_calibrate_->IsEventOnSideBezels(xev, bounds_)) {
- break;
+ // Ignore touch events with touch press happening on the side bezel.
+ if (!IsSideBezelsEnabled()) {
+ uint32 tracking_id = (1 << touchev.touch_id());
+ if (type == ui::ET_TOUCH_PRESSED &&
+ touch_calibrate_->IsEventOnSideBezels(xev, bounds_))
+ bezel_tracking_ids_ |= tracking_id;
+ if (bezel_tracking_ids_ & tracking_id) {
+ if (type == ui::ET_TOUCH_CANCELLED || type == ui::ET_TOUCH_RELEASED)
+ bezel_tracking_ids_ =
+ (bezel_tracking_ids_ | tracking_id) ^ tracking_id;
+ return;
+ }
}
#endif // defined(USE_XI2_MT)
- ui::TouchEvent touchev(xev);
#if defined(OS_CHROMEOS)
if (base::chromeos::IsRunningOnChromeOS()) {
if (!bounds_.Contains(touchev.location()))
@@ -1131,7 +1090,7 @@ RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
// static
gfx::Size RootWindowHost::GetNativeScreenSize() {
- ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay();
+ ::XDisplay* xdisplay = gfx::GetXDisplay();
return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
}
diff --git a/chromium/ui/aura/root_window_host_x11.h b/chromium/ui/aura/root_window_host_x11.h
index c38002dda07..77d97b90efa 100644
--- a/chromium/ui/aura/root_window_host_x11.h
+++ b/chromium/ui/aura/root_window_host_x11.h
@@ -63,9 +63,6 @@ class RootWindowHostX11 : public RootWindowHost,
virtual void OnCursorVisibilityChanged(bool show) OVERRIDE;
virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE;
- virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
- const gfx::Point& dest_offset,
- SkCanvas* canvas) OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void PrepareForShutdown() OVERRIDE;
@@ -106,7 +103,7 @@ class RootWindowHostX11 : public RootWindowHost,
RootWindowHostDelegate* delegate_;
// The display and the native X window hosting the root window.
- Display* xdisplay_;
+ XDisplay* xdisplay_;
::Window xwindow_;
// The native root window.
@@ -141,6 +138,9 @@ class RootWindowHostX11 : public RootWindowHost,
ui::X11AtomCache atom_cache_;
+ // Touch ids of which the touch press happens at side bezel region.
+ uint32 bezel_tracking_ids_;
+
DISALLOW_COPY_AND_ASSIGN(RootWindowHostX11);
};
diff --git a/chromium/ui/aura/root_window_mac.h b/chromium/ui/aura/root_window_mac.h
deleted file mode 100644
index 13a044c21d2..00000000000
--- a/chromium/ui/aura/root_window_mac.h
+++ /dev/null
@@ -1,37 +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_AURA_ROOT_WINDOW_MAC_H_
-#define UI_AURA_ROOT_WINDOW_MAC_H_
-
-#import <Cocoa/Cocoa.h>
-
-namespace aura {
-class RootWindowHostMacDelegate;
-} // aura
-
-// RootWindow routes NSWindow events back to the RootWindowHost for dispatch
-// to the Aura event handling system.
-@interface RootWindowMac : NSWindow {
- @private
- // Weak. May be NULL. The host delegate acts as a conduit for event routing
- // back to the host.
- aura::RootWindowHostMacDelegate* hostDelegate_;
-}
-
-// Designated initializer.
-- (id)initWithContentRect:(NSRect)contentRect
- styleMask:(NSUInteger)windowStyle
- backing:(NSBackingStoreType)bufferingType
- defer:(BOOL)deferCreation;
-
-// Sets the |hostDelegate_|
-- (void)setHostDelegate:(aura::RootWindowHostMacDelegate*)hostDelegate;
-
-// Overrides main event dispatch to route NSWindow events to host delegate.
-- (void)sendEvent:(NSEvent*)event;
-
-@end
-
-#endif // UI_AURA_ROOT_WINDOW_MAC_H_
diff --git a/chromium/ui/aura/root_window_mac.mm b/chromium/ui/aura/root_window_mac.mm
deleted file mode 100644
index 32e42b7ad9d..00000000000
--- a/chromium/ui/aura/root_window_mac.mm
+++ /dev/null
@@ -1,35 +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.
-
-#import "ui/aura/root_window_mac.h"
-
-#include "ui/aura/root_window_host_mac.h"
-
-@implementation RootWindowMac
-
-- (id)initWithContentRect:(NSRect)contentRect
- styleMask:(NSUInteger)windowStyle
- backing:(NSBackingStoreType)bufferingType
- defer:(BOOL)deferCreation {
- if ((self = [super initWithContentRect:contentRect
- styleMask:windowStyle
- backing:bufferingType
- defer:deferCreation])) {
- hostDelegate_ = NULL;
- }
- return self;
-}
-
-- (void)setHostDelegate:(aura::RootWindowHostMacDelegate*)hostDelegate {
- hostDelegate_ = hostDelegate;
-}
-
-- (void)sendEvent:(NSEvent*)event {
- // Allow both the Cocoa machinery and the Aura machinery to handle the event.
- [super sendEvent:event];
- if (hostDelegate_)
- hostDelegate_->SendEvent(event);
-}
-
-@end
diff --git a/chromium/ui/aura/root_window_unittest.cc b/chromium/ui/aura/root_window_unittest.cc
index 739de66811f..652562b2604 100644
--- a/chromium/ui/aura/root_window_unittest.cc
+++ b/chromium/ui/aura/root_window_unittest.cc
@@ -17,12 +17,12 @@
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window_tracker.h"
-#include "ui/base/events/event.h"
-#include "ui/base/events/event_handler.h"
-#include "ui/base/events/event_utils.h"
#include "ui/base/gestures/gesture_configuration.h"
#include "ui/base/hit_test.h"
-#include "ui/base/keycodes/keyboard_codes.h"
+#include "ui/events/event.h"
+#include "ui/events/event_handler.h"
+#include "ui/events/event_utils.h"
+#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/screen.h"
@@ -402,11 +402,15 @@ namespace {
class EventFilterRecorder : public ui::EventHandler {
public:
typedef std::vector<ui::EventType> Events;
+ typedef std::vector<gfx::Point> MouseEventLocations;
EventFilterRecorder() {}
Events& events() { return events_; }
+ MouseEventLocations& mouse_locations() { return mouse_locations_; }
+ gfx::Point mouse_location(int i) const { return mouse_locations_[i]; }
+
// ui::EventHandler overrides:
virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE {
events_.push_back(event->type());
@@ -414,6 +418,7 @@ class EventFilterRecorder : public ui::EventHandler {
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
events_.push_back(event->type());
+ mouse_locations_.push_back(event->location());
}
virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE {
@@ -430,6 +435,7 @@ class EventFilterRecorder : public ui::EventHandler {
private:
Events events_;
+ MouseEventLocations mouse_locations_;
DISALLOW_COPY_AND_ASSIGN(EventFilterRecorder);
};
@@ -679,6 +685,41 @@ TEST_F(RootWindowTest, DispatchSyntheticMouseEvents) {
EXPECT_TRUE(filter->events().empty());
}
+// Tests that a mouse exit is dispatched to the last known cursor location
+// when the cursor becomes invisible.
+TEST_F(RootWindowTest, DispatchMouseExitWhenCursorHidden) {
+ EventFilterRecorder* filter = new EventFilterRecorder;
+ root_window()->SetEventFilter(filter); // passes ownership
+
+ test::TestWindowDelegate delegate;
+ gfx::Point window_origin(7, 18);
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
+ &delegate, 1234, gfx::Rect(window_origin,
+ gfx::Size(100, 100)), root_window()));
+ window->Show();
+
+ // Dispatch a mouse move event into the window.
+ gfx::Point mouse_location(gfx::Point(15, 25));
+ ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, mouse_location,
+ mouse_location, 0);
+ EXPECT_TRUE(filter->events().empty());
+ root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse1);
+ EXPECT_FALSE(filter->events().empty());
+ filter->events().clear();
+
+ // Hide the cursor and verify a mouse exit was dispatched.
+ root_window()->OnCursorVisibilityChanged(false);
+ EXPECT_FALSE(filter->events().empty());
+ EXPECT_EQ("MOUSE_EXITED", EventTypesToString(filter->events()));
+
+ // Verify the mouse exit was dispatched at the correct location
+ // (in the correct coordinate space).
+ int translated_x = mouse_location.x() - window_origin.x();
+ int translated_y = mouse_location.y() - window_origin.y();
+ gfx::Point translated_point(translated_x, translated_y);
+ EXPECT_EQ(filter->mouse_location(0).ToString(), translated_point.ToString());
+}
+
class DeletingEventFilter : public ui::EventHandler {
public:
DeletingEventFilter()
@@ -882,4 +923,132 @@ TEST_F(RootWindowTest, GestureEndDeliveredAfterNestedGestures) {
EXPECT_EQ(1, d2.gesture_end_count());
}
+// Tests whether we can repost the Tap down gesture event.
+TEST_F(RootWindowTest, RepostTapdownGestureTest) {
+ EventFilterRecorder* filter = new EventFilterRecorder;
+ root_window()->SetEventFilter(filter); // passes ownership
+
+ test::TestWindowDelegate delegate;
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
+ &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window()));
+
+ ui::GestureEventDetails details(ui::ET_GESTURE_TAP_DOWN, 0.0f, 0.0f);
+ gfx::Point point(10, 10);
+ ui::GestureEvent event(
+ ui::ET_GESTURE_TAP_DOWN,
+ point.x(),
+ point.y(),
+ 0,
+ ui::EventTimeForNow(),
+ details,
+ 0);
+ root_window()->RepostEvent(event);
+ RunAllPendingInMessageLoop();
+ // TODO(rbyers): Currently disabled - crbug.com/170987
+ EXPECT_FALSE(EventTypesToString(filter->events()).find("GESTURE_TAP_DOWN") !=
+ std::string::npos);
+ filter->events().clear();
+}
+
+// This class inherits from the EventFilterRecorder class which provides a
+// facility to record events. This class additionally provides a facility to
+// repost the ET_GESTURE_TAP_DOWN gesture to the target window and records
+// events after that.
+class RepostGestureEventRecorder : public EventFilterRecorder {
+ public:
+ RepostGestureEventRecorder(aura::Window* repost_source,
+ aura::Window* repost_target)
+ : repost_source_(repost_source),
+ repost_target_(repost_target),
+ reposted_(false) {}
+
+ virtual ~RepostGestureEventRecorder() {}
+
+ virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
+ EXPECT_EQ(reposted_ ? repost_target_ : repost_source_, event->target());
+ if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
+ if (!reposted_) {
+ EXPECT_NE(repost_target_, event->target());
+ reposted_ = true;
+ events().clear();
+ repost_target_->GetRootWindow()->RepostEvent(*event);
+ // Ensure that the reposted gesture event above goes to the
+ // repost_target_;
+ repost_source_->GetRootWindow()->RemoveChild(repost_source_);
+ return;
+ }
+ }
+ EventFilterRecorder::OnGestureEvent(event);
+ }
+
+ // Ignore mouse events as they don't fire at all times. This causes
+ // the GestureRepostEventOrder test to fail randomly.
+ virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {}
+
+ private:
+ aura::Window* repost_source_;
+ aura::Window* repost_target_;
+ // set to true if we reposted the ET_GESTURE_TAP_DOWN event.
+ bool reposted_;
+ DISALLOW_COPY_AND_ASSIGN(RepostGestureEventRecorder);
+};
+
+// Tests whether events which are generated after the reposted gesture event
+// are received after that. In this case the scroll sequence events should
+// be received after the reposted gesture event.
+TEST_F(RootWindowTest, GestureRepostEventOrder) {
+ // Expected events at the end for the repost_target window defined below.
+ const char kExpectedTargetEvents[] =
+ // TODO)(rbyers): Gesture event reposting is disabled - crbug.com/279039.
+ // "GESTURE_BEGIN GESTURE_TAP_DOWN "
+ "TOUCH_RELEASED TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED "
+ " GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE TOUCH_MOVED "
+ "GESTURE_SCROLL_UPDATE TOUCH_MOVED GESTURE_SCROLL_UPDATE TOUCH_RELEASED "
+ "GESTURE_SCROLL_END GESTURE_END";
+ // We create two windows.
+ // The first window (repost_source) is the one to which the initial tap
+ // gesture is sent. It reposts this event to the second window
+ // (repost_target).
+ // We then generate the scroll sequence for repost_target and look for two
+ // ET_GESTURE_TAP_DOWN events in the event list at the end.
+ test::TestWindowDelegate delegate;
+ scoped_ptr<aura::Window> repost_target(CreateTestWindowWithDelegate(
+ &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window()));
+
+ scoped_ptr<aura::Window> repost_source(CreateTestWindowWithDelegate(
+ &delegate, 1, gfx::Rect(0, 0, 50, 50), root_window()));
+
+ RepostGestureEventRecorder* repost_event_recorder =
+ new RepostGestureEventRecorder(repost_source.get(), repost_target.get());
+ root_window()->SetEventFilter(repost_event_recorder); // passes ownership
+
+ // Generate a tap down gesture for the repost_source. This will be reposted
+ // to repost_target.
+ test::EventGenerator repost_generator(root_window(), repost_source.get());
+ repost_generator.GestureTapAt(gfx::Point(40, 40));
+ RunAllPendingInMessageLoop();
+
+ test::EventGenerator scroll_generator(root_window(), repost_target.get());
+ scroll_generator.GestureScrollSequence(
+ gfx::Point(80, 80),
+ gfx::Point(100, 100),
+ base::TimeDelta::FromMilliseconds(100),
+ 3);
+ RunAllPendingInMessageLoop();
+
+ int tap_down_count = 0;
+ for (size_t i = 0; i < repost_event_recorder->events().size(); ++i) {
+ if (repost_event_recorder->events()[i] == ui::ET_GESTURE_TAP_DOWN)
+ ++tap_down_count;
+ }
+
+ // We expect two tap down events. One from the repost and the other one from
+ // the scroll sequence posted above.
+ // TODO(rbyers): Currently disabled - crbug.com/170987
+ EXPECT_EQ(1, tap_down_count);
+
+ EXPECT_EQ(kExpectedTargetEvents,
+ EventTypesToString(repost_event_recorder->events()));
+}
+
} // namespace aura
diff --git a/chromium/ui/aura/root_window_view_mac.h b/chromium/ui/aura/root_window_view_mac.h
deleted file mode 100644
index 6617f36dad9..00000000000
--- a/chromium/ui/aura/root_window_view_mac.h
+++ /dev/null
@@ -1,21 +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_AURA_ROOT_WINDOW_VIEW_MAC_H_
-#define UI_AURA_ROOT_WINDOW_VIEW_MAC_H_
-
-#import <Cocoa/Cocoa.h>
-
-#include "ui/compositor/compositor.h"
-
-// RootWindowView provides an NSView class that delegates drawing to a
-// ui::Compositor delegate, setting up the NSOpenGLContext as required.
-@interface RootWindowView : NSView {
- @private
- ui::Compositor* compositor_;
-}
--(void)setCompositor:(ui::Compositor*)compositor;
-@end
-
-#endif // UI_AURA_ROOT_WINDOW_VIEW_MAC_H_
diff --git a/chromium/ui/aura/root_window_view_mac.mm b/chromium/ui/aura/root_window_view_mac.mm
deleted file mode 100644
index a82100e8434..00000000000
--- a/chromium/ui/aura/root_window_view_mac.mm
+++ /dev/null
@@ -1,16 +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.
-
-#import "ui/aura/root_window_view_mac.h"
-
-@implementation RootWindowView
--(void)setCompositor:(ui::Compositor*)compositor {
- compositor_ = compositor;
-}
-
-- (void)drawRect:(NSRect)rect {
- if (compositor_)
- compositor_->Draw(false);
-}
-@end
diff --git a/chromium/ui/aura/window.cc b/chromium/ui/aura/window.cc
index e5289e46a29..b14048287c6 100644
--- a/chromium/ui/aura/window.cc
+++ b/chromium/ui/aura/window.cc
@@ -25,24 +25,15 @@
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_tracker.h"
-#include "ui/base/animation/multi_animation.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
+#include "ui/gfx/animation/multi_animation.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/path.h"
#include "ui/gfx/screen.h"
namespace aura {
-namespace {
-
-void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory,
- unsigned sync_point, bool lost_resource) {
- // NOTE: shared_memory will get released when we go out of scope.
-}
-
-} // namespace
-
Window::Window(WindowDelegate* delegate)
: type_(client::WINDOW_TYPE_UNKNOWN),
owned_by_parent_(true),
@@ -154,12 +145,6 @@ ui::Layer* Window::RecreateLayer() {
return NULL;
old_layer->set_delegate(NULL);
- float mailbox_scale_factor;
- cc::TextureMailbox old_mailbox =
- old_layer->GetTextureMailbox(&mailbox_scale_factor);
- scoped_refptr<ui::Texture> old_texture = old_layer->external_texture();
- if (delegate_ && old_texture.get())
- old_layer->SetExternalTexture(delegate_->CopyTexture().get());
layer_ = new ui::Layer(old_layer->type());
layer_owner_.reset(layer_);
@@ -167,29 +152,9 @@ ui::Layer* Window::RecreateLayer() {
layer_->set_scale_content(old_layer->scale_content());
layer_->set_delegate(this);
layer_->SetMasksToBounds(old_layer->GetMasksToBounds());
- // Move the original texture to the new layer if the old layer has a
- // texture and we could copy it into the old layer,
- // crbug.com/175211.
- if (delegate_ && old_texture.get()) {
- layer_->SetExternalTexture(old_texture.get());
- } else if (old_mailbox.IsSharedMemory()) {
- base::SharedMemory* old_buffer = old_mailbox.shared_memory();
- const size_t size = old_mailbox.shared_memory_size_in_bytes();
-
- scoped_ptr<base::SharedMemory> new_buffer(new base::SharedMemory);
- new_buffer->CreateAndMapAnonymous(size);
-
- if (old_buffer->memory() && new_buffer->memory()) {
- memcpy(new_buffer->memory(), old_buffer->memory(), size);
- base::SharedMemory* new_buffer_raw_ptr = new_buffer.get();
- cc::TextureMailbox::ReleaseCallback callback =
- base::Bind(MailboxReleaseCallback, Passed(&new_buffer));
- cc::TextureMailbox new_mailbox(new_buffer_raw_ptr,
- old_mailbox.shared_memory_size(),
- callback);
- layer_->SetTextureMailbox(new_mailbox, mailbox_scale_factor);
- }
- }
+
+ if (delegate_)
+ delegate_->DidRecreateLayer(old_layer, layer_);
UpdateLayerName(name_);
layer_->SetFillsBoundsOpaquely(!transparent_);
@@ -224,9 +189,9 @@ void Window::SetName(const std::string& name) {
}
void Window::SetTransparent(bool transparent) {
- // Cannot change transparent flag after the window is initialized.
- DCHECK(!layer());
transparent_ = transparent;
+ if (layer())
+ layer_->SetFillsBoundsOpaquely(!transparent_);
}
RootWindow* Window::GetRootWindow() {
diff --git a/chromium/ui/aura/window.h b/chromium/ui/aura/window.h
index 92dfa90b9c4..3ed7ca5cdff 100644
--- a/chromium/ui/aura/window.h
+++ b/chromium/ui/aura/window.h
@@ -17,13 +17,13 @@
#include "ui/aura/aura_export.h"
#include "ui/aura/client/window_types.h"
#include "ui/aura/window_observer.h"
-#include "ui/base/events/event_constants.h"
-#include "ui/base/events/event_target.h"
#include "ui/base/gestures/gesture_types.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/layer_delegate.h"
#include "ui/compositor/layer_owner.h"
#include "ui/compositor/layer_type.h"
+#include "ui/events/event_constants.h"
+#include "ui/events/event_target.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/rect.h"
diff --git a/chromium/ui/aura/window_delegate.h b/chromium/ui/aura/window_delegate.h
index bcbd2a6984c..ff941ef95b3 100644
--- a/chromium/ui/aura/window_delegate.h
+++ b/chromium/ui/aura/window_delegate.h
@@ -8,8 +8,8 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "ui/aura/aura_export.h"
-#include "ui/base/events/event_constants.h"
-#include "ui/base/events/event_handler.h"
+#include "ui/events/event_constants.h"
+#include "ui/events/event_handler.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
@@ -23,6 +23,7 @@ class Size;
namespace ui {
class GestureEvent;
class KeyEvent;
+class Layer;
class MouseEvent;
class Texture;
class TouchEvent;
@@ -95,9 +96,12 @@ class AURA_EXPORT WindowDelegate : public ui::EventHandler {
// above returns true.
virtual void GetHitTestMask(gfx::Path* mask) const = 0;
- // Called from RecreateLayer() if the layer the window is associated with has
- // an external texture.
- virtual scoped_refptr<ui::Texture> CopyTexture() = 0;
+ // Called from RecreateLayer() after the new layer was created. old_layer is
+ // the layer that will be returned to the caller of RecreateLayer, new_layer
+ // will be the layer now used on the Window. The implementation only has to do
+ // anything if the layer has external content (SetExternalTexture /
+ // SetTextureMailbox / SetDelegatedFrame was called).
+ virtual void DidRecreateLayer(ui::Layer* old_layer, ui::Layer* new_layer) = 0;
protected:
virtual ~WindowDelegate() {}
diff --git a/chromium/ui/aura/window_unittest.cc b/chromium/ui/aura/window_unittest.cc
index 320d1a61f7b..c37eb833cc9 100644
--- a/chromium/ui/aura/window_unittest.cc
+++ b/chromium/ui/aura/window_unittest.cc
@@ -27,15 +27,15 @@
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_property.h"
-#include "ui/base/events/event.h"
-#include "ui/base/events/event_utils.h"
#include "ui/base/gestures/gesture_configuration.h"
#include "ui/base/hit_test.h"
-#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/compositor/test/test_layers.h"
+#include "ui/events/event.h"
+#include "ui/events/event_utils.h"
+#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/screen.h"
@@ -1780,7 +1780,7 @@ TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) {
EXPECT_FALSE(!w1->layer());
w1->layer()->GetAnimator()->set_disable_timer_for_test(true);
- ui::AnimationContainerElement* element = w1->layer()->GetAnimator();
+ gfx::AnimationContainerElement* element = w1->layer()->GetAnimator();
EXPECT_EQ("0,0 100x100", w1->bounds().ToString());
EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString());
@@ -2740,7 +2740,7 @@ TEST_F(WindowTest, DelegateNotifiedAsBoundsChange) {
// Animate to the end, which should notify of the change.
base::TimeTicks start_time =
window->layer()->GetAnimator()->last_step_time();
- ui::AnimationContainerElement* element = window->layer()->GetAnimator();
+ gfx::AnimationContainerElement* element = window->layer()->GetAnimator();
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
EXPECT_TRUE(delegate.bounds_changed());
EXPECT_NE("0,0 100x100", window->bounds().ToString());
@@ -2782,7 +2782,7 @@ TEST_F(WindowTest, DelegateNotifiedAsBoundsChangeInHiddenLayer) {
// Animate to the end: will *not* notify of the change since we are hidden.
base::TimeTicks start_time =
window->layer()->GetAnimator()->last_step_time();
- ui::AnimationContainerElement* element = window->layer()->GetAnimator();
+ gfx::AnimationContainerElement* element = window->layer()->GetAnimator();
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
// No bounds changed notification at the end of animation since layer