Commit 84b41dc9 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

window-service: don't do a grab when in unified mode

Classic ash doesn't do grabs when in unified mode. For compatibility
this patch makes the window-service not execute a grab when in unified
mode. To execute a grab leads to ash doing the wrong event conversion.

BUG=804460,773348
TEST=covered by test

Change-Id: I6d402ec4eb5d68946f98757cc4a56e850bd1e8b0
Reviewed-on: https://chromium-review.googlesource.com/884569
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531828}
parent 1cc93c3a
......@@ -304,7 +304,7 @@ const Display* DisplayManager::GetDisplayContaining(
return nullptr;
}
Display* DisplayManager::GetDisplayById(int64_t display_id) {
const Display* DisplayManager::GetDisplayById(int64_t display_id) const {
for (Display* display : displays_) {
if (display->GetId() == display_id)
return display;
......@@ -333,6 +333,10 @@ WindowManagerDisplayRoot* DisplayManager::GetWindowManagerDisplayRoot(
window));
}
bool DisplayManager::InUnifiedDisplayMode() const {
return GetDisplayById(display::kUnifiedDisplayId) != nullptr;
}
WindowId DisplayManager::GetAndAdvanceNextRootId() {
// TODO(sky): handle wrapping!
const uint16_t id = next_root_id_++;
......
......@@ -89,7 +89,11 @@ class DisplayManager : public UserIdTrackerObserver,
// Returns the display with the specified display id, or null if there is no
// display with that id.
Display* GetDisplayById(int64_t display_id);
const Display* GetDisplayById(int64_t display_id) const;
Display* GetDisplayById(int64_t display_id) {
return const_cast<Display*>(
const_cast<const DisplayManager*>(this)->GetDisplayById(display_id));
}
const WindowManagerDisplayRoot* GetWindowManagerDisplayRoot(
const ServerWindow* window) const;
......@@ -104,6 +108,8 @@ class DisplayManager : public UserIdTrackerObserver,
return !displays_.empty() || !pending_displays_.empty();
}
bool InUnifiedDisplayMode() const;
// Returns the id for the next root window (both for the root of a Display
// as well as the root of WindowManagers).
WindowId GetAndAdvanceNextRootId();
......
......@@ -727,8 +727,12 @@ void TestPlatformDisplay::Init(PlatformDisplayDelegate* delegate) {
}
void TestPlatformDisplay::SetViewportSize(const gfx::Size& size) {}
void TestPlatformDisplay::SetTitle(const base::string16& title) {}
void TestPlatformDisplay::SetCapture() {}
void TestPlatformDisplay::ReleaseCapture() {}
void TestPlatformDisplay::SetCapture() {
has_capture_ = true;
}
void TestPlatformDisplay::ReleaseCapture() {
has_capture_ = false;
}
void TestPlatformDisplay::SetCursor(const ui::CursorData& cursor) {
*cursor_storage_ = cursor;
}
......
......@@ -809,6 +809,8 @@ class TestPlatformDisplay : public PlatformDisplay {
const display::ViewportMetrics& metrics() const { return metrics_; }
bool has_capture() const { return has_capture_; }
// PlatformDisplay:
void Init(PlatformDisplayDelegate* delegate) override;
void SetViewportSize(const gfx::Size& size) override;
......@@ -836,6 +838,7 @@ class TestPlatformDisplay : public PlatformDisplay {
display::Display::Rotation::ROTATE_0;
float cursor_scale_ = 1.0f;
gfx::Rect confine_cursor_bounds_;
bool has_capture_ = false;
DISALLOW_COPY_AND_ASSIGN(TestPlatformDisplay);
};
......
......@@ -730,6 +730,12 @@ ServerWindow* WindowManagerState::GetFocusedWindowForEventDispatcher(
void WindowManagerState::SetNativeCapture(ServerWindow* window) {
DCHECK(window);
DCHECK(IsActive());
// Classic ash expects no native grab when in unified display.
// See http://crbug.com/773348 for details.
if (display_manager()->InUnifiedDisplayMode())
return;
WindowManagerDisplayRoot* display_root =
display_manager()->GetWindowManagerDisplayRoot(window);
DCHECK(display_root);
......@@ -738,6 +744,11 @@ void WindowManagerState::SetNativeCapture(ServerWindow* window) {
}
void WindowManagerState::ReleaseNativeCapture() {
// Classic ash expects no native grab when in unified display.
// See http://crbug.com/773348 for details.
if (display_manager()->InUnifiedDisplayMode())
return;
// Tests trigger calling this without a corresponding SetNativeCapture().
// TODO(sky): maybe abstract this away so that DCHECK can be added?
if (!platform_display_with_capture_)
......
......@@ -839,6 +839,27 @@ TEST_F(WindowManagerStateTest, CursorLocationManagerUpdatedOnMouseMove) {
.current_cursor_location()));
}
TEST_F(WindowManagerStateTest, SetCapture) {
ASSERT_EQ(1u, window_server()->display_manager()->displays().size());
Display* display = *(window_server()->display_manager()->displays().begin());
TestPlatformDisplay* platform_display =
static_cast<TestPlatformDisplay*>(display->platform_display());
EXPECT_TRUE(window_tree()->SetCapture(FirstRootId(window_tree())));
EXPECT_EQ(FirstRoot(window_tree()), window_manager_state()->capture_window());
EXPECT_TRUE(platform_display->has_capture());
EXPECT_TRUE(window_tree()->ReleaseCapture(FirstRootId(window_tree())));
EXPECT_FALSE(platform_display->has_capture());
// In unified mode capture should not propagate to the PlatformDisplay. This
// is for compatibility with classic ash. See http://crbug.com/773348.
display->SetDisplay(display::Display(display::kUnifiedDisplayId));
EXPECT_TRUE(window_tree()->SetCapture(FirstRootId(window_tree())));
EXPECT_EQ(FirstRoot(window_tree()), window_manager_state()->capture_window());
EXPECT_FALSE(platform_display->has_capture());
EXPECT_TRUE(window_tree()->ReleaseCapture(FirstRootId(window_tree())));
EXPECT_FALSE(platform_display->has_capture());
}
TEST_F(WindowManagerStateTestAsync, CursorResetOverNoTargetAsync) {
ASSERT_EQ(1u, window_server()->display_manager()->displays().size());
const ClientWindowId child_window_id(window_tree()->id(), 11);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment