display: Mouse exit from the old display when switching displays
When switching from a window tree host to another, mouse should exit the old window tree host otherwise some effects on the old display will never exit such as hovering. BUG=298548104 Change-Id: I2045d2b21a79f5fa3826337cfdb0876c3e303e74 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6336772 Commit-Queue: Yichen Zhou <yichenz@chromium.org> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org> Cr-Commit-Position: refs/heads/main@{#1429869}
This commit is contained in:
@ -10,9 +10,11 @@
|
||||
#include "ash/display/display_util.h"
|
||||
#include "ash/display/shared_display_edge_indicator.h"
|
||||
#include "ash/display/window_tree_host_manager.h"
|
||||
#include "ash/host/ash_window_tree_host.h"
|
||||
#include "ash/root_window_controller.h"
|
||||
#include "ash/shell.h"
|
||||
#include "ui/aura/window.h"
|
||||
#include "ui/aura/window_event_dispatcher.h"
|
||||
#include "ui/display/display_layout.h"
|
||||
#include "ui/display/manager/display_manager.h"
|
||||
#include "ui/display/manager/util/display_manager_util.h"
|
||||
@ -192,9 +194,14 @@ bool ExtendedMouseWarpController::WarpMouseCursorInNativeCoords(
|
||||
// The mouse must move.
|
||||
aura::Window* dst_window = Shell::GetRootWindowForDisplayId(
|
||||
in_a_edge ? warp->b_display_id_ : warp->a_display_id_);
|
||||
aura::Window* src_window = Shell::GetRootWindowForDisplayId(
|
||||
in_a_edge ? warp->a_display_id_ : warp->b_display_id_);
|
||||
AshWindowTreeHost* target_ash_host =
|
||||
RootWindowController::ForWindow(dst_window)->ash_host();
|
||||
AshWindowTreeHost* src_ash_host =
|
||||
RootWindowController::ForWindow(src_window)->ash_host();
|
||||
|
||||
src_ash_host->AsWindowTreeHost()->dispatcher()->OnHostCursorExit();
|
||||
MoveCursorTo(target_ash_host, point_in_screen, update_mouse_location_now);
|
||||
return true;
|
||||
}
|
||||
|
@ -267,6 +267,16 @@ void WindowEventDispatcher::OnCursorMovedToRootLocation(
|
||||
PostSynthesizeMouseMove(window());
|
||||
}
|
||||
|
||||
void WindowEventDispatcher::OnHostCursorExit() {
|
||||
auto details =
|
||||
DispatchMouseExitAtPoint(window(), GetLastMouseLocationInRoot());
|
||||
if (details.dispatcher_destroyed) {
|
||||
return;
|
||||
}
|
||||
mouse_pressed_handler_ = nullptr;
|
||||
mouse_moved_handler_ = nullptr;
|
||||
}
|
||||
|
||||
void WindowEventDispatcher::OnPostNotifiedWindowDestroying(Window* window) {
|
||||
OnWindowHidden(window, WINDOW_DESTROYED);
|
||||
}
|
||||
|
@ -130,6 +130,9 @@ class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor,
|
||||
void OnHostLostMouseGrab();
|
||||
void OnCursorMovedToRootLocation(const gfx::Point& root_location);
|
||||
|
||||
// Invoked when mouse exit the underlying window tree host.
|
||||
void OnHostCursorExit();
|
||||
|
||||
// TODO(beng): This is only needed because this cleanup needs to happen after
|
||||
// all other observers are notified of OnWindowDestroying() but
|
||||
// before OnWindowDestroyed() is sent (i.e. while the window
|
||||
|
Reference in New Issue
Block a user