Added changeWorkspace() and a broken toggleShaded()

This commit is contained in:
Scott Moynes 2002-07-20 01:44:01 +00:00
parent a939bb6e41
commit b4411cb1ef
5 changed files with 41 additions and 30 deletions

View file

@ -22,6 +22,7 @@
#include "actions.hh" #include "actions.hh"
Action::Action(enum ActionType type, KeyCode keycode, int modifierMask): Action::Action(enum ActionType type, KeyCode keycode, int modifierMask,
_type(type), _keycode(keycode), _modifierMask(modifierMask) int num): _type(type), _keycode(keycode),
_modifierMask(modifierMask), _numberParam(num)
{ } { }

View file

@ -47,15 +47,15 @@ public:
nextWindow, nextWindow,
prevWindow, prevWindow,
nextWindowOnAllDesktops, nextWindowOnAllWorkspaces,
prevWindowOnAllDesktops, prevWindowOnAllWorkspaces,
nextWindowOfClass, nextWindowOfClass,
prevWindowOfClass, prevWindowOfClass,
changeDesktop, changeWorkspace, //done
nextDesktop, nextWorkspace, //done
prevDesktop, prevWorkspace, //done
// these are openbox extensions // these are openbox extensions
showRootMenu, showRootMenu,
@ -75,12 +75,15 @@ private:
const KeyCode _keycode; const KeyCode _keycode;
const int _modifierMask; const int _modifierMask;
const int _numberParam;
public: public:
inline enum ActionType type() const { return _type;} inline enum ActionType type() const { return _type;}
inline const KeyCode keycode() const { return _keycode; } inline const KeyCode keycode() const { return _keycode; }
inline const int modifierMask() const { return _modifierMask; } inline const int modifierMask() const { return _modifierMask; }
inline const int number() const { return _numberParam; }
Action(enum ActionType type, KeyCode keycode, int modifierMask); Action(enum ActionType type, KeyCode keycode, int modifierMask,
int number = 0);
}; };
typedef std::list<Action> ActionList; typedef std::list<Action> ActionList;

View file

@ -76,14 +76,18 @@ epist::epist(char **argv, char *dpy_name, char *rc_file)
::exit(1); ::exit(1);
} }
_actions.push_back(Action(Action::nextDesktop, _actions.push_back(Action(Action::nextWorkspace,
XKeysymToKeycode(getXDisplay(), XKeysymToKeycode(getXDisplay(),
XStringToKeysym("Tab")), XStringToKeysym("Tab")),
Mod1Mask)); Mod1Mask));
_actions.push_back(Action(Action::prevDesktop, _actions.push_back(Action(Action::prevWorkspace,
XKeysymToKeycode(getXDisplay(), XKeysymToKeycode(getXDisplay(),
XStringToKeysym("Tab")), XStringToKeysym("Tab")),
ControlMask)); ControlMask));
_actions.push_back(Action(Action::shade,
XKeysymToKeycode(getXDisplay(),
XStringToKeysym("F5")),
Mod1Mask));
activateGrabs(); activateGrabs();
} }
@ -92,11 +96,6 @@ epist::~epist() {
delete _xatom; delete _xatom;
} }
// XGrabKey(_epist->getXDisplay(), XKeysymToKeycode(_epist->getXDisplay(),
// XStringToKeysym("F5")),
// Mod1Mask, _root, True, GrabModeAsync, GrabModeAsync);
void epist::activateGrabs() { void epist::activateGrabs() {
ScreenList::const_iterator scrit, scrend = _screens.end(); ScreenList::const_iterator scrit, scrend = _screens.end();

View file

@ -150,12 +150,18 @@ void screen::handleKeypress(const XEvent &e) {
e.xkey.state == it->modifierMask() ) e.xkey.state == it->modifierMask() )
{ {
switch (it->type()) { switch (it->type()) {
case Action::nextDesktop: case Action::nextWorkspace:
cycleWorkspace(true); cycleWorkspace(true);
break; break;
case Action::prevDesktop: case Action::prevWorkspace:
cycleWorkspace(false); cycleWorkspace(false);
break; break;
case Action::changeWorkspace:
changeWorkspace(it->number());
break;
case Action::shade:
toggleShaded((*_active)->window());
break;
} }
break; break;
} }
@ -259,9 +265,7 @@ void screen::updateActiveWindow() {
} }
*/ */
void screen::cycleWorkspace(const bool forward) { void screen::cycleWorkspace(const bool forward) const {
cout << "blef" << endl;
unsigned long currentDesktop = 0; unsigned long currentDesktop = 0;
unsigned long numDesktops = 0; unsigned long numDesktops = 0;
@ -272,9 +276,6 @@ void screen::cycleWorkspace(const bool forward) {
else else
--currentDesktop; --currentDesktop;
cout << currentDesktop << endl;
_xatom->getValue(_root, XAtom::net_number_of_desktops, XAtom::cardinal, _xatom->getValue(_root, XAtom::net_number_of_desktops, XAtom::cardinal,
numDesktops); numDesktops);
@ -283,10 +284,15 @@ void screen::cycleWorkspace(const bool forward) {
else if (currentDesktop >= numDesktops) else if (currentDesktop >= numDesktops)
currentDesktop = 0; currentDesktop = 0;
changeWorkspace(currentDesktop);
_xatom->sendClientMessage(_root, XAtom::net_current_desktop, _root,
currentDesktop);
} }
} }
void screen::changeWorkspace(const int num) const {
_xatom->sendClientMessage(_root, XAtom::net_current_desktop, _root, num);
}
void screen::toggleShaded(const Window win) const {
_xatom->sendClientMessage(_root, XAtom::net_wm_state, win, 2,
XAtom::net_wm_state_shaded);
}

View file

@ -65,7 +65,9 @@ public:
void handleKeypress(const XEvent &e); void handleKeypress(const XEvent &e);
void cycleWorkspace(const bool forward); void cycleWorkspace(const bool forward)const;
void changeWorkspace(const int num)const;
void toggleShaded(const Window win) const;
}; };
#endif // __screen_hh #endif // __screen_hh