#ifndef UI_GFX_X_WM_SYNC_H_
#define UI_GFX_X_WM_SYNC_H_
#include "base/component_export.h"
#include "base/functional/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observation.h"
#include "ui/gfx/x/event_observer.h"
#include "ui/gfx/x/window_event_manager.h"
#include "ui/gfx/x/xproto.h"
namespace x11 {
class Connection;
class COMPONENT_EXPORT(X11) WmSync final : public EventObserver {
public:
WmSync(Connection* connection, base::OnceClosure on_synced);
WmSync(Connection* connection,
base::OnceClosure on_synced,
bool sync_with_wm);
WmSync(WmSync&&) = delete;
WmSync& operator=(WmSync&&) = delete;
~WmSync() override;
private:
void OnEvent(const Event& xevent) override;
void OnGetInputFocusResponse(GetInputFocusResponse response);
void Cleanup();
const raw_ptr<Connection> connection_;
base::OnceClosure on_synced_;
Window window_ = Window::None;
ScopedEventSelector window_events_;
base::ScopedObservation<Connection, EventObserver> scoped_observation_{this};
base::WeakPtrFactory<WmSync> weak_ptr_factory_{this};
};
}
#endif