Skip to content

Commit a1a30e4

Browse files
author
hekra01
committed
add new behavior option for long keypress
1 parent a7342f0 commit a1a30e4

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

Diff for: src/webdriver/extension_qt/q_key_converter.cc

+21-6
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ bool QKeyConverter::ConvertKeysToWebKeyEvents(const string16& client_keys,
299299
if (i > 0 && key == keys[i - 1])
300300
autoPress = true;
301301

302+
bool sendRelease;
303+
#if WD_ENABLE_ONE_KEYRELEASE
304+
// Send only last key release
305+
sendRelease = !autoRelease;
306+
#else
307+
// Send key release in all cases
308+
sendRelease = true;
309+
#endif
302310
// Create the key events.
303311
bool necessary_modifiers[3];
304312
for (int i = 0; i < 3; ++i) {
@@ -313,18 +321,25 @@ bool QKeyConverter::ConvertKeysToWebKeyEvents(const string16& client_keys,
313321

314322
if (unmodified_text.length() || modified_text.length()) {
315323
key_events.push_back(QKeyEvent(QEvent::KeyPress, key_code, all_modifiers, unmodified_text.c_str(), autoPress));
316-
key_events.push_back(QKeyEvent(QEvent::KeyRelease, key_code, all_modifiers, unmodified_text.c_str(), autoRelease));
324+
if (sendRelease) {
325+
key_events.push_back(QKeyEvent(QEvent::KeyRelease, key_code, all_modifiers, unmodified_text.c_str(), autoRelease));
326+
}
317327
}
318328
else
319329
{
320330
key_events.push_back(QKeyEvent(QEvent::KeyPress, key_code, all_modifiers, QString::null, autoPress));
321-
key_events.push_back(QKeyEvent(QEvent::KeyRelease, key_code, all_modifiers, QString::null, autoRelease));
331+
if (sendRelease) {
332+
key_events.push_back(QKeyEvent(QEvent::KeyRelease, key_code, all_modifiers, QString::null, autoRelease));
333+
}
322334
}
323335

324-
for (int i = 2; i > -1; --i) {
325-
if (necessary_modifiers[i]) {
326-
key_events.push_back(
327-
QKeyEvent(QEvent::KeyRelease, kModifiers[i].key_code, sticky_modifiers, QString::null, autoRelease));
336+
337+
if (sendRelease) {
338+
for (int i = 2; i > -1; --i) {
339+
if (necessary_modifiers[i]) {
340+
key_events.push_back(
341+
QKeyEvent(QEvent::KeyRelease, kModifiers[i].key_code, sticky_modifiers, QString::null, autoRelease));
342+
}
328343
}
329344
}
330345
}

Diff for: wd_build_options.gypi

+5-1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@
131131

132132
[ '<(WD_CONFIG_PLAYER) == 1', {
133133
'defines': [ 'WD_ENABLE_PLAYER=1' ],
134-
} ]
134+
}],
135+
136+
[ '<(WD_CONFIG_ONE_KEYRELEASE) == 1', {
137+
'defines': [ 'WD_ENABLE_ONE_KEYRELEASE=1' ],
138+
}]
135139
],
136140
}

Diff for: wd_common.gypi

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
'WD_CONFIG_QUICK%': '1',
77
'WD_BUILD_MONGOOSE%': '0',
88
'WD_CONFIG_PLAYER%': '1',
9+
'WD_CONFIG_ONE_KEYRELEASE%': '0',
910

1011
'QT_BIN_PATH%': '/usr/lib/qt4/bin',
1112
'QT_INC_PATH%': '/usr/include',

0 commit comments

Comments
 (0)