[vlc-devel] commit: Skins2: Use vlc KEY_MODIFIER_* constants for key modifier masks, simplifying the code. Revert from enum to static const int to not have to include vlc_keys. h through the header file. (JP Dinger )

git version control git at videolan.org
Sat Dec 5 22:35:07 CET 2009


vlc | branch: master | JP Dinger <jpd at videolan.org> | Mon Nov 16 13:51:30 2009 +0100| [3569ffff1f6536644363537737f55b490f63939c] | committer: JP Dinger 

Skins2: Use vlc KEY_MODIFIER_* constants for key modifier masks, simplifying the code. Revert from enum to static const int to not have to include vlc_keys.h through the header file.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3569ffff1f6536644363537737f55b490f63939c
---

 modules/gui/skins2/events/evt_input.cpp |   12 ++++++++++++
 modules/gui/skins2/events/evt_input.hpp |    8 ++++----
 modules/gui/skins2/events/evt_key.cpp   |   11 -----------
 modules/gui/skins2/events/evt_key.hpp   |    2 +-
 modules/gui/skins2/src/top_window.cpp   |    2 +-
 5 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/modules/gui/skins2/events/evt_input.cpp b/modules/gui/skins2/events/evt_input.cpp
index d56d45e..8b94776 100644
--- a/modules/gui/skins2/events/evt_input.cpp
+++ b/modules/gui/skins2/events/evt_input.cpp
@@ -23,7 +23,15 @@
  *****************************************************************************/
 
 #include "evt_input.hpp"
+#include "vlc_keys.h"
 
+const int
+    EvtInput::kModNone=0,
+    EvtInput::kModAlt=KEY_MODIFIER_ALT,
+    EvtInput::kModShift=KEY_MODIFIER_SHIFT,
+    EvtInput::kModCtrl=KEY_MODIFIER_CTRL,
+    EvtInput::kModMeta=KEY_MODIFIER_META,
+    EvtInput::kModCmd=KEY_MODIFIER_COMMAND;
 
 EvtInput::EvtInput( intf_thread_t *pIntf, int mod )
     : EvtGeneric( pIntf), m_mod( mod ) { }
@@ -44,6 +52,10 @@ void EvtInput::addModifier( string &rEvtString ) const
             m += "ctrl,";
         if( m_mod & kModShift )
             m += "shift,";
+        if( m_mod & kModMeta )
+            m += "meta,";
+        if( m_mod & kModCmd )
+            m += "cmd,";
         // Append the result except the last ','
         rEvtString.insert( rEvtString.end(), m.begin(), m.end()-1 );
     }
diff --git a/modules/gui/skins2/events/evt_input.hpp b/modules/gui/skins2/events/evt_input.hpp
index a001c0e..2ae83d6 100644
--- a/modules/gui/skins2/events/evt_input.hpp
+++ b/modules/gui/skins2/events/evt_input.hpp
@@ -27,7 +27,6 @@
 
 #include "evt_generic.hpp"
 
-
 /// Base class for mouse and key events
 class EvtInput: public EvtGeneric
 {
@@ -35,16 +34,17 @@ public:
     virtual ~EvtInput() { }
 
     /// Masks for modifier keys
-    enum { kModNone=0, kModAlt=1, kModCtrl=2, kModShift=4 };
+    static const int
+        kModNone, kModAlt, kModShift, kModCtrl, kModMeta, kModCmd;
 
     /// Get the modifiers
-    virtual int getMod() const { return m_mod; }
+    int getMod() const { return m_mod; }
 
 protected:
     EvtInput( intf_thread_t *pIntf, int mod = kModNone );
 
     /// Add the modifier to the event string
-    virtual void addModifier( string &rEvtString ) const;
+    void addModifier( string &rEvtString ) const;
 
 private:
     /// Modifiers (special key(s) pressed during the mouse event)
diff --git a/modules/gui/skins2/events/evt_key.cpp b/modules/gui/skins2/events/evt_key.cpp
index 7bb3a32..9cf3467 100644
--- a/modules/gui/skins2/events/evt_key.cpp
+++ b/modules/gui/skins2/events/evt_key.cpp
@@ -53,14 +53,3 @@ const string EvtKey::getAsString() const
 
     return event;
 }
-
-int EvtKey::getModKey() const {
-    int i = getKey();
-    if( getMod() & kModAlt )
-        i |= KEY_MODIFIER_ALT;
-    if( getMod() & kModCtrl )
-        i |= KEY_MODIFIER_CTRL;
-    if( getMod() & kModShift )
-        i |= KEY_MODIFIER_SHIFT;
-}
-
diff --git a/modules/gui/skins2/events/evt_key.hpp b/modules/gui/skins2/events/evt_key.hpp
index 28d04cb..29c6457 100644
--- a/modules/gui/skins2/events/evt_key.hpp
+++ b/modules/gui/skins2/events/evt_key.hpp
@@ -44,7 +44,7 @@ public:
     virtual const string getAsString() const;
 
     int getKey() const { return m_key; }
-    int getModKey() const;
+    int getModKey() const { return m_key | getMod(); }
 
     ActionType_t getKeyState() const { return m_action; }
 
diff --git a/modules/gui/skins2/src/top_window.cpp b/modules/gui/skins2/src/top_window.cpp
index 279a28f..e184c28 100644
--- a/modules/gui/skins2/src/top_window.cpp
+++ b/modules/gui/skins2/src/top_window.cpp
@@ -244,7 +244,7 @@ void TopWindow::processEvent( EvtKey &rEvtKey )
                         rEvtKey.getModKey() );
     }
 
-    // Always store the modifier, which can be needed for scroll events
+    // Always store the modifier, which can be needed for scroll events.
     m_currModifier = rEvtKey.getMod();
 }
 




More information about the vlc-devel mailing list