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