2016-12-05 19:41:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <xcb/xcb.h>
|
|
|
|
|
2022-10-01 20:24:23 +00:00
|
|
|
#include "cairo/context.hpp"
|
|
|
|
#include "cairo/surface.hpp"
|
2016-12-05 19:41:00 +00:00
|
|
|
#include "common.hpp"
|
|
|
|
#include "utils/concurrency.hpp"
|
2022-10-01 20:24:23 +00:00
|
|
|
#include "x11/background_manager.hpp"
|
2021-09-08 16:13:21 +00:00
|
|
|
#include "x11/xembed.hpp"
|
2016-12-05 19:41:00 +00:00
|
|
|
|
2022-09-11 19:47:50 +00:00
|
|
|
/*
|
|
|
|
* Manages the lifecycle of a tray client according to the XEMBED protocol
|
|
|
|
*
|
|
|
|
* Ref: https://specifications.freedesktop.org/xembed-spec/xembed-spec-latest.html
|
|
|
|
*/
|
|
|
|
|
2016-12-05 19:41:00 +00:00
|
|
|
POLYBAR_NS
|
|
|
|
|
|
|
|
// fwd declarations
|
|
|
|
class connection;
|
|
|
|
|
2022-10-31 22:21:00 +00:00
|
|
|
namespace tray {
|
|
|
|
|
|
|
|
class client : public non_copyable_mixin, public non_movable_mixin {
|
2016-12-05 19:41:00 +00:00
|
|
|
public:
|
2022-10-31 22:21:00 +00:00
|
|
|
explicit client(
|
2023-03-23 22:03:45 +00:00
|
|
|
const logger& log, connection& conn, xcb_window_t parent, xcb_window_t win, size s, rgba desired_background);
|
2022-10-31 22:21:00 +00:00
|
|
|
~client();
|
2016-12-05 19:41:00 +00:00
|
|
|
|
2022-09-14 19:53:02 +00:00
|
|
|
string name() const;
|
|
|
|
|
2017-01-19 10:11:28 +00:00
|
|
|
unsigned int width() const;
|
|
|
|
unsigned int height() const;
|
2016-12-21 22:22:02 +00:00
|
|
|
void clear_window() const;
|
2016-12-05 19:41:00 +00:00
|
|
|
|
2022-04-04 19:06:17 +00:00
|
|
|
void update_client_attributes() const;
|
|
|
|
void reparent() const;
|
|
|
|
|
2016-12-21 22:22:02 +00:00
|
|
|
bool match(const xcb_window_t& win) const;
|
|
|
|
bool mapped() const;
|
|
|
|
void mapped(bool state);
|
2016-12-05 19:41:00 +00:00
|
|
|
|
2022-08-27 21:02:34 +00:00
|
|
|
void hidden(bool state);
|
|
|
|
|
2022-09-14 20:12:13 +00:00
|
|
|
bool should_be_mapped() const;
|
|
|
|
|
2022-03-07 14:12:42 +00:00
|
|
|
xcb_window_t embedder() const;
|
2022-10-31 22:21:00 +00:00
|
|
|
xcb_window_t client_window() const;
|
2021-09-08 16:13:21 +00:00
|
|
|
|
|
|
|
void query_xembed();
|
|
|
|
bool is_xembed_supported() const;
|
|
|
|
const xembed::info& get_xembed() const;
|
2016-12-05 19:41:00 +00:00
|
|
|
|
2022-04-04 19:06:17 +00:00
|
|
|
void notify_xembed() const;
|
|
|
|
|
|
|
|
void add_to_save_set() const;
|
|
|
|
|
2016-12-21 22:22:02 +00:00
|
|
|
void ensure_state() const;
|
2022-10-01 20:24:23 +00:00
|
|
|
void set_position(int x, int y);
|
2022-04-04 19:06:17 +00:00
|
|
|
void configure_notify() const;
|
2016-12-05 19:41:00 +00:00
|
|
|
|
2022-10-01 20:24:23 +00:00
|
|
|
void update_bg() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void observe_background();
|
|
|
|
|
2022-03-07 14:12:42 +00:00
|
|
|
const logger& m_log;
|
|
|
|
|
2016-12-21 22:22:02 +00:00
|
|
|
connection& m_connection;
|
2022-03-07 14:12:42 +00:00
|
|
|
|
2022-09-14 19:53:02 +00:00
|
|
|
/**
|
|
|
|
* Name of the client window for debugging.
|
|
|
|
*/
|
|
|
|
string m_name{};
|
|
|
|
|
2022-03-07 14:12:42 +00:00
|
|
|
/**
|
|
|
|
* Embedder window.
|
|
|
|
*
|
|
|
|
* The docking client window is reparented to this window.
|
|
|
|
* This window is itself a child of the main tray window.
|
|
|
|
*
|
|
|
|
* This class owns this window and is responsible for creating/destroying it.
|
|
|
|
*/
|
|
|
|
xcb_window_t m_wrapper{XCB_NONE};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Client window.
|
|
|
|
*
|
|
|
|
* The window itself is owned by the application providing it.
|
|
|
|
* This class is responsible for correctly mapping and reparenting it in accordance with the XEMBED protocol.
|
|
|
|
*/
|
|
|
|
xcb_window_t m_client{XCB_NONE};
|
2016-12-05 19:41:00 +00:00
|
|
|
|
2021-09-08 16:13:21 +00:00
|
|
|
/**
|
|
|
|
* Whether the client window supports XEMBED.
|
|
|
|
*
|
|
|
|
* A tray client can still work when it doesn't support XEMBED.
|
|
|
|
*/
|
|
|
|
bool m_xembed_supported{false};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _XEMBED_INFO of the client window
|
2022-03-07 14:12:42 +00:00
|
|
|
*
|
|
|
|
* Only valid if m_xembed_supported == true
|
2021-09-08 16:13:21 +00:00
|
|
|
*/
|
2022-10-31 22:21:00 +00:00
|
|
|
xembed::info m_xembed{};
|
2021-09-08 16:13:21 +00:00
|
|
|
|
2023-03-23 21:38:42 +00:00
|
|
|
/**
|
|
|
|
* Background pixmap of wrapper window
|
|
|
|
*/
|
|
|
|
xcb_pixmap_t m_pixmap{XCB_NONE};
|
|
|
|
|
2022-09-14 20:12:13 +00:00
|
|
|
/**
|
|
|
|
* Whether the wrapper window is currently mapped.
|
|
|
|
*/
|
2016-12-21 22:22:02 +00:00
|
|
|
bool m_mapped{false};
|
2016-12-05 19:41:00 +00:00
|
|
|
|
2022-09-14 20:12:13 +00:00
|
|
|
/**
|
|
|
|
* Whether the
|
|
|
|
*/
|
2022-08-27 21:02:34 +00:00
|
|
|
bool m_hidden{false};
|
|
|
|
|
2022-02-27 20:36:16 +00:00
|
|
|
size m_size;
|
2022-10-01 20:24:23 +00:00
|
|
|
position m_pos{0, 0};
|
|
|
|
|
2023-03-23 22:03:45 +00:00
|
|
|
const rgba m_desired_background;
|
|
|
|
const bool m_transparent{m_desired_background.is_transparent()};
|
2022-10-01 20:24:23 +00:00
|
|
|
background_manager& m_background_manager;
|
2023-03-23 22:03:45 +00:00
|
|
|
shared_ptr<bg_slice> m_bg_slice{nullptr};
|
2022-10-01 20:24:23 +00:00
|
|
|
unique_ptr<cairo::context> m_context;
|
|
|
|
unique_ptr<cairo::xcb_surface> m_surface;
|
2016-12-21 22:22:02 +00:00
|
|
|
};
|
2016-12-05 19:41:00 +00:00
|
|
|
|
2022-10-31 22:21:00 +00:00
|
|
|
} // namespace tray
|
|
|
|
|
2016-12-05 19:41:00 +00:00
|
|
|
POLYBAR_NS_END
|