diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2021-01-27 22:06:49 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2021-01-27 22:06:49 +0100 |
| commit | 06950aab233de6a2f47293d59575bb42f6131660 (patch) | |
| tree | 62f6eed4a6d35414f656d22b9ac7420849018a11 /src/xcb_connection.hh | |
| parent | 1ef9c463f1efc1adfb62e42ab3dd17e8c6394373 (diff) | |
Complete rewrite using C++ and with shared state support
Diffstat (limited to 'src/xcb_connection.hh')
| -rw-r--r-- | src/xcb_connection.hh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/xcb_connection.hh b/src/xcb_connection.hh new file mode 100644 index 0000000..74ee751 --- /dev/null +++ b/src/xcb_connection.hh @@ -0,0 +1,30 @@ +#ifndef XCB_CONNECTION_HH +#define XCB_CONNECTION_HH + +#include <memory> +#include <xcb/xcb.h> + +namespace xcb { + +namespace internal { + +struct xcb_connection_deleter { + void operator() (xcb_connection_t* ptr) { + xcb_disconnect(ptr); + } +}; + +} // namespace internal + +typedef std::shared_ptr<xcb_connection_t> shared_conn; +typedef std::unique_ptr<xcb_connection_t, + internal::xcb_connection_deleter> unique_conn; + +shared_conn make_shared_conn(xcb_connection_t* conn); +unique_conn make_unique_conn(xcb_connection_t* conn); + +xcb_screen_t* get_screen(xcb_connection_t* conn, int screen_index); + +} // namespace xcb + +#endif // XCB_CONNECTION_HH |
