aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Bollerhey <gbsoftware@arcor.de>2014-01-12 03:35:30 (GMT)
committerJan Sucan <jan@jansucan.com>2020-04-05 07:55:33 (GMT)
commitf833ff71a579406f6e5d46770acb726ba040f9e1 (patch)
tree948cfe0a18c6f7010b1b2646d060ab1eb78ea790
parent47474be46c8509d960d84c102db41179db8192b0 (diff)
downloadfluxbox-f833ff71a579406f6e5d46770acb726ba040f9e1.zip
fluxbox-f833ff71a579406f6e5d46770acb726ba040f9e1.tar.bz2
Use FbTk::StringUtils instead of own tokenizer.
-rw-r--r--src/SystemTray.cc37
1 files changed, 9 insertions, 28 deletions
diff --git a/src/SystemTray.cc b/src/SystemTray.cc
index dff10b5..b4f1e9b 100644
--- a/src/SystemTray.cc
+++ b/src/SystemTray.cc
@@ -23,6 +23,7 @@
23 23
24#include "FbTk/EventManager.hh" 24#include "FbTk/EventManager.hh"
25#include "FbTk/ImageControl.hh" 25#include "FbTk/ImageControl.hh"
26#include "FbTk/StringUtil.hh"
26#include "FbTk/TextUtils.hh" 27#include "FbTk/TextUtils.hh"
27#include "FbTk/MemFun.hh" 28#include "FbTk/MemFun.hh"
28 29
@@ -83,31 +84,6 @@ void getScreenCoordinates(Window win, int x, int y, int &screen_x, int &screen_y
83 84
84static SystemTray *s_theoneandonly = 0; 85static SystemTray *s_theoneandonly = 0;
85 86
86static std::string trim(const std::string& str)
87{
88 // removes trailing and leading whitespace from a string
89
90 const std::string whitespace(" \t");
91 const auto strBegin = str.find_first_not_of(whitespace);
92 if (strBegin == std::string::npos)
93 return ""; // no content
94
95 const auto strEnd = str.find_last_not_of(whitespace);
96 const auto strRange = strEnd - strBegin + 1;
97
98 return str.substr(strBegin, strRange);
99}
100
101static void parse_order(const std::string s, std::vector<std::string> &out) {
102 // splits a comma seperated list and performs trimming
103
104 std::stringstream ss(s);
105 std::string item;
106
107 while (std::getline(ss, item, ','))
108 out.push_back(trim(item));
109}
110
111/// helper class for tray windows, so we dont call XDestroyWindow 87/// helper class for tray windows, so we dont call XDestroyWindow
112class SystemTray::TrayWindow : public FbTk::FbWindow { 88class SystemTray::TrayWindow : public FbTk::FbWindow {
113public: 89public:
@@ -259,8 +235,8 @@ SystemTray::SystemTray(const FbTk::FbWindow& parent,
259 "", screen.name() + ".systray.pinRight", 235 "", screen.name() + ".systray.pinRight",
260 screen.altName() + ".Systray.PinRight") { 236 screen.altName() + ".Systray.PinRight") {
261 237
262 parse_order(m_rc_systray_pinleft, m_pinleft); 238 FbTk::StringUtil::stringtok(m_pinleft, m_rc_systray_pinleft, " ,");
263 parse_order(m_rc_systray_pinright, m_pinright); 239 FbTk::StringUtil::stringtok(m_pinright, m_rc_systray_pinright, " ,");
264 240
265 FbTk::EventManager::instance()->add(*this, m_window); 241 FbTk::EventManager::instance()->add(*this, m_window);
266 FbTk::EventManager::instance()->add(*this, m_selection_owner); 242 FbTk::EventManager::instance()->add(*this, m_selection_owner);
@@ -627,7 +603,12 @@ void SystemTray::showClient(TrayWindow *traywin) {
627} 603}
628 604
629void SystemTray::sortClients() { 605void SystemTray::sortClients() {
630 m_clients.sort([](TrayWindow *a, TrayWindow *b){return a->m_order < b->m_order;}); 606 m_clients.sort(
607 [](TrayWindow *a, TrayWindow *b) {
608 return a->m_order < b->m_order;
609 }
610 );
611
631 rearrangeClients(); 612 rearrangeClients();
632} 613}
633 614