aboutsummaryrefslogtreecommitdiff
path: root/src/FbCommands.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbCommands.cc')
-rw-r--r--src/FbCommands.cc82
1 files changed, 75 insertions, 7 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index b0289b8..eb7fbfd 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -445,13 +445,12 @@ REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(bindkey, FbCommands::BindKeyCmd, void);
445BindKeyCmd::BindKeyCmd(const string &keybind):m_keybind(keybind) { } 445BindKeyCmd::BindKeyCmd(const string &keybind):m_keybind(keybind) { }
446 446
447void BindKeyCmd::execute() { 447void BindKeyCmd::execute() {
448 if (Fluxbox::instance()->keys() != 0) { 448 Keys* keys = Fluxbox::instance()->keys();
449 if (Fluxbox::instance()->keys()->addBinding(m_keybind)) { 449 if (keys && keys->addBinding(m_keybind)) {
450 ofstream ofile(Fluxbox::instance()->keys()->filename().c_str(), ios::app); 450 ofstream ofile(keys->filename().c_str(), ios::app);
451 if (!ofile) 451 if (!ofile)
452 return; 452 return;
453 ofile<<m_keybind<<endl; 453 ofile<<m_keybind<<endl;
454 }
455 } 454 }
456} 455}
457 456
@@ -542,4 +541,73 @@ void DeiconifyCmd::execute() {
542 }; 541 };
543} 542}
544 543
544
545REGISTER_COMMAND_WITH_ARGS(clientpatterntest, FbCommands::ClientPatternTestCmd, void);
546
547void ClientPatternTestCmd::execute() {
548
549 std::vector< const FluxboxWindow* > matches;
550 std::string result;
551 std::string pat;
552 int opts;
553 ClientPattern* cp;
554 Display* dpy;
555 Atom atom_utf8;
556 Atom atom_fbcmd_result;
557 Fluxbox::ScreenList::const_iterator screen;
558 const Fluxbox::ScreenList screens(Fluxbox::instance()->screenList());
559
560 dpy = Fluxbox::instance()->display();
561 atom_utf8 = XInternAtom(dpy, "UTF8_STRING", False);
562 atom_fbcmd_result = XInternAtom(dpy, "_FLUXBOX_ACTION_RESULT", False);
563
564 FocusableList::parseArgs(m_args, opts, pat);
565 cp = new ClientPattern(pat.c_str());
566
567 if (!cp->error()) {
568
569 const FocusableList* windows;
570 FocusControl::Focusables::const_iterator wit;
571 FocusControl::Focusables::const_iterator wit_end;
572
573 for (screen = screens.begin(); screen != screens.end(); screen++) {
574
575 windows = FocusableList::getListFromOptions(**screen, opts|FocusableList::LIST_GROUPS);
576 wit = windows->clientList().begin();
577 wit_end = windows->clientList().end();
578
579 for ( ; wit != wit_end; wit++) {
580 if (typeid(**wit) == typeid(FluxboxWindow) && cp->match(**wit)) {
581 matches.push_back(static_cast<const FluxboxWindow*>(*wit));
582 }
583 }
584 }
585
586 if (!matches.empty()) {
587 std::vector< const FluxboxWindow* >::const_iterator win;
588 for (win = matches.begin(); win != matches.end(); win++) {
589 result += "0x";
590 result += FbTk::StringUtil::number2HexString((*win)->clientWindow());
591 result += "\t";
592 result += (*win)->title().logical();
593 result += "\n";
594 }
595 } else {
596 result += "0\n";
597 }
598 } else {
599 result = "-1\t";
600 result += FbTk::StringUtil::number2String(cp->error_col());
601 result += "\n";
602 }
603
604
605 // write result to _FLUXBOX_ACTION_RESULT property
606 for (screen = screens.begin(); screen != screens.end(); screen++) {
607 (*screen)->rootWindow().changeProperty(atom_fbcmd_result, atom_utf8, 8,
608 PropModeReplace, (unsigned char*)result.c_str(), result.size());
609 }
610}
611
612
545} // end namespace FbCommands 613} // end namespace FbCommands