Commit da48f73f authored by JP Dinger's avatar JP Dinger

Skins2: Factor out getModKey() and getKeyState() (both used twice), use...

Skins2: Factor out getModKey() and getKeyState() (both used twice), use var_SetVariant() instead of var_Set().
parent d79be0ff
......@@ -54,3 +54,13 @@ 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;
}
......@@ -44,6 +44,9 @@ public:
virtual const string getAsString() const;
int getKey() const { return m_key; }
int getModKey() const;
ActionType_t getKeyState() const { return m_action; }
private:
/// The concerned key, stored according to the '#define's in vlc_keys.h
......
......@@ -218,7 +218,7 @@ void TopWindow::processEvent( EvtKey &rEvtKey )
}
// Only do the action when the key is down
if( rEvtKey.getAsString().find( "key:down") != string::npos )
if( rEvtKey.getKeyState() == EvtKey::kDown )
{
//XXX not to be hardcoded!
// Ctrl-S = Change skin
......@@ -240,31 +240,14 @@ void TopWindow::processEvent( EvtKey &rEvtKey )
return;
}
vlc_value_t val;
// Set the key
val.i_int = rEvtKey.getKey();
// Set the modifiers
if( rEvtKey.getMod() & EvtInput::kModAlt )
{
val.i_int |= KEY_MODIFIER_ALT;
}
if( rEvtKey.getMod() & EvtInput::kModCtrl )
{
val.i_int |= KEY_MODIFIER_CTRL;
}
if( rEvtKey.getMod() & EvtInput::kModShift )
{
val.i_int |= KEY_MODIFIER_SHIFT;
}
var_Set( getIntf()->p_libvlc, "key-pressed", val );
var_SetInteger( getIntf()->p_libvlc, "key-pressed",
rEvtKey.getModKey() );
}
// Always store the modifier, which can be needed for scroll events
m_currModifier = rEvtKey.getMod();
}
void TopWindow::processEvent( EvtScroll &rEvtScroll )
{
// Raise the windows
......@@ -289,20 +272,11 @@ void TopWindow::processEvent( EvtScroll &rEvtScroll )
}
else
{
// Treat the scroll event as a hotkey
vlc_value_t val;
if( rEvtScroll.getDirection() == EvtScroll::kUp )
{
val.i_int = KEY_MOUSEWHEELUP;
}
else
{
val.i_int = KEY_MOUSEWHEELDOWN;
}
// Add the modifiers
val.i_int |= m_currModifier;
// Treat the scroll event as a hotkey plus current modifiers
int i = (rEvtScroll.getDirection() == EvtScroll::kUp ?
KEY_MOUSEWHEELUP : KEY_MOUSEWHEELDOWN) | m_currModifier;
var_Set( getIntf()->p_libvlc, "key-pressed", val );
var_SetInteger( getIntf()->p_libvlc, "key-pressed", i );
}
}
......
......@@ -97,26 +97,8 @@ void VoutWindow::setFullscreen( bool b_fullscreen )
void VoutWindow::processEvent( EvtKey &rEvtKey )
{
// Only do the action when the key is down
if( rEvtKey.getAsString().find( "key:down") != string::npos )
{
vlc_value_t val;
// Set the key
val.i_int = rEvtKey.getKey();
// Set the modifiers
if( rEvtKey.getMod() & EvtInput::kModAlt )
{
val.i_int |= KEY_MODIFIER_ALT;
}
if( rEvtKey.getMod() & EvtInput::kModCtrl )
{
val.i_int |= KEY_MODIFIER_CTRL;
}
if( rEvtKey.getMod() & EvtInput::kModShift )
{
val.i_int |= KEY_MODIFIER_SHIFT;
}
var_Set( getIntf()->p_libvlc, "key-pressed", val );
}
if( rEvtKey.getKeyState() == EvtKey::kDown )
var_SetInteger( getIntf()->p_libvlc, "key-pressed",
rEvtKey.getModKey() );
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment