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
1=== modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp'
2--- src/modules/Unity/Application/mirsurfaceitem.cpp 2014-09-11 20:21:47 +0000
3+++ src/modules/Unity/Application/mirsurfaceitem.cpp 2014-09-24 21:36:07 +0000
4@@ -72,9 +72,10 @@
5 mirEvent.key.key_code = qtEvent->nativeVirtualKey();
6 mirEvent.key.scan_code = qtEvent->nativeScanCode();
7
8- // TODO: Investigate how to pass it from mir to qt in the first place.
9- // Then implement the reverse here.
10- mirEvent.key.repeat_count = 0;
11+ // TODO: It's not the best that we lose the actual repeat count from
12+ // the original mir event (pre QtEventFeeder)...of course it will
13+ // not matter for Qt clients...so this is an improvement for now.
14+ mirEvent.key.repeat_count = qtEvent->isAutoRepeat() ? 1 : 0;
15
16 // Don't care
17 mirEvent.key.down_time = 0;
18
19=== modified file 'src/platforms/mirserver/qteventfeeder.cpp'
20--- src/platforms/mirserver/qteventfeeder.cpp 2014-08-28 12:56:57 +0000
21+++ src/platforms/mirserver/qteventfeeder.cpp 2014-09-24 21:36:07 +0000
22@@ -264,13 +264,15 @@
23 char s[2];
24 int keyCode = translateKeysym(xk_sym, s, sizeof(s));
25 QString text = QString::fromLatin1(s);
26+
27+ bool is_auto_rep = event.repeat_count > 0;
28
29 QPlatformInputContext* context = QGuiApplicationPrivate::platformIntegration()->inputContext();
30 if (context) {
31 // TODO: consider event.repeat_count
32 QKeyEvent qKeyEvent(keyType, keyCode, modifiers,
33 event.scan_code, event.key_code, event.modifiers,
34- text);
35+ text, is_auto_rep);
36 qKeyEvent.setTimestamp(timestamp);
37 if (context->filterEvent(&qKeyEvent)) {
38 // key event filtered out by input context
39@@ -279,7 +281,7 @@
40 }
41
42 mQtWindowSystem->handleExtendedKeyEvent(timestamp, keyType, keyCode, modifiers,
43- event.scan_code, event.key_code, event.modifiers, text);
44+ event.scan_code, event.key_code, event.modifiers, text, is_auto_rep);
45 }
46
47 void QtEventFeeder::dispatchMotion(MirMotionEvent const& event)

Subscribers

People subscribed via source and target branches