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