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

Side by Side Diff: ui/aura/window_event_dispatcher.h

Issue 184903003: Window ownership -> WindowTreeHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/window.cc ('k') | ui/aura/window_event_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_AURA_WINDOW_EVENT_DISPATCHER_H_ 5 #ifndef UI_AURA_WINDOW_EVENT_DISPATCHER_H_
6 #define UI_AURA_WINDOW_EVENT_DISPATCHER_H_ 6 #define UI_AURA_WINDOW_EVENT_DISPATCHER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
(...skipping 22 matching lines...) Expand all
34 } 34 }
35 35
36 namespace ui { 36 namespace ui {
37 class GestureEvent; 37 class GestureEvent;
38 class GestureRecognizer; 38 class GestureRecognizer;
39 class KeyEvent; 39 class KeyEvent;
40 class LayerAnimationSequence; 40 class LayerAnimationSequence;
41 class MouseEvent; 41 class MouseEvent;
42 class ScrollEvent; 42 class ScrollEvent;
43 class TouchEvent; 43 class TouchEvent;
44 class ViewProp;
45 } 44 }
46 45
47 namespace aura { 46 namespace aura {
48 class RootWindowObserver; 47 class RootWindowObserver;
49 class TestScreen; 48 class TestScreen;
50 class WindowTargeter; 49 class WindowTargeter;
51 50
52 // RootWindow is responsible for hosting a set of windows. 51 // WindowEventDispatcher orchestrates event dispatch within a window tree
52 // owned by WindowTreeHost. WTH also owns the WED.
53 // TODO(beng): In progress, remove functionality not directly related to
54 // event dispatch.
53 class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor, 55 class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor,
54 public ui::GestureEventHelper, 56 public ui::GestureEventHelper,
55 public ui::LayerAnimationObserver, 57 public ui::LayerAnimationObserver,
56 public client::CaptureDelegate, 58 public client::CaptureDelegate,
57 public WindowTreeHostDelegate { 59 public WindowTreeHostDelegate {
58 public: 60 public:
59 explicit WindowEventDispatcher(WindowTreeHost* host); 61 explicit WindowEventDispatcher(WindowTreeHost* host);
60 virtual ~WindowEventDispatcher(); 62 virtual ~WindowEventDispatcher();
61 63
62 // Returns the WindowTreeHost for the specified accelerated widget, or NULL 64 Window* window() { return host()->window(); }
63 // if there is none associated. 65 const Window* window() const { return host()->window(); }
64 static WindowEventDispatcher* GetForAcceleratedWidget(
65 gfx::AcceleratedWidget widget);
66
67 Window* window() {
68 return const_cast<Window*>(
69 const_cast<const WindowEventDispatcher*>(this)->window());
70 }
71 const Window* window() const { return window_.get(); }
72 WindowTreeHost* host() { 66 WindowTreeHost* host() {
73 return const_cast<WindowTreeHost*>( 67 return const_cast<WindowTreeHost*>(
74 const_cast<const WindowEventDispatcher*>(this)->host()); 68 const_cast<const WindowEventDispatcher*>(this)->host());
75 } 69 }
76 const WindowTreeHost* host() const { return host_; } 70 const WindowTreeHost* host() const { return host_; }
77 Window* mouse_pressed_handler() { return mouse_pressed_handler_; } 71 Window* mouse_pressed_handler() { return mouse_pressed_handler_; }
78 Window* mouse_moved_handler() { return mouse_moved_handler_; } 72 Window* mouse_moved_handler() { return mouse_moved_handler_; }
79 73
80 // Stop listening events in preparation for shutdown. 74 // Stop listening events in preparation for shutdown.
81 void PrepareForShutdown(); 75 void PrepareForShutdown();
(...skipping 16 matching lines...) Expand all
98 // events are dispatched from GestureRecognizer instead of WindowTreeHost. 92 // events are dispatched from GestureRecognizer instead of WindowTreeHost.
99 void DispatchGestureEvent(ui::GestureEvent* event); 93 void DispatchGestureEvent(ui::GestureEvent* event);
100 94
101 // Invoked when |window| is being destroyed. 95 // Invoked when |window| is being destroyed.
102 void OnWindowDestroying(Window* window); 96 void OnWindowDestroying(Window* window);
103 97
104 // Invoked when |window|'s bounds have changed. |contained_mouse| indicates if 98 // Invoked when |window|'s bounds have changed. |contained_mouse| indicates if
105 // the bounds before change contained the |last_moust_location()|. 99 // the bounds before change contained the |last_moust_location()|.
106 void OnWindowBoundsChanged(Window* window, bool contained_mouse); 100 void OnWindowBoundsChanged(Window* window, bool contained_mouse);
107 101
108 // Dispatches OnMouseExited to the |window| which is hiding if nessessary. 102 // Dispatches OnMouseExited to the |window| which is hiding if necessary.
109 void DispatchMouseExitToHidingWindow(Window* window); 103 void DispatchMouseExitToHidingWindow(Window* window);
110 104
111 // Dispatches a ui::ET_MOUSE_EXITED event at |point|. 105 // Dispatches a ui::ET_MOUSE_EXITED event at |point|.
112 void DispatchMouseExitAtPoint(const gfx::Point& point); 106 void DispatchMouseExitAtPoint(const gfx::Point& point);
113 107
114 // Invoked when |window|'s visibility has changed. 108 // Invoked when |window|'s visibility has changed.
115 void OnWindowVisibilityChanged(Window* window, bool is_visible); 109 void OnWindowVisibilityChanged(Window* window, bool is_visible);
116 110
117 // Invoked when |window|'s tranfrom has changed. |contained_mouse| 111 // Invoked when |window|'s transform has changed. |contained_mouse|
118 // indicates if the bounds before change contained the 112 // indicates if the bounds before change contained the
119 // |last_moust_location()|. 113 // |last_moust_location()|.
120 void OnWindowTransformed(Window* window, bool contained_mouse); 114 void OnWindowTransformed(Window* window, bool contained_mouse);
121 115
122 // Invoked when the keyboard mapping (in X11 terms: the mapping between 116 // Invoked when the keyboard mapping (in X11 terms: the mapping between
123 // keycodes and keysyms) has changed. 117 // key-codes and key-syms) has changed.
124 void OnKeyboardMappingChanged(); 118 void OnKeyboardMappingChanged();
125 119
126 // The system windowing system has sent a request that we close our window. 120 // The system windowing system has sent a request that we close our window.
127 void OnWindowTreeHostCloseRequested(); 121 void OnWindowTreeHostCloseRequested();
128 122
129 // Add/remove observer. There is no need to remove the observer if 123 // Add/remove observer. There is no need to remove the observer if
130 // the root window is being deleted. In particular, you SHOULD NOT remove 124 // the root window is being deleted. In particular, you SHOULD NOT remove
131 // in |WindowObserver::OnWindowDestroying| of the observer observing 125 // in |WindowObserver::OnWindowDestroying| of the observer observing
132 // the root window because it is too late to remove it. 126 // the root window because it is too late to remove it.
133 void AddRootWindowObserver(RootWindowObserver* observer); 127 void AddRootWindowObserver(RootWindowObserver* observer);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 void SynthesizeMouseMoveEventAsync(); 258 void SynthesizeMouseMoveEventAsync();
265 259
266 // Posts a task to send synthesized mouse move event if there 260 // Posts a task to send synthesized mouse move event if there
267 // is no a pending task. 261 // is no a pending task.
268 void PostMouseMoveEventAfterWindowChange(); 262 void PostMouseMoveEventAfterWindowChange();
269 263
270 void PreDispatchLocatedEvent(Window* target, ui::LocatedEvent* event); 264 void PreDispatchLocatedEvent(Window* target, ui::LocatedEvent* event);
271 void PreDispatchMouseEvent(Window* target, ui::MouseEvent* event); 265 void PreDispatchMouseEvent(Window* target, ui::MouseEvent* event);
272 void PreDispatchTouchEvent(Window* target, ui::TouchEvent* event); 266 void PreDispatchTouchEvent(Window* target, ui::TouchEvent* event);
273 267
274 // TODO(beng): should be owned by WindowTreeHost.
275 scoped_ptr<Window> window_;
276
277 WindowTreeHost* host_; 268 WindowTreeHost* host_;
278 269
279 // Touch ids that are currently down. 270 // Touch ids that are currently down.
280 uint32 touch_ids_down_; 271 uint32 touch_ids_down_;
281 272
282 ObserverList<RootWindowObserver> observers_; 273 ObserverList<RootWindowObserver> observers_;
283 274
284 Window* mouse_pressed_handler_; 275 Window* mouse_pressed_handler_;
285 Window* mouse_moved_handler_; 276 Window* mouse_moved_handler_;
286 Window* event_dispatch_target_; 277 Window* event_dispatch_target_;
287 Window* old_dispatch_target_; 278 Window* old_dispatch_target_;
288 279
289 bool synthesize_mouse_move_; 280 bool synthesize_mouse_move_;
290 281
291 // How many move holds are outstanding. We try to defer dispatching 282 // How many move holds are outstanding. We try to defer dispatching
292 // touch/mouse moves while the count is > 0. 283 // touch/mouse moves while the count is > 0.
293 int move_hold_count_; 284 int move_hold_count_;
294 // The location of |held_move_event_| is in |window_|'s coordinate. 285 // The location of |held_move_event_| is in |window_|'s coordinate.
295 scoped_ptr<ui::LocatedEvent> held_move_event_; 286 scoped_ptr<ui::LocatedEvent> held_move_event_;
296 287
297 // Allowing for reposting of events. Used when exiting context menus. 288 // Allowing for reposting of events. Used when exiting context menus.
298 scoped_ptr<ui::LocatedEvent> held_repostable_event_; 289 scoped_ptr<ui::LocatedEvent> held_repostable_event_;
299 290
300 // Set when dispatching a held event. 291 // Set when dispatching a held event.
301 bool dispatching_held_event_; 292 bool dispatching_held_event_;
302 293
303 scoped_ptr<ui::ViewProp> prop_;
304
305 // Used to schedule reposting an event. 294 // Used to schedule reposting an event.
306 base::WeakPtrFactory<WindowEventDispatcher> repost_event_factory_; 295 base::WeakPtrFactory<WindowEventDispatcher> repost_event_factory_;
307 296
308 // Used to schedule DispatchHeldEvents() when |move_hold_count_| goes to 0. 297 // Used to schedule DispatchHeldEvents() when |move_hold_count_| goes to 0.
309 base::WeakPtrFactory<WindowEventDispatcher> held_event_factory_; 298 base::WeakPtrFactory<WindowEventDispatcher> held_event_factory_;
310 299
311 DISALLOW_COPY_AND_ASSIGN(WindowEventDispatcher); 300 DISALLOW_COPY_AND_ASSIGN(WindowEventDispatcher);
312 }; 301 };
313 302
314 } // namespace aura 303 } // namespace aura
315 304
316 #endif // UI_AURA_WINDOW_EVENT_DISPATCHER_H_ 305 #endif // UI_AURA_WINDOW_EVENT_DISPATCHER_H_
OLDNEW
« no previous file with comments | « ui/aura/window.cc ('k') | ui/aura/window_event_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698