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

41 lines
689 B
C++
Raw Normal View History

2016-11-02 15:22:45 -04:00
#pragma once
#include <X11/Xutil.h>
#include "common.hpp"
2016-11-19 00:22:44 -05:00
POLYBAR_NS
2016-11-02 15:22:45 -04:00
namespace xlib {
extern Display* g_display;
extern XVisualInfo g_visual_info;
extern Display* get_display();
extern Visual* get_visual(int screen = 0);
extern Colormap create_colormap(int screen = 0);
/**
* RAII wrapper for Xlib display locking
*/
class xlib_lock {
public:
explicit xlib_lock(Display* display) {
XLockDisplay(display);
m_display = display;
}
~xlib_lock() {
XUnlockDisplay(m_display);
}
protected:
Display* m_display;
};
inline auto make_display_lock() {
return make_unique<xlib_lock>(get_display());
}
}
2016-11-19 00:22:44 -05:00
POLYBAR_NS_END