some cleanups and such.
This commit is contained in:
parent
b4411cb1ef
commit
c517f51100
7 changed files with 45 additions and 33 deletions
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "actions.hh"
|
||||
|
||||
Action::Action(enum ActionType type, KeyCode keycode, int modifierMask,
|
||||
Action::Action(enum ActionType type, KeyCode keycode, unsigned int modifierMask,
|
||||
int num): _type(type), _keycode(keycode),
|
||||
_modifierMask(modifierMask), _numberParam(num)
|
||||
{ }
|
||||
|
|
|
@ -73,16 +73,16 @@ public:
|
|||
private:
|
||||
enum ActionType _type;
|
||||
const KeyCode _keycode;
|
||||
const int _modifierMask;
|
||||
const unsigned int _modifierMask;
|
||||
|
||||
const int _numberParam;
|
||||
public:
|
||||
inline enum ActionType type() const { return _type;}
|
||||
inline const KeyCode keycode() const { return _keycode; }
|
||||
inline const int modifierMask() const { return _modifierMask; }
|
||||
inline const unsigned 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, unsigned int modifierMask,
|
||||
int number = 0);
|
||||
};
|
||||
|
||||
|
|
|
@ -138,6 +138,7 @@ void epist::process_event(XEvent *e) {
|
|||
else
|
||||
root = e->xany.window;
|
||||
|
||||
cout << "event\n";
|
||||
ScreenList::const_iterator it, end = _screens.end();
|
||||
for (it = _screens.begin(); it != end; ++it) {
|
||||
if ((*it)->rootWindow() == root) {
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
void removeWindow(XWindow *window);
|
||||
XWindow *findWindow(Window window) const;
|
||||
|
||||
list<Action> actions(void) { return _actions; }
|
||||
ActionList actions(void) { return _actions; }
|
||||
};
|
||||
|
||||
#endif // __epist_hh
|
||||
|
|
|
@ -143,28 +143,32 @@ void screen::processEvent(const XEvent &e) {
|
|||
}
|
||||
|
||||
void screen::handleKeypress(const XEvent &e) {
|
||||
list<Action>::const_iterator it = _epist->actions().begin();
|
||||
list<Action>::const_iterator end = _epist->actions().end();
|
||||
ActionList::const_iterator it = _epist->actions().begin();
|
||||
ActionList::const_iterator end = _epist->actions().end();
|
||||
cout << "key press\n";
|
||||
for (; it != end; ++it) {
|
||||
if (e.xkey.keycode == it->keycode() &&
|
||||
e.xkey.state == it->modifierMask() )
|
||||
{
|
||||
switch (it->type()) {
|
||||
case Action::nextWorkspace:
|
||||
cycleWorkspace(true);
|
||||
break;
|
||||
case Action::prevWorkspace:
|
||||
cycleWorkspace(false);
|
||||
break;
|
||||
case Action::changeWorkspace:
|
||||
changeWorkspace(it->number());
|
||||
break;
|
||||
case Action::shade:
|
||||
toggleShaded((*_active)->window());
|
||||
break;
|
||||
}
|
||||
e.xkey.state == it->modifierMask()) {
|
||||
switch (it->type()) {
|
||||
case Action::nextWorkspace:
|
||||
cycleWorkspace(true);
|
||||
break;
|
||||
|
||||
case Action::prevWorkspace:
|
||||
cycleWorkspace(false);
|
||||
break;
|
||||
|
||||
case Action::changeWorkspace:
|
||||
changeWorkspace(it->number());
|
||||
break;
|
||||
|
||||
case Action::shade:
|
||||
(*_active)->shade(! (*_active)->shaded());
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,7 +220,8 @@ void screen::updateClientList() {
|
|||
if (it == end) { // didn't already exist
|
||||
if (doAddWindow(rootclients[i])) {
|
||||
cout << "Added window: 0x" << hex << rootclients[i] << dec << endl;
|
||||
_clients.insert(insert_point, new XWindow(_epist, rootclients[i]));
|
||||
_clients.insert(insert_point, new XWindow(_epist, this,
|
||||
rootclients[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -291,8 +296,3 @@ void screen::cycleWorkspace(const bool forward) const {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -31,12 +31,13 @@ using std::endl;
|
|||
using std::hex;
|
||||
using std::dec;
|
||||
|
||||
#include "window.hh"
|
||||
#include "epist.hh"
|
||||
#include "screen.hh"
|
||||
#include "window.hh"
|
||||
#include "../../src/XAtom.hh"
|
||||
|
||||
XWindow::XWindow(epist *epist, Window window)
|
||||
: _epist(epist), _xatom(epist->xatom()), _window(window) {
|
||||
XWindow::XWindow(epist *epist, screen *screen, Window window)
|
||||
: _epist(epist), _screen(screen), _xatom(epist->xatom()), _window(window) {
|
||||
|
||||
_unmapped = false;
|
||||
|
||||
|
@ -140,3 +141,9 @@ void XWindow::processEvent(const XEvent &e) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void XWindow::shade(const bool sh) const {
|
||||
_xatom->sendClientMessage(_screen->rootWindow(), XAtom::net_wm_state,
|
||||
_window, (sh ? 1 : 0), XAtom::net_wm_state_shaded);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ extern "C" {
|
|||
#include <string>
|
||||
|
||||
class epist;
|
||||
class screen;
|
||||
class XWindow;
|
||||
class XAtom;
|
||||
|
||||
|
@ -39,6 +40,7 @@ typedef std::list<XWindow *> WindowList;
|
|||
class XWindow {
|
||||
private:
|
||||
epist *_epist;
|
||||
screen *_screen;
|
||||
XAtom *_xatom;
|
||||
Window _window;
|
||||
|
||||
|
@ -61,7 +63,7 @@ private:
|
|||
void updateClass();
|
||||
|
||||
public:
|
||||
XWindow(epist *epist, Window window);
|
||||
XWindow(epist *epist, screen *screen, Window window);
|
||||
virtual ~XWindow();
|
||||
|
||||
inline Window window() const { return _window; }
|
||||
|
@ -78,6 +80,8 @@ public:
|
|||
|
||||
void processEvent(const XEvent &e);
|
||||
|
||||
void shade(const bool sh) const;
|
||||
|
||||
bool operator == (const XWindow &w) const { return w._window == _window; }
|
||||
bool operator == (const Window &w) const { return w == _window; }
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue