Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Unified Diff: components/mus/ws/window_manager_state.cc

Issue 1883263002: mash: Repost mouse pressed event when closing Ash system tray (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/mus/ws/window_manager_state.h ('k') | components/mus/ws/window_manager_state_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/window_manager_state.cc
diff --git a/components/mus/ws/window_manager_state.cc b/components/mus/ws/window_manager_state.cc
index f383906af0ca6e47959ea7568b1b304f628edd27..ca81c527bffde99fb487cba3d3d822d40e6861c1 100644
--- a/components/mus/ws/window_manager_state.cc
+++ b/components/mus/ws/window_manager_state.cc
@@ -160,7 +160,9 @@ void WindowManagerState::OnWillDestroyTree(WindowTree* tree) {
// The WindowTree is dying. So it's not going to ack the event.
// If the dying tree matches the root |tree_| marked as handled so we don't
// notify it of accelerators.
- OnEventAck(tree_awaiting_input_ack_, tree == tree_);
+ OnEventAck(tree_awaiting_input_ack_, tree == tree_
+ ? mojom::EventResult::HANDLED
+ : mojom::EventResult::UNHANDLED);
}
WindowManagerState::WindowManagerState(Display* display,
@@ -227,7 +229,8 @@ void WindowManagerState::ProcessEvent(const ui::Event& event) {
event_dispatcher_.ProcessEvent(event);
}
-void WindowManagerState::OnEventAck(mojom::WindowTree* tree, bool handled) {
+void WindowManagerState::OnEventAck(mojom::WindowTree* tree,
+ mojom::EventResult result) {
if (tree_awaiting_input_ack_ != tree) {
// TODO(sad): The ack must have arrived after the timeout. We should do
// something here, and in OnEventAckTimeout().
@@ -236,8 +239,19 @@ void WindowManagerState::OnEventAck(mojom::WindowTree* tree, bool handled) {
tree_awaiting_input_ack_ = nullptr;
event_ack_timer_.Stop();
- if (!handled && post_target_accelerator_)
+ if (result == mojom::EventResult::UNHANDLED && post_target_accelerator_) {
OnAccelerator(post_target_accelerator_->id(), *event_awaiting_input_ack_);
+ } else if (result == mojom::EventResult::REPOST) {
+ scoped_ptr<ui::Event> event = ui::Event::Clone(*event_awaiting_input_ack_);
+ // The cached event may have had its location transformed to a window
+ // target. Use its original coordinates when reposting so it can be
+ // transformed to other targets.
+ if (event->IsPointerEvent()) {
+ ui::PointerEvent* pointer_event = event->AsPointerEvent();
+ pointer_event->set_location(pointer_event->root_location());
+ }
+ event_dispatcher_.ProcessEvent(*event);
+ }
ProcessNextEventFromQueue();
}
@@ -249,7 +263,7 @@ WindowServer* WindowManagerState::window_server() {
void WindowManagerState::OnEventAckTimeout() {
// TODO(sad): Figure out what we should do.
NOTIMPLEMENTED() << "Event ACK timed out.";
- OnEventAck(tree_awaiting_input_ack_, false);
+ OnEventAck(tree_awaiting_input_ack_, mojom::EventResult::UNHANDLED);
}
void WindowManagerState::QueueEvent(
@@ -284,12 +298,12 @@ void WindowManagerState::ProcessNextEventFromQueue() {
void WindowManagerState::DispatchInputEventToWindowImpl(
ServerWindow* target,
bool in_nonclient_area,
- const ui::Event& event,
+ const ui::Event& transformed_event,
base::WeakPtr<Accelerator> accelerator) {
if (target == root_->parent())
target = root_.get();
- if (event.IsMousePointerEvent()) {
+ if (transformed_event.IsMousePointerEvent()) {
DCHECK(event_dispatcher_.mouse_cursor_source_window());
display_->UpdateNativeCursor(
event_dispatcher_.mouse_cursor_source_window()->cursor());
@@ -322,11 +336,11 @@ void WindowManagerState::DispatchInputEventToWindowImpl(
&WindowManagerState::OnEventAckTimeout);
tree_awaiting_input_ack_ = tree;
+ event_awaiting_input_ack_ = ui::Event::Clone(transformed_event);
if (accelerator) {
- event_awaiting_input_ack_ = ui::Event::Clone(event);
post_target_accelerator_ = accelerator;
}
- tree->DispatchInputEvent(target, event);
+ tree->DispatchInputEvent(target, transformed_event);
}
void WindowManagerState::OnAccelerator(uint32_t accelerator_id,
@@ -359,24 +373,25 @@ void WindowManagerState::OnServerWindowCaptureLost(ServerWindow* window) {
window_server()->ProcessLostCapture(window);
}
-void WindowManagerState::DispatchInputEventToWindow(ServerWindow* target,
- bool in_nonclient_area,
- const ui::Event& event,
- Accelerator* accelerator) {
+void WindowManagerState::DispatchInputEventToWindow(
+ ServerWindow* target,
+ bool in_nonclient_area,
+ const ui::Event& transformed_event,
+ Accelerator* accelerator) {
DCHECK(IsActive());
// TODO(sky): this needs to see if another wms has capture and if so forward
// to it.
if (event_ack_timer_.IsRunning()) {
scoped_ptr<ProcessedEventTarget> processed_event_target(
new ProcessedEventTarget(target, in_nonclient_area, accelerator));
- QueueEvent(event, std::move(processed_event_target));
+ QueueEvent(transformed_event, std::move(processed_event_target));
return;
}
base::WeakPtr<Accelerator> weak_accelerator;
if (accelerator)
weak_accelerator = accelerator->GetWeakPtr();
- DispatchInputEventToWindowImpl(target, in_nonclient_area, event,
+ DispatchInputEventToWindowImpl(target, in_nonclient_area, transformed_event,
weak_accelerator);
}
« no previous file with comments | « components/mus/ws/window_manager_state.h ('k') | components/mus/ws/window_manager_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698