src/actions.cpp

Go to the documentation of this file.
00001 // Copyright (c) 2003 - 2004 Anselm R. Garbe <anselmg at t-online.de>
00002 // See ../LICENSE.txt for license details.
00003 //
00004 // $Id: actions.cpp 2 2007-05-16 10:38:27Z eg $
00005 
00006 extern "C" {
00007 #include <assert.h>
00008 #include <X11/Xlib.h>
00009 }
00010 #include <sstream>
00011 #include <map>
00012 
00013 #include "actions.h"
00014 
00015 #include "action.h"
00016 #include "binder.h"
00017 #include "client.h"
00018 #include "clientbar.h"
00019 #include "frame.h"
00020 #include "inputbar.h"
00021 #include "launcher.h"
00022 #include "kernel.h"
00023 #include "monitor.h"
00024 #include "logger.h"
00025 #include "expander.h"
00026 #include "prompt.h"
00027 #include "slot.h"
00028 #include "util.h"
00029 #include "validators.h"
00030 #include "workspace.h"
00031 
00032 Actions::Actions() {
00033 }
00034 
00035 Actions::~Actions() {
00036 }
00037 
00038 void Actions::initInternActions(MBindings *actionBindings) {
00039     Action *action = 0;
00040 
00041     (*actionBindings)["restart"] = new Action("restart", &Actions::restart, &Validators::isAlwaysPossible);
00042     (*actionBindings)["quit"] = new Action("quit", &Actions::quit, &Validators::isAlwaysPossible);
00043     (*actionBindings)["save-settings"] = new Action("save-settings", &Actions::saveSettings, &Validators::isAlwaysPossible);
00044 
00045     (*actionBindings)["begin-record"] = new Action("begin-record", &Actions::beginChainRecord, &Validators::validateBeginRecord);
00046 
00047     action = new Action("end-record-chain", &Actions::endChainRecord, &Validators::validateEndRecord);
00048     action->prompts()->push_back(new Prompt("action name : ", 0));
00049     (*actionBindings)["end-record-chain"] = action;
00050 
00051     action = new Action("end-record-script", &Actions::endScriptRecord,
00052                         &Validators::validateEndRecord);
00053     action->prompts()->push_back(new Prompt("script path : ", 0));
00054     (*actionBindings)["end-record-script"] = action;
00055 
00056     (*actionBindings)["cancel-record"] = new Action("cancel-record", &Actions::cancelRecord, &Validators::validateCancelRecord);
00057 
00058     action = new Action("exec-term", &Actions::executeTerm,
00059                         &Validators::isWorkspaceFocused);
00060     action->prompts()->push_back(new Prompt("command : ", &Binder::queryCommandForPattern));
00061     (*actionBindings)["exec-term"] = action;
00062 
00063     (*actionBindings)["rehash"] = new Action("rehash", &Actions::rehash, &Validators::isAlwaysPossible);
00064 
00065     action = new Action("exec", &Actions::execute,
00066                         &Validators::isWorkspaceFocused);
00067     action->prompts()->push_back(new Prompt("command : ", &Binder::queryCommandForPattern));
00068     (*actionBindings)["exec"] = action;
00069 
00070     action = new Action("destroy-action", &Actions::destroyAction,
00071                         &Validators::validateDestroyAction);
00072     action->prompts()->push_back(new Prompt("action to destroy : ",
00073                                     &Binder::queryExternChainActionsForPattern));
00074     (*actionBindings)["destroy-action"] = action;
00075 
00076 #ifdef SLOT_SUPPORT
00077     (*actionBindings)["slot-client"] = new Action("slot-client", &Actions::slotClient, &Validators::isClientFocused);
00078     (*actionBindings)["unslot-client"] = new Action("unslot-client", &Actions::unslotClient, &Validators::existsSlotClient);
00079     (*actionBindings)["toggle-slot"] = new Action("toggle-slot", &Actions::toggleSlot, &Validators::isAlwaysPossible);
00080     (*actionBindings)["cycle-slot-tab-next"] = new Action("cycle-slot-tab-next", &Actions::cycleSlotTabNext, &Validators::existSlotTabs);
00081     (*actionBindings)["cycle-slot-tab-prev"] = new Action("cycle-slot-tab-prev", &Actions::cycleSlotTabPrev, &Validators::existSlotTabs);
00082     (*actionBindings)["kill-slot-client"] = new Action("kill-slot-client", &Actions::killSlotClient, &Validators::existsSlotClient);
00083 #endif // SLOT_SUPPORT
00084 
00085     (*actionBindings)["toggle-client-sticky"] = new Action("toggle-client-sticky", &Actions::toggleClientSticky, &Validators::isClientFocused);
00086 
00087     (*actionBindings)["toggle-client-mode"] = new Action("toggle-client-mode", &Actions::toggleClientMode, &Validators::isFrameOrClientFrameFocused);
00088     (*actionBindings)["grow-left"] = new Action("grow-left", &Actions::growLeft, &Validators::validateResizeLeft);
00089     (*actionBindings)["grow-right"] = new Action("grow-right", &Actions::growRight, &Validators::validateResizeRight);
00090     (*actionBindings)["grow-up"] = new Action("grow-up", &Actions::growUp, &Validators::validateResizeUp);
00091     (*actionBindings)["grow-down"] = new Action("grow-down", &Actions::growDown, &Validators::validateResizeDown);
00092     (*actionBindings)["shrink-left"] = new Action("shrink-left", &Actions::shrinkLeft, &Validators::validateResizeRight);
00093     (*actionBindings)["shrink-right"] = new Action("shrink-right", &Actions::shrinkRight, &Validators::validateResizeLeft);
00094     (*actionBindings)["shrink-up"] = new Action("shrink-up", &Actions::shrinkUp, &Validators::validateResizeDown);
00095     (*actionBindings)["shrink-down"] = new Action("shrink-down", &Actions::shrinkDown, &Validators::validateResizeUp);
00096     (*actionBindings)["move-client-left"] = new Action("move-client-left", &Actions::moveClientLeft, &Validators::isFloatingClientFocused);
00097     (*actionBindings)["move-client-right"] = new Action("move-client-right", &Actions::moveClientRight, &Validators::isFloatingClientFocused);
00098     (*actionBindings)["move-client-up"] = new Action("move-client-up", &Actions::moveClientUp, &Validators::isFloatingClientFocused);
00099     (*actionBindings)["move-client-down"] = new Action("move-client-down", &Actions::moveClientDown, &Validators::isFloatingClientFocused);
00100     (*actionBindings)["show-bars"] = new Action("show-bars", &Actions::showBars, &Validators::isFrameOrClientFrameFocused);
00101     (*actionBindings)["hide-bars"] = new Action("hide-bars", &Actions::hideBars, &Validators::isFrameOrClientFrameFocused);
00102     (*actionBindings)["toggle-bar"] = new Action("toggle-bar", &Actions::toggleBar, &Validators::isFrameOrClientFrameFocused);
00103     (*actionBindings)["show-borders"] = new Action("show-borders", &Actions::showBorders, &Validators::isFrameOrClientFrameFocused);
00104     (*actionBindings)["hide-borders"] = new Action("hide-borders", &Actions::hideBorders, &Validators::isFrameOrClientFrameFocused);
00105     (*actionBindings)["toggle-border"] = new Action("toggle-border", &Actions::toggleBorder, &Validators::isFrameOrClientFrameFocused);
00106     (*actionBindings)["toggle-statusbar"] = new Action("toggle-statusbar", &Actions::toggleStatusBar, &Validators::isAlwaysPossible);
00107     (*actionBindings)["toggle-clientbar"] = new Action("toggle-clientbar", &Actions::toggleClientBar, &Validators::isAlwaysPossible);
00108     (*actionBindings)["kill-client"] = new Action("kill-client", &Actions::killClient, &Validators::isClientFocused);
00109     (*actionBindings)["cycle-client-next"] = new Action("cycle-client-next", &Actions::cycleClientNext, &Validators::existClients);
00110     (*actionBindings)["cycle-workspace-next"] = new Action("cycle-workspace-next", &Actions::cycleWorkspaceNext, &Validators::existWorkspaces);
00111 
00112     (*actionBindings)["toggle-mode"] = new Action("toggle-mode", &Actions::toggleMode, &Validators::validateToggleMode);
00113 
00114     action = new Action("select-monitor", &Actions::selectMonitor, &Validators::existMonitors);
00115     action->prompts()->push_back(new Prompt("monitor : ",
00116                  &Binder::queryMonitorsForPattern));
00117     (*actionBindings)["select-monitor"] = action;
00118 
00119     action = new Action("select-workspace", &Actions::selectWorkspace, &Validators::existWorkspaces);
00120     action->prompts()->push_back(new Prompt("workspace : ",
00121                  &Binder::queryWorkspacesForPattern));
00122     (*actionBindings)["select-workspace"] = action;
00123 
00124     action = new Action("select-client",
00125             &Actions::selectClient, &Validators::validateSelectClient);
00126     action->prompts()->push_back(new Prompt("client : ",
00127                  &Binder::queryClientsForPattern));
00128     (*actionBindings)["select-client"] = action;
00129 
00130     action = new Action("select-client-id",
00131             &Actions::selectClientId, &Validators::validateSelectClient);
00132     action->prompts()->push_back(new Prompt("client id: ",
00133                  &Binder::queryClientIdsForPattern));
00134     (*actionBindings)["select-client-id"] = action;
00135 
00136     (*actionBindings)["hook-client"] = new Action("hook-client", &Actions::hookClient, &Validators::validateHookClient);
00137     (*actionBindings)["unhook-client"] = new Action("unhook-client", &Actions::unhookClient, &Validators::validateUnhookClient);
00138 
00139     (*actionBindings)["cycle-client-prev"] = new Action("cycle-client-prev", &Actions::cycleClientPrev, &Validators::existClients);
00140     (*actionBindings)["cycle-workspace-prev"] = new Action("cycle-workspace-prev", &Actions::cycleWorkspacePrev, &Validators::existWorkspaces);
00141     (*actionBindings)["split-frame-left"] = new Action("split-frame-left", &Actions::splitFrameLeft, &Validators::existClientsWithinFrame);
00142     (*actionBindings)["split-frame-right"] = new Action("split-frame-right", &Actions::splitFrameRight, &Validators::existClientsWithinFrame);
00143     (*actionBindings)["split-frame-up"] = new Action("split-frame-up", &Actions::splitFrameUp, &Validators::existClientsWithinFrame);
00144     (*actionBindings)["split-frame-down"] = new Action("split-frame-down", &Actions::splitFrameDown, &Validators::existClientsWithinFrame);
00145     (*actionBindings)["join-frame-left"] = new Action("join-frame-left", &Actions::joinFrameLeft, &Validators::existsFrameLeft);
00146     (*actionBindings)["join-frame-right"] = new Action("join-frame-right", &Actions::joinFrameRight, &Validators::existsFrameRight);
00147     (*actionBindings)["join-frame-up"] = new Action("join-frame-up", &Actions::joinFrameUp, &Validators::existsFrameUp);
00148     (*actionBindings)["join-frame-down"] = new Action("join-frame-down", &Actions::joinFrameDown, &Validators::existsFrameDown);
00149     (*actionBindings)["send-client-left"] = new Action("send-client-left", &Actions::sendClientLeft, &Validators::existsFrameLeft);
00150     (*actionBindings)["send-client-right"] = new Action("send-client-right", &Actions::sendClientRight, &Validators::existsFrameRight);
00151     (*actionBindings)["send-client-up"] = new Action("send-client-up", &Actions::sendClientUp, &Validators::existsFrameUp);
00152     (*actionBindings)["send-client-down"] = new Action("send-client-down", &Actions::sendClientDown, &Validators::existsFrameDown);
00153     (*actionBindings)["detach-all-clients"] = new Action("detach-all-clients", &Actions::detachAllClients, &Validators::existClients);
00154     (*actionBindings)["attach-all-clients"] = new Action("attach-all-clients", &Actions::attachAllClients, &Validators::existDetachedClients);
00155     (*actionBindings)["detach-client"] = new Action("detach-client", &Actions::detachClient, &Validators::isClientFocused);
00156     (*actionBindings)["attach-last-client"] = new Action("attach-last-client", &Actions::attachLastClient, &Validators::existsDetachedClient);
00157     (*actionBindings)["inputmode"] = new Action("inputmode", &Actions::inputMode, &Validators::validateInputMode);
00158 
00159     action = new Action("attach-client",
00160             &Actions::attachClient, &Validators::existDetachedClients);
00161     action->prompts()->push_back(new Prompt("client : ",
00162                  &Binder::queryDetachedClientsForPattern));
00163     (*actionBindings)["attach-client"] = action;
00164 
00165     action = new Action("create-action", &Actions::createAction,
00166                         &Validators::isAlwaysPossible);
00167     action->prompts()->push_back(new Prompt("command : ", &Binder::queryCommandForPattern));
00168     action->prompts()->push_back(new Prompt("action name : ", 0));
00169     (*actionBindings)["create-action"] = action;
00170 
00171     action = new Action("create-workspace", &Actions::createWorkspace, &Validators::isAlwaysPossible);
00172     action->prompts()->push_back(new Prompt("workspace name : ", 0));
00173     (*actionBindings)["create-workspace"] = action;
00174 
00175     (*actionBindings)["destroy-frame"] = new Action("destroy-frame", &Actions::destroyFrame, &Validators::validateDestroyFrame);
00176     (*actionBindings)["destroy-workspace"] = new Action("destroy-workspace", &Actions::destroyWorkspace, &Validators::validateDestroyWorkspace);
00177 
00178     action = new Action("bind-shortcut", &Actions::bindShortcut,
00179             &Validators::isAlwaysPossible);
00180     action->prompts()->push_back(new Prompt("action to bind : ",
00181                 &Binder::queryActionKeysWithoutValidationForPattern));
00182     action->prompts()->push_back(new Prompt("keys <modifier>+<key> : ", 0));
00183     (*actionBindings)["bind-shortcut"] = action;
00184 
00185     action = new Action("rename-workspace", &Actions::renameWorkspace, &Validators::isWorkspaceFocused);
00186     action->prompts()->push_back(new Prompt("new name : ", 0));
00187     (*actionBindings)["rename-workspace"] = action;
00188 
00189     (*actionBindings)["select-frame-left"] = new Action("select-frame-left", &Actions::selectFrameLeft, &Validators::existsFrameLeft);
00190     (*actionBindings)["select-frame-right"] = new Action("select-frame-right", &Actions::selectFrameRight, &Validators::existsFrameRight);
00191     (*actionBindings)["select-frame-up"] = new Action("select-frame-up", &Actions::selectFrameUp, &Validators::existsFrameUp);
00192     (*actionBindings)["select-frame-down"] = new Action("select-frame-down", &Actions::selectFrameDown, &Validators::existsFrameDown);
00193 
00194     (*actionBindings)["swap-frame-left"] = new Action("swap-frame-left", &Actions::swapFrameLeft, &Validators::existsFrameLeft);
00195     (*actionBindings)["swap-frame-right"] = new Action("swap-frame-right", &Actions::swapFrameRight, &Validators::existsFrameRight);
00196     (*actionBindings)["swap-frame-up"] = new Action("swap-frame-up", &Actions::swapFrameUp, &Validators::existsFrameUp);
00197     (*actionBindings)["swap-frame-down"] = new Action("swap-frame-down", &Actions::swapFrameDown, &Validators::existsFrameDown);
00198 
00199     (*actionBindings)["swap-client-left"] = new Action("swap-client-left", &Actions::swapClientLeft, &Validators::existsFrameLeft);
00200     (*actionBindings)["swap-client-right"] = new Action("swap-client-right", &Actions::swapClientRight, &Validators::existsFrameRight);
00201     (*actionBindings)["swap-client-up"] = new Action("swap-client-up", &Actions::swapClientUp, &Validators::existsFrameUp);
00202     (*actionBindings)["swap-client-down"] = new Action("swap-client-down", &Actions::swapClientDown, &Validators::existsFrameDown);
00203 
00204     (*actionBindings)["toggle-max"] = new Action("toggle-max", &Actions::toggleMaximization, &Validators::isFrameOrClientFrameFocused);
00205 
00206     (*actionBindings)["raise"] = new Action("raise", &Actions::raise, &Validators::isClientFocused);
00207     (*actionBindings)["lower"] = new Action("lower", &Actions::lower, &Validators::isClientFocused);
00208     (*actionBindings)["fit-client"] = new Action("fit-client", &Actions::fitClient, &Validators::isClientFocused);
00209     (*actionBindings)["banish"] = new Action("banish", &Actions::banish, &Validators::isAlwaysPossible);
00210     (*actionBindings)["toggle-clientbar-mode"] = new Action("toggle-clientbar-mode", &Actions::toggleClientBarMode, &Validators::isAlwaysPossible);
00211     (*actionBindings)["toggle-sloppy-mode"] = new Action("toggle-sloppy-mode", &Actions::toggleSloppyMode, &Validators::isAlwaysPossible);
00212     (*actionBindings)["toggle-shortcuts"] = new Action("toggle-shortcuts", &Actions::toggleShortcuts, &Validators::isAlwaysPossible);
00213     (*actionBindings)["grab-move"] = new Action("grab-move", &Actions::grabMove, &Validators::isClientFrameFocused);
00214     (*actionBindings)["toggle-tiled"] = new Action("toggle-tiled", &Actions::toggleTiled, &Validators::existClientsWithinFrame);
00215     (*actionBindings)["zoom-client"] = new Action("zoom-client", &Actions::zoomClient, &Validators::existClientsWithinFrame);
00216 
00217 }
00218 
00219 void Actions::selectFrameLeft(Action *caller, const char *argument) {
00220 
00221     Monitor *monitor = KERNEL->focusedMonitor();
00222     Workspace *workspace = monitor->focused();
00223     assert(workspace);
00224 
00225     workspace->selectFrame(LEFT);
00226 }
00227 
00228 void Actions::selectFrameRight(Action *caller, const char *argument) {
00229 
00230     Monitor *monitor = KERNEL->focusedMonitor();
00231     Workspace *workspace = monitor->focused();
00232     assert(workspace);
00233 
00234     workspace->selectFrame(RIGHT);
00235 }
00236 
00237 void Actions::selectFrameUp(Action *caller, const char *argument) {
00238 
00239     Monitor *monitor = KERNEL->focusedMonitor();
00240     Workspace *workspace = monitor->focused();
00241     assert(workspace);
00242 
00243     workspace->selectFrame(UP);
00244 }
00245 
00246 void Actions::selectFrameDown(Action *caller, const char *argument) {
00247 
00248     Monitor *monitor = KERNEL->focusedMonitor();
00249     Workspace *workspace = monitor->focused();
00250     assert(workspace);
00251 
00252     workspace->selectFrame(DOWN);
00253 }
00254 
00255 void Actions::toggleShortcuts(Action *caller, const char *argument) {
00256     KERNEL->toggleShortcuts();
00257 }
00258 
00259 void Actions::restart(Action *caller, const char *argument) {
00260     KERNEL->restart();
00261 }
00262 
00263 void Actions::quit(Action *caller, const char *argument) {
00264     KERNEL->stop();
00265 }
00266 
00267 void Actions::saveSettings(Action *caller, const char *argument) {
00268     KERNEL->saveSettings();
00269 }
00270 
00271 void Actions::execute(Action *caller, const char *command) {
00272 
00273     Launcher::instance()->exec(command);
00274 }
00275 
00276 void Actions::executeTerm(Action *caller, const char *command) {
00277     MSettings *commonSettings = KERNEL->commonSettings();
00278     string cmd = Util::get(commonSettings, (string)"terminal") + " " + command;
00279 
00280     Launcher::instance()->exec(cmd);
00281 }
00282 
00283 void Actions::cycleClientNext(Action *caller, const char *argument) {
00284     Monitor *monitor = KERNEL->focusedMonitor();
00285     Workspace *workspace = monitor->focused();
00286     assert(workspace);
00287 
00288     workspace->cycleClientNext();
00289 }
00290 
00291 void Actions::cycleClientPrev(Action *caller, const char *argument) {
00292     Monitor *monitor = KERNEL->focusedMonitor();
00293     Workspace *workspace = monitor->focused();
00294     assert(workspace);
00295 
00296     workspace->cycleClientPrev();
00297 }
00298 
00299 void Actions::attachAllClients(Action *caller, const char *argument) {
00300     Monitor *monitor = KERNEL->focusedMonitor();
00301     monitor->attachAllClients();
00302 }
00303 
00304 void Actions::detachAllClients(Action *caller, const char *argument) {
00305     Monitor *monitor = KERNEL->focusedMonitor();
00306     monitor->detachAllClients();
00307 }
00308 
00309 void Actions::detachClient(Action *caller, const char *argument) {
00310     Monitor *monitor = KERNEL->focusedMonitor();
00311     monitor->detachClient();
00312 }
00313 
00314 #ifdef SLOT_SUPPORT
00315 void Actions::unslotClient(Action *caller, const char *argument) {
00316     Monitor *monitor = KERNEL->focusedMonitor();
00317     assert(monitor != 0);
00318 
00319     monitor->unslotClient();
00320 }
00321 
00322 void Actions::slotClient(Action *caller, const char *argument) {
00323     Monitor *monitor = KERNEL->focusedMonitor();
00324     assert(monitor != 0);
00325 
00326     monitor->slotClient();
00327 }
00328 
00329 void Actions::toggleSlot(Action *caller, const char *argument) {
00330 
00331     Monitor *monitor = KERNEL->focusedMonitor();
00332     assert(monitor != 0);
00333 
00334     monitor->toggleSlot();
00335 }
00336 
00337 void Actions::cycleSlotTabNext(Action *caller, const char *argument) {
00338 
00339     Monitor *monitor = KERNEL->focusedMonitor();
00340     monitor->cycleSlotTabNext();
00341 }
00342 
00343 void Actions::cycleSlotTabPrev(Action *caller, const char *argument) {
00344 
00345     Monitor *monitor = KERNEL->focusedMonitor();
00346     monitor->cycleSlotTabPrev();
00347 }
00348 
00349 void Actions::killSlotClient(Action *caller, const char *argument) {
00350 
00351     Monitor *monitor = KERNEL->focusedMonitor();
00352     KERNEL->killClient(monitor->slot()->focused()->focused());
00353 }
00354 
00355 #endif // SLOT_SUPPORT
00356 
00357 void Actions::attachClient(Action *caller, const char *argument) {
00358     Monitor *monitor = KERNEL->focusedMonitor();
00359 
00360     monitor->attachClientByName(argument);
00361 }
00362 
00363 void Actions::attachLastClient(Action *caller, const char *argument) {
00364     Monitor *monitor = KERNEL->focusedMonitor();
00365 
00366     monitor->attachLastClient();
00367 }
00368 
00369 void Actions::toggleClientSticky(Action *caller, const char *argument) {
00370     Monitor *monitor = KERNEL->focusedMonitor();
00371     Workspace *workspace = monitor->focused();
00372     assert(workspace);
00373 
00374     workspace->toggleClientSticky();
00375 }
00376 
00377 void Actions::toggleClientMode(Action *caller, const char *argument) {
00378     Monitor *monitor = KERNEL->focusedMonitor();
00379     Workspace *workspace = monitor->focused();
00380     assert(workspace);
00381 
00382     workspace->toggleClientMode();
00383 }
00384 
00385 void Actions::toggleMode(Action *caller, const char *argument) {
00386     Monitor *monitor = KERNEL->focusedMonitor();
00387     Workspace *workspace = monitor->focused();
00388 
00389     workspace->toggleMode();
00390 }
00391 
00392 void Actions::cycleWorkspaceNext(Action *caller, const char *argument) {
00393 
00394     Monitor *monitor = KERNEL->focusedMonitor();
00395     assert(monitor != 0);
00396 
00397     monitor->focus(monitor->next());
00398 }
00399 
00400 void Actions::cycleWorkspacePrev(Action *caller, const char *argument) {
00401 
00402     Monitor *monitor = KERNEL->focusedMonitor();
00403     assert(monitor != 0);
00404 
00405     monitor->focus(monitor->prev());
00406 }
00407 
00408 void Actions::growLeft(Action *caller, const char *argument) {
00409 
00410     Monitor *monitor = KERNEL->focusedMonitor();
00411     Workspace *workspace = monitor->focused();
00412     Thing *thing = workspace->focusedThing();
00413     assert(thing);
00414 
00415     workspace->resize(thing, LEFT, true);
00416 }
00417 
00418 void Actions::growRight(Action *caller, const char *argument) {
00419 
00420     Monitor *monitor = KERNEL->focusedMonitor();
00421     Workspace *workspace = monitor->focused();
00422     Thing *thing = workspace->focusedThing();
00423     assert(thing);
00424 
00425     workspace->resize(thing, RIGHT, true);
00426 }
00427 
00428 void Actions::growUp(Action *caller, const char *argument) {
00429 
00430     Monitor *monitor = KERNEL->focusedMonitor();
00431     Workspace *workspace = monitor->focused();
00432     Thing *thing = workspace->focusedThing();
00433     assert(thing);
00434 
00435     workspace->resize(thing, UP, true);
00436 }
00437 
00438 void Actions::growDown(Action *caller, const char *argument) {
00439 
00440     Monitor *monitor = KERNEL->focusedMonitor();
00441     Workspace *workspace = monitor->focused();
00442     Thing *thing = workspace->focusedThing();
00443     assert(thing);
00444 
00445     workspace->resize(thing, DOWN, true);
00446 }
00447 
00448 void Actions::shrinkLeft(Action *caller, const char *argument) {
00449 
00450     Monitor *monitor = KERNEL->focusedMonitor();
00451     Workspace *workspace = monitor->focused();
00452     Thing *thing = workspace->focusedThing();
00453     assert(thing);
00454 
00455     workspace->resize(thing, LEFT, false);
00456 }
00457 
00458 void Actions::shrinkRight(Action *caller, const char *argument) {
00459 
00460     Monitor *monitor = KERNEL->focusedMonitor();
00461     Workspace *workspace = monitor->focused();
00462     Thing *thing = workspace->focusedThing();
00463     assert(thing);
00464 
00465     workspace->resize(thing, RIGHT, false);
00466 }
00467 
00468 void Actions::shrinkUp(Action *caller, const char *argument) {
00469 
00470     Monitor *monitor = KERNEL->focusedMonitor();
00471     Workspace *workspace = monitor->focused();
00472     Thing *thing = workspace->focusedThing();
00473     assert(thing);
00474 
00475     workspace->resize(thing, UP, false);
00476 }
00477 
00478 void Actions::shrinkDown(Action *caller, const char *argument) {
00479 
00480     Monitor *monitor = KERNEL->focusedMonitor();
00481     Workspace *workspace = monitor->focused();
00482     Thing *thing = workspace->focusedThing();
00483     assert(thing);
00484 
00485     workspace->resize(thing, DOWN, false);
00486 }
00487 
00488 void Actions::moveClientLeft(Action *caller, const char *argument) {
00489 
00490     Monitor *monitor = KERNEL->focusedMonitor();
00491     Workspace *workspace = monitor->focused();
00492     assert(workspace);
00493 
00494     Client *client = monitor->focusedClient();
00495     if (client) {
00496         workspace->moveClient(LEFT);
00497     }
00498 }
00499 
00500 void Actions::moveClientRight(Action *caller, const char *argument) {
00501 
00502     Monitor *monitor = KERNEL->focusedMonitor();
00503     Workspace *workspace = monitor->focused();
00504     assert(workspace);
00505 
00506     Client *client = monitor->focusedClient();
00507     if (client) {
00508         workspace->moveClient(RIGHT);
00509     }
00510 }
00511 
00512 void Actions::moveClientUp(Action *caller, const char *argument) {
00513 
00514     Monitor *monitor = KERNEL->focusedMonitor();
00515     Workspace *workspace = monitor->focused();
00516     assert(workspace);
00517 
00518     Client *client = monitor->focusedClient();
00519     if (client) {
00520         workspace->moveClient(UP);
00521     }
00522 }
00523 
00524 void Actions::moveClientDown(Action *caller, const char *argument) {
00525 
00526     Monitor *monitor = KERNEL->focusedMonitor();
00527     Workspace *workspace = monitor->focused();
00528     assert(workspace);
00529 
00530     Client *client = monitor->focusedClient();
00531     if (client) {
00532         workspace->moveClient(DOWN);
00533     }
00534 }
00535 
00536 void Actions::sendClientLeft(Action *caller, const char *argument) {
00537 
00538     Monitor *monitor = KERNEL->focusedMonitor();
00539     Workspace *workspace = monitor->focused();
00540     assert(workspace);
00541 
00542     Client *client = monitor->focusedClient();
00543     if (client) {
00544         workspace->sendClient(LEFT);
00545     }
00546 }
00547 
00548 void Actions::sendClientRight(Action *caller, const char *argument) {
00549 
00550     Monitor *monitor = KERNEL->focusedMonitor();
00551     Workspace *workspace = monitor->focused();
00552     assert(workspace);
00553 
00554     Client *client = monitor->focusedClient();
00555     if (client) {
00556         workspace->sendClient(RIGHT);
00557     }
00558 }
00559 
00560 void Actions::sendClientUp(Action *caller, const char *argument) {
00561 
00562     Monitor *monitor = KERNEL->focusedMonitor();
00563     Workspace *workspace = monitor->focused();
00564     assert(workspace);
00565 
00566     Client *client = monitor->focusedClient();
00567     if (client) {
00568         workspace->sendClient(UP);
00569     }
00570 }
00571 
00572 void Actions::sendClientDown(Action *caller, const char *argument) {
00573 
00574     Monitor *monitor = KERNEL->focusedMonitor();
00575     Workspace *workspace = monitor->focused();
00576     assert(workspace);
00577 
00578     Client *client = monitor->focusedClient();
00579     if (client) {
00580         workspace->sendClient(DOWN);
00581     }
00582 }
00583 
00584 void Actions::joinFrameLeft(Action *caller, const char *argument) {
00585 
00586     Monitor *monitor = KERNEL->focusedMonitor();
00587     Workspace *workspace = monitor->focused();
00588     assert(workspace);
00589 
00590     workspace->joinFrame(LEFT);
00591 }
00592 
00593 void Actions::joinFrameRight(Action *caller, const char *argument) {
00594 
00595     Monitor *monitor = KERNEL->focusedMonitor();
00596     Workspace *workspace = monitor->focused();
00597     assert(workspace);
00598 
00599     workspace->joinFrame(RIGHT);
00600 }
00601 
00602 void Actions::joinFrameUp(Action *caller, const char *argument) {
00603 
00604     Monitor *monitor = KERNEL->focusedMonitor();
00605     Workspace *workspace = monitor->focused();
00606     assert(workspace);
00607 
00608     workspace->joinFrame(UP);
00609 }
00610 
00611 void Actions::joinFrameDown(Action *caller, const char *argument) {
00612 
00613     Monitor *monitor = KERNEL->focusedMonitor();
00614     Workspace *workspace = monitor->focused();
00615     assert(workspace);
00616 
00617     workspace->joinFrame(DOWN);
00618 }
00619 
00620 void Actions::splitFrameLeft(Action *caller, const char *argument) {
00621 
00622     Monitor *monitor = KERNEL->focusedMonitor();
00623     Workspace *workspace = monitor->focused();
00624     assert(workspace);
00625 
00626     workspace->splitFrame(LEFT);
00627 }
00628 
00629 void Actions::splitFrameRight(Action *caller, const char *argument) {
00630 
00631     Monitor *monitor = KERNEL->focusedMonitor();
00632     Workspace *workspace = monitor->focused();
00633     assert(workspace);
00634 
00635     workspace->splitFrame(RIGHT);
00636 }
00637 
00638 void Actions::splitFrameUp(Action *caller, const char *argument) {
00639 
00640     Monitor *monitor = KERNEL->focusedMonitor();
00641     Workspace *workspace = monitor->focused();
00642     assert(workspace);
00643 
00644     workspace->splitFrame(UP);
00645 }
00646 
00647 void Actions::splitFrameDown(Action *caller, const char *argument) {
00648 
00649     Monitor *monitor = KERNEL->focusedMonitor();
00650     Workspace *workspace = monitor->focused();
00651     assert(workspace);
00652 
00653     workspace->splitFrame(DOWN);
00654 }
00655 
00656 void Actions::showBorders(Action *caller, const char *argument) {
00657 
00658     Monitor *monitor = KERNEL->focusedMonitor();
00659     Workspace *workspace = monitor->focused();
00660     assert(workspace);
00661 
00662     workspace->toggleBorders(true);
00663 }
00664 
00665 void Actions::hideBorders(Action *caller, const char *argument) {
00666 
00667     Monitor *monitor = KERNEL->focusedMonitor();
00668     Workspace *workspace = monitor->focused();
00669     assert(workspace);
00670 
00671     workspace->toggleBorders(false);
00672 }
00673 
00674 void Actions::toggleBorder(Action *caller, const char *argument) {
00675 
00676     Monitor *monitor = KERNEL->focusedMonitor();
00677     Workspace *workspace = monitor->focused();
00678     assert(workspace);
00679 
00680     Thing *thing = workspace->focusedThing();
00681     if (thing) {
00682         if (thing->borderWidth()) {
00683             thing->setBorderWidth(0);
00684         }
00685         else {
00686             thing->setBorderWidth(KERNEL->borderWidth());
00687         }
00688         thing->resize();
00689     }
00690 }
00691 
00692 void Actions::showBars(Action *caller, const char *argument) {
00693 
00694     Monitor *monitor = KERNEL->focusedMonitor();
00695     Workspace *workspace = monitor->focused();
00696     assert(workspace);
00697 
00698     workspace->toggleBars(true);
00699 }
00700 
00701 void Actions::hideBars(Action *caller, const char *argument) {
00702 
00703     Monitor *monitor = KERNEL->focusedMonitor();
00704     Workspace *workspace = monitor->focused();
00705     assert(workspace);
00706 
00707     workspace->toggleBars(false);
00708 }
00709 
00710 void Actions::toggleBar(Action *caller, const char *argument) {
00711 
00712     Monitor *monitor = KERNEL->focusedMonitor();
00713     Workspace *workspace = monitor->focused();
00714     assert(workspace);
00715 
00716     Thing *thing = workspace->focusedThing();
00717     if (thing) {
00718         thing->setTitleBarHeight(thing->titleBarHeight() ? 
00719                                  0 : monitor->titleBarHeight());
00720         thing->resize();
00721     }
00722 }
00723 
00724 void Actions::toggleClientBar(Action *caller, const char *argument) {
00725 
00726     Monitor *monitor = KERNEL->focusedMonitor();
00727     assert(monitor != 0);
00728 
00729     monitor->toggleClientBar();
00730 }
00731 
00732 void Actions::toggleStatusBar(Action *caller, const char *argument) {
00733 
00734     Monitor *monitor = KERNEL->focusedMonitor();
00735     assert(monitor != 0);
00736 
00737     monitor->toggleStatusBar();
00738 }
00739 
00740 void Actions::inputMode(Action *caller, const char *argument) {
00741 
00742     Monitor *monitor = KERNEL->focusedMonitor();
00743     assert(monitor != 0);
00744 
00745     monitor->inputBar()->runKey(KERNEL->defaultPrompt());
00746 }
00747 
00748 void Actions::killClient(Action *caller, const char *argument) {
00749 
00750     KERNEL->killClient(KERNEL->focusedClient());
00751 }
00752 
00753 void Actions::sequence(Action *caller, const char *command) {
00754 
00755     Launcher::instance()->execSeq(caller, command);
00756 }
00757 
00758 void Actions::createAction(Action *caller, const char *argument) {
00759 
00760     string arg = argument;
00761     LOGDEBUG("arg: " + arg);
00762     unsigned int argDelim = arg.find_last_of('+');
00763     if (argDelim == string::npos) {
00764         return;
00765     }
00766     string cmd = arg.substr(0, argDelim);
00767     string bind = arg.substr(argDelim + 1);
00768 
00769     if ((bind.length() < 1) || (cmd.length() < 1)) {
00770         return;
00771     }
00772     Action *action = new Action(bind, &Actions::execute,
00773                                 &Validators::isWorkspaceFocused, Action::EXTERN,
00774                                 (char *)cmd.c_str());
00775     (*KERNEL->actionBindings())[bind] = action;
00776     (*KERNEL->actionSettings())["extern." + action->id() + ".cmd"] = cmd;
00777 }
00778 
00779 void Actions::createWorkspace(Action *caller, const char *argument) {
00780 
00781     assert(argument != 0);
00782 
00783     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00784 
00785     focusedMonitor->createNewWorkspace(argument);
00786 }
00787 
00788 
00789 void Actions::bindShortcut(Action *caller, const char *argument) {
00790 
00791     KERNEL->bindShortcut(argument);
00792 }
00793 
00794 // TODO: ungrab potentially keys before removing
00795 void Actions::destroyAction(Action *caller, const char *argument) {
00796 
00797     Action *action = Util::get(KERNEL->actionBindings(), argument);
00798     if (action && (action->type() != Action::INTERN)) {
00799 
00800         Util::remove(KERNEL->actionBindings(), argument);
00801         string prefix = (action->type() == Action::EXTERN) ? "extern." :
00802             "chain.";
00803         prefix += argument;
00804         Util::remove(KERNEL->actionSettings(), prefix);
00805     }
00806 }
00807 
00808 void Actions::destroyWorkspace(Action *caller, const char *argument) {
00809     Monitor *monitor = KERNEL->focusedMonitor();
00810     assert(monitor != 0);
00811 
00812     monitor->destroyWorkspace(monitor->focused());
00813 }
00814 
00815 void Actions::selectMonitor(Action *caller, const char *argument) {
00816 
00817     KERNEL->selectMonitor(argument);
00818 }
00819 
00820 void Actions::selectWorkspace(Action *caller, const char *argument) {
00821 
00822     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00823     Workspace *workspace = focusedMonitor->workspaceForName(argument);
00824     if (workspace) {
00825         focusedMonitor->focus(workspace);
00826     }
00827 }
00828 
00829 void Actions::selectClientId(Action *caller, const char *argument) {
00830 
00831     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00832 
00833     focusedMonitor->focusClientById(argument);
00834 }
00835 
00836 void Actions::selectClient(Action *caller, const char *argument) {
00837 
00838     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00839 
00840     focusedMonitor->focusClientByName(argument);
00841 }
00842 
00843 void Actions::renameWorkspace(Action *caller, const char *argument) {
00844 
00845     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00846     assert(focusedMonitor != 0);
00847 
00848     focusedMonitor->renameWorkspace(focusedMonitor->focused(),
00849                                     argument);
00850 }
00851 
00852 void Actions::swapFrameLeft(Action *caller, const char *argument) {
00853 
00854     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00855     Workspace *workspace = focusedMonitor->focused();
00856     assert(workspace);
00857 
00858     workspace->swapFrame(LEFT);
00859 }
00860 
00861 void Actions::swapFrameRight(Action *caller, const char *argument) {
00862 
00863     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00864     Workspace *workspace = focusedMonitor->focused();
00865     assert(workspace);
00866 
00867     workspace->swapFrame(RIGHT);
00868 }
00869 
00870 void Actions::swapFrameUp(Action *caller, const char *argument) {
00871 
00872     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00873     Workspace *workspace = focusedMonitor->focused();
00874     assert(workspace);
00875 
00876     workspace->swapFrame(UP);
00877 }
00878 
00879 void Actions::swapFrameDown(Action *caller, const char *argument) {
00880 
00881     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00882     Workspace *workspace = focusedMonitor->focused();
00883     assert(workspace);
00884 
00885     workspace->swapFrame(DOWN);
00886 }
00887 
00888 void Actions::swapClientLeft(Action *caller, const char *argument) {
00889 
00890     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00891     Workspace *workspace = focusedMonitor->focused();
00892     assert(workspace);
00893 
00894     workspace->swapClient(LEFT);
00895 }
00896 
00897 void Actions::swapClientRight(Action *caller, const char *argument) {
00898 
00899     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00900     Workspace *workspace = focusedMonitor->focused();
00901     assert(workspace);
00902 
00903     workspace->swapClient(RIGHT);
00904 }
00905 
00906 void Actions::swapClientUp(Action *caller, const char *argument) {
00907 
00908     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00909     Workspace *workspace = focusedMonitor->focused();
00910     assert(workspace);
00911 
00912     workspace->swapClient(UP);
00913 }
00914 
00915 void Actions::swapClientDown(Action *caller, const char *argument) {
00916 
00917     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00918     Workspace *workspace = focusedMonitor->focused();
00919     assert(workspace);
00920 
00921     workspace->swapClient(DOWN);
00922 }
00923 
00924 
00925 void Actions::toggleMaximization(Action *caller, const char *argument) {
00926     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00927 
00928     focusedMonitor->toggleThingMaximization();
00929 }
00930 
00931 void Actions::toggleClientBarMode(Action *caller, const char *argument) {
00932 
00933     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00934     ClientBar *clientBar = focusedMonitor->clientBar();
00935 
00936     clientBar->setMode((clientBar->mode() == ClientBar::PAGER) ?
00937                         ClientBar::CLIENTINFO : ClientBar::PAGER);
00938     clientBar->illuminate();
00939 }
00940 
00941 void Actions::fitClient(Action *caller, const char *argument) {
00942 
00943     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00944     Workspace *workspace = focusedMonitor->focused();
00945 
00946     workspace->fitClient();
00947 }
00948 
00949 void Actions::lower(Action *caller, const char *argument) {
00950 
00951     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00952     Workspace *workspace = focusedMonitor->focused();
00953 
00954     workspace->lower();
00955 }
00956 
00957 void Actions::raise(Action *caller, const char *argument) {
00958 
00959     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00960     Workspace *workspace = focusedMonitor->focused();
00961 
00962     workspace->raise();
00963 }
00964 
00965 void Actions::rehash(Action *caller, const char *argument) {
00966 
00967     Expander::instance()->rehash();
00968 }
00969 
00970 void Actions::beginChainRecord(Action *caller, const char *argument) {
00971     KERNEL->beginRecording();
00972 }
00973 
00974 void Actions::endChainRecord(Action *caller, const char *argument) {
00975     KERNEL->endChainRecording(argument);
00976 }
00977 
00978 void Actions::endScriptRecord(Action *caller, const char *argument) {
00979     KERNEL->endScriptRecording(argument);
00980 }
00981 
00982 void Actions::cancelRecord(Action *caller, const char *argument) {
00983     KERNEL->cancelRecording();
00984 }
00985 
00986 void Actions::banish(Action *caller, const char *argument) {
00987     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00988     focusedMonitor->banish();
00989 }
00990 
00991 void Actions::unhookClient(Action *caller, const char *argument) {
00992     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00993 
00994     focusedMonitor->unhookClient();
00995 }
00996 
00997 void Actions::hookClient(Action *caller, const char *argument) {
00998     Monitor *focusedMonitor = KERNEL->focusedMonitor();
00999 
01000     focusedMonitor->hookClient();
01001 }
01002 
01003 void Actions::toggleSloppyMode(Action *caller, const char *argument) {
01004     KERNEL->toggleSloppyMode();
01005 }
01006 
01007 void Actions::grabMove(Action *caller, const char *argument) {
01008     KERNEL->grabMove();
01009 }
01010 
01011 void Actions::zoomClient(Action *caller, const char *argument) {
01012     Monitor *monitor = KERNEL->focusedMonitor();
01013     Workspace *workspace = monitor->focused(); 
01014     Frame *frame = workspace->focusedFrame();
01015 
01016     if (frame) {
01017         frame->zoomClient();
01018     }
01019 }
01020 
01021 void Actions::toggleTiled(Action *caller, const char *argument) {
01022     Monitor *monitor = KERNEL->focusedMonitor();
01023     Workspace *workspace = monitor->focused();
01024     Frame *frame = workspace->focusedFrame();
01025     if (frame) {
01026         frame->toggleTiled();
01027     }
01028 }
01029 
01030 void Actions::destroyFrame(Action *caller, const char *argument) {
01031     Monitor *monitor = KERNEL->focusedMonitor();
01032     Workspace *workspace = monitor->focused();
01033 
01034     if (workspace->focusedFrame()) {
01035         workspace->destroyFrame(workspace->focusedFrame());
01036     }
01037 }

Generated on Thu May 24 15:19:31 2007 for ncwm by  doxygen 1.5.1