Merge lp:~mir-team/qtmir/fix-key-auto-repeat into lp:qtmir

Proposed by Robert Carr
Status: Merged
Approved by: Daniel d'Andrada
Approved revision: 256
Merged at revision: 270
Proposed branch: lp:~mir-team/qtmir/fix-key-auto-repeat
Merge into: lp:qtmir
Diff against target: 47 lines (+8/-5)
2 files modified
src/modules/Unity/Application/mirsurfaceitem.cpp (+4/-3)
src/platforms/mirserver/qteventfeeder.cpp (+4/-2)
To merge this branch: bzr merge lp:~mir-team/qtmir/fix-key-auto-repeat
Reviewer Review Type Date Requested Status
Daniel d'Andrada (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+235873@code.launchpad.net

Commit message

Pass key auto-repeat flag through QtEventFeeder.

This ensures that clients of a qtmir server will receive a value for MirKeyEvent.repeat_count.

Description of the change

Fix key auto repeat...note though we lose the actual count of repeat_count from the original mir event, and instead just end up using it as a boolean "is this an auto-repeat event". This works fine for Qt clients as they only deal with isAutoRep, but supposedly some mir clients could want to utilize the actual repeat_count (e.g. accelerating repeat...? I'm not really confident on the use case actually).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

 * Are there any related MPs required for this MP to build/function as expected? Please list.
No
 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes
* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Just checked QWindowSystemInterface::handleExtendedKeyEvent signature:

"""
void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type type, int key,
                                                    Qt::KeyboardModifiers modifiers,
                                                    quint32 nativeScanCode, quint32 nativeVirtualKey,
                                                    quint32 nativeModifiers,
                                                    const QString& text, bool autorep,
                                                    ushort count)

"""

So its last parameter is the repeat count. Seems to be what you want.

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

And please property format your commit message.

Its first line should be a short description of the change. Then an empty line with the long, detailed, description coming after it.

Revision history for this message
Robert Carr (robertcarr) wrote :

Hi Daniel, I believe the count is actually something else :(

http://qt-project.org/doc/qt-4.8/qkeyevent.html#count

I got confused too.

Fixing commit message though.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

So maybe if, let's say, mir key is 'c' with repeat_count 4, we would have a QKeyEvent(key=Qt::Key_C, text="cccc",count=4)?

But, anyway, the bug doesn't complain about the count number.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp'
--- src/modules/Unity/Application/mirsurfaceitem.cpp 2014-09-11 20:21:47 +0000
+++ src/modules/Unity/Application/mirsurfaceitem.cpp 2014-09-24 21:36:07 +0000
@@ -72,9 +72,10 @@
72 mirEvent.key.key_code = qtEvent->nativeVirtualKey();72 mirEvent.key.key_code = qtEvent->nativeVirtualKey();
73 mirEvent.key.scan_code = qtEvent->nativeScanCode();73 mirEvent.key.scan_code = qtEvent->nativeScanCode();
7474
75 // TODO: Investigate how to pass it from mir to qt in the first place.75 // TODO: It's not the best that we lose the actual repeat count from
76 // Then implement the reverse here.76 // the original mir event (pre QtEventFeeder)...of course it will
77 mirEvent.key.repeat_count = 0;77 // not matter for Qt clients...so this is an improvement for now.
78 mirEvent.key.repeat_count = qtEvent->isAutoRepeat() ? 1 : 0;
7879
79 // Don't care80 // Don't care
80 mirEvent.key.down_time = 0;81 mirEvent.key.down_time = 0;
8182
=== modified file 'src/platforms/mirserver/qteventfeeder.cpp'
--- src/platforms/mirserver/qteventfeeder.cpp 2014-08-28 12:56:57 +0000
+++ src/platforms/mirserver/qteventfeeder.cpp 2014-09-24 21:36:07 +0000
@@ -264,13 +264,15 @@
264 char s[2];264 char s[2];
265 int keyCode = translateKeysym(xk_sym, s, sizeof(s));265 int keyCode = translateKeysym(xk_sym, s, sizeof(s));
266 QString text = QString::fromLatin1(s);266 QString text = QString::fromLatin1(s);
267
268 bool is_auto_rep = event.repeat_count > 0;
267269
268 QPlatformInputContext* context = QGuiApplicationPrivate::platformIntegration()->inputContext();270 QPlatformInputContext* context = QGuiApplicationPrivate::platformIntegration()->inputContext();
269 if (context) {271 if (context) {
270 // TODO: consider event.repeat_count272 // TODO: consider event.repeat_count
271 QKeyEvent qKeyEvent(keyType, keyCode, modifiers,273 QKeyEvent qKeyEvent(keyType, keyCode, modifiers,
272 event.scan_code, event.key_code, event.modifiers,274 event.scan_code, event.key_code, event.modifiers,
273 text);275 text, is_auto_rep);
274 qKeyEvent.setTimestamp(timestamp);276 qKeyEvent.setTimestamp(timestamp);
275 if (context->filterEvent(&qKeyEvent)) {277 if (context->filterEvent(&qKeyEvent)) {
276 // key event filtered out by input context278 // key event filtered out by input context
@@ -279,7 +281,7 @@
279 }281 }
280282
281 mQtWindowSystem->handleExtendedKeyEvent(timestamp, keyType, keyCode, modifiers,283 mQtWindowSystem->handleExtendedKeyEvent(timestamp, keyType, keyCode, modifiers,
282 event.scan_code, event.key_code, event.modifiers, text);284 event.scan_code, event.key_code, event.modifiers, text, is_auto_rep);
283}285}
284286
285void QtEventFeeder::dispatchMotion(MirMotionEvent const& event)287void QtEventFeeder::dispatchMotion(MirMotionEvent const& event)

Subscribers

People subscribed via source and target branches