]> Dogcows Code - chaz/openbox/commitdiff
implement toggleMaximize(Vert|Horz|Full)
authorDana Jansens <danakj@orodu.net>
Sat, 20 Jul 2002 18:44:39 +0000 (18:44 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 20 Jul 2002 18:44:39 +0000 (18:44 +0000)
util/epist/actions.hh
util/epist/epist.cc
util/epist/screen.cc
util/epist/window.cc
util/epist/window.hh

index b13149ae231e293fdc1cfb7b0a95bead8038bccd..aefe6282728c63a06e59ff60fcb29e1a75330173 100644 (file)
@@ -47,9 +47,9 @@ public:
     moveWindowLeft, //done
     moveWindowRight, //done
 
-    toggleMaximizeFull,
-    toggleMaximizeVertical,
-    toggleMaximizeHorizontal,
+    toggleMaximizeFull, //done
+    toggleMaximizeVertical, //done
+    toggleMaximizeHorizontal, //done
 
     sendToWorkspace, //done
 
index 76a64aeaf231b2fd4e1690715462b877e473dc09..13f663c92c3bd695f8e86b939a08992207f51129 100644 (file)
@@ -142,6 +142,18 @@ epist::epist(char **argv, char *dpy_name, char *rc_file)
                            XKeysymToKeycode(getXDisplay(),
                                              XStringToKeysym("O")),
                            Mod1Mask | ControlMask));
+  _actions.push_back(Action(Action::toggleMaximizeHorizontal,
+                           XKeysymToKeycode(getXDisplay(),
+                                             XStringToKeysym("X")),
+                           ShiftMask | Mod1Mask));
+  _actions.push_back(Action(Action::toggleMaximizeVertical,
+                           XKeysymToKeycode(getXDisplay(),
+                                             XStringToKeysym("X")),
+                           ShiftMask | ControlMask));
+  _actions.push_back(Action(Action::toggleMaximizeFull,
+                           XKeysymToKeycode(getXDisplay(),
+                                             XStringToKeysym("X")),
+                           Mod1Mask | ControlMask));
   _actions.push_back(Action(Action::changeWorkspace,
                            XKeysymToKeycode(getXDisplay(),
                                              XStringToKeysym("1")),
index cd749aeea2b3a5421f035f02908bbe73799c130f..19a57c71dd1658d847b668a43c629eda400a3ee1 100644 (file)
@@ -265,6 +265,18 @@ void screen::handleKeypress(const XEvent &e) {
           window->shade(! window->shaded());
           return;
       
+        case Action::toggleMaximizeHorizontal:
+          window->toggleMaximize(XWindow::Max_Horz);
+          return;
+      
+        case Action::toggleMaximizeVertical:
+          window->toggleMaximize(XWindow::Max_Vert);
+          return;
+      
+        case Action::toggleMaximizeFull:
+          window->toggleMaximize(XWindow::Max_Full);
+          return;
+      
         default:
           assert(false);  // unhandled action type!
           break;
index fd951aa1db9e5abe31e13bb72931f464e1388076..aca644c3630056ea70de6c9d76977b9060817d7e 100644 (file)
@@ -289,3 +289,69 @@ void XWindow::move(int x, int y) const {
   findFramePosition(fx, fy);
   XMoveWindow(_epist->getXDisplay(), _window, fx + x, fy + y);
 }
+
+
+void XWindow::toggleMaximize(Max max) const {
+  switch (max) {
+  case Max_Full:
+    _xatom->
+      sendClientMessage(_screen->rootWindow(), XAtom::net_wm_state,
+                        _window, (_max_vert == _max_horz ? 2 : 1),
+                        _xatom->getAtom(XAtom::net_wm_state_maximized_horz),
+                        _xatom->getAtom(XAtom::net_wm_state_maximized_vert));
+    break;
+
+  case Max_Horz:
+    _xatom->
+      sendClientMessage(_screen->rootWindow(), XAtom::net_wm_state,
+                        _window, 2,
+                        _xatom->getAtom(XAtom::net_wm_state_maximized_horz));
+    break;
+
+  case Max_Vert:
+    _xatom->
+      sendClientMessage(_screen->rootWindow(), XAtom::net_wm_state,
+                        _window, 2,
+                        _xatom->getAtom(XAtom::net_wm_state_maximized_vert));
+    break;
+    
+  case Max_None:
+    assert(false);  // you should not do this. it is pointless and probly a bug
+    break;
+  }
+}
+
+
+void XWindow::maximize(Max max) const {
+  switch (max) {
+  case Max_None:
+    _xatom->
+      sendClientMessage(_screen->rootWindow(), XAtom::net_wm_state,
+                        _window, 0,
+                        _xatom->getAtom(XAtom::net_wm_state_maximized_horz),
+                        _xatom->getAtom(XAtom::net_wm_state_maximized_vert));
+    break;
+
+  case Max_Full:
+    _xatom->
+      sendClientMessage(_screen->rootWindow(), XAtom::net_wm_state,
+                        _window, 1,
+                        _xatom->getAtom(XAtom::net_wm_state_maximized_horz),
+                        _xatom->getAtom(XAtom::net_wm_state_maximized_vert));
+    break;
+
+  case Max_Horz:
+    _xatom->
+      sendClientMessage(_screen->rootWindow(), XAtom::net_wm_state,
+                        _window, 1,
+                        _xatom->getAtom(XAtom::net_wm_state_maximized_horz));
+    break;
+
+  case Max_Vert:
+    _xatom->
+      sendClientMessage(_screen->rootWindow(), XAtom::net_wm_state,
+                        _window, 1,
+                        _xatom->getAtom(XAtom::net_wm_state_maximized_vert));
+    break;
+  }
+}
index 5ba0435656144bb49439621be7db01b5e079e604..e7f382808cc56de23ca33221166067ef7ae75208 100644 (file)
@@ -38,6 +38,14 @@ class XAtom;
 typedef std::list<XWindow *> WindowList;
 
 class XWindow {
+public:
+  enum Max {
+    Max_None,
+    Max_Horz,
+    Max_Vert,
+    Max_Full
+  };
+
 private:
   epist *_epist;
   screen *_screen;
@@ -90,6 +98,8 @@ public:
   void focus() const;
   void sendTo(unsigned int dest) const;
   void move(int x, int y) const;
+  void toggleMaximize(Max max) const; // i hate toggle functions
+  void maximize(Max max) const;
 
   bool operator == (const XWindow &w) const { return w._window == _window; }
   bool operator == (const Window &w) const { return w == _window; }
This page took 0.031295 seconds and 4 git commands to generate.