Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tray: Embed in bar window #2609

Merged
merged 69 commits into from
Mar 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
18485d0
Cleanup tray code
patrick96 Feb 27, 2022
3244b10
Make tray window a bar subwindow
patrick96 Feb 27, 2022
ba0e478
Cleanup tray position handling
patrick96 Feb 27, 2022
7acd4c7
xcb: Cleanup value packing
patrick96 Mar 6, 2022
6fa85d2
Remove unused parameter
patrick96 Mar 6, 2022
ab2b5f6
Use bar window depth for tray pixmap
patrick96 Mar 7, 2022
ab7612e
tray: Make m_clients exclusive owner of clients
patrick96 Mar 7, 2022
9544130
Fix screen messing up if client docking fails
patrick96 Mar 7, 2022
3711e99
Use individual wrapper window for each tray client
patrick96 Mar 7, 2022
b8c275d
Fix BadMatch error for wrapper window
patrick96 Mar 16, 2022
9b1afe7
Cleanup selection of visual for bar window
patrick96 Mar 16, 2022
6043f85
controller: Keep only eventloop in try-catch
patrick96 Mar 16, 2022
b5c742a
Use connection.root() to get root window
patrick96 Mar 16, 2022
48d8187
Collect bar window, visual, and depth in bar_settings
patrick96 Mar 16, 2022
81d1f74
Move client configuration into tray_client
patrick96 Apr 4, 2022
bdfe655
tray: Reuse bar visual
patrick96 Apr 4, 2022
9ad73da
tray: Remove calculate_client_x
patrick96 Apr 4, 2022
d743a22
--wip-- [skip ci]
patrick96 Apr 15, 2022
4bbb28b
Merge remote-tracking branch 'upstream/master' into tray-child-window
patrick96 Jul 25, 2022
9c75954
tray: Remove background_manager
patrick96 Jul 25, 2022
dca9e15
tray: Store position relative to inner area
patrick96 Jul 26, 2022
ef06472
tray: Remove tray window
patrick96 Aug 27, 2022
d658c07
tray: Cleanup tray settings
patrick96 Aug 28, 2022
de560fe
tray: Remove mutex
patrick96 Aug 28, 2022
1dcff93
tray: Stop listening to ui::visibility_change
patrick96 Aug 28, 2022
ffcdf7d
tray: Start tray from module
patrick96 Aug 28, 2022
03a2e6b
tray: Read width directly from tray_manager
patrick96 Aug 28, 2022
b72458a
tray: Load settings from module section
patrick96 Sep 3, 2022
1127792
tray: Update module using callback
patrick96 Sep 3, 2022
901183a
tray: Fix tray not updating after (un)map_notify
patrick96 Sep 3, 2022
fe96602
Merge remote-tracking branch 'upstream/master' into tray-child-window
patrick96 Sep 4, 2022
3b9ff04
tray: Fix build error
patrick96 Sep 4, 2022
ea5ffdd
Merge remote-tracking branch 'upstream/master' into tray-child-window
patrick96 Sep 11, 2022
60173e5
tray: Better lifecycle handling
patrick96 Sep 11, 2022
8ec9807
Merge remote-tracking branch 'upstream/master' into tray-child-window
patrick96 Sep 13, 2022
5fd62ed
tray: Cleanup logging
patrick96 Sep 14, 2022
63c6b13
tray: Cleanup client state handling
patrick96 Sep 14, 2022
627d43d
tray: Set _NET_SYSTEM_TRAY_ORIENTATION
patrick96 Sep 19, 2022
0c223ae
fix(tray): Too many printf directives
patrick96 Sep 19, 2022
5c38d5c
tray: Store clients in unique_ptr
patrick96 Sep 24, 2022
def2682
tray: Set _NET_SYSTEM_TRAY_VISUAL
patrick96 Sep 26, 2022
463ef96
Add pseudo transparency back to tray icons
patrick96 Oct 1, 2022
ae3deab
Remove unused operator==
patrick96 Oct 1, 2022
2e902fe
Add .cache to gitignore
patrick96 Oct 5, 2022
0096fea
Merge remote-tracking branch 'upstream/master' into tray-child-window
patrick96 Oct 5, 2022
3cfa012
tray: Fix infinite update loop
patrick96 Oct 9, 2022
d699765
cleanup
patrick96 Oct 9, 2022
6d74ae5
Merge remote-tracking branch 'upstream/master' into tray-child-window
patrick96 Oct 16, 2022
7049c75
--wip-- [skip ci] tray experiments
patrick96 Oct 16, 2022
cfe9a81
clang-format: Only indent inner namespaces
patrick96 Oct 31, 2022
ca25b56
tray: Add back legacy tray implementation
patrick96 Oct 31, 2022
f5d1689
tray: Cleanup
patrick96 Oct 31, 2022
d296d67
Merge remote-tracking branch 'upstream/master' into tray-child-window
patrick96 Oct 31, 2022
aadd4ce
Remove screen realloc argument
patrick96 Nov 30, 2022
6527988
Replace wait_for_response with handle callback
patrick96 Nov 30, 2022
e8870d6
tray: Prevent crash when no wallpaper is found
patrick96 Dec 21, 2022
1aeac22
Delete tray client pixmap and gc in destructor
patrick96 Mar 23, 2023
f6172e1
Remove tray client gc
patrick96 Mar 23, 2023
89f29fa
tray: documentation
patrick96 Mar 23, 2023
58e0911
tray: Disable pseudo-transparency for opaque bgs
patrick96 Mar 23, 2023
47f6d9c
renderer: documentation
patrick96 Mar 23, 2023
616b3fe
color: fix tests
patrick96 Mar 23, 2023
ac589b3
Remove TODOs
patrick96 Mar 25, 2023
3e3a380
tray: Remove option TODOs
patrick96 Mar 25, 2023
23153c3
tray: Address rendering related TODOs
patrick96 Mar 25, 2023
f3ce047
tray: Remove delayed notifications
patrick96 Mar 25, 2023
1174645
tray: Cleanup & documentation
patrick96 Mar 25, 2023
04fefa0
fix(tray): Correct y-position with border
patrick96 Mar 25, 2023
921e2d0
Merge remote-tracking branch 'upstream/master' into tray-child-window
patrick96 Mar 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Language: Cpp
Standard: c++17
BasedOnStyle: Google
ColumnLimit: 120
NamespaceIndentation: All
NamespaceIndentation: Inner
AlignAfterOpenBracket: DontAlign
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
/.cache

