diff options
Diffstat (limited to 'src/CurrentWindowCmd.cc')
-rw-r--r-- | src/CurrentWindowCmd.cc | 69 |
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 | ||
228 | class ActivateTabCmd: public WindowHelperCmd { | 228 | class ActivateTabCmd: public WindowHelperCmd { |
229 | public: | 229 | public: |
230 | ActivateTabCmd() { } | 230 | explicit ActivateTabCmd() { } |
231 | protected: | 231 | protected: |
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 | |||
244 | REGISTER_COMMAND(activatetab, ActivateTabCmd, void); | ||
245 | |||
246 | class SetXPropCmd: public WindowHelperCmd { | ||
247 | public: | ||
248 | explicit SetXPropCmd(const FbTk::FbString& name, const FbTk::FbString& value) : | ||
249 | m_name(name), m_value(value) { } | ||
250 | |||
251 | protected: | ||
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 | |||
261 | private: | ||
262 | FbTk::FbString m_name; | ||
263 | FbTk::FbString m_value; | ||
233 | }; | 264 | }; |
234 | 265 | ||
266 | FbTk::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 | ||
236 | void 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 | ||
246 | REGISTER_COMMAND(activatetab, ActivateTabCmd, void); | 296 | REGISTER_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 | |||
680 | REGISTER_COMMAND_WITH_ARGS(matches, MatchCmd, bool); | 733 | REGISTER_COMMAND_WITH_ARGS(matches, MatchCmd, bool); |
681 | 734 | ||
682 | bool MatchCmd::real_execute() { | 735 | bool MatchCmd::real_execute() { |