| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_VIEWS_TEST_X11_PROPERTY_CHANGE_WAITER_H_ | 5 #ifndef UI_VIEWS_TEST_X11_PROPERTY_CHANGE_WAITER_H_ |
| 6 #define UI_VIEWS_TEST_X11_PROPERTY_CHANGE_WAITER_H_ | 6 #define UI_VIEWS_TEST_X11_PROPERTY_CHANGE_WAITER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "ui/events/platform/platform_event_dispatcher.h" | 14 #include "ui/events/platform/platform_event_dispatcher.h" |
| 15 #include "ui/events/platform/platform_event_types.h" | 15 #include "ui/events/platform/platform_event_types.h" |
| 16 #include "ui/gfx/x/x11_types.h" | 16 #include "ui/gfx/x/x11_types.h" |
| 17 | 17 |
| 18 namespace ui { | 18 namespace ui { |
| 19 class ScopedEventDispatcher; | 19 class ScopedEventDispatcher; |
| 20 class X11AtomCache; | 20 class X11AtomCache; |
| 21 class XScopedEventSelector; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace views { | 24 namespace views { |
| 24 | 25 |
| 25 // Blocks till the value of |property| on |window| changes. | 26 // Blocks till the value of |property| on |window| changes. |
| 26 class X11PropertyChangeWaiter : public ui::PlatformEventDispatcher { | 27 class X11PropertyChangeWaiter : public ui::PlatformEventDispatcher { |
| 27 public: | 28 public: |
| 28 X11PropertyChangeWaiter(XID window, const char* property); | 29 X11PropertyChangeWaiter(XID window, const char* property); |
| 29 ~X11PropertyChangeWaiter() override; | 30 ~X11PropertyChangeWaiter() override; |
| 30 | 31 |
| 31 // Blocks till the value of |property_| changes. | 32 // Blocks till the value of |property_| changes. |
| 32 virtual void Wait(); | 33 virtual void Wait(); |
| 33 | 34 |
| 34 protected: | 35 protected: |
| 35 // Returns whether the run loop can exit. | 36 // Returns whether the run loop can exit. |
| 36 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event); | 37 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event); |
| 37 | 38 |
| 38 XID xwindow() const { | 39 XID xwindow() const { |
| 39 return x_window_; | 40 return x_window_; |
| 40 } | 41 } |
| 41 | 42 |
| 42 private: | 43 private: |
| 43 // ui::PlatformEventDispatcher: | 44 // ui::PlatformEventDispatcher: |
| 44 bool CanDispatchEvent(const ui::PlatformEvent& event) override; | 45 bool CanDispatchEvent(const ui::PlatformEvent& event) override; |
| 45 uint32_t DispatchEvent(const ui::PlatformEvent& event) override; | 46 uint32_t DispatchEvent(const ui::PlatformEvent& event) override; |
| 46 | 47 |
| 47 XID x_window_; | 48 XID x_window_; |
| 48 const char* property_; | 49 const char* property_; |
| 49 | 50 |
| 51 std::unique_ptr<ui::XScopedEventSelector> x_window_events_; |
| 52 |
| 50 // Whether Wait() should block. | 53 // Whether Wait() should block. |
| 51 bool wait_; | 54 bool wait_; |
| 52 | 55 |
| 53 // Ends the run loop. | 56 // Ends the run loop. |
| 54 base::Closure quit_closure_; | 57 base::Closure quit_closure_; |
| 55 | 58 |
| 56 // The event mask to be restored upon X11PropertyChangeWaiter's destruction. | |
| 57 long old_event_mask_; | |
| 58 | |
| 59 std::unique_ptr<ui::ScopedEventDispatcher> dispatcher_; | 59 std::unique_ptr<ui::ScopedEventDispatcher> dispatcher_; |
| 60 | 60 |
| 61 std::unique_ptr<ui::X11AtomCache> atom_cache_; | 61 std::unique_ptr<ui::X11AtomCache> atom_cache_; |
| 62 | 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(X11PropertyChangeWaiter); | 63 DISALLOW_COPY_AND_ASSIGN(X11PropertyChangeWaiter); |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 } // namespace views | 66 } // namespace views |
| 67 | 67 |
| 68 #endif // UI_VIEWS_TEST_X11_PROPERTY_CHANGE_WAITER_H_ | 68 #endif // UI_VIEWS_TEST_X11_PROPERTY_CHANGE_WAITER_H_ |
| OLD | NEW |