polybar-*.tar
*.cache
6 changes: 4 additions & 2 deletions include/components/bar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ class connection;
class logger;
class renderer;
class screen;
namespace legacy_tray {
class tray_manager;
}

namespace tags {
class dispatch;
class dispatch;
}
// }}}

Expand Down Expand Up @@ -92,7 +94,7 @@ class bar : public xpp::event::sink<evt::button_press, evt::expose, evt::propert
const logger& m_log;
eventloop::loop& m_loop;
unique_ptr<screen> m_screen;
unique_ptr<tray_manager> m_tray;
unique_ptr<legacy_tray::tray_manager> m_tray;
unique_ptr<renderer> m_renderer;
unique_ptr<tags::dispatch> m_dispatch;
unique_ptr<tags::action_context> m_action_ctxt;
Expand Down
1 change: 1 addition & 0 deletions include/components/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class controller : public signal_receiver<SIGN_PRIORITY_CONTROLLER, signals::eve

protected:
void trigger_notification();
void start_modules();
void read_events(bool confwatch);
void process_inputdata(string&& cmd);
bool process_update(bool force);
Expand Down
2 changes: 1 addition & 1 deletion include/components/eventloop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ namespace eventloop {
UV(uv_accept, this->template get<uv_stream_t>(), client.template get<uv_stream_t>());
}

