| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_VIEWS_COREWM_WINDOW_MODALITY_CONTROLLER_H_ | 5 #ifndef UI_VIEWS_COREWM_WINDOW_MODALITY_CONTROLLER_H_ |
| 6 #define UI_VIEWS_COREWM_WINDOW_MODALITY_CONTROLLER_H_ | 6 #define UI_VIEWS_COREWM_WINDOW_MODALITY_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "ui/aura/env_observer.h" | 11 #include "ui/aura/env_observer.h" |
| 12 #include "ui/aura/window_observer.h" | 12 #include "ui/aura/window_observer.h" |
| 13 #include "ui/events/event_handler.h" | 13 #include "ui/events/event_handler.h" |
| 14 #include "ui/views/views_export.h" | 14 #include "ui/views/views_export.h" |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 class EventTarget; |
| 17 class LocatedEvent; | 18 class LocatedEvent; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace views { | 21 namespace views { |
| 21 namespace corewm { | 22 namespace corewm { |
| 22 | 23 |
| 23 // Sets the modal parent for the child. | 24 // Sets the modal parent for the child. |
| 24 VIEWS_EXPORT void SetModalParent(aura::Window* child, aura::Window* parent); | 25 VIEWS_EXPORT void SetModalParent(aura::Window* child, aura::Window* parent); |
| 25 | 26 |
| 26 // Returns the modal transient child of |window|, or NULL if |window| does not | 27 // Returns the modal transient child of |window|, or NULL if |window| does not |
| 27 // have any modal transient children. | 28 // have any modal transient children. |
| 28 VIEWS_EXPORT aura::Window* GetModalTransient(aura::Window* window); | 29 VIEWS_EXPORT aura::Window* GetModalTransient(aura::Window* window); |
| 29 | 30 |
| 30 // WindowModalityController is an event filter that consumes events sent to | 31 // WindowModalityController is an event filter that consumes events sent to |
| 31 // windows that are the transient parents of window-modal windows. This filter | 32 // windows that are the transient parents of window-modal windows. This filter |
| 32 // must be added to the CompoundEventFilter so that activation works properly. | 33 // must be added to the CompoundEventFilter so that activation works properly. |
| 33 class VIEWS_EXPORT WindowModalityController : public ui::EventHandler, | 34 class VIEWS_EXPORT WindowModalityController : public ui::EventHandler, |
| 34 public aura::EnvObserver, | 35 public aura::EnvObserver, |
| 35 public aura::WindowObserver { | 36 public aura::WindowObserver { |
| 36 public: | 37 public: |
| 37 WindowModalityController(); | 38 explicit WindowModalityController(ui::EventTarget* event_target); |
| 38 virtual ~WindowModalityController(); | 39 virtual ~WindowModalityController(); |
| 39 | 40 |
| 40 // Overridden from ui::EventHandler: | 41 // Overridden from ui::EventHandler: |
| 41 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | 42 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
| 42 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 43 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
| 43 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | 44 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; |
| 44 | 45 |
| 45 // Overridden from aura::EnvObserver: | 46 // Overridden from aura::EnvObserver: |
| 46 virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; | 47 virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; |
| 47 | 48 |
| 48 // Overridden from aura::WindowObserver: | 49 // Overridden from aura::WindowObserver: |
| 49 virtual void OnWindowPropertyChanged(aura::Window* window, | 50 virtual void OnWindowPropertyChanged(aura::Window* window, |
| 50 const void* key, | 51 const void* key, |
| 51 intptr_t old) OVERRIDE; | 52 intptr_t old) OVERRIDE; |
| 52 virtual void OnWindowVisibilityChanged(aura::Window* window, | 53 virtual void OnWindowVisibilityChanged(aura::Window* window, |
| 53 bool visible) OVERRIDE; | 54 bool visible) OVERRIDE; |
| 54 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; | 55 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 // Processes a mouse/touch event, and returns true if the event should be | 58 // Processes a mouse/touch event, and returns true if the event should be |
| 58 // consumed. | 59 // consumed. |
| 59 bool ProcessLocatedEvent(aura::Window* target, | 60 bool ProcessLocatedEvent(aura::Window* target, |
| 60 ui::LocatedEvent* event); | 61 ui::LocatedEvent* event); |
| 61 | 62 |
| 62 std::vector<aura::Window*> windows_; | 63 std::vector<aura::Window*> windows_; |
| 63 | 64 |
| 65 ui::EventTarget* event_target_; |
| 66 |
| 64 DISALLOW_COPY_AND_ASSIGN(WindowModalityController); | 67 DISALLOW_COPY_AND_ASSIGN(WindowModalityController); |
| 65 }; | 68 }; |
| 66 | 69 |
| 67 } // namespace corewm | 70 } // namespace corewm |
| 68 } // namespace views | 71 } // namespace views |
| 69 | 72 |
| 70 #endif // UI_VIEWS_COREWM_WINDOW_MODALITY_CONTROLLER_H_ | 73 #endif // UI_VIEWS_COREWM_WINDOW_MODALITY_CONTROLLER_H_ |
| OLD | NEW |