New issue
Advanced search Search tips

Issue 773348 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug

Blocking:
issue 726470



Sign in to add a comment

Inconsistent window grab behavior between Unified Desktop Mode and Extended Display Mode

Project Member Reported by afakhry@chromium.org, Oct 10 2017

Issue description

This bug is relevant to X11WindowOzone when running the Linux ChromeOS build. Let's assume you ran it using the following command-line arg to create 4 displays:

--ash-host-window-bounds=10+10-400x400,+430+10-400x400,+850+10-400x400,+1270+10-400x400

[ display 1 ] [ display 2 ] [ display 3 ] [ display 4 ] 

* Try dragging a window from display 4 towards display 3.
* X11WindowOzone::GetBounds() remain the bounds of display 4 until you drop the window.


Now switch to Unified Desktop mode by adding --ash-enable-unified-desktop.

* Try the same thing as above: drag a window from display 4 to display 3.
* Once mouse warps to display 3, X11WindowOzone::GetBounds() will change to display 3's bounds.
* Notice that the window will jump to display 2 or 1 rather than 3.

The above behavior is not what ScreenPositionController::ConvertHostPointToRelativeToRootWindow() [1] expects. This causes the erroneous jump.

Oshima believes this is a regression when we switched from X11 to Ozone.



[1]: https://cs.chromium.org/chromium/src/ash/display/screen_position_controller.cc?q=ScreenPositionController::ConvertHostPointToRelativeToRootWindow&sq=package:chromium&l=22
 
Turns out that the |platform_window_| in WindowTreeHostPlatform is created as a StubWindow by AshWindowTreeHostUnified [1]. The StubWindow does nothing when SetCapture() is called.

Oshima, and Kyle, is that the expected behavior?


[1]: https://cs.chromium.org/chromium/src/ash/host/ash_window_tree_host_unified.cc?type=cs&q=AshWindowTreeHostUnified&l=52

Comment 2 by osh...@chromium.org, Oct 11 2017

That's not the issue. Problem is that passive grab should happen on mirroring window, not on the stub window hosting desktop.

Comment 3 Deleted

There are actually two problems here. If you patch in https://crrev.com/c/705115 then it's a little more obvious. The unified mouse warp controller only supports two displays. I see a lot of this error when running with three or four displays in unified mode.

[139039:139039:1011/093202.049751:ERROR:unified_mouse_warp_controller.cc(123)] Only two displays are supported

After patching in https://crrev.com/c/705115 you can only move between the first and second display.

Luckily, the other problem still exists with only two displays. I'm running with the following command line flags:

--ash-host-window-bounds=10+10-600x600,+660+10-600x600 --ash-enable-unified-desktop

If you start dragging a window from a point on display 2 back and hit the left edge, the mouse warp controller moves the cursor to the rightmost edge of display 1. The window moves as if the cursor is past the leftmost edge of display 1 instead of where the cursor actually is.

The problem is that display 2 still has capture since the mouse hasn't been released. UnifiedMouseWarpController moves the cursor from display 2 to display 1. The mouse event coordinates are still in relation to display 2, so the X coordinate is negative, since display 1 is to the left of display 2. The mouse event gets converted to screen coordinates by MirroringScreenPositionClient which is for the whole unified desktop area. I added a couple log statements seen here.

[145931:145931:1011/100327.379709:ERROR:x11_window_base.cc(257)] MoveCursorTo() 598,48 on 10,28 600x600
[145931:145931:1011/100327.379826:ERROR:mirror_window_controller.cc(66)] MirroringScreenPositionClient::ConvertHostPointToScreen initial_point=-52,46
[145931:145931:1011/100327.379847:ERROR:mirror_window_controller.cc(71)] MirroringScreenPositionClient::ConvertHostPointToScreen converted_point=-52,46

The problem is MirroringScreenPositionClient doesn't take into the different XWindows since everything has the same root aura::Window. I'm not sure how/if the USE_X11 build handled this? I would assume USE_X11 had the same problem, since it's the X11 implicit capture that is causing the problem.

Comment 5 by osh...@chromium.org, Oct 11 2017

> The unified mouse warp controller only supports two displays.

That's what afakhry@ is trying to fix.

> The problem is that display 2 still has capture since the mouse hasn't been released.

Yet, ozone dispatches dispatches event to display 1 because it's relying on explicit capture.

I'm fine to change the behavior, but it has to be consistent between unified and non unified scenario.






> [139039:139039:1011/093202.049751:ERROR:unified_mouse_warp_controller.cc(123)] Only two displays are supported

I fixed this problem as part of this CL: https://chromium-review.googlesource.com/c/chromium/src/+/683094

