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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_TEST_X11_PROPERTY_CHANGE_WAITER_H_
6 #define UI_VIEWS_TEST_X11_PROPERTY_CHANGE_WAITER_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ui/events/platform/platform_event_dispatcher.h"
11 #include "ui/events/platform/platform_event_types.h"
12 #include "ui/gfx/x/x11_types.h"
15 class ScopedEventDispatcher
;
21 // Blocks till the value of |property| on |window| changes.
22 class X11PropertyChangeWaiter
: public ui::PlatformEventDispatcher
{
24 X11PropertyChangeWaiter(XID window
, const char* property
);
25 ~X11PropertyChangeWaiter() override
;
27 // Blocks till the value of |property_| changes.
31 // Returns whether the run loop can exit.
32 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent
& event
);
39 // ui::PlatformEventDispatcher:
40 bool CanDispatchEvent(const ui::PlatformEvent
& event
) override
;
41 uint32_t DispatchEvent(const ui::PlatformEvent
& event
) override
;
44 const char* property_
;
46 // Whether Wait() should block.
50 base::Closure quit_closure_
;
52 // The event mask to be restored upon X11PropertyChangeWaiter's destruction.
55 scoped_ptr
<ui::ScopedEventDispatcher
> dispatcher_
;
57 scoped_ptr
<ui::X11AtomCache
> atom_cache_
;
59 DISALLOW_COPY_AND_ASSIGN(X11PropertyChangeWaiter
);
64 #endif // UI_VIEWS_TEST_X11_PROPERTY_CHANGE_WAITER_H_