aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-11-27 21:47:46 (GMT)
committerfluxgen <fluxgen>2002-11-27 21:47:46 (GMT)
commitd39c023411aca300017a2710d484a2b16e5dd064 (patch)
tree5d48241f772b5289658c55712b86d7bfe7bf95f5 /src/FbTk
parent97d610761e8c682d86b182cd101971c5eda53f49 (diff)
downloadfluxbox-d39c023411aca300017a2710d484a2b16e5dd064.zip
fluxbox-d39c023411aca300017a2710d484a2b16e5dd064.tar.bz2
using SignalEventHandler class instead of the old EventHandler template
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/SignalHandler.cc12
-rw-r--r--src/FbTk/SignalHandler.hh17
2 files changed, 13 insertions, 16 deletions
diff --git a/src/FbTk/SignalHandler.cc b/src/FbTk/SignalHandler.cc
index d78c42c..ddb3766 100644
--- a/src/FbTk/SignalHandler.cc
+++ b/src/FbTk/SignalHandler.cc
@@ -19,13 +19,13 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: SignalHandler.cc,v 1.1 2002/11/26 16:01:27 fluxgen Exp $ 22// $Id: SignalHandler.cc,v 1.2 2002/11/27 21:47:46 fluxgen Exp $
23 23
24#include "SignalHandler.hh" 24#include "SignalHandler.hh"
25 25
26namespace FbTk { 26namespace FbTk {
27 27
28EventHandler<SignalEvent> *SignalHandler::s_signal_handler[NSIG]; 28SignalEventHandler *SignalHandler::s_signal_handler[NSIG];
29 29
30SignalHandler::SignalHandler() { 30SignalHandler::SignalHandler() {
31 // clear signal list 31 // clear signal list
@@ -38,8 +38,8 @@ SignalHandler *SignalHandler::instance() {
38 return &singleton; 38 return &singleton;
39} 39}
40 40
41bool SignalHandler::registerHandler(int signum, EventHandler<SignalEvent> *eh, 41bool SignalHandler::registerHandler(int signum, SignalEventHandler *eh,
42 EventHandler<SignalEvent> **oldhandler_ret) { 42 SignalEventHandler **oldhandler_ret) {
43 // must be less than NSIG 43 // must be less than NSIG
44 if (signum >= NSIG) 44 if (signum >= NSIG)
45 return false; 45 return false;
@@ -72,9 +72,7 @@ void SignalHandler::handleSignal(int signum) {
72 return; 72 return;
73 // make sure we got a handler for this signal 73 // make sure we got a handler for this signal
74 if (s_signal_handler[signum] != 0) { 74 if (s_signal_handler[signum] != 0) {
75 SignalEvent sigev; 75 s_signal_handler[signum]->handleSignal(signum);
76 sigev.signum = signum;
77 s_signal_handler[signum]->handleEvent(&sigev);
78 } 76 }
79} 77}
80 78
diff --git a/src/FbTk/SignalHandler.hh b/src/FbTk/SignalHandler.hh
index e05fb3a..aa3a275 100644
--- a/src/FbTk/SignalHandler.hh
+++ b/src/FbTk/SignalHandler.hh
@@ -1,4 +1,4 @@
1// SignalHandler.hh for Fluxbox Window Manager 1// SignalHandler.hh for FbTk
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org) 2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3// 3//
4// Permission is hereby granted, free of charge, to any person obtaining a 4// Permission is hereby granted, free of charge, to any person obtaining a
@@ -19,19 +19,19 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: SignalHandler.hh,v 1.1 2002/11/26 16:01:27 fluxgen Exp $ 22// $Id: SignalHandler.hh,v 1.2 2002/11/27 21:47:33 fluxgen Exp $
23 23
24#ifndef FBTK_SIGNALHANDLER_HH 24#ifndef FBTK_SIGNALHANDLER_HH
25#define FBTK_SIGNALHANDLER_HH 25#define FBTK_SIGNALHANDLER_HH
26 26
27#include "EventHandler.hh"
28
29#include <signal.h> 27#include <signal.h>
30 28
31namespace FbTk { 29namespace FbTk {
32 30
33struct SignalEvent { 31
34 int signum; 32class SignalEventHandler {
33public:
34 virtual void handleSignal(int signum) = 0;
35}; 35};
36 36
37/** 37/**
@@ -42,7 +42,6 @@ struct SignalEvent {
42*/ 42*/
43class SignalHandler { 43class SignalHandler {
44public: 44public:
45
46 /// get singleton object 45 /// get singleton object
47 static SignalHandler *instance(); 46 static SignalHandler *instance();
48 /** 47 /**
@@ -52,7 +51,7 @@ public:
52 @param eh event handler 51 @param eh event handler
53 @param oldhandler_ret return handler to old sighandler 52 @param oldhandler_ret return handler to old sighandler
54 */ 53 */
55 bool registerHandler(int signum, EventHandler<SignalEvent> *eh, EventHandler<SignalEvent> **oldhandler_ret = 0); 54 bool registerHandler(int signum, SignalEventHandler *eh, SignalEventHandler **oldhandler_ret = 0);
56 /** 55 /**
57 removes the signum handler 56 removes the signum handler
58 @param signum signal number 57 @param signum signal number
@@ -63,7 +62,7 @@ private:
63 62
64 static void handleSignal(int signum); 63 static void handleSignal(int signum);
65 64
66 static EventHandler<SignalEvent> *s_signal_handler[NSIG]; ///< NSIG defined in signal.h 65 static SignalEventHandler *s_signal_handler[NSIG]; ///< NSIG defined in signal.h
67}; 66};
68 67
69}; // end namespace FbTk 68}; // end namespace FbTk