From c517f511000c8ec775f7413527b9e276b7995806 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 20 Jul 2002 08:06:54 +0000 Subject: [PATCH] some cleanups and such. --- util/epist/actions.cc | 2 +- util/epist/actions.hh | 6 +++--- util/epist/epist.cc | 1 + util/epist/epist.hh | 2 +- util/epist/screen.cc | 48 +++++++++++++++++++++---------------------- util/epist/window.cc | 13 +++++++++--- util/epist/window.hh | 6 +++++- 7 files changed, 45 insertions(+), 33 deletions(-) diff --git a/util/epist/actions.cc b/util/epist/actions.cc index ac4fc4ab..493d0215 100644 --- a/util/epist/actions.cc +++ b/util/epist/actions.cc @@ -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) { } diff --git a/util/epist/actions.hh b/util/epist/actions.hh index 09ee523f..b211bf9d 100644 --- a/util/epist/actions.hh +++ b/util/epist/actions.hh @@ -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); }; diff --git a/util/epist/epist.cc b/util/epist/epist.cc index 6296fe03..9b046000 100644 --- a/util/epist/epist.cc +++ b/util/epist/epist.cc @@ -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) { diff --git a/util/epist/epist.hh b/util/epist/epist.hh index f960319c..cf5df3f0 100644 --- a/util/epist/epist.hh +++ b/util/epist/epist.hh @@ -67,7 +67,7 @@ public: void removeWindow(XWindow *window); XWindow *findWindow(Window window) const; - list actions(void) { return _actions; } + ActionList actions(void) { return _actions; } }; #endif // __epist_hh diff --git a/util/epist/screen.cc b/util/epist/screen.cc index afe5b8d1..fd65db4c 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -143,28 +143,32 @@ void screen::processEvent(const XEvent &e) { } void screen::handleKeypress(const XEvent &e) { - list::const_iterator it = _epist->actions().begin(); - list::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); -} diff --git a/util/epist/window.cc b/util/epist/window.cc index 4027b47f..1d5a219d 100644 --- a/util/epist/window.cc +++ b/util/epist/window.cc @@ -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); +} diff --git a/util/epist/window.hh b/util/epist/window.hh index 30ae529d..edd126b0 100644 --- a/util/epist/window.hh +++ b/util/epist/window.hh @@ -31,6 +31,7 @@ extern "C" { #include class epist; +class screen; class XWindow; class XAtom; @@ -39,6 +40,7 @@ typedef std::list 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; } }; -- 2.39.2