some cleanups and such.

This commit is contained in:
Dana Jansens 2002-07-20 08:06:54 +00:00
parent b4411cb1ef
commit c517f51100
7 changed files with 45 additions and 33 deletions

View file

@ -22,7 +22,7 @@
#include "actions.hh" #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), int num): _type(type), _keycode(keycode),
_modifierMask(modifierMask), _numberParam(num) _modifierMask(modifierMask), _numberParam(num)
{ } { }

View file

@ -73,16 +73,16 @@ public:
private: private:
enum ActionType _type; enum ActionType _type;
const KeyCode _keycode; const KeyCode _keycode;
const int _modifierMask; const unsigned int _modifierMask;
const int _numberParam; 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 unsigned int modifierMask() const { return _modifierMask; }
inline const int number() const { return _numberParam; } 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); int number = 0);
}; };

View file

@ -138,6 +138,7 @@ void epist::process_event(XEvent *e) {
else else
root = e->xany.window; root = e->xany.window;
cout << "event\n";
ScreenList::const_iterator it, end = _screens.end(); ScreenList::const_iterator it, end = _screens.end();
for (it = _screens.begin(); it != end; ++it) { for (it = _screens.begin(); it != end; ++it) {
if ((*it)->rootWindow() == root) { if ((*it)->rootWindow() == root) {

View file

@ -67,7 +67,7 @@ public:
void removeWindow(XWindow *window); void removeWindow(XWindow *window);
XWindow *findWindow(Window window) const; XWindow *findWindow(Window window) const;
list<Action> actions(void) { return _actions; } ActionList actions(void) { return _actions; }
}; };
#endif // __epist_hh #endif // __epist_hh

View file

@ -143,26 +143,30 @@ void screen::processEvent(const XEvent &e) {
} }
void screen::handleKeypress(const XEvent &e) { void screen::handleKeypress(const XEvent &e) {
list<Action>::const_iterator it = _epist->actions().begin(); ActionList::const_iterator it = _epist->actions().begin();
list<Action>::const_iterator end = _epist->actions().end(); ActionList::const_iterator end = _epist->actions().end();
cout << "key press\n";
for (; it != end; ++it) { for (; it != end; ++it) {
if (e.xkey.keycode == it->keycode() && if (e.xkey.keycode == it->keycode() &&
e.xkey.state == it->modifierMask() ) e.xkey.state == it->modifierMask()) {
{
switch (it->type()) { switch (it->type()) {
case Action::nextWorkspace: case Action::nextWorkspace:
cycleWorkspace(true); cycleWorkspace(true);
break; break;
case Action::prevWorkspace: case Action::prevWorkspace:
cycleWorkspace(false); cycleWorkspace(false);
break; break;
case Action::changeWorkspace: case Action::changeWorkspace:
changeWorkspace(it->number()); changeWorkspace(it->number());
break; break;
case Action::shade: case Action::shade:
toggleShaded((*_active)->window()); (*_active)->shade(! (*_active)->shaded());
break; break;
} }
break; break;
} }
} }
@ -216,7 +220,8 @@ void screen::updateClientList() {
if (it == end) { // didn't already exist if (it == end) { // didn't already exist
if (doAddWindow(rootclients[i])) { if (doAddWindow(rootclients[i])) {
cout << "Added window: 0x" << hex << rootclients[i] << dec << endl; 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 { 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);
} }
void screen::toggleShaded(const Window win) const {
_xatom->sendClientMessage(_root, XAtom::net_wm_state, win, 2,
XAtom::net_wm_state_shaded);
}

View file

@ -31,12 +31,13 @@ using std::endl;
using std::hex; using std::hex;
using std::dec; using std::dec;
#include "window.hh"
#include "epist.hh" #include "epist.hh"
#include "screen.hh"
#include "window.hh"
#include "../../src/XAtom.hh" #include "../../src/XAtom.hh"
XWindow::XWindow(epist *epist, Window window) XWindow::XWindow(epist *epist, screen *screen, Window window)
: _epist(epist), _xatom(epist->xatom()), _window(window) { : _epist(epist), _screen(screen), _xatom(epist->xatom()), _window(window) {
_unmapped = false; _unmapped = false;
@ -140,3 +141,9 @@ void XWindow::processEvent(const XEvent &e) {
break; 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);
}

View file

@ -31,6 +31,7 @@ extern "C" {
#include <string> #include <string>
class epist; class epist;
class screen;
class XWindow; class XWindow;
class XAtom; class XAtom;
@ -39,6 +40,7 @@ typedef std::list<XWindow *> WindowList;
class XWindow { class XWindow {
private: private:
epist *_epist; epist *_epist;
screen *_screen;
XAtom *_xatom; XAtom *_xatom;
Window _window; Window _window;
@ -61,7 +63,7 @@ private:
void updateClass(); void updateClass();
public: public:
XWindow(epist *epist, Window window); XWindow(epist *epist, screen *screen, Window window);
virtual ~XWindow(); virtual ~XWindow();
inline Window window() const { return _window; } inline Window window() const { return _window; }
@ -78,6 +80,8 @@ public:
void processEvent(const XEvent &e); void processEvent(const XEvent &e);
void shade(const bool sh) 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; }
}; };