Merge lp:~dandrader/qtubuntu/useApplicationStateAPI into lp:qtubuntu

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Gerry Boland
Approved revision: 291
Merged at revision: 298
Proposed branch: lp:~dandrader/qtubuntu/useApplicationStateAPI
Merge into: lp:qtubuntu
Prerequisite: lp:~albaguirre/qtubuntu/use-mir-surface-apis
Diff against target: 70 lines (+16/-5)
3 files modified
src/ubuntumirclient/input.cpp (+7/-0)
src/ubuntumirclient/integration.cpp (+9/-4)
src/ubuntumirclient/window.cpp (+0/-1)
To merge this branch: bzr merge lp:~dandrader/qtubuntu/useApplicationStateAPI
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+277720@code.launchpad.net

Commit message

Implement support for application state

Adapted code contribution from Sam Segers.

Also brought QWindowSystemInterface::handleWindowActivated() calls together, so they are all made from the same part of the code to ease tracking.

Description of the change

Tested on Nexus 4. Works as expected.

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
Gerry Boland (gerboland) wrote :

+ case ApplicationState:
+ return true;
+ break;
no need to break if you return.

- QWindowSystemInterface::handleWindowActivated(window(), Qt::ActiveWindowFocusReason);
that is a weird line to exist. Alberto added it, with comment "Ignore unfocusing events", would like to know why.

Otherwise code looks ok, need to test

review: Needs Fixing
291. By Daniel d'Andrada

Remove redundant break

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

> + case ApplicationState:
> + return true;
> + break;
> no need to break if you return.

Fixed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Tested on Bq, found no regression in the random selection of app I tried.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntumirclient/input.cpp'
2--- src/ubuntumirclient/input.cpp 2015-11-17 12:47:45 +0000
3+++ src/ubuntumirclient/input.cpp 2015-11-20 15:43:39 +0000
4@@ -240,9 +240,16 @@
5 if (focused) {
6 mPendingFocusGainedEvents--;
7 ubuntuEvent->window->handleSurfaceFocused();
8+ QWindowSystemInterface::handleWindowActivated(ubuntuEvent->window->window(), Qt::ActiveWindowFocusReason);
9+ if (qGuiApp->applicationState() == Qt::ApplicationInactive) {
10+ QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive);
11+ }
12 } else if(!mPendingFocusGainedEvents) {
13 DLOG("[ubuntumirclient QPA] No windows have focus");
14 QWindowSystemInterface::handleWindowActivated(nullptr, Qt::ActiveWindowFocusReason);
15+ if (qGuiApp->applicationState() == Qt::ApplicationActive) {
16+ QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive);
17+ }
18 }
19 }
20 break;
21
22=== modified file 'src/ubuntumirclient/integration.cpp'
23--- src/ubuntumirclient/integration.cpp 2015-10-22 14:17:32 +0000
24+++ src/ubuntumirclient/integration.cpp 2015-11-20 15:43:39 +0000
25@@ -46,8 +46,11 @@
26 Q_UNUSED(options)
27 Q_UNUSED(context)
28 DASSERT(context != NULL);
29- QCoreApplication::postEvent(QCoreApplication::instance(),
30- new QEvent(QEvent::ApplicationActivate));
31+ if (qGuiApp->focusWindow()) {
32+ QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive);
33+ } else {
34+ QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive);
35+ }
36 }
37
38 static void aboutToStopCallback(UApplicationArchive *archive, void* context)
39@@ -61,8 +64,7 @@
40 } else {
41 qWarning("UbuntuClientIntegration aboutToStopCallback(): no input context");
42 }
43- QCoreApplication::postEvent(QCoreApplication::instance(),
44- new QEvent(QEvent::ApplicationDeactivate));
45+ QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationSuspended);
46 }
47
48 UbuntuClientIntegration::UbuntuClientIntegration()
49@@ -175,6 +177,9 @@
50 case OpenGL:
51 return true;
52
53+ case ApplicationState:
54+ return true;
55+
56 case ThreadedOpenGL:
57 if (qEnvironmentVariableIsEmpty("QTUBUNTU_NO_THREADED_OPENGL")) {
58 return true;
59
60=== modified file 'src/ubuntumirclient/window.cpp'
61--- src/ubuntumirclient/window.cpp 2015-11-17 13:42:24 +0000
62+++ src/ubuntumirclient/window.cpp 2015-11-20 15:43:39 +0000
63@@ -534,7 +534,6 @@
64 // Therefore let's ensure we are up to date with the system clipboard now that we are getting
65 // focused again.
66 mClipboard->requestDBusClipboardContents();
67- QWindowSystemInterface::handleWindowActivated(window(), Qt::ActiveWindowFocusReason);
68 }
69
70 void UbuntuWindow::setWindowState(Qt::WindowState state)

Subscribers

People subscribed via source and target branches