1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-10-27 05:23:39 -04:00
polybar/include/x11/connection.hpp

98 lines
2.1 KiB
C++
Raw Normal View History

2016-11-02 15:22:45 -04:00
#pragma once
#include <X11/X.h>
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
2016-11-25 02:42:31 -05:00
#include <boost/optional.hpp>
2016-11-02 15:22:45 -04:00
#include <iomanip>
#include <xpp/xpp.hpp>
#include "common.hpp"
#include "x11/types.hpp"
2016-11-20 17:04:31 -05:00
#ifdef ENABLE_DAMAGE_EXT
#include "x11/damage.hpp"
#endif
#ifdef ENABLE_RENDER_EXT
#include "x11/render.hpp"
#endif
2016-11-26 00:13:20 -05:00
#ifdef ENABLE_RANDR_EXT
#include "x11/randr.hpp"
#endif
2016-11-20 17:04:31 -05:00
2016-11-19 00:22:44 -05:00
POLYBAR_NS
2016-11-02 15:22:45 -04:00
using xpp_connection = xpp::connection<
#ifdef ENABLE_DAMAGE_EXT
xpp::damage::extension
#endif
#ifdef ENABLE_RANDR_EXT
#ifdef ENABLE_DAMAGE_EXT
,
#endif
xpp::randr::extension
#endif
#ifdef ENABLE_RENDER_EXT
#ifdef ENABLE_RANDR_EXT
,
#endif
xpp::render::extension
#endif
>;
class connection : public xpp_connection {
public:
explicit connection() {}
explicit connection(xcb_connection_t* conn) : xpp_connection(conn) {}
connection& operator=(const connection&) {
return *this;
}
virtual ~connection() {}
void preload_atoms();
void query_extensions();
string id(xcb_window_t w) const;
xcb_screen_t* screen();
2016-11-25 02:42:31 -05:00
shared_ptr<xcb_client_message_event_t> make_client_message(xcb_atom_t type, xcb_window_t target) const;
2016-11-02 15:22:45 -04:00
2016-11-25 07:55:15 -05:00
void send_client_message(const shared_ptr<xcb_client_message_event_t>& message, xcb_window_t target,
2016-11-02 15:22:45 -04:00
uint32_t event_mask = 0xFFFFFF, bool propagate = false) const;
2016-11-25 07:55:15 -05:00
void send_dummy_event(xcb_window_t target, uint32_t event = XCB_EVENT_MASK_STRUCTURE_NOTIFY) const;
2016-11-02 15:22:45 -04:00
2016-11-20 17:04:31 -05:00
boost::optional<xcb_visualtype_t*> visual_type(xcb_screen_t* screen, int match_depth = 32);
2016-11-02 15:22:45 -04:00
static string error_str(int error_code);
void dispatch_event(const shared_ptr<xcb_generic_event_t>& evt) const;
/**
* Attach sink to the registry */
template <typename Sink>
void attach_sink(Sink&& sink, registry::priority prio = 0) {
m_registry.attach(prio, forward<Sink>(sink));
}
/**
* Detach sink from the registry
*/
template <typename Sink>
void detach_sink(Sink&& sink, registry::priority prio = 0) {
m_registry.detach(prio, forward<Sink>(sink));
}
protected:
registry m_registry{*this};
xcb_screen_t* m_screen = nullptr;
};
2016-11-20 17:04:31 -05:00
di::injector<connection&> configure_connection();
2016-11-02 15:22:45 -04:00
2016-11-19 00:22:44 -05:00
POLYBAR_NS_END