added window cycling

This commit is contained in:
Dana Jansens 2002-07-20 09:02:45 +00:00
parent 8e601e4a64
commit c9be3ee061
4 changed files with 56 additions and 7 deletions

View file

@ -39,7 +39,7 @@ public:
raiseWindow, raiseWindow,
lowerWindow, lowerWindow,
closeWindow, closeWindow,
shade, toggleshade,
moveWindowUp, moveWindowUp,
moveWindowDown, moveWindowDown,
moveWindowLeft, moveWindowLeft,

View file

@ -79,15 +79,23 @@ epist::epist(char **argv, char *dpy_name, char *rc_file)
_actions.push_back(Action(Action::nextWorkspace, _actions.push_back(Action(Action::nextWorkspace,
XKeysymToKeycode(getXDisplay(), XKeysymToKeycode(getXDisplay(),
XStringToKeysym("Tab")), XStringToKeysym("Tab")),
Mod1Mask)); ControlMask));
_actions.push_back(Action(Action::prevWorkspace, _actions.push_back(Action(Action::prevWorkspace,
XKeysymToKeycode(getXDisplay(), XKeysymToKeycode(getXDisplay(),
XStringToKeysym("Tab")), XStringToKeysym("Tab")),
ControlMask)); ControlMask | ShiftMask));
_actions.push_back(Action(Action::shade, _actions.push_back(Action(Action::toggleshade,
XKeysymToKeycode(getXDisplay(), XKeysymToKeycode(getXDisplay(),
XStringToKeysym("F5")), XStringToKeysym("F5")),
Mod1Mask)); Mod1Mask));
_actions.push_back(Action(Action::nextWindow,
XKeysymToKeycode(getXDisplay(),
XStringToKeysym("Tab")),
Mod1Mask));
_actions.push_back(Action(Action::prevWindow,
XKeysymToKeycode(getXDisplay(),
XStringToKeysym("Tab")),
Mod1Mask | ShiftMask));
activateGrabs(); activateGrabs();
} }

View file

@ -157,6 +157,14 @@ void screen::handleKeypress(const XEvent &e) {
cycleWorkspace(false); cycleWorkspace(false);
return; return;
case Action::nextWindow:
cycleWindow(true);
return;
case Action::prevWindow:
cycleWindow(false);
return;
case Action::changeWorkspace: case Action::changeWorkspace:
changeWorkspace(it->number()); changeWorkspace(it->number());
return; return;
@ -167,7 +175,7 @@ void screen::handleKeypress(const XEvent &e) {
XWindow *window = *_active; XWindow *window = *_active;
switch (it->type()) { switch (it->type()) {
case Action::shade: case Action::toggleshade:
window->shade(! window->shaded()); window->shade(! window->shaded());
return; return;
} }
@ -274,6 +282,37 @@ void screen::updateActiveWindow() {
} }
*/ */
void screen::cycleWindow(const bool forward) const {
if (_clients.empty()) return;
WindowList::const_iterator target = _active;
if (target == _clients.end())
target = _clients.begin();
do {
if (forward) {
++target;
if (target == _clients.end())
target = _clients.begin();
} else {
if (target == _clients.begin())
target = _clients.end();
--target;
}
} while (target == _clients.end() || (*target)->iconic());
if (target != _clients.end()) {
// we dont send an ACTIVE_WINDOW client message because that would also
// unshade the window if it was shaded
XSetInputFocus(_epist->getXDisplay(), (*target)->window(), RevertToNone,
CurrentTime);
XRaiseWindow(_epist->getXDisplay(), (*target)->window());
}
}
void screen::cycleWorkspace(const bool forward) const { void screen::cycleWorkspace(const bool forward) const {
unsigned long currentDesktop = 0; unsigned long currentDesktop = 0;
unsigned long numDesktops = 0; unsigned long numDesktops = 0;
@ -297,6 +336,7 @@ void screen::cycleWorkspace(const bool forward) const {
} }
} }
void screen::changeWorkspace(const int num) const { void screen::changeWorkspace(const int num) const {
_xatom->sendClientMessage(_root, XAtom::net_current_desktop, _root, num); _xatom->sendClientMessage(_root, XAtom::net_current_desktop, _root, num);
} }

View file

@ -65,8 +65,9 @@ public:
void handleKeypress(const XEvent &e); void handleKeypress(const XEvent &e);
void cycleWorkspace(const bool forward)const; void cycleWindow(const bool forward) const;
void changeWorkspace(const int num)const; void cycleWorkspace(const bool forward) const;
void changeWorkspace(const int num) const;
void toggleShaded(const Window win) const; void toggleShaded(const Window win) const;
}; };