fix(window): title on new workspace

pull/70/head
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 /.vscode
*.swp *.swp
packagecache packagecache
/subprojects/fmt-4.1.0 /subprojects/**/
/build /build
/dist /dist
/meson.egg-info /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_manager_v1_get_xdg_output(client.xdg_output_manager, *output);
zxdg_output_v1_add_listener(xdg_output_, &xdgOutputListener, this); zxdg_output_v1_add_listener(xdg_output_, &xdgOutputListener, this);
window.set_title("waybar"); window.set_title("waybar");
window.set_decorated(false);
window.set_name("waybar"); window.set_name("waybar");
window.set_decorated(false);
window.set_resizable(false); window.set_resizable(false);
setupConfig(); setupConfig();
setupCss(); setupCss();
setupWidgets();
Gtk::Widget& wrap(window); auto wrap = reinterpret_cast<GtkWidget*>(window.gobj());
gtk_widget_realize(wrap.gobj()); gtk_widget_realize(wrap);
GdkWindow *gdk_window = gtk_widget_get_window(wrap.gobj()); GdkWindow *gdk_window = gtk_widget_get_window(wrap);
gdk_wayland_window_set_use_custom_surface(gdk_window); gdk_wayland_window_set_use_custom_surface(gdk_window);
surface = gdk_wayland_window_get_wl_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); zwlr_layer_surface_v1_set_size(layer_surface, width, height);
wl_surface_commit(surface); wl_surface_commit(surface);
setupWidgets();
} }
void waybar::Bar::handleLogicalPosition(void* /*data*/, void waybar::Bar::handleLogicalPosition(void* /*data*/,

View File

@ -33,6 +33,7 @@ void Host::nameAppeared(GDBusConnection* connection,
auto host = static_cast<SNI::Host *>(data); auto host = static_cast<SNI::Host *>(data);
if (host->cancellable_ != nullptr) { if (host->cancellable_ != nullptr) {
// TODO // TODO
return;
} }
host->cancellable_ = g_cancellable_new(); host->cancellable_ = g_cancellable_new();
sn_watcher_proxy_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) Glib::Dispatcher *dp, Json::Value config)
: bus_name(bn), object_path(op), event_box(), icon_size(16), : bus_name(bn), object_path(op), event_box(), icon_size(16),
effective_icon_size(0), image(Gtk::manage(new Gtk::Image())), effective_icon_size(0), image(Gtk::manage(new Gtk::Image())),
dp_(dp), config_(config) { dp_(dp), config_(config)
{
if (config_["icon-size"].isUInt()) { if (config_["icon-size"].isUInt()) {
icon_size = config_["icon-size"].asUInt(); icon_size = config_["icon-size"].asUInt();
} }
@ -172,10 +173,12 @@ waybar::modules::SNI::Item::extractPixBuf(GVariant *variant) {
void waybar::modules::SNI::Item::updateMenu() void waybar::modules::SNI::Item::updateMenu()
{ {
event_box.set_tooltip_text(title); event_box.set_tooltip_text(title);
if (!menu.empty()) { if (gtk_menu == nullptr && !menu.empty()) {
auto *dbmenu = dbusmenu_gtkmenu_new(bus_name.data(), menu.data()); auto dbmenu = dbusmenu_gtkmenu_new(bus_name.data(), menu.data());
if (dbmenu) { if (dbmenu != nullptr) {
g_object_ref_sink(dbmenu);
gtk_menu = Glib::wrap(GTK_MENU(dbmenu), false); 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) { bool waybar::modules::SNI::Item::handleClick(GdkEventButton *const &ev) {
if (ev->type == GDK_BUTTON_PRESS) { if (ev->type == GDK_BUTTON_PRESS) {
if (gtk_menu) { if (gtk_menu && gtk_menu->get_children().size() > 0) {
if (!gtk_menu->get_attach_widget()) { #if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu->attach_to_widget(event_box); 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); gtk_menu->popup(ev->button, ev->time);
#endif
gtk_menu->set_state_flags(Gtk::STATE_FLAG_ACTIVE, false);
} else { } else {
sn_item_call_activate( sn_item_call_activate(
proxy_, ev->x, ev->y, nullptr, &Item::handleActivate, this); 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"); label_.set_name("window");
ipc_.connect(); ipc_.connect();
ipc_.subscribe("[ \"window\" ]"); ipc_.subscribe("[\"window\",\"workspace\"]");
getFocusedWindow(); getFocusedWindow();
// Launch worker // Launch worker
worker(); worker();
@ -22,9 +22,11 @@ void waybar::modules::sway::Window::worker()
window_ = parsed["container"]["name"].asString(); window_ = parsed["container"]["name"].asString();
windowId_ = parsed["container"]["id"].asInt(); windowId_ = parsed["container"]["id"].asInt();
dp.emit(); dp.emit();
} else if (parsed["change"] == "close" } else if ((parsed["change"] == "close"
&& parsed["container"]["focused"].asBool() && 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(); window_.clear();
windowId_ = -1; windowId_ = -1;
dp.emit(); dp.emit();