-
-
Notifications
You must be signed in to change notification settings - Fork 735
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
Add module "sway/hide" for swaybar integration #860
Conversation
} | ||
|
||
void Hide::onEvent(const struct Ipc::ipc_response& res) { | ||
auto payload = parser_.parse(res.payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a mutex here, might fix your crash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My C++ knowledge is almost 0, I just copy pasted some bits from other places that looked correct. 😞
2253f3e crashes less, but it still fails. Logs:
**
Gtk:ERROR:../gtk/gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
**
Gtk:ERROR:../gtk/gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
Bail out! Gtk:ERROR:../gtk/gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
Bail out! Gtk:ERROR:../gtk/gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
Aborted (core dumped)
Sounds like hiding a painting bar is a no-no.
I think the mutex should be on the setVisible
module for the bar itself, but waiting for the first paint. Is there some kind of event queue where we can add the hide/show events, instead of being done ASAP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased this to the latest master and force-pushed
Configuration option `layer` can now take a value "overlay", which draws the bar on top of the windows without creating an exclusive zone.
This allows auto-showing the bar when the modifier is pressed Closes Alexays#255 Setup instructions: - Set the `mode` of the bar to "hide" in sway configuration file - Set the `layer` of the bar to "overlay" in Waybar configuration file - Add "sway/hide" into `modules-left` in Waybar configuration file
Currently, it won't build. I am unfamiliar with C++, I don't know what's wrong.
This is also a rebase-fix
Call this when toggling visibility with SIGUSR1, and for `sway/hide` events.
This doesn't solve the issue, but it crashes less often...
Keep this as similar to "upstream" as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try to rework waybar::Bar
in order to provide methods to apply certain parts of the bar_config object, but that'll have to wait until the weekend.
Switching to Gio::Socket
in the main loop might resolve all threading issues. But that's a lot of refactoring for sway ipc code...
@@ -22,6 +22,9 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name) const { | |||
if (ref == "sway/window") { | |||
return new waybar::modules::sway::Window(id, bar_, config_[name]); | |||
} | |||
if (ref == "sway/hide") { | |||
return new waybar::modules::sway::Hide(id, bar_, config_[name]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should that be a module?
Maybe we can implement it as a generic SwayBarConfigHandler class that is created by the waybar::Client
instance when the SWAYSOCK is defined and controls all the bars.
The benefit is that on multi-monitor configurations bar events would be handled once.
|
||
void Hide::onEvent(const struct Ipc::ipc_response& res) { | ||
auto payload = parser_.parse(res.payload); | ||
if (payload.isMember("mode")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that each waybar instance supposed to have bar id (waybar -b bar-0
) and events from sway could be addressed to the specific bar or to all bars.
Somewhere around here you should check if the current waybar instance needs to handle the event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to use just call setVisible
on the bar_
object, but I got an error about mismatching const
which is above my meagre C++-fu.
This is a CSS-only change. It should be properly hidden.
@alebastr Thanks for the review. From the GTK logs, a mutex on the I don't know enough C++ to do much more than this, but I'm available for testing. |
Continued in #1241 |
Rebases and continues work by @xPMo in https://github.com/xPMo/Waybar/tree/sway-hide
This allows auto-showing the bar when the modifier is pressed
Closes #255
Setup instructions:
mode
of the bar to "hide" in sway configuration filemodules-left
in Waybar configuration file