aboutsummaryrefslogtreecommitdiff
path: root/src/CurrentWindowCmd.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/CurrentWindowCmd.cc')
-rw-r--r--src/CurrentWindowCmd.cc69
1 files changed, 61 insertions, 8 deletions
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc
index e2fdb94..1851f2d 100644
--- a/src/CurrentWindowCmd.cc
+++ b/src/CurrentWindowCmd.cc
@@ -227,23 +227,75 @@ REGISTER_COMMAND_PARSER(focus, parseFocusCmd, void);
227 227
228class ActivateTabCmd: public WindowHelperCmd { 228class ActivateTabCmd: public WindowHelperCmd {
229public: 229public:
230 ActivateTabCmd() { } 230 explicit ActivateTabCmd() { }
231protected: 231protected:
232 void real_execute(); 232 void real_execute() {
233 WinClient* winclient = fbwindow().winClientOfLabelButtonWindow(
234 Fluxbox::instance()->lastEvent().xany.window);
235
236 if (winclient && winclient != &fbwindow().winClient()) {
237 fbwindow().setCurrentClient(*winclient, true);
238 }
239
240 }
241};
242
243
244REGISTER_COMMAND(activatetab, ActivateTabCmd, void);
245
246class SetXPropCmd: public WindowHelperCmd {
247public:
248 explicit SetXPropCmd(const FbTk::FbString& name, const FbTk::FbString& value) :
249 m_name(name), m_value(value) { }
250
251protected:
252 void real_execute() {
253
254 WinClient& client = fbwindow().winClient();
255 Atom prop = XInternAtom(client.display(), m_name.c_str(), False);
256
257 client.changeProperty(prop, XInternAtom(client.display(), "UTF8_STRING", False), 8,
258 PropModeReplace, (unsigned char*)m_value.c_str(), m_value.size());
259 }
260
261private:
262 FbTk::FbString m_name;
263 FbTk::FbString m_value;
233}; 264};
234 265
266FbTk::Command<void> *parseSetXPropCmd(const string &command, const string &args, bool trusted) {
267
268 SetXPropCmd* cmd = 0;
269
270 if (trusted) {
271
272 FbTk::FbString name = args;
273
274 FbTk::StringUtil::removeFirstWhitespace(name);
275 FbTk::StringUtil::removeTrailingWhitespace(name);
276
277 if (name.size() > 1 && name[0] != '=') { // the smallest valid argument is 'X='
278
279 FbTk::FbString value;
235 280
236void ActivateTabCmd::real_execute() { 281 size_t eq = name.find('=');
282 if (eq != name.npos && eq != name.size()) {
237 283
238 WinClient* winclient = fbwindow().winClientOfLabelButtonWindow( 284 value.assign(name, eq + 1, name.size());
239 Fluxbox::instance()->lastEvent().xany.window); 285 name.resize(eq);
286 }
240 287
241 if (winclient && winclient != &fbwindow().winClient()) { 288 cmd = new SetXPropCmd(name, value);
242 fbwindow().setCurrentClient(*winclient, true); 289
290 }
243 } 291 }
292
293 return cmd;
244} 294}
245 295
246REGISTER_COMMAND(activatetab, ActivateTabCmd, void); 296REGISTER_COMMAND_PARSER(setxprop, parseSetXPropCmd, void);
297
298
247 299
248} // end anonymous namespace 300} // end anonymous namespace
249 301
@@ -677,6 +729,7 @@ void SetAlphaCmd::real_execute() {
677 : m_unfocus); 729 : m_unfocus);
678} 730}
679 731
732
680REGISTER_COMMAND_WITH_ARGS(matches, MatchCmd, bool); 733REGISTER_COMMAND_WITH_ARGS(matches, MatchCmd, bool);
681 734
682bool MatchCmd::real_execute() { 735bool MatchCmd::real_execute() {