Added sendToNext/PrevWorkspace to send the active window to next/previous workspace...
authorScott Moynes <smoynes@nexus.carleton.ca>
Tue, 31 Dec 2002 22:52:06 +0000 (22:52 +0000)
committerScott Moynes <smoynes@nexus.carleton.ca>
Tue, 31 Dec 2002 22:52:06 +0000 (22:52 +0000)
util/epist/actions.cc
util/epist/actions.hh
util/epist/epistrc.5.in
util/epist/parser.cc
util/epist/screen.cc
util/epist/screen.hh
util/epist/window.cc

index e37ff2470602338e445b40ed65d9dac5510e61cc..86619af7ff3b52d5f01c15e5200b25f20d8974ea 100644 (file)
@@ -37,12 +37,32 @@ Action::Action(enum ActionType type, KeyCode keycode, unsigned int modifierMask,
     noaction
   };
 
+  ActionType bool_types[] = {
+    sendToNextWorkspace,
+    sendToPrevWorkspace,
+    noaction
+  };
+
   for (int i = 0; str_types[i] != noaction; ++i) {
     if (type == str_types[i]) {
       _stringParam = str;
       return;
     }
   }
+
+  for (int i = 0; bool_types[i] != noaction; ++i) {
+    if (type == bool_types[i]) {
+      const char *tmp = str.c_str();
+
+      
+      if (strcasecmp(tmp, "true") == 0 || strcasecmp(tmp, "1") == 0 ||
+          strcasecmp(tmp, "on") == 0)
+        _numberParam = 1;
+      else
+        _numberParam = 0;
+      return;
+    }
+  }
  
   _numberParam = atoi( str.c_str() );
 
index ac6d62b5f2c75b466d94fcb93212f05742f75d70..78ab1007b0d79c988997fe4e7c9ce4bfdd813f96 100644 (file)
@@ -53,6 +53,8 @@ public:
     toggleMaximizeHorizontal, //done
 
     sendToWorkspace, //done
+    sendToNextWorkspace,
+    sendToPrevWorkspace,
 
     nextWindow, //done for now
     prevWindow, //done for now
index 06615768ec7d9dc0da7320fc00725e39f3f17e7c..e05e93cb48906d735e68a1adaddfe34d5a1d6053 100644 (file)
@@ -120,6 +120,10 @@ Maximizes and Unmaxizes the currently focused window horizontally.
 Sends the currently focused window to another workspace. This takes a single
 numberical parameter, which is the workspace to send the window to. Workspace
 numbers begin at 1.
+.SS sendToNextWorkspace
+.SS sendToPrevWorkspace
+Sends the currently focused window to the next/previous workspace. Takes 
+boolean parameter that when true switches to that workspace as well.
 .SS nextWindow
 .SS prevWindow
 Cycles focus to the next/previous window on the workspace. This can take a
index f6ed589e4ed8449eb67b28e6e7339f63ccab1667..c1b2ff83988f0efe098f15062a196f096ebd96cd 100644 (file)
@@ -102,6 +102,8 @@ void parser::setAction(string act)
     { "togglemaximizevertical", Action::toggleMaximizeVertical },
     { "togglemaximizehorizontal", Action::toggleMaximizeHorizontal },
     { "sendtoworkspace", Action::sendToWorkspace },
+    { "sendtonextworkspace", Action::sendToNextWorkspace },
+    { "sendtoprevworkspace", Action::sendToPrevWorkspace },
     { "nextwindow", Action::nextWindow },
     { "prevwindow", Action::prevWindow },
     { "nextwindowonallworkspaces", Action::nextWindowOnAllWorkspaces },
index 63b9578d2d94fd3e3f90c77fd13f7e8b8e9bf15c..f15b43f0864552b957b647a9805b35920b4d07af 100644 (file)
@@ -320,7 +320,15 @@ void screen::handleKeypress(const XEvent &e) {
     case Action::sendToWorkspace:
       window->sendTo(it->number());
       return;
+      
+    case Action::sendToNextWorkspace:
+      sendToNextWorkspace(*window, true, (it->number() != 0));
+      return;
 
+    case Action::sendToPrevWorkspace:
+      sendToNextWorkspace(*window, false, (it->number() != 0));
+      return;
+      
     case Action::toggleOmnipresent:
       if (window->desktop() == 0xffffffff)
         window->sendTo(_active_desktop);
@@ -694,7 +702,6 @@ void screen::cycleWorkspace(const bool forward, const int increment,
     changeWorkspace(destination);
 }
 
-
 void screen::changeWorkspace(const int num) const {
   assert(_managed);
 
@@ -766,6 +773,21 @@ void screen::changeWorkspaceHorz(const int num) const {
   changeWorkspace(wnum);
 }
 
+ void screen::sendToNextWorkspace(const XWindow &window, bool forward,
+                                  bool follow) const {
+   assert(_managed);
+   int dest = (signed) _active_desktop + (forward ? 1 : -1 );
+   
+   if (dest >= (signed)_num_desktops)
+       dest = 0;
+   else if ( dest < 0)
+       dest = _num_desktops - 1;
+         
+   window.sendTo(dest);
+   if (follow)
+     changeWorkspace(dest);
+ }
+
 void screen::grabKey(const KeyCode keyCode, const int modifierMask) const {
 
   Display *display = _epist->getXDisplay();
index f0f3de079d87a654eaa608a541040dfde9646be1..c9907b36f627c9d56dcdd316b7b489445f93d7c9 100644 (file)
@@ -97,6 +97,8 @@ public:
   void changeWorkspaceVert(const int num) const;
   void changeWorkspaceHorz(const int num) const;
 
+  void sendToNextWorkspace(const XWindow& win, bool forward, 
+                           bool follow) const;
   void toggleShaded(const Window win) const;
   void execCommand(const std::string &cmd) const;
 
index 6b3f2f5f7741895bdc714ca1b3de4cb24cc05254..127ca3ef0908aa069b1c4bf7c8274565c26f94d1 100644 (file)
@@ -279,7 +279,6 @@ void XWindow::sendTo(unsigned int dest) const {
                             _window, dest);
 }
 
-
 void XWindow::move(int x, int y) const {
   // get the window's decoration sizes (margins)
   Strut margins;