Merge lp:~dandrader/unity8/testWithQtMir into lp:unity8
- testWithQtMir
- Merge into trunk
Status: | Work in progress |
---|---|
Proposed branch: | lp:~dandrader/unity8/testWithQtMir |
Merge into: | lp:unity8 |
Diff against target: |
8576 lines (+750/-5610) 76 files modified
CMakeLists.txt (+1/-11) CODING (+8/-2) cmake/modules/QmlPlugins.cmake (+19/-13) cmake/modules/QmlTest.cmake (+7/-5) debian/control (+3/-8) debian/tests/control (+1/-0) debian/tests/qmluitests.sh (+6/-0) debian/unity8-tests.install (+0/-1) include/paths.h.in (+0/-10) plugins/Cursor/MousePointer.cpp (+9/-2) plugins/Cursor/MousePointer.h (+3/-2) src/Dash/main.cpp (+0/-20) src/MouseTouchAdaptor.cpp (+0/-419) src/MouseTouchAdaptor.h (+0/-72) src/ShellApplication.cpp (+2/-19) src/ShellApplication.h (+1/-9) src/UnityCommandLineParser.cpp (+0/-10) src/UnityCommandLineParser.h (+0/-8) tests/CMakeLists.txt (+15/-2) tests/autopilot/unity8/shell/tests/__init__.py (+0/-1) tests/mocks/Cursor/CMakeLists.txt (+34/-1) tests/mocks/Cursor/Cursor.qml (+0/-34) tests/mocks/Cursor/WindowedMousePointer.cpp (+62/-0) tests/mocks/Cursor/WindowedMousePointer.h (+35/-0) tests/mocks/Cursor/plugin.cpp (+43/-0) tests/mocks/Cursor/plugin.h (+33/-0) tests/mocks/Cursor/qmldir (+1/-0) tests/mocks/Unity/Application/ApplicationInfo.cpp (+0/-417) tests/mocks/Unity/Application/ApplicationInfo.h (+0/-162) tests/mocks/Unity/Application/ApplicationManager.cpp (+0/-557) tests/mocks/Unity/Application/ApplicationManager.h (+0/-122) tests/mocks/Unity/Application/CMakeLists.txt (+0/-35) tests/mocks/Unity/Application/MirMock.cpp (+0/-62) tests/mocks/Unity/Application/MirMock.h (+0/-43) tests/mocks/Unity/Application/MirSurface.cpp (+0/-550) tests/mocks/Unity/Application/MirSurface.h (+0/-232) tests/mocks/Unity/Application/MirSurfaceItem.cpp (+0/-415) tests/mocks/Unity/Application/MirSurfaceItem.h (+0/-138) tests/mocks/Unity/Application/MirSurfaceListModel.cpp (+0/-136) tests/mocks/Unity/Application/MirSurfaceListModel.h (+0/-56) tests/mocks/Unity/Application/ObjectListModel.h (+0/-108) tests/mocks/Unity/Application/SurfaceManager.cpp (+0/-281) tests/mocks/Unity/Application/SurfaceManager.h (+0/-116) tests/mocks/Unity/Application/VirtualKeyboard.cpp (+0/-58) tests/mocks/Unity/Application/VirtualKeyboard.h (+0/-37) tests/mocks/Unity/Application/plugin.cpp (+0/-68) tests/mocks/Unity/Application/plugin.h (+0/-31) tests/mocks/Unity/Application/qmldir (+0/-3) tests/mocks/Unity/Application/resources/MirSurfaceItem.qml (+0/-126) tests/mocks/Unity/Application/resources/VirtualKeyboard.qml (+0/-41) tests/mocks/Unity/Application/resources/screenshots/gmail-webapp.svg (+0/-343) tests/mocks/Unity/Application/resources/screenshots/ubuntu-weather-app.svg (+0/-201) tests/mocks/Unity/Application/resources/surfaces.qrc (+0/-23) tests/mocks/Unity/CMakeLists.txt (+0/-1) tests/qmltests/ApplicationMenuDataLoader.qml (+0/-1) tests/qmltests/ApplicationMenus/tst_MenuBar.qml (+0/-3) tests/qmltests/ApplicationMenus/tst_MenuPopup.qml (+1/-1) tests/qmltests/CMakeLists.txt (+8/-8) tests/qmltests/Panel/tst_ActiveCallHint.qml (+6/-10) tests/qmltests/Stage/ApplicationCheckBox.qml (+3/-3) tests/qmltests/Stage/tst_ApplicationWindow.qml (+113/-157) tests/qmltests/Stage/tst_DecoratedWindow.qml (+9/-2) tests/qmltests/Stage/tst_DesktopStage.qml (+40/-40) tests/qmltests/Stage/tst_PhoneStage.qml (+21/-33) tests/qmltests/Stage/tst_SurfaceContainer.qml (+26/-21) tests/qmltests/Stage/tst_TabletStage.qml (+50/-54) tests/qmltests/Tutorial/tst_Tutorial.qml (+2/-2) tests/qmltests/tst_OrientedShell.qml (+36/-86) tests/qmltests/tst_Shell.qml (+98/-124) tests/uqmlscene/CMakeLists.txt (+0/-6) tests/utils/modules/Unity/Test/CMakeLists.txt (+0/-8) tests/utils/modules/Unity/Test/MouseTouchEmulationCheckbox.qml (+4/-4) tests/utils/modules/Unity/Test/StageTestCase.qml (+49/-0) tests/utils/modules/Unity/Test/UnityTestCase.qml (+0/-16) tests/utils/modules/Unity/Test/plugin.cpp (+1/-19) tools/scopetool.cpp (+0/-1) |
To merge this branch: | bzr merge lp:~dandrader/unity8/testWithQtMir |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity8 CI Bot | continuous-integration | Needs Fixing | |
Albert Astals Cid (community) | Needs Fixing | ||
Review via email: mp+316851@code.launchpad.net |
Commit message
Use qtmir in qmltests instead of mocks
Description of the change
Prereq-archive: ppa:ci-
To select the resulution of the test window, use the MIR_SERVER_
$ MIR_SERVER_
For edge-push with the mouse, hold Shift while moving it across an edge.
Building it all in this silo: https:/
* Are there any related MPs required for this MP to build/function as expected? Please list.
https:/
https:/
* 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
* If you changed the UI, has there been a design review?
N/A
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2808
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2809
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2810
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2810
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2811
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Albert Astals Cid (aacid) wrote : | # |
Why the added -maxwarnings 0? Are we somehow more verbose than we where?
You forgot to remove these "mousetouch" instances
./tests/
./src/Dash/
./src/Dash/
I'm not a fan of
m_testingMode = qEnvironmentVar
in production code, do you think that you can turn that into a static bool variable that is set to true somewhere else? Maybe in uqmlscene?
Albert Astals Cid (aacid) wrote : | # |
A few tests failed here
xvfbtestActiveC
Totals: 18 passed, 7 failed, 0 skipped, 0 blacklisted
xvfbtestTutorial
Totals: 26 passed, 2 failed, 0 skipped, 0 blacklisted
xvfbtestGreeter
Totals: 7 passed, 1 failed, 0 skipped, 0 blacklisted
xvfbtestGreeterDBus
Totals: 5 passed, 7 failed, 0 skipped, 0 blacklisted
xvfbtestListVie
Totals: 64 passed, 6 failed, 0 skipped, 0 blacklisted
xvfbtestListVie
Totals: 72 passed, 8 failed, 0 skipped, 0 blacklisted
And a few core dumped
xvfbtestVertica
xvfbtestOrganicGrid
xvfbtestHorizon
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2812
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Daniel d'Andrada (dandrader) wrote : | # |
On 10/02/2017 08:36, Albert Astals Cid wrote:
> Review: Needs Fixing
>
> A few tests failed here
>
> xvfbtestActiveC
> Totals: 18 passed, 7 failed, 0 skipped, 0 blacklisted
>
> xvfbtestTutorial
> Totals: 26 passed, 2 failed, 0 skipped, 0 blacklisted
>
> xvfbtestGreeter
> Totals: 7 passed, 1 failed, 0 skipped, 0 blacklisted
>
> xvfbtestGreeterDBus
> Totals: 5 passed, 7 failed, 0 skipped, 0 blacklisted
>
> xvfbtestListVie
> Totals: 64 passed, 6 failed, 0 skipped, 0 blacklisted
>
> xvfbtestListVie
> Totals: 72 passed, 8 failed, 0 skipped, 0 blacklisted
>
>
>
>
> And a few core dumped
>
> xvfbtestVertica
> xvfbtestOrganicGrid
> xvfbtestHorizon
All fixed. Thanks.
Daniel d'Andrada (dandrader) wrote : | # |
On 10/02/2017 06:56, Albert Astals Cid wrote:
> Review: Needs Fixing
>
> Why the added -maxwarnings 0? Are we somehow more verbose than we where?
Not strictly related to the topic of this branch. But when you run big
tests like tst_Shell or tst_DesktopStage, at some point it stops logging
debug messages (considered warnings by qmltestrunner) and just logs the
test results instead. So it you get a failure in a late test, you're out
of luck as the log won't show you what was happening before the failure.
You will have to resort to running the test separately to ensure the
"max warnings" cap doesn't kick in.
And yes, the real mirserver logs more stuff than our (RIP) mock
Unity.Application module. Specially during start up, when it creates a
display, screen, etc.
>
>
> You forgot to remove these "mousetouch" instances
> ./tests/
> ./src/Dash/
> ./src/Dash/
Fixed.
> I'm not a fan of
> m_testingMode = qEnvironmentVar
> in production code, do you think that you can turn that into a static bool variable that is set to true somewhere else? Maybe in uqmlscene?
>
>
Neither am I. But that was the cleanest solution I found. Another being
copy pasting the Cursor plugin into the test/mocks subdir and change the
code there. But that involves code duplication and is rather complicated.
I don't see how exactly to do that testing mode set from within
uqmlscene and have it accessible from a qml plugin. In any case, the
elephant in the room would remain as production code would still have a
if(){}else[} for running in production or in test mode, which is the
real problem.
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2813
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2815
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2816
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2817
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Albert Astals Cid (aacid) wrote : | # |
> > I'm not a fan of
> > m_testingMode = qEnvironmentVar
> > in production code, do you think that you can turn that into a static bool variable that is set
> > to true somewhere else? Maybe in uqmlscene?
>
> Neither am I. But that was the cleanest solution I found. Another being
> copy pasting the Cursor plugin into the test/mocks subdir and change the
> code there. But that involves code duplication and is rather complicated.
What do you think about something like http://
It's unfinished (needs copying of the "real" Cursor.qml to the "mock" path) but i think it could work and that way we would get rid of that envvar and the if, no?
Daniel d'Andrada (dandrader) wrote : | # |
On 13/02/2017 08:08, Albert Astals Cid wrote:
>>> I'm not a fan of
>>> m_testingMode = qEnvironmentVar
>>> in production code, do you think that you can turn that into a static bool variable that is set
>>> to true somewhere else? Maybe in uqmlscene?
>> Neither am I. But that was the cleanest solution I found. Another being
>> copy pasting the Cursor plugin into the test/mocks subdir and change the
>> code there. But that involves code duplication and is rather complicated.
> What do you think about something like http://
>
> It's unfinished (needs copying of the "real" Cursor.qml to the "mock" path) but i think it could work and that way we would get rid of that envvar and the if, no?
By the way, that env var is what qtmir checks to decide whether to
initialize into test mode (with fake, internal mir client, apps) or
normal mode.
Albert Astals Cid (aacid) wrote : | # |
> By the way, that env var is what qtmir checks to decide whether to
> initialize into test mode (with fake, internal mir client, apps) or
> normal mode.
$ grep -R UNITY_TESTING
$
I don't see the envvar being used.
Albert Astals Cid (aacid) wrote : | # |
Ah, you mean your proposed qtmir branch introduces the envvar use in qtmir, i also disagree with that use then :)
Daniel d'Andrada (dandrader) wrote : | # |
On 13/02/2017 08:46, Albert Astals Cid wrote:
>> By the way, that env var is what qtmir checks to decide whether to
>> initialize into test mode (with fake, internal mir client, apps) or
>> normal mode.
> $ grep -R UNITY_TESTING
> $
>
> I don't see the envvar being used.
Did you check lp:~dandrader/qtmir/fake-apps ?
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2818
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2821
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2822
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2823
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2824
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
- 2808. By Launchpad Translations on behalf of unity-team
-
Launchpad automatic translations update.
Daniel d'Andrada (dandrader) wrote : | # |
On 13/02/2017 08:08, Albert Astals Cid wrote:
>>> I'm not a fan of
>>> m_testingMode = qEnvironmentVar
>>> in production code, do you think that you can turn that into a static bool variable that is set
>>> to true somewhere else? Maybe in uqmlscene?
>> Neither am I. But that was the cleanest solution I found. Another being
>> copy pasting the Cursor plugin into the test/mocks subdir and change the
>> code there. But that involves code duplication and is rather complicated.
> What do you think about something like http://
>
> It's unfinished (needs copying of the "real" Cursor.qml to the "mock" path) but i think it could work and that way we would get rid of that envvar and the if, no?
Ok, took the testing-related code out of the production Cursor plugin.
You should be happy now. :)
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2825
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
- 2809. By Albert Astals Cid
-
Make menus items close the menu when clicking on them (LP: #1657082, #1657399)
Approved by: Daniel d'Andrada, Unity8 CI Bot
- 2810. By Albert Astals Cid
-
Clicking on an open menu closes it + test
Approved by: Michael Zanetti, Unity8 CI Bot
- 2811. By Albert Astals Cid
-
Make the menus and submenus do not go outside the screen when popping out
Approved by: Michael Zanetti, Unity8 CI Bot
- 2812. By Albert Astals Cid
-
Auto open submenus on hover (LP: #1657085)
Approved by: Michael Zanetti, Unity8 CI Bot
- 2813. By Albert Astals Cid
-
Make the double click on a menu not be maximize the window below (LP: #1657079)
Approved by: Michael Zanetti, Unity8 CI Bot
- 2814. By Albert Astals Cid
-
Make the MenuBar InverseMouseArea eat hover events when there's a popup open (LP: #1657763)
Approved by: Michael Zanetti, Unity8 CI Bot
- 2815. By Nick Dedekind
-
Added overflow support to application menus.
Hover timer for auto-scrolling menu popup overflow.Approved by: Albert Astals Cid, Unity8 CI Bot
- 2816. By Nick Dedekind
-
Updated menu colors
Approved by: Lukáš Tinkl, Unity8 CI Bot
- 2817. By Albert Astals Cid
-
Make double click on the window decoration maximize
And fix test and add a new one (LP: #1657758)
Approved by: Daniel d'Andrada, Unity8 CI Bot
- 2818. By Lukáš Tinkl
-
Fixes for activating minimized windows and restoring fullscreen ones (LP: #1656808, #1658937, #1658938)
Approved by: Michael Zanetti, Unity8 CI Bot
- 2819. By Michael Zanetti
-
move right edge push area up some levels so it can be used on top of the indicators
Approved by: Lukáš Tinkl
- 2820. By Michael Zanetti
-
fix minimizing/
restoring transitions (LP: #1658936) Approved by: Lukáš Tinkl, Unity8 CI Bot
- 2821. By Michael Zanetti
-
fix some glitches with spread positioning
There are some circumstances which can cause the spread to jump around
* If there are only 2 apps and alt+tab is used to open the spread, move to the first (currently focused one), then release, the next time the spread is invoked, tiles animated to the old position and then jumped to the initial position. Resetting the spread position when the spread is left, fixes that.
* If many apps are open and the first one is tabbed to, the flickable could be moved to negative content positions which again would cause a jump when then interacting with the finger or mouse to reposition the spread.Approved by: Lukáš Tinkl, Unity8 CI Bot
- 2822. By Michael Zanetti
-
fix jumpy animation when closing an item from the spread
Approved by: Lukáš Tinkl, Unity8 CI Bot
- 2823. By Michael Zanetti
-
Show the wallpaper while the focused app is moving in staged mode (LP: #1648251)
Approved by: Lukáš Tinkl, Unity8 CI Bot
- 2824. By Michael Zanetti
-
Update the tutorial to mention the app drawer instead of the dash on long left edge swipe (LP: #1658932)
Approved by: Lukáš Tinkl, Unity8 CI Bot
- 2825. By Michael Zanetti
-
prevent hiding the launcher when the mouse hover event is eaten by the EdgePushArea (LP: #1657045)
Approved by: Albert Astals Cid, Unity8 CI Bot
- 2826. By Daniel d'Andrada
-
Consolidate launcher API checks
Approved by: Albert Astals Cid, Unity8 CI Bot
- 2827. By Michael Zanetti
-
properly invalidate the whole model
this fixes a crash in certain circumstances but makes things slower.
To compensate the slowness, turning off dynamic sorting/filtering
in the topmost proxy models seems to work fine. (LP: #1658190)Approved by: Lukáš Tinkl, Unity8 CI Bot
- 2828. By Albert Astals Cid
-
Eat hover events when the launcher quicklist is open
This way we don't change the mouse cursor wrongly to resize windows for example (LP: #1640776)
Approved by: Michael Zanetti, Unity8 CI Bot
- 2829. By Albert Astals Cid
-
Remove TODO now that we require Qt > 5.5
Approved by: Michał Sawicz, Unity8 CI Bot
- 2830. By Michael Zanetti
-
stabilize OrientedShell test (LP: #1658994)
Approved by: Lukáš Tinkl, Unity8 CI Bot
- 2831. By Albert Astals Cid
-
Serialize two make targets that want to cp to the same target file
Whitout it, running
while [ true ]; do rm -f qmldir; make -j4 all; if [ $? -ne 0 ]; then break; fi; done
in builddir/tests/mocks/ Unity eventually fails. (LP: #1660576) Approved by: Michael Terry, Unity8 CI Bot
- 2832. By Albert Astals Cid
-
Remove variable that is always false (LP: #1585910)
Approved by: Michael Zanetti, Unity8 CI Bot
- 2833. By CI Train Bot Account
-
Releasing 8.15+17.
04.20170216. 1-0ubuntu1
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2827
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2807
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Michał Sawicz (saviq) : | # |
Daniel d'Andrada (dandrader) wrote : | # |
On 17/02/2017 10:51, Michał Sawicz wrote:
>
> Diff comments:
>
>> === modified file 'debian/
>> --- debian/
>> +++ debian/
>> @@ -2,6 +2,7 @@
>> Restrictions: allow-stderr
>> Depends: dpkg-dev,
>> unity8-tests,
>> + mir-platform-
> This needs to be the meta package instead:
>
> mir-graphics-
Done
- 2834. By Daniel d'Andrada
-
Use qtmir in qmltests instead of mocks
Albert Astals Cid (aacid) wrote : | # |
Contents conflict in tests/mocks/
1 conflicts encountered.
Daniel d'Andrada (dandrader) wrote : | # |
On 21/02/2017 10:26, Albert Astals Cid wrote:
> Review: Needs Fixing
>
> Contents conflict in tests/mocks/
> 1 conflicts encountered.
fixed
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2834
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 2835. By Daniel d'Andrada
-
Make tst_DecoratedWindow more reliable
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2835
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Albert Astals Cid (aacid) wrote : | # |
Looks good to me, only thing missing is CI/tests not being happy, after that i'll approve + top-approve
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2836
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 2836. By Daniel d'Andrada
-
Keep running some qml ui tests as regular client apps in the host system
A lot of the tests have no need to be run as a fully fledged mir server nor access Unity.Application
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2836
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 2837. By Daniel d'Andrada
-
WIP - Attempt to get tests to run in jenkins CI
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2837
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2837
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 2838. By Daniel d'Andrada
-
further investigation
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2838
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Albert Astals Cid (aacid) wrote : | # |
Moving to WiP until we can fix the problem with CI
Unmerged revisions
- 2838. By Daniel d'Andrada
-
further investigation
- 2837. By Daniel d'Andrada
-
WIP - Attempt to get tests to run in jenkins CI
- 2836. By Daniel d'Andrada
-
Keep running some qml ui tests as regular client apps in the host system
A lot of the tests have no need to be run as a fully fledged mir server nor access Unity.Application
- 2835. By Daniel d'Andrada
-
Make tst_DecoratedWindow more reliable
- 2834. By Daniel d'Andrada
-
Use qtmir in qmltests instead of mocks
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2017-02-16 13:45:35 +0000 |
3 | +++ CMakeLists.txt 2017-02-23 19:04:58 +0000 |
4 | @@ -70,7 +70,7 @@ |
5 | find_package(Qt5Concurrent 5.6 REQUIRED) |
6 | find_package(Qt5Sql 5.6 REQUIRED) |
7 | |
8 | -pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=26) |
9 | +pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=27) |
10 | pkg_check_modules(GEONAMES REQUIRED geonames>=0.2) |
11 | pkg_check_modules(GIO REQUIRED gio-2.0>=2.32) |
12 | pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32) |
13 | @@ -158,16 +158,6 @@ |
14 | set(STDOUT_LOGGER "-o" "-,txt") |
15 | endif() |
16 | |
17 | -execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH OUTPUT_VARIABLE ARCH) |
18 | -if (NOT ARCH MATCHES "arm*") |
19 | - set(ENABLE_TOUCH_EMULATION true) |
20 | - add_definitions(-DUNITY8_ENABLE_TOUCH_EMULATION) |
21 | - pkg_check_modules(MOUSETOUCHADAPTOR_LIBS REQUIRED x11 xcb xi) |
22 | -else() |
23 | - set(ENABLE_TOUCH_EMULATION false) |
24 | - message(STATUS "Touch emulation support disabled.") |
25 | -endif() |
26 | - |
27 | # add subdirectories to build |
28 | add_subdirectory(include) |
29 | add_subdirectory(src) |
30 | |
31 | === modified file 'CODING' |
32 | --- CODING 2016-10-13 11:02:11 +0000 |
33 | +++ CODING 2017-02-23 19:04:58 +0000 |
34 | @@ -68,9 +68,9 @@ |
35 | ========================== |
36 | |
37 | Running unity8 on a device should be done using crossbuilder. |
38 | -Go to |
39 | +Go to |
40 | * https://launchpad.net/crossbuilder and |
41 | -* https://wiki.ubuntu.com/Touch/Crossbuilder |
42 | +* https://wiki.ubuntu.com/Touch/Crossbuilder |
43 | for more details on crossbuilder. |
44 | |
45 | unity8 will automatically restart on the phone once deployment |
46 | @@ -134,6 +134,12 @@ |
47 | |
48 | $ make tryDragHandle |
49 | |
50 | +To define the dimensions of the test window, use the MIR_SERVER_X11_DISPLAYS environment variable. Like this: |
51 | + |
52 | +$ MIR_SERVER_X11_DISPLAYS=1920x1080 make tryDragHandle |
53 | + |
54 | +To have the mouse bounded by shell screen limits when running, eg, "make tryShell", hold the Shift key. |
55 | + |
56 | NB: Manual test or interation doesn't make sense for all components or classes, |
57 | particularly the non-graphical ones. In such cases no "tryFoo" make target is |
58 | provided. |
59 | |
60 | === modified file 'cmake/modules/QmlPlugins.cmake' |
61 | --- cmake/modules/QmlPlugins.cmake 2015-04-29 21:55:29 +0000 |
62 | +++ cmake/modules/QmlPlugins.cmake 2017-02-23 19:04:58 +0000 |
63 | @@ -27,7 +27,9 @@ |
64 | # Resource file names are matched against {*.{qml,js,jpg,png,sci,svg},qmldir}. |
65 | # |
66 | # export_qmlfiles(plugin path |
67 | -# [SEARCH_PATH path] # Path to search for resources in (defaults to ${CMAKE_CURRENT_SOURCE_DIR}) |
68 | +# [SEARCH_PATH path] # Path to search for resource files. Defaults to ${CMAKE_CURRENT_SOURCE_DIR} |
69 | +# [GLOBBING_EXPRESSIONS] # The globbing expressions used to find the files to be copied. If set, |
70 | +# overrides any given SEARCH_PATH. |
71 | # [BINARY_DIR path] |
72 | # [DESTINATION path] |
73 | # [TARGET_PREFIX string] # Will be prefixed to the target name |
74 | @@ -38,8 +40,8 @@ |
75 | |
76 | macro(export_qmlfiles PLUGIN PATH) |
77 | set(single SEARCH_PATH BINARY_DIR DESTINATION TARGET_PREFIX) |
78 | - cmake_parse_arguments(QMLFILES "" "${single}" "" ${ARGN}) |
79 | - |
80 | + cmake_parse_arguments(QMLFILES "" "${single}" "GLOBBING_EXPRESSIONS" ${ARGN}) |
81 | + |
82 | if(NOT QMLFILES_SEARCH_PATH) |
83 | set(QMLFILES_SEARCH_PATH ${CMAKE_CURRENT_SOURCE_DIR}) |
84 | endif() |
85 | @@ -50,16 +52,20 @@ |
86 | set(qmlfiles_dir ${CMAKE_CURRENT_BINARY_DIR}) |
87 | endif() |
88 | |
89 | - file(GLOB QMLFILES |
90 | - ${QMLFILES_SEARCH_PATH}/*.qml |
91 | - ${QMLFILES_SEARCH_PATH}/*.js |
92 | - ${QMLFILES_SEARCH_PATH}/*.jpg |
93 | - ${QMLFILES_SEARCH_PATH}/*.png |
94 | - ${QMLFILES_SEARCH_PATH}/*.sci |
95 | - ${QMLFILES_SEARCH_PATH}/*.svg |
96 | - ${QMLFILES_SEARCH_PATH}/*.qmltypes |
97 | - ${QMLFILES_SEARCH_PATH}/qmldir |
98 | - ) |
99 | + if(NOT QMLFILES_GLOBBING_EXPRESSIONS) |
100 | + set(QMLFILES_GLOBBING_EXPRESSIONS |
101 | + ${QMLFILES_SEARCH_PATH}/*.qml |
102 | + ${QMLFILES_SEARCH_PATH}/*.js |
103 | + ${QMLFILES_SEARCH_PATH}/*.jpg |
104 | + ${QMLFILES_SEARCH_PATH}/*.png |
105 | + ${QMLFILES_SEARCH_PATH}/*.sci |
106 | + ${QMLFILES_SEARCH_PATH}/*.svg |
107 | + ${QMLFILES_SEARCH_PATH}/*.qmltypes |
108 | + ${QMLFILES_SEARCH_PATH}/qmldir |
109 | + ) |
110 | + endif() |
111 | + |
112 | + file(GLOB QMLFILES ${QMLFILES_GLOBBING_EXPRESSIONS}) |
113 | |
114 | execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${qmlfiles_dir}) |
115 | |
116 | |
117 | === modified file 'cmake/modules/QmlTest.cmake' |
118 | --- cmake/modules/QmlTest.cmake 2017-01-24 07:43:35 +0000 |
119 | +++ cmake/modules/QmlTest.cmake 2017-02-23 19:04:58 +0000 |
120 | @@ -118,7 +118,7 @@ |
121 | |
122 | add_executable_test(${COMPONENT_NAME} qmltestrunner |
123 | ${ARGN} |
124 | - ARGS -input ${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml ${QMLTEST_ARGS} |
125 | + ARGS -input ${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml ${QMLTEST_ARGS} -maxwarnings 0 |
126 | ) |
127 | |
128 | if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml") |
129 | @@ -151,7 +151,7 @@ |
130 | endfunction() |
131 | |
132 | |
133 | -# add_executable_test(target component_name |
134 | +# add_executable_test(component_name target |
135 | # [...] # see doc for add_manual_qml_test for common arguments |
136 | # [ADD_TEST] # whether to add to the "test" target |
137 | # [ARG_PREFIX arg_prefix] # prefix logging arguments with this string |
138 | @@ -189,10 +189,12 @@ |
139 | ${args} |
140 | ) |
141 | |
142 | + set(common_qmltest_env QML2_IMPORT_PATH=${imports} ${QMLTEST_ENVIRONMENT}) |
143 | + |
144 | add_qmltest_target(test${COMPONENT_NAME} ${TARGET} |
145 | COMMAND ${qmltest_command} |
146 | ${depends} |
147 | - ENVIRONMENT QML2_IMPORT_PATH=${imports} ${QMLTEST_ENVIRONMENT} |
148 | + ENVIRONMENT ${common_qmltest_env} |
149 | ${add_test} |
150 | ${targets} |
151 | ) |
152 | @@ -201,7 +203,7 @@ |
153 | add_qmltest_target(xvfbtest${COMPONENT_NAME} ${TARGET} |
154 | COMMAND $<TARGET_FILE:xvfb-run> --server-args "-screen 0 1024x768x24" --auto-servernum ${qmltest_command} |
155 | ${depends} |
156 | - ENVIRONMENT QML2_IMPORT_PATH=${imports} ${QMLTEST_ENVIRONMENT} LD_PRELOAD=/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/mesa/libGL.so.1 |
157 | + ENVIRONMENT ${common_qmltest_env} LD_PRELOAD=/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/mesa/libGL.so.1 |
158 | TARGETS ${xvfb_targets} |
159 | ) |
160 | endif() |
161 | @@ -210,7 +212,7 @@ |
162 | add_qmltest_target(gdbtest${COMPONENT_NAME} ${TARGET} |
163 | COMMAND $<TARGET_FILE:gdb> -ex run -args ${qmltest_command} |
164 | ${depends} |
165 | - ENVIRONMENT QML2_IMPORT_PATH=${imports} ${QMLTEST_ENVIRONMENT} |
166 | + ENVIRONMENT ${common_qmltest_env} |
167 | ) |
168 | endif() |
169 | endfunction() |
170 | |
171 | === modified file 'debian/control' |
172 | --- debian/control 2017-02-06 09:11:56 +0000 |
173 | +++ debian/control 2017-02-23 19:04:58 +0000 |
174 | @@ -38,13 +38,8 @@ |
175 | libubuntugestures5-private-dev (>= 1.3.2030), |
176 | libudev-dev, |
177 | libudm-common-dev, |
178 | - libunity-api-dev (>= 8.2), |
179 | + libunity-api-dev (>= 8.4), |
180 | libusermetricsoutput1-dev, |
181 | -# Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop |
182 | - libx11-dev[!arm64 !armhf], |
183 | - libxcb1-dev[!arm64 !armhf], |
184 | - libxi-dev[!arm64 !armhf], |
185 | -# End of X11 libs |
186 | pkg-config, |
187 | python3-all:any, |
188 | python3-setuptools, |
189 | @@ -162,7 +157,7 @@ |
190 | qttranslations5-l10n, |
191 | ubuntu-thumbnailer-impl-0, |
192 | ubuntu-wallpapers, |
193 | - unity-application-impl-26, |
194 | + unity-application-impl-27, |
195 | unity-notifications-impl-3, |
196 | unity-plugin-scopes | unity-scopes-impl, |
197 | unity-scopes-impl-12, |
198 | @@ -212,7 +207,7 @@ |
199 | ${misc:Depends}, |
200 | ${shlibs:Depends}, |
201 | Provides: unity-application-impl, |
202 | - unity-application-impl-26, |
203 | + unity-application-impl-27, |
204 | unity8-fake-env, |
205 | Replaces: unity8-autopilot (<< 8.02+15.04.20150422-0ubuntu1), |
206 | unity8-fake-env, |
207 | |
208 | === modified file 'debian/tests/control' |
209 | --- debian/tests/control 2016-06-03 13:39:53 +0000 |
210 | +++ debian/tests/control 2017-02-23 19:04:58 +0000 |
211 | @@ -2,6 +2,7 @@ |
212 | Restrictions: allow-stderr |
213 | Depends: dpkg-dev, |
214 | unity8-tests, |
215 | + mir-graphics-drivers-desktop |
216 | |
217 | Tests: autopilot.sh |
218 | Restrictions: allow-stderr, |
219 | |
220 | === modified file 'debian/tests/qmluitests.sh' |
221 | --- debian/tests/qmluitests.sh 2016-07-14 13:04:10 +0000 |
222 | +++ debian/tests/qmluitests.sh 2017-02-23 19:04:58 +0000 |
223 | @@ -8,4 +8,10 @@ |
224 | |
225 | export ARTIFACTS_DIR="${ADT_ARTIFACTS}" |
226 | |
227 | +export MIR_SERVER_PLATFORM_GRAPHICS_LIB="/usr/lib/${DEB_HOST_MULTIARCH}/mir/server-platform/server-mesa-x11.so.12" |
228 | + |
229 | +echo "********* checking dri **********" |
230 | +ls /dev/dri |
231 | +echo "********* DONE checking dri **********" |
232 | + |
233 | /usr/lib/$DEB_HOST_MULTIARCH/unity8/tests/scripts/xvfballtests.sh |
234 | |
235 | === modified file 'debian/unity8-tests.install' |
236 | --- debian/unity8-tests.install 2016-04-22 20:01:26 +0000 |
237 | +++ debian/unity8-tests.install 2017-02-23 19:04:58 +0000 |
238 | @@ -1,7 +1,6 @@ |
239 | data/unity-mock-indicator-service.conf usr/share/upstart/sessions/ |
240 | usr/bin/unity-mock-indicator-service |
241 | usr/lib/*/unity8/qml/mocks |
242 | -usr/lib/*/unity8/qml/nonmirplugins |
243 | usr/lib/*/unity8/qml/scopefakes |
244 | usr/lib/*/unity8/qml/utils |
245 | usr/lib/*/unity8/tests |
246 | |
247 | === modified file 'include/paths.h.in' |
248 | --- include/paths.h.in 2016-12-06 20:16:56 +0000 |
249 | +++ include/paths.h.in 2017-02-23 19:04:58 +0000 |
250 | @@ -103,16 +103,6 @@ |
251 | return paths; |
252 | } |
253 | |
254 | -inline QStringList nonMirImportPaths() { |
255 | - QStringList paths; |
256 | - if (isRunningInstalled()) { |
257 | - paths << installRoot() + QStringLiteral("@CMAKE_INSTALL_PREFIX@/@SHELL_INSTALL_QML@/nonmirplugins"); |
258 | - } else { |
259 | - paths << buildDirectory() + QStringLiteral("/nonmirplugins"); |
260 | - } |
261 | - return paths; |
262 | -} |
263 | - |
264 | inline QStringList fallbackImportPaths() { |
265 | QStringList paths; |
266 | if (isRunningInstalled()) { |
267 | |
268 | === modified file 'plugins/Cursor/MousePointer.cpp' |
269 | --- plugins/Cursor/MousePointer.cpp 2016-09-07 08:36:59 +0000 |
270 | +++ plugins/Cursor/MousePointer.cpp 2017-02-23 19:04:58 +0000 |
271 | @@ -1,5 +1,5 @@ |
272 | /* |
273 | - * Copyright (C) 2015-2016 Canonical, Ltd. |
274 | + * Copyright (C) 2015-2017 Canonical, Ltd. |
275 | * |
276 | * This program is free software: you can redistribute it and/or modify it under |
277 | * the terms of the GNU Lesser General Public License version 3, as published by |
278 | @@ -33,9 +33,11 @@ |
279 | { |
280 | } |
281 | |
282 | -void MousePointer::handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButtons buttons, |
283 | +void MousePointer::handleMouseEvent(ulong timestamp, QPointF movement, QPointF position, Qt::MouseButtons buttons, |
284 | Qt::KeyboardModifiers modifiers) |
285 | { |
286 | + Q_UNUSED(position); |
287 | + |
288 | if (!parentItem()) { |
289 | return; |
290 | } |
291 | @@ -44,6 +46,11 @@ |
292 | Q_EMIT mouseMoved(); |
293 | } |
294 | |
295 | + applyMouseMovement(timestamp, movement, buttons, modifiers); |
296 | +} |
297 | + |
298 | +void MousePointer::applyMouseMovement(ulong timestamp, QPointF movement, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) |
299 | +{ |
300 | m_accumulatedMovement += movement; |
301 | // don't apply the fractional part |
302 | QPointF appliedMovement(int(m_accumulatedMovement.x()), int(m_accumulatedMovement.y())); |
303 | |
304 | === modified file 'plugins/Cursor/MousePointer.h' |
305 | --- plugins/Cursor/MousePointer.h 2016-09-07 08:36:59 +0000 |
306 | +++ plugins/Cursor/MousePointer.h 2017-02-23 19:04:58 +0000 |
307 | @@ -1,5 +1,5 @@ |
308 | /* |
309 | - * Copyright (C) 2015-2016 Canonical, Ltd. |
310 | + * Copyright (C) 2015-2017 Canonical, Ltd. |
311 | * |
312 | * This program is free software: you can redistribute it and/or modify it under |
313 | * the terms of the GNU Lesser General Public License version 3, as published by |
314 | @@ -47,7 +47,7 @@ |
315 | void setTopBoundaryOffset(int topBoundaryOffset); |
316 | |
317 | public Q_SLOTS: |
318 | - void handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButtons buttons, |
319 | + void handleMouseEvent(ulong timestamp, QPointF movement, QPointF position, Qt::MouseButtons buttons, |
320 | Qt::KeyboardModifiers modifiers) override; |
321 | void handleWheelEvent(ulong timestamp, QPoint angleDelta, Qt::KeyboardModifiers modifiers) override; |
322 | |
323 | @@ -67,6 +67,7 @@ |
324 | |
325 | protected: |
326 | void itemChange(ItemChange change, const ItemChangeData &value) override; |
327 | + void applyMouseMovement(ulong timestamp, QPointF movement, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); |
328 | |
329 | private Q_SLOTS: |
330 | void registerScreen(QScreen *screen); |
331 | |
332 | === modified file 'src/Dash/main.cpp' |
333 | --- src/Dash/main.cpp 2016-10-27 00:05:28 +0000 |
334 | +++ src/Dash/main.cpp 2017-02-23 19:04:58 +0000 |
335 | @@ -32,9 +32,6 @@ |
336 | |
337 | #include <paths.h> |
338 | #include "../qmldebuggerutils.h" |
339 | -#ifdef UNITY8_ENABLE_TOUCH_EMULATION |
340 | - #include "../MouseTouchAdaptor.h" |
341 | -#endif |
342 | #include "../CachingNetworkManagerFactory.h" |
343 | #include "../UnixSignalHandler.h" |
344 | |
345 | @@ -51,10 +48,6 @@ |
346 | parser.setApplicationDescription(QStringLiteral("Description: Unity 8 Shell Dash")); |
347 | parser.addHelpOption(); |
348 | |
349 | - QCommandLineOption mousetouchOption(QStringLiteral("mousetouch"), |
350 | - QStringLiteral("Allow the mouse to provide touch input")); |
351 | - parser.addOption(mousetouchOption); |
352 | - |
353 | QCommandLineOption windowGeometryOption(QStringList() << QStringLiteral("windowgeometry"), |
354 | QStringLiteral("Specify the window geometry as [<width>x<height>]"), QStringLiteral("windowgeometry"), QStringLiteral("1")); |
355 | parser.addOption(windowGeometryOption); |
356 | @@ -92,15 +85,6 @@ |
357 | bindtextdomain("unity8", translationDirectory().toUtf8().data()); |
358 | textdomain("unity8"); |
359 | |
360 | - #ifdef UNITY8_ENABLE_TOUCH_EMULATION |
361 | - // You will need this if you want to interact with touch-only components using a mouse |
362 | - // Needed only when manually testing on a desktop. |
363 | - MouseTouchAdaptor *mouseTouchAdaptor = 0; |
364 | - if (parser.isSet(mousetouchOption)) { |
365 | - mouseTouchAdaptor = MouseTouchAdaptor::instance(); |
366 | - } |
367 | - #endif |
368 | - |
369 | QQmlApplicationEngine *engine = new QQmlApplicationEngine(application); |
370 | |
371 | int initialWidth = -1; |
372 | @@ -136,10 +120,6 @@ |
373 | |
374 | delete engine; |
375 | |
376 | - #ifdef UNITY8_ENABLE_TOUCH_EMULATION |
377 | - delete mouseTouchAdaptor; |
378 | - #endif |
379 | - |
380 | delete application; |
381 | |
382 | return result; |
383 | |
384 | === removed file 'src/MouseTouchAdaptor.cpp' |
385 | --- src/MouseTouchAdaptor.cpp 2017-01-17 14:20:54 +0000 |
386 | +++ src/MouseTouchAdaptor.cpp 1970-01-01 00:00:00 +0000 |
387 | @@ -1,419 +0,0 @@ |
388 | -/* |
389 | - * Copyright (C) 2013,2015 Canonical, Ltd. |
390 | - * |
391 | - * This program is free software; you can redistribute it and/or modify |
392 | - * it under the terms of the GNU General Public License as published by |
393 | - * the Free Software Foundation; version 3. |
394 | - * |
395 | - * This program is distributed in the hope that it will be useful, |
396 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
397 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
398 | - * GNU General Public License for more details. |
399 | - * |
400 | - * You should have received a copy of the GNU General Public License |
401 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
402 | - * |
403 | - * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> |
404 | - */ |
405 | - |
406 | - |
407 | -/* Some parts of the code were copied from the XCB platform plugin of the Qt Toolkit, |
408 | - * which is under the following license: |
409 | - */ |
410 | - |
411 | -/**************************************************************************** |
412 | -** |
413 | -** Copyright (C) 2015 The Qt Company Ltd. |
414 | -** Contact: http://www.qt.io/licensing/ |
415 | -** |
416 | -** This file is part of the . |
417 | -** |
418 | -** $QT_BEGIN_LICENSE:LGPL21$ |
419 | -** Commercial License Usage |
420 | -** Licensees holding valid commercial Qt licenses may use this file in |
421 | -** accordance with the commercial license agreement provided with the |
422 | -** Software or, alternatively, in accordance with the terms contained in |
423 | -** a written agreement between you and The Qt Company. For licensing terms |
424 | -** and conditions see http://www.qt.io/terms-conditions. For further |
425 | -** information use the contact form at http://www.qt.io/contact-us. |
426 | -** |
427 | -** GNU Lesser General Public License Usage |
428 | -** Alternatively, this file may be used under the terms of the GNU Lesser |
429 | -** General Public License version 2.1 or version 3 as published by the Free |
430 | -** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
431 | -** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
432 | -** following information to ensure the GNU Lesser General Public License |
433 | -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
434 | -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
435 | -** |
436 | -** As a special exception, The Qt Company gives you certain additional |
437 | -** rights. These rights are described in The Qt Company LGPL Exception |
438 | -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
439 | -** |
440 | -** $QT_END_LICENSE$ |
441 | -** |
442 | -****************************************************************************/ |
443 | - |
444 | -#include "MouseTouchAdaptor.h" |
445 | - |
446 | -#include <qpa/qplatformnativeinterface.h> |
447 | -#include <qpa/qwindowsysteminterface.h> |
448 | - |
449 | -#include <QCoreApplication> |
450 | -#include <QMouseEvent> |
451 | -#include <QTest> |
452 | - |
453 | -#include <X11/extensions/XInput2.h> |
454 | -#include <X11/extensions/XI2proto.h> |
455 | - |
456 | -using QTest::QTouchEventSequence; |
457 | - |
458 | -namespace { |
459 | -MouseTouchAdaptor *g_instance = nullptr; |
460 | - |
461 | -const Qt::KeyboardModifiers TRI_PRESS_MODIFIER = Qt::ShiftModifier|Qt::ControlModifier|Qt::AltModifier; |
462 | -const Qt::KeyboardModifiers QUAD_PRESS_MODIFIER = TRI_PRESS_MODIFIER|Qt::MetaModifier; |
463 | - |
464 | -Qt::MouseButton translateMouseButton(xcb_button_t detail) |
465 | -{ |
466 | - switch (detail) { |
467 | - case 1: return Qt::LeftButton; |
468 | - case 2: return Qt::MidButton; |
469 | - case 3: return Qt::RightButton; |
470 | - // Button values 4-7 are Wheel events |
471 | - default: return Qt::NoButton; |
472 | - } |
473 | -} |
474 | - |
475 | -Qt::KeyboardModifiers translateMofidier(uint32_t mod) |
476 | -{ |
477 | - Qt::KeyboardModifiers qtMod = Qt::NoModifier; |
478 | - |
479 | - if (mod & 0x01) qtMod |= Qt::ShiftModifier; |
480 | - if (mod & 0x04) qtMod |= Qt::ControlModifier; |
481 | - if (mod & 0x08) qtMod |= Qt::AltModifier; |
482 | - if (mod & 0x40) qtMod |= Qt::MetaModifier; |
483 | - |
484 | - return qtMod; |
485 | -} |
486 | -} // end of anonymous namespace |
487 | - |
488 | -MouseTouchAdaptor::MouseTouchAdaptor() |
489 | - : QObject(nullptr) |
490 | - , m_leftButtonIsPressed(false) |
491 | - , m_triPressModifier(false) |
492 | - , m_quadPressModifier(false) |
493 | - , m_enabled(true) |
494 | -{ |
495 | - QCoreApplication::instance()->installNativeEventFilter(this); |
496 | - |
497 | - m_touchDevice = new QTouchDevice; |
498 | - m_touchDevice->setType(QTouchDevice::TouchScreen); |
499 | - QWindowSystemInterface::registerTouchDevice(m_touchDevice); |
500 | - |
501 | - fetchXInput2Info(); |
502 | -} |
503 | - |
504 | -MouseTouchAdaptor::~MouseTouchAdaptor() |
505 | -{ |
506 | - g_instance = nullptr; |
507 | -} |
508 | - |
509 | -MouseTouchAdaptor* MouseTouchAdaptor::instance() |
510 | -{ |
511 | - if (!g_instance) { |
512 | - g_instance = new MouseTouchAdaptor; |
513 | - } |
514 | - |
515 | - return g_instance; |
516 | -} |
517 | - |
518 | -void MouseTouchAdaptor::fetchXInput2Info() |
519 | -{ |
520 | - QPlatformNativeInterface *nativeInterface = qGuiApp->platformNativeInterface(); |
521 | - Display *xDisplay = static_cast<Display*>(nativeInterface->nativeResourceForIntegration("Display")); |
522 | - if (xDisplay && XQueryExtension(xDisplay, "XInputExtension", &m_xiOpCode, &m_xiEventBase, &m_xiErrorBase)) { |
523 | - int xiMajor = 2; |
524 | - m_xi2Minor = 2; // try 2.2 first, needed for TouchBegin/Update/End |
525 | - if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == BadRequest) { |
526 | - m_xi2Minor = 1; // for smooth scrolling 2.1 is enough |
527 | - if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == BadRequest) { |
528 | - m_xi2Minor = 0; // for tablet support 2.0 is enough |
529 | - m_xi2Enabled = XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) != BadRequest; |
530 | - } else |
531 | - m_xi2Enabled = true; |
532 | - } else { |
533 | - m_xi2Enabled = true; |
534 | - } |
535 | - } |
536 | -} |
537 | - |
538 | -// Starting from the xcb version 1.9.3 struct xcb_ge_event_t has changed: |
539 | -// - "pad0" became "extension" |
540 | -// - "pad1" and "pad" became "pad0" |
541 | -// New and old version of this struct share the following fields: |
542 | -// NOTE: API might change again in the next release of xcb in which case this comment will |
543 | -// need to be updated to reflect the reality. |
544 | -typedef struct qt_xcb_ge_event_t { |
545 | - uint8_t response_type; |
546 | - uint8_t extension; |
547 | - uint16_t sequence; |
548 | - uint32_t length; |
549 | - uint16_t event_type; |
550 | -} qt_xcb_ge_event_t; |
551 | - |
552 | -bool xi2PrepareXIGenericDeviceEvent(xcb_ge_event_t *ev, int opCode) |
553 | -{ |
554 | - qt_xcb_ge_event_t *event = (qt_xcb_ge_event_t *)ev; |
555 | - // xGenericEvent has "extension" on the second byte, the same is true for xcb_ge_event_t starting from |
556 | - // the xcb version 1.9.3, prior to that it was called "pad0". |
557 | - if (event->extension == opCode) { |
558 | - // xcb event structs contain stuff that wasn't on the wire, the full_sequence field |
559 | - // adds an extra 4 bytes and generic events cookie data is on the wire right after the standard 32 bytes. |
560 | - // Move this data back to have the same layout in memory as it was on the wire |
561 | - // and allow casting, overwriting the full_sequence field. |
562 | - memmove((char*) event + 32, (char*) event + 36, event->length * 4); |
563 | - return true; |
564 | - } |
565 | - return false; |
566 | -} |
567 | - |
568 | -static inline qreal fixed1616ToReal(FP1616 val) |
569 | -{ |
570 | - return qreal(val) / 0x10000; |
571 | -} |
572 | - |
573 | -bool MouseTouchAdaptor::xi2HandleEvent(xcb_ge_event_t *event) |
574 | -{ |
575 | - if (!xi2PrepareXIGenericDeviceEvent(event, m_xiOpCode)) { |
576 | - return false; |
577 | - } |
578 | - |
579 | - xXIGenericDeviceEvent *xiEvent = reinterpret_cast<xXIGenericDeviceEvent *>(event); |
580 | - xXIDeviceEvent *xiDeviceEvent = 0; |
581 | - |
582 | - switch (xiEvent->evtype) { |
583 | - case XI_ButtonPress: |
584 | - case XI_ButtonRelease: |
585 | - case XI_Motion: |
586 | - xiDeviceEvent = reinterpret_cast<xXIDeviceEvent *>(event); |
587 | - break; |
588 | - default: |
589 | - break; |
590 | - } |
591 | - |
592 | - if (!xiDeviceEvent) { |
593 | - return false; |
594 | - } |
595 | - |
596 | - switch (xiDeviceEvent->evtype) { |
597 | - case XI_ButtonPress: |
598 | - return handleButtonPress( |
599 | - static_cast<WId>(xiDeviceEvent->event), |
600 | - xiDeviceEvent->detail, |
601 | - xiDeviceEvent->mods.base_mods, |
602 | - fixed1616ToReal(xiDeviceEvent->event_x), |
603 | - fixed1616ToReal(xiDeviceEvent->event_y)); |
604 | - case XI_ButtonRelease: |
605 | - return handleButtonRelease( |
606 | - static_cast<WId>(xiDeviceEvent->event), |
607 | - xiDeviceEvent->detail, |
608 | - xiDeviceEvent->mods.base_mods, |
609 | - fixed1616ToReal(xiDeviceEvent->event_x), |
610 | - fixed1616ToReal(xiDeviceEvent->event_y)); |
611 | - case XI_Motion: |
612 | - return handleMotionNotify( |
613 | - static_cast<WId>(xiDeviceEvent->event), |
614 | - xiDeviceEvent->mods.base_mods, |
615 | - fixed1616ToReal(xiDeviceEvent->event_x), |
616 | - fixed1616ToReal(xiDeviceEvent->event_y)); |
617 | - return true; |
618 | - default: |
619 | - return false; |
620 | - } |
621 | -} |
622 | - |
623 | - |
624 | -bool MouseTouchAdaptor::nativeEventFilter(const QByteArray & eventType, |
625 | - void * message, long * /*result*/) |
626 | -{ |
627 | - static int eventCount = 0; |
628 | - eventCount++; |
629 | - if (!m_enabled) { |
630 | - return false; |
631 | - } |
632 | - |
633 | - if (eventType != "xcb_generic_event_t") { |
634 | - // wrong backend. |
635 | - qWarning("MouseTouchAdaptor: XCB backend not in use. Adaptor inoperative!"); |
636 | - return false; |
637 | - } |
638 | - |
639 | - xcb_generic_event_t *xcbEvent = static_cast<xcb_generic_event_t *>(message); |
640 | - |
641 | - switch (xcbEvent->response_type & ~0x80) { |
642 | - case XCB_BUTTON_PRESS: { |
643 | - auto pressEvent = reinterpret_cast<xcb_button_press_event_t *>(xcbEvent); |
644 | - return handleButtonPress(static_cast<WId>(pressEvent->event), pressEvent->detail, 0, |
645 | - pressEvent->event_x, pressEvent->event_y); |
646 | - } |
647 | - case XCB_BUTTON_RELEASE: { |
648 | - auto releaseEvent = reinterpret_cast<xcb_button_release_event_t *>(xcbEvent); |
649 | - return handleButtonRelease(static_cast<WId>(releaseEvent->event), releaseEvent->detail, 0, |
650 | - releaseEvent->event_x, releaseEvent->event_y); |
651 | - } |
652 | - case XCB_MOTION_NOTIFY: { |
653 | - auto motionEvent = reinterpret_cast<xcb_motion_notify_event_t *>(xcbEvent); |
654 | - return handleMotionNotify(static_cast<WId>(motionEvent->event), 0, |
655 | - motionEvent->event_x, motionEvent->event_y); |
656 | - } |
657 | - case XCB_GE_GENERIC: |
658 | - if (m_xi2Enabled) { |
659 | - return xi2HandleEvent(reinterpret_cast<xcb_ge_event_t *>(xcbEvent)); |
660 | - } else { |
661 | - return false; |
662 | - } |
663 | - default: |
664 | - return false; |
665 | - }; |
666 | -} |
667 | - |
668 | -bool MouseTouchAdaptor::handleButtonPress(WId windowId, uint32_t detail, uint32_t modifiers, int x, int y) |
669 | -{ |
670 | - Qt::MouseButton button = translateMouseButton(detail); |
671 | - Qt::KeyboardModifiers qtMod = translateMofidier(modifiers); |
672 | - |
673 | - // Just eat the event if it wasn't a left mouse press |
674 | - if (button != Qt::LeftButton) |
675 | - return true; |
676 | - |
677 | - QWindow *targetWindow = findQWindowWithXWindowID(windowId); |
678 | - |
679 | - QPoint windowPos(x / targetWindow->devicePixelRatio(), y / targetWindow->devicePixelRatio()); |
680 | - |
681 | - QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice, |
682 | - false /* autoCommit */); |
683 | - touchEvent.press(0 /* touchId */, windowPos); |
684 | - if (qtMod == TRI_PRESS_MODIFIER) { |
685 | - touchEvent.press(1, windowPos); |
686 | - touchEvent.press(2, windowPos); |
687 | - m_triPressModifier = true; |
688 | - } |
689 | - if (qtMod == QUAD_PRESS_MODIFIER) { |
690 | - touchEvent.press(1, windowPos); |
691 | - touchEvent.press(2, windowPos); |
692 | - touchEvent.press(3, windowPos); |
693 | - m_quadPressModifier = true; |
694 | - } |
695 | - |
696 | - touchEvent.commit(false /* processEvents */); |
697 | - |
698 | - m_leftButtonIsPressed = true; |
699 | - return true; |
700 | -} |
701 | - |
702 | -bool MouseTouchAdaptor::handleButtonRelease(WId windowId, uint32_t detail, uint32_t, int x, int y) |
703 | -{ |
704 | - Qt::MouseButton button = translateMouseButton(detail); |
705 | - |
706 | - // Don't eat the event if it wasn't a left mouse press |
707 | - if (button != Qt::LeftButton) |
708 | - return false; |
709 | - |
710 | - QWindow *targetWindow = findQWindowWithXWindowID(windowId); |
711 | - |
712 | - QPoint windowPos(x / targetWindow->devicePixelRatio(), y / targetWindow->devicePixelRatio()); |
713 | - |
714 | - QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice, |
715 | - false /* autoCommit */); |
716 | - touchEvent.release(0 /* touchId */, windowPos); |
717 | - if (m_triPressModifier) { |
718 | - touchEvent.release(1, windowPos); |
719 | - touchEvent.release(2, windowPos); |
720 | - } |
721 | - if (m_quadPressModifier) { |
722 | - touchEvent.release(1, windowPos); |
723 | - touchEvent.release(2, windowPos); |
724 | - touchEvent.release(3, windowPos); |
725 | - } |
726 | - touchEvent.commit(false /* processEvents */); |
727 | - |
728 | - m_leftButtonIsPressed = false; |
729 | - m_triPressModifier = false; |
730 | - m_quadPressModifier = false; |
731 | - return true; |
732 | -} |
733 | - |
734 | -bool MouseTouchAdaptor::handleMotionNotify(WId windowId, uint32_t modifiers, int x, int y) |
735 | -{ |
736 | - if (!m_leftButtonIsPressed) { |
737 | - return true; |
738 | - } |
739 | - Qt::KeyboardModifiers qtMod = translateMofidier(modifiers); |
740 | - |
741 | - QWindow *targetWindow = findQWindowWithXWindowID(windowId); |
742 | - |
743 | - QPoint windowPos(x / targetWindow->devicePixelRatio(), y / targetWindow->devicePixelRatio()); |
744 | - |
745 | - QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice, |
746 | - false /* autoCommit */); |
747 | - touchEvent.move(0 /* touchId */, windowPos); |
748 | - if (m_triPressModifier) { |
749 | - if (qtMod == TRI_PRESS_MODIFIER) { |
750 | - touchEvent.move(1, windowPos); |
751 | - touchEvent.move(2, windowPos); |
752 | - } else { |
753 | - // released modifiers |
754 | - touchEvent.release(1, windowPos); |
755 | - touchEvent.release(2, windowPos); |
756 | - m_triPressModifier = false; |
757 | - } |
758 | - } |
759 | - if (m_quadPressModifier) { |
760 | - if (qtMod == QUAD_PRESS_MODIFIER) { |
761 | - touchEvent.move(1, windowPos); |
762 | - touchEvent.move(2, windowPos); |
763 | - touchEvent.move(3, windowPos); |
764 | - } else { |
765 | - touchEvent.release(1, windowPos); |
766 | - touchEvent.release(2, windowPos); |
767 | - touchEvent.release(3, windowPos); |
768 | - m_quadPressModifier = false; |
769 | - } |
770 | - } |
771 | - touchEvent.commit(false /* processEvents */); |
772 | - |
773 | - return true; |
774 | -} |
775 | - |
776 | -QWindow *MouseTouchAdaptor::findQWindowWithXWindowID(WId windowId) |
777 | -{ |
778 | - QWindowList windowList = QGuiApplication::topLevelWindows(); |
779 | - QWindow *foundWindow = nullptr; |
780 | - |
781 | - int i = 0; |
782 | - while (!foundWindow && i < windowList.count()) { |
783 | - QWindow *window = windowList[i]; |
784 | - if (window->winId() == windowId) { |
785 | - foundWindow = window; |
786 | - } else { |
787 | - ++i; |
788 | - } |
789 | - } |
790 | - |
791 | - Q_ASSERT(foundWindow); |
792 | - return foundWindow; |
793 | -} |
794 | - |
795 | -bool MouseTouchAdaptor::enabled() const |
796 | -{ |
797 | - return m_enabled; |
798 | -} |
799 | - |
800 | -void MouseTouchAdaptor::setEnabled(bool value) |
801 | -{ |
802 | - if (value != m_enabled) { |
803 | - m_enabled = value; |
804 | - Q_EMIT enabledChanged(value); |
805 | - } |
806 | -} |
807 | |
808 | === removed file 'src/MouseTouchAdaptor.h' |
809 | --- src/MouseTouchAdaptor.h 2017-01-17 14:20:54 +0000 |
810 | +++ src/MouseTouchAdaptor.h 1970-01-01 00:00:00 +0000 |
811 | @@ -1,72 +0,0 @@ |
812 | -/* |
813 | - * Copyright (C) 2013,2015 Canonical, Ltd. |
814 | - * |
815 | - * This program is free software; you can redistribute it and/or modify |
816 | - * it under the terms of the GNU General Public License as published by |
817 | - * the Free Software Foundation; version 3. |
818 | - * |
819 | - * This program is distributed in the hope that it will be useful, |
820 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
821 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
822 | - * GNU General Public License for more details. |
823 | - * |
824 | - * You should have received a copy of the GNU General Public License |
825 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
826 | - * |
827 | - * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> |
828 | - */ |
829 | - |
830 | -#ifndef MOUSE_TOUCH_ADAPTOR_H |
831 | -#define MOUSE_TOUCH_ADAPTOR_H |
832 | - |
833 | -#include <QtCore/QAbstractNativeEventFilter> |
834 | -#include <QWindow> |
835 | - |
836 | -#include <xcb/xcb.h> |
837 | - |
838 | -class QMouseEvent; |
839 | -class QTouchDevice; |
840 | - |
841 | -// Transforms QMouseEvents into single-finger QTouchEvents. |
842 | -class MouseTouchAdaptor : public QObject, public QAbstractNativeEventFilter { |
843 | - Q_OBJECT |
844 | -public: |
845 | - virtual ~MouseTouchAdaptor(); |
846 | - |
847 | - static MouseTouchAdaptor* instance(); |
848 | - |
849 | - // Filters mouse events and posts the equivalent QTouchEvents. |
850 | - bool nativeEventFilter(const QByteArray & eventType, void *message, long *result) override; |
851 | - |
852 | - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) |
853 | - |
854 | - bool enabled() const; |
855 | - void setEnabled(bool value); |
856 | - |
857 | -Q_SIGNALS: |
858 | - void enabledChanged(bool value); |
859 | - |
860 | -private: |
861 | - MouseTouchAdaptor(); |
862 | - void fetchXInput2Info(); |
863 | - bool xi2HandleEvent(xcb_ge_event_t *event); |
864 | - |
865 | - bool handleButtonPress(WId windowId, uint32_t detail, uint32_t modifiers, int x, int y); |
866 | - bool handleButtonRelease(WId windowId, uint32_t detail, uint32_t modifiers, int x, int y); |
867 | - bool handleMotionNotify(WId windowId, uint32_t modifiers, int x, int y); |
868 | - QWindow *findQWindowWithXWindowID(WId windowId); |
869 | - |
870 | - QTouchDevice *m_touchDevice; |
871 | - bool m_leftButtonIsPressed; |
872 | - bool m_triPressModifier; |
873 | - bool m_quadPressModifier; |
874 | - |
875 | - |
876 | - bool m_enabled; |
877 | - |
878 | - bool m_xi2Enabled{false}; |
879 | - int m_xi2Minor{-1}; |
880 | - int m_xiOpCode, m_xiEventBase, m_xiErrorBase; |
881 | -}; |
882 | - |
883 | -#endif // MOUSE_TOUCH_ADAPTOR_H |
884 | |
885 | === modified file 'src/ShellApplication.cpp' |
886 | --- src/ShellApplication.cpp 2017-01-10 14:46:22 +0000 |
887 | +++ src/ShellApplication.cpp 2017-02-23 19:04:58 +0000 |
888 | @@ -40,7 +40,7 @@ |
889 | |
890 | connect(this, &QGuiApplication::screenAdded, this, &ShellApplication::onScreenAdded); |
891 | |
892 | - setupQmlEngine(isMirServer); |
893 | + setupQmlEngine(); |
894 | |
895 | UnityCommandLineParser parser(*this); |
896 | |
897 | @@ -86,15 +86,6 @@ |
898 | m_shellView->setFlags(Qt::FramelessWindowHint); |
899 | } |
900 | |
901 | - |
902 | - #ifdef UNITY8_ENABLE_TOUCH_EMULATION |
903 | - // You will need this if you want to interact with touch-only components using a mouse |
904 | - // Needed only when manually testing on a desktop. |
905 | - if (parser.hasMouseToTouch()) { |
906 | - m_mouseTouchAdaptor = MouseTouchAdaptor::instance(); |
907 | - } |
908 | - #endif |
909 | - |
910 | new DebuggingController(this); |
911 | |
912 | // Some hard-coded policy for now. |
913 | @@ -144,25 +135,17 @@ |
914 | delete m_secondaryWindow; |
915 | m_secondaryWindow = nullptr; |
916 | |
917 | - #ifdef UNITY8_ENABLE_TOUCH_EMULATION |
918 | - delete m_mouseTouchAdaptor; |
919 | - m_mouseTouchAdaptor = nullptr; |
920 | - #endif |
921 | - |
922 | delete m_qmlEngine; |
923 | m_qmlEngine = nullptr; |
924 | } |
925 | |
926 | -void ShellApplication::setupQmlEngine(bool isMirServer) |
927 | +void ShellApplication::setupQmlEngine() |
928 | { |
929 | m_qmlEngine = new QQmlEngine(this); |
930 | |
931 | m_qmlEngine->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory())); |
932 | |
933 | prependImportPaths(m_qmlEngine, ::overrideImportPaths()); |
934 | - if (!isMirServer) { |
935 | - prependImportPaths(m_qmlEngine, ::nonMirImportPaths()); |
936 | - } |
937 | appendImportPaths(m_qmlEngine, ::fallbackImportPaths()); |
938 | |
939 | m_qmlEngine->setNetworkAccessManagerFactory(new CachingNetworkManagerFactory); |
940 | |
941 | === modified file 'src/ShellApplication.h' |
942 | --- src/ShellApplication.h 2015-12-16 13:58:39 +0000 |
943 | +++ src/ShellApplication.h 2017-02-23 19:04:58 +0000 |
944 | @@ -24,10 +24,6 @@ |
945 | |
946 | #include "ApplicationArguments.h" |
947 | |
948 | -#ifdef UNITY8_ENABLE_TOUCH_EMULATION |
949 | -#include "MouseTouchAdaptor.h" |
950 | -#endif |
951 | - |
952 | #include "SecondaryWindow.h" |
953 | #include "ShellView.h" |
954 | |
955 | @@ -47,16 +43,12 @@ |
956 | void onScreenAdded(QScreen*); |
957 | |
958 | private: |
959 | - void setupQmlEngine(bool isMirServer); |
960 | + void setupQmlEngine(); |
961 | QString m_deviceName; |
962 | ApplicationArguments m_qmlArgs; |
963 | ShellView *m_shellView{nullptr}; |
964 | SecondaryWindow *m_secondaryWindow{nullptr}; |
965 | |
966 | - #ifdef UNITY8_ENABLE_TOUCH_EMULATION |
967 | - MouseTouchAdaptor *m_mouseTouchAdaptor{nullptr}; |
968 | - #endif |
969 | - |
970 | QQmlEngine *m_qmlEngine{nullptr}; |
971 | }; |
972 | |
973 | |
974 | === modified file 'src/UnityCommandLineParser.cpp' |
975 | --- src/UnityCommandLineParser.cpp 2015-12-16 13:58:39 +0000 |
976 | +++ src/UnityCommandLineParser.cpp 2017-02-23 19:04:58 +0000 |
977 | @@ -37,12 +37,6 @@ |
978 | QStringLiteral("Run without window borders")); |
979 | parser.addOption(framelessOption); |
980 | |
981 | - #ifdef UNITY8_ENABLE_TOUCH_EMULATION |
982 | - QCommandLineOption mousetouchOption(QStringLiteral("mousetouch"), |
983 | - QStringLiteral("Allow the mouse to provide touch input")); |
984 | - parser.addOption(mousetouchOption); |
985 | - #endif |
986 | - |
987 | QCommandLineOption windowGeometryOption(QStringList() << QStringLiteral("windowgeometry"), |
988 | QStringLiteral("Specify the window geometry as [<width>x<height>]"), QStringLiteral("windowgeometry"), QStringLiteral("1")); |
989 | parser.addOption(windowGeometryOption); |
990 | @@ -78,10 +72,6 @@ |
991 | m_hasTestability = parser.isSet(testabilityOption); |
992 | m_hasFrameless = parser.isSet(framelessOption); |
993 | |
994 | - #ifdef UNITY8_ENABLE_TOUCH_EMULATION |
995 | - m_hasMouseToTouch = parser.isSet(mousetouchOption); |
996 | - #endif |
997 | - |
998 | m_hasFullscreen = parser.isSet(fullscreenOption); |
999 | m_deviceName = parser.value(devicenameOption); |
1000 | resolveMode(parser, modeOption); |
1001 | |
1002 | === modified file 'src/UnityCommandLineParser.h' |
1003 | --- src/UnityCommandLineParser.h 2015-12-16 13:58:39 +0000 |
1004 | +++ src/UnityCommandLineParser.h 2017-02-23 19:04:58 +0000 |
1005 | @@ -29,10 +29,6 @@ |
1006 | bool hasTestability() const { return m_hasTestability; } |
1007 | bool hasFrameless() const { return m_hasFrameless; } |
1008 | |
1009 | - #ifdef UNITY8_ENABLE_TOUCH_EMULATION |
1010 | - bool hasMouseToTouch() const { return m_hasMouseToTouch; } |
1011 | - #endif |
1012 | - |
1013 | bool hasFullscreen() const { return m_hasFullscreen; } |
1014 | QString deviceName() const { return m_deviceName; } |
1015 | QString mode() const { return m_mode; } |
1016 | @@ -48,10 +44,6 @@ |
1017 | bool m_hasTestability; |
1018 | bool m_hasFrameless; |
1019 | |
1020 | - #ifdef UNITY8_ENABLE_TOUCH_EMULATION |
1021 | - bool m_hasMouseToTouch; |
1022 | - #endif |
1023 | - |
1024 | bool m_hasFullscreen; |
1025 | QString m_deviceName; |
1026 | QString m_mode; |
1027 | |
1028 | === modified file 'tests/CMakeLists.txt' |
1029 | --- tests/CMakeLists.txt 2017-01-24 07:43:35 +0000 |
1030 | +++ tests/CMakeLists.txt 2017-02-23 19:04:58 +0000 |
1031 | @@ -77,7 +77,7 @@ |
1032 | ) |
1033 | endfunction() |
1034 | |
1035 | -# add a graphical unit test |
1036 | +# add a graphical unit test running as a regular GUI app |
1037 | function(add_unity8_uitest COMPONENT_NAME TARGET) |
1038 | unity8_parse_arguments(${ARGN}) |
1039 | add_executable_test(${COMPONENT_NAME} ${TARGET} |
1040 | @@ -103,7 +103,7 @@ |
1041 | ) |
1042 | endfunction() |
1043 | |
1044 | -# add a graphical qml test |
1045 | +# add a graphical qml test running as a mir server |
1046 | function(add_unity8_qmltest PATH COMPONENT_NAME) |
1047 | unity8_parse_arguments(${ARGN}) |
1048 | add_qml_test(${PATH} ${COMPONENT_NAME} |
1049 | @@ -111,6 +111,19 @@ |
1050 | TARGETS uitests |
1051 | ${U8TEST_ARGN} |
1052 | ENVIRONMENT ${environment} |
1053 | + QT_QPA_PLATFORM=mirserver |
1054 | + ${U8TEST_ENVIRONMENT} |
1055 | + ) |
1056 | +endfunction() |
1057 | + |
1058 | +# add a graphical qml test running as a regular application in the host system |
1059 | +function(add_unity8_simpleqmltest PATH COMPONENT_NAME) |
1060 | + unity8_parse_arguments(${ARGN}) |
1061 | + add_qml_test(${PATH} ${COMPONENT_NAME} |
1062 | + IMPORT_PATHS ${UNITY_IMPORT_PATHS} |
1063 | + TARGETS uitests |
1064 | + ${U8TEST_ARGN} |
1065 | + ENVIRONMENT ${environment} |
1066 | ${U8TEST_ENVIRONMENT} |
1067 | ) |
1068 | endfunction() |
1069 | |
1070 | === modified file 'tests/autopilot/unity8/shell/tests/__init__.py' |
1071 | --- tests/autopilot/unity8/shell/tests/__init__.py 2016-12-19 19:55:07 +0000 |
1072 | +++ tests/autopilot/unity8/shell/tests/__init__.py 2017-02-23 19:04:58 +0000 |
1073 | @@ -149,7 +149,6 @@ |
1074 | '-windowgeometry', |
1075 | geo_string, |
1076 | '-frameless', |
1077 | - '-mousetouch' |
1078 | ] |
1079 | return scale_divisor |
1080 | |
1081 | |
1082 | === modified file 'tests/mocks/Cursor/CMakeLists.txt' |
1083 | --- tests/mocks/Cursor/CMakeLists.txt 2016-12-06 20:16:56 +0000 |
1084 | +++ tests/mocks/Cursor/CMakeLists.txt 2017-02-23 19:04:58 +0000 |
1085 | @@ -1,1 +1,34 @@ |
1086 | -add_unity8_mock(Cursor 1.1 Cursor) |
1087 | +include_directories( |
1088 | + ${CMAKE_CURRENT_SOURCE_DIR} |
1089 | + ${CMAKE_SOURCE_DIR}/plugins/Cursor/3rd_party/xcursor |
1090 | + ${CMAKE_SOURCE_DIR}/plugins/Cursor/ |
1091 | +) |
1092 | + |
1093 | +include_directories( |
1094 | + SYSTEM |
1095 | + ${Qt5Gui_PRIVATE_INCLUDE_DIRS} |
1096 | +) |
1097 | + |
1098 | +set(QMLPLUGIN_SRC |
1099 | + plugin.cpp |
1100 | + WindowedMousePointer.cpp |
1101 | + ${CMAKE_SOURCE_DIR}/plugins/Cursor/CursorImageInfo.cpp |
1102 | + ${CMAKE_SOURCE_DIR}/plugins/Cursor/CursorImageProvider.cpp |
1103 | + ${CMAKE_SOURCE_DIR}/plugins/Cursor/MousePointer.cpp |
1104 | + # We need to run moc on this header |
1105 | + ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirMousePointerInterface.h |
1106 | + ) |
1107 | + |
1108 | +add_library(WindowedCursor-qml SHARED ${QMLPLUGIN_SRC}) |
1109 | + |
1110 | +target_link_libraries(WindowedCursor-qml |
1111 | + xcursorloader-static |
1112 | + ${QT5PLATFORM_SUPPORT_LDFLAGS} |
1113 | +) |
1114 | + |
1115 | +qt5_use_modules(WindowedCursor-qml Qml Quick Svg) |
1116 | + |
1117 | +# It takes Cursor.qml directly from the production Cursor plugin. We use our own qmldir file though, hence |
1118 | +# the custom globbing expression. |
1119 | +add_unity8_mock(Cursor 1.1 Cursor |
1120 | + GLOBBING_EXPRESSIONS ${CMAKE_CURRENT_SOURCE_DIR}/qmldir ${CMAKE_SOURCE_DIR}/plugins/Cursor/*.qml) |
1121 | |
1122 | === removed file 'tests/mocks/Cursor/Cursor.qml' |
1123 | --- tests/mocks/Cursor/Cursor.qml 2016-10-03 11:15:27 +0000 |
1124 | +++ tests/mocks/Cursor/Cursor.qml 1970-01-01 00:00:00 +0000 |
1125 | @@ -1,34 +0,0 @@ |
1126 | -/* |
1127 | - * Copyright (C) 2015-2016 Canonical, Ltd. |
1128 | - * |
1129 | - * This program is free software; you can redistribute it and/or modify |
1130 | - * it under the terms of the GNU General Public License as published by |
1131 | - * the Free Software Foundation; version 3. |
1132 | - * |
1133 | - * This program is distributed in the hope that it will be useful, |
1134 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1135 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1136 | - * GNU General Public License for more details. |
1137 | - * |
1138 | - * You should have received a copy of the GNU General Public License |
1139 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1140 | - */ |
1141 | - |
1142 | -import QtQuick 2.4 |
1143 | - |
1144 | -Item { |
1145 | - property int topBoundaryOffset // effectively panel height |
1146 | - property Item confiningItem |
1147 | - |
1148 | - signal pushedLeftBoundary(real amount, int buttons) |
1149 | - signal pushedRightBoundary(real amount, int buttons) |
1150 | - signal pushedTopBoundary(real amount, int buttons) |
1151 | - signal pushedTopLeftCorner(real amount, int buttons) |
1152 | - signal pushedTopRightCorner(real amount, int buttons) |
1153 | - signal pushedBottomLeftCorner(real amount, int buttons) |
1154 | - signal pushedBottomRightCorner(real amount, int buttons) |
1155 | - signal pushStopped() |
1156 | - signal mouseMoved() |
1157 | - |
1158 | - onMouseMoved: opacity = 1; |
1159 | -} |
1160 | |
1161 | === added file 'tests/mocks/Cursor/WindowedMousePointer.cpp' |
1162 | --- tests/mocks/Cursor/WindowedMousePointer.cpp 1970-01-01 00:00:00 +0000 |
1163 | +++ tests/mocks/Cursor/WindowedMousePointer.cpp 2017-02-23 19:04:58 +0000 |
1164 | @@ -0,0 +1,62 @@ |
1165 | +/* |
1166 | + * Copyright (C) 2017 Canonical, Ltd. |
1167 | + * |
1168 | + * This program is free software: you can redistribute it and/or modify it under |
1169 | + * the terms of the GNU Lesser General Public License version 3, as published by |
1170 | + * the Free Software Foundation. |
1171 | + * |
1172 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
1173 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
1174 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1175 | + * Lesser General Public License for more details. |
1176 | + * |
1177 | + * You should have received a copy of the GNU Lesser General Public License |
1178 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1179 | + */ |
1180 | + |
1181 | +#include "WindowedMousePointer.h" |
1182 | + |
1183 | +// Qt |
1184 | +#include <qpa/qwindowsysteminterface.h> |
1185 | +#include <QQuickWindow> |
1186 | + |
1187 | +void WindowedMousePointer::handleMouseEvent(ulong timestamp, QPointF movement, QPointF position, Qt::MouseButtons buttons, |
1188 | + Qt::KeyboardModifiers modifiers) |
1189 | +{ |
1190 | + if (!parentItem()) { |
1191 | + return; |
1192 | + } |
1193 | + |
1194 | + if (!movement.isNull()) { |
1195 | + Q_EMIT mouseMoved(); |
1196 | + } |
1197 | + |
1198 | + if (modifiers.testFlag(Qt::ShiftModifier)) { |
1199 | + // put it back within shell bounds |
1200 | + if (m_wasMatchingPosition) { |
1201 | + setX(qBound(0.0, x(), parentItem()->width() - 1)); |
1202 | + setY(qBound(0.0, y(), parentItem()->height() - 1)); |
1203 | + } |
1204 | + |
1205 | + // Behave just like the real mouse in production which will do edge pushes, will be |
1206 | + // constrained to scene boundaries and obeys item confinement. Useful for testing such features. |
1207 | + applyMouseMovement(timestamp, movement, buttons, modifiers); |
1208 | + |
1209 | + m_wasMatchingPosition = false; |
1210 | + } else { |
1211 | + // Blindly follow host mouse pointer. Can go outside shell item boundaries, which is needed to reach the test UI controls |
1212 | + // since they lie outside it. |
1213 | + // It's also more intuitive as the tester expects the shell mouse to be where the host mouse is no matter what. |
1214 | + matchMousePosition(timestamp, position, buttons, modifiers); |
1215 | + } |
1216 | + |
1217 | +} |
1218 | + |
1219 | +void WindowedMousePointer::matchMousePosition(ulong timestamp, QPointF position, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) |
1220 | +{ |
1221 | + QPointF localPos = parentItem()->mapFromScene(position); |
1222 | + setX(localPos.x()); |
1223 | + setY(localPos.y()); |
1224 | + m_wasMatchingPosition = true; |
1225 | + QWindowSystemInterface::handleMouseEvent(window(), timestamp, position /*local*/, position /*global*/, buttons, modifiers); |
1226 | +} |
1227 | |
1228 | === added file 'tests/mocks/Cursor/WindowedMousePointer.h' |
1229 | --- tests/mocks/Cursor/WindowedMousePointer.h 1970-01-01 00:00:00 +0000 |
1230 | +++ tests/mocks/Cursor/WindowedMousePointer.h 2017-02-23 19:04:58 +0000 |
1231 | @@ -0,0 +1,35 @@ |
1232 | +/* |
1233 | + * Copyright (C) 2017 Canonical, Ltd. |
1234 | + * |
1235 | + * This program is free software: you can redistribute it and/or modify it under |
1236 | + * the terms of the GNU Lesser General Public License version 3, as published by |
1237 | + * the Free Software Foundation. |
1238 | + * |
1239 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
1240 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
1241 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1242 | + * Lesser General Public License for more details. |
1243 | + * |
1244 | + * You should have received a copy of the GNU Lesser General Public License |
1245 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1246 | + */ |
1247 | + |
1248 | +#ifndef WINDOWED_MOUSE_POINTER_H |
1249 | +#define WINDOWED_MOUSE_POINTER_H |
1250 | + |
1251 | +// From the real Cursor plugin |
1252 | +#include <MousePointer.h> |
1253 | + |
1254 | +class WindowedMousePointer : public MousePointer { |
1255 | + Q_OBJECT |
1256 | +public: |
1257 | +public Q_SLOTS: |
1258 | + void handleMouseEvent(ulong timestamp, QPointF movement, QPointF position, Qt::MouseButtons buttons, |
1259 | + Qt::KeyboardModifiers modifiers) override; |
1260 | +private: |
1261 | + void matchMousePosition(ulong timestamp, QPointF position, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); |
1262 | + |
1263 | + bool m_wasMatchingPosition{false}; |
1264 | +}; |
1265 | + |
1266 | +#endif // WINDOWED_MOUSE_POINTER_H |
1267 | |
1268 | === added file 'tests/mocks/Cursor/plugin.cpp' |
1269 | --- tests/mocks/Cursor/plugin.cpp 1970-01-01 00:00:00 +0000 |
1270 | +++ tests/mocks/Cursor/plugin.cpp 2017-02-23 19:04:58 +0000 |
1271 | @@ -0,0 +1,43 @@ |
1272 | +/* |
1273 | + * Copyright (C) 2017 Canonical, Ltd. |
1274 | + * |
1275 | + * This program is free software; you can redistribute it and/or modify |
1276 | + * it under the terms of the GNU General Public License as published by |
1277 | + * the Free Software Foundation; version 3. |
1278 | + * |
1279 | + * This program is distributed in the hope that it will be useful, |
1280 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1281 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1282 | + * GNU General Public License for more details. |
1283 | + * |
1284 | + * You should have received a copy of the GNU General Public License |
1285 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1286 | + */ |
1287 | + |
1288 | +// Qt |
1289 | +#include <QtQml/qqml.h> |
1290 | +#include <QQmlContext> |
1291 | + |
1292 | +// self |
1293 | +#include "plugin.h" |
1294 | + |
1295 | +// from the real Cursor plugin |
1296 | +#include <CursorImageInfo.h> |
1297 | +#include <CursorImageProvider.h> |
1298 | + |
1299 | +// local |
1300 | +#include "WindowedMousePointer.h" |
1301 | + |
1302 | +void WindowedCursorPlugin::registerTypes(const char *uri) |
1303 | +{ |
1304 | + Q_ASSERT(uri == QLatin1String("Cursor")); |
1305 | + qmlRegisterType<CursorImageInfo>(uri, 1, 1, "CursorImageInfo"); |
1306 | + qmlRegisterType<WindowedMousePointer>(uri, 1, 1, "MousePointer"); |
1307 | +} |
1308 | + |
1309 | +void WindowedCursorPlugin::initializeEngine(QQmlEngine *engine, const char *uri) |
1310 | +{ |
1311 | + QQmlExtensionPlugin::initializeEngine(engine, uri); |
1312 | + |
1313 | + engine->addImageProvider(QStringLiteral("cursor"), new CursorImageProvider()); |
1314 | +} |
1315 | |
1316 | === added file 'tests/mocks/Cursor/plugin.h' |
1317 | --- tests/mocks/Cursor/plugin.h 1970-01-01 00:00:00 +0000 |
1318 | +++ tests/mocks/Cursor/plugin.h 2017-02-23 19:04:58 +0000 |
1319 | @@ -0,0 +1,33 @@ |
1320 | +/* |
1321 | + * Copyright (C) 2017 Canonical, Ltd. |
1322 | + * |
1323 | + * This program is free software; you can redistribute it and/or modify |
1324 | + * it under the terms of the GNU General Public License as published by |
1325 | + * the Free Software Foundation; version 3. |
1326 | + * |
1327 | + * This program is distributed in the hope that it will be useful, |
1328 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1329 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1330 | + * GNU General Public License for more details. |
1331 | + * |
1332 | + * You should have received a copy of the GNU General Public License |
1333 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1334 | + */ |
1335 | + |
1336 | +#ifndef WINDOWED_CURSOR_PLUGIN_H |
1337 | +#define WINDOWED_CURSOR_PLUGIN_H |
1338 | + |
1339 | +#include <QtQml/QQmlEngine> |
1340 | +#include <QtQml/QQmlExtensionPlugin> |
1341 | + |
1342 | +class WindowedCursorPlugin : public QQmlExtensionPlugin |
1343 | +{ |
1344 | + Q_OBJECT |
1345 | + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") |
1346 | + |
1347 | +public: |
1348 | + void registerTypes(const char *uri) override; |
1349 | + void initializeEngine(QQmlEngine *engine, const char *uri) override; |
1350 | +}; |
1351 | + |
1352 | +#endif // WINDOWED_CURSOR_PLUGIN_H |
1353 | |
1354 | === modified file 'tests/mocks/Cursor/qmldir' |
1355 | --- tests/mocks/Cursor/qmldir 2016-05-19 19:44:37 +0000 |
1356 | +++ tests/mocks/Cursor/qmldir 2017-02-23 19:04:58 +0000 |
1357 | @@ -1,2 +1,3 @@ |
1358 | module Cursor |
1359 | +plugin WindowedCursor-qml |
1360 | Cursor 1.1 Cursor.qml |
1361 | |
1362 | === removed file 'tests/mocks/Unity/Application/ApplicationInfo.cpp' |
1363 | --- tests/mocks/Unity/Application/ApplicationInfo.cpp 2017-01-26 11:10:01 +0000 |
1364 | +++ tests/mocks/Unity/Application/ApplicationInfo.cpp 1970-01-01 00:00:00 +0000 |
1365 | @@ -1,417 +0,0 @@ |
1366 | -/* |
1367 | - * Copyright (C) 2013-2016 Canonical, Ltd. |
1368 | - * |
1369 | - * This program is free software; you can redistribute it and/or modify |
1370 | - * it under the terms of the GNU General Public License as published by |
1371 | - * the Free Software Foundation; version 3. |
1372 | - * |
1373 | - * This program is distributed in the hope that it will be useful, |
1374 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1375 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1376 | - * GNU General Public License for more details. |
1377 | - * |
1378 | - * You should have received a copy of the GNU General Public License |
1379 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1380 | - */ |
1381 | - |
1382 | -#include "ApplicationInfo.h" |
1383 | -#include "MirSurface.h" |
1384 | -#include "SurfaceManager.h" |
1385 | - |
1386 | -#include <paths.h> |
1387 | - |
1388 | -#include <QGuiApplication> |
1389 | -#include <QQuickItem> |
1390 | -#include <QQuickView> |
1391 | -#include <QQmlComponent> |
1392 | - |
1393 | -#define APPLICATION_DEBUG 0 |
1394 | - |
1395 | -#if APPLICATION_DEBUG |
1396 | -#define DEBUG_MSG(params) qDebug().nospace() << "Application["<<appId()<<"]::" << __func__ << " " << params |
1397 | - |
1398 | -QString stateToStr(ApplicationInfo::State state) |
1399 | -{ |
1400 | - switch (state) { |
1401 | - case ApplicationInfo::Starting: |
1402 | - return "starting"; |
1403 | - case ApplicationInfo::Running: |
1404 | - return "running"; |
1405 | - case ApplicationInfo::Suspended: |
1406 | - return "suspended"; |
1407 | - case ApplicationInfo::Stopped: |
1408 | - return "stopped"; |
1409 | - default: |
1410 | - return "???"; |
1411 | - }; |
1412 | -} |
1413 | - |
1414 | -#else |
1415 | -#define DEBUG_MSG(params) ((void)0) |
1416 | -#endif |
1417 | - |
1418 | -#define WARNING_MSG(params) qWarning().nospace() << "Application["<<appId()<<"]::" << __func__ << " " << params |
1419 | - |
1420 | -ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent) |
1421 | - : ApplicationInfoInterface(appId, parent) |
1422 | - , m_appId(appId) |
1423 | - , m_surfaceList(new MirSurfaceListModel(this)) |
1424 | - , m_promptSurfaceList(new MirSurfaceListModel(this)) |
1425 | -{ |
1426 | - connect(m_surfaceList, &MirSurfaceListModel::countChanged, |
1427 | - this, &ApplicationInfo::onSurfaceCountChanged, Qt::QueuedConnection); |
1428 | - |
1429 | - m_surfaceCreationTimer.setSingleShot(true); |
1430 | - m_surfaceCreationTimer.setInterval(500); |
1431 | - connect(&m_surfaceCreationTimer, &QTimer::timeout, this, &ApplicationInfo::createSurface); |
1432 | -} |
1433 | - |
1434 | -ApplicationInfo::ApplicationInfo(QObject *parent) |
1435 | - : ApplicationInfo(QString(), parent) |
1436 | -{ |
1437 | -} |
1438 | - |
1439 | -ApplicationInfo::~ApplicationInfo() |
1440 | -{ |
1441 | -} |
1442 | - |
1443 | -void ApplicationInfo::createPromptSurface() |
1444 | -{ |
1445 | - if (state() == ApplicationInfo::Stopped) { return; } |
1446 | - |
1447 | - auto surfaceManager = SurfaceManager::instance(); |
1448 | - if (!surfaceManager) { |
1449 | - WARNING_MSG("No SurfaceManager"); |
1450 | - return; |
1451 | - } |
1452 | - |
1453 | - QStringList screenshotIds = {"gallery", "map", "facebook", "camera", "browser", "music", "twitter"}; |
1454 | - int i = rand() % screenshotIds.count(); |
1455 | - |
1456 | - QUrl screenshotUrl = QString("qrc:///Unity/Application/screenshots/%1@12.png") |
1457 | - .arg(screenshotIds[i]); |
1458 | - |
1459 | - auto surface = surfaceManager->createSurface(QString("prompt foo"), |
1460 | - Mir::NormalType, |
1461 | - Mir::RestoredState, |
1462 | - nullptr, /* parentSurface */ |
1463 | - screenshotUrl); |
1464 | - surfaceManager->notifySurfaceCreated(surface); |
1465 | - |
1466 | - m_promptSurfaceList->addSurface(surface); |
1467 | - |
1468 | - surfaceManager->activate(surface); |
1469 | -} |
1470 | - |
1471 | -void ApplicationInfo::createSurface() |
1472 | -{ |
1473 | - if (state() == ApplicationInfo::Stopped) { return; } |
1474 | - |
1475 | - QString surfaceName = name() + "s window title"; |
1476 | - if (m_surfaceList->count() > 0) { |
1477 | - surfaceName.append(QString(" %1").arg(m_surfaceList->count()+1)); |
1478 | - } |
1479 | - |
1480 | - auto surfaceManager = SurfaceManager::instance(); |
1481 | - if (!surfaceManager) { |
1482 | - WARNING_MSG("No SurfaceManager"); |
1483 | - return; |
1484 | - } |
1485 | - |
1486 | - bool wasFocused = focused(); |
1487 | - |
1488 | - auto surface = surfaceManager->createSurface(surfaceName, |
1489 | - Mir::NormalType, |
1490 | - fullscreen() ? Mir::FullscreenState : Mir::RestoredState, |
1491 | - nullptr, /* parentSurface */ |
1492 | - m_screenshotFileName, |
1493 | - m_qmlFilePath); |
1494 | - |
1495 | - surface->setShellChrome(m_shellChrome); |
1496 | - |
1497 | - m_surfaceList->addSurface(surface); |
1498 | - |
1499 | - ++m_liveSurfaceCount; |
1500 | - connect(surface, &MirSurface::liveChanged, this, [this, surface](){ |
1501 | - if (!surface->live()) { |
1502 | - --m_liveSurfaceCount; |
1503 | - if (m_liveSurfaceCount == 0) { |
1504 | - if (m_closingSurfaces.contains(surface) |
1505 | - || (m_state == Running && m_requestedState == RequestedRunning)) { |
1506 | - Q_EMIT closed(); |
1507 | - } |
1508 | - setState(Stopped); |
1509 | - } else { |
1510 | - if (m_closingSurfaces.contains(surface) && m_requestedState == RequestedSuspended |
1511 | - && m_closingSurfaces.count() == 1) { |
1512 | - setState(Suspended); |
1513 | - } |
1514 | - } |
1515 | - m_closingSurfaces.removeAll(surface); |
1516 | - } |
1517 | - }); |
1518 | - connect(surface, &MirSurface::closeRequested, this, [this, surface](){ |
1519 | - m_closingSurfaces.append(surface); |
1520 | - if (m_state == Suspended) { |
1521 | - // resume to allow application to close its surface |
1522 | - setState(Running); |
1523 | - } |
1524 | - }); |
1525 | - connect(surface, &MirSurfaceInterface::focusedChanged, this, [&](bool /*value*/) { |
1526 | - #if APPLICATION_DEBUG |
1527 | - qDebug().nospace() << "Application[" << appId() << "].focusedChanged(" << focused() << ")"; |
1528 | - #endif |
1529 | - Q_EMIT focusedChanged(focused()); |
1530 | - }); |
1531 | - |
1532 | - connect(surface, &MirSurface::focusRequested, this, &ApplicationInfo::focusRequested); |
1533 | - |
1534 | - if (wasFocused != focused()) { |
1535 | - Q_EMIT focusedChanged(focused()); |
1536 | - } |
1537 | - |
1538 | - if (m_state == Starting) { |
1539 | - if (m_requestedState == RequestedRunning) { |
1540 | - setState(Running); |
1541 | - } else { |
1542 | - setState(Suspended); |
1543 | - } |
1544 | - } |
1545 | - |
1546 | - surfaceManager->notifySurfaceCreated(surface); |
1547 | - surfaceManager->activate(surface); |
1548 | -} |
1549 | - |
1550 | -void ApplicationInfo::setIconId(const QString &iconId) |
1551 | -{ |
1552 | - setIcon(QUrl(testDataDir() + "/graphics/applicationIcons/" + iconId + "@18.png")); |
1553 | -} |
1554 | - |
1555 | -void ApplicationInfo::setScreenshotId(const QString &screenshotId) |
1556 | -{ |
1557 | - QString screenshotFileName; |
1558 | - |
1559 | - if (screenshotId.endsWith(".svg")) { |
1560 | - screenshotFileName = QString("qrc:///Unity/Application/screenshots/%2") |
1561 | - .arg(screenshotId); |
1562 | - } else { |
1563 | - screenshotFileName = QString("qrc:///Unity/Application/screenshots/%2@12.png") |
1564 | - .arg(screenshotId); |
1565 | - } |
1566 | - |
1567 | - if (screenshotFileName != m_screenshotFileName) { |
1568 | - m_screenshotFileName = screenshotFileName; |
1569 | - } |
1570 | -} |
1571 | - |
1572 | -void ApplicationInfo::setQmlFilename(const QString &qmlFilename) |
1573 | -{ |
1574 | - m_qmlFilePath = QString("qrc:///Unity/Application/%1").arg(qmlFilename); |
1575 | -} |
1576 | - |
1577 | -void ApplicationInfo::setName(const QString &value) |
1578 | -{ |
1579 | - if (value != m_name) { |
1580 | - m_name = value; |
1581 | - Q_EMIT nameChanged(value); |
1582 | - } |
1583 | -} |
1584 | - |
1585 | -void ApplicationInfo::setIcon(const QUrl &value) |
1586 | -{ |
1587 | - if (value != m_icon) { |
1588 | - m_icon = value; |
1589 | - Q_EMIT iconChanged(value); |
1590 | - } |
1591 | -} |
1592 | - |
1593 | -void ApplicationInfo::setState(State value) |
1594 | -{ |
1595 | - if (value != m_state) { |
1596 | - DEBUG_MSG(qPrintable(stateToStr(value))); |
1597 | - if (!m_manualSurfaceCreation && value == ApplicationInfo::Starting) { |
1598 | - Q_ASSERT(m_surfaceList->count() == 0); |
1599 | - m_surfaceCreationTimer.start(); |
1600 | - } else if (value == ApplicationInfo::Stopped) { |
1601 | - m_surfaceCreationTimer.stop(); |
1602 | - for (int i = 0; i < m_surfaceList->count(); ++i) { |
1603 | - MirSurface *surface = static_cast<MirSurface*>(m_surfaceList->get(i)); |
1604 | - surface->setLive(false); |
1605 | - } |
1606 | - for (int i = 0; i < m_promptSurfaceList->count(); ++i) { |
1607 | - auto surface = static_cast<MirSurface*>(m_promptSurfaceList->get(i)); |
1608 | - surface->setLive(false); |
1609 | - } |
1610 | - } |
1611 | - |
1612 | - m_state = value; |
1613 | - Q_EMIT stateChanged(value); |
1614 | - } |
1615 | -} |
1616 | - |
1617 | -void ApplicationInfo::close() |
1618 | -{ |
1619 | - DEBUG_MSG(""); |
1620 | - |
1621 | - if (m_surfaceList->count() > 0) { |
1622 | - for (int i = 0; i < m_surfaceList->count(); ++i) { |
1623 | - MirSurface *surface = static_cast<MirSurface*>(m_surfaceList->get(i)); |
1624 | - surface->close(); |
1625 | - } |
1626 | - } else { |
1627 | - setState(Stopped); |
1628 | - Q_EMIT closed(); |
1629 | - } |
1630 | -} |
1631 | - |
1632 | -void ApplicationInfo::setFullscreen(bool value) |
1633 | -{ |
1634 | - m_fullscreen = value; |
1635 | - if (m_surfaceList->rowCount() > 0) { |
1636 | - m_surfaceList->get(0)->requestState(Mir::FullscreenState); |
1637 | - } |
1638 | -} |
1639 | - |
1640 | -bool ApplicationInfo::fullscreen() const |
1641 | -{ |
1642 | - if (m_surfaceList->rowCount() > 0) { |
1643 | - return m_surfaceList->get(0)->state() == Mir::FullscreenState; |
1644 | - } else { |
1645 | - return m_fullscreen; |
1646 | - } |
1647 | -} |
1648 | - |
1649 | -void ApplicationInfo::setManualSurfaceCreation(bool value) |
1650 | -{ |
1651 | - if (value != m_manualSurfaceCreation) { |
1652 | - m_manualSurfaceCreation = value; |
1653 | - Q_EMIT manualSurfaceCreationChanged(value); |
1654 | - |
1655 | - if (m_manualSurfaceCreation && m_surfaceCreationTimer.isActive()) { |
1656 | - m_surfaceCreationTimer.stop(); |
1657 | - } |
1658 | - } |
1659 | -} |
1660 | - |
1661 | -Qt::ScreenOrientations ApplicationInfo::supportedOrientations() const |
1662 | -{ |
1663 | - return m_supportedOrientations; |
1664 | -} |
1665 | - |
1666 | -void ApplicationInfo::setSupportedOrientations(Qt::ScreenOrientations orientations) |
1667 | -{ |
1668 | - m_supportedOrientations = orientations; |
1669 | -} |
1670 | - |
1671 | -bool ApplicationInfo::rotatesWindowContents() const |
1672 | -{ |
1673 | - return m_rotatesWindowContents; |
1674 | -} |
1675 | - |
1676 | -void ApplicationInfo::setRotatesWindowContents(bool value) |
1677 | -{ |
1678 | - m_rotatesWindowContents = value; |
1679 | -} |
1680 | - |
1681 | -ApplicationInfo::RequestedState ApplicationInfo::requestedState() const |
1682 | -{ |
1683 | - return m_requestedState; |
1684 | -} |
1685 | - |
1686 | -void ApplicationInfo::setRequestedState(RequestedState value) |
1687 | -{ |
1688 | - if (m_requestedState == value) { |
1689 | - return; |
1690 | - } |
1691 | - DEBUG_MSG((value == RequestedRunning ? "RequestedRunning" : "RequestedSuspended") ); |
1692 | - |
1693 | - m_requestedState = value; |
1694 | - Q_EMIT requestedStateChanged(m_requestedState); |
1695 | - |
1696 | - if (m_requestedState == RequestedRunning) { |
1697 | - |
1698 | - if (m_state == Suspended) { |
1699 | - Q_ASSERT(m_liveSurfaceCount > 0); |
1700 | - setState(Running); |
1701 | - } else if (m_state == Stopped) { |
1702 | - Q_ASSERT(m_liveSurfaceCount == 0); |
1703 | - // it's restarting |
1704 | - setState(Starting); |
1705 | - } |
1706 | - |
1707 | - } else if (m_requestedState == RequestedSuspended && m_state == Running |
1708 | - && m_closingSurfaces.isEmpty()) { |
1709 | - setState(Suspended); |
1710 | - } |
1711 | -} |
1712 | - |
1713 | -bool ApplicationInfo::isTouchApp() const |
1714 | -{ |
1715 | - return m_isTouchApp; |
1716 | -} |
1717 | - |
1718 | -void ApplicationInfo::setIsTouchApp(bool isTouchApp) |
1719 | -{ |
1720 | - m_isTouchApp = isTouchApp; |
1721 | -} |
1722 | - |
1723 | -bool ApplicationInfo::exemptFromLifecycle() const |
1724 | -{ |
1725 | - return m_exemptFromLifecycle; |
1726 | -} |
1727 | - |
1728 | -void ApplicationInfo::setExemptFromLifecycle(bool exemptFromLifecycle) |
1729 | -{ |
1730 | - if (m_exemptFromLifecycle != exemptFromLifecycle) |
1731 | - { |
1732 | - m_exemptFromLifecycle = exemptFromLifecycle; |
1733 | - Q_EMIT exemptFromLifecycleChanged(m_exemptFromLifecycle); |
1734 | - } |
1735 | -} |
1736 | - |
1737 | -QSize ApplicationInfo::initialSurfaceSize() const |
1738 | -{ |
1739 | - return m_initialSurfaceSize; |
1740 | -} |
1741 | - |
1742 | -void ApplicationInfo::setInitialSurfaceSize(const QSize &size) |
1743 | -{ |
1744 | - if (size != m_initialSurfaceSize) { |
1745 | - m_initialSurfaceSize = size; |
1746 | - Q_EMIT initialSurfaceSizeChanged(m_initialSurfaceSize); |
1747 | - } |
1748 | -} |
1749 | - |
1750 | -void ApplicationInfo::setShellChrome(Mir::ShellChrome shellChrome) |
1751 | -{ |
1752 | - m_shellChrome = shellChrome; |
1753 | - if (m_surfaceList->rowCount() > 0) { |
1754 | - static_cast<MirSurface*>(m_surfaceList->get(0))->setShellChrome(shellChrome); |
1755 | - } |
1756 | -} |
1757 | - |
1758 | -bool ApplicationInfo::focused() const |
1759 | -{ |
1760 | - bool someSurfaceHasFocus = false; // to be proven wrong |
1761 | - for (int i = 0; i < m_surfaceList->count() && !someSurfaceHasFocus; ++i) { |
1762 | - someSurfaceHasFocus = m_surfaceList->get(i)->focused(); |
1763 | - } |
1764 | - return someSurfaceHasFocus; |
1765 | -} |
1766 | - |
1767 | -void ApplicationInfo::onSurfaceCountChanged() |
1768 | -{ |
1769 | - if (m_surfaceList->count() == 0 && m_state == Running) { |
1770 | - setState(Stopped); |
1771 | - } |
1772 | -} |
1773 | - |
1774 | -void ApplicationInfo::requestFocus() |
1775 | -{ |
1776 | - if (m_surfaceList->count() == 0) { |
1777 | - Q_EMIT focusRequested(); |
1778 | - } else { |
1779 | - auto surface = static_cast<MirSurface*>(m_surfaceList->get(0)); |
1780 | - surface->requestFocus(); |
1781 | - } |
1782 | -} |
1783 | |
1784 | === removed file 'tests/mocks/Unity/Application/ApplicationInfo.h' |
1785 | --- tests/mocks/Unity/Application/ApplicationInfo.h 2017-01-26 11:10:01 +0000 |
1786 | +++ tests/mocks/Unity/Application/ApplicationInfo.h 1970-01-01 00:00:00 +0000 |
1787 | @@ -1,162 +0,0 @@ |
1788 | -/* |
1789 | - * Copyright (C) 2013-2016 Canonical, Ltd. |
1790 | - * |
1791 | - * This program is free software; you can redistribute it and/or modify |
1792 | - * it under the terms of the GNU General Public License as published by |
1793 | - * the Free Software Foundation; version 3. |
1794 | - * |
1795 | - * This program is distributed in the hope that it will be useful, |
1796 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1797 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1798 | - * GNU General Public License for more details. |
1799 | - * |
1800 | - * You should have received a copy of the GNU General Public License |
1801 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1802 | - */ |
1803 | - |
1804 | -#ifndef APPLICATION_H |
1805 | -#define APPLICATION_H |
1806 | - |
1807 | -#include <QObject> |
1808 | - |
1809 | -class MirSurface; |
1810 | - |
1811 | -// unity-api |
1812 | -#include <unity/shell/application/ApplicationInfoInterface.h> |
1813 | -#include <unity/shell/application/Mir.h> |
1814 | - |
1815 | -#include "MirSurfaceListModel.h" |
1816 | - |
1817 | -#include <QList> |
1818 | -#include <QTimer> |
1819 | -#include <QUrl> |
1820 | - |
1821 | -using namespace unity::shell::application; |
1822 | - |
1823 | -class ApplicationInfo : public ApplicationInfoInterface { |
1824 | - Q_OBJECT |
1825 | - |
1826 | - //// |
1827 | - // FIXME: Remove those |
1828 | - Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged) |
1829 | - |
1830 | - // Only exists in this fake implementation |
1831 | - |
1832 | - // whether the test code will explicitly control the creation of the application surface |
1833 | - Q_PROPERTY(bool manualSurfaceCreation READ manualSurfaceCreation WRITE setManualSurfaceCreation NOTIFY manualSurfaceCreationChanged) |
1834 | - |
1835 | - Q_PROPERTY(QString screenshot READ screenshot CONSTANT) |
1836 | - |
1837 | -public: |
1838 | - ApplicationInfo(QObject *parent = nullptr); |
1839 | - ApplicationInfo(const QString &appId, QObject *parent = nullptr); |
1840 | - ~ApplicationInfo(); |
1841 | - |
1842 | - Q_INVOKABLE void createPromptSurface(); |
1843 | - |
1844 | - RequestedState requestedState() const override; |
1845 | - void setRequestedState(RequestedState) override; |
1846 | - |
1847 | - void setIconId(const QString &iconId); |
1848 | - void setScreenshotId(const QString &screenshotId); |
1849 | - void setQmlFilename(const QString &); |
1850 | - |
1851 | - void setAppId(const QString &value) { m_appId = value; } |
1852 | - QString appId() const override { return m_appId; } |
1853 | - |
1854 | - void setName(const QString &value); |
1855 | - QString name() const override { return m_name; } |
1856 | - |
1857 | - QString comment() const override { return QString(); } |
1858 | - |
1859 | - QUrl icon() const override { return m_icon; } |
1860 | - |
1861 | - Q_INVOKABLE void setState(State value); |
1862 | - State state() const override { return m_state; } |
1863 | - |
1864 | - bool focused() const override; |
1865 | - |
1866 | - QString splashTitle() const override { return QString(); } |
1867 | - QUrl splashImage() const override { return QUrl(); } |
1868 | - bool splashShowHeader() const override { return false; } |
1869 | - QColor splashColor() const override { return QColor(0,0,0,0); } |
1870 | - QColor splashColorHeader() const override { return QColor(0,0,0,0); } |
1871 | - QColor splashColorFooter() const override { return QColor(0,0,0,0); } |
1872 | - |
1873 | - QString screenshot() const { return m_screenshotFileName; } |
1874 | - |
1875 | - void setFullscreen(bool value); |
1876 | - bool fullscreen() const; |
1877 | - |
1878 | - Qt::ScreenOrientations supportedOrientations() const override; |
1879 | - void setSupportedOrientations(Qt::ScreenOrientations orientations); |
1880 | - |
1881 | - bool rotatesWindowContents() const override; |
1882 | - void setRotatesWindowContents(bool value); |
1883 | - |
1884 | - bool manualSurfaceCreation() const { return m_manualSurfaceCreation; } |
1885 | - void setManualSurfaceCreation(bool value); |
1886 | - |
1887 | - bool isTouchApp() const override; |
1888 | - void setIsTouchApp(bool isTouchApp); // only in mock |
1889 | - |
1890 | - bool exemptFromLifecycle() const override; |
1891 | - void setExemptFromLifecycle(bool) override; |
1892 | - |
1893 | - QSize initialSurfaceSize() const override; |
1894 | - void setInitialSurfaceSize(const QSize &size) override; |
1895 | - |
1896 | - Q_INVOKABLE void setShellChrome(Mir::ShellChrome shellChrome); |
1897 | - |
1898 | - MirSurfaceListInterface* surfaceList() const override { return m_surfaceList; } |
1899 | - MirSurfaceListInterface* promptSurfaceList() const override { return m_promptSurfaceList; } |
1900 | - int surfaceCount() const override { return m_surfaceList->count(); } |
1901 | - |
1902 | - ////// |
1903 | - // internal mock stuff |
1904 | - void close() override; |
1905 | - void requestFocus(); |
1906 | - |
1907 | -Q_SIGNALS: |
1908 | - void fullscreenChanged(bool value); |
1909 | - void manualSurfaceCreationChanged(bool value); |
1910 | - void closed(); |
1911 | - |
1912 | -public Q_SLOTS: |
1913 | - Q_INVOKABLE void createSurface(); |
1914 | - |
1915 | -private Q_SLOTS: |
1916 | - void onSurfaceCountChanged(); |
1917 | - |
1918 | -private: |
1919 | - void setIcon(const QUrl &value); |
1920 | - |
1921 | - QString m_screenshotFileName; |
1922 | - |
1923 | - QString m_appId; |
1924 | - QString m_name; |
1925 | - QUrl m_icon; |
1926 | - State m_state{Stopped}; |
1927 | - bool m_fullscreen{false}; |
1928 | - Qt::ScreenOrientations m_supportedOrientations{Qt::PortraitOrientation | |
1929 | - Qt::LandscapeOrientation | |
1930 | - Qt::InvertedPortraitOrientation | |
1931 | - Qt::InvertedLandscapeOrientation}; |
1932 | - bool m_rotatesWindowContents{false}; |
1933 | - RequestedState m_requestedState{RequestedRunning}; |
1934 | - bool m_isTouchApp{true}; |
1935 | - bool m_exemptFromLifecycle{false}; |
1936 | - QSize m_initialSurfaceSize; |
1937 | - MirSurfaceListModel *m_surfaceList; |
1938 | - MirSurfaceListModel *m_promptSurfaceList; |
1939 | - int m_liveSurfaceCount{0}; |
1940 | - QTimer m_surfaceCreationTimer; |
1941 | - QList<MirSurface*> m_closingSurfaces; |
1942 | - bool m_manualSurfaceCreation{false}; |
1943 | - Mir::ShellChrome m_shellChrome{Mir::NormalChrome}; |
1944 | - QUrl m_qmlFilePath; |
1945 | -}; |
1946 | - |
1947 | -Q_DECLARE_METATYPE(ApplicationInfo*) |
1948 | - |
1949 | -#endif // APPLICATION_H |
1950 | |
1951 | === removed file 'tests/mocks/Unity/Application/ApplicationManager.cpp' |
1952 | --- tests/mocks/Unity/Application/ApplicationManager.cpp 2017-01-26 11:10:01 +0000 |
1953 | +++ tests/mocks/Unity/Application/ApplicationManager.cpp 1970-01-01 00:00:00 +0000 |
1954 | @@ -1,557 +0,0 @@ |
1955 | -/* |
1956 | - * Copyright (C) 2013-2016 Canonical, Ltd. |
1957 | - * |
1958 | - * This program is free software; you can redistribute it and/or modify |
1959 | - * it under the terms of the GNU General Public License as published by |
1960 | - * the Free Software Foundation; version 3. |
1961 | - * |
1962 | - * This program is distributed in the hope that it will be useful, |
1963 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1964 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1965 | - * GNU General Public License for more details. |
1966 | - * |
1967 | - * You should have received a copy of the GNU General Public License |
1968 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1969 | - */ |
1970 | - |
1971 | -#include "ApplicationManager.h" |
1972 | -#include "ApplicationInfo.h" |
1973 | -#include "MirSurface.h" |
1974 | - |
1975 | -#include <paths.h> |
1976 | -#include <csignal> |
1977 | - |
1978 | -#include <QDir> |
1979 | -#include <QGuiApplication> |
1980 | -#include <QQuickItem> |
1981 | -#include <QQuickView> |
1982 | -#include <QQmlComponent> |
1983 | -#include <QTimer> |
1984 | -#include <QDateTime> |
1985 | -#include <QtDBus/QtDBus> |
1986 | - |
1987 | -#define APPLICATIONMANAGER_DEBUG 0 |
1988 | - |
1989 | -#if APPLICATIONMANAGER_DEBUG |
1990 | -#define DEBUG_MSG(params) qDebug().nospace() << "ApplicationManager::" << __func__ << " " << params |
1991 | -#define XDEBUG_MSG(params) qDebug().nospace() << "ApplicationManager::" << params |
1992 | -#else |
1993 | -#define DEBUG_MSG(params) ((void)0) |
1994 | -#define XDEBUG_MSG(params) ((void)0) |
1995 | -#endif |
1996 | - |
1997 | -namespace unityapi = unity::shell::application; |
1998 | - |
1999 | - |
2000 | -ApplicationManager::ApplicationManager(QObject *parent) |
2001 | - : ApplicationManagerInterface(parent) |
2002 | -{ |
2003 | - DEBUG_MSG(""); |
2004 | - |
2005 | - ApplicationManagerNotifier::instance()->setApplicationManager(this); |
2006 | - |
2007 | - buildListOfAvailableApplications(); |
2008 | - |
2009 | - // Emit signal to notify Upstart that Mir is ready to receive client connections |
2010 | - // see http://upstart.ubuntu.com/cookbook/#expect-stop |
2011 | - // We do this because some autopilot tests actually use this mock Unity.Application module, |
2012 | - // so we have to mimic what the real ApplicationManager does in that regard. |
2013 | - if (qgetenv("UNITY_MIR_EMITS_SIGSTOP") == "1") { |
2014 | - raise(SIGSTOP); |
2015 | - } |
2016 | -} |
2017 | - |
2018 | -ApplicationManager::~ApplicationManager() |
2019 | -{ |
2020 | - ApplicationManagerNotifier::instance()->setApplicationManager(nullptr); |
2021 | -} |
2022 | - |
2023 | -int ApplicationManager::rowCount(const QModelIndex& parent) const { |
2024 | - return !parent.isValid() ? m_runningApplications.size() : 0; |
2025 | -} |
2026 | - |
2027 | -QVariant ApplicationManager::data(const QModelIndex& index, int role) const { |
2028 | - if (index.row() < 0 || index.row() >= m_runningApplications.size()) |
2029 | - return QVariant(); |
2030 | - |
2031 | - auto app = m_runningApplications.at(index.row()); |
2032 | - switch(role) { |
2033 | - case RoleAppId: |
2034 | - return app->appId(); |
2035 | - case RoleName: |
2036 | - return app->name(); |
2037 | - case RoleComment: |
2038 | - return app->comment(); |
2039 | - case RoleIcon: |
2040 | - return app->icon(); |
2041 | - case RoleState: |
2042 | - return app->state(); |
2043 | - case RoleFocused: |
2044 | - return app->focused(); |
2045 | - case RoleIsTouchApp: |
2046 | - return app->isTouchApp(); |
2047 | - case RoleExemptFromLifecycle: |
2048 | - return app->exemptFromLifecycle(); |
2049 | - case RoleApplication: |
2050 | - return QVariant::fromValue(static_cast<unityapi::ApplicationInfoInterface*>(app)); |
2051 | - default: |
2052 | - return QVariant(); |
2053 | - } |
2054 | -} |
2055 | - |
2056 | -ApplicationInfo *ApplicationManager::get(int row) const { |
2057 | - if (row < 0 || row >= m_runningApplications.size()) |
2058 | - return nullptr; |
2059 | - return m_runningApplications.at(row); |
2060 | -} |
2061 | - |
2062 | -ApplicationInfo *ApplicationManager::findApplication(const QString &appId) const { |
2063 | - for (ApplicationInfo *app : m_runningApplications) { |
2064 | - if (app->appId() == appId) { |
2065 | - return app; |
2066 | - } |
2067 | - } |
2068 | - return nullptr; |
2069 | -} |
2070 | - |
2071 | -unityapi::ApplicationInfoInterface *ApplicationManager::findApplicationWithSurface(unityapi::MirSurfaceInterface* surface) const |
2072 | -{ |
2073 | - for (ApplicationInfo *app : m_runningApplications) { |
2074 | - auto surfaceList = static_cast<MirSurfaceListModel*>(app->surfaceList()); |
2075 | - if (surfaceList->contains(static_cast<MirSurface*>(surface))) { |
2076 | - return app; |
2077 | - } |
2078 | - } |
2079 | - return nullptr; |
2080 | -} |
2081 | - |
2082 | -QModelIndex ApplicationManager::findIndex(ApplicationInfo* application) |
2083 | -{ |
2084 | - for (int i = 0; i < m_runningApplications.size(); ++i) { |
2085 | - if (m_runningApplications.at(i) == application) { |
2086 | - return index(i); |
2087 | - } |
2088 | - } |
2089 | - |
2090 | - return QModelIndex(); |
2091 | -} |
2092 | - |
2093 | -bool ApplicationManager::add(ApplicationInfo *application) { |
2094 | - if (!application || m_runningApplications.contains(application)) { |
2095 | - return false; |
2096 | - } |
2097 | - DEBUG_MSG(application->appId()); |
2098 | - |
2099 | - application->setState(ApplicationInfo::Starting); |
2100 | - |
2101 | - beginInsertRows(QModelIndex(), m_runningApplications.size(), m_runningApplications.size()); |
2102 | - m_runningApplications.append(application); |
2103 | - |
2104 | - connect(application, &ApplicationInfo::focusedChanged, this, [application, this]() { |
2105 | - QModelIndex appIndex = findIndex(application); |
2106 | - if (!appIndex.isValid()) return; |
2107 | - Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << ApplicationManager::RoleFocused); |
2108 | - XDEBUG_MSG("focusedApplicationId = " << focusedApplicationId()); |
2109 | - Q_EMIT focusedApplicationIdChanged(); |
2110 | - if (application->focused()) { |
2111 | - raiseApp(application->appId()); |
2112 | - } |
2113 | - }); |
2114 | - connect(application, &ApplicationInfo::stateChanged, this, [application, this]() { |
2115 | - QModelIndex appIndex = findIndex(application); |
2116 | - if (!appIndex.isValid()) return; |
2117 | - Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << ApplicationManager::RoleState); |
2118 | - }); |
2119 | - |
2120 | - connect(application, &ApplicationInfo::closed, this, [application, this]() { |
2121 | - this->remove(application); |
2122 | - }); |
2123 | - connect(application, &ApplicationInfo::focusRequested, this, [application, this]() { |
2124 | - Q_EMIT this->focusRequested(application->appId()); |
2125 | - }); |
2126 | - |
2127 | - endInsertRows(); |
2128 | - Q_EMIT countChanged(); |
2129 | - if (count() == 1) Q_EMIT emptyChanged(isEmpty()); // was empty but not anymore |
2130 | - |
2131 | - return true; |
2132 | -} |
2133 | - |
2134 | -void ApplicationManager::remove(ApplicationInfo *application) { |
2135 | - int i = m_runningApplications.indexOf(application); |
2136 | - application->disconnect(this); |
2137 | - if (i != -1) { |
2138 | - DEBUG_MSG(application->appId()); |
2139 | - Q_ASSERT(!m_modelBusy); |
2140 | - m_modelBusy = true; |
2141 | - beginRemoveRows(QModelIndex(), i, i); |
2142 | - m_runningApplications.removeAt(i); |
2143 | - endRemoveRows(); |
2144 | - m_modelBusy = false; |
2145 | - Q_EMIT countChanged(); |
2146 | - if (isEmpty()) Q_EMIT emptyChanged(isEmpty()); |
2147 | - DEBUG_MSG(application->appId() << " after: " << qPrintable(toString())); |
2148 | - } |
2149 | -} |
2150 | - |
2151 | -void ApplicationManager::raiseApp(const QString &appId) |
2152 | -{ |
2153 | - |
2154 | - int index = -1; |
2155 | - for (int i = 0; i < m_runningApplications.count() && index == -1; ++i) { |
2156 | - if (m_runningApplications[i]->appId() == appId) { |
2157 | - index = i; |
2158 | - } |
2159 | - } |
2160 | - |
2161 | - if (index >= 0) { |
2162 | - if (m_modelBusy) { |
2163 | - DEBUG_MSG(appId << " - model busy. Try again later."); |
2164 | - QMetaObject::invokeMethod(this, "raiseApp", Qt::QueuedConnection, Q_ARG(QString, appId)); |
2165 | - } else { |
2166 | - DEBUG_MSG(appId); |
2167 | - move(index, 0); |
2168 | - } |
2169 | - } |
2170 | -} |
2171 | - |
2172 | -void ApplicationManager::move(int from, int to) { |
2173 | - if (from == to) return; |
2174 | - |
2175 | - if (from >= 0 && from < m_runningApplications.size() && to >= 0 && to < m_runningApplications.size()) { |
2176 | - QModelIndex parent; |
2177 | - Q_ASSERT(!m_modelBusy); |
2178 | - m_modelBusy = true; |
2179 | - /* When moving an item down, the destination index needs to be incremented |
2180 | - * by one, as explained in the documentation: |
2181 | - * http://qt-project.org/doc/qt-5.0/qtcore/qabstractitemmodel.html#beginMoveRows */ |
2182 | - beginMoveRows(parent, from, from, parent, to + (to > from ? 1 : 0)); |
2183 | - m_runningApplications.move(from, to); |
2184 | - endMoveRows(); |
2185 | - m_modelBusy = false; |
2186 | - } |
2187 | -} |
2188 | - |
2189 | -ApplicationInfo* ApplicationManager::startApplication(const QString &appId, |
2190 | - const QStringList &arguments) |
2191 | -{ |
2192 | - DEBUG_MSG(appId); |
2193 | - Q_UNUSED(arguments) |
2194 | - |
2195 | - ApplicationInfo *application = findApplication(appId); |
2196 | - if (application) { |
2197 | - // the requested app is already running |
2198 | - return application; |
2199 | - } else { |
2200 | - application = add(appId); |
2201 | - } |
2202 | - |
2203 | - // most likely not among the available ones |
2204 | - if (!application) |
2205 | - return nullptr; |
2206 | - |
2207 | - return application; |
2208 | -} |
2209 | - |
2210 | -ApplicationInfo* ApplicationManager::add(QString appId) |
2211 | -{ |
2212 | - ApplicationInfo *application = nullptr; |
2213 | - |
2214 | - for (ApplicationInfo *availableApp : m_availableApplications) { |
2215 | - if (availableApp->appId() == appId) { |
2216 | - application = availableApp; |
2217 | - break; |
2218 | - } |
2219 | - } |
2220 | - |
2221 | - if (application) { |
2222 | - if (!add(application)) { |
2223 | - application = nullptr; |
2224 | - } |
2225 | - } |
2226 | - |
2227 | - return application; |
2228 | -} |
2229 | - |
2230 | -bool ApplicationManager::stopApplication(const QString &appId) |
2231 | -{ |
2232 | - DEBUG_MSG(appId); |
2233 | - ApplicationInfo *application = findApplication(appId); |
2234 | - if (application == nullptr) |
2235 | - return false; |
2236 | - |
2237 | - application->close(); |
2238 | - return true; |
2239 | -} |
2240 | - |
2241 | -QString ApplicationManager::focusedApplicationId() const { |
2242 | - for (ApplicationInfo *app : m_runningApplications) { |
2243 | - if (app->focused()) { |
2244 | - return app->appId(); |
2245 | - } |
2246 | - } |
2247 | - return QString(); |
2248 | -} |
2249 | - |
2250 | -bool ApplicationManager::requestFocusApplication(const QString &appId) |
2251 | -{ |
2252 | - ApplicationInfo *application = findApplication(appId); |
2253 | - if (application == nullptr) |
2254 | - return false; |
2255 | - |
2256 | - application->requestFocus(); |
2257 | - |
2258 | - return true; |
2259 | -} |
2260 | - |
2261 | -void ApplicationManager::buildListOfAvailableApplications() |
2262 | -{ |
2263 | - /* |
2264 | - ATTENTION! |
2265 | - Be careful when changing application properties here as some qmltests |
2266 | - rely on them being the way it's specified here (e.g. that camera-app |
2267 | - is fullscreen, that twitter-webapp can rotate in all directions, etc) |
2268 | - */ |
2269 | - |
2270 | - ApplicationInfo *application; |
2271 | - |
2272 | - application = new ApplicationInfo(this); |
2273 | - application->setAppId("unity8-dash"); |
2274 | - application->setName("Unity 8 Mock Dash"); |
2275 | - application->setScreenshotId("unity8-dash"); |
2276 | - application->setIconId("dash"); |
2277 | - m_availableApplications.append(application); |
2278 | - |
2279 | - application = new ApplicationInfo(this); |
2280 | - application->setAppId("dialer-app"); |
2281 | - application->setName("Dialer"); |
2282 | - application->setScreenshotId("dialer"); |
2283 | - application->setIconId("dialer-app"); |
2284 | - application->setSupportedOrientations(Qt::PortraitOrientation |
2285 | - | Qt::InvertedPortraitOrientation); |
2286 | - m_availableApplications.append(application); |
2287 | - |
2288 | - application = new ApplicationInfo(this); |
2289 | - application->setAppId("camera-app"); |
2290 | - application->setName("Camera"); |
2291 | - application->setScreenshotId("camera"); |
2292 | - application->setIconId("camera"); |
2293 | - application->setFullscreen(true); |
2294 | - application->setSupportedOrientations(Qt::PortraitOrientation |
2295 | - | Qt::LandscapeOrientation |
2296 | - | Qt::InvertedPortraitOrientation |
2297 | - | Qt::InvertedLandscapeOrientation); |
2298 | - application->setRotatesWindowContents(true); |
2299 | - m_availableApplications.append(application); |
2300 | - |
2301 | - application = new ApplicationInfo(this); |
2302 | - application->setAppId("camera-app2"); |
2303 | - application->setName("Camera2"); |
2304 | - application->setScreenshotId("camera"); |
2305 | - application->setIconId("camera"); |
2306 | - application->setSupportedOrientations(Qt::PortraitOrientation |
2307 | - | Qt::LandscapeOrientation |
2308 | - | Qt::InvertedPortraitOrientation |
2309 | - | Qt::InvertedLandscapeOrientation); |
2310 | - application->setRotatesWindowContents(true); |
2311 | - m_availableApplications.append(application); |
2312 | - |
2313 | - application = new ApplicationInfo(this); |
2314 | - application->setAppId("gallery-app"); |
2315 | - application->setName("Gallery"); |
2316 | - application->setScreenshotId("gallery"); |
2317 | - application->setIconId("gallery"); |
2318 | - application->setShellChrome(Mir::LowChrome); |
2319 | - m_availableApplications.append(application); |
2320 | - |
2321 | - application = new ApplicationInfo(this); |
2322 | - application->setAppId("facebook-webapp"); |
2323 | - application->setName("Facebook"); |
2324 | - application->setScreenshotId("facebook"); |
2325 | - application->setIconId("facebook"); |
2326 | - m_availableApplications.append(application); |
2327 | - |
2328 | - application = new ApplicationInfo(this); |
2329 | - application->setAppId("webbrowser-app"); |
2330 | - application->setShellChrome(Mir::LowChrome); |
2331 | - application->setName("Browser"); |
2332 | - application->setScreenshotId("browser"); |
2333 | - application->setIconId("browser"); |
2334 | - m_availableApplications.append(application); |
2335 | - |
2336 | - application = new ApplicationInfo(this); |
2337 | - application->setAppId("twitter-webapp"); |
2338 | - application->setName("Twitter"); |
2339 | - application->setScreenshotId("twitter"); |
2340 | - application->setIconId("twitter"); |
2341 | - m_availableApplications.append(application); |
2342 | - |
2343 | - application = new ApplicationInfo(this); |
2344 | - application->setAppId("map"); |
2345 | - application->setName("Map"); |
2346 | - application->setIconId("map"); |
2347 | - application->setScreenshotId("map"); |
2348 | - m_availableApplications.append(application); |
2349 | - |
2350 | - application = new ApplicationInfo(this); |
2351 | - application->setAppId("gmail-webapp"); |
2352 | - application->setName("GMail"); |
2353 | - application->setIconId("gmail"); |
2354 | - application->setScreenshotId("gmail-webapp.svg"); |
2355 | - application->setSupportedOrientations(Qt::PortraitOrientation |
2356 | - | Qt::LandscapeOrientation |
2357 | - | Qt::InvertedPortraitOrientation |
2358 | - | Qt::InvertedLandscapeOrientation); |
2359 | - m_availableApplications.append(application); |
2360 | - |
2361 | - application = new ApplicationInfo(this); |
2362 | - application->setAppId("music-app"); |
2363 | - application->setName("Music"); |
2364 | - application->setIconId("soundcloud"); |
2365 | - application->setScreenshotId("music"); |
2366 | - application->setSupportedOrientations(Qt::PortraitOrientation |
2367 | - | Qt::LandscapeOrientation |
2368 | - | Qt::InvertedPortraitOrientation |
2369 | - | Qt::InvertedLandscapeOrientation); |
2370 | - m_availableApplications.append(application); |
2371 | - |
2372 | - application = new ApplicationInfo(this); |
2373 | - application->setAppId("ubuntu-weather-app"); |
2374 | - application->setName("Weather"); |
2375 | - application->setIconId("weather"); |
2376 | - application->setScreenshotId("ubuntu-weather-app.svg"); |
2377 | - application->setSupportedOrientations(Qt::LandscapeOrientation |
2378 | - | Qt::InvertedLandscapeOrientation); |
2379 | - m_availableApplications.append(application); |
2380 | - |
2381 | - application = new ApplicationInfo(this); |
2382 | - application->setAppId("notes-app"); |
2383 | - application->setName("Notepad"); |
2384 | - application->setIconId("notepad"); |
2385 | -// application->setStage(ApplicationInfoInterface::SideStage); |
2386 | - m_availableApplications.append(application); |
2387 | - |
2388 | - application = new ApplicationInfo(this); |
2389 | - application->setAppId("calendar-app"); |
2390 | - application->setName("Calendar"); |
2391 | - application->setIconId("calendar"); |
2392 | - m_availableApplications.append(application); |
2393 | - |
2394 | - application = new ApplicationInfo(this); |
2395 | - application->setAppId("evernote"); |
2396 | - application->setName("Evernote"); |
2397 | - application->setIconId("evernote"); |
2398 | - m_availableApplications.append(application); |
2399 | - |
2400 | - application = new ApplicationInfo(this); |
2401 | - application->setAppId("pinterest"); |
2402 | - application->setName("Pinterest"); |
2403 | - application->setIconId("pinterest"); |
2404 | - m_availableApplications.append(application); |
2405 | - |
2406 | - application = new ApplicationInfo(this); |
2407 | - application->setAppId("soundcloud"); |
2408 | - application->setName("SoundCloud"); |
2409 | - application->setIconId("soundcloud"); |
2410 | - m_availableApplications.append(application); |
2411 | - |
2412 | - application = new ApplicationInfo(this); |
2413 | - application->setAppId("wikipedia"); |
2414 | - application->setName("Wikipedia"); |
2415 | - application->setIconId("wikipedia"); |
2416 | - m_availableApplications.append(application); |
2417 | - |
2418 | - application = new ApplicationInfo(this); |
2419 | - application->setAppId("youtube"); |
2420 | - application->setName("YouTube"); |
2421 | - application->setIconId("youtube"); |
2422 | - m_availableApplications.append(application); |
2423 | - |
2424 | - application = new ApplicationInfo(this); |
2425 | - application->setAppId("libreoffice"); |
2426 | - application->setName("LibreOffice"); |
2427 | - application->setIconId("libreoffice"); |
2428 | - application->setScreenshotId("libreoffice"); |
2429 | - application->setIsTouchApp(false); |
2430 | - m_availableApplications.append(application); |
2431 | - |
2432 | - application = new ApplicationInfo(this); |
2433 | - application->setAppId("primary-oriented-app"); |
2434 | - application->setName("Primary Oriented"); |
2435 | - application->setSupportedOrientations(Qt::PrimaryOrientation); |
2436 | - m_availableApplications.append(application); |
2437 | - |
2438 | - application = new ApplicationInfo(this); |
2439 | - application->setAppId("kate"); |
2440 | - application->setName("Kate"); |
2441 | - application->setIconId("libreoffice"); |
2442 | - application->setScreenshotId("libreoffice"); |
2443 | - application->setQmlFilename("Kate.qml"); |
2444 | - application->setIsTouchApp(false); |
2445 | - m_availableApplications.append(application); |
2446 | -} |
2447 | - |
2448 | - |
2449 | -QStringList ApplicationManager::availableApplications() |
2450 | -{ |
2451 | - QStringList appIds; |
2452 | - Q_FOREACH(ApplicationInfo *app, m_availableApplications) { |
2453 | - appIds << app->appId(); |
2454 | - } |
2455 | - return appIds; |
2456 | -} |
2457 | - |
2458 | -bool ApplicationManager::isEmpty() const |
2459 | -{ |
2460 | - return m_runningApplications.isEmpty(); |
2461 | -} |
2462 | - |
2463 | -ApplicationInfo *ApplicationManager::findApplication(MirSurface* surface) |
2464 | -{ |
2465 | - for (ApplicationInfo *app : m_runningApplications) { |
2466 | - auto surfaceList = static_cast<MirSurfaceListModel*>(app->surfaceList()); |
2467 | - if (surfaceList->contains(surface)) { |
2468 | - return app; |
2469 | - } |
2470 | - } |
2471 | - return nullptr; |
2472 | -} |
2473 | - |
2474 | -QString ApplicationManager::toString() |
2475 | -{ |
2476 | - QString str; |
2477 | - for (int i = 0; i < m_runningApplications.count(); ++i) { |
2478 | - auto *application = m_runningApplications.at(i); |
2479 | - |
2480 | - QString itemStr = QString("(index=%1,appId=%2)") |
2481 | - .arg(i) |
2482 | - .arg(application->appId()); |
2483 | - |
2484 | - if (i > 0) { |
2485 | - str.append(","); |
2486 | - } |
2487 | - str.append(itemStr); |
2488 | - } |
2489 | - return str; |
2490 | -} |
2491 | - |
2492 | -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
2493 | -// ApplicationManagerNotifier |
2494 | - |
2495 | -ApplicationManagerNotifier *ApplicationManagerNotifier::m_instance = nullptr; |
2496 | - |
2497 | -ApplicationManagerNotifier *ApplicationManagerNotifier::instance() |
2498 | -{ |
2499 | - if (!m_instance) { |
2500 | - m_instance = new ApplicationManagerNotifier; |
2501 | - } |
2502 | - return m_instance; |
2503 | -} |
2504 | - |
2505 | -void ApplicationManagerNotifier::setApplicationManager(ApplicationManager *appMan) |
2506 | -{ |
2507 | - if (appMan != m_applicationManager) { |
2508 | - m_applicationManager = appMan; |
2509 | - Q_EMIT applicationManagerChanged(m_applicationManager); |
2510 | - } |
2511 | -} |
2512 | |
2513 | === removed file 'tests/mocks/Unity/Application/ApplicationManager.h' |
2514 | --- tests/mocks/Unity/Application/ApplicationManager.h 2016-12-07 11:19:17 +0000 |
2515 | +++ tests/mocks/Unity/Application/ApplicationManager.h 1970-01-01 00:00:00 +0000 |
2516 | @@ -1,122 +0,0 @@ |
2517 | -/* |
2518 | - * Copyright (C) 2013-2016 Canonical, Ltd. |
2519 | - * |
2520 | - * This program is free software; you can redistribute it and/or modify |
2521 | - * it under the terms of the GNU General Public License as published by |
2522 | - * the Free Software Foundation; version 3. |
2523 | - * |
2524 | - * This program is distributed in the hope that it will be useful, |
2525 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2526 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2527 | - * GNU General Public License for more details. |
2528 | - * |
2529 | - * You should have received a copy of the GNU General Public License |
2530 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2531 | - */ |
2532 | - |
2533 | -#ifndef APPLICATION_MANAGER_H |
2534 | -#define APPLICATION_MANAGER_H |
2535 | - |
2536 | -#include <QObject> |
2537 | -#include <QList> |
2538 | -#include <QStringList> |
2539 | -#include <QTimer> |
2540 | -#include "ApplicationInfo.h" |
2541 | - |
2542 | -// unity-api |
2543 | -#include <unity/shell/application/ApplicationManagerInterface.h> |
2544 | - |
2545 | -namespace unity { |
2546 | - namespace shell { |
2547 | - namespace application { |
2548 | - class MirSurfaceInterface; |
2549 | - } |
2550 | - } |
2551 | -} |
2552 | - |
2553 | -class QQuickItem; |
2554 | -using namespace unity::shell::application; |
2555 | - |
2556 | -class ApplicationManager : public ApplicationManagerInterface { |
2557 | - Q_OBJECT |
2558 | - |
2559 | - Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged) |
2560 | - Q_PROPERTY(QStringList availableApplications READ availableApplications NOTIFY availableApplicationsChanged) |
2561 | - |
2562 | - public: |
2563 | - ApplicationManager(QObject *parent = nullptr); |
2564 | - virtual ~ApplicationManager(); |
2565 | - |
2566 | - // QAbstractItemModel methods. |
2567 | - int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
2568 | - QVariant data(const QModelIndex& index, int role) const override; |
2569 | - |
2570 | - // ApplicationManagerInterface methods |
2571 | - Q_INVOKABLE ApplicationInfo *get(int index) const override; |
2572 | - Q_INVOKABLE ApplicationInfo *findApplication(const QString &appId) const override; |
2573 | - unity::shell::application::ApplicationInfoInterface *findApplicationWithSurface(unity::shell::application::MirSurfaceInterface* surface) const override; |
2574 | - |
2575 | - Q_INVOKABLE void move(int from, int to); |
2576 | - |
2577 | - // Application control methods |
2578 | - Q_INVOKABLE bool requestFocusApplication(const QString &appId) override; |
2579 | - Q_INVOKABLE ApplicationInfo *startApplication(const QString &appId, const QStringList &arguments = QStringList()) override; |
2580 | - Q_INVOKABLE bool stopApplication(const QString &appId) override; |
2581 | - |
2582 | - QString focusedApplicationId() const override; |
2583 | - |
2584 | - // Only for testing |
2585 | - QStringList availableApplications(); |
2586 | - Q_INVOKABLE ApplicationInfo* add(QString appId); |
2587 | - |
2588 | - QModelIndex findIndex(ApplicationInfo* application); |
2589 | - |
2590 | - bool isEmpty() const; |
2591 | - |
2592 | - Q_SIGNALS: |
2593 | - void focusRequested(const QString &appId); |
2594 | - void emptyChanged(bool empty); |
2595 | - void availableApplicationsChanged(QStringList list); |
2596 | - |
2597 | - private Q_SLOTS: |
2598 | - void raiseApp(const QString &appId); |
2599 | - |
2600 | - private: |
2601 | - bool add(ApplicationInfo *application); |
2602 | - void remove(ApplicationInfo* application); |
2603 | - void buildListOfAvailableApplications(); |
2604 | - QString toString(); |
2605 | - ApplicationInfo *findApplication(MirSurface* surface); |
2606 | - QList<ApplicationInfo*> m_runningApplications; |
2607 | - QList<ApplicationInfo*> m_availableApplications; |
2608 | - bool m_modelBusy{false}; |
2609 | -}; |
2610 | - |
2611 | -/* |
2612 | - Lifecycle of the ApplicationManager instance belongs to the QML plugin. |
2613 | - So this guy here is used to notify other parts of the system when the plugin creates and destroys |
2614 | - the ApplicationManager. |
2615 | - |
2616 | - Unlike ApplicationManager, we create ApplicationManagerNotifier whenever we want. |
2617 | - */ |
2618 | -class ApplicationManagerNotifier : public QObject { |
2619 | - Q_OBJECT |
2620 | -public: |
2621 | - static ApplicationManagerNotifier *instance(); |
2622 | - |
2623 | - ApplicationManager *applicationManager() { return m_applicationManager; } |
2624 | - |
2625 | -Q_SIGNALS: |
2626 | - void applicationManagerChanged(ApplicationManager *applicationManager); |
2627 | - |
2628 | -private: |
2629 | - void setApplicationManager(ApplicationManager *); |
2630 | - static ApplicationManagerNotifier *m_instance; |
2631 | - ApplicationManager *m_applicationManager{nullptr}; |
2632 | - |
2633 | -friend class ApplicationManager; |
2634 | -}; |
2635 | - |
2636 | -Q_DECLARE_METATYPE(ApplicationManager*) |
2637 | - |
2638 | -#endif // APPLICATION_MANAGER_H |
2639 | |
2640 | === removed file 'tests/mocks/Unity/Application/CMakeLists.txt' |
2641 | --- tests/mocks/Unity/Application/CMakeLists.txt 2016-12-20 15:50:41 +0000 |
2642 | +++ tests/mocks/Unity/Application/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
2643 | @@ -1,35 +0,0 @@ |
2644 | -set(FakeUnityApplicationQml_SOURCES |
2645 | - plugin.cpp |
2646 | - ApplicationInfo.cpp |
2647 | - ApplicationManager.cpp |
2648 | - MirSurface.cpp |
2649 | - MirSurfaceItem.cpp |
2650 | - MirSurfaceListModel.cpp |
2651 | - MirMock.cpp |
2652 | - ObjectListModel.h |
2653 | - SurfaceManager.cpp |
2654 | - VirtualKeyboard.cpp |
2655 | - ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h |
2656 | - ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h |
2657 | - ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h |
2658 | - ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h |
2659 | - ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceItemInterface.h |
2660 | - ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h |
2661 | - ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/SurfaceManagerInterface.h |
2662 | - resources/surfaces.qrc |
2663 | -) |
2664 | - |
2665 | -add_library(FakeUnityApplicationQml MODULE ${FakeUnityApplicationQml_SOURCES}) |
2666 | - |
2667 | -add_library(NonMirUnityApplicationQml MODULE ${FakeUnityApplicationQml_SOURCES}) |
2668 | -set_target_properties(NonMirUnityApplicationQml PROPERTIES OUTPUT_NAME FakeUnityApplicationQml) |
2669 | - |
2670 | -qt5_use_modules(FakeUnityApplicationQml Core Quick DBus) |
2671 | -qt5_use_modules(NonMirUnityApplicationQml Core Quick DBus) |
2672 | - |
2673 | -add_unity8_mock(Unity.Application 0.1 Unity/Application TARGETS FakeUnityApplicationQml) |
2674 | -add_unity8_mock(Unity.Application 0.1 Unity/Application |
2675 | - PREFIX nonmirplugins |
2676 | - TARGETS NonMirUnityApplicationQml |
2677 | - BINARY_DIR ${CMAKE_BINARY_DIR}/nonmirplugins |
2678 | - NO_TYPES) |
2679 | |
2680 | === removed file 'tests/mocks/Unity/Application/MirMock.cpp' |
2681 | --- tests/mocks/Unity/Application/MirMock.cpp 2016-12-07 14:52:32 +0000 |
2682 | +++ tests/mocks/Unity/Application/MirMock.cpp 1970-01-01 00:00:00 +0000 |
2683 | @@ -1,62 +0,0 @@ |
2684 | -/* |
2685 | - * Copyright (C) 2016 Canonical, Ltd. |
2686 | - * |
2687 | - * This program is free software; you can redistribute it and/or modify |
2688 | - * it under the terms of the GNU General Public License as published by |
2689 | - * the Free Software Foundation; version 3. |
2690 | - * |
2691 | - * This program is distributed in the hope that it will be useful, |
2692 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2693 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2694 | - * GNU General Public License for more details. |
2695 | - * |
2696 | - * You should have received a copy of the GNU General Public License |
2697 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2698 | - */ |
2699 | - |
2700 | -#include "MirMock.h" |
2701 | - |
2702 | -MirMock *MirMock::the_mir = nullptr; |
2703 | - |
2704 | -MirMock *MirMock::instance() |
2705 | -{ |
2706 | - return the_mir; |
2707 | -} |
2708 | - |
2709 | -MirMock::MirMock() |
2710 | -{ |
2711 | - Q_ASSERT(the_mir == nullptr); |
2712 | - the_mir = this; |
2713 | -} |
2714 | - |
2715 | -MirMock::~MirMock() |
2716 | -{ |
2717 | - Q_ASSERT(the_mir == this); |
2718 | - the_mir = nullptr; |
2719 | -} |
2720 | - |
2721 | -void MirMock::setCursorName(const QString &cursorName) |
2722 | -{ |
2723 | - if (cursorName != m_cursorName) { |
2724 | - m_cursorName = cursorName; |
2725 | - Q_EMIT cursorNameChanged(m_cursorName); |
2726 | - } |
2727 | -} |
2728 | - |
2729 | -QString MirMock::cursorName() const |
2730 | -{ |
2731 | - return m_cursorName; |
2732 | -} |
2733 | - |
2734 | -QString MirMock::currentKeymap() const |
2735 | -{ |
2736 | - return m_keymap; |
2737 | -} |
2738 | - |
2739 | -void MirMock::setCurrentKeymap(const QString &keymap) |
2740 | -{ |
2741 | - if (keymap != m_keymap) { |
2742 | - m_keymap = keymap; |
2743 | - Q_EMIT currentKeymapChanged(m_keymap); |
2744 | - } |
2745 | -} |
2746 | |
2747 | === removed file 'tests/mocks/Unity/Application/MirMock.h' |
2748 | --- tests/mocks/Unity/Application/MirMock.h 2016-12-07 14:52:32 +0000 |
2749 | +++ tests/mocks/Unity/Application/MirMock.h 1970-01-01 00:00:00 +0000 |
2750 | @@ -1,43 +0,0 @@ |
2751 | -/* |
2752 | - * Copyright (C) 2016 Canonical, Ltd. |
2753 | - * |
2754 | - * This program is free software; you can redistribute it and/or modify |
2755 | - * it under the terms of the GNU General Public License as published by |
2756 | - * the Free Software Foundation; version 3. |
2757 | - * |
2758 | - * This program is distributed in the hope that it will be useful, |
2759 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2760 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2761 | - * GNU General Public License for more details. |
2762 | - * |
2763 | - * You should have received a copy of the GNU General Public License |
2764 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2765 | - */ |
2766 | - |
2767 | -#ifndef MIR_MOCK_H |
2768 | -#define MIR_MOCK_H |
2769 | - |
2770 | -#include <unity/shell/application/Mir.h> |
2771 | - |
2772 | -class MirMock : public ::Mir |
2773 | -{ |
2774 | - Q_OBJECT |
2775 | -public: |
2776 | - explicit MirMock(); |
2777 | - virtual ~MirMock(); |
2778 | - |
2779 | - static MirMock *instance(); |
2780 | - |
2781 | - void setCursorName(const QString &cursorName) override; |
2782 | - QString cursorName() const override; |
2783 | - |
2784 | - QString currentKeymap() const override; |
2785 | - void setCurrentKeymap(const QString &keymap) override; |
2786 | - |
2787 | -private: |
2788 | - static MirMock *the_mir; |
2789 | - QString m_cursorName; |
2790 | - QString m_keymap; |
2791 | -}; |
2792 | - |
2793 | -#endif |
2794 | |
2795 | === removed file 'tests/mocks/Unity/Application/MirSurface.cpp' |
2796 | --- tests/mocks/Unity/Application/MirSurface.cpp 2017-01-26 11:10:01 +0000 |
2797 | +++ tests/mocks/Unity/Application/MirSurface.cpp 1970-01-01 00:00:00 +0000 |
2798 | @@ -1,550 +0,0 @@ |
2799 | -/* |
2800 | - * Copyright (C) 2015-2016 Canonical, Ltd. |
2801 | - * |
2802 | - * This program is free software; you can redistribute it and/or modify |
2803 | - * it under the terms of the GNU General Public License as published by |
2804 | - * the Free Software Foundation; version 3. |
2805 | - * |
2806 | - * This program is distributed in the hope that it will be useful, |
2807 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2808 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2809 | - * GNU General Public License for more details. |
2810 | - * |
2811 | - * You should have received a copy of the GNU General Public License |
2812 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2813 | - */ |
2814 | - |
2815 | -#include "MirSurface.h" |
2816 | - |
2817 | -#include <QDebug> |
2818 | -#include <QQmlEngine> |
2819 | - |
2820 | -// local |
2821 | -#include "SurfaceManager.h" |
2822 | - |
2823 | -#define MIRSURFACE_DEBUG 0 |
2824 | - |
2825 | -#if MIRSURFACE_DEBUG |
2826 | -#define DEBUG_MSG(params) qDebug().nospace() << "MirSurface[" << (void*)this << "," << m_name << "]::" << __func__ << " " << params |
2827 | -#define XDEBUG_MSG(params) qDebug().nospace() << "MirSurface[" << (void*)this << "," << m_name << "]::" << params |
2828 | - |
2829 | -const char *stateToStr(Mir::State state) |
2830 | -{ |
2831 | - switch (state) { |
2832 | - case Mir::UnknownState: |
2833 | - return "unknown"; |
2834 | - case Mir::RestoredState: |
2835 | - return "restored"; |
2836 | - case Mir::MinimizedState: |
2837 | - return "minimized"; |
2838 | - case Mir::MaximizedState: |
2839 | - return "maximized"; |
2840 | - case Mir::VertMaximizedState: |
2841 | - return "vertMaximized"; |
2842 | - case Mir::FullscreenState: |
2843 | - return "fullscreen"; |
2844 | - case Mir::HorizMaximizedState: |
2845 | - return "horizMaximized"; |
2846 | - case Mir::MaximizedLeftState: |
2847 | - return "maximizedLeft"; |
2848 | - case Mir::MaximizedRightState: |
2849 | - return "maximizedRight"; |
2850 | - case Mir::MaximizedTopLeftState: |
2851 | - return "maximizedTopLeft"; |
2852 | - case Mir::MaximizedTopRightState: |
2853 | - return "maximizedTopRight"; |
2854 | - case Mir::MaximizedBottomLeftState: |
2855 | - return "maximizedBottomLeft"; |
2856 | - case Mir::MaximizedBottomRightState: |
2857 | - return "maximizedBottomRight"; |
2858 | - case Mir::HiddenState: |
2859 | - return "hidden"; |
2860 | - default: |
2861 | - return "???"; |
2862 | - } |
2863 | -} |
2864 | - |
2865 | -#else |
2866 | -#define DEBUG_MSG(params) ((void)0) |
2867 | -#define XDEBUG_MSG(params) ((void)0) |
2868 | -#endif |
2869 | - |
2870 | -using namespace unity::shell::application; |
2871 | - |
2872 | -MirSurface::MirSurface(const QString& name, |
2873 | - Mir::Type type, |
2874 | - Mir::State state, |
2875 | - MirSurface *parentSurface, |
2876 | - const QUrl& screenshot, |
2877 | - const QUrl &qmlFilePath) |
2878 | - : unity::shell::application::MirSurfaceInterface(nullptr) |
2879 | - , m_name(name) |
2880 | - , m_type(type) |
2881 | - , m_state(state) |
2882 | - , m_orientationAngle(Mir::Angle0) |
2883 | - , m_screenshotUrl(screenshot) |
2884 | - , m_qmlFilePath(qmlFilePath) |
2885 | - , m_live(true) |
2886 | - , m_focused(false) |
2887 | - , m_activeFocus(false) |
2888 | - , m_width(-1) |
2889 | - , m_height(-1) |
2890 | - , m_slowToResize(false) |
2891 | - , m_shellChrome(Mir::NormalChrome) |
2892 | - , m_parentSurface(parentSurface) |
2893 | - , m_childSurfaceList(new MirSurfaceListModel(this)) |
2894 | -{ |
2895 | - DEBUG_MSG("state=" << stateToStr(state)); |
2896 | - |
2897 | - QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); |
2898 | - |
2899 | - m_delayedResizeTimer.setInterval(600); |
2900 | - m_delayedResizeTimer.setSingleShot(true); |
2901 | - connect(&m_delayedResizeTimer, &QTimer::timeout, this, &MirSurface::applyDelayedResize); |
2902 | - |
2903 | - m_zombieTimer.setInterval(100); |
2904 | - m_zombieTimer.setSingleShot(true); |
2905 | - connect(&m_zombieTimer, &QTimer::timeout, this, [this](){ this->setLive(false); }); |
2906 | - |
2907 | - updateInputBoundsAfterResize(); |
2908 | -} |
2909 | - |
2910 | -MirSurface::~MirSurface() |
2911 | -{ |
2912 | - DEBUG_MSG(""); |
2913 | - |
2914 | - // Early warning, while MirSurface methods can still be accessed. |
2915 | - Q_EMIT destroyed(this); |
2916 | -} |
2917 | - |
2918 | -QString MirSurface::name() const |
2919 | -{ |
2920 | - return m_name; |
2921 | -} |
2922 | - |
2923 | -QString MirSurface::persistentId() const |
2924 | -{ |
2925 | - return m_name+"Id"; |
2926 | -} |
2927 | - |
2928 | -Mir::Type MirSurface::type() const |
2929 | -{ |
2930 | - return m_type; |
2931 | -} |
2932 | - |
2933 | -Mir::State MirSurface::state() const |
2934 | -{ |
2935 | - return m_state; |
2936 | -} |
2937 | - |
2938 | -void MirSurface::requestState(Mir::State state) |
2939 | -{ |
2940 | - if (state == m_state) { |
2941 | - return; |
2942 | - } |
2943 | - DEBUG_MSG(stateToStr(state)); |
2944 | - Q_EMIT stateRequested(state); |
2945 | -} |
2946 | - |
2947 | -void MirSurface::setState(Mir::State state) |
2948 | -{ |
2949 | - if (state == m_state) { |
2950 | - return; |
2951 | - } |
2952 | - DEBUG_MSG(stateToStr(state)); |
2953 | - |
2954 | - bool oldVisible = visible(); |
2955 | - |
2956 | - m_state = state; |
2957 | - Q_EMIT stateChanged(state); |
2958 | - |
2959 | - if (visible() != oldVisible) { |
2960 | - XDEBUG_MSG("visibleChanged("<<visible()<<")"); |
2961 | - Q_EMIT visibleChanged(visible()); |
2962 | - } |
2963 | -} |
2964 | - |
2965 | -bool MirSurface::live() const |
2966 | -{ |
2967 | - return m_live; |
2968 | -} |
2969 | - |
2970 | -bool MirSurface::visible() const |
2971 | -{ |
2972 | - return m_state != Mir::MinimizedState && m_state != Mir::HiddenState; |
2973 | -} |
2974 | - |
2975 | -void MirSurface::setLive(bool live) |
2976 | -{ |
2977 | - if (live == m_live) |
2978 | - return; |
2979 | - |
2980 | - DEBUG_MSG(live); |
2981 | - m_live = live; |
2982 | - Q_EMIT liveChanged(live); |
2983 | - |
2984 | - if (!m_live && m_views.count() == 0) { |
2985 | - deleteLater(); |
2986 | - } |
2987 | -} |
2988 | - |
2989 | -QUrl MirSurface::qmlFilePath() const |
2990 | -{ |
2991 | - return m_qmlFilePath; |
2992 | -} |
2993 | - |
2994 | -QUrl MirSurface::screenshotUrl() const |
2995 | -{ |
2996 | - return m_screenshotUrl; |
2997 | -} |
2998 | - |
2999 | -void MirSurface::setScreenshotUrl(QUrl screenshotUrl) |
3000 | -{ |
3001 | - if (screenshotUrl == m_screenshotUrl) |
3002 | - return; |
3003 | - |
3004 | - m_screenshotUrl = screenshotUrl; |
3005 | - Q_EMIT screenshotUrlChanged(screenshotUrl); |
3006 | -} |
3007 | - |
3008 | -Mir::OrientationAngle MirSurface::orientationAngle() const |
3009 | -{ |
3010 | - return m_orientationAngle; |
3011 | -} |
3012 | - |
3013 | -void MirSurface::setOrientationAngle(Mir::OrientationAngle angle) |
3014 | -{ |
3015 | - if (angle == m_orientationAngle) |
3016 | - return; |
3017 | - |
3018 | - m_orientationAngle = angle; |
3019 | - Q_EMIT orientationAngleChanged(angle); |
3020 | -} |
3021 | - |
3022 | -void MirSurface::setKeymap(const QString &value) |
3023 | -{ |
3024 | - if (value != m_keymap) { |
3025 | - DEBUG_MSG(value); |
3026 | - m_keymap = value; |
3027 | - Q_EMIT keymapChanged(m_keymap); |
3028 | - } |
3029 | -} |
3030 | - |
3031 | -QString MirSurface::keymap() const |
3032 | -{ |
3033 | - return m_keymap; |
3034 | -} |
3035 | - |
3036 | -Mir::ShellChrome MirSurface::shellChrome() const |
3037 | -{ |
3038 | - return m_shellChrome; |
3039 | -} |
3040 | - |
3041 | -void MirSurface::setShellChrome(Mir::ShellChrome shellChrome) |
3042 | -{ |
3043 | - if (shellChrome == m_shellChrome) |
3044 | - return; |
3045 | - |
3046 | - DEBUG_MSG(shellChrome); |
3047 | - m_shellChrome = shellChrome; |
3048 | - Q_EMIT shellChromeChanged(shellChrome); |
3049 | -} |
3050 | - |
3051 | -void MirSurface::registerView(qintptr viewId) |
3052 | -{ |
3053 | - m_views.insert(viewId, MirSurface::View{false}); |
3054 | - DEBUG_MSG(viewId << " after=" << m_views.count()); |
3055 | -} |
3056 | - |
3057 | -void MirSurface::unregisterView(qintptr viewId) |
3058 | -{ |
3059 | - m_views.remove(viewId); |
3060 | - DEBUG_MSG(viewId << " after=" << m_views.count() << " live=" << m_live); |
3061 | - if (!m_live && m_views.count() == 0) { |
3062 | - deleteLater(); |
3063 | - } |
3064 | - updateExposure(); |
3065 | -} |
3066 | - |
3067 | -void MirSurface::setViewExposure(qintptr viewId, bool visible) |
3068 | -{ |
3069 | - if (!m_views.contains(viewId)) return; |
3070 | - |
3071 | - m_views[viewId].visible = visible; |
3072 | - updateExposure(); |
3073 | -} |
3074 | - |
3075 | -void MirSurface::updateExposure() |
3076 | -{ |
3077 | - bool newExposure = false; |
3078 | - QHashIterator<qintptr, View> i(m_views); |
3079 | - while (i.hasNext()) { |
3080 | - i.next(); |
3081 | - newExposure |= i.value().visible; |
3082 | - } |
3083 | - |
3084 | - if (newExposure != m_exposed) { |
3085 | - m_exposed = newExposure; |
3086 | - DEBUG_MSG(m_exposed); |
3087 | - Q_EMIT exposedChanged(m_exposed); |
3088 | - updateInputBoundsAfterResize(); |
3089 | - } |
3090 | -} |
3091 | - |
3092 | -bool MirSurface::activeFocus() const |
3093 | -{ |
3094 | - return m_activeFocus; |
3095 | -} |
3096 | - |
3097 | -void MirSurface::setActiveFocus(bool value) |
3098 | -{ |
3099 | - if (m_activeFocus == value) |
3100 | - return; |
3101 | - |
3102 | - m_activeFocus = value; |
3103 | - |
3104 | - Q_EMIT activeFocusChanged(value); |
3105 | - |
3106 | - if (m_activeFocus && !m_focused) { |
3107 | - requestFocus(); |
3108 | - } |
3109 | -} |
3110 | - |
3111 | -int MirSurface::width() const |
3112 | -{ |
3113 | - return m_width; |
3114 | -} |
3115 | - |
3116 | -int MirSurface::height() const |
3117 | -{ |
3118 | - return m_height; |
3119 | -} |
3120 | - |
3121 | -void MirSurface::resize(int width, int height) |
3122 | -{ |
3123 | - if (m_slowToResize) { |
3124 | - if (!m_delayedResizeTimer.isActive()) { |
3125 | - m_delayedResize.setWidth(width); |
3126 | - m_delayedResize.setHeight(height); |
3127 | - m_delayedResizeTimer.start(); |
3128 | - } else { |
3129 | - m_pendingResize.setWidth(width); |
3130 | - m_pendingResize.setHeight(height); |
3131 | - } |
3132 | - } else { |
3133 | - doResize(width, height); |
3134 | - } |
3135 | -} |
3136 | - |
3137 | -void MirSurface::applyDelayedResize() |
3138 | -{ |
3139 | - doResize(m_delayedResize.width(), m_delayedResize.height()); |
3140 | - m_delayedResize.setWidth(-1); |
3141 | - m_delayedResize.setHeight(-1); |
3142 | - |
3143 | - if (m_pendingResize.isValid()) { |
3144 | - QSize size = m_pendingResize; |
3145 | - m_pendingResize.setWidth(-1); |
3146 | - m_pendingResize.setHeight(-1); |
3147 | - resize(size.width(), size.height()); |
3148 | - } |
3149 | -} |
3150 | - |
3151 | -void MirSurface::doResize(int width, int height) |
3152 | -{ |
3153 | - bool changed = false; |
3154 | - |
3155 | - if (width != m_width) { |
3156 | - m_width = width; |
3157 | - Q_EMIT widthChanged(); |
3158 | - changed = true; |
3159 | - } |
3160 | - |
3161 | - if (m_height != height) { |
3162 | - m_height = height; |
3163 | - Q_EMIT heightChanged(); |
3164 | - changed = true; |
3165 | - } |
3166 | - |
3167 | - if (changed) { |
3168 | - XDEBUG_MSG("sizeChanged(width="<<width<<", height="<<height<<")"); |
3169 | - Q_EMIT sizeChanged(QSize(width, height)); |
3170 | - } |
3171 | - |
3172 | - updateInputBoundsAfterResize(); |
3173 | -} |
3174 | - |
3175 | -void MirSurface::updateInputBoundsAfterResize() |
3176 | -{ |
3177 | - setInputBounds(QRect(0, 0, m_width, m_height)); |
3178 | -} |
3179 | - |
3180 | -bool MirSurface::isSlowToResize() const |
3181 | -{ |
3182 | - return m_slowToResize; |
3183 | -} |
3184 | - |
3185 | -void MirSurface::setSlowToResize(bool value) |
3186 | -{ |
3187 | - if (m_slowToResize != value) { |
3188 | - DEBUG_MSG(value); |
3189 | - m_slowToResize = value; |
3190 | - Q_EMIT slowToResizeChanged(); |
3191 | - if (!m_slowToResize && m_delayedResizeTimer.isActive()) { |
3192 | - m_delayedResizeTimer.stop(); |
3193 | - applyDelayedResize(); |
3194 | - } |
3195 | - } |
3196 | -} |
3197 | - |
3198 | -void MirSurface::setMinimumWidth(int value) |
3199 | -{ |
3200 | - if (value != m_minimumWidth) { |
3201 | - m_minimumWidth = value; |
3202 | - Q_EMIT minimumWidthChanged(m_minimumWidth); |
3203 | - } |
3204 | -} |
3205 | - |
3206 | -void MirSurface::setMaximumWidth(int value) |
3207 | -{ |
3208 | - if (value != m_maximumWidth) { |
3209 | - m_maximumWidth = value; |
3210 | - Q_EMIT maximumWidthChanged(m_maximumWidth); |
3211 | - } |
3212 | -} |
3213 | - |
3214 | -void MirSurface::setMinimumHeight(int value) |
3215 | -{ |
3216 | - if (value != m_minimumHeight) { |
3217 | - m_minimumHeight = value; |
3218 | - Q_EMIT minimumHeightChanged(m_minimumHeight); |
3219 | - } |
3220 | -} |
3221 | - |
3222 | -void MirSurface::setMaximumHeight(int value) |
3223 | -{ |
3224 | - if (value != m_maximumHeight) { |
3225 | - m_maximumHeight = value; |
3226 | - Q_EMIT maximumHeightChanged(m_maximumHeight); |
3227 | - } |
3228 | -} |
3229 | - |
3230 | -void MirSurface::setWidthIncrement(int value) |
3231 | -{ |
3232 | - if (value != m_widthIncrement) { |
3233 | - m_widthIncrement = value; |
3234 | - Q_EMIT widthIncrementChanged(m_widthIncrement); |
3235 | - } |
3236 | -} |
3237 | - |
3238 | -void MirSurface::setHeightIncrement(int value) |
3239 | -{ |
3240 | - if (value != m_heightIncrement) { |
3241 | - m_heightIncrement = value; |
3242 | - Q_EMIT heightIncrementChanged(m_heightIncrement); |
3243 | - } |
3244 | -} |
3245 | - |
3246 | -void MirSurface::close() |
3247 | -{ |
3248 | - DEBUG_MSG(""); |
3249 | - if (!m_zombieTimer.isActive()) { |
3250 | - m_zombieTimer.start(); |
3251 | - Q_EMIT closeRequested(); |
3252 | - } |
3253 | -} |
3254 | - |
3255 | -void MirSurface::activate() |
3256 | -{ |
3257 | - DEBUG_MSG(""); |
3258 | - SurfaceManager::instance()->activate(this); |
3259 | -} |
3260 | - |
3261 | -void MirSurface::requestFocus() |
3262 | -{ |
3263 | - DEBUG_MSG(""); |
3264 | - Q_EMIT focusRequested(); |
3265 | -} |
3266 | - |
3267 | -void MirSurface::setFocused(bool value) |
3268 | -{ |
3269 | - if (m_focused == value) |
3270 | - return; |
3271 | - |
3272 | - DEBUG_MSG("(" << value << ")"); |
3273 | - |
3274 | - m_focused = value; |
3275 | - Q_EMIT focusedChanged(value); |
3276 | -} |
3277 | - |
3278 | -bool MirSurface::focused() const |
3279 | -{ |
3280 | - return m_focused; |
3281 | -} |
3282 | - |
3283 | -QRect MirSurface::inputBounds() const |
3284 | -{ |
3285 | - return m_inputBounds; |
3286 | -} |
3287 | - |
3288 | -void MirSurface::setInputBounds(const QRect &boundsRect) |
3289 | -{ |
3290 | - if (boundsRect != m_inputBounds) { |
3291 | - m_inputBounds = boundsRect; |
3292 | - DEBUG_MSG("(" << m_inputBounds << ")"); |
3293 | - Q_EMIT inputBoundsChanged(m_inputBounds); |
3294 | - } |
3295 | -} |
3296 | - |
3297 | -void MirSurface::openMenu(qreal x, qreal y, qreal width, qreal height) |
3298 | -{ |
3299 | - auto *menu = SurfaceManager::instance()->createSurface("menu", Mir::MenuType, Mir::HiddenState, |
3300 | - this /* parentSurface */, |
3301 | - QUrl() /* screenshot */, |
3302 | - QUrl("qrc:///Unity/Application/KateMenu.qml")); |
3303 | - |
3304 | - menu->setRequestedPosition(QPoint(x,y)); |
3305 | - menu->resize(width, height); |
3306 | - menu->requestState(Mir::RestoredState); |
3307 | - |
3308 | - SurfaceManager::instance()->notifySurfaceCreated(menu); |
3309 | -} |
3310 | - |
3311 | -void MirSurface::openDialog(qreal x, qreal y, qreal width, qreal height) |
3312 | -{ |
3313 | - auto *dialog = SurfaceManager::instance()->createSurface("dialog", Mir::DialogType, Mir::HiddenState, |
3314 | - this /* parentSurface */, |
3315 | - QUrl() /* screenshot */, |
3316 | - QUrl("qrc:///Unity/Application/KateDialog.qml")); |
3317 | - |
3318 | - dialog->setRequestedPosition(QPoint(x,y)); |
3319 | - dialog->resize(width, height); |
3320 | - dialog->requestState(Mir::RestoredState); |
3321 | - |
3322 | - SurfaceManager::instance()->notifySurfaceCreated(dialog); |
3323 | - |
3324 | - dialog->requestFocus(); |
3325 | -} |
3326 | - |
3327 | -void MirSurface::setRequestedPosition(const QPoint &value) |
3328 | -{ |
3329 | - if (value != m_requestedPosition) { |
3330 | - m_requestedPosition = value; |
3331 | - Q_EMIT requestedPositionChanged(value); |
3332 | - |
3333 | - // fake-miral: always comply |
3334 | - m_position = m_requestedPosition; |
3335 | - XDEBUG_MSG("positionChanged("<<m_position<<")"); |
3336 | - Q_EMIT positionChanged(m_position); |
3337 | - } |
3338 | -} |
3339 | - |
3340 | -MirSurfaceInterface* MirSurface::parentSurface() const |
3341 | -{ |
3342 | - return m_parentSurface; |
3343 | -} |
3344 | - |
3345 | -MirSurfaceListInterface* MirSurface::childSurfaceList() const |
3346 | -{ |
3347 | - return m_childSurfaceList; |
3348 | -} |
3349 | |
3350 | === removed file 'tests/mocks/Unity/Application/MirSurface.h' |
3351 | --- tests/mocks/Unity/Application/MirSurface.h 2017-01-26 11:10:01 +0000 |
3352 | +++ tests/mocks/Unity/Application/MirSurface.h 1970-01-01 00:00:00 +0000 |
3353 | @@ -1,232 +0,0 @@ |
3354 | -/* |
3355 | - * Copyright (C) 2015-2016 Canonical, Ltd. |
3356 | - * |
3357 | - * This program is free software; you can redistribute it and/or modify |
3358 | - * it under the terms of the GNU General Public License as published by |
3359 | - * the Free Software Foundation; version 3. |
3360 | - * |
3361 | - * This program is distributed in the hope that it will be useful, |
3362 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3363 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3364 | - * GNU General Public License for more details. |
3365 | - * |
3366 | - * You should have received a copy of the GNU General Public License |
3367 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3368 | - */ |
3369 | - |
3370 | -#ifndef MOCK_MIR_SURFACE_H |
3371 | -#define MOCK_MIR_SURFACE_H |
3372 | - |
3373 | -#include <QObject> |
3374 | -#include <QTimer> |
3375 | -#include <QUrl> |
3376 | -#include <QHash> |
3377 | - |
3378 | -// unity-api |
3379 | -#include <unity/shell/application/MirSurfaceInterface.h> |
3380 | - |
3381 | -#include "MirSurfaceListModel.h" |
3382 | - |
3383 | -class MirSurface; |
3384 | - |
3385 | -class MirSurface : public unity::shell::application::MirSurfaceInterface |
3386 | -{ |
3387 | - Q_OBJECT |
3388 | - |
3389 | - //// |
3390 | - // for use in qml tests |
3391 | - Q_PROPERTY(int width READ width NOTIFY widthChanged) |
3392 | - Q_PROPERTY(int height READ height NOTIFY heightChanged) |
3393 | - Q_PROPERTY(bool activeFocus READ activeFocus NOTIFY activeFocusChanged) |
3394 | - Q_PROPERTY(bool slowToResize READ isSlowToResize WRITE setSlowToResize NOTIFY slowToResizeChanged) |
3395 | - Q_PROPERTY(bool exposed READ exposed NOTIFY exposedChanged) |
3396 | - |
3397 | -public: |
3398 | - MirSurface(const QString& name, |
3399 | - Mir::Type type, |
3400 | - Mir::State state, |
3401 | - MirSurface *parentSurface, |
3402 | - const QUrl& screenshot, |
3403 | - const QUrl &qmlFilePath = QUrl()); |
3404 | - virtual ~MirSurface(); |
3405 | - |
3406 | - //// |
3407 | - // unity.shell.application.MirSurface |
3408 | - |
3409 | - Mir::Type type() const override; |
3410 | - |
3411 | - QString name() const override; |
3412 | - |
3413 | - QString persistentId() const override; |
3414 | - |
3415 | - QPoint position() const override { return m_position; } |
3416 | - |
3417 | - QSize size() const override { return QSize(width(),height()); } |
3418 | - void resize(int width, int height) override; |
3419 | - void resize(const QSize &size) override { resize(size.width(), size.height()); } |
3420 | - |
3421 | - |
3422 | - Mir::State state() const override; |
3423 | - |
3424 | - bool live() const override; |
3425 | - |
3426 | - bool visible() const override; |
3427 | - |
3428 | - Mir::OrientationAngle orientationAngle() const override; |
3429 | - void setOrientationAngle(Mir::OrientationAngle) override; |
3430 | - |
3431 | - int minimumWidth() const override { return m_minimumWidth; } |
3432 | - int minimumHeight() const override { return m_minimumHeight; } |
3433 | - int maximumWidth() const override { return m_maximumWidth; } |
3434 | - int maximumHeight() const override { return m_maximumHeight; } |
3435 | - int widthIncrement() const override { return m_widthIncrement; } |
3436 | - int heightIncrement() const override { return m_heightIncrement; } |
3437 | - |
3438 | - void setKeymap(const QString &) override; |
3439 | - QString keymap() const override; |
3440 | - |
3441 | - Mir::ShellChrome shellChrome() const override; |
3442 | - |
3443 | - bool focused() const override; |
3444 | - QRect inputBounds() const override; |
3445 | - |
3446 | - bool confinesMousePointer() const override { return false; } |
3447 | - |
3448 | - QPoint requestedPosition() const override { return m_requestedPosition; } |
3449 | - void setRequestedPosition(const QPoint &) override; |
3450 | - |
3451 | - unity::shell::application::MirSurfaceInterface* parentSurface() const override; |
3452 | - unity::shell::application::MirSurfaceListInterface* childSurfaceList() const override; |
3453 | - |
3454 | - Q_INVOKABLE void close() override; |
3455 | - Q_INVOKABLE void activate() override; |
3456 | - |
3457 | - //// |
3458 | - // API for tests |
3459 | - |
3460 | - Q_INVOKABLE void requestFocus(); |
3461 | - Q_INVOKABLE void setLive(bool live); |
3462 | - Q_INVOKABLE void setShellChrome(Mir::ShellChrome shellChrome); |
3463 | - |
3464 | - int width() const; |
3465 | - int height() const; |
3466 | - |
3467 | - bool isSlowToResize() const; |
3468 | - void setSlowToResize(bool value); |
3469 | - |
3470 | - bool exposed() const { return m_exposed; } |
3471 | - |
3472 | - Q_INVOKABLE void setMinimumWidth(int); |
3473 | - Q_INVOKABLE void setMaximumWidth(int); |
3474 | - Q_INVOKABLE void setMinimumHeight(int); |
3475 | - Q_INVOKABLE void setMaximumHeight(int); |
3476 | - Q_INVOKABLE void setWidthIncrement(int); |
3477 | - Q_INVOKABLE void setHeightIncrement(int); |
3478 | - |
3479 | - Q_INVOKABLE virtual void setInputBounds(const QRect &boundsRect); |
3480 | - |
3481 | - Q_INVOKABLE void openMenu(qreal x, qreal y, qreal width, qreal height); |
3482 | - Q_INVOKABLE void openDialog(qreal x, qreal y, qreal width, qreal height); |
3483 | - |
3484 | - ///// |
3485 | - // internal mock stuff |
3486 | - |
3487 | - QUrl qmlFilePath() const; |
3488 | - |
3489 | - QUrl screenshotUrl() const; |
3490 | - void setScreenshotUrl(QUrl); |
3491 | - |
3492 | - bool activeFocus() const; |
3493 | - void setActiveFocus(bool); |
3494 | - |
3495 | - void registerView(qintptr viewId); |
3496 | - void unregisterView(qintptr viewId); |
3497 | - void setViewExposure(qintptr viewId, bool visible); |
3498 | - int viewCount() const { return m_views.count(); } |
3499 | - |
3500 | - void setFocused(bool value); |
3501 | - |
3502 | - void setState(Mir::State state); |
3503 | - |
3504 | - Mir::State previousState() const { return m_previousState; } |
3505 | - void setPreviousState(Mir::State state) { m_previousState = state; } |
3506 | - |
3507 | -public Q_SLOTS: |
3508 | - //// |
3509 | - // unity.shell.application.MirSurface |
3510 | - void requestState(Mir::State) override; |
3511 | - |
3512 | -Q_SIGNALS: |
3513 | - //// |
3514 | - // API for tests |
3515 | - void widthChanged(); |
3516 | - void heightChanged(); |
3517 | - void slowToResizeChanged(); |
3518 | - void exposedChanged(bool exposed); |
3519 | - |
3520 | - //// |
3521 | - // internal mock stuff |
3522 | - void screenshotUrlChanged(QUrl); |
3523 | - void activeFocusChanged(bool); |
3524 | - void closeRequested(); |
3525 | - void stateRequested(Mir::State); |
3526 | - |
3527 | -protected: |
3528 | - virtual void updateInputBoundsAfterResize(); |
3529 | - |
3530 | -private Q_SLOTS: |
3531 | - void applyDelayedResize(); |
3532 | - |
3533 | -private: |
3534 | - void doResize(int width, int height); |
3535 | - void updateExposure(); |
3536 | - |
3537 | - const QString m_name; |
3538 | - const Mir::Type m_type; |
3539 | - Mir::State m_state; |
3540 | - Mir::State m_previousState{Mir::UnknownState}; |
3541 | - Mir::OrientationAngle m_orientationAngle; |
3542 | - |
3543 | - QUrl m_screenshotUrl; |
3544 | - QUrl m_qmlFilePath; |
3545 | - bool m_live; |
3546 | - bool m_focused; |
3547 | - bool m_activeFocus; |
3548 | - int m_width; |
3549 | - int m_height; |
3550 | - |
3551 | - int m_minimumWidth{0}; |
3552 | - int m_minimumHeight{0}; |
3553 | - int m_maximumWidth{0}; |
3554 | - int m_maximumHeight{0}; |
3555 | - int m_widthIncrement{0}; |
3556 | - int m_heightIncrement{0}; |
3557 | - |
3558 | - QString m_keymap; |
3559 | - |
3560 | - bool m_slowToResize; |
3561 | - QTimer m_delayedResizeTimer; |
3562 | - QSize m_delayedResize; |
3563 | - QSize m_pendingResize; |
3564 | - |
3565 | - Mir::ShellChrome m_shellChrome; |
3566 | - |
3567 | - struct View { |
3568 | - bool visible; |
3569 | - }; |
3570 | - QHash<qintptr, View> m_views; |
3571 | - bool m_exposed{false}; |
3572 | - |
3573 | - QTimer m_zombieTimer; |
3574 | - |
3575 | - QRect m_inputBounds; |
3576 | - |
3577 | - QPoint m_position; |
3578 | - QPoint m_requestedPosition; |
3579 | - |
3580 | - unity::shell::application::MirSurfaceInterface* m_parentSurface; |
3581 | - |
3582 | - MirSurfaceListModel *m_childSurfaceList; |
3583 | -}; |
3584 | - |
3585 | -#endif // MOCK_MIR_SURFACE_H |
3586 | |
3587 | === removed file 'tests/mocks/Unity/Application/MirSurfaceItem.cpp' |
3588 | --- tests/mocks/Unity/Application/MirSurfaceItem.cpp 2017-01-26 11:10:01 +0000 |
3589 | +++ tests/mocks/Unity/Application/MirSurfaceItem.cpp 1970-01-01 00:00:00 +0000 |
3590 | @@ -1,415 +0,0 @@ |
3591 | -/* |
3592 | - * Copyright (C) 2014-2016 Canonical, Ltd. |
3593 | - * |
3594 | - * This program is free software; you can redistribute it and/or modify |
3595 | - * it under the terms of the GNU General Public License as published by |
3596 | - * the Free Software Foundation; version 3. |
3597 | - * |
3598 | - * This program is distributed in the hope that it will be useful, |
3599 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3600 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3601 | - * GNU General Public License for more details. |
3602 | - * |
3603 | - * You should have received a copy of the GNU General Public License |
3604 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3605 | - */ |
3606 | - |
3607 | -#include "MirSurfaceItem.h" |
3608 | - |
3609 | -#include <paths.h> |
3610 | - |
3611 | -#include <QGuiApplication> |
3612 | -#include <QQuickView> |
3613 | -#include <QQmlContext> |
3614 | -#include <QQmlProperty> |
3615 | -#include <QQmlEngine> |
3616 | -#include <QString> |
3617 | - |
3618 | -#include <QDebug> |
3619 | - |
3620 | -using namespace unity::shell::application; |
3621 | - |
3622 | -#define MIRSURFACEITEM_DEBUG 0 |
3623 | - |
3624 | -#if MIRSURFACEITEM_DEBUG |
3625 | -#define DEBUG_MSG(params) qDebug().nospace() << "MirSurfaceItem::" << __func__ << " " << params |
3626 | -#else |
3627 | -#define DEBUG_MSG(params) ((void)0) |
3628 | -#endif |
3629 | - |
3630 | -MirSurfaceItem::MirSurfaceItem(QQuickItem *parent) |
3631 | - : MirSurfaceItemInterface(parent) |
3632 | - , m_qmlSurface(nullptr) |
3633 | - , m_qmlContentComponent(nullptr) |
3634 | - , m_qmlItem(nullptr) |
3635 | - , m_consumesInput(false) |
3636 | - , m_orientationAngle(nullptr) |
3637 | - , m_surfaceWidth(0) |
3638 | - , m_surfaceHeight(0) |
3639 | - , m_touchPressCount(0) |
3640 | - , m_touchReleaseCount(0) |
3641 | - , m_mousePressCount(0) |
3642 | - , m_mouseReleaseCount(0) |
3643 | -{ |
3644 | - DEBUG_MSG((void*)(this) << name()); |
3645 | - setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton | |
3646 | - Qt::ExtraButton1 | Qt::ExtraButton2 | Qt::ExtraButton3 | Qt::ExtraButton4 | |
3647 | - Qt::ExtraButton5 | Qt::ExtraButton6 | Qt::ExtraButton7 | Qt::ExtraButton8 | |
3648 | - Qt::ExtraButton9 | Qt::ExtraButton10 | Qt::ExtraButton11 | |
3649 | - Qt::ExtraButton12 | Qt::ExtraButton13); |
3650 | - |
3651 | - connect(this, &QQuickItem::activeFocusChanged, this, &MirSurfaceItem::updateMirSurfaceActiveFocus); |
3652 | - connect(this, &QQuickItem::visibleChanged, this, &MirSurfaceItem::updateMirSurfaceExposure); |
3653 | - |
3654 | - connect(this, &MirSurfaceItem::consumesInputChanged, this, [this]() { |
3655 | - updateMirSurfaceActiveFocus(hasActiveFocus()); |
3656 | - }); |
3657 | - |
3658 | - // We're just clipping contents in the mock. The real QtMir would copy only relevant buffer instead |
3659 | - setClip(true); |
3660 | -} |
3661 | - |
3662 | -MirSurfaceItem::~MirSurfaceItem() |
3663 | -{ |
3664 | - DEBUG_MSG((void*)(this) << name()); |
3665 | - setSurface(nullptr); |
3666 | - delete m_orientationAngle; |
3667 | -} |
3668 | - |
3669 | -void MirSurfaceItem::printComponentErrors() |
3670 | -{ |
3671 | - QList<QQmlError> errors = m_qmlContentComponent->errors(); |
3672 | - for (int i = 0; i < errors.count(); ++i) { |
3673 | - qDebug() << errors[i]; |
3674 | - } |
3675 | -} |
3676 | - |
3677 | -Mir::Type MirSurfaceItem::type() const |
3678 | -{ |
3679 | - if (m_qmlSurface) { |
3680 | - return m_qmlSurface->type(); |
3681 | - } else { |
3682 | - return Mir::UnknownType; |
3683 | - } |
3684 | -} |
3685 | - |
3686 | -Mir::State MirSurfaceItem::surfaceState() const |
3687 | -{ |
3688 | - if (m_qmlSurface) { |
3689 | - return m_qmlSurface->state(); |
3690 | - } else { |
3691 | - return Mir::UnknownState; |
3692 | - } |
3693 | -} |
3694 | - |
3695 | -QString MirSurfaceItem::name() const |
3696 | -{ |
3697 | - if (m_qmlSurface) { |
3698 | - return m_qmlSurface->name(); |
3699 | - } else { |
3700 | - return QString(); |
3701 | - } |
3702 | -} |
3703 | - |
3704 | -bool MirSurfaceItem::live() const |
3705 | -{ |
3706 | - if (m_qmlSurface) { |
3707 | - return m_qmlSurface->live(); |
3708 | - } else { |
3709 | - return false; |
3710 | - } |
3711 | -} |
3712 | - |
3713 | -Mir::ShellChrome MirSurfaceItem::shellChrome() const |
3714 | -{ |
3715 | - if (m_qmlSurface) { |
3716 | - return m_qmlSurface->shellChrome(); |
3717 | - } else { |
3718 | - return Mir::NormalChrome; |
3719 | - } |
3720 | -} |
3721 | - |
3722 | -Mir::OrientationAngle MirSurfaceItem::orientationAngle() const |
3723 | -{ |
3724 | - if (m_orientationAngle) { |
3725 | - Q_ASSERT(!m_qmlSurface); |
3726 | - return *m_orientationAngle; |
3727 | - } else if (m_qmlSurface) { |
3728 | - return m_qmlSurface->orientationAngle(); |
3729 | - } else { |
3730 | - return Mir::Angle0; |
3731 | - } |
3732 | -} |
3733 | - |
3734 | -void MirSurfaceItem::setOrientationAngle(Mir::OrientationAngle angle) |
3735 | -{ |
3736 | - DEBUG_MSG(angle); |
3737 | - |
3738 | - if (m_qmlSurface) { |
3739 | - Q_ASSERT(!m_orientationAngle); |
3740 | - m_qmlSurface->setOrientationAngle(angle); |
3741 | - } else if (!m_orientationAngle) { |
3742 | - m_orientationAngle = new Mir::OrientationAngle; |
3743 | - *m_orientationAngle = angle; |
3744 | - Q_EMIT orientationAngleChanged(angle); |
3745 | - } else if (*m_orientationAngle != angle) { |
3746 | - *m_orientationAngle = angle; |
3747 | - Q_EMIT orientationAngleChanged(angle); |
3748 | - } |
3749 | - |
3750 | - if (m_qmlItem) { |
3751 | - QQmlProperty orientationProp(m_qmlItem, "orientationAngle"); |
3752 | - if (orientationProp.isValid()) { |
3753 | - orientationProp.write(QVariant::fromValue(orientationAngle())); |
3754 | - } |
3755 | - } |
3756 | -} |
3757 | - |
3758 | -void MirSurfaceItem::updateScreenshot(QUrl screenshotUrl) |
3759 | -{ |
3760 | - if (m_qmlItem) { |
3761 | - QQmlProperty screenshotSource(m_qmlItem, "screenshotSource"); |
3762 | - if (screenshotSource.isValid()) { |
3763 | - screenshotSource.write(QVariant::fromValue(screenshotUrl)); |
3764 | - } |
3765 | - } |
3766 | -} |
3767 | - |
3768 | -void MirSurfaceItem::onComponentStatusChanged(QQmlComponent::Status status) |
3769 | -{ |
3770 | - if (status == QQmlComponent::Ready) { |
3771 | - createQmlContentItem(); |
3772 | - } |
3773 | -} |
3774 | - |
3775 | -void MirSurfaceItem::createQmlContentItem() |
3776 | -{ |
3777 | - DEBUG_MSG(""); |
3778 | - |
3779 | - m_qmlItem = qobject_cast<QQuickItem*>(m_qmlContentComponent->create()); |
3780 | - m_qmlItem->setParentItem(this); |
3781 | - |
3782 | - m_qmlItem->setWidth(m_surfaceWidth); |
3783 | - m_qmlItem->setHeight(m_surfaceHeight); |
3784 | - |
3785 | - setImplicitWidth(m_qmlItem->implicitWidth()); |
3786 | - setImplicitHeight(m_qmlItem->implicitHeight()); |
3787 | - |
3788 | - { |
3789 | - QQmlProperty screenshotSource(m_qmlItem, "screenshotSource"); |
3790 | - if (screenshotSource.isValid()) { |
3791 | - screenshotSource.write(QVariant::fromValue(m_qmlSurface->screenshotUrl())); |
3792 | - } |
3793 | - } |
3794 | - |
3795 | - { |
3796 | - QQmlProperty orientationProp(m_qmlItem, "orientationAngle"); |
3797 | - if (orientationProp.isValid()) { |
3798 | - orientationProp.write(QVariant::fromValue(orientationAngle())); |
3799 | - } |
3800 | - } |
3801 | - |
3802 | - { |
3803 | - QQmlProperty surfaceProperty(m_qmlItem, "surface"); |
3804 | - if (surfaceProperty.isValid()) { |
3805 | - surfaceProperty.write(QVariant::fromValue(m_qmlSurface)); |
3806 | - } |
3807 | - } |
3808 | -} |
3809 | - |
3810 | -void MirSurfaceItem::touchEvent(QTouchEvent * event) |
3811 | -{ |
3812 | - if (event->type() == QEvent::TouchBegin) { |
3813 | - m_touchTrail.clear(); |
3814 | - } |
3815 | - |
3816 | - if (event->touchPointStates() & Qt::TouchPointPressed) { |
3817 | - ++m_touchPressCount; |
3818 | - Q_EMIT touchPressCountChanged(m_touchPressCount); |
3819 | - } else if (event->touchPointStates() & Qt::TouchPointReleased) { |
3820 | - ++m_touchReleaseCount; |
3821 | - Q_EMIT touchReleaseCountChanged(m_touchReleaseCount); |
3822 | - } |
3823 | - |
3824 | - Q_FOREACH(const QTouchEvent::TouchPoint &touchPoint, event->touchPoints()) { |
3825 | - QString id(touchPoint.id()); |
3826 | - QVariantList list = m_touchTrail[id].toList(); |
3827 | - list.append(QVariant::fromValue(touchPoint.pos())); |
3828 | - if (list.count() > 100) list.pop_front(); |
3829 | - m_touchTrail[id] = list; |
3830 | - } |
3831 | - |
3832 | - if (m_qmlItem) { |
3833 | - QQmlProperty touchTrail(m_qmlItem, "touchTrail"); |
3834 | - touchTrail.write(m_touchTrail); |
3835 | - } |
3836 | -} |
3837 | - |
3838 | -void MirSurfaceItem::mousePressEvent(QMouseEvent * event) |
3839 | -{ |
3840 | - m_mousePressCount++; |
3841 | - Q_EMIT mousePressCountChanged(m_mousePressCount); |
3842 | - event->accept(); |
3843 | -} |
3844 | - |
3845 | -void MirSurfaceItem::mouseMoveEvent(QMouseEvent * event) |
3846 | -{ |
3847 | - event->accept(); |
3848 | -} |
3849 | - |
3850 | -void MirSurfaceItem::mouseReleaseEvent(QMouseEvent * event) |
3851 | -{ |
3852 | - m_mouseReleaseCount++; |
3853 | - Q_EMIT mouseReleaseCountChanged(m_mouseReleaseCount); |
3854 | - event->accept(); |
3855 | -} |
3856 | - |
3857 | -void MirSurfaceItem::setSurface(MirSurfaceInterface* surface) |
3858 | -{ |
3859 | - DEBUG_MSG("this=" << (void*)(this) << " name=" << name() << " surface=" << surface); |
3860 | - |
3861 | - if (m_qmlSurface == surface) { |
3862 | - return; |
3863 | - } |
3864 | - |
3865 | - if (m_qmlSurface) { |
3866 | - delete m_qmlItem; |
3867 | - m_qmlItem = nullptr; |
3868 | - |
3869 | - delete m_qmlContentComponent; |
3870 | - m_qmlContentComponent = nullptr; |
3871 | - |
3872 | - if (hasActiveFocus() && m_consumesInput && m_qmlSurface->live()) { |
3873 | - m_qmlSurface->setActiveFocus(false); |
3874 | - } |
3875 | - |
3876 | - disconnect(m_qmlSurface, nullptr, this, nullptr); |
3877 | - m_qmlSurface->unregisterView((qintptr)this); |
3878 | - } |
3879 | - |
3880 | - m_qmlSurface = static_cast<MirSurface*>(surface); |
3881 | - |
3882 | - if (m_qmlSurface) { |
3883 | - m_qmlSurface->registerView((qintptr)this); |
3884 | - |
3885 | - updateSurfaceSize(); |
3886 | - updateMirSurfaceExposure(); |
3887 | - |
3888 | - if (m_orientationAngle) { |
3889 | - m_qmlSurface->setOrientationAngle(*m_orientationAngle); |
3890 | - connect(m_qmlSurface, &MirSurfaceInterface::orientationAngleChanged, this, &MirSurfaceItem::orientationAngleChanged); |
3891 | - delete m_orientationAngle; |
3892 | - m_orientationAngle = nullptr; |
3893 | - } else { |
3894 | - connect(m_qmlSurface, &MirSurfaceInterface::orientationAngleChanged, this, &MirSurfaceItem::orientationAngleChanged); |
3895 | - Q_EMIT orientationAngleChanged(m_qmlSurface->orientationAngle()); |
3896 | - } |
3897 | - |
3898 | - connect(m_qmlSurface, &MirSurface::screenshotUrlChanged, this, &MirSurfaceItem::updateScreenshot); |
3899 | - connect(m_qmlSurface, &MirSurface::liveChanged, this, &MirSurfaceItem::liveChanged); |
3900 | - connect(m_qmlSurface, &MirSurface::stateChanged, this, &MirSurfaceItem::surfaceStateChanged); |
3901 | - |
3902 | - QUrl qmlComponentFilePath; |
3903 | - if (!m_qmlSurface->qmlFilePath().isEmpty()) { |
3904 | - qmlComponentFilePath = m_qmlSurface->qmlFilePath(); |
3905 | - } else { |
3906 | - qmlComponentFilePath = QUrl("qrc:///Unity/Application/MirSurfaceItem.qml"); |
3907 | - } |
3908 | - |
3909 | - m_qmlContentComponent = new QQmlComponent(QQmlEngine::contextForObject(parent())->engine(), qmlComponentFilePath); |
3910 | - |
3911 | - switch (m_qmlContentComponent->status()) { |
3912 | - case QQmlComponent::Ready: |
3913 | - createQmlContentItem(); |
3914 | - break; |
3915 | - case QQmlComponent::Loading: |
3916 | - connect(m_qmlContentComponent, &QQmlComponent::statusChanged, |
3917 | - this, &MirSurfaceItem::onComponentStatusChanged); |
3918 | - break; |
3919 | - case QQmlComponent::Error: |
3920 | - printComponentErrors(); |
3921 | - qFatal("MirSurfaceItem: failed to create content component."); |
3922 | - break; |
3923 | - default: |
3924 | - qFatal("MirSurfaceItem: Unhandled component status"); |
3925 | - } |
3926 | - |
3927 | - if (m_consumesInput) { |
3928 | - m_qmlSurface->setActiveFocus(hasActiveFocus()); |
3929 | - } |
3930 | - } |
3931 | - |
3932 | - Q_EMIT surfaceChanged(m_qmlSurface); |
3933 | -} |
3934 | - |
3935 | - |
3936 | -void MirSurfaceItem::updateMirSurfaceActiveFocus(bool focused) |
3937 | -{ |
3938 | - if (m_qmlSurface && m_consumesInput && m_qmlSurface->live()) { |
3939 | - m_qmlSurface->setActiveFocus(focused); |
3940 | - } |
3941 | -} |
3942 | - |
3943 | -void MirSurfaceItem::updateMirSurfaceExposure() |
3944 | -{ |
3945 | - if (!m_qmlSurface) return; |
3946 | - |
3947 | - m_qmlSurface->setViewExposure((qintptr)this, isVisible()); |
3948 | -} |
3949 | - |
3950 | -void MirSurfaceItem::setConsumesInput(bool value) |
3951 | -{ |
3952 | - if (m_consumesInput != value) { |
3953 | - m_consumesInput = value; |
3954 | - Q_EMIT consumesInputChanged(value); |
3955 | - } |
3956 | -} |
3957 | - |
3958 | -int MirSurfaceItem::surfaceWidth() const |
3959 | -{ |
3960 | - return m_surfaceWidth; |
3961 | -} |
3962 | - |
3963 | -void MirSurfaceItem::setSurfaceWidth(int value) |
3964 | -{ |
3965 | -// qDebug() << "setSurfaceWidth called" << value; |
3966 | - if (value != -1 && m_surfaceWidth != value) { |
3967 | - m_surfaceWidth = value; |
3968 | - Q_EMIT surfaceWidthChanged(m_surfaceWidth); |
3969 | - updateSurfaceSize(); |
3970 | - } |
3971 | -} |
3972 | - |
3973 | -int MirSurfaceItem::surfaceHeight() const |
3974 | -{ |
3975 | - return m_surfaceHeight; |
3976 | -} |
3977 | - |
3978 | -void MirSurfaceItem::setSurfaceHeight(int value) |
3979 | -{ |
3980 | - if (value != -1 && m_surfaceHeight != value) { |
3981 | - m_surfaceHeight = value; |
3982 | - Q_EMIT surfaceHeightChanged(m_surfaceHeight); |
3983 | - updateSurfaceSize(); |
3984 | - } |
3985 | -} |
3986 | - |
3987 | -void MirSurfaceItem::updateSurfaceSize() |
3988 | -{ |
3989 | - if (m_qmlSurface && m_surfaceWidth > 0 && m_surfaceHeight > 0) { |
3990 | - m_qmlSurface->resize(m_surfaceWidth, m_surfaceHeight); |
3991 | - if (m_qmlItem) { |
3992 | - m_qmlItem->setWidth(m_surfaceWidth); |
3993 | - m_qmlItem->setHeight(m_surfaceHeight); |
3994 | - } |
3995 | - setImplicitSize(m_surfaceWidth, m_surfaceHeight); |
3996 | - } |
3997 | -} |
3998 | - |
3999 | -void MirSurfaceItem::setFillMode(FillMode value) |
4000 | -{ |
4001 | - if (value != m_fillMode) { |
4002 | - m_fillMode = value; |
4003 | - Q_EMIT fillModeChanged(m_fillMode); |
4004 | - } |
4005 | -} |
4006 | |
4007 | === removed file 'tests/mocks/Unity/Application/MirSurfaceItem.h' |
4008 | --- tests/mocks/Unity/Application/MirSurfaceItem.h 2016-11-30 19:24:02 +0000 |
4009 | +++ tests/mocks/Unity/Application/MirSurfaceItem.h 1970-01-01 00:00:00 +0000 |
4010 | @@ -1,138 +0,0 @@ |
4011 | -/* |
4012 | - * Copyright (C) 2014-2015 Canonical, Ltd. |
4013 | - * |
4014 | - * This program is free software; you can redistribute it and/or modify |
4015 | - * it under the terms of the GNU General Public License as published by |
4016 | - * the Free Software Foundation; version 3. |
4017 | - * |
4018 | - * This program is distributed in the hope that it will be useful, |
4019 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4020 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4021 | - * GNU General Public License for more details. |
4022 | - * |
4023 | - * You should have received a copy of the GNU General Public License |
4024 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4025 | - */ |
4026 | - |
4027 | -#ifndef MIRSURFACEITEM_H |
4028 | -#define MIRSURFACEITEM_H |
4029 | - |
4030 | -#include "MirSurface.h" |
4031 | - |
4032 | -#include <QQuickItem> |
4033 | -#include <QUrl> |
4034 | - |
4035 | -// unity-api |
4036 | -#include <unity/shell/application/MirSurfaceItemInterface.h> |
4037 | - |
4038 | -class MirSurfaceItem : public unity::shell::application::MirSurfaceItemInterface |
4039 | -{ |
4040 | - Q_OBJECT |
4041 | - |
4042 | - //// |
4043 | - // for use in qml tests |
4044 | - Q_PROPERTY(int touchPressCount READ touchPressCount WRITE setTouchPressCount |
4045 | - NOTIFY touchPressCountChanged DESIGNABLE false) |
4046 | - Q_PROPERTY(int touchReleaseCount READ touchReleaseCount WRITE setTouchReleaseCount |
4047 | - NOTIFY touchReleaseCountChanged DESIGNABLE false) |
4048 | - |
4049 | - Q_PROPERTY(int mousePressCount READ mousePressCount WRITE setMousePressCount |
4050 | - NOTIFY mousePressCountChanged) |
4051 | - Q_PROPERTY(int mouseReleaseCount READ mouseReleaseCount WRITE setMouseReleaseCount |
4052 | - NOTIFY mouseReleaseCountChanged) |
4053 | -public: |
4054 | - explicit MirSurfaceItem(QQuickItem *parent = 0); |
4055 | - ~MirSurfaceItem(); |
4056 | - |
4057 | - Mir::Type type() const override; |
4058 | - QString name() const override; |
4059 | - bool live() const override; |
4060 | - Mir::ShellChrome shellChrome() const override; |
4061 | - |
4062 | - Mir::State surfaceState() const override; |
4063 | - |
4064 | - Mir::OrientationAngle orientationAngle() const override; |
4065 | - void setOrientationAngle(Mir::OrientationAngle angle) override; |
4066 | - |
4067 | - unity::shell::application::MirSurfaceInterface* surface() const override { return m_qmlSurface; } |
4068 | - void setSurface(unity::shell::application::MirSurfaceInterface*) override; |
4069 | - |
4070 | - bool consumesInput() const override { return m_consumesInput; } |
4071 | - void setConsumesInput(bool value) override; |
4072 | - |
4073 | - int surfaceWidth() const override; |
4074 | - void setSurfaceWidth(int value) override; |
4075 | - |
4076 | - int surfaceHeight() const override; |
4077 | - void setSurfaceHeight(int value) override; |
4078 | - |
4079 | - FillMode fillMode() const override { return m_fillMode; } |
4080 | - void setFillMode(FillMode value) override; |
4081 | - |
4082 | - ///// |
4083 | - // For use in qml tests |
4084 | - |
4085 | - void setLive(bool live); |
4086 | - |
4087 | - int touchPressCount() const { return m_touchPressCount; } |
4088 | - void setTouchPressCount(int count) { m_touchPressCount = count; Q_EMIT touchPressCountChanged(count); } |
4089 | - |
4090 | - int touchReleaseCount() const { return m_touchReleaseCount; } |
4091 | - void setTouchReleaseCount(int count) { m_touchReleaseCount = count; Q_EMIT touchReleaseCountChanged(count); } |
4092 | - |
4093 | - int mousePressCount() const { return m_mousePressCount; } |
4094 | - void setMousePressCount(int count) { m_mousePressCount = count; Q_EMIT mousePressCountChanged(count); } |
4095 | - |
4096 | - int mouseReleaseCount() const { return m_mouseReleaseCount; } |
4097 | - void setMouseReleaseCount(int count) { m_mouseReleaseCount = count; Q_EMIT mouseReleaseCountChanged(count); } |
4098 | - |
4099 | -Q_SIGNALS: |
4100 | - void touchPressCountChanged(int count); |
4101 | - void touchReleaseCountChanged(int count); |
4102 | - void mousePressCountChanged(int count); |
4103 | - void mouseReleaseCountChanged(int count); |
4104 | - |
4105 | -protected: |
4106 | - void touchEvent(QTouchEvent * event) override; |
4107 | - void mousePressEvent(QMouseEvent * event) override; |
4108 | - void mouseMoveEvent(QMouseEvent * event) override; |
4109 | - void mouseReleaseEvent(QMouseEvent * event) override; |
4110 | - |
4111 | -private Q_SLOTS: |
4112 | - void onComponentStatusChanged(QQmlComponent::Status status); |
4113 | - void updateScreenshot(QUrl screenshot); |
4114 | - void updateMirSurfaceExposure(); |
4115 | - void updateMirSurfaceActiveFocus(bool focused); |
4116 | - |
4117 | -private: |
4118 | - void createQmlContentItem(); |
4119 | - void printComponentErrors(); |
4120 | - void updateSurfaceSize(); |
4121 | - |
4122 | - MirSurface* m_qmlSurface; |
4123 | - |
4124 | - QQmlComponent *m_qmlContentComponent; |
4125 | - QQuickItem *m_qmlItem; |
4126 | - |
4127 | - bool m_consumesInput; |
4128 | - |
4129 | - Mir::OrientationAngle *m_orientationAngle; |
4130 | - |
4131 | - int m_surfaceWidth; |
4132 | - int m_surfaceHeight; |
4133 | - |
4134 | - int m_touchPressCount; |
4135 | - int m_touchReleaseCount; |
4136 | - int m_mousePressCount; |
4137 | - int m_mouseReleaseCount; |
4138 | - QVariantMap m_touchTrail; |
4139 | - |
4140 | - FillMode m_fillMode{Stretch}; |
4141 | - |
4142 | - friend class SurfaceManager; |
4143 | -}; |
4144 | - |
4145 | -Q_DECLARE_METATYPE(MirSurfaceItem*) |
4146 | -Q_DECLARE_METATYPE(QList<MirSurfaceItem*>) |
4147 | - |
4148 | -#endif // MIRSURFACEITEM_H |
4149 | |
4150 | === removed file 'tests/mocks/Unity/Application/MirSurfaceListModel.cpp' |
4151 | --- tests/mocks/Unity/Application/MirSurfaceListModel.cpp 2016-11-30 19:24:02 +0000 |
4152 | +++ tests/mocks/Unity/Application/MirSurfaceListModel.cpp 1970-01-01 00:00:00 +0000 |
4153 | @@ -1,136 +0,0 @@ |
4154 | -/* |
4155 | - * Copyright (C) 2016 Canonical, Ltd. |
4156 | - * |
4157 | - * This program is free software; you can redistribute it and/or modify |
4158 | - * it under the terms of the GNU General Public License as published by |
4159 | - * the Free Software Foundation; version 3. |
4160 | - * |
4161 | - * This program is distributed in the hope that it will be useful, |
4162 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4163 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4164 | - * GNU General Public License for more details. |
4165 | - * |
4166 | - * You should have received a copy of the GNU General Public License |
4167 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4168 | - */ |
4169 | - |
4170 | -#include "MirSurfaceListModel.h" |
4171 | -#include "ApplicationInfo.h" |
4172 | - |
4173 | -#include "MirSurface.h" |
4174 | - |
4175 | -#define MIRSURFACELISTMODEL_DEBUG 0 |
4176 | - |
4177 | -#if MIRSURFACELISTMODEL_DEBUG |
4178 | -#include <QDebug> |
4179 | -#define DEBUG_MSG(params) qDebug().nospace() << "MirSurfaceListModel::" << __func__ << params |
4180 | -#else |
4181 | -#define DEBUG_MSG(params) ((void)0) |
4182 | -#endif |
4183 | - |
4184 | -using namespace unity::shell::application; |
4185 | - |
4186 | -MirSurfaceListModel::MirSurfaceListModel(QObject *parent) : |
4187 | - MirSurfaceListInterface(parent) |
4188 | -{ |
4189 | -} |
4190 | - |
4191 | -int MirSurfaceListModel::rowCount(const QModelIndex &parent) const |
4192 | -{ |
4193 | - return !parent.isValid() ? m_surfaceList.size() : 0; |
4194 | -} |
4195 | - |
4196 | -QVariant MirSurfaceListModel::data(const QModelIndex& index, int role) const |
4197 | -{ |
4198 | - if (index.row() < 0 || index.row() >= m_surfaceList.size()) |
4199 | - return QVariant(); |
4200 | - |
4201 | - if (role == SurfaceRole) { |
4202 | - MirSurface *surface = m_surfaceList.at(index.row()); |
4203 | - return QVariant::fromValue(static_cast<unity::shell::application::MirSurfaceInterface*>(surface)); |
4204 | - } else { |
4205 | - return QVariant(); |
4206 | - } |
4207 | -} |
4208 | - |
4209 | -void MirSurfaceListModel::raise(MirSurface *surface) |
4210 | -{ |
4211 | - DEBUG_MSG("(" << surface << ")"); |
4212 | - int i = m_surfaceList.indexOf(surface); |
4213 | - if (i != -1) { |
4214 | - moveSurface(i, 0); |
4215 | - } |
4216 | -} |
4217 | - |
4218 | -void MirSurfaceListModel::addSurface(MirSurface *surface) |
4219 | -{ |
4220 | - DEBUG_MSG("(" << surface << ")"); |
4221 | - beginInsertRows(QModelIndex(), 0, 0); |
4222 | - m_surfaceList.prepend(surface); |
4223 | - connectSurface(surface); |
4224 | - endInsertRows(); |
4225 | - Q_EMIT countChanged(m_surfaceList.count()); |
4226 | - Q_EMIT firstChanged(); |
4227 | -} |
4228 | - |
4229 | -void MirSurfaceListModel::connectSurface(MirSurface *surface) |
4230 | -{ |
4231 | - connect(surface, &QObject::destroyed, this, [this, surface](){ this->removeSurface(surface); }); |
4232 | - connect(surface, &MirSurfaceInterface::focusedChanged, this, [this, surface](bool surfaceFocused){ |
4233 | - if (surfaceFocused) { |
4234 | - raise(surface); |
4235 | - } |
4236 | - }); |
4237 | -} |
4238 | - |
4239 | -void MirSurfaceListModel::removeSurface(MirSurface *surface) |
4240 | -{ |
4241 | - int i = m_surfaceList.indexOf(surface); |
4242 | - if (i != -1) { |
4243 | - beginRemoveRows(QModelIndex(), i, i); |
4244 | - m_surfaceList.removeAt(i); |
4245 | - endRemoveRows(); |
4246 | - Q_EMIT countChanged(m_surfaceList.count()); |
4247 | - if (m_surfaceList.count() == 0 || i == 0) { |
4248 | - Q_EMIT firstChanged(); |
4249 | - } |
4250 | - } |
4251 | -} |
4252 | - |
4253 | -void MirSurfaceListModel::moveSurface(int from, int to) |
4254 | -{ |
4255 | - if (from == to) return; |
4256 | - |
4257 | - if (from >= 0 && from < m_surfaceList.size() && to >= 0 && to < m_surfaceList.size()) { |
4258 | - QModelIndex parent; |
4259 | - /* When moving an item down, the destination index needs to be incremented |
4260 | - by one, as explained in the documentation: |
4261 | - http://qt-project.org/doc/qt-5.0/qtcore/qabstractitemmodel.html#beginMoveRows */ |
4262 | - |
4263 | - beginMoveRows(parent, from, from, parent, to + (to > from ? 1 : 0)); |
4264 | - m_surfaceList.move(from, to); |
4265 | - endMoveRows(); |
4266 | - } |
4267 | - |
4268 | - if ((from == 0 || to == 0) && m_surfaceList.count() > 1) { |
4269 | - Q_EMIT firstChanged(); |
4270 | - } |
4271 | -} |
4272 | - |
4273 | -MirSurfaceInterface *MirSurfaceListModel::get(int index) |
4274 | -{ |
4275 | - if (index >=0 && index < m_surfaceList.count()) { |
4276 | - return m_surfaceList[index]; |
4277 | - } else { |
4278 | - return nullptr; |
4279 | - } |
4280 | -} |
4281 | - |
4282 | -const MirSurfaceInterface *MirSurfaceListModel::get(int index) const |
4283 | -{ |
4284 | - if (index >=0 && index < m_surfaceList.count()) { |
4285 | - return m_surfaceList.at(index); |
4286 | - } else { |
4287 | - return nullptr; |
4288 | - } |
4289 | -} |
4290 | |
4291 | === removed file 'tests/mocks/Unity/Application/MirSurfaceListModel.h' |
4292 | --- tests/mocks/Unity/Application/MirSurfaceListModel.h 2017-01-26 11:10:01 +0000 |
4293 | +++ tests/mocks/Unity/Application/MirSurfaceListModel.h 1970-01-01 00:00:00 +0000 |
4294 | @@ -1,56 +0,0 @@ |
4295 | -/* |
4296 | - * Copyright (C) 2016 Canonical, Ltd. |
4297 | - * |
4298 | - * This program is free software; you can redistribute it and/or modify |
4299 | - * it under the terms of the GNU General Public License as published by |
4300 | - * the Free Software Foundation; version 3. |
4301 | - * |
4302 | - * This program is distributed in the hope that it will be useful, |
4303 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4304 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4305 | - * GNU General Public License for more details. |
4306 | - * |
4307 | - * You should have received a copy of the GNU General Public License |
4308 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4309 | - */ |
4310 | - |
4311 | -#ifndef MIRSURFACELISTMODEL_H |
4312 | -#define MIRSURFACELISTMODEL_H |
4313 | - |
4314 | -// unity-api |
4315 | -#include <unity/shell/application/MirSurfaceListInterface.h> |
4316 | - |
4317 | -#include <QAbstractListModel> |
4318 | -#include <QList> |
4319 | - |
4320 | -class MirSurface; |
4321 | - |
4322 | -class MirSurfaceListModel : public unity::shell::application::MirSurfaceListInterface |
4323 | -{ |
4324 | - Q_OBJECT |
4325 | -public: |
4326 | - explicit MirSurfaceListModel(QObject *parent = 0); |
4327 | - |
4328 | - Q_INVOKABLE unity::shell::application::MirSurfaceInterface *get(int index) override; |
4329 | - const unity::shell::application::MirSurfaceInterface *get(int index) const; |
4330 | - |
4331 | - // QAbstractItemModel methods |
4332 | - int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
4333 | - QVariant data(const QModelIndex& index, int role) const override; |
4334 | - |
4335 | - void addSurface(MirSurface *surface); |
4336 | - void removeSurface(MirSurface *surface); |
4337 | - |
4338 | - bool contains(MirSurface *surface) const { return m_surfaceList.contains(surface); } |
4339 | - |
4340 | -private: |
4341 | - void raise(MirSurface *surface); |
4342 | - void moveSurface(int from, int to); |
4343 | - void connectSurface(MirSurface *surface); |
4344 | - |
4345 | - QList<MirSurface*> m_surfaceList; |
4346 | -}; |
4347 | - |
4348 | -Q_DECLARE_METATYPE(MirSurfaceListModel*) |
4349 | - |
4350 | -#endif // MIRSURFACELISTMODEL_H |
4351 | |
4352 | === removed file 'tests/mocks/Unity/Application/ObjectListModel.h' |
4353 | --- tests/mocks/Unity/Application/ObjectListModel.h 2016-04-04 13:37:49 +0000 |
4354 | +++ tests/mocks/Unity/Application/ObjectListModel.h 1970-01-01 00:00:00 +0000 |
4355 | @@ -1,108 +0,0 @@ |
4356 | -/* |
4357 | - * Copyright (C) 2014 Canonical, Ltd. |
4358 | - * |
4359 | - * This program is free software: you can redistribute it and/or modify it under |
4360 | - * the terms of the GNU Lesser General Public License version 3, as published by |
4361 | - * the Free Software Foundation. |
4362 | - * |
4363 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
4364 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
4365 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4366 | - * Lesser General Public License for more details. |
4367 | - * |
4368 | - * You should have received a copy of the GNU Lesser General Public License |
4369 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4370 | - */ |
4371 | - |
4372 | -#ifndef OBJECTLISTMODEL_H |
4373 | -#define OBJECTLISTMODEL_H |
4374 | - |
4375 | -// Qt |
4376 | -#include <QAbstractListModel> |
4377 | - |
4378 | -#include <QDebug> |
4379 | - |
4380 | -template<class TYPE> |
4381 | -class ObjectListModel : public QAbstractListModel |
4382 | -{ |
4383 | -public: |
4384 | - ObjectListModel(QObject *parent = 0) |
4385 | - : QAbstractListModel(parent) |
4386 | - {} |
4387 | - |
4388 | - enum Roles { |
4389 | - RoleModelData = Qt::UserRole, |
4390 | - }; |
4391 | - |
4392 | - const QList<TYPE*>& list() const { return m_items; } |
4393 | - bool contains(TYPE* item) const { return m_items.contains(item); } |
4394 | - |
4395 | - void insert(uint index, TYPE* item) |
4396 | - { |
4397 | - index = qMin(index, (uint)m_items.count()); |
4398 | - |
4399 | - int existingIndex = m_items.indexOf(item); |
4400 | - if (existingIndex != -1) { |
4401 | - move(existingIndex, qMin(index, (uint)(m_items.count()-1))); |
4402 | - } else { |
4403 | - beginInsertRows(QModelIndex(), index, index); |
4404 | - m_items.insert(index, item); |
4405 | - endInsertRows(); |
4406 | - } |
4407 | - } |
4408 | - |
4409 | - void remove(TYPE* item) |
4410 | - { |
4411 | - int existingIndex = m_items.indexOf(item); |
4412 | - if (existingIndex != -1) { |
4413 | - beginRemoveRows(QModelIndex(), existingIndex, existingIndex); |
4414 | - m_items.removeAt(existingIndex); |
4415 | - endRemoveRows(); |
4416 | - } |
4417 | - } |
4418 | - |
4419 | - // from QAbstractItemModel |
4420 | - int rowCount(const QModelIndex& = QModelIndex()) const override |
4421 | - { |
4422 | - return m_items.count(); |
4423 | - } |
4424 | - |
4425 | - QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override |
4426 | - { |
4427 | - if (index.row() >= 0 && index.row() < m_items.count()) { |
4428 | - if (role == RoleModelData) { |
4429 | - TYPE *item = m_items.at(index.row()); |
4430 | - return QVariant::fromValue(item); |
4431 | - } |
4432 | - } |
4433 | - return QVariant(); |
4434 | - } |
4435 | - |
4436 | - QHash<int, QByteArray> roleNames() const override |
4437 | - { |
4438 | - QHash<int, QByteArray> roleNames; |
4439 | - roleNames.insert(RoleModelData, "modelData"); |
4440 | - return roleNames; |
4441 | - } |
4442 | - |
4443 | -protected: |
4444 | - void move(int from, int to) |
4445 | - { |
4446 | - if (from == to) return; |
4447 | - |
4448 | - if (from >= 0 && from < m_items.size() && to >= 0 && to < m_items.size()) { |
4449 | - QModelIndex parent; |
4450 | - /* When moving an item down, the destination index needs to be incremented |
4451 | - by one, as explained in the documentation: |
4452 | - http://qt-project.org/doc/qt-5.0/qtcore/qabstractitemmodel.html#beginMoveRows */ |
4453 | - |
4454 | - beginMoveRows(parent, from, from, parent, to + (to > from ? 1 : 0)); |
4455 | - m_items.move(from, to); |
4456 | - endMoveRows(); |
4457 | - } |
4458 | - } |
4459 | - |
4460 | - QList<TYPE*> m_items; |
4461 | -}; |
4462 | - |
4463 | -#endif // OBJECTLISTMODEL_H |
4464 | |
4465 | === removed file 'tests/mocks/Unity/Application/SurfaceManager.cpp' |
4466 | --- tests/mocks/Unity/Application/SurfaceManager.cpp 2017-02-07 16:21:09 +0000 |
4467 | +++ tests/mocks/Unity/Application/SurfaceManager.cpp 1970-01-01 00:00:00 +0000 |
4468 | @@ -1,281 +0,0 @@ |
4469 | -/* |
4470 | - * Copyright (C) 2014-2016 Canonical, Ltd. |
4471 | - * |
4472 | - * This program is free software; you can redistribute it and/or modify |
4473 | - * it under the terms of the GNU General Public License as published by |
4474 | - * the Free Software Foundation; version 3. |
4475 | - * |
4476 | - * This program is distributed in the hope that it will be useful, |
4477 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4478 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4479 | - * GNU General Public License for more details. |
4480 | - * |
4481 | - * You should have received a copy of the GNU General Public License |
4482 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4483 | - */ |
4484 | - |
4485 | -#include "SurfaceManager.h" |
4486 | - |
4487 | -#include "ApplicationInfo.h" |
4488 | -#include "VirtualKeyboard.h" |
4489 | - |
4490 | -#include <paths.h> |
4491 | - |
4492 | -#define SURFACEMANAGER_DEBUG 0 |
4493 | - |
4494 | -#if SURFACEMANAGER_DEBUG |
4495 | -#define DEBUG_MSG(params) qDebug().nospace() << "SurfaceManager[" << (void*)this << "]::" << __func__ << params |
4496 | -#else |
4497 | -#define DEBUG_MSG(params) ((void)0) |
4498 | -#endif |
4499 | - |
4500 | -namespace unityapi = unity::shell::application; |
4501 | - |
4502 | -SurfaceManager *SurfaceManager::m_instance = nullptr; |
4503 | - |
4504 | -SurfaceManager *SurfaceManager::instance() |
4505 | -{ |
4506 | - return m_instance; |
4507 | -} |
4508 | - |
4509 | -SurfaceManager::SurfaceManager(QObject *) |
4510 | -{ |
4511 | - DEBUG_MSG(""); |
4512 | - |
4513 | - Q_ASSERT(m_instance == nullptr); |
4514 | - m_instance = this; |
4515 | -} |
4516 | - |
4517 | -SurfaceManager::~SurfaceManager() |
4518 | -{ |
4519 | - DEBUG_MSG(""); |
4520 | - |
4521 | - if (m_virtualKeyboard) { |
4522 | - m_virtualKeyboard->setLive(false); |
4523 | - } |
4524 | - |
4525 | - Q_ASSERT(m_instance == this); |
4526 | - m_instance = nullptr; |
4527 | -} |
4528 | - |
4529 | -MirSurface *SurfaceManager::createSurface(const QString& name, |
4530 | - Mir::Type type, |
4531 | - Mir::State state, |
4532 | - MirSurface *parentSurface, |
4533 | - const QUrl &screenshot, |
4534 | - const QUrl &qmlFilePath) |
4535 | -{ |
4536 | - MirSurface* surface = new MirSurface(name, type, state, parentSurface, screenshot, qmlFilePath); |
4537 | - registerSurface(surface); |
4538 | - if (parentSurface) { |
4539 | - static_cast<MirSurfaceListModel*>(parentSurface->childSurfaceList())->addSurface(surface); |
4540 | - } |
4541 | - return surface; |
4542 | -} |
4543 | - |
4544 | -void SurfaceManager::registerSurface(MirSurface *surface) |
4545 | -{ |
4546 | - m_surfaces.prepend(surface); |
4547 | - |
4548 | - if (!surface->parentSurface()) { |
4549 | - surface->setMinimumWidth(m_newSurfaceMinimumWidth); |
4550 | - surface->setMaximumWidth(m_newSurfaceMaximumWidth); |
4551 | - surface->setMinimumHeight(m_newSurfaceMinimumHeight); |
4552 | - surface->setMaximumHeight(m_newSurfaceMaximumHeight); |
4553 | - surface->setWidthIncrement(m_newSurfaceWidthIncrement); |
4554 | - surface->setHeightIncrement(m_newSurfaceHeightIncrement); |
4555 | - } |
4556 | - |
4557 | - connect(surface, &MirSurface::stateRequested, this, [=](Mir::State state) { |
4558 | - this->onStateRequested(surface, state); |
4559 | - }); |
4560 | - |
4561 | - const QString persistentId = surface->persistentId(); |
4562 | - connect(surface, &QObject::destroyed, this, [=]() { |
4563 | - this->onSurfaceDestroyed(surface, persistentId); |
4564 | - }); |
4565 | - |
4566 | -} |
4567 | - |
4568 | -void SurfaceManager::notifySurfaceCreated(unityapi::MirSurfaceInterface *surface) |
4569 | -{ |
4570 | - Q_EMIT surfaceCreated(surface); |
4571 | -} |
4572 | - |
4573 | -void SurfaceManager::setNewSurfaceMinimumWidth(int value) |
4574 | -{ |
4575 | - if (m_newSurfaceMinimumWidth != value) { |
4576 | - m_newSurfaceMinimumWidth = value; |
4577 | - Q_EMIT newSurfaceMinimumWidthChanged(m_newSurfaceMinimumWidth); |
4578 | - } |
4579 | -} |
4580 | - |
4581 | -void SurfaceManager::setNewSurfaceMaximumWidth(int value) |
4582 | -{ |
4583 | - if (m_newSurfaceMaximumWidth != value) { |
4584 | - m_newSurfaceMaximumWidth = value; |
4585 | - Q_EMIT newSurfaceMaximumWidthChanged(m_newSurfaceMaximumWidth); |
4586 | - } |
4587 | -} |
4588 | - |
4589 | -void SurfaceManager::setNewSurfaceMinimumHeight(int value) |
4590 | -{ |
4591 | - if (m_newSurfaceMinimumHeight != value) { |
4592 | - m_newSurfaceMinimumHeight = value; |
4593 | - Q_EMIT newSurfaceMinimumHeightChanged(m_newSurfaceMinimumHeight); |
4594 | - } |
4595 | -} |
4596 | - |
4597 | -void SurfaceManager::setNewSurfaceMaximumHeight(int value) |
4598 | -{ |
4599 | - if (m_newSurfaceMaximumHeight != value) { |
4600 | - m_newSurfaceMaximumHeight = value; |
4601 | - Q_EMIT newSurfaceMaximumHeightChanged(m_newSurfaceMaximumHeight); |
4602 | - } |
4603 | -} |
4604 | - |
4605 | -void SurfaceManager::setNewSurfaceWidthIncrement(int value) |
4606 | -{ |
4607 | - if (m_newSurfaceWidthIncrement != value) { |
4608 | - m_newSurfaceWidthIncrement = value; |
4609 | - Q_EMIT newSurfaceWidthIncrementChanged(m_newSurfaceWidthIncrement); |
4610 | - } |
4611 | -} |
4612 | - |
4613 | -void SurfaceManager::setNewSurfaceHeightIncrement(int value) |
4614 | -{ |
4615 | - if (m_newSurfaceHeightIncrement != value) { |
4616 | - m_newSurfaceHeightIncrement = value; |
4617 | - Q_EMIT newSurfaceHeightIncrementChanged(m_newSurfaceHeightIncrement); |
4618 | - } |
4619 | -} |
4620 | - |
4621 | -void SurfaceManager::raise(unityapi::MirSurfaceInterface *surface) |
4622 | -{ |
4623 | - if (m_underModification) |
4624 | - return; |
4625 | - |
4626 | - DEBUG_MSG("("<<surface<<") started"); |
4627 | - Q_EMIT modificationsStarted(); |
4628 | - m_underModification = true; |
4629 | - |
4630 | - doRaise(surface); |
4631 | - |
4632 | - m_underModification = false; |
4633 | - Q_EMIT modificationsEnded(); |
4634 | - DEBUG_MSG("("<<surface<<") ended"); |
4635 | -} |
4636 | - |
4637 | -void SurfaceManager::doRaise(unityapi::MirSurfaceInterface *apiSurface) |
4638 | -{ |
4639 | - auto surface = static_cast<MirSurface*>(apiSurface); |
4640 | - int index = m_surfaces.indexOf(surface); |
4641 | - Q_ASSERT(index != -1); |
4642 | - m_surfaces.move(index, 0); |
4643 | - |
4644 | - Q_EMIT surfacesRaised({surface}); |
4645 | -} |
4646 | - |
4647 | -void SurfaceManager::activate(unityapi::MirSurfaceInterface *apiSurface) |
4648 | -{ |
4649 | - auto surface = static_cast<MirSurface*>(apiSurface); |
4650 | - |
4651 | - if (surface == m_focusedSurface) { |
4652 | - return; |
4653 | - } |
4654 | - |
4655 | - Q_ASSERT(!m_underModification); |
4656 | - |
4657 | - DEBUG_MSG("("<<surface<<") started"); |
4658 | - Q_EMIT modificationsStarted(); |
4659 | - m_underModification = true; |
4660 | - if (m_focusedSurface) { |
4661 | - m_focusedSurface->setFocused(false); |
4662 | - } |
4663 | - if (surface) { |
4664 | - if (surface->state() == Mir::HiddenState || surface->state() == Mir::MinimizedState) { |
4665 | - if (surface->previousState() != Mir::UnknownState) { |
4666 | - surface->setState(surface->previousState()); |
4667 | - } else { |
4668 | - surface->setState(Mir::RestoredState); |
4669 | - } |
4670 | - } |
4671 | - surface->setFocused(true); |
4672 | - doRaise(surface); |
4673 | - } |
4674 | - m_focusedSurface = surface; |
4675 | - m_underModification = false; |
4676 | - Q_EMIT modificationsEnded(); |
4677 | - DEBUG_MSG("("<<surface<<") ended"); |
4678 | -} |
4679 | - |
4680 | -void SurfaceManager::onStateRequested(MirSurface *surface, Mir::State state) |
4681 | -{ |
4682 | - DEBUG_MSG("("<<surface<<","<<state<<") started"); |
4683 | - Q_EMIT modificationsStarted(); |
4684 | - m_underModification = true; |
4685 | - |
4686 | - surface->setPreviousState(surface->state()); |
4687 | - surface->setState(state); |
4688 | - |
4689 | - if ((state == Mir::MinimizedState || state == Mir::HiddenState) && surface->focused()) { |
4690 | - Q_ASSERT(m_focusedSurface == surface); |
4691 | - surface->setFocused(false); |
4692 | - m_focusedSurface = nullptr; |
4693 | - focusFirstAvailableSurface(); |
4694 | - } |
4695 | - |
4696 | - m_underModification = false; |
4697 | - Q_EMIT modificationsEnded(); |
4698 | - DEBUG_MSG("("<<surface<<","<<state<<") ended"); |
4699 | -} |
4700 | - |
4701 | -void SurfaceManager::onSurfaceDestroyed(MirSurface *surface, const QString& persistentId) |
4702 | -{ |
4703 | - m_surfaces.removeAll(surface); |
4704 | - if (m_focusedSurface == surface) { |
4705 | - m_focusedSurface = nullptr; |
4706 | - |
4707 | - Q_EMIT modificationsStarted(); |
4708 | - m_underModification = true; |
4709 | - |
4710 | - focusFirstAvailableSurface(); |
4711 | - |
4712 | - m_underModification = false; |
4713 | - Q_EMIT modificationsEnded(); |
4714 | - } |
4715 | - Q_EMIT surfaceDestroyed(persistentId); |
4716 | -} |
4717 | - |
4718 | -void SurfaceManager::focusFirstAvailableSurface() |
4719 | -{ |
4720 | - MirSurface *chosenSurface = nullptr; |
4721 | - for (int i = 0; i < m_surfaces.count() && !chosenSurface; ++i) { |
4722 | - auto *surface = m_surfaces[i]; |
4723 | - if (surface->state() != Mir::HiddenState && surface->state() != Mir::MinimizedState) { |
4724 | - chosenSurface = surface; |
4725 | - } |
4726 | - } |
4727 | - |
4728 | - if (!chosenSurface) { |
4729 | - return; |
4730 | - } |
4731 | - |
4732 | - if (m_focusedSurface) { |
4733 | - m_focusedSurface->setFocused(false); |
4734 | - } |
4735 | - |
4736 | - chosenSurface->setFocused(true); |
4737 | - doRaise(chosenSurface); |
4738 | - |
4739 | - m_focusedSurface = chosenSurface; |
4740 | -} |
4741 | - |
4742 | -void SurfaceManager::createInputMethodSurface() |
4743 | -{ |
4744 | - if (!m_virtualKeyboard) { |
4745 | - m_virtualKeyboard = new VirtualKeyboard; |
4746 | - registerSurface(m_virtualKeyboard); |
4747 | - Q_EMIT surfaceCreated(m_virtualKeyboard); |
4748 | - } |
4749 | -} |
4750 | |
4751 | === removed file 'tests/mocks/Unity/Application/SurfaceManager.h' |
4752 | --- tests/mocks/Unity/Application/SurfaceManager.h 2017-01-26 11:10:01 +0000 |
4753 | +++ tests/mocks/Unity/Application/SurfaceManager.h 1970-01-01 00:00:00 +0000 |
4754 | @@ -1,116 +0,0 @@ |
4755 | -/* |
4756 | - * Copyright (C) 2014-2016 Canonical, Ltd. |
4757 | - * |
4758 | - * This program is free software; you can redistribute it and/or modify |
4759 | - * it under the terms of the GNU General Public License as published by |
4760 | - * the Free Software Foundation; version 3. |
4761 | - * |
4762 | - * This program is distributed in the hope that it will be useful, |
4763 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4764 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4765 | - * GNU General Public License for more details. |
4766 | - * |
4767 | - * You should have received a copy of the GNU General Public License |
4768 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4769 | - */ |
4770 | - |
4771 | -#ifndef SURFACEMANAGER_H |
4772 | -#define SURFACEMANAGER_H |
4773 | - |
4774 | -#include <QObject> |
4775 | - |
4776 | -#include <unity/shell/application/SurfaceManagerInterface.h> |
4777 | - |
4778 | -#include "MirSurface.h" |
4779 | -#include "VirtualKeyboard.h" |
4780 | - |
4781 | -class ApplicationInfo; |
4782 | - |
4783 | -class SurfaceManager : public unity::shell::application::SurfaceManagerInterface |
4784 | -{ |
4785 | - Q_OBJECT |
4786 | - Q_PROPERTY(int newSurfaceMinimumWidth READ newSurfaceMinimumWidth WRITE setNewSurfaceMinimumWidth NOTIFY newSurfaceMinimumWidthChanged) |
4787 | - Q_PROPERTY(int newSurfaceMaximumWidth READ newSurfaceMaximumWidth WRITE setNewSurfaceMaximumWidth NOTIFY newSurfaceMaximumWidthChanged) |
4788 | - Q_PROPERTY(int newSurfaceMinimumHeight READ newSurfaceMinimumHeight WRITE setNewSurfaceMinimumHeight NOTIFY newSurfaceMinimumHeightChanged) |
4789 | - Q_PROPERTY(int newSurfaceMaximumHeight READ newSurfaceMaximumHeight WRITE setNewSurfaceMaximumHeight NOTIFY newSurfaceMaximumHeightChanged) |
4790 | - Q_PROPERTY(int newSurfaceWidthIncrement READ newSurfaceWidthIncrement WRITE setNewSurfaceWidthIncrement NOTIFY newSurfaceWidthIncrementChanged) |
4791 | - Q_PROPERTY(int newSurfaceHeightIncrement READ newSurfaceHeightIncrement WRITE setNewSurfaceHeightIncrement NOTIFY newSurfaceHeightIncrementChanged) |
4792 | - |
4793 | -public: |
4794 | - explicit SurfaceManager(QObject *parent = 0); |
4795 | - virtual ~SurfaceManager(); |
4796 | - |
4797 | - static SurfaceManager *instance(); |
4798 | - |
4799 | - // SurfaceManagerInterface |
4800 | - void raise(unity::shell::application::MirSurfaceInterface *surface) override; |
4801 | - void activate(unity::shell::application::MirSurfaceInterface *surface) override; |
4802 | - |
4803 | - Q_INVOKABLE MirSurface* createSurface(const QString& name, |
4804 | - Mir::Type type, |
4805 | - Mir::State state, |
4806 | - MirSurface *parentSurface, |
4807 | - const QUrl &screenshot, |
4808 | - const QUrl &qmlFilePath = QUrl()); |
4809 | - |
4810 | - |
4811 | - void notifySurfaceCreated(unity::shell::application::MirSurfaceInterface *); |
4812 | - |
4813 | - int newSurfaceMinimumWidth() const { return m_newSurfaceMinimumWidth; } |
4814 | - void setNewSurfaceMinimumWidth(int value); |
4815 | - |
4816 | - int newSurfaceMaximumWidth() const { return m_newSurfaceMaximumWidth; } |
4817 | - void setNewSurfaceMaximumWidth(int value); |
4818 | - |
4819 | - int newSurfaceMinimumHeight() const { return m_newSurfaceMinimumHeight; } |
4820 | - void setNewSurfaceMinimumHeight(int value); |
4821 | - |
4822 | - int newSurfaceMaximumHeight() const { return m_newSurfaceMaximumHeight; } |
4823 | - void setNewSurfaceMaximumHeight(int value); |
4824 | - |
4825 | - int newSurfaceWidthIncrement() const { return m_newSurfaceWidthIncrement; } |
4826 | - void setNewSurfaceWidthIncrement(int); |
4827 | - |
4828 | - int newSurfaceHeightIncrement() const { return m_newSurfaceHeightIncrement; } |
4829 | - void setNewSurfaceHeightIncrement(int); |
4830 | - |
4831 | -public Q_SLOTS: |
4832 | - void createInputMethodSurface(); |
4833 | - |
4834 | -Q_SIGNALS: |
4835 | - void surfaceDestroyed(const QString& persistentSurfaceId); |
4836 | - |
4837 | - void newSurfaceMinimumWidthChanged(int value); |
4838 | - void newSurfaceMaximumWidthChanged(int value); |
4839 | - void newSurfaceMinimumHeightChanged(int value); |
4840 | - void newSurfaceMaximumHeightChanged(int value); |
4841 | - void newSurfaceWidthIncrementChanged(int value); |
4842 | - void newSurfaceHeightIncrementChanged(int value); |
4843 | - |
4844 | -private Q_SLOTS: |
4845 | - void onStateRequested(MirSurface *surface, Mir::State state); |
4846 | - void onSurfaceDestroyed(MirSurface *surface, const QString& persistentId); |
4847 | - |
4848 | -private: |
4849 | - void doRaise(unity::shell::application::MirSurfaceInterface *surface); |
4850 | - void focusFirstAvailableSurface(); |
4851 | - void registerSurface(MirSurface *surface); |
4852 | - |
4853 | - static SurfaceManager *m_instance; |
4854 | - |
4855 | - int m_newSurfaceMinimumWidth{0}; |
4856 | - int m_newSurfaceMaximumWidth{0}; |
4857 | - int m_newSurfaceMinimumHeight{0}; |
4858 | - int m_newSurfaceMaximumHeight{0}; |
4859 | - int m_newSurfaceWidthIncrement{1}; |
4860 | - int m_newSurfaceHeightIncrement{1}; |
4861 | - |
4862 | - MirSurface *m_focusedSurface{nullptr}; |
4863 | - bool m_underModification{false}; |
4864 | - |
4865 | - QList<MirSurface*> m_surfaces; |
4866 | - |
4867 | - VirtualKeyboard *m_virtualKeyboard{nullptr}; |
4868 | -}; |
4869 | - |
4870 | -#endif // SURFACEMANAGER_H |
4871 | |
4872 | === removed file 'tests/mocks/Unity/Application/VirtualKeyboard.cpp' |
4873 | --- tests/mocks/Unity/Application/VirtualKeyboard.cpp 2017-01-26 11:10:01 +0000 |
4874 | +++ tests/mocks/Unity/Application/VirtualKeyboard.cpp 1970-01-01 00:00:00 +0000 |
4875 | @@ -1,58 +0,0 @@ |
4876 | -/* |
4877 | - * Copyright (C) 2015,2016 Canonical, Ltd. |
4878 | - * |
4879 | - * This program is free software; you can redistribute it and/or modify |
4880 | - * it under the terms of the GNU General Public License as published by |
4881 | - * the Free Software Foundation; version 3. |
4882 | - * |
4883 | - * This program is distributed in the hope that it will be useful, |
4884 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4885 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4886 | - * GNU General Public License for more details. |
4887 | - * |
4888 | - * You should have received a copy of the GNU General Public License |
4889 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4890 | - */ |
4891 | - |
4892 | -#include "VirtualKeyboard.h" |
4893 | - |
4894 | -#include <paths.h> |
4895 | - |
4896 | -#include <QString> |
4897 | - |
4898 | -#include <QDebug> |
4899 | - |
4900 | -VirtualKeyboard::VirtualKeyboard() |
4901 | - : MirSurface("input-method", |
4902 | - Mir::InputMethodType, |
4903 | - Mir::MinimizedState, |
4904 | - nullptr, /* parentSurface */ |
4905 | - QUrl("qrc:///Unity/Application/vkb_portrait.png"), |
4906 | - QUrl("qrc:///Unity/Application/VirtualKeyboard.qml")) |
4907 | -{ |
4908 | -} |
4909 | - |
4910 | -VirtualKeyboard::~VirtualKeyboard() |
4911 | -{ |
4912 | -} |
4913 | - |
4914 | -void VirtualKeyboard::updateInputBoundsAfterResize() |
4915 | -{ |
4916 | - int width = this->width(); |
4917 | - |
4918 | - int height = 0; |
4919 | - if (visible()) { |
4920 | - if (this->width() > this->height()) { |
4921 | - // landscape |
4922 | - height = this->height() * 0.4; |
4923 | - } else { |
4924 | - // portrait |
4925 | - height = this->width() * 0.6; |
4926 | - } |
4927 | - } |
4928 | - |
4929 | - int x = 0; |
4930 | - int y = this->height() - height; |
4931 | - |
4932 | - setInputBounds(QRect(x, y, width, height)); |
4933 | -} |
4934 | |
4935 | === removed file 'tests/mocks/Unity/Application/VirtualKeyboard.h' |
4936 | --- tests/mocks/Unity/Application/VirtualKeyboard.h 2016-06-30 13:51:32 +0000 |
4937 | +++ tests/mocks/Unity/Application/VirtualKeyboard.h 1970-01-01 00:00:00 +0000 |
4938 | @@ -1,37 +0,0 @@ |
4939 | -/* |
4940 | - * Copyright (C) 2015,2016 Canonical, Ltd. |
4941 | - * |
4942 | - * This program is free software; you can redistribute it and/or modify |
4943 | - * it under the terms of the GNU General Public License as published by |
4944 | - * the Free Software Foundation; version 3. |
4945 | - * |
4946 | - * This program is distributed in the hope that it will be useful, |
4947 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4948 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4949 | - * GNU General Public License for more details. |
4950 | - * |
4951 | - * You should have received a copy of the GNU General Public License |
4952 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4953 | - */ |
4954 | - |
4955 | -#ifndef VIRTUALKEYBOARD_H |
4956 | -#define VIRTUALKEYBOARD_H |
4957 | - |
4958 | -#include "MirSurface.h" |
4959 | - |
4960 | -#include <QQuickItem> |
4961 | - |
4962 | -class VirtualKeyboard : public MirSurface |
4963 | -{ |
4964 | - Q_OBJECT |
4965 | -public: |
4966 | - explicit VirtualKeyboard(); |
4967 | - ~VirtualKeyboard(); |
4968 | - |
4969 | -protected: |
4970 | - void updateInputBoundsAfterResize() override; |
4971 | -}; |
4972 | - |
4973 | -Q_DECLARE_METATYPE(VirtualKeyboard*) |
4974 | - |
4975 | -#endif // VIRTUALKEYBOARD_H |
4976 | |
4977 | === removed file 'tests/mocks/Unity/Application/plugin.cpp' |
4978 | --- tests/mocks/Unity/Application/plugin.cpp 2016-12-01 11:38:26 +0000 |
4979 | +++ tests/mocks/Unity/Application/plugin.cpp 1970-01-01 00:00:00 +0000 |
4980 | @@ -1,68 +0,0 @@ |
4981 | -/* |
4982 | - * Copyright (C) 2013-2016 Canonical, Ltd. |
4983 | - * |
4984 | - * This program is free software; you can redistribute it and/or modify |
4985 | - * it under the terms of the GNU General Public License as published by |
4986 | - * the Free Software Foundation; version 3. |
4987 | - * |
4988 | - * This program is distributed in the hope that it will be useful, |
4989 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4990 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4991 | - * GNU General Public License for more details. |
4992 | - * |
4993 | - * You should have received a copy of the GNU General Public License |
4994 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4995 | - */ |
4996 | - |
4997 | -#include "plugin.h" |
4998 | -#include "ApplicationInfo.h" |
4999 | -#include "ApplicationManager.h" |
5000 | -#include "MirMock.h" |
FAILED: Continuous integration, rev:2807 /unity8- jenkins. ubuntu. com/job/ lp-unity8- ci/3117/ /unity8- jenkins. ubuntu. com/job/ build/4059/ console /unity8- jenkins. ubuntu. com/job/ build-0- fetch/4087 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 3927/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= zesty/3927/ console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 3927/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= zesty/3927/ console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 3927/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= zesty/3927/ console
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /unity8- jenkins. ubuntu. com/job/ lp-unity8- ci/3117/ rebuild
https:/