From cbe4521737087a3113720b040cc0e043358188c7 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Tue, 18 May 2021 11:05:02 +0200
Subject: [PATCH] tray: Do not swallow clear_window exceptions
---
src/x11/tray_client.cpp | 9 +++------
src/x11/tray_manager.cpp | 16 ++++++++++++----
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/x11/tray_client.cpp b/src/x11/tray_client.cpp
index 9075083f..12978fad 100644
--- a/src/x11/tray_client.cpp
+++ b/src/x11/tray_client.cpp
@@ -1,9 +1,10 @@
+#include "x11/tray_client.hpp"
+
#include
#include
#include "utils/memory.hpp"
#include "x11/connection.hpp"
-#include "x11/tray_client.hpp"
#include "x11/xembed.hpp"
POLYBAR_NS
@@ -28,11 +29,7 @@ unsigned int tray_client::height() const {
}
void tray_client::clear_window() const {
- try {
- m_connection.clear_area_checked(1, window(), 0, 0, width(), height());
- } catch (const xpp::x::error::window& err) {
- // ignore
- }
+ m_connection.clear_area_checked(1, window(), 0, 0, width(), height());
}
/**
diff --git a/src/x11/tray_manager.cpp b/src/x11/tray_manager.cpp
index 44bac367..f8414538 100644
--- a/src/x11/tray_manager.cpp
+++ b/src/x11/tray_manager.cpp
@@ -427,13 +427,21 @@ void tray_manager::refresh_window() {
m_connection.poly_fill_rectangle(m_pixmap, m_gc, 1, &rect);
}
- if (m_surface)
+ if (m_surface) {
m_surface->flush();
+ }
m_connection.clear_area(0, m_tray, 0, 0, width, height);
for (auto&& client : m_clients) {
- client->clear_window();
+ try {
+ if (client->mapped()) {
+ client->clear_window();
+ }
+ } catch (const std::exception& e) {
+ m_log.err("Failed to clear tray client %s '%s' (%s)", m_connection.id(client->window()),
+ ewmh_util::get_wm_name(client->window()), e.what());
+ }
}
m_connection.flush();
@@ -477,8 +485,8 @@ void tray_manager::create_window() {
<< cw_class(XCB_WINDOW_CLASS_INPUT_OUTPUT)
<< cw_params_backing_store(XCB_BACKING_STORE_WHEN_MAPPED)
<< cw_params_event_mask(XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT
- |XCB_EVENT_MASK_STRUCTURE_NOTIFY
- |XCB_EVENT_MASK_EXPOSURE)
+ |XCB_EVENT_MASK_STRUCTURE_NOTIFY
+ |XCB_EVENT_MASK_EXPOSURE)
<< cw_params_override_redirect(true);
// clang-format on