00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _COMPACTION_H
00029 #define _COMPACTION_H
00030
00031 #include <boost/function.hpp>
00032
00033 #include <X11/Xlib-xcb.h>
00034
00035 #include <core/option.h>
00036
00037 class PrivateAction;
00038
00039 #define CompModAlt 0
00040 #define CompModMeta 1
00041 #define CompModSuper 2
00042 #define CompModHyper 3
00043 #define CompModModeSwitch 4
00044 #define CompModNumLock 5
00045 #define CompModScrollLock 6
00046 #define CompModNum 7
00047
00048 #define CompAltMask (1 << 16)
00049 #define CompMetaMask (1 << 17)
00050 #define CompSuperMask (1 << 18)
00051 #define CompHyperMask (1 << 19)
00052 #define CompModeSwitchMask (1 << 20)
00053 #define CompNumLockMask (1 << 21)
00054 #define CompScrollLockMask (1 << 22)
00055
00056 #define CompNoMask (1 << 25)
00057
00061 class CompAction {
00062 public:
00063 typedef enum {
00064 StateInitKey = 1 << 0,
00065 StateTermKey = 1 << 1,
00066 StateInitButton = 1 << 2,
00067 StateTermButton = 1 << 3,
00068 StateInitBell = 1 << 4,
00069 StateInitEdge = 1 << 5,
00070 StateTermEdge = 1 << 6,
00071 StateInitEdgeDnd = 1 << 7,
00072 StateTermEdgeDnd = 1 << 8,
00073 StateCommit = 1 << 9,
00074 StateCancel = 1 << 10,
00075 StateAutoGrab = 1 << 11,
00076 StateNoEdgeDelay = 1 << 12
00077 } StateEnum;
00078
00082 typedef enum {
00083 BindingTypeNone = 0,
00084 BindingTypeKey = 1 << 0,
00085 BindingTypeButton = 1 << 1,
00086 BindingTypeEdgeButton = 1 << 2
00087 } BindingTypeEnum;
00088
00089 class KeyBinding {
00090 public:
00091 KeyBinding ();
00092 KeyBinding (const KeyBinding&);
00093 KeyBinding (int keycode, unsigned int modifiers = 0);
00094
00095 unsigned int modifiers () const;
00096 int keycode () const;
00097
00098 bool fromString (const CompString &str);
00099 CompString toString () const;
00100
00101 private:
00102 unsigned int mModifiers;
00103 int mKeycode;
00104 };
00105
00106 class ButtonBinding {
00107 public:
00108 ButtonBinding ();
00109 ButtonBinding (const ButtonBinding&);
00110 ButtonBinding (int button, unsigned int modifiers = 0);
00111
00112 unsigned int modifiers () const;
00113 int button () const;
00114
00115 bool fromString (const CompString &str);
00116 CompString toString () const;
00117
00118 private:
00119 unsigned int mModifiers;
00120 int mButton;
00121 };
00122
00123 typedef unsigned int State;
00124 typedef unsigned int BindingType;
00125 typedef boost::function <bool (CompAction *, State, CompOption::Vector &)> CallBack;
00126
00127 public:
00128 CompAction ();
00129 CompAction (const CompAction &);
00130 ~CompAction ();
00131
00132 CallBack initiate ();
00133 CallBack terminate ();
00134
00135 void setInitiate (const CallBack &initiate);
00136 void setTerminate (const CallBack &terminate);
00137
00138 State state ();
00139 BindingType type ();
00140
00141 KeyBinding & key ();
00142 void setKey (const KeyBinding &key);
00143
00144 ButtonBinding & button ();
00145 void setButton (const ButtonBinding &button);
00146
00147 unsigned int edgeMask ();
00148 void setEdgeMask (unsigned int edge);
00149
00150 bool bell ();
00151 void setBell (bool bell);
00152
00153 void setState (State state);
00154
00155 void copyState (const CompAction &action);
00156
00157 bool operator== (const CompAction& val);
00158 CompAction & operator= (const CompAction &action);
00159
00160 bool keyFromString (const CompString &str);
00161 bool buttonFromString (const CompString &str);
00162 bool edgeMaskFromString (const CompString &str);
00163
00164 CompString keyToString ();
00165 CompString buttonToString ();
00166 CompString edgeMaskToString ();
00167
00168 static CompString edgeToString (unsigned int edge);
00169
00170 private:
00171 PrivateAction *priv;
00172 };
00173
00174 #endif