mirror of
https://github.com/polybar/polybar.git
synced 2024-10-27 05:23:39 -04:00
Use bar window depth for tray pixmap
This commit is contained in:
parent
6fa85d2ce8
commit
ab2b5f603c
3 changed files with 24 additions and 21 deletions
|
@ -95,10 +95,10 @@ class tray_manager : public xpp::event::sink<evt::expose, evt::visibility_notify
|
||||||
signals::ui::update_background, signals::ui_tray::tray_pos_change> {
|
signals::ui::update_background, signals::ui_tray::tray_pos_change> {
|
||||||
public:
|
public:
|
||||||
using make_type = unique_ptr<tray_manager>;
|
using make_type = unique_ptr<tray_manager>;
|
||||||
static make_type make(const bar_settings& settings);
|
static make_type make(const bar_settings& bar_opts);
|
||||||
|
|
||||||
explicit tray_manager(connection& conn, signal_emitter& emitter, const logger& logger, background_manager& back,
|
explicit tray_manager(connection& conn, signal_emitter& emitter, const logger& logger, background_manager& back,
|
||||||
const bar_settings& settings);
|
const bar_settings& bar_opts);
|
||||||
|
|
||||||
~tray_manager();
|
~tray_manager();
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,8 @@ bar::make_type bar::make(loop& loop, bool only_initialize_values) {
|
||||||
* TODO: Break out all tray handling
|
* TODO: Break out all tray handling
|
||||||
*/
|
*/
|
||||||
bar::bar(connection& conn, signal_emitter& emitter, const config& config, const logger& logger, loop& loop,
|
bar::bar(connection& conn, signal_emitter& emitter, const config& config, const logger& logger, loop& loop,
|
||||||
unique_ptr<screen>&& screen, unique_ptr<tags::dispatch>&& dispatch, unique_ptr<tags::action_context>&& action_ctxt,
|
unique_ptr<screen>&& screen, unique_ptr<tags::dispatch>&& dispatch,
|
||||||
bool only_initialize_values)
|
unique_ptr<tags::action_context>&& action_ctxt, bool only_initialize_values)
|
||||||
: m_connection(conn)
|
: m_connection(conn)
|
||||||
, m_sig(emitter)
|
, m_sig(emitter)
|
||||||
, m_conf(config)
|
, m_conf(config)
|
||||||
|
|
|
@ -48,14 +48,14 @@ POLYBAR_NS
|
||||||
/**
|
/**
|
||||||
* Create instance
|
* Create instance
|
||||||
*/
|
*/
|
||||||
tray_manager::make_type tray_manager::make(const bar_settings& settings) {
|
tray_manager::make_type tray_manager::make(const bar_settings& bar_opts) {
|
||||||
return std::make_unique<tray_manager>(
|
return std::make_unique<tray_manager>(
|
||||||
connection::make(), signal_emitter::make(), logger::make(), background_manager::make(), settings);
|
connection::make(), signal_emitter::make(), logger::make(), background_manager::make(), bar_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
tray_manager::tray_manager(connection& conn, signal_emitter& emitter, const logger& logger, background_manager& back,
|
tray_manager::tray_manager(connection& conn, signal_emitter& emitter, const logger& logger, background_manager& back,
|
||||||
const bar_settings& settings)
|
const bar_settings& bar_opts)
|
||||||
: m_connection(conn), m_sig(emitter), m_log(logger), m_background_manager(back), m_bar_opts(settings) {
|
: m_connection(conn), m_sig(emitter), m_log(logger), m_background_manager(back), m_bar_opts(bar_opts) {
|
||||||
m_connection.attach_sink(this, SINK_PRIORITY_TRAY);
|
m_connection.attach_sink(this, SINK_PRIORITY_TRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,19 +248,22 @@ void tray_manager::deactivate(bool clear_selection) {
|
||||||
if (m_tray) {
|
if (m_tray) {
|
||||||
m_log.trace("tray: Destroy window");
|
m_log.trace("tray: Destroy window");
|
||||||
m_connection.destroy_window(m_tray);
|
m_connection.destroy_window(m_tray);
|
||||||
}
|
m_tray = 0;
|
||||||
m_context.reset();
|
|
||||||
m_surface.reset();
|
|
||||||
if (m_pixmap) {
|
|
||||||
m_connection.free_pixmap(m_pixmap);
|
|
||||||
}
|
|
||||||
if (m_gc) {
|
|
||||||
m_connection.free_gc(m_gc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tray = 0;
|
m_context.reset();
|
||||||
|
m_surface.reset();
|
||||||
|
|
||||||
|
if (m_pixmap) {
|
||||||
|
m_connection.free_pixmap(m_pixmap);
|
||||||
m_pixmap = 0;
|
m_pixmap = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_gc) {
|
||||||
|
m_connection.free_gc(m_gc);
|
||||||
m_gc = 0;
|
m_gc = 0;
|
||||||
|
}
|
||||||
|
|
||||||
m_opts.win_size.w = 0;
|
m_opts.win_size.w = 0;
|
||||||
m_opts.num_clients = 0;
|
m_opts.num_clients = 0;
|
||||||
m_acquired_selection = false;
|
m_acquired_selection = false;
|
||||||
|
@ -516,9 +519,9 @@ void tray_manager::create_bg() {
|
||||||
|
|
||||||
if (!m_pixmap) {
|
if (!m_pixmap) {
|
||||||
try {
|
try {
|
||||||
|
auto depth = m_connection.get_geometry(m_bar_opts.window)->depth;
|
||||||
m_pixmap = m_connection.generate_id();
|
m_pixmap = m_connection.generate_id();
|
||||||
// TODO get depth from bar window
|
m_connection.create_pixmap_checked(depth, m_pixmap, m_tray, w, h);
|
||||||
m_connection.create_pixmap_checked(32, m_pixmap, m_tray, w, h);
|
|
||||||
} catch (const exception& err) {
|
} catch (const exception& err) {
|
||||||
return m_log.err("Failed to create pixmap for tray background (err: %s)", err.what());
|
return m_log.err("Failed to create pixmap for tray background (err: %s)", err.what());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue