fix: Update font visual if depth changes
This commit is contained in:
parent
b2e8428550
commit
b90856157b
@ -55,6 +55,8 @@ class font_manager {
|
||||
font_manager(const font_manager& o) = delete;
|
||||
font_manager& operator=(const font_manager& o) = delete;
|
||||
|
||||
void set_visual(shared_ptr<Visual>&& v);
|
||||
|
||||
void cleanup();
|
||||
bool load(const string& name, int8_t fontindex = DEFAULT_FONT_INDEX, int8_t offset_y = 0);
|
||||
void set_preferred_font(int8_t index);
|
||||
|
@ -8,7 +8,7 @@ POLYBAR_NS
|
||||
|
||||
namespace xlib {
|
||||
shared_ptr<Display> get_display();
|
||||
shared_ptr<Visual> get_visual(int screen = 0);
|
||||
shared_ptr<Visual> get_visual(int screen = 0, uint8_t depth = 32);
|
||||
|
||||
Colormap create_colormap(int screen = 0);
|
||||
|
||||
|
@ -50,6 +50,7 @@ renderer::renderer(connection& conn, signal_emitter& emitter, const logger& logg
|
||||
|
||||
if ((m_visual = m_connection.visual_type(m_connection.screen(), 24)) == nullptr) {
|
||||
m_log.err("No 24-bit TrueColor visual found, aborting...");
|
||||
throw application_error("No matching TrueColor visual found...");
|
||||
}
|
||||
|
||||
if (m_visual == nullptr) {
|
||||
@ -57,6 +58,8 @@ renderer::renderer(connection& conn, signal_emitter& emitter, const logger& logg
|
||||
}
|
||||
|
||||
m_depth = 24;
|
||||
|
||||
m_fontmanager->set_visual(xlib::get_visual(m_connection.default_screen(), m_depth));
|
||||
}
|
||||
|
||||
m_log.trace("renderer: Allocate colormap");
|
||||
|
@ -56,6 +56,10 @@ font_manager::~font_manager() {
|
||||
}
|
||||
}
|
||||
|
||||
void font_manager::set_visual(shared_ptr<Visual>&& v) {
|
||||
m_visual = forward<decltype(v)>(v);
|
||||
}
|
||||
|
||||
void font_manager::cleanup() {
|
||||
if (m_xftdraw != nullptr) {
|
||||
XftDrawDestroy(m_xftdraw);
|
||||
|
@ -15,10 +15,10 @@ namespace xlib {
|
||||
return g_display_ptr;
|
||||
}
|
||||
|
||||
shared_ptr<Visual> get_visual(int screen) {
|
||||
shared_ptr<Visual> get_visual(int screen, uint8_t depth) {
|
||||
if (!g_visual_ptr) {
|
||||
XVisualInfo info{};
|
||||
if (XMatchVisualInfo(get_display().get(), screen, 32, TrueColor, &info)) {
|
||||
if (XMatchVisualInfo(get_display().get(), screen, depth, TrueColor, &info)) {
|
||||
g_visual_ptr = shared_ptr<Visual>(info.visual, [=](Visual* v) { XFree(v); });
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user