fix(window): title on new workspace

This commit is contained in:
Alexis 2018-10-29 21:52:53 +01:00
parent 4307e4fd8e
commit c9a8a07976
5 changed files with 28 additions and 17 deletions

2
.gitignore vendored
View File

@ -4,7 +4,7 @@ vgcore.*
/.vscode
*.swp
packagecache
/subprojects/fmt-4.1.0
/subprojects/**/
/build
/dist
/meson.egg-info

View File

@ -20,16 +20,15 @@ waybar::Bar::Bar(const Client& client,
zxdg_output_manager_v1_get_xdg_output(client.xdg_output_manager, *output);
zxdg_output_v1_add_listener(xdg_output_, &xdgOutputListener, this);
window.set_title("waybar");
window.set_decorated(false);
window.set_name("waybar");
window.set_decorated(false);
window.set_resizable(false);
setupConfig();
setupCss();
setupWidgets();
Gtk::Widget& wrap(window);
gtk_widget_realize(wrap.gobj());
GdkWindow *gdk_window = gtk_widget_get_window(wrap.gobj());
auto wrap = reinterpret_cast<GtkWidget*>(window.gobj());
gtk_widget_realize(wrap);
GdkWindow *gdk_window = gtk_widget_get_window(wrap);
gdk_wayland_window_set_use_custom_surface(gdk_window);
surface = gdk_wayland_window_get_wl_surface(gdk_window);
@ -60,6 +59,8 @@ waybar::Bar::Bar(const Client& client,
zwlr_layer_surface_v1_set_size(layer_surface, width, height);
wl_surface_commit(surface);
setupWidgets();
}
void waybar::Bar::handleLogicalPosition(void* /*data*/,

View File

@ -33,6 +33,7 @@ void Host::nameAppeared(GDBusConnection* connection,
auto host = static_cast<SNI::Host *>(data);
if (host->cancellable_ != nullptr) {
// TODO
return;
}
host->cancellable_ = g_cancellable_new();
sn_watcher_proxy_new(

View File

@ -7,7 +7,8 @@ waybar::modules::SNI::Item::Item(std::string bn, std::string op,
Glib::Dispatcher *dp, Json::Value config)
: bus_name(bn), object_path(op), event_box(), icon_size(16),
effective_icon_size(0), image(Gtk::manage(new Gtk::Image())),
dp_(dp), config_(config) {
dp_(dp), config_(config)
{
if (config_["icon-size"].isUInt()) {
icon_size = config_["icon-size"].asUInt();
}
@ -172,10 +173,12 @@ waybar::modules::SNI::Item::extractPixBuf(GVariant *variant) {
void waybar::modules::SNI::Item::updateMenu()
{
event_box.set_tooltip_text(title);
if (!menu.empty()) {
auto *dbmenu = dbusmenu_gtkmenu_new(bus_name.data(), menu.data());
if (dbmenu) {
if (gtk_menu == nullptr && !menu.empty()) {
auto dbmenu = dbusmenu_gtkmenu_new(bus_name.data(), menu.data());
if (dbmenu != nullptr) {
g_object_ref_sink(dbmenu);
gtk_menu = Glib::wrap(GTK_MENU(dbmenu), false);
gtk_menu->attach_to_widget(event_box);
}
}
}
@ -248,11 +251,15 @@ void waybar::modules::SNI::Item::handleSecondaryActivate(GObject *src,
bool waybar::modules::SNI::Item::handleClick(GdkEventButton *const &ev) {
if (ev->type == GDK_BUTTON_PRESS) {
if (gtk_menu) {
if (!gtk_menu->get_attach_widget()) {
gtk_menu->attach_to_widget(event_box);
}
if (gtk_menu && gtk_menu->get_children().size() > 0) {
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu->popup_at_widget(reinterpret_cast<Gtk::Widget*>(&event_box),
Gdk::GRAVITY_NORTH_WEST, Gdk::GRAVITY_NORTH_WEST,
reinterpret_cast<GdkEvent*>(ev));
#else
gtk_menu->popup(ev->button, ev->time);
#endif
gtk_menu->set_state_flags(Gtk::STATE_FLAG_ACTIVE, false);
} else {
sn_item_call_activate(
proxy_, ev->x, ev->y, nullptr, &Item::handleActivate, this);

View File

@ -5,7 +5,7 @@ waybar::modules::sway::Window::Window(Bar &bar, const Json::Value& config)
{
label_.set_name("window");
ipc_.connect();
ipc_.subscribe("[ \"window\" ]");
ipc_.subscribe("[\"window\",\"workspace\"]");
getFocusedWindow();
// Launch worker
worker();
@ -22,9 +22,11 @@ void waybar::modules::sway::Window::worker()
window_ = parsed["container"]["name"].asString();
windowId_ = parsed["container"]["id"].asInt();
dp.emit();
} else if (parsed["change"] == "close"
} else if ((parsed["change"] == "close"
&& parsed["container"]["focused"].asBool()
&& windowId_ == parsed["container"]["id"].asInt()) {
&& windowId_ == parsed["container"]["id"].asInt())
|| (parsed["change"] == "focus" && parsed["current"]["focus"].isArray()
&& parsed["current"]["focus"].empty())) {
window_.clear();
windowId_ = -1;
dp.emit();