polybar-dwm/include/components/x11/xlib.hpp
Michael Carlberg efba06dc2d fix(xft): Allocate xft color by value
- Solves the issue with transparency using Xft.
- X11 fonts are still affected by the alpha issue.

Closes jaagr/lemonbuddy#119
2016-10-30 02:37:56 +01:00

61 lines
1.2 KiB
C++

#pragma once
#include <X11/Xutil.h>
#include "common.hpp"
LEMONBUDDY_NS
namespace xlib {
static Display* g_display = nullptr;
static XVisualInfo g_visual_info;
/**
* Get pointer of Xlib Display
*/
inline Display* get_display() {
if (g_display == nullptr)
g_display = XOpenDisplay(nullptr);
return g_display;
}
/**
* Get pointer of Xlib visual
*/
inline Visual* get_visual(int screen = 0) {
if (g_visual_info.visual == nullptr) {
XMatchVisualInfo(get_display(), screen, 32, TrueColor, &g_visual_info);
}
return g_visual_info.visual;
}
inline Colormap create_colormap(int screen = 0) {
return XCreateColormap(get_display(), XRootWindow(get_display(), screen), get_visual(), screen);
}
/**
* 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());
// }
}
LEMONBUDDY_NS_END