From e61097b8881bc7e72a5499816cb1199ea274a3ca Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Thu, 7 Oct 2010 22:54:10 +0200 Subject: Rework template meta-magic - No more implicit dependency on Boost.MPL - Better documentation for template magic - Move input handler policies to handler definitions where they belong - Separate out event descriptions from handlers --- src/input/unprivilegedInputHandlerChain.cpp | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/input/unprivilegedInputHandlerChain.cpp (limited to 'src/input/unprivilegedInputHandlerChain.cpp') diff --git a/src/input/unprivilegedInputHandlerChain.cpp b/src/input/unprivilegedInputHandlerChain.cpp new file mode 100644 index 0000000..fbbc770 --- /dev/null +++ b/src/input/unprivilegedInputHandlerChain.cpp @@ -0,0 +1,30 @@ +/* + # Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg + # + # This program is free software distributed under the GPL version 2. + # See http://openslx.org/COPYING + # + # If you have any feedback please consult http://openslx.org/feedback and + # send your suggestions, praise, or complaints to feedback@openslx.org + # + # General information about OpenSLX can be found at http://openslx.org/ + # -------------------------------------------------------------------------- + # privilegedInputHandlerChain.cpp + # - Definition of the input handler chains - implementation for + # unprivileged chain + # -------------------------------------------------------------------------- + */ + +#include "x11FakeKeyboardHandler.h" +#include "x11FakeMouseHandler.h" +#include "privilegedHandlerForwarder.h" +#include "inputHandlerChains.h" + +InputEventHandlerChain makeUnprivilegedInputEventHandlerChain() +{ + return InputEventHandlerChain().add() + .add() + .add() + .add(); +} + -- cgit v1.2.3-55-g7522 From c8978b46070959273d8ee8d760b2594c18a237a9 Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Sun, 10 Oct 2010 14:31:49 +0200 Subject: Add an InputEventHandler that is not compatible anywhere. --- src/input/incompatibleHandler.h | 37 +++++++++++++++++++++++++++++ src/input/unprivilegedInputHandlerChain.cpp | 4 +++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/input/incompatibleHandler.h (limited to 'src/input/unprivilegedInputHandlerChain.cpp') diff --git a/src/input/incompatibleHandler.h b/src/input/incompatibleHandler.h new file mode 100644 index 0000000..5a92806 --- /dev/null +++ b/src/input/incompatibleHandler.h @@ -0,0 +1,37 @@ +/* + # Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg + # + # This program is free software distributed under the GPL version 2. + # See http://openslx.org/COPYING + # + # If you have any feedback please consult http://openslx.org/feedback and + # send your suggestions, praise, or complaints to feedback@openslx.org + # + # General information about OpenSLX can be found at http://openslx.org/ + # -------------------------------------------------------------------------- + # incompatibleHandler.h: + # - A handler that is not compatible with any system. + # The presence of this file does no harm whatsoever, + # since there will never be any references generated to the class + # it defines, and allows us to test the claim that + # the Require<...> policy does a better job than the preprocessor. + # -------------------------------------------------------------------------- + */ + +#ifndef INCOMPATIBLEHANDLERTYPE_H_ +#define INCOMPATIBLEHANDLERTYPE_H_ + +#include "inputEventHandler.h" + +namespace incompatible { + struct Incompatible; +} + +class IncompatibleHandler : public InputEventHandler< + input_policy::Require > +{ + void doHandle(InputEvent const&, InputEventContext const*); +}; + + +#endif /* INCOMPATIBLEHANDLERTYPE_H_ */ diff --git a/src/input/unprivilegedInputHandlerChain.cpp b/src/input/unprivilegedInputHandlerChain.cpp index fbbc770..9353321 100644 --- a/src/input/unprivilegedInputHandlerChain.cpp +++ b/src/input/unprivilegedInputHandlerChain.cpp @@ -18,6 +18,7 @@ #include "x11FakeKeyboardHandler.h" #include "x11FakeMouseHandler.h" #include "privilegedHandlerForwarder.h" +#include "incompatibleHandler.h" #include "inputHandlerChains.h" InputEventHandlerChain makeUnprivilegedInputEventHandlerChain() @@ -25,6 +26,7 @@ InputEventHandlerChain makeUnprivilegedInputEventHandlerChain() return InputEventHandlerChain().add() .add() .add() - .add(); + .add() + .add(); // See comments in incompatibleHandler.h } -- cgit v1.2.3-55-g7522 From 30a85f582ea72f7358012b6385afa3d623de8b52 Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Sun, 10 Oct 2010 21:30:04 +0200 Subject: Fix stupidity in handler chain definition --- src/input/unprivilegedInputHandlerChain.cpp | 2 +- src/input/x11FakeMouseHandler.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/input/unprivilegedInputHandlerChain.cpp') diff --git a/src/input/unprivilegedInputHandlerChain.cpp b/src/input/unprivilegedInputHandlerChain.cpp index 9353321..2df2d77 100644 --- a/src/input/unprivilegedInputHandlerChain.cpp +++ b/src/input/unprivilegedInputHandlerChain.cpp @@ -25,7 +25,7 @@ InputEventHandlerChain makeUnprivilegedInputEventHandlerChain() { return InputEventHandlerChain().add() .add() - .add() + .add() .add() .add(); // See comments in incompatibleHandler.h } diff --git a/src/input/x11FakeMouseHandler.h b/src/input/x11FakeMouseHandler.h index 8ff8df4..9d41c31 100644 --- a/src/input/x11FakeMouseHandler.h +++ b/src/input/x11FakeMouseHandler.h @@ -20,7 +20,7 @@ #include "inputEventHandler.h" class X11FakeMouseButtonHandler : public InputEventHandler< - input_policy::Match, + input_policy::Match, input_policy::Require, input_policy::Unprivileged> { -- cgit v1.2.3-55-g7522 From 732b9cfec697e893fcf5b65e1e7c9e5921ea5951 Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Mon, 11 Oct 2010 09:02:38 +0200 Subject: Introduce LogNonMatchingHandler --- src/input/CMakeLists.txt | 1 + src/input/logNonMatchingHandler.cpp | 27 +++++++++++++++++++++++ src/input/logNonMatchingHandler.h | 33 +++++++++++++++++++++++++++++ src/input/unprivilegedInputHandlerChain.cpp | 4 +++- 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/input/logNonMatchingHandler.cpp create mode 100644 src/input/logNonMatchingHandler.h (limited to 'src/input/unprivilegedInputHandlerChain.cpp') diff --git a/src/input/CMakeLists.txt b/src/input/CMakeLists.txt index d950c67..b4dfa4d 100644 --- a/src/input/CMakeLists.txt +++ b/src/input/CMakeLists.txt @@ -4,6 +4,7 @@ set(pvsinput_SRCS inputEvent.cpp unprivilegedInputHandlerChain.cpp inputEventHandler.cpp + logNonMatchingHandler.cpp ) set(feature_DEFS) diff --git a/src/input/logNonMatchingHandler.cpp b/src/input/logNonMatchingHandler.cpp new file mode 100644 index 0000000..dd694fc --- /dev/null +++ b/src/input/logNonMatchingHandler.cpp @@ -0,0 +1,27 @@ +/* +# Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# src/input/nonMatchingHandler.cpp: +# - Log events that were not matched by another handler - implementation +# ----------------------------------------------------------------------------- +*/ + +#include "logNonMatchingHandler.h" +#include + +void LogNonMatchingHandler::doHandle(InputEvent const& event, InputEventContext const* context) +{ + // It's not really nonmatched if it has already been denied + if(!context->hasBeenDenied) + { + qWarning("No matching handler found for event %s", event.toString().toLocal8Bit().constData()); + } +} diff --git a/src/input/logNonMatchingHandler.h b/src/input/logNonMatchingHandler.h new file mode 100644 index 0000000..3403640 --- /dev/null +++ b/src/input/logNonMatchingHandler.h @@ -0,0 +1,33 @@ +/* +# Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# src/input/nonMatchingHandler.h: +# - Log events that were not matched by another handler - interface +# ----------------------------------------------------------------------------- +*/ + +#ifndef LOGNONMATCHINGHANDLER_H_ +#define LOGNONMATCHINGHANDLER_H_ + +#include "inputEventHandler.h" + +class LogNonMatchingHandler : public InputEventHandler +{ +public: + bool isApplicable(InputEvent const&, InputEventContext const*) + { + return true; + } + + void doHandle(InputEvent const&, InputEventContext const*); +}; + +#endif /* LOGNONMATCHINGHANDLER_H_ */ diff --git a/src/input/unprivilegedInputHandlerChain.cpp b/src/input/unprivilegedInputHandlerChain.cpp index 2df2d77..3f47631 100644 --- a/src/input/unprivilegedInputHandlerChain.cpp +++ b/src/input/unprivilegedInputHandlerChain.cpp @@ -20,6 +20,7 @@ #include "privilegedHandlerForwarder.h" #include "incompatibleHandler.h" #include "inputHandlerChains.h" +#include "logNonMatchingHandler.h" InputEventHandlerChain makeUnprivilegedInputEventHandlerChain() { @@ -27,6 +28,7 @@ InputEventHandlerChain makeUnprivilegedInputEventHandlerChain() .add() .add() .add() - .add(); // See comments in incompatibleHandler.h + .add() // See comments in incompatibleHandler.h + .add(); } -- cgit v1.2.3-55-g7522