> The problem is that display 2 still has capture since the mouse hasn't been released...

Does that mean that there is an implicit capture by X11 (which sends the located events relative to display 2), and an explicit capture done by ozone (which doesn't work in this case since it tried to capture the unified stub window, but not the mirroring one)?
On a real device:

   - In non-unified mode, explicit capture works because we forward the SetCapture() call to the DrmWindowHost(), and hence events keeps getting sent to the source display no matter where you are now.

   - In unified mode, since explicit capture doesn't work (because of the stub window), the events are sent to the current display (not the source display), and the |event->location()| is relative to the **current** display as well (no negative coordinates).

Oshima believes that this is the wrong way to implement passive grab, because if SetCapture() ends up being not called (like in the case of unified desktop mirroring hosts), then it won't work.


I have a work-around fix for this that involves using |event->root_location()|, but for a long term solution and to unify the behavior between X11 and ozone, what was the intended behavior when ozone was implemented? (this comment: "For now Ozone works in a similar manner as X11..." [1] makes it sound like ozone was intended to match the behavior of X11).


[1]: https://cs.chromium.org/chromium/src/ash/display/screen_position_controller.cc?type=cs&q=ScreenPositionController::ConvertHostPointToRelativeToRootWindow&l=49
Cc: sadrul@chromium.org
> Does that mean that there is an implicit capture by X11 (which sends the located events relative to display 2), and an explicit capture done by ozone (which doesn't work in this case since it tried to capture the unified stub window, but not the mirroring one)?

Yes I think so. There is explicit capture in X11WindowOzone. This works the same as DrmWindowHost. There is also X11 implicit passive grab that I think is always there? Maybe there is some way to toggle it off.

> what was the intended behavior when ozone was implemented?

I'm not sure what the Ozone DRM intended behaviour was. For Ozone X11 I just tried to make sure that dragging between windows worked correctly and tests passed. I also didn't know unified mode existed at that point. +sadrul who might be able to clarify.
Is there anything actionable needed for this bug?
Me and oshima considered two alternatives.
- Either work around it in the unified desktop case, or
- remove passive grab entirely.

But we decided to do this after we land the Unified Desktop changes.
Cc: kylec...@chromium.org
Owner: ----
Status: Available (was: Assigned)
That sgtm.
Owner: afakhry@chromium.org
Status: Assigned (was: Available)

Comment 13 by sky@chromium.org, Jan 24 2018

Cc: sky@chromium.org
It would be nice if ash was consistent here, which I think means doing a grab on the real display when in unified mode. This way we wouldn't have two possible paths for events. It would also mean you see consistent behavior when running on the desktop (ozone-x11 backend) vs real device (ozone-drm backend).
Cc: msw@chromium.org
Oshima and I agreed before that we should get rid of the grab entirely. We had that for historical reasons when we were dependent on X11. The Ozone implementation simulated the same behavior for no reason. We think it will be better if we remove it completely.

Comment 15 by sky@chromium.org, Jan 24 2018

If you do that, won't you see much different behavior when running on desktop chromeos vs actual device? It seems it would be nice if the two behaved the same.
The goal was to also undo the passive grab done by x11, so the behavior in the end should be the same.
Correction. The grab was fpr old, non ozone x11 impl (it was x11 that is grabbing the input). We can remove grab from both ozone-x11 and ozone-drm and can have consistent behavior on both.

Comment 18 by sky@chromium.org, Jan 25 2018

As long as we are consistent, I'm happy.
Project Member

Comment 19 by bugdroid1@chromium.org, Jan 25 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/84b41dc990a9810ae67a3f6583faadf72422fdb0

commit 84b41dc990a9810ae67a3f6583faadf72422fdb0
Author: Scott Violet <sky@chromium.org>
Date: Thu Jan 25 06:24:57 2018

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: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531828}
[modify] https://crrev.com/84b41dc990a9810ae67a3f6583faadf72422fdb0/services/ui/ws/display_manager.cc
[modify] https://crrev.com/84b41dc990a9810ae67a3f6583faadf72422fdb0/services/ui/ws/display_manager.h
[modify] https://crrev.com/84b41dc990a9810ae67a3f6583faadf72422fdb0/services/ui/ws/test_utils.cc
[modify] https://crrev.com/84b41dc990a9810ae67a3f6583faadf72422fdb0/services/ui/ws/test_utils.h
[modify] https://crrev.com/84b41dc990a9810ae67a3f6583faadf72422fdb0/services/ui/ws/window_manager_state.cc
[modify] https://crrev.com/84b41dc990a9810ae67a3f6583faadf72422fdb0/services/ui/ws/window_manager_state_unittest.cc

Blocking: 726470

Sign in to add a comment