Merge lp:~widelands-dev/widelands/bug-1616661_messagebox_hotkeys into lp:widelands
- bug-1616661_messagebox_hotkeys
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 8103 | ||||
Proposed branch: | lp:~widelands-dev/widelands/bug-1616661_messagebox_hotkeys | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
185 lines (+77/-30) 3 files modified
data/tribes/scripting/help/controls.lua (+11/-11) src/wlapplication.cc (+28/-1) src/wui/game_message_menu.cc (+38/-18) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/bug-1616661_messagebox_hotkeys | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
SirVer | Approve | ||
GunChleoc | Needs Resubmitting | ||
Review via email: mp+305381@code.launchpad.net |
Commit message
Change the hotkeys used in message box to filter messages from [1..5] to Alt + [1...5]. Squash multiple triggering of Alt keys cause by interference with Linux window managers.
Description of the change
Fixes conflict with hotkeys of saved positions of map.
Change the hotkeys used in message box to filter messages from [1..5] to Alt + [1...5]. The Tooltips and the help texts are also changed accordingly.
There is a NOCOMM left. I didn't found any tooltip which correspond to this code. So maybe it could be removed.
bunnybot (widelandsofficial) wrote : | # |
Klaus Halfmann (klaus-halfmann) wrote : | # |
Please wait until this could be tested on OSX.
No idea how the Mapping of the Alt key workds with SDL on OSX yet.
bunnybot (widelandsofficial) wrote : | # |
Bunnybot encountered an error while working on this merge proposal:
Running 'bzr pull --overwrite' failed. Output:
ssh_exchange_
ConnectionReset reading response for 'BzrDir.open_2.1', retrying
ssh_exchange_
bzr: ERROR: Connection closed: Unexpected end of message. Please check connectivity and permissions, and report a bug if problems persist.
Using saved parent location: bzr+ssh:
bunnybot (widelandsofficial) wrote : | # |
Bunnybot encountered an error while working on this merge proposal:
Running 'bzr pull --overwrite' failed. Output:
ssh_exchange_
ConnectionReset reading response for 'BzrDir.open_2.1', retrying
ssh_exchange_
bzr: ERROR: Connection closed: Unexpected end of message. Please check connectivity and permissions, and report a bug if problems persist.
Using saved parent location: bzr+ssh:
GunChleoc (gunchleoc) wrote : | # |
The message button access doesn't work on Ubuntu.
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1311. State: passed. Details: https:/
Appveyor build 1153. State: success. Details: https:/
kaputtnik (franku) wrote : | # |
> The message button access doesn't work on Ubuntu.
Pressing "n"? Clicking the "Message" button? Those work here on arch-linux.
Until tomorrow i am away for 14 days so if something goes wrong with this branch feel free to change it.
kaputtnik (franku) wrote : | # |
Until -> As from tomorrow :-S
SirVer (sirver) wrote : | # |
Works on Mac! there is a NOCOM in the code still.
GunChleoc (gunchleoc) wrote : | # |
If I use
if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
it works with the control keys, If I use
if (code.mod & (KMOD_LALT | KMOD_RALT)) {
It does not work with the Alt keys. Same code, different key *headdesk*
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1315. State: passed. Details: https:/
Appveyor build 1157. State: failed. Details: https:/
SirVer (sirver) wrote : | # |
Maybe linux uses different key modifiers for the keys? Maybe there is a type issue somewhere? Does
if ((code.mod & KMOD_LALT) || (code.mod & KMOD_RALT)) work?
GunChleoc (gunchleoc) wrote : | # |
I have found out what happens:
if (code.mod & KMOD_CTRL) { triggers once, toggling the button off or on.
if (code.mod & KMOD_ALT) { triggers twice, toggling the button off and on.
The next question to solve is why / how to circumvent the bug.
The intention is that the user can hit the same key twice in order to toggle the button on and off, rather than having to use ALT + 0 to toggle off, so I'd rather not reprogram the filter_messages function.
SirVer (sirver) wrote : | # |
I would print out all the key events that end up in this function and try to understand why with alt 2 messages are sent.
GunChleoc (gunchleoc) wrote : | # |
These are the events I get for key down:
Ctrl alone:
===========
sym = 1073742048, mod = 0
Alt alone:
==========
sym = 1073742050, mod = 0
sym = 1073742050, mod = 256 (LALT)
Ctrl-1:
=======
sym = 1073742048, mod = 0
sym = 49, mod = 64 (LCTRL)
pressed 1
Alt-1:
======
sym = 1073742050, mod = 0
sym = 1073742050, mod = 256 (LALT)
sym = 49, mod = 256 (LALT)
pressed 1
sym = 1073742050, mod = 256 (LALT)
sym = 49, mod = 256 (LALT)
pressed 1
My best guess is that the window manager is interfering and messing things up. The only other place where we use the Alt key is in the tool selection in the editor, where it doesn't matter if the key is triggered multiple times.
SirVer (sirver) wrote : | # |
I remember that we had issues with Windowmanagers and alt before - some use this key also to make the window draggable as a whole. Maybe we should stick to ctrl shortcuts then. Or how about using the F1-F5 keys?
GunChleoc (gunchleoc) wrote : | # |
Hmmm, people usually associate F1 with help, F5 with refresh etc... also, 0 has some nice semantics that we can't have with the function keys.
I have found a workaround that will work for everything except toggling a button on and off with the same key while the game is paused. What do you think?
We could also try to attack the problem at the poll event stage, but I'd rather do that when we're not in feature freeze.
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1318. State: passed. Details: https:/
Appveyor build 1160. State: success. Details: https:/
SirVer (sirver) : | # |
GunChleoc (gunchleoc) wrote : | # |
Yep, fixing this in WLApplication is much cleaner.
SirVer (sirver) wrote : | # |
one comment inline, but I think this can go in the way it is.
GunChleoc (gunchleoc) wrote : | # |
Reordering the events is no problem there because of how often the function is called. So, I decided to go for efficiency and less code ;)
So, all bugs closed ow for Build 19! *happy dance*
@bunnybot merge
Preview Diff
1 | === modified file 'data/tribes/scripting/help/controls.lua' |
2 | --- data/tribes/scripting/help/controls.lua 2016-05-17 16:40:22 +0000 |
3 | +++ data/tribes/scripting/help/controls.lua 2016-09-16 16:56:31 +0000 |
4 | @@ -73,17 +73,17 @@ |
5 | h3(_"In the message window, the following additional shortcuts are available:") .. |
6 | p( |
7 | -- TRANSLATORS: This is the helptext for an access key combination. |
8 | - dl(help_format_hotkey("0"), _"Show all messages") .. |
9 | - -- TRANSLATORS: This is the helptext for an access key combination. |
10 | - dl(help_format_hotkey("1"), _"Show geologists’ messages only") .. |
11 | - -- TRANSLATORS: This is the helptext for an access key combination. |
12 | - dl(help_format_hotkey("2"), _"Show economy messages only") .. |
13 | - -- TRANSLATORS: This is the helptext for an access key combination. |
14 | - dl(help_format_hotkey("3"), _"Show seafaring messages only") .. |
15 | - -- TRANSLATORS: This is the helptext for an access key combination. |
16 | - dl(help_format_hotkey("4"), _"Show warfare messages only") .. |
17 | - -- TRANSLATORS: This is the helptext for an access key combination. |
18 | - dl(help_format_hotkey("5"), _"Show scenario messages only") .. |
19 | + dl(help_format_hotkey(pgettext("hotkey", "Alt + 0")), _"Show all messages") .. |
20 | + -- TRANSLATORS: This is the helptext for an access key combination. |
21 | + dl(help_format_hotkey(pgettext("hotkey", "Alt + 1")), _"Show geologists’ messages only") .. |
22 | + -- TRANSLATORS: This is the helptext for an access key combination. |
23 | + dl(help_format_hotkey(pgettext("hotkey", "Alt + 2")), _"Show economy messages only") .. |
24 | + -- TRANSLATORS: This is the helptext for an access key combination. |
25 | + dl(help_format_hotkey(pgettext("hotkey", "Alt + 3")), _"Show seafaring messages only") .. |
26 | + -- TRANSLATORS: This is the helptext for an access key combination. |
27 | + dl(help_format_hotkey(pgettext("hotkey", "Alt + 4")), _"Show warfare messages only") .. |
28 | + -- TRANSLATORS: This is the helptext for an access key combination. |
29 | + dl(help_format_hotkey(pgettext("hotkey", "Alt + 5")), _"Show scenario messages only") .. |
30 | -- TRANSLATORS: This is the helptext for an access key combination. |
31 | dl(help_format_hotkey("G"), _"Jump to the location corresponding to the current message") .. |
32 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. |
33 | |
34 | === modified file 'src/wlapplication.cc' |
35 | --- src/wlapplication.cc 2016-08-13 12:16:14 +0000 |
36 | +++ src/wlapplication.cc 2016-09-16 16:56:31 +0000 |
37 | @@ -534,13 +534,26 @@ |
38 | } |
39 | |
40 | void WLApplication::handle_input(InputCallback const* cb) { |
41 | + // Container for keyboard events using the Alt key. |
42 | + // <sym, mod>, type. |
43 | + std::map<std::pair<int32_t, uint16_t>, uint32_t> alt_events; |
44 | + |
45 | SDL_Event ev; |
46 | while (poll_event(ev)) { |
47 | switch (ev.type) { |
48 | case SDL_KEYUP: |
49 | case SDL_KEYDOWN: { |
50 | bool handled = false; |
51 | - if (cb && cb->key) { |
52 | + // Workaround for duplicate triggering of the Alt key in Ubuntu: |
53 | + // Don't accept the same key twice, so we use a map to squash them and handle them later. |
54 | + if (ev.key.keysym.mod & KMOD_ALT) { |
55 | + alt_events.insert(std::make_pair<std::pair<int32_t, uint16_t>, uint32_t>( |
56 | + std::make_pair<int32_t, uint16_t>(static_cast<int32_t>(ev.key.keysym.sym), |
57 | + static_cast<uint16_t>(ev.key.keysym.mod)), |
58 | + static_cast<uint32_t>(ev.type))); |
59 | + handled = true; |
60 | + } |
61 | + if (!handled && cb && cb->key) { |
62 | handled = cb->key(ev.type == SDL_KEYDOWN, ev.key.keysym); |
63 | } |
64 | if (!handled) { |
65 | @@ -575,6 +588,20 @@ |
66 | default:; |
67 | } |
68 | } |
69 | + |
70 | + // Now constructing the events for the Alt key from the container and handling them. |
71 | + for (const auto& event : alt_events) { |
72 | + ev.type = event.second; |
73 | + ev.key.keysym.sym = event.first.first; |
74 | + ev.key.keysym.mod = event.first.second; |
75 | + bool handled = false; |
76 | + if (cb && cb->key) { |
77 | + handled = cb->key(ev.type == SDL_KEYDOWN, ev.key.keysym); |
78 | + } |
79 | + if (!handled) { |
80 | + handle_key(ev.type == SDL_KEYDOWN, ev.key.keysym.sym, ev.key.keysym.mod); |
81 | + } |
82 | + } |
83 | } |
84 | |
85 | /* |
86 | |
87 | === modified file 'src/wui/game_message_menu.cc' |
88 | --- src/wui/game_message_menu.cc 2016-08-04 15:49:05 +0000 |
89 | +++ src/wui/game_message_menu.cc 2016-09-16 16:56:31 +0000 |
90 | @@ -357,23 +357,41 @@ |
91 | center_view(); |
92 | return true; |
93 | case SDLK_0: |
94 | - filter_messages(Widelands::Message::Type::kAllMessages); |
95 | - return true; |
96 | + if (code.mod & KMOD_ALT) { |
97 | + filter_messages(Widelands::Message::Type::kAllMessages); |
98 | + return true; |
99 | + } |
100 | + return false; |
101 | case SDLK_1: |
102 | - filter_messages(Widelands::Message::Type::kGeologists); |
103 | - return true; |
104 | + if (code.mod & KMOD_ALT) { |
105 | + filter_messages(Widelands::Message::Type::kGeologists); |
106 | + return true; |
107 | + } |
108 | + return false; |
109 | case SDLK_2: |
110 | - filter_messages(Widelands::Message::Type::kEconomy); |
111 | - return true; |
112 | + if (code.mod & KMOD_ALT) { |
113 | + filter_messages(Widelands::Message::Type::kEconomy); |
114 | + return true; |
115 | + } |
116 | + return false; |
117 | case SDLK_3: |
118 | - filter_messages(Widelands::Message::Type::kSeafaring); |
119 | - return true; |
120 | + if (code.mod & KMOD_ALT) { |
121 | + filter_messages(Widelands::Message::Type::kSeafaring); |
122 | + return true; |
123 | + } |
124 | + return false; |
125 | case SDLK_4: |
126 | - filter_messages(Widelands::Message::Type::kWarfare); |
127 | - return true; |
128 | + if (code.mod & KMOD_ALT) { |
129 | + filter_messages(Widelands::Message::Type::kWarfare); |
130 | + return true; |
131 | + } |
132 | + return false; |
133 | case SDLK_5: |
134 | - filter_messages(Widelands::Message::Type::kScenario); |
135 | - return true; |
136 | + if (code.mod & KMOD_ALT) { |
137 | + filter_messages(Widelands::Message::Type::kScenario); |
138 | + return true; |
139 | + } |
140 | + return false; |
141 | case SDLK_DELETE: |
142 | archive_or_restore(); |
143 | return true; |
144 | @@ -494,10 +512,11 @@ |
145 | scenariobtn_->set_perm_pressed(false); |
146 | button.set_perm_pressed(true); |
147 | message_filter_ = msgtype; |
148 | + |
149 | /** TRANSLATORS: %1% is a tooltip, %2% is the corresponding hotkey */ |
150 | button.set_tooltip((boost::format(_("%1% (Hotkey: %2%)")) |
151 | /** TRANSLATORS: Tooltip in the messages window */ |
152 | - % _("Show all messages") % "0") |
153 | + % _("Show all messages") % pgettext("hotkey", "Alt + 0")) |
154 | .str()); |
155 | } |
156 | } |
157 | @@ -508,23 +527,24 @@ |
158 | void GameMessageMenu::set_filter_messages_tooltips() { |
159 | geologistsbtn_->set_tooltip((boost::format(_("%1% (Hotkey: %2%)")) |
160 | /** TRANSLATORS: Tooltip in the messages window */ |
161 | - % _("Show geologists' messages only") % "1") |
162 | + % _("Show geologists' messages only") % |
163 | + pgettext("hotkey", "Alt + 1")) |
164 | .str()); |
165 | economybtn_->set_tooltip((boost::format(_("%1% (Hotkey: %2%)")) |
166 | /** TRANSLATORS: Tooltip in the messages window */ |
167 | - % _("Show economy messages only") % "2") |
168 | + % _("Show economy messages only") % pgettext("hotkey", "Alt + 2")) |
169 | .str()); |
170 | seafaringbtn_->set_tooltip((boost::format(_("%1% (Hotkey: %2%)")) |
171 | /** TRANSLATORS: Tooltip in the messages window */ |
172 | - % _("Show seafaring messages only") % "3") |
173 | + % _("Show seafaring messages only") % pgettext("hotkey", "Alt + 3")) |
174 | .str()); |
175 | warfarebtn_->set_tooltip((boost::format(_("%1% (Hotkey: %2%)")) |
176 | /** TRANSLATORS: Tooltip in the messages window */ |
177 | - % _("Show warfare messages only") % "4") |
178 | + % _("Show warfare messages only") % pgettext("hotkey", "Alt + 4")) |
179 | .str()); |
180 | scenariobtn_->set_tooltip((boost::format(_("%1% (Hotkey: %2%)")) |
181 | /** TRANSLATORS: Tooltip in the messages window */ |
182 | - % _("Show scenario messages only") % "5") |
183 | + % _("Show scenario messages only") % pgettext("hotkey", "Alt + 5")) |
184 | .str()); |
185 | } |
186 |
Continuous integration builds have changed state:
Travis build 1311. State: passed. Details: https:/ /travis- ci.org/ widelands/ widelands/ builds/ 158847433. /ci.appveyor. com/project/ widelands- dev/widelands/ build/_ widelands_ dev_widelands_ bug_1616661_ messagebox_ hotkeys- 1153.
Appveyor build 1153. State: success. Details: https:/