]> Dogcows Code - chaz/openbox/blobdiff - util/epist/screen.cc
make both for's work teh same way
[chaz/openbox] / util / epist / screen.cc
index ad2b17721ea39183fa257d35ee63b262613e67e6..d8f055401645cd7b39e4e55a5705eb7a74d60cbb 100644 (file)
@@ -1,5 +1,5 @@
 // -*- mode: C++; indent-tabs-mode: nil; -*-
-// screen.cc for Epistory - a key handler for NETWM/EWMH window managers.
+// screen.cc for Epistophy - a key handler for NETWM/EWMH window managers.
 // Copyright (c) 2002 - 2002 Ben Jansens <ben at orodu.net>
 //
 // Permission is hereby granted, free of charge, to any person obtaining a
@@ -137,10 +137,30 @@ void screen::processEvent(const XEvent &e) {
     }
     break;
   case KeyPress:
+    handleKeypress(e);
     break;
   }
 }
 
+void screen::handleKeypress(const XEvent &e) {
+  list<Action>::const_iterator it = _epist->actions().begin();
+  list<Action>::const_iterator end = _epist->actions().end();
+  for (; it != end; ++it) {
+    if (e.xkey.keycode == it->keycode() &&
+        e.xkey.state == it->modifierMask() )
+      {
+        switch (it->type()) {
+        case Action::nextDesktop:
+          cycleWorkspace(true);
+          break;
+        case Action::prevDesktop:
+          cycleWorkspace(false);
+          break;
+        }
+        break;
+      }
+  }
+}
 
 // do we want to add this window to our list?
 bool screen::doAddWindow(Window window) const {
@@ -238,3 +258,35 @@ void screen::updateActiveWindow() {
         perror("putenv()");
       }
  */
+
+void screen::cycleWorkspace(const bool forward) {
+  cout << "blef" << endl;
+
+  unsigned long currentDesktop = 0;
+  unsigned long numDesktops = 0;
+  
+  if (_xatom->getValue(_root, XAtom::net_current_desktop, XAtom::cardinal,
+                       currentDesktop)) {
+    if (forward)     
+      ++currentDesktop;
+    else
+      --currentDesktop;
+
+    cout << currentDesktop << endl;
+
+    
+    _xatom->getValue(_root, XAtom::net_number_of_desktops, XAtom::cardinal,
+                     numDesktops);
+    
+    if ( ( (signed)currentDesktop) == -1)
+      currentDesktop = numDesktops - 1;
+    else if (currentDesktop >= numDesktops)
+      currentDesktop = 0;
+
+    
+    _xatom->sendClientMessage(_root, XAtom::net_current_desktop, _root,
+                              currentDesktop);
+    
+  }
+}
+                                               
This page took 0.021346 seconds and 4 git commands to generate.