fix(bar): Configure window before remapping

Some WMs like i3 discard position information when unmapping the bar and
because of that the bar would be at the wrong position after being
remapped.

Fixes #1484
Ref: https://github.com/i3/i3/pull/3834
This commit is contained in:
patrick96 2019-10-16 00:30:10 +02:00 committed by Patrick Ziegler
parent a119c3386b
commit fea579ec85
2 changed files with 24 additions and 6 deletions

View File

@ -74,6 +74,8 @@ class bar : public xpp::event::sink<evt::button_press, evt::expose, evt::propert
protected:
void restack_window();
void reconfigue_window();
void reconfigure_geom();
void reconfigure_pos();
void reconfigure_struts();
void reconfigure_wm_hints();

View File

@ -404,6 +404,11 @@ void bar::show() {
try {
m_log.info("Showing bar window");
m_sig.emit(visibility_change{true});
/**
* First reconfigures the window so that WMs that discard some information
* when unmapping have the correct window properties (geometry etc).
*/
reconfigue_window();
m_connection.map_window_checked(m_opts.window);
m_connection.flush();
m_visible = true;
@ -460,6 +465,22 @@ void bar::restack_window() {
}
}
void bar::reconfigue_window() {
m_log.trace("bar: Reconfigure window");
restack_window();
reconfigure_geom();
reconfigure_struts();
reconfigure_wm_hints();
}
/**
* Reconfigure window geometry
*/
void bar::reconfigure_geom() {
window win{m_connection, m_opts.window};
win.reconfigure_geom(m_opts.size.w, m_opts.size.h, m_opts.pos.x, m_opts.pos.y);
}
/**
* Reconfigure window position
*/
@ -796,11 +817,7 @@ bool bar::on(const signals::eventqueue::start&) {
m_connection.ensure_event_mask(m_opts.window, XCB_EVENT_MASK_STRUCTURE_NOTIFY);
m_log.info("Bar window: %s", m_connection.id(m_opts.window));
restack_window();
m_log.trace("bar: Reconfigure window");
reconfigure_struts();
reconfigure_wm_hints();
reconfigue_window();
m_log.trace("bar: Map window");
m_connection.map_window_checked(m_opts.window);
@ -810,7 +827,6 @@ bool bar::on(const signals::eventqueue::start&) {
m_sig.emit(signals::ui::update_geometry{});
// Reconfigure window position after mapping (required by Openbox)
// Required by Openbox
reconfigure_pos();
m_log.trace("bar: Draw empty bar");