all repos — fluxbox @ 43c4469119b5b5357d01e59a23cf541fb233bd28

custom fork of the fluxbox windowmanager

using FbTk's new EventHandler interface
fluxgen fluxgen
commit

43c4469119b5b5357d01e59a23cf541fb233bd28

parent

97a2ea9d2321cad25a00f2509b4474243696c621

2 files changed, 48 insertions(+), 41 deletions(-)

jump to
M util/fbrun/FbRun.ccutil/fbrun/FbRun.cc

@@ -19,11 +19,12 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbRun.cc,v 1.7 2002/11/26 17:13:36 fluxgen Exp $ +// $Id: FbRun.cc,v 1.8 2002/11/27 21:56:56 fluxgen Exp $ #include "FbRun.hh" #include "App.hh" +#include "EventManager.hh" #include <X11/Xlib.h> #include <X11/keysym.h>

@@ -48,6 +49,7 @@ }

FbRun::~FbRun() { hide(); + FbTk::EventManager::instance()->unregisterEventHandler(m_win); XDestroyWindow(m_display, m_win); }

@@ -70,7 +72,7 @@ outfile<<m_runtext<<endl;

else cerr<<"FbRun Warning: Can't write command history to file: "<<m_history_file<<endl; } - + FbTk::App::instance()->end(); // end application m_end = true; // mark end of processing }

@@ -192,7 +194,9 @@ if (m_win == None)

throw string("Failed to create FbRun window!"); XSelectInput(m_display, m_win, KeyPressMask|ExposureMask); - + + FbTk::EventManager::instance()->registerEventHandler(*this, m_win); + setNoMaximize(); m_width = width;

@@ -200,46 +204,41 @@ m_height = height;

} -void FbRun::handleEvent(XEvent * const xev) { - switch (xev->type) { - case KeyPress: { - KeySym ks; - char keychar[1]; - XLookupString(&xev->xkey, keychar, 1, &ks, 0); - if (ks == XK_Escape) { - m_end = true; - hide(); - return; // no more processing - } else if (ks == XK_Return) { - run(m_runtext); - m_runtext = ""; // clear text - } else if (ks == XK_BackSpace) { - if (m_runtext.size() != 0) { // we can't erase what we don't have ;) - m_runtext.erase(m_runtext.size()-1); - redrawLabel(); - } - } else if (! IsModifierKey(ks) && !IsCursorKey(ks)) { - m_runtext+=keychar[0]; // append character - redrawLabel(); - } else if (IsCursorKey(ks)) { - - switch (ks) { - case XK_Up: - prevHistoryItem(); - break; - case XK_Down: - nextHistoryItem(); - break; - } - redrawLabel(); - } - } break; - case Expose: +void FbRun::keyPressEvent(XKeyEvent &ke) { + KeySym ks; + char keychar[1]; + XLookupString(&ke, keychar, 1, &ks, 0); + if (ks == XK_Escape) { + m_end = true; + hide(); + return; // no more processing + } else if (ks == XK_Return) { + run(m_runtext); + m_runtext = ""; // clear text + } else if (ks == XK_BackSpace) { + if (m_runtext.size() != 0) { // we can't erase what we don't have ;) + m_runtext.erase(m_runtext.size()-1); redrawLabel(); + } + } else if (! IsModifierKey(ks) && !IsCursorKey(ks)) { + m_runtext+=keychar[0]; // append character + redrawLabel(); + } else if (IsCursorKey(ks)) { + + switch (ks) { + case XK_Up: + prevHistoryItem(); break; - default: + case XK_Down: + nextHistoryItem(); break; + } + redrawLabel(); } +} + +void FbRun::exposeEvent(XExposeEvent &ev) { + redrawLabel(); } void FbRun::getSize(size_t &width, size_t &height) {
M util/fbrun/FbRun.hhutil/fbrun/FbRun.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbRun.hh,v 1.6 2002/11/15 14:03:14 fluxgen Exp $ +// $Id: FbRun.hh,v 1.7 2002/11/27 21:56:02 fluxgen Exp $ #ifndef FBRUN_HH #define FBRUN_HH

@@ -33,7 +33,7 @@

/** Creates and managed a run window */ -class FbRun: public FbTk::EventHandler<XEvent> { +class FbRun: public FbTk::EventHandler { public: FbRun(int x = 0, int y = 0, size_t width = 200); ~FbRun();

@@ -63,6 +63,14 @@ loads history file.

@return true on success, else false */ bool loadHistory(const char *filename); + /** + @name events + */ + ///@{ + void exposeEvent(XExposeEvent &ev); + void keyPressEvent(XKeyEvent &ev); + ///@} + private: void nextHistoryItem(); void prevHistoryItem();