From 20991a3465ebbe5f6e6f8e5549a2f82106dfc160 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Sat, 15 Oct 2016 14:49:53 +0200 Subject: [PATCH] fix(tray): Handle error when trying to restack window --- include/components/x11/connection.hpp | 2 +- include/components/x11/tray.hpp | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/components/x11/connection.hpp b/include/components/x11/connection.hpp index 77acf14c..cb2b0f25 100644 --- a/include/components/x11/connection.hpp +++ b/include/components/x11/connection.hpp @@ -57,7 +57,7 @@ class connection : public xpp_connection { */ auto id(xcb_window_t w) const { return string_util::from_stream( - std::stringstream() << "0x" << std::hex << std::setw(8) << std::setfill('0') << w); + std::stringstream() << "0x" << std::hex << std::setw(7) << std::setfill('0') << w); } /** diff --git a/include/components/x11/tray.hpp b/include/components/x11/tray.hpp index 15ebd4db..5e07ba5f 100644 --- a/include/components/x11/tray.hpp +++ b/include/components/x11/tray.hpp @@ -325,12 +325,17 @@ class traymanager m_settings.width + m_settings.spacing * 2, m_settings.height + m_settings.spacing * 2, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, scr->root_visual, mask, values); - // Put the tray window above the defined sibling in the window stack - if (m_settings.sibling != XCB_NONE) { - const uint32_t value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE; - const uint32_t value_list[2]{m_settings.sibling, XCB_STACK_MODE_ABOVE}; - m_connection.configure_window_checked(m_tray, value_mask, value_list); - m_connection.flush(); + try { + // Put the tray window above the defined sibling in the window stack + if (m_settings.sibling != XCB_NONE) { + const uint32_t value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE; + const uint32_t value_list[2]{m_settings.sibling, XCB_STACK_MODE_ABOVE}; + m_connection.configure_window_checked(m_tray, value_mask, value_list); + m_connection.flush(); + } + } catch (const std::exception& err) { + auto id = m_connection.id(m_settings.sibling); + m_logger.trace("tray: Failed to put tray above %s in the stack (%s)", id, err.what()); } }