From ad987098ff10a03f74a5388de0b920cdcf67dd1c Mon Sep 17 00:00:00 2001
From: patrick96
Date: Tue, 18 May 2021 11:02:10 +0200
Subject: [PATCH] fix(tray): Support clients with different depths
XCB_BACK_PIXMAP_PARENT_RELATIVE requires that the client has the same
depth as the tray window.
There was an issue with dropbox having a depth of 32 and the tray window
having a depth of 24 that caused the configuration of the icon to fail.
It would then be displayed outside of the bar because the catch block
was not hit (different exception).
We now just don't configure XCB_CW_BACK_PIXMAP. This seems to work and
is also what stalonetray does.
This does not fix the issue with dropbox having an arbitrary background.
Fixes #1679
Fixes #2430
---
CHANGELOG.md | 2 ++
src/x11/tray_manager.cpp | 16 +++++++---------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2d03d7c4..6fbc5e03 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Build
- Support building documentation on sphinx 4.0 ([`#2424`](https://github.com/polybar/polybar/issues/2424))
+### Fixed
+- Tray icons sometimes appears outside of bar ([`#2430`](https://github.com/polybar/polybar/issues/2430), [`#1679`](https://github.com/polybar/polybar/issues/1679))
## [3.5.5] - 2021-03-01
### Build
diff --git a/src/x11/tray_manager.cpp b/src/x11/tray_manager.cpp
index 5cf503d1..44bac367 100644
--- a/src/x11/tray_manager.cpp
+++ b/src/x11/tray_manager.cpp
@@ -726,7 +726,7 @@ void tray_manager::track_selection_owner(xcb_window_t owner) {
* Process client docking request
*/
void tray_manager::process_docking_request(xcb_window_t win) {
- m_log.info("Processing docking request from %s", m_connection.id(win));
+ m_log.info("Processing docking request from '%s' (%s)", ewmh_util::get_wm_name(win), m_connection.id(win));
m_clients.emplace_back(factory_util::shared(m_connection, win, m_opts.width, m_opts.height));
auto& client = m_clients.back();
@@ -734,18 +734,15 @@ void tray_manager::process_docking_request(xcb_window_t win) {
try {
m_log.trace("tray: Get client _XEMBED_INFO");
xembed::query(m_connection, win, client->xembed());
- } catch (const application_error& err) {
- m_log.err(err.what());
- } catch (const xpp::x::error::window& err) {
+ } catch (const std::exception& err) {
m_log.err("Failed to query _XEMBED_INFO, removing client... (%s)", err.what());
remove_client(win, true);
return;
}
try {
- const unsigned int mask{XCB_CW_BACK_PIXMAP | XCB_CW_EVENT_MASK};
- const unsigned int values[]{
- XCB_BACK_PIXMAP_PARENT_RELATIVE, XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY};
+ const unsigned int mask = XCB_CW_EVENT_MASK;
+ const unsigned int values[]{XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY};
m_log.trace("tray: Update client window");
m_connection.change_window_attributes_checked(client->window(), mask, values);
@@ -767,8 +764,9 @@ void tray_manager::process_docking_request(xcb_window_t win) {
m_log.trace("tray: Map client");
m_connection.map_window_checked(client->window());
}
- } catch (const xpp::x::error::window& err) {
- m_log.err("Failed to setup tray client, removing... (%s)", err.what());
+
+ } catch (const std::exception& err) {
+ m_log.err("Failed to setup tray client removing... (%s)", err.what());
remove_client(win, false);
}
}