implement toggleMaximize(Vert|Horz|Full)
This commit is contained in:
parent
f7a41999bf
commit
4aeca296e8
5 changed files with 103 additions and 3 deletions
|
@ -47,9 +47,9 @@ public:
|
||||||
moveWindowLeft, //done
|
moveWindowLeft, //done
|
||||||
moveWindowRight, //done
|
moveWindowRight, //done
|
||||||
|
|
||||||
toggleMaximizeFull,
|
toggleMaximizeFull, //done
|
||||||
toggleMaximizeVertical,
|
toggleMaximizeVertical, //done
|
||||||
toggleMaximizeHorizontal,
|
toggleMaximizeHorizontal, //done
|
||||||
|
|
||||||
sendToWorkspace, //done
|
sendToWorkspace, //done
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,18 @@ epist::epist(char **argv, char *dpy_name, char *rc_file)
|
||||||
XKeysymToKeycode(getXDisplay(),
|
XKeysymToKeycode(getXDisplay(),
|
||||||
XStringToKeysym("O")),
|
XStringToKeysym("O")),
|
||||||
Mod1Mask | ControlMask));
|
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,
|
_actions.push_back(Action(Action::changeWorkspace,
|
||||||
XKeysymToKeycode(getXDisplay(),
|
XKeysymToKeycode(getXDisplay(),
|
||||||
XStringToKeysym("1")),
|
XStringToKeysym("1")),
|
||||||
|
|
|
@ -265,6 +265,18 @@ void screen::handleKeypress(const XEvent &e) {
|
||||||
window->shade(! window->shaded());
|
window->shade(! window->shaded());
|
||||||
return;
|
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:
|
default:
|
||||||
assert(false); // unhandled action type!
|
assert(false); // unhandled action type!
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -289,3 +289,69 @@ void XWindow::move(int x, int y) const {
|
||||||
findFramePosition(fx, fy);
|
findFramePosition(fx, fy);
|
||||||
XMoveWindow(_epist->getXDisplay(), _window, fx + x, fy + y);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -38,6 +38,14 @@ class XAtom;
|
||||||
typedef std::list<XWindow *> WindowList;
|
typedef std::list<XWindow *> WindowList;
|
||||||
|
|
||||||
class XWindow {
|
class XWindow {
|
||||||
|
public:
|
||||||
|
enum Max {
|
||||||
|
Max_None,
|
||||||
|
Max_Horz,
|
||||||
|
Max_Vert,
|
||||||
|
Max_Full
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
epist *_epist;
|
epist *_epist;
|
||||||
screen *_screen;
|
screen *_screen;
|
||||||
|
@ -90,6 +98,8 @@ public:
|
||||||
void focus() const;
|
void focus() const;
|
||||||
void sendTo(unsigned int dest) const;
|
void sendTo(unsigned int dest) const;
|
||||||
void move(int x, int y) 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 XWindow &w) const { return w._window == _window; }
|
||||||
bool operator == (const Window &w) const { return w == _window; }
|
bool operator == (const Window &w) const { return w == _window; }
|
||||||
|
|
Loading…
Reference in a new issue