[aseprite] 08/196: Add Windows Key as possible Modifier in Keyboard Shortcuts on Windows and Linux as a step to fix #796
Tobias Hansen
thansen at moszumanska.debian.org
Wed Apr 20 18:49:55 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit e22332144a6a8c4721c61e97dc7c11acfd8c5a40
Author: Gabriel Rauter <rauter.gabriel at gmail.com>
Date: Tue Mar 1 20:14:32 2016 +0100
Add Windows Key as possible Modifier in Keyboard Shortcuts on Windows and Linux as a step to fix #796
---
data/widgets/select_accelerator.xml | 1 +
src/app/ui/select_accelerator.cpp | 3 +++
src/she/alleg4/key_poller.cpp | 4 +++-
src/she/keys.h | 3 ++-
src/she/win/vk.cpp | 3 +++
src/ui/accelerator.cpp | 6 ++++++
src/ui/keys.h | 1 +
src/ui/message.cpp | 3 ++-
src/ui/message.h | 2 ++
9 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/data/widgets/select_accelerator.xml b/data/widgets/select_accelerator.xml
index 16e78fe..4ebe709 100644
--- a/data/widgets/select_accelerator.xml
+++ b/data/widgets/select_accelerator.xml
@@ -15,6 +15,7 @@
<check text="Alt" id="alt" />
<check text="Shift" id="shift" />
<check text="Space" id="space" />
+ <check text="Windows" id="windows" />
</hbox>
<label text="Assigned to:" />
diff --git a/src/app/ui/select_accelerator.cpp b/src/app/ui/select_accelerator.cpp
index bd3e8c8..ff6be37 100644
--- a/src/app/ui/select_accelerator.cpp
+++ b/src/app/ui/select_accelerator.cpp
@@ -95,6 +95,7 @@ SelectAccelerator::SelectAccelerator(const ui::Accelerator& accel, KeyContext ke
ctrl()->Click.connect(base::Bind<void>(&SelectAccelerator::onModifierChange, this, kKeyCtrlModifier, ctrl()));
shift()->Click.connect(base::Bind<void>(&SelectAccelerator::onModifierChange, this, kKeyShiftModifier, shift()));
space()->Click.connect(base::Bind<void>(&SelectAccelerator::onModifierChange, this, kKeySpaceModifier, space()));
+ windows()->Click.connect(base::Bind<void>(&SelectAccelerator::onModifierChange, this, kKeyWinModifier, windows()));
m_keyField->AccelChange.connect(&SelectAccelerator::onAccelChange, this);
clearButton()->Click.connect(base::Bind<void>(&SelectAccelerator::onClear, this));
@@ -156,8 +157,10 @@ void SelectAccelerator::updateModifiers()
shift()->setSelected(m_accel.modifiers() & kKeyShiftModifier ? true: false);
space()->setSelected(m_accel.modifiers() & kKeySpaceModifier ? true: false);
#if __APPLE__
+ windows()->setVisible(false);
cmd()->setSelected(m_accel.modifiers() & kKeyCmdModifier ? true: false);
#else
+ windows()->setSelected(m_accel.modifiers() & kKeyWinModifier ? true: false);
cmd()->setVisible(false);
#endif
}
diff --git a/src/she/alleg4/key_poller.cpp b/src/she/alleg4/key_poller.cpp
index 9594593..2a98b94 100644
--- a/src/she/alleg4/key_poller.cpp
+++ b/src/she/alleg4/key_poller.cpp
@@ -46,7 +46,9 @@ void she_keyboard_lowlevel_callback(int scancode)
scancode == KEY_LSHIFT ||
scancode == KEY_LCONTROL ||
scancode == KEY_ALT ||
- scancode == KEY_COMMAND) {
+ scancode == KEY_COMMAND ||
+ scancode == KEY_LWIN ||
+ scancode == KEY_RWIN ) {
she_keyboard_ucallback(-1, &scancode);
}
return;
diff --git a/src/she/keys.h b/src/she/keys.h
index 6724d4d..5f72483 100644
--- a/src/she/keys.h
+++ b/src/she/keys.h
@@ -17,7 +17,8 @@ namespace she {
kKeyAltModifier = 4,
kKeyCmdModifier = 8,
kKeySpaceModifier = 16,
- kKeyUninitializedModifier = 32,
+ kKeyWinModifier = 32,
+ kKeyUninitializedModifier = 64,
};
enum KeyScancode {
diff --git a/src/she/win/vk.cpp b/src/she/win/vk.cpp
index f7f96af..e4ff2f3 100644
--- a/src/she/win/vk.cpp
+++ b/src/she/win/vk.cpp
@@ -309,6 +309,9 @@ KeyModifiers get_modifiers_from_last_win32_message()
modifiers |= kKeyAltModifier;
if (GetKeyState(VK_SPACE) & 0x8000)
modifiers |= kKeySpaceModifier;
+ if (GetKeyState(kKeyLWin) & 0x8000) ||
+ (GetKeyState(kKeyRWin) & 0x8000))
+ modifiers |= kKeyWinModifier;
return (KeyModifiers)modifiers;
}
diff --git a/src/ui/accelerator.cpp b/src/ui/accelerator.cpp
index a0eda01..a27da07 100644
--- a/src/ui/accelerator.cpp
+++ b/src/ui/accelerator.cpp
@@ -36,6 +36,8 @@ static KeyModifiers get_pressed_modifiers_from_she()
if (she::is_key_pressed(kKeyRControl)) mods = KeyModifiers(int(mods) | int(kKeyCtrlModifier));
if (she::is_key_pressed(kKeyAlt) ) mods = KeyModifiers(int(mods) | int(kKeyAltModifier));
if (she::is_key_pressed(kKeyCommand) ) mods = KeyModifiers(int(mods) | int(kKeyCmdModifier));
+ if (she::is_key_pressed(kKeyLWin) ) mods = KeyModifiers(int(mods) | int(kKeyWinModifier));
+ if (she::is_key_pressed(kKeyRWin) ) mods = KeyModifiers(int(mods) | int(kKeyWinModifier));
return mods;
}
@@ -89,6 +91,9 @@ Accelerator::Accelerator(const std::string& str)
else if (tok == "cmd") {
m_modifiers = (KeyModifiers)((int)m_modifiers | (int)kKeyCmdModifier);
}
+ else if (tok == "windows") {
+ m_modifiers = (KeyModifiers)((int)m_modifiers | (int)kKeyWinModifier);
+ }
// Scancode
@@ -347,6 +352,7 @@ std::string Accelerator::toString() const
if (m_modifiers & kKeyAltModifier) buf += "Alt+";
if (m_modifiers & kKeyShiftModifier) buf += "Shift+";
if (m_modifiers & kKeySpaceModifier) buf += "Space+";
+ if (m_modifiers & kKeyWinModifier) buf += "Windows+";
// Key
if (m_unicodeChar) {
diff --git a/src/ui/keys.h b/src/ui/keys.h
index 1f4f2b2..25a9954 100644
--- a/src/ui/keys.h
+++ b/src/ui/keys.h
@@ -21,6 +21,7 @@ namespace ui {
using she::kKeyAltModifier;
using she::kKeyCmdModifier;
using she::kKeySpaceModifier;
+ using she::kKeyWinModifier;
using she::kKeyUninitializedModifier;
using she::kKeyNil;
diff --git a/src/ui/message.cpp b/src/ui/message.cpp
index 46e8e27..7559692 100644
--- a/src/ui/message.cpp
+++ b/src/ui/message.cpp
@@ -30,7 +30,8 @@ Message::Message(MessageType type, KeyModifiers modifiers)
(she::is_key_pressed(kKeyLControl) || she::is_key_pressed(kKeyRControl) ? kKeyCtrlModifier: 0) |
(she::is_key_pressed(kKeyAlt) ? kKeyAltModifier: 0) |
(she::is_key_pressed(kKeyCommand) ? kKeyCmdModifier: 0) |
- (she::is_key_pressed(kKeySpace) ? kKeySpaceModifier: 0));
+ (she::is_key_pressed(kKeySpace) ? kKeySpaceModifier: 0) |
+ (she::is_key_pressed(kKeyLWin) || she::is_key_pressed(kKeyRWin) ? kKeyWinModifier: 0));
}
else {
m_modifiers = modifiers;
diff --git a/src/ui/message.h b/src/ui/message.h
index 6529154..01dca20 100644
--- a/src/ui/message.h
+++ b/src/ui/message.h
@@ -42,10 +42,12 @@ namespace ui {
bool ctrlPressed() const { return (m_modifiers & kKeyCtrlModifier) == kKeyCtrlModifier; }
bool altPressed() const { return (m_modifiers & kKeyAltModifier) == kKeyAltModifier; }
bool cmdPressed() const { return (m_modifiers & kKeyCmdModifier) == kKeyCmdModifier; }
+ bool winPressed() const { return (m_modifiers & kKeyWinModifier) == kKeyWinModifier; }
bool onlyShiftPressed() const { return m_modifiers == kKeyShiftModifier; }
bool onlyCtrlPressed() const { return m_modifiers == kKeyCtrlModifier; }
bool onlyAltPressed() const { return m_modifiers == kKeyAltModifier; }
bool onlyCmdPressed() const { return m_modifiers == kKeyCmdModifier; }
+ bool onlyWinPressed() const { return m_modifiers == kKeyWinModifier; }
void addRecipient(Widget* widget);
void prependRecipient(Widget* widget);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list