Avi Drissman | 3e1a26c | 2022-09-15 20:26:03 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors |
Xiaoqian Dai | 563f020 | 2019-10-04 22:01:10 | [diff] [blame] | 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_SCOPED_WINDOW_EVENT_TARGETING_BLOCKER_H_ |
| 6 | #define UI_AURA_SCOPED_WINDOW_EVENT_TARGETING_BLOCKER_H_ |
| 7 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 8 | #include "base/memory/raw_ptr.h" |
Xiaoqian Dai | 563f020 | 2019-10-04 22:01:10 | [diff] [blame] | 9 | #include "ui/aura/aura_export.h" |
| 10 | #include "ui/aura/window_observer.h" |
| 11 | |
| 12 | namespace aura { |
| 13 | |
| 14 | class Window; |
| 15 | |
| 16 | // Temporarily blocks the event targeting by setting kNone targeting policy to |
| 17 | // |window_|. The original event targeting policy will be restored if all |
| 18 | // targeting blockers are removed from |window_|. |
| 19 | class AURA_EXPORT ScopedWindowEventTargetingBlocker : public WindowObserver { |
| 20 | public: |
| 21 | explicit ScopedWindowEventTargetingBlocker(Window* window); |
Peter Boström | c8c1235 | 2021-09-21 23:37:15 | [diff] [blame] | 22 | |
| 23 | ScopedWindowEventTargetingBlocker(const ScopedWindowEventTargetingBlocker&) = |
| 24 | delete; |
| 25 | ScopedWindowEventTargetingBlocker& operator=( |
| 26 | const ScopedWindowEventTargetingBlocker&) = delete; |
| 27 | |
Xiaoqian Dai | 563f020 | 2019-10-04 22:01:10 | [diff] [blame] | 28 | ~ScopedWindowEventTargetingBlocker() override; |
| 29 | |
| 30 | // WindowObserver: |
| 31 | void OnWindowDestroying(Window* window) override; |
| 32 | |
Mitsuru Oshima | c2d394b | 2025-04-03 21:06:16 | [diff] [blame] | 33 | aura::Window* window() { return window_.get(); } |
| 34 | |
Xiaoqian Dai | 563f020 | 2019-10-04 22:01:10 | [diff] [blame] | 35 | private: |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 36 | raw_ptr<Window> window_; |
Xiaoqian Dai | 563f020 | 2019-10-04 22:01:10 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | } // namespace aura |
| 40 | |
| 41 | #endif // UI_AURA_SCOPED_WINDOW_EVENT_TARGETING_BLOCKER_H_ |