summaryrefslogtreecommitdiff
path: root/src/action.cpp
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2008-12-22 11:00:18 +0100
committerDennis Kasprzyk <onestone@compiz-fusion.org>2008-12-22 11:00:18 +0100
commit51c755cd98acb9f37bd6868b5bd6256402273f99 (patch)
tree3782e2ff77d4a1153ec67923711213f4a13f272f /src/action.cpp
parent1acfd96b7843e28bc37b4b2e8da21b9ea3106fc7 (diff)
downloadunity-window-decorator-51c755cd98acb9f37bd6868b5bd6256402273f99.tar.gz
unity-window-decorator-51c755cd98acb9f37bd6868b5bd6256402273f99.tar.bz2
Allow to set keycode/buttons/modifiers in CompAction.
Diffstat (limited to 'src/action.cpp')
-rw-r--r--src/action.cpp67
1 files changed, 61 insertions, 6 deletions
diff --git a/src/action.cpp b/src/action.cpp
index 78b67ae..9a06697 100644
--- a/src/action.cpp
+++ b/src/action.cpp
@@ -134,14 +134,20 @@ CompAction::KeyBinding::KeyBinding (const KeyBinding& k) :
{
}
+CompAction::KeyBinding::KeyBinding (int keycode, unsigned int modifiers) :
+ mModifiers (modifiers),
+ mKeycode (keycode)
+{
+}
+
unsigned int
-CompAction::KeyBinding::modifiers ()
+CompAction::KeyBinding::modifiers () const
{
return mModifiers;
}
int
-CompAction::KeyBinding::keycode ()
+CompAction::KeyBinding::keycode () const
{
return mKeycode;
}
@@ -207,7 +213,7 @@ CompAction::KeyBinding::fromString (const CompString &str)
}
CompString
-CompAction::KeyBinding::toString ()
+CompAction::KeyBinding::toString () const
{
CompString binding = "";
@@ -249,14 +255,20 @@ CompAction::ButtonBinding::ButtonBinding (const ButtonBinding& b) :
{
}
+CompAction::ButtonBinding::ButtonBinding (int button, unsigned int modifiers) :
+ mModifiers (modifiers),
+ mButton (button)
+{
+}
+
unsigned int
-CompAction::ButtonBinding::modifiers ()
+CompAction::ButtonBinding::modifiers () const
{
return mModifiers;
}
int
-CompAction::ButtonBinding::button ()
+CompAction::ButtonBinding::button () const
{
return mButton;
}
@@ -294,7 +306,7 @@ CompAction::ButtonBinding::fromString (const CompString &str)
}
CompString
-CompAction::ButtonBinding::toString ()
+CompAction::ButtonBinding::toString () const
{
CompString binding;
@@ -364,12 +376,46 @@ CompAction::key ()
return priv->key;
}
+void
+CompAction::setKey (const CompAction::KeyBinding &key)
+{
+ priv->key = key;
+
+ if (key.modifiers () || key.keycode ())
+ {
+ priv->type = CompAction::BindingTypeKey;
+ }
+ else
+ {
+ priv->type = CompAction::BindingTypeNone;
+ }
+}
+
CompAction::ButtonBinding &
CompAction::button ()
{
return priv->button;
}
+void
+CompAction::setButton (const CompAction::ButtonBinding &button)
+{
+ priv->button = button;
+
+ if (button.modifiers () || button.button ())
+ {
+ if (priv->edgeMask)
+ priv->type = CompAction::BindingTypeEdgeButton;
+ else
+ priv->type = CompAction::BindingTypeButton;
+ }
+ else
+ {
+ priv->type = CompAction::BindingTypeNone;
+ }
+
+}
+
unsigned int
CompAction::edgeMask ()
{
@@ -380,6 +426,15 @@ void
CompAction::setEdgeMask (unsigned int edge)
{
priv->edgeMask = edge;
+
+ if (priv->type == CompAction::BindingTypeEdgeButton ||
+ priv->type == CompAction::BindingTypeButton)
+ {
+ if (priv->edgeMask)
+ priv->type = CompAction::BindingTypeEdgeButton;
+ else
+ priv->type = CompAction::BindingTypeButton;
+ }
}
bool