refactor(x11): Close xlib display

This commit is contained in:
Michael Carlberg 2017-01-01 21:11:01 +01:00
parent a2bcb1a627
commit ce7faa9fe7
3 changed files with 8 additions and 9 deletions

View File

@ -21,7 +21,6 @@
using namespace polybar;
int main(int argc, char** argv) {
// std::cout << x << std::Endl;
// clang-format off
const command_line::options opts{
command_line::option{"-h", "--help", "Show help options"},

View File

@ -62,9 +62,13 @@ connection::connection(Display* dsp) : base_type(XGetXCBConnection(dsp)), m_disp
}
connection::~connection() {
if (m_display != nullptr) {
XCloseDisplay(m_display);
} else {
disconnect();
std::for_each(m_visual.begin(), m_visual.end(), [=](pair<uint8_t, Visual*> p) { XFree(p.second); });
m_visual.clear();
}
}
void connection::pack_values(uint32_t mask, const uint32_t* src, uint32_t* dest) {

View File

@ -37,11 +37,7 @@ font_manager::font_manager(connection& conn, const logger& logger)
, m_logger(logger)
, m_display(m_connection)
, m_visual(m_connection.visual())
, m_colormap(XDefaultColormap(m_display, m_connection.default_screen())) {
if (!XftInit(nullptr) || !XftInitFtLibrary()) {
throw application_error("Could not initialize Xft library");
}
}
, m_colormap(XDefaultColormap(m_display, m_connection.default_screen())) {}
font_manager::~font_manager() {
cleanup();