void read_start(cb_read &&fun, cb_void&& eof_cb, cb_error&& err_cb) {
void read_start(cb_read&& fun, cb_void&& eof_cb, cb_error&& err_cb) {
this->read_callback = std::move(fun);
this->read_eof_cb = std::move(eof_cb);
this->read_err_cb = std::move(err_cb);
Expand Down
16 changes: 10 additions & 6 deletions include/components/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ class logger {

explicit logger(loglevel level);

const logger& operator=(const logger&) const {
return *this;
}

static loglevel parse_verbosity(const string& name, loglevel fallback = loglevel::NONE);

void verbosity(loglevel level);

#ifdef DEBUG_LOGGER // {{{
#ifdef DEBUG_LOGGER // {{{
template <typename... Args>
void trace(const string& message, Args&&... args) const {
output(loglevel::TRACE, message, std::forward<Args>(args)...);
Expand All @@ -57,7 +61,7 @@ class logger {
void trace(Args&&...) const {}
template <typename... Args>
void trace_x(Args&&...) const {}
#endif // }}}
#endif // }}}

/**
* Output an info message
Expand Down Expand Up @@ -118,21 +122,21 @@ class logger {
return;
}

#if defined(__clang__) // {{{
#if defined(__clang__) // {{{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-security"
#endif // }}}
#endif // }}}

dprintf(m_fd, (m_prefixes.at(level) + format + m_suffixes.at(level) + "\n").c_str(), convert(values)...);

#if defined(__clang__) // {{{
#if defined(__clang__) // {{{
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif // }}}
#endif // }}}
}

private:
Expand Down
14 changes: 10 additions & 4 deletions include/components/renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class renderer : public renderer_interface,
~renderer();

xcb_window_t window() const;
xcb_visualtype_t* visual() const;
int depth() const;

void begin(xcb_rectangle_t rect);
void end();
Expand Down Expand Up @@ -102,18 +104,22 @@ class renderer : public renderer_interface,
const bar_settings& m_bar;
std::shared_ptr<bg_slice> m_background;

int m_depth{32};
int m_depth{-1};
xcb_window_t m_window;
xcb_colormap_t m_colormap;
xcb_colormap_t m_colormap{XCB_NONE};
xcb_visualtype_t* m_visual;
xcb_gcontext_t m_gcontext;

/**
* Background pixmap for the bar window
*
* All bar contents are rendered onto this.
*/
xcb_pixmap_t m_pixmap;

xcb_rectangle_t m_rect{0, 0, 0U, 0U};
reserve_area m_cleararea{};

// bool m_autosize{false};

unique_ptr<cairo::context> m_context;
unique_ptr<cairo::xcb_surface> m_surface;
map<alignment, alignment_block> m_blocks;
Expand Down
17 changes: 8 additions & 9 deletions include/components/screen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,16 @@ class logger;
class connection;
class signal_emitter;

class screen : public xpp::event::sink<evt::randr_screen_change_notify> {
class screen : public xpp::event::sink<evt::map_notify, evt::randr_screen_change_notify> {
public:
using make_type = unique_ptr<screen>;
static make_type make();

explicit screen(connection& conn, signal_emitter& emitter, const logger& logger, const config& conf);
~screen();

struct size size() const {
return m_size;
}

xcb_window_t root() const {
return m_root;
}

protected:
void handle(const evt::map_notify& evt) override;
void handle(const evt::randr_screen_change_notify& evt) override;

private:
Expand All @@ -50,6 +43,12 @@ class screen : public xpp::event::sink<evt::randr_screen_change_notify> {
};
bool m_sigraised{false};

/**
* Original event mask on the root window.
* Used to restore event mask after the proxy window is mapped.
*/
uint32_t m_root_mask{0};

bool have_monitors_changed() const;
};

Expand Down
20 changes: 17 additions & 3 deletions include/components/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@ enum class strut {
struct position {
int x{0};
int y{0};

bool operator==(const position& other) {
return this->x == other.x && this->y == other.y;
}
};

struct size {
unsigned int w{1U};
unsigned int h{1U};
unsigned w{1U};
unsigned h{1U};
};

enum class spacing_type { SPACE, POINT, PIXEL };
Expand Down Expand Up @@ -163,11 +167,21 @@ struct action {
string command{};
};

/**
* Settings specific to the X window system.
*/
struct x_settings {
xcb_window_t window{XCB_NONE};
xcb_visualtype_t* visual{nullptr};
int depth{-1};
};

struct bar_settings {
explicit bar_settings() = default;
bar_settings(const bar_settings& other) = default;

xcb_window_t window{XCB_NONE};
x_settings x_data;

monitor_t monitor{};
bool monitor_strict{false};
bool monitor_exact{true};
Expand Down
6 changes: 0 additions & 6 deletions include/events/signal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@ namespace signals {
} // namespace ui

namespace ui_tray {
struct mapped_clients : public detail::value_signal<mapped_clients, unsigned int> {
using base_type::base_type;
};
struct tray_width_change : public detail::value_signal<tray_width_change, unsigned int> {
using base_type::base_type;
};
struct tray_pos_change : public detail::value_signal<tray_pos_change, int> {
using base_type::base_type;
};
Expand Down
2 changes: 0 additions & 2 deletions include/events/signal_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ namespace signals {
struct update_geometry;
} // namespace ui
namespace ui_tray {
struct mapped_clients;
struct tray_width_change;
struct tray_pos_change;
struct tray_visibility;
} // namespace ui_tray
Expand Down
2 changes: 1 addition & 1 deletion include/modules/ipc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ namespace modules {
int m_current_hook{-1};
void exec_hook();
};
} // namespace modules
} // namespace modules

POLYBAR_NS_END
2 changes: 1 addition & 1 deletion include/modules/meta/inotify_module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace modules {

if (!this->running()) {
break;
}
}
}
CAST_MOD(Impl)->idle();
}
Expand Down
29 changes: 14 additions & 15 deletions include/modules/tray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@
#include "common.hpp"
#include "components/bar.hpp"
#include "modules/meta/static_module.hpp"
#include "x11/tray_manager.hpp"

POLYBAR_NS
namespace modules {
class tray_module : public static_module<tray_module>,
public signal_receiver<SIGN_PRIORITY_TRAY, signals::ui_tray::tray_width_change> {
public:
explicit tray_module(const bar_settings& bar_settings, string name_);
string get_format() const;
class tray_module : public static_module<tray_module> {
public:
explicit tray_module(const bar_settings& bar_settings, string name_);
string get_format() const;

bool build(builder* builder, const string& tag) const;
void update() {}
void teardown();
void start() override;

bool on(const signals::ui_tray::tray_width_change& evt) override;
bool build(builder* builder, const string& tag) const;
void update() {}

static constexpr auto TYPE = "internal/tray";
static constexpr auto TYPE = "internal/tray";

private:
static constexpr const char* TAG_TRAY{"<tray>"};
private:
static constexpr const char* TAG_TRAY{"<tray>"};

int m_width{0};
};
} // namespace modules
tray::manager m_tray;
};
} // namespace modules
POLYBAR_NS_END
1 change: 1 addition & 0 deletions include/utils/color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class rgba {
uint8_t blue_i() const;

bool has_color() const;
bool is_transparent() const;
rgba apply_alpha_to(rgba other) const;
rgba try_apply_alpha_to(rgba other) const;

Expand Down