| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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_AURA_SHELL_ROOT_WINDOW_EVENT_FILTER_H_ | |
| 6 #define UI_AURA_SHELL_ROOT_WINDOW_EVENT_FILTER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/observer_list.h" | |
| 11 #include "ui/aura/event.h" | |
| 12 #include "ui/aura/event_filter.h" | |
| 13 #include "ui/aura_shell/aura_shell_export.h" | |
| 14 | |
| 15 namespace aura_shell { | |
| 16 namespace internal { | |
| 17 | |
| 18 // RootWindowEventFilter gets all root window events first and can provide | |
| 19 // actions to those events. It implements root window features such as click to | |
| 20 // activate a window and cursor change when moving mouse. | |
| 21 // Additional event filters can be added to RootWIndowEventFilter. Events will | |
| 22 // pass through those additional filters in their addition order and could be | |
| 23 // consumed by any of those filters. If an event is consumed by a filter, the | |
| 24 // rest of the filter(s) and RootWindowEventFilter will not see the consumed | |
| 25 // event. | |
| 26 class AURA_SHELL_EXPORT RootWindowEventFilter : public aura::EventFilter { | |
| 27 public: | |
| 28 RootWindowEventFilter(); | |
| 29 virtual ~RootWindowEventFilter(); | |
| 30 | |
| 31 // Adds/removes additional event filters. | |
| 32 void AddFilter(aura::EventFilter* filter); | |
| 33 void RemoveFilter(aura::EventFilter* filter); | |
| 34 | |
| 35 // Overridden from EventFilter: | |
| 36 virtual bool PreHandleKeyEvent(aura::Window* target, | |
| 37 aura::KeyEvent* event) OVERRIDE; | |
| 38 virtual bool PreHandleMouseEvent(aura::Window* target, | |
| 39 aura::MouseEvent* event) OVERRIDE; | |
| 40 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, | |
| 41 aura::TouchEvent* event) OVERRIDE; | |
| 42 | |
| 43 private: | |
| 44 // Updates the cursor if the target provides a custom one, and provides | |
| 45 // default resize cursors for window edges. | |
| 46 void UpdateCursor(aura::Window* target, aura::MouseEvent* event); | |
| 47 | |
| 48 // Sets the cursor invisible when the target receives touch press event. | |
| 49 void SetCursorVisible(aura::Window* target, | |
| 50 aura::LocatedEvent* event, | |
| 51 bool show); | |
| 52 | |
| 53 // Dispatches event to additional filters. Returns false or | |
| 54 // ui::TOUCH_STATUS_UNKNOWN if event is consumed. | |
| 55 bool FilterKeyEvent(aura::Window* target, aura::KeyEvent* event); | |
| 56 bool FilterMouseEvent(aura::Window* target, aura::MouseEvent* event); | |
| 57 ui::TouchStatus FilterTouchEvent(aura::Window* target, | |
| 58 aura::TouchEvent* event); | |
| 59 | |
| 60 // Additional event filters that pre-handles events. | |
| 61 ObserverList<aura::EventFilter, true> filters_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(RootWindowEventFilter); | |
| 64 }; | |
| 65 | |
| 66 } // namespace internal | |
| 67 } // namespace aura_shell | |
| 68 | |
| 69 #endif // UI_AURA_SHELL_ROOT_WINDOW_EVENT_FILTER_H_ | |
| OLD | NEW |