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

Unified Diff: components/mus/ws/event_dispatcher.h

Issue 1425123002: Makes event dispatch implicitly target specific window until release (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge 2 trunk Created 5 years, 2 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 | « no previous file | components/mus/ws/event_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/event_dispatcher.h
diff --git a/components/mus/ws/event_dispatcher.h b/components/mus/ws/event_dispatcher.h
index 0e89233572769c5dcadf0273fcc7798e172bf1c1..bbd2badce05cc8188c60cb9e6f660d5cc5e29568 100644
--- a/components/mus/ws/event_dispatcher.h
+++ b/components/mus/ws/event_dispatcher.h
@@ -13,6 +13,7 @@
#include "components/mus/public/interfaces/input_event_matcher.mojom.h"
#include "components/mus/public/interfaces/input_events.mojom.h"
#include "components/mus/public/interfaces/input_key_codes.mojom.h"
+#include "components/mus/ws/server_window_observer.h"
#include "ui/gfx/geometry/rect_f.h"
namespace mus {
@@ -23,10 +24,10 @@ class EventMatcher;
class ServerWindow;
// Handles dispatching events to the right location as well as updating focus.
-class EventDispatcher {
+class EventDispatcher : public ServerWindowObserver {
public:
explicit EventDispatcher(EventDispatcherDelegate* delegate);
- ~EventDispatcher();
+ ~EventDispatcher() override;
void set_root(ServerWindow* root) { root_ = root; }
@@ -38,29 +39,67 @@ class EventDispatcher {
void OnEvent(mojom::EventPtr event);
private:
+ // Keeps track of state associated with a pointer down until the
+ // corresponding up/cancel.
+ struct PointerTarget {
+ PointerTarget() : window(nullptr), in_nonclient_area(false) {}
+
+ // NOTE: this is set to null if the window is destroyed before a
+ // corresponding release/cancel.
+ ServerWindow* window;
+
+ // Did the pointer event start in the non-client area.
+ bool in_nonclient_area;
+ };
+
+ void ProcessKeyEvent(mojom::EventPtr event);
+
+ // EventDispatcher provides the following logic for pointer events:
+ // . wheel events go to the current target of the associated pointer. If
+ // there is no target, they go to the deepest window.
+ // . move (not drag) events go to the deepest window.
+ // . when a pointer goes down all events until the corresponding up or
+ // cancel go to the deepest target. For mouse events the up only occurs
+ // when no buttons on the mouse are down.
+ void ProcessPointerEvent(mojom::EventPtr event);
+
+ // If |target->window| is valid, then passes the event to the delegate.
+ void DispatchToPointerTarget(const PointerTarget& target,
+ mojom::EventPtr event);
+
+ // Stops sending pointer events to |window|. This does not remove the entry
+ // for |window| from |pointer_targets_|, rather it nulls out the window. This
+ // way we continue to eat events until the up/cancel is received.
+ void CancelPointerEventsToTarget(ServerWindow* window);
+
+ // Returns true if we're currently an observer for |window|. We are an
+ // observer for a window if any pointer events are targeting it.
+ bool IsObservingWindow(ServerWindow* window);
+
// Looks to see if there is an accelerator bound to the specified code/flags.
// If there is one, sets |accelerator_id| to the id of the accelerator invoked
// and returns true. If there is none, returns false so normal key event
// processing can continue.
bool FindAccelerator(const mojom::Event& event, uint32_t* accelerator_id);
- // Returns the ServerWindow that should receive |event|. If |event| is a
- // pointer-type event, then this function also updates the event location to
- // make sure it is in the returned target's coordinate space.
- ServerWindow* FindEventTarget(mojom::Event* event);
+ // ServerWindowObserver:
+ void OnWillChangeWindowHierarchy(ServerWindow* window,
+ ServerWindow* new_parent,
+ ServerWindow* old_parent) override;
+ void OnWindowVisibilityChanged(ServerWindow* window) override;
+ void OnWindowDestroyed(ServerWindow* window) override;
EventDispatcherDelegate* delegate_;
ServerWindow* root_;
cc::SurfaceId surface_id_;
- ServerWindow* capture_window_;
-
- // Was the capture the result of clicking in the non-client area?
- bool capture_in_nonclient_area_;
using Entry = std::pair<uint32_t, EventMatcher>;
std::map<uint32_t, EventMatcher> accelerators_;
+ using PointerIdToTargetMap = std::map<int32_t, PointerTarget>;
+ PointerIdToTargetMap pointer_targets_;
+
DISALLOW_COPY_AND_ASSIGN(EventDispatcher);
};
« no previous file with comments | « no previous file | components/mus/ws/event_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698