From 343d1a2ff21b410ea7dae26542db90a199cd3014 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Wed, 12 Oct 2016 10:50:14 +0200 Subject: [PATCH] fix(tray): Respond to client XCB_RESIZE_REQUEST --- README.md | 2 +- include/components/x11/tray.hpp | 65 +++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index a6578474..e0e783b7 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ A compiler with c++14 support. For example [`clang`](http://clang.llvm.org/get_s - cmake - boost - xcb-util-wm -- libxft +- libXft Optional dependencies for module support: diff --git a/include/components/x11/tray.hpp b/include/components/x11/tray.hpp index af8ba025..d99b4bb4 100644 --- a/include/components/x11/tray.hpp +++ b/include/components/x11/tray.hpp @@ -73,6 +73,27 @@ class trayclient { return m_xembed.get(); } + void configure_notify(int16_t x, int16_t y, uint16_t w, uint16_t h) { + auto notify = reinterpret_cast(calloc(32, 1)); + + notify->response_type = XCB_CONFIGURE_NOTIFY; + notify->event = m_window; + notify->window = m_window; + notify->override_redirect = false; + notify->above_sibling = XCB_NONE; + notify->x = x; + notify->y = y; + notify->width = w; + notify->height = h; + notify->border_width = 0; + + m_connection.send_event( + false, notify->event, XCB_EVENT_MASK_STRUCTURE_NOTIFY, reinterpret_cast(notify)); + m_connection.flush(); + + free(notify); + } + protected: connection& m_connection; xcb_window_t m_window{0}; @@ -85,8 +106,9 @@ class trayclient { class traymanager : public xpp::event::sink { + evt::configure_request, evt::resize_request, evt::selection_clear, evt::selection_notify, + evt::property_notify, evt::reparent_notify, evt::destroy_notify, evt::map_notify, + evt::unmap_notify> { public: explicit traymanager(connection& conn, const logger& logger) : m_connection(conn), m_logger(logger) { @@ -499,28 +521,25 @@ class traymanager * so we return an answer that'll put him in place. */ void handle(const evt::configure_request& evt) { - if (!find_client(evt->window)) - return; + auto client = find_client(evt->window); + if (client) { + m_logger.trace( + "tray: Received configure_request for client %s", m_connection.id(evt->window)); + client->configure_notify(calculate_client_xpos(evt->window), m_settings.spacing, + m_settings.width, m_settings.height); + } + } - m_logger.trace("tray: Received configure_request"); - - auto resp = reinterpret_cast(calloc(32, 1)); - - resp->response_type = XCB_CONFIGURE_NOTIFY; - resp->event = evt->window; - resp->window = evt->window; - resp->override_redirect = false; - resp->above_sibling = XCB_NONE; - resp->x = calculate_client_xpos(evt->window); - resp->y = m_settings.spacing; - resp->width = m_settings.width; - resp->height = m_settings.height; - resp->border_width = 0; - m_connection.send_event( - false, resp->event, XCB_EVENT_MASK_STRUCTURE_NOTIFY, reinterpret_cast(resp)); - m_connection.flush(); - - free(resp); + /** + * @see tray_manager::handle(const evt::configure_request&); + */ + void handle(const evt::resize_request& evt) { + auto client = find_client(evt->window); + if (client) { + m_logger.trace("tray: Received resize_request for client %s", m_connection.id(evt->window)); + client->configure_notify(calculate_client_xpos(evt->window), m_settings.spacing, + m_settings.width, m_settings.height); + } } /**