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_WM_CORE_FOCUS_RULES_H_ | 5 #ifndef UI_WM_CORE_FOCUS_RULES_H_ |
6 #define UI_WM_CORE_FOCUS_RULES_H_ | 6 #define UI_WM_CORE_FOCUS_RULES_H_ |
7 | 7 |
8 #include "ui/wm/wm_export.h" | 8 #include "ui/wm/wm_export.h" |
9 | 9 |
10 namespace aura { | 10 namespace aura { |
11 class Window; | 11 class Window; |
12 } | 12 } |
13 | 13 |
14 namespace ui { | |
15 class Event; | |
16 } | |
17 | |
14 namespace wm { | 18 namespace wm { |
15 | 19 |
16 // Implemented by an object that establishes the rules about what can be | 20 // Implemented by an object that establishes the rules about what can be |
17 // focused or activated. | 21 // focused or activated. |
18 class WM_EXPORT FocusRules { | 22 class WM_EXPORT FocusRules { |
19 public: | 23 public: |
20 virtual ~FocusRules() {} | 24 virtual ~FocusRules() {} |
21 | 25 |
22 // Returns true if |window| is a toplevel window. Whether or not a window | 26 // Returns true if |window| is a toplevel window. Whether or not a window |
23 // is considered toplevel is determined by a similar set of rules that | 27 // is considered toplevel is determined by a similar set of rules that |
24 // govern activation and focus. Not all toplevel windows are activatable, | 28 // govern activation and focus. Not all toplevel windows are activatable, |
25 // call CanActivateWindow() to determine if a window can be activated. | 29 // call CanActivateWindow() to determine if a window can be activated. |
26 virtual bool IsToplevelWindow(aura::Window* window) const = 0; | 30 virtual bool IsToplevelWindow(aura::Window* window) const = 0; |
27 // Returns true if |window| can be activated or focused. | 31 // Returns true if |window| can be activated or focused. |
28 virtual bool CanActivateWindow(aura::Window* window) const = 0; | 32 virtual bool CanActivateWindow(aura::Window* window) const = 0; |
29 // For CanFocusWindow(), NULL is supported, because NULL is a valid focusable | 33 // For CanFocusWindow(), nullptr window is supported, because nullptr is a |
sky
2017/04/17 16:08:48
optional: in comments I think null is fine.
Qiang(Joe) Xu
2017/04/17 17:40:32
Done.
| |
30 // window (in the case of clearing focus). | 34 // valid focusable window (in the case of clearing focus). |
31 virtual bool CanFocusWindow(aura::Window* window) const = 0; | 35 // |event| can be provided to check whether for the |event| the default focus |
sky
2017/04/17 16:08:48
How about:
If |event| is non-null it is the event
Qiang(Joe) Xu
2017/04/17 17:40:32
Done.
| |
36 // rules for |window| should be disabled. | |
37 virtual bool CanFocusWindow(aura::Window* window, ui::Event* event) const = 0; | |
32 | 38 |
33 // Returns the toplevel window containing |window|. Not all toplevel windows | 39 // Returns the toplevel window containing |window|. Not all toplevel windows |
34 // are activatable, call GetActivatableWindow() instead to return the | 40 // are activatable, call GetActivatableWindow() instead to return the |
35 // activatable window, which might be in a different hierarchy. | 41 // activatable window, which might be in a different hierarchy. |
36 // Will return NULL if |window| is not contained by a window considered to be | 42 // Will return NULL if |window| is not contained by a window considered to be |
37 // a toplevel window. | 43 // a toplevel window. |
38 virtual aura::Window* GetToplevelWindow(aura::Window* window) const = 0; | 44 virtual aura::Window* GetToplevelWindow(aura::Window* window) const = 0; |
39 // Returns the activatable or focusable window given an attempt to activate or | 45 // Returns the activatable or focusable window given an attempt to activate or |
40 // focus |window|. Some possible scenarios (not intended to be exhaustive): | 46 // focus |window|. Some possible scenarios (not intended to be exhaustive): |
41 // - |window| is a child of a non-focusable window and so focus must be set | 47 // - |window| is a child of a non-focusable window and so focus must be set |
(...skipping 15 matching lines...) Expand all Loading... | |
57 // - it is being destroyed. | 63 // - it is being destroyed. |
58 // - it is being explicitly deactivated. | 64 // - it is being explicitly deactivated. |
59 // |ignore| cannot be NULL. | 65 // |ignore| cannot be NULL. |
60 virtual aura::Window* GetNextActivatableWindow( | 66 virtual aura::Window* GetNextActivatableWindow( |
61 aura::Window* ignore) const = 0; | 67 aura::Window* ignore) const = 0; |
62 }; | 68 }; |
63 | 69 |
64 } // namespace wm | 70 } // namespace wm |
65 | 71 |
66 #endif // UI_WM_CORE_FOCUS_RULES_H_ | 72 #endif // UI_WM_CORE_FOCUS_RULES_H_ |
OLD | NEW |