From 4aeca296e895bfe74d59d4732e740c2d49c10080 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 20 Jul 2002 18:44:39 +0000 Subject: [PATCH] implement toggleMaximize(Vert|Horz|Full) --- util/epist/actions.hh | 6 ++-- util/epist/epist.cc | 12 ++++++++ util/epist/screen.cc | 12 ++++++++ util/epist/window.cc | 66 +++++++++++++++++++++++++++++++++++++++++++ util/epist/window.hh | 10 +++++++ 5 files changed, 103 insertions(+), 3 deletions(-) diff --git a/util/epist/actions.hh b/util/epist/actions.hh index b13149ae..aefe6282 100644 --- a/util/epist/actions.hh +++ b/util/epist/actions.hh @@ -47,9 +47,9 @@ public: moveWindowLeft, //done moveWindowRight, //done - toggleMaximizeFull, - toggleMaximizeVertical, - toggleMaximizeHorizontal, + toggleMaximizeFull, //done + toggleMaximizeVertical, //done + toggleMaximizeHorizontal, //done sendToWorkspace, //done diff --git a/util/epist/epist.cc b/util/epist/epist.cc index 76a64aea..13f663c9 100644 --- a/util/epist/epist.cc +++ b/util/epist/epist.cc @@ -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")), diff --git a/util/epist/screen.cc b/util/epist/screen.cc index cd749aee..19a57c71 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -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; diff --git a/util/epist/window.cc b/util/epist/window.cc index fd951aa1..aca644c3 100644 --- a/util/epist/window.cc +++ b/util/epist/window.cc @@ -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; + } +} diff --git a/util/epist/window.hh b/util/epist/window.hh index 5ba04356..e7f38280 100644 --- a/util/epist/window.hh +++ b/util/epist/window.hh @@ -38,6 +38,14 @@ class XAtom; typedef std::list 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; } -- 2.45.2