Hello community,

here is the log from the commit of package waybar for openSUSE:Factory checked 
in at 2019-06-24 21:53:12
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/waybar (Old)
 and      /work/SRC/openSUSE:Factory/.waybar.new.4615 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "waybar"

Mon Jun 24 21:53:12 2019 rev:10 rq:711644 version:0.7.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/waybar/waybar.changes    2019-06-17 
10:35:08.145210342 +0200
+++ /work/SRC/openSUSE:Factory/.waybar.new.4615/waybar.changes  2019-06-24 
21:54:05.556139816 +0200
@@ -1,0 +2,12 @@
+Mon Jun 24 06:42:45 UTC 2019 - mvet...@suse.com
+
+- Update to 0.7.0:
+  Added:
+  * Scrolling threshold #381
+  * Total memory #385
+  Changed:
+  * Improved scroll behavior
+  * Fixed sway/window not showing window title sometimes 486b5a5
+  * Fixed sway/window not showing floating window title dabe2be
+
+-------------------------------------------------------------------

Old:
----
  0.6.9.tar.gz

New:
----
  0.7.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ waybar.spec ++++++
--- /var/tmp/diff_new_pack.QXeDPa/_old  2019-06-24 21:54:06.208140318 +0200
+++ /var/tmp/diff_new_pack.QXeDPa/_new  2019-06-24 21:54:06.212140321 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           waybar
-Version:        0.6.9
+Version:        0.7.0
 Release:        0
 Summary:        Customizable Wayland bar for Sway and Wlroots based compositors
 License:        MIT

++++++ 0.6.9.tar.gz -> 0.7.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/include/ALabel.hpp 
new/Waybar-0.7.0/include/ALabel.hpp
--- old/Waybar-0.6.9/include/ALabel.hpp 2019-06-14 10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/include/ALabel.hpp 2019-06-22 18:17:16.000000000 +0200
@@ -1,41 +1,30 @@
 #pragma once
 
 #include <glibmm/markup.h>
-#include <gtkmm/eventbox.h>
 #include <gtkmm/label.h>
 #include <json/json.h>
-#include "IModule.hpp"
+#include "AModule.hpp"
 
 namespace waybar {
 
-class ALabel : public IModule {
+class ALabel : public AModule {
  public:
   ALabel(const Json::Value &, const std::string &, const std::string &, const 
std::string &format,
          uint16_t interval = 0);
-  virtual ~ALabel();
+  virtual ~ALabel() = default;
   virtual auto        update() -> void;
   virtual std::string getIcon(uint16_t, const std::string &alt = "", uint16_t 
max = 0);
-  virtual             operator Gtk::Widget &();
 
  protected:
-  bool tooltipEnabled();
-
-  Gtk::EventBox              event_box_;
   Gtk::Label                 label_;
-  const Json::Value &        config_;
   std::string                format_;
   std::string                click_param;
-  std::mutex                 mutex_;
   const std::chrono::seconds interval_;
   bool                       alt_ = false;
   std::string                default_format_;
 
-  virtual bool        handleToggle(GdkEventButton *const &ev);
-  virtual bool        handleScroll(GdkEventScroll *);
+  virtual bool        handleToggle(GdkEventButton *const &e);
   virtual std::string getState(uint8_t value, bool lesser = false);
-
- private:
-  std::vector<int> pid_;
 };
 
 }  // namespace waybar
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/include/AModule.hpp 
new/Waybar-0.7.0/include/AModule.hpp
--- old/Waybar-0.6.9/include/AModule.hpp        1970-01-01 01:00:00.000000000 
+0100
+++ new/Waybar-0.7.0/include/AModule.hpp        2019-06-22 18:17:16.000000000 
+0200
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <glibmm/dispatcher.h>
+#include <glibmm/markup.h>
+#include <gtkmm/eventbox.h>
+#include <json/json.h>
+#include "IModule.hpp"
+
+namespace waybar {
+
+class AModule : public IModule {
+ public:
+  AModule(const Json::Value &, const std::string &, const std::string &,
+          bool enable_click = false, bool enable_scroll = false);
+  virtual ~AModule();
+  virtual auto update() -> void;
+  virtual      operator Gtk::Widget &();
+
+  Glib::Dispatcher dp;
+
+ protected:
+  enum SCROLL_DIR { NONE, UP, DOWN, LEFT, RIGHT };
+
+  SCROLL_DIR getScrollDir(GdkEventScroll *e);
+  bool       tooltipEnabled();
+
+  const Json::Value &config_;
+  Gtk::EventBox      event_box_;
+  std::string        click_param_;
+
+  virtual bool handleToggle(GdkEventButton *const &ev);
+  virtual bool handleScroll(GdkEventScroll *);
+
+ private:
+  std::vector<int> pid_;
+  gdouble          distance_scrolled_y_;
+  gdouble          distance_scrolled_x_;
+};
+
+}  // namespace waybar
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/include/IModule.hpp 
new/Waybar-0.7.0/include/IModule.hpp
--- old/Waybar-0.6.9/include/IModule.hpp        2019-06-14 10:27:41.000000000 
+0200
+++ new/Waybar-0.7.0/include/IModule.hpp        2019-06-22 18:17:16.000000000 
+0200
@@ -1,7 +1,5 @@
 #pragma once
 
-#include <glibmm/dispatcher.h>
-#include <gtkmm/box.h>
 #include <gtkmm/widget.h>
 
 namespace waybar {
@@ -11,7 +9,6 @@
   virtual ~IModule() = default;
   virtual auto     update() -> void = 0;
   virtual          operator Gtk::Widget &() = 0;
-  Glib::Dispatcher dp;  // Hmmm Maybe I should create an abstract class ?
 };
 
 }  // namespace waybar
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/include/bar.hpp 
new/Waybar-0.7.0/include/bar.hpp
--- old/Waybar-0.6.9/include/bar.hpp    2019-06-14 10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/include/bar.hpp    2019-06-22 18:17:16.000000000 +0200
@@ -4,8 +4,9 @@
 #include <gtkmm/cssprovider.h>
 #include <gtkmm/main.h>
 #include <gtkmm/window.h>
+#include <gtkmm/box.h>
 #include <json/json.h>
-#include "IModule.hpp"
+#include "AModule.hpp"
 #include "idle-inhibit-unstable-v1-client-protocol.h"
 #include "wlr-layer-shell-unstable-v1-client-protocol.h"
 #include "xdg-output-unstable-v1-client-protocol.h"
@@ -73,9 +74,9 @@
   Gtk::Box                                      center_;
   Gtk::Box                                      right_;
   Gtk::Box                                      box_;
-  std::vector<std::unique_ptr<waybar::IModule>> modules_left_;
-  std::vector<std::unique_ptr<waybar::IModule>> modules_center_;
-  std::vector<std::unique_ptr<waybar::IModule>> modules_right_;
+  std::vector<std::unique_ptr<waybar::AModule>> modules_left_;
+  std::vector<std::unique_ptr<waybar::AModule>> modules_center_;
+  std::vector<std::unique_ptr<waybar::AModule>> modules_right_;
 };
 
 }  // namespace waybar
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/include/factory.hpp 
new/Waybar-0.7.0/include/factory.hpp
--- old/Waybar-0.6.9/include/factory.hpp        2019-06-14 10:27:41.000000000 
+0200
+++ new/Waybar-0.7.0/include/factory.hpp        2019-06-22 18:17:16.000000000 
+0200
@@ -37,7 +37,7 @@
 class Factory {
  public:
   Factory(const Bar& bar, const Json::Value& config);
-  IModule* makeModule(const std::string& name) const;
+  AModule* makeModule(const std::string& name) const;
 
  private:
   const Bar&         bar_;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/include/modules/pulseaudio.hpp 
new/Waybar-0.7.0/include/modules/pulseaudio.hpp
--- old/Waybar-0.6.9/include/modules/pulseaudio.hpp     2019-06-14 
10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/include/modules/pulseaudio.hpp     2019-06-22 
18:17:16.000000000 +0200
@@ -21,14 +21,13 @@
   static void sourceInfoCb(pa_context*, const pa_source_info* i, int, void* 
data);
   static void serverInfoCb(pa_context*, const pa_server_info*, void*);
   static void volumeModifyCb(pa_context*, int, void*);
-  bool        handleVolume(GdkEventScroll* e);
 
+  bool              handleScroll(GdkEventScroll* e);
   const std::string getPortIcon() const;
 
   pa_threaded_mainloop* mainloop_;
   pa_mainloop_api*      mainloop_api_;
   pa_context*           context_;
-  bool                  scrolling_;
   // SINK
   uint32_t    sink_idx_{0};
   uint16_t    volume_;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/include/modules/sni/tray.hpp 
new/Waybar-0.7.0/include/modules/sni/tray.hpp
--- old/Waybar-0.6.9/include/modules/sni/tray.hpp       2019-06-14 
10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/include/modules/sni/tray.hpp       2019-06-22 
18:17:16.000000000 +0200
@@ -1,7 +1,7 @@
 #pragma once
 
 #include <fmt/format.h>
-#include "IModule.hpp"
+#include "AModule.hpp"
 #include "bar.hpp"
 #include "modules/sni/host.hpp"
 #include "modules/sni/watcher.hpp"
@@ -9,19 +9,17 @@
 
 namespace waybar::modules::SNI {
 
-class Tray : public IModule {
+class Tray : public AModule {
  public:
   Tray(const std::string&, const Bar&, const Json::Value&);
   ~Tray() = default;
   auto update() -> void;
-       operator Gtk::Widget&();
 
  private:
   void onAdd(std::unique_ptr<Item>& item);
   void onRemove(std::unique_ptr<Item>& item);
 
   static inline std::size_t nb_hosts_ = 0;
-  const Json::Value&        config_;
   Gtk::Box                  box_;
   SNI::Watcher              watcher_;
   SNI::Host                 host_;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/include/modules/sway/ipc/client.hpp 
new/Waybar-0.7.0/include/modules/sway/ipc/client.hpp
--- old/Waybar-0.6.9/include/modules/sway/ipc/client.hpp        2019-06-14 
10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/include/modules/sway/ipc/client.hpp        2019-06-22 
18:17:16.000000000 +0200
@@ -5,7 +5,6 @@
 #include <sys/un.h>
 #include <unistd.h>
 #include <cstring>
-#include <iostream>
 #include <memory>
 #include <mutex>
 #include "ipc.hpp"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/include/modules/sway/mode.hpp 
new/Waybar-0.7.0/include/modules/sway/mode.hpp
--- old/Waybar-0.6.9/include/modules/sway/mode.hpp      2019-06-14 
10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/include/modules/sway/mode.hpp      2019-06-22 
18:17:16.000000000 +0200
@@ -22,6 +22,7 @@
 
   std::string      mode_;
   util::JsonParser parser_;
+  std::mutex       mutex_;
 
   util::SleeperThread thread_;
   Ipc                 ipc_;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/include/modules/sway/window.hpp 
new/Waybar-0.7.0/include/modules/sway/window.hpp
--- old/Waybar-0.6.9/include/modules/sway/window.hpp    2019-06-14 
10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/include/modules/sway/window.hpp    2019-06-22 
18:17:16.000000000 +0200
@@ -21,17 +21,18 @@
   void                                                   onEvent(const struct 
Ipc::ipc_response&);
   void                                                   onCmd(const struct 
Ipc::ipc_response&);
   void                                                   worker();
-  std::tuple<std::size_t, int, std::string, std::string> getFocusedNode(const 
Json::Value& nodes);
+  std::tuple<std::size_t, int, std::string, std::string> getFocusedNode(const 
Json::Value& nodes,
+                                                                        
std::string&       output);
   void                                                   getTree();
 
   const Bar&       bar_;
-  std::mutex       mutex_;
   std::string      window_;
   int              windowId_;
   std::string      app_id_;
   std::string      old_app_id_;
   std::size_t      app_nb_;
   util::JsonParser parser_;
+  std::mutex       mutex_;
 
   util::SleeperThread thread_;
   Ipc                 ipc_;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/include/modules/sway/workspaces.hpp 
new/Waybar-0.7.0/include/modules/sway/workspaces.hpp
--- old/Waybar-0.6.9/include/modules/sway/workspaces.hpp        2019-06-14 
10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/include/modules/sway/workspaces.hpp        2019-06-22 
18:17:16.000000000 +0200
@@ -3,7 +3,7 @@
 #include <fmt/format.h>
 #include <gtkmm/button.h>
 #include <gtkmm/label.h>
-#include "IModule.hpp"
+#include "AModule.hpp"
 #include "bar.hpp"
 #include "client.hpp"
 #include "modules/sway/ipc/client.hpp"
@@ -12,12 +12,11 @@
 
 namespace waybar::modules::sway {
 
-class Workspaces : public IModule, public sigc::trackable {
+class Workspaces : public AModule, public sigc::trackable {
  public:
   Workspaces(const std::string&, const waybar::Bar&, const Json::Value&);
   ~Workspaces() = default;
   auto update() -> void;
-       operator Gtk::Widget&();
 
  private:
   void              onCmd(const struct Ipc::ipc_response&);
@@ -33,14 +32,12 @@
   bool              handleScroll(GdkEventScroll*);
 
   const Bar&                                   bar_;
-  const Json::Value&                           config_;
   std::vector<Json::Value>                     workspaces_;
   std::vector<std::string>                     workspaces_order_;
-  std::mutex                                   mutex_;
   Gtk::Box                                     box_;
   util::JsonParser                             parser_;
-  bool                                         scrolling_;
   std::unordered_map<std::string, Gtk::Button> buttons_;
+  std::mutex                                   mutex_;
 
   util::SleeperThread thread_;
   Ipc                 ipc_;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/meson.build new/Waybar-0.7.0/meson.build
--- old/Waybar-0.6.9/meson.build        2019-06-14 10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/meson.build        2019-06-22 18:17:16.000000000 +0200
@@ -1,6 +1,6 @@
 project(
     'waybar', 'cpp', 'c',
-    version: '0.6.9',
+    version: '0.7.0',
     license: 'MIT',
     default_options : [
         'cpp_std=c++17',
@@ -65,6 +65,7 @@
 
 src_files = files(
     'src/factory.cpp',
+    'src/AModule.cpp',
     'src/ALabel.cpp',
     'src/modules/memory.cpp',
     'src/modules/battery.cpp',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/resources/style.css 
new/Waybar-0.7.0/resources/style.css
--- old/Waybar-0.6.9/resources/style.css        2019-06-14 10:27:41.000000000 
+0200
+++ new/Waybar-0.7.0/resources/style.css        2019-06-22 18:17:16.000000000 
+0200
@@ -58,9 +58,20 @@
     border-bottom: 3px solid #ffffff;
 }
 
-#clock, #battery, #cpu, #memory, #temperature, #backlight, #network, 
#pulseaudio, #custom-media, #tray, #mode, #idle_inhibitor {
+#clock,
+#battery,
+#cpu,
+#memory,
+#temperature,
+#backlight,
+#network,
+#pulseaudio,
+#custom-media,
+#tray,
+#mode,
+#idle_inhibitor {
     padding: 0 10px;
-    margin: 0 5px;
+    margin: 0 4px;
     color: #ffffff;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/src/ALabel.cpp 
new/Waybar-0.7.0/src/ALabel.cpp
--- old/Waybar-0.6.9/src/ALabel.cpp     2019-06-14 10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/src/ALabel.cpp     2019-06-22 18:17:16.000000000 +0200
@@ -2,9 +2,11 @@
 #include <fmt/format.h>
 #include <util/command.hpp>
 
-waybar::ALabel::ALabel(const Json::Value& config, const std::string& name, 
const std::string& id,
-                       const std::string& format, uint16_t interval)
-    : config_(config),
+namespace waybar {
+
+ALabel::ALabel(const Json::Value& config, const std::string& name, const 
std::string& id,
+               const std::string& format, uint16_t interval)
+    : AModule(config, name, id, config["format-alt"].isString()),
       format_(config_["format"].isString() ? config_["format"].asString() : 
format),
       interval_(config_["interval"] == "once"
                     ? std::chrono::seconds(100000000)
@@ -24,96 +26,13 @@
   if (config_["rotate"].isUInt()) {
     label_.set_angle(config["rotate"].asUInt());
   }
-
-  if (config_["format-alt"].isString()) {
-    event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
-    event_box_.signal_button_press_event().connect(sigc::mem_fun(*this, 
&ALabel::handleToggle));
-  }
-
-  // configure events' user commands
-  if (config_["on-click"].isString() || config_["on-click-middle"].isString() 
||
-      config_["on-click-backward"].isString() || 
config_["on-click-forward"].isString() ||
-      config_["on-click-right"].isString()) {
-    event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
-    event_box_.signal_button_press_event().connect(sigc::mem_fun(*this, 
&ALabel::handleToggle));
-  }
-  if (config_["on-scroll-up"].isString() || 
config_["on-scroll-down"].isString()) {
-    event_box_.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK);
-    event_box_.signal_scroll_event().connect(sigc::mem_fun(*this, 
&ALabel::handleScroll));
-  }
 }
 
-waybar::ALabel::~ALabel() {
-  for (const auto& pid : pid_) {
-    if (pid != -1) {
-      kill(-pid, 9);
-    }
-  }
-}
-
-auto waybar::ALabel::update() -> void {
+auto ALabel::update() -> void {
   // Nothing here
 }
 
-bool waybar::ALabel::handleToggle(GdkEventButton* const& e) {
-  std::string format;
-  if (config_["on-click"].isString() && e->button == 1) {
-    format = config_["on-click"].asString();
-  } else if (config_["on-click-middle"].isString() && e->button == 2) {
-    format = config_["on-click-middle"].asString();
-  } else if (config_["on-click-right"].isString() && e->button == 3) {
-    format = config_["on-click-right"].asString();
-  } else if (config_["on-click-forward"].isString() && e->button == 8) {
-    format = config_["on-click-backward"].asString();
-  } else if (config_["on-click-backward"].isString() && e->button == 9) {
-    format = config_["on-click-forward"].asString();
-  }
-  if (!format.empty()) {
-    pid_.push_back(util::command::forkExec(fmt::format(format, fmt::arg("arg", 
click_param))));
-  }
-  if (config_["format-alt-click"].isUInt() && e->button == 
config_["format-alt-click"].asUInt()) {
-    alt_ = !alt_;
-    if (alt_ && config_["format-alt"].isString()) {
-      format_ = config_["format-alt"].asString();
-    } else {
-      format_ = default_format_;
-    }
-  }
-
-  dp.emit();
-  return true;
-}
-
-bool waybar::ALabel::handleScroll(GdkEventScroll* e) {
-  // Avoid concurrent scroll event
-  std::lock_guard<std::mutex> lock(mutex_);
-  bool                        direction_up = false;
-
-  if (e->direction == GDK_SCROLL_UP) {
-    direction_up = true;
-  }
-  if (e->direction == GDK_SCROLL_DOWN) {
-    direction_up = false;
-  }
-  if (e->direction == GDK_SCROLL_SMOOTH) {
-    gdouble delta_x, delta_y;
-    gdk_event_get_scroll_deltas(reinterpret_cast<const GdkEvent*>(e), 
&delta_x, &delta_y);
-    if (delta_y < 0) {
-      direction_up = true;
-    } else if (delta_y > 0) {
-      direction_up = false;
-    }
-  }
-  if (direction_up && config_["on-scroll-up"].isString()) {
-    
pid_.push_back(util::command::forkExec(config_["on-scroll-up"].asString()));
-  } else if (config_["on-scroll-down"].isString()) {
-    
pid_.push_back(util::command::forkExec(config_["on-scroll-down"].asString()));
-  }
-  dp.emit();
-  return true;
-}
-
-std::string waybar::ALabel::getIcon(uint16_t percentage, const std::string& 
alt, uint16_t max) {
+std::string ALabel::getIcon(uint16_t percentage, const std::string& alt, 
uint16_t max) {
   auto format_icons = config_["format-icons"];
   if (format_icons.isObject()) {
     if (!alt.empty() && (format_icons[alt].isString() || 
format_icons[alt].isArray())) {
@@ -133,7 +52,19 @@
   return "";
 }
 
-std::string waybar::ALabel::getState(uint8_t value, bool lesser) {
+bool waybar::ALabel::handleToggle(GdkEventButton* const& e) {
+  if (config_["format-alt-click"].isUInt() && e->button == 
config_["format-alt-click"].asUInt()) {
+    alt_ = !alt_;
+    if (alt_ && config_["format-alt"].isString()) {
+      format_ = config_["format-alt"].asString();
+    } else {
+      format_ = default_format_;
+    }
+  }
+  return AModule::handleToggle(e);
+}
+
+std::string ALabel::getState(uint8_t value, bool lesser) {
   if (!config_["states"].isObject()) {
     return "";
   }
@@ -162,8 +93,4 @@
   return valid_state;
 }
 
-bool waybar::ALabel::tooltipEnabled() {
-  return config_["tooltip"].isBool() ? config_["tooltip"].asBool() : true;
-}
-
-waybar::ALabel::operator Gtk::Widget&() { return event_box_; }
+}  // namespace waybar
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/src/AModule.cpp 
new/Waybar-0.7.0/src/AModule.cpp
--- old/Waybar-0.6.9/src/AModule.cpp    1970-01-01 01:00:00.000000000 +0100
+++ new/Waybar-0.7.0/src/AModule.cpp    2019-06-22 18:17:16.000000000 +0200
@@ -0,0 +1,119 @@
+#include "AModule.hpp"
+#include <fmt/format.h>
+#include <util/command.hpp>
+
+namespace waybar {
+
+AModule::AModule(const Json::Value& config, const std::string& name, const 
std::string& id,
+                 bool enable_click, bool enable_scroll)
+    : config_(std::move(config)) {
+  // configure events' user commands
+  if (config_["on-click"].isString() || config_["on-click-middle"].isString() 
||
+      config_["on-click-backward"].isString() || 
config_["on-click-forward"].isString() ||
+      config_["on-click-right"].isString() || enable_click) {
+    event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
+    event_box_.signal_button_press_event().connect(sigc::mem_fun(*this, 
&AModule::handleToggle));
+  }
+  if (config_["on-scroll-up"].isString() || 
config_["on-scroll-down"].isString() || enable_scroll) {
+    event_box_.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK);
+    event_box_.signal_scroll_event().connect(sigc::mem_fun(*this, 
&AModule::handleScroll));
+  }
+}
+
+AModule::~AModule() {
+  for (const auto& pid : pid_) {
+    if (pid != -1) {
+      kill(-pid, 9);
+    }
+  }
+}
+
+auto AModule::update() -> void {
+  // Nothing here
+}
+
+bool AModule::handleToggle(GdkEventButton* const& e) {
+  std::string format;
+  if (config_["on-click"].isString() && e->button == 1) {
+    format = config_["on-click"].asString();
+  } else if (config_["on-click-middle"].isString() && e->button == 2) {
+    format = config_["on-click-middle"].asString();
+  } else if (config_["on-click-right"].isString() && e->button == 3) {
+    format = config_["on-click-right"].asString();
+  } else if (config_["on-click-forward"].isString() && e->button == 8) {
+    format = config_["on-click-backward"].asString();
+  } else if (config_["on-click-backward"].isString() && e->button == 9) {
+    format = config_["on-click-forward"].asString();
+  }
+  if (!format.empty()) {
+    pid_.push_back(util::command::forkExec(fmt::format(format, fmt::arg("arg", 
click_param_))));
+  }
+  dp.emit();
+  return true;
+}
+
+AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) {
+  switch (e -> direction) {
+    case GDK_SCROLL_UP: return SCROLL_DIR::UP;
+    case GDK_SCROLL_DOWN: return SCROLL_DIR::DOWN;
+    case GDK_SCROLL_LEFT: return SCROLL_DIR::LEFT;
+    case GDK_SCROLL_RIGHT: return SCROLL_DIR::RIGHT;
+    case GDK_SCROLL_SMOOTH: {
+      SCROLL_DIR dir{SCROLL_DIR::NONE};
+
+      distance_scrolled_y_ += e->delta_y;
+      distance_scrolled_x_ += e->delta_x;
+
+      gdouble threshold = 0;
+      if (config_["smooth-scrolling-threshold"].isNumeric()) {
+        threshold = config_["smooth-scrolling-threshold"].asDouble();
+      }
+
+      if (distance_scrolled_y_ < -threshold) {
+        dir = SCROLL_DIR::UP;
+      } else if (distance_scrolled_y_ > threshold) {
+        dir = SCROLL_DIR::DOWN;
+      } else if (distance_scrolled_x_ > threshold) {
+        dir = SCROLL_DIR::RIGHT;
+      } else if (distance_scrolled_x_ < -threshold) {
+        dir = SCROLL_DIR::LEFT;
+      }
+
+      switch (dir) {
+        case SCROLL_DIR::UP:
+        case SCROLL_DIR::DOWN:
+          distance_scrolled_y_ = 0;
+          break;
+        case SCROLL_DIR::LEFT:
+        case SCROLL_DIR::RIGHT:
+          distance_scrolled_x_ = 0;
+          break;
+        case SCROLL_DIR::NONE:
+          break;
+      }
+
+      return dir;
+    }
+    // Silence -Wreturn-type:
+    default: return SCROLL_DIR::NONE;
+  }
+}
+
+bool AModule::handleScroll(GdkEventScroll* e) {
+  auto dir = getScrollDir(e);
+  if (dir == SCROLL_DIR::UP && config_["on-scroll-up"].isString()) {
+    
pid_.push_back(util::command::forkExec(config_["on-scroll-up"].asString()));
+  } else if (dir == SCROLL_DIR::DOWN && config_["on-scroll-down"].isString()) {
+    
pid_.push_back(util::command::forkExec(config_["on-scroll-down"].asString()));
+  }
+  dp.emit();
+  return true;
+}
+
+bool AModule::tooltipEnabled() {
+  return config_["tooltip"].isBool() ? config_["tooltip"].asBool() : true;
+}
+
+AModule::operator Gtk::Widget&() { return event_box_; }
+
+}  // namespace waybar
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/src/bar.cpp new/Waybar-0.7.0/src/bar.cpp
--- old/Waybar-0.6.9/src/bar.cpp        2019-06-14 10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/src/bar.cpp        2019-06-22 18:17:16.000000000 +0200
@@ -287,14 +287,11 @@
           modules_right_.emplace_back(module);
         }
         module->dp.connect([module, &name] {
-          // Fix https://github.com/Alexays/Waybar/issues/320, proper way?
-          Glib::signal_idle().connect_once([module, &name] {
-            try {
-              module->update();
-            } catch (const std::exception& e) {
-              spdlog::error("{}: {}", name.asString(), e.what());
-            }
-          });
+          try {
+            module->update();
+          } catch (const std::exception& e) {
+            spdlog::error("{}: {}", name.asString(), e.what());
+          }
         });
       } catch (const std::exception& e) {
         spdlog::warn("module {}: {}", name.asString(), e.what());
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/src/factory.cpp 
new/Waybar-0.7.0/src/factory.cpp
--- old/Waybar-0.6.9/src/factory.cpp    2019-06-14 10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/src/factory.cpp    2019-06-22 18:17:16.000000000 +0200
@@ -2,7 +2,7 @@
 
 waybar::Factory::Factory(const Bar& bar, const Json::Value& config) : 
bar_(bar), config_(config) {}
 
-waybar::IModule* waybar::Factory::makeModule(const std::string& name) const {
+waybar::AModule* waybar::Factory::makeModule(const std::string& name) const {
   try {
     auto hash_pos = name.find('#');
     auto ref = name.substr(0, hash_pos);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/src/modules/memory.cpp 
new/Waybar-0.7.0/src/modules/memory.cpp
--- old/Waybar-0.6.9/src/modules/memory.cpp     2019-06-14 10:27:41.000000000 
+0200
+++ new/Waybar-0.7.0/src/modules/memory.cpp     2019-06-22 18:17:16.000000000 
+0200
@@ -11,6 +11,7 @@
 auto waybar::modules::Memory::update() -> void {
   parseMeminfo();
   if (memtotal_ > 0 && memfree_ >= 0) {
+    auto total_ram_gigabytes = memtotal_ / std::pow(1024, 2);
     int  used_ram_percentage = 100 * (memtotal_ - memfree_) / memtotal_;
     auto used_ram_gigabytes = (memtotal_ - memfree_) / std::pow(1024, 2);
     auto available_ram_gigabytes = memfree_ / std::pow(1024, 2);
@@ -18,6 +19,7 @@
     getState(used_ram_percentage);
     label_.set_markup(fmt::format(format_,
                                   used_ram_percentage,
+                                  fmt::arg("total", total_ram_gigabytes),
                                   fmt::arg("percentage", used_ram_percentage),
                                   fmt::arg("used", used_ram_gigabytes),
                                   fmt::arg("avail", available_ram_gigabytes)));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/src/modules/pulseaudio.cpp 
new/Waybar-0.7.0/src/modules/pulseaudio.cpp
--- old/Waybar-0.6.9/src/modules/pulseaudio.cpp 2019-06-14 10:27:41.000000000 
+0200
+++ new/Waybar-0.7.0/src/modules/pulseaudio.cpp 2019-06-22 18:17:16.000000000 
+0200
@@ -5,7 +5,6 @@
       mainloop_(nullptr),
       mainloop_api_(nullptr),
       context_(nullptr),
-      scrolling_(false),
       sink_idx_(0),
       volume_(0),
       muted_(false),
@@ -32,13 +31,6 @@
     throw std::runtime_error("pa_mainloop_run() failed.");
   }
   pa_threaded_mainloop_unlock(mainloop_);
-
-  // define the pulse scroll events only when no user provided
-  // events are configured
-  if (!config["on-scroll-up"].isString() && 
!config["on-scroll-down"].isString()) {
-    event_box_.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK);
-    event_box_.signal_scroll_event().connect(sigc::mem_fun(*this, 
&Pulseaudio::handleVolume));
-  }
 }
 
 waybar::modules::Pulseaudio::~Pulseaudio() {
@@ -74,50 +66,33 @@
   }
 }
 
-bool waybar::modules::Pulseaudio::handleVolume(GdkEventScroll *e) {
-  // Avoid concurrent scroll event
-  if (scrolling_) {
-    return false;
+bool waybar::modules::Pulseaudio::handleScroll(GdkEventScroll *e) {
+  // change the pulse volume only when no user provided
+  // events are configured
+  if (config_["on-scroll-up"].isString() || 
config_["on-scroll-down"].isString()) {
+    return AModule::handleScroll(e);
   }
-  bool        direction_up = false;
-  double      volume_tick = (double)PA_VOLUME_NORM / 100;
+  auto dir = AModule::getScrollDir(e);
+  if (dir == SCROLL_DIR::NONE) {
+    return true;
+  }
+  double      volume_tick = static_cast<double>(PA_VOLUME_NORM) / 100;
   pa_volume_t change = volume_tick;
   pa_cvolume  pa_volume = pa_volume_;
-  scrolling_ = true;
-  if (e->direction == GDK_SCROLL_UP) {
-    direction_up = true;
-  }
-  if (e->direction == GDK_SCROLL_DOWN) {
-    direction_up = false;
-  }
-
-  if (e->direction == GDK_SCROLL_SMOOTH) {
-    gdouble delta_x, delta_y;
-    gdk_event_get_scroll_deltas(reinterpret_cast<const GdkEvent *>(e), 
&delta_x, &delta_y);
-    if (delta_y < 0) {
-      direction_up = true;
-    } else if (delta_y > 0) {
-      direction_up = false;
-    }
-  }
-
   // isDouble returns true for integers as well, just in case
   if (config_["scroll-step"].isDouble()) {
     change = round(config_["scroll-step"].asDouble() * volume_tick);
   }
-
-  if (direction_up) {
+  if (dir == SCROLL_DIR::UP) {
     if (volume_ + 1 < 100) {
       pa_cvolume_inc(&pa_volume, change);
     }
-  } else {
+  } else if (dir == SCROLL_DIR::DOWN) {
     if (volume_ - 1 >= 0) {
       pa_cvolume_dec(&pa_volume, change);
     }
   }
-
   pa_context_set_sink_volume_by_index(context_, sink_idx_, &pa_volume, 
volumeModifyCb, this);
-
   return true;
 }
 
@@ -249,7 +224,4 @@
   if (tooltipEnabled()) {
     label_.set_tooltip_text(desc_);
   }
-  if (scrolling_) {
-    scrolling_ = false;
-  }
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/src/modules/sni/tray.cpp 
new/Waybar-0.7.0/src/modules/sni/tray.cpp
--- old/Waybar-0.6.9/src/modules/sni/tray.cpp   2019-06-14 10:27:41.000000000 
+0200
+++ new/Waybar-0.7.0/src/modules/sni/tray.cpp   2019-06-22 18:17:16.000000000 
+0200
@@ -4,15 +4,16 @@
 namespace waybar::modules::SNI {
 
 Tray::Tray(const std::string& id, const Bar& bar, const Json::Value& config)
-    : config_(config),
+    : AModule(config, "tray", id),
       box_(bar.vertical ? Gtk::ORIENTATION_VERTICAL : 
Gtk::ORIENTATION_HORIZONTAL, 0),
       watcher_(nb_hosts_),
       host_(nb_hosts_, config, std::bind(&Tray::onAdd, this, 
std::placeholders::_1),
             std::bind(&Tray::onRemove, this, std::placeholders::_1)) {
-  box_.set_name("tray");
   spdlog::warn(
       "For a functionnal tray you must have libappindicator-* installed and 
export "
       "XDG_CURRENT_DESKTOP=Unity");
+  box_.set_name("tray");
+  event_box_.add(box_);
   if (!id.empty()) {
     box_.get_style_context()->add_class(id);
   }
@@ -41,6 +42,4 @@
   }
 }
 
-Tray::operator Gtk::Widget&() { return box_; }
-
 }  // namespace waybar::modules::SNI
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/src/modules/sway/ipc/client.cpp 
new/Waybar-0.7.0/src/modules/sway/ipc/client.cpp
--- old/Waybar-0.6.9/src/modules/sway/ipc/client.cpp    2019-06-14 
10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/src/modules/sway/ipc/client.cpp    2019-06-22 
18:17:16.000000000 +0200
@@ -142,4 +142,4 @@
   signal_event.emit(res);
 }
 
-}  // namespace waybar::modules::sway
\ No newline at end of file
+}  // namespace waybar::modules::sway
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/src/modules/sway/mode.cpp 
new/Waybar-0.7.0/src/modules/sway/mode.cpp
--- old/Waybar-0.6.9/src/modules/sway/mode.cpp  2019-06-14 10:27:41.000000000 
+0200
+++ new/Waybar-0.7.0/src/modules/sway/mode.cpp  2019-06-22 18:17:16.000000000 
+0200
@@ -13,6 +13,7 @@
 
 void Mode::onEvent(const struct Ipc::ipc_response& res) {
   try {
+    std::lock_guard<std::mutex> lock(mutex_);
     auto payload = parser_.parse(res.payload);
     if (payload["change"] != "default") {
       mode_ = Glib::Markup::escape_text(payload["change"].asString());
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/src/modules/sway/window.cpp 
new/Waybar-0.7.0/src/modules/sway/window.cpp
--- old/Waybar-0.6.9/src/modules/sway/window.cpp        2019-06-14 
10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/src/modules/sway/window.cpp        2019-06-22 
18:17:16.000000000 +0200
@@ -22,8 +22,9 @@
 void Window::onCmd(const struct Ipc::ipc_response& res) {
   try {
     std::lock_guard<std::mutex> lock(mutex_);
-    auto                        payload = parser_.parse(res.payload);
-    std::tie(app_nb_, windowId_, window_, app_id_) = getFocusedNode(payload);
+    auto payload = parser_.parse(res.payload);
+    auto output = payload["ouput"].isString() ? payload["output"].asString() : 
"";
+    std::tie(app_nb_, windowId_, window_, app_id_) = 
getFocusedNode(payload["nodes"], output);
     dp.emit();
   } catch (const std::exception& e) {
     spdlog::error("Window: {}", e.what());
@@ -69,20 +70,28 @@
 }
 
 std::tuple<std::size_t, int, std::string, std::string> Window::getFocusedNode(
-    const Json::Value& nodes) {
-  for (auto const& node : nodes["nodes"]) {
-    if (node["focused"].asBool() && node["type"] == "con") {
-      if ((!config_["all-outputs"].asBool() && nodes["output"] == 
bar_.output->name) ||
+    const Json::Value& nodes, std::string& output) {
+  for (auto const& node : nodes) {
+    if (node["output"].isString()) {
+      output = node["output"].asString();
+    }
+    if (node["focused"].asBool() && (node["type"] == "con" || node["type"] == 
"floating_con")) {
+      if ((!config_["all-outputs"].asBool() && output == bar_.output->name) ||
           config_["all-outputs"].asBool()) {
         auto app_id = node["app_id"].isString() ? node["app_id"].asString()
                                                 : 
node["window_properties"]["instance"].asString();
-        return {nodes["nodes"].size(),
+        return {nodes.size(),
                 node["id"].asInt(),
                 Glib::Markup::escape_text(node["name"].asString()),
                 app_id};
       }
     }
-    auto [nb, id, name, app_id] = getFocusedNode(node);
+    auto [nb, id, name, app_id] = getFocusedNode(node["nodes"], output);
+    if (id > -1 && !name.empty()) {
+      return {nb, id, name, app_id};
+    }
+    // Search for floating node
+    std::tie(nb, id, name, app_id) = getFocusedNode(node["floating_nodes"], 
output);
     if (id > -1 && !name.empty()) {
       return {nb, id, name, app_id};
     }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Waybar-0.6.9/src/modules/sway/workspaces.cpp 
new/Waybar-0.7.0/src/modules/sway/workspaces.cpp
--- old/Waybar-0.6.9/src/modules/sway/workspaces.cpp    2019-06-14 
10:27:41.000000000 +0200
+++ new/Waybar-0.7.0/src/modules/sway/workspaces.cpp    2019-06-22 
18:17:16.000000000 +0200
@@ -4,14 +4,14 @@
 namespace waybar::modules::sway {
 
 Workspaces::Workspaces(const std::string &id, const Bar &bar, const 
Json::Value &config)
-    : bar_(bar),
-      config_(config),
-      box_(bar.vertical ? Gtk::ORIENTATION_VERTICAL : 
Gtk::ORIENTATION_HORIZONTAL, 0),
-      scrolling_(false) {
+    : AModule(config, "workspaces", id, false, 
!config["disable-scroll"].asBool()),
+      bar_(bar),
+      box_(bar.vertical ? Gtk::ORIENTATION_VERTICAL : 
Gtk::ORIENTATION_HORIZONTAL, 0) {
   box_.set_name("workspaces");
   if (!id.empty()) {
     box_.get_style_context()->add_class(id);
   }
+  event_box_.add(box_);
   ipc_.subscribe(R"(["workspace"])");
   ipc_.signal_event.connect(sigc::mem_fun(*this, &Workspaces::onEvent));
   ipc_.signal_cmd.connect(sigc::mem_fun(*this, &Workspaces::onCmd));
@@ -36,9 +36,9 @@
 void Workspaces::onCmd(const struct Ipc::ipc_response &res) {
   if (res.type == IPC_GET_WORKSPACES) {
     try {
-      auto payload = parser_.parse(res.payload);
-      if (payload.isArray()) {
+      {
         std::lock_guard<std::mutex> lock(mutex_);
+        auto                        payload = parser_.parse(res.payload);
         workspaces_.clear();
         std::copy_if(payload.begin(),
                      payload.end(),
@@ -91,16 +91,11 @@
                       return lhs["name"].asString() < rhs["name"].asString();
                     });
         }
-
-        dp.emit();
       }
+      dp.emit();
     } catch (const std::exception &e) {
       spdlog::error("Workspaces: {}", e.what());
     }
-  } else {
-    if (scrolling_) {
-      scrolling_ = false;
-    }
   }
 }
 
@@ -181,8 +176,8 @@
 }
 
 Gtk::Button &Workspaces::addButton(const Json::Value &node) {
-  auto  pair = buttons_.emplace(node["name"].asString(), 
node["name"].asString());
-  auto &button = pair.first->second;
+  auto   pair = buttons_.emplace(node["name"].asString(), 
node["name"].asString());
+  auto &&button = pair.first->second;
   box_.pack_start(button, false, false, 0);
   button.set_relief(Gtk::RELIEF_NONE);
   button.signal_clicked().connect([this, node] {
@@ -201,10 +196,6 @@
       spdlog::error("Workspaces: {}", e.what());
     }
   });
-  if (!config_["disable-scroll"].asBool()) {
-    button.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK);
-    button.signal_scroll_event().connect(sigc::mem_fun(*this, 
&Workspaces::handleScroll));
-  }
   return button;
 }
 
@@ -223,46 +214,27 @@
 }
 
 bool Workspaces::handleScroll(GdkEventScroll *e) {
-  // Avoid concurrent scroll event
-  if (scrolling_) {
-    return false;
+  auto dir = AModule::getScrollDir(e);
+  if (dir == SCROLL_DIR::NONE) {
+    return true;
+  }
+  std::lock_guard<std::mutex> lock(mutex_);
+  auto it = std::find_if(workspaces_.begin(), workspaces_.end(), [](const auto 
&workspace) {
+    return workspace["focused"].asBool();
+  });
+  if (it == workspaces_.end()) {
+    return true;
   }
   std::string name;
-  scrolling_ = true;
-  {
-    std::lock_guard<std::mutex> lock(mutex_);
-    auto it = std::find_if(workspaces_.begin(), workspaces_.end(), [](const 
auto &workspace) {
-      return workspace["focused"].asBool();
-    });
-    if (it == workspaces_.end()) {
-      scrolling_ = false;
-      return false;
-    }
-    switch (e->direction) {
-      case GDK_SCROLL_DOWN:
-      case GDK_SCROLL_RIGHT:
-        name = getCycleWorkspace(it, false);
-        break;
-      case GDK_SCROLL_UP:
-      case GDK_SCROLL_LEFT:
-        name = getCycleWorkspace(it, true);
-        break;
-      case GDK_SCROLL_SMOOTH:
-        gdouble delta_x, delta_y;
-        gdk_event_get_scroll_deltas(reinterpret_cast<const GdkEvent *>(e), 
&delta_x, &delta_y);
-        if (delta_y < 0) {
-          name = getCycleWorkspace(it, true);
-        } else if (delta_y > 0) {
-          name = getCycleWorkspace(it, false);
-        }
-        break;
-      default:
-        break;
-    }
-    if (name.empty() || name == (*it)["name"].asString()) {
-      scrolling_ = false;
-      return false;
-    }
+  if (dir == SCROLL_DIR::DOWN || dir == SCROLL_DIR::RIGHT) {
+    name = getCycleWorkspace(it, false);
+  } else if (dir == SCROLL_DIR::UP || dir == SCROLL_DIR::LEFT) {
+    name = getCycleWorkspace(it, true);
+  } else {
+    return true;
+  }
+  if (name == (*it)["name"].asString()) {
+    return true;
   }
   try {
     ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace \"{}\"", name));
@@ -311,6 +283,4 @@
   }
 }
 
-Workspaces::operator Gtk::Widget &() { return box_; }
-
 }  // namespace waybar::modules::sway


Reply via email to