From 3244b10ce31231475517e9b0290bbf26f95d094e Mon Sep 17 00:00:00 2001 From: patrick96 Date: Sun, 27 Feb 2022 20:42:10 +0100 Subject: [PATCH] Make tray window a bar subwindow Currently requires a dirty workaround to prevent tray icons with different depths from crashing --- include/x11/tray_manager.hpp | 4 ++-- src/x11/tray_manager.cpp | 43 +++++++++--------------------------- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/include/x11/tray_manager.hpp b/include/x11/tray_manager.hpp index 6abaf8ec..cf60488a 100644 --- a/include/x11/tray_manager.hpp +++ b/include/x11/tray_manager.hpp @@ -52,12 +52,13 @@ struct tray_settings { unsigned int height{0U}; unsigned int height_fill{0U}; unsigned int spacing{0U}; - unsigned int sibling{0U}; rgba background{}; rgba foreground{}; bool transparent{false}; bool detached{false}; bool adaptive{false}; + + xcb_window_t bar_window; }; class tray_manager : public xpp::event::sinkroot_depth, m_pixmap, m_tray, w, h); + // TODO get depth from bar window + m_connection.create_pixmap_checked(32, m_pixmap, m_tray, w, h); } catch (const exception& err) { return m_log.err("Failed to create pixmap for tray background (err: %s)", err.what()); } @@ -565,32 +565,6 @@ void tray_manager::create_bg() { } } -/** - * Put tray window above the defined sibling in the window stack - */ -void tray_manager::restack_window() { - if (m_opts.sibling == XCB_NONE) { - return; - } - - try { - m_log.trace("tray: Restacking tray window"); - - unsigned int mask = 0; - unsigned int values[7]; - xcb_params_configure_window_t params{}; - - XCB_AUX_ADD_PARAM(&mask, ¶ms, sibling, m_opts.sibling); - XCB_AUX_ADD_PARAM(&mask, ¶ms, stack_mode, XCB_STACK_MODE_ABOVE); - - connection::pack_values(mask, ¶ms, values); - m_connection.configure_window_checked(m_tray, mask, values); - } catch (const exception& err) { - auto id = m_connection.id(m_opts.sibling); - m_log.err("tray: Failed to put tray above %s in the stack (%s)", id, err.what()); - } -} - /** * Set window WM hints */ @@ -752,6 +726,9 @@ void tray_manager::process_docking_request(xcb_window_t win) { m_log.trace("tray: Add client window to the save set"); m_connection.change_save_set_checked(XCB_SET_MODE_INSERT, client->window()); + // TODO properly support tray icon backgrounds + auto p = XCB_BACK_PIXMAP_NONE; + m_connection.change_window_attributes_checked(client->window(), XCB_CW_BACK_PIXMAP, &p); m_log.trace("tray: Reparent client"); m_connection.reparent_window_checked( client->window(), m_tray, calculate_client_x(client->window()), calculate_client_y());