fix(tray): Follow window fade

This commit is contained in:
Michael Carlberg 2016-12-16 07:10:45 +01:00
parent a7005be82c
commit 697638db2b
5 changed files with 17 additions and 1 deletions

View File

@ -80,6 +80,9 @@ namespace signals {
const ValueType* operator()() const { const ValueType* operator()() const {
return reinterpret_cast<const ValueType*>(&m_data); return reinterpret_cast<const ValueType*>(&m_data);
} }
const ValueType* data() const {
return reinterpret_cast<const ValueType*>(&m_data);
}
private: private:
char m_data[sizeof(ValueType)]; char m_data[sizeof(ValueType)];
@ -112,6 +115,7 @@ namespace signals {
namespace ui { namespace ui {
DEFINE_VALUE_SIGNAL(50, button_press, string); DEFINE_VALUE_SIGNAL(50, button_press, string);
DEFINE_VALUE_SIGNAL(51, visibility_change, bool); DEFINE_VALUE_SIGNAL(51, visibility_change, bool);
DEFINE_VALUE_SIGNAL(52, dim_window, double);
} }
namespace parser { namespace parser {

View File

@ -25,6 +25,7 @@ namespace signals {
namespace ui { namespace ui {
struct button_press; struct button_press;
struct visibility_change; struct visibility_change;
struct dim_window;
} }
namespace parser { namespace parser {
struct change_background; struct change_background;

View File

@ -63,7 +63,7 @@ struct tray_settings {
class tray_manager : public xpp::event::sink<evt::expose, evt::visibility_notify, evt::client_message, class tray_manager : public xpp::event::sink<evt::expose, evt::visibility_notify, evt::client_message,
evt::configure_request, evt::resize_request, evt::selection_clear, evt::property_notify, evt::configure_request, evt::resize_request, evt::selection_clear, evt::property_notify,
evt::reparent_notify, evt::destroy_notify, evt::map_notify, evt::unmap_notify>, evt::reparent_notify, evt::destroy_notify, evt::map_notify, evt::unmap_notify>,
public signal_receiver<SIGN_PRIORITY_TRAY, visibility_change> { public signal_receiver<SIGN_PRIORITY_TRAY, visibility_change, dim_window> {
public: public:
using make_type = unique_ptr<tray_manager>; using make_type = unique_ptr<tray_manager>;
static make_type make(); static make_type make();
@ -128,6 +128,7 @@ class tray_manager : public xpp::event::sink<evt::expose, evt::visibility_notify
void handle(const evt::unmap_notify& evt); void handle(const evt::unmap_notify& evt);
bool on(const visibility_change& evt); bool on(const visibility_change& evt);
bool on(const dim_window& evt);
private: private:
connection& m_connection; connection& m_connection;

View File

@ -425,6 +425,7 @@ void bar::handle(const evt::enter_notify&) {
if (m_opts.dimmed) { if (m_opts.dimmed) {
window win{m_connection, m_opts.window}; window win{m_connection, m_opts.window};
wm_util::set_wm_window_opacity(m_connection, m_opts.window, 1.0 * 0xFFFFFFFF); wm_util::set_wm_window_opacity(m_connection, m_opts.window, 1.0 * 0xFFFFFFFF);
m_sig.emit(dim_window{1.0});
m_opts.dimmed = false; m_opts.dimmed = false;
} }
} }
@ -439,6 +440,7 @@ void bar::handle(const evt::leave_notify&) {
if (!m_opts.dimmed) { if (!m_opts.dimmed) {
window win{m_connection, m_opts.window}; window win{m_connection, m_opts.window};
wm_util::set_wm_window_opacity(m_connection, m_opts.window, m_opts.dimvalue * 0xFFFFFFFF); wm_util::set_wm_window_opacity(m_connection, m_opts.window, m_opts.dimvalue * 0xFFFFFFFF);
m_sig.emit(dim_window{double{m_opts.dimvalue}});
m_opts.dimmed = true; m_opts.dimmed = true;
} }
} }

View File

@ -1146,4 +1146,12 @@ bool tray_manager::on(const visibility_change& evt) {
return true; return true;
} }
bool tray_manager::on(const dim_window& evt) {
if (m_activated) {
wm_util::set_wm_window_opacity(m_connection, m_tray, *evt.data() * 0xFFFFFFFF);
}
// let the event bubble
return false;
}
POLYBAR_NS_END POLYBAR_NS_END