Merge lp:~andreas-pokorny/qtmir/controlMirCursor-and-more into lp:qtmir

Proposed by Andreas Pokorny
Status: Work in progress
Proposed branch: lp:~andreas-pokorny/qtmir/controlMirCursor-and-more
Merge into: lp:qtmir
Diff against target: 520 lines (+101/-48)
17 files modified
debian/changelog (+6/-0)
src/platforms/mirserver/cursor.cpp (+20/-2)
src/platforms/mirserver/cursor.h (+4/-1)
src/platforms/mirserver/miropenglcontext.cpp (+14/-2)
src/platforms/mirserver/mirserver.cpp (+17/-26)
src/platforms/mirserver/mirserverstatuslistener.cpp (+8/-0)
src/platforms/mirserver/mirserverstatuslistener.h (+2/-0)
src/platforms/mirserver/offscreensurface.cpp (+0/-1)
src/platforms/mirserver/screen.cpp (+2/-1)
src/platforms/mirserver/screen.h (+2/-1)
src/platforms/mirserver/screensmodel.cpp (+4/-2)
src/platforms/mirserver/screensmodel.h (+4/-2)
tests/framework/fake_displayconfigurationoutput.h (+8/-2)
tests/framework/mock_display.h (+4/-2)
tests/mirserver/Screen/screen_test.cpp (+4/-4)
tests/mirserver/ScreensModel/stub_screen.h (+1/-1)
tests/mirserver/ScreensModel/testable_screensmodel.h (+1/-1)
To merge this branch: bzr merge lp:~andreas-pokorny/qtmir/controlMirCursor-and-more
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+305611@code.launchpad.net

Commit message

WIP

Description of the change

mp needed for integration silo

To post a comment you must log in.
552. By Andreas Pokorny

update of qtmir

553. By Andreas Pokorny

changelog update

554. By Andreas Pokorny

forward qtmir cursor position to the nested cursor

555. By Andreas Pokorny

Feed cursor position directly into WindowSystemInterface

Unmerged revisions

555. By Andreas Pokorny

Feed cursor position directly into WindowSystemInterface

554. By Andreas Pokorny

forward qtmir cursor position to the nested cursor

553. By Andreas Pokorny

changelog update

552. By Andreas Pokorny

update of qtmir

551. By Andreas Pokorny

update to upcoming lp:mir interfaces

550. By Daniel d'Andrada

WIP

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2016-09-06 18:31:27 +0000
3+++ debian/changelog 2016-09-15 07:26:35 +0000
4@@ -1,3 +1,9 @@
5+qtmir (0.4.8+16.10.20160906-0ubuntu2) UNRELEASED; urgency=medium
6+
7+ * updates for nested cursor
8+
9+ -- Andreas Pokorny <andreas.pokorny@canonical.com> Tue, 13 Sep 2016 20:38:14 +0200
10+
11 qtmir (0.4.8+16.10.20160906-0ubuntu1) yakkety; urgency=medium
12
13 [ Daniel d'Andrada ]
14
15=== modified file 'src/platforms/mirserver/cursor.cpp'
16--- src/platforms/mirserver/cursor.cpp 2016-08-08 13:10:40 +0000
17+++ src/platforms/mirserver/cursor.cpp 2016-09-15 07:26:35 +0000
18@@ -22,10 +22,12 @@
19
20 // Unity API
21 #include <unity/shell/application/MirMousePointerInterface.h>
22+#include <qpa/qwindowsysteminterface.h>
23
24 using namespace qtmir;
25
26-Cursor::Cursor()
27+Cursor::Cursor(std::shared_ptr<mir::graphics::Cursor> const& cursor)
28+ : m_cursor{cursor}, m_cursorPosition{50.0f, 80.0f}
29 {
30 m_shapeToCursorName[Qt::ArrowCursor] = QStringLiteral("left_ptr");
31 m_shapeToCursorName[Qt::UpArrowCursor] = QStringLiteral("up_arrow");
32@@ -55,6 +57,7 @@
33
34 void Cursor::changeCursor(QCursor *windowCursor, QWindow * /*window*/)
35 {
36+ // TODO forward cursor..
37 if (m_mousePointer.isNull()) {
38 return;
39 }
40@@ -101,6 +104,13 @@
41 bool Cursor::handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButtons buttons,
42 Qt::KeyboardModifiers modifiers)
43 {
44+ m_cursorPosition += movement;
45+ // make movement decisions here and emit events as needed ..
46+ m_cursor->move_to(mir::geometry::Point{int(m_cursorPosition.x()), int(m_cursorPosition.y())});
47+ QWindowSystemInterface::handleMouseEvent(NULL, timestamp, m_cursorPosition, m_cursorPosition,
48+ buttons, modifiers);
49+ return true;
50+#if 0
51 QMutexLocker locker(&m_mutex);
52
53 if (!m_mousePointer || !m_mousePointer->isVisible()) {
54@@ -119,10 +129,15 @@
55 }
56
57 return ok;
58+#endif
59 }
60
61 bool Cursor::handleWheelEvent(ulong timestamp, QPoint angleDelta, Qt::KeyboardModifiers modifiers)
62 {
63+ QWindowSystemInterface::handleWheelEvent(0, timestamp, m_cursorPosition, m_cursorPosition,
64+ QPoint() /* pixelDelta */, angleDelta, modifiers, Qt::ScrollUpdate);
65+ return true;
66+#if 0
67 QMutexLocker locker(&m_mutex);
68
69 if (!m_mousePointer || !m_mousePointer->isVisible()) {
70@@ -140,10 +155,13 @@
71 }
72
73 return ok;
74+#endif
75 }
76
77 void Cursor::setPos(const QPoint &pos)
78 {
79+ m_cursor->move_to(mir::geometry::Point{pos.x(), pos.y()});
80+ return;
81 if (!m_mousePointer) {
82 QPlatformCursor::setPos(pos);
83 return;
84@@ -155,7 +173,7 @@
85 movement.setX(pos.x() - mouseScenePos.x());
86 movement.setY(pos.y() - mouseScenePos.y());
87
88- m_mousePointer->handleMouseEvent(0 /*timestamp*/, movement, Qt::NoButton, Qt::NoModifier);
89+ //m_mousePointer->handleMouseEvent(0 /*timestamp*/, movement, Qt::NoButton, Qt::NoModifier);
90 }
91
92 QPoint Cursor::pos() const
93
94=== modified file 'src/platforms/mirserver/cursor.h'
95--- src/platforms/mirserver/cursor.h 2016-06-06 19:25:20 +0000
96+++ src/platforms/mirserver/cursor.h 2016-09-15 07:26:35 +0000
97@@ -20,6 +20,7 @@
98
99 #include <QMutex>
100 #include <QPointer>
101+#include <mir/graphics/cursor.h>
102
103 // Unity API
104 #include <unity/shell/application/MirPlatformCursor.h>
105@@ -30,7 +31,7 @@
106 {
107 Q_OBJECT
108 public:
109- Cursor();
110+ Cursor(std::shared_ptr<mir::graphics::Cursor> const& cursor);
111
112 // Called form Mir input thread
113 bool handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButtons buttons,
114@@ -59,8 +60,10 @@
115 QMutex m_mutex;
116 QPointer<MirMousePointerInterface> m_mousePointer;
117 QMap<int,QString> m_shapeToCursorName;
118+ std::shared_ptr<mir::graphics::Cursor> const m_cursor;
119 QString m_qtCursorName;
120 QString m_mirCursorName;
121+ QPointF m_cursorPosition;
122 };
123
124 } // namespace qtmir
125
126=== modified file 'src/platforms/mirserver/miropenglcontext.cpp'
127--- src/platforms/mirserver/miropenglcontext.cpp 2016-06-07 19:30:06 +0000
128+++ src/platforms/mirserver/miropenglcontext.cpp 2016-09-15 07:26:35 +0000
129@@ -29,7 +29,19 @@
130
131 // Mir
132 #include <mir/graphics/display.h>
133-#include <mir/graphics/gl_context.h>
134+#include <mir/renderer/gl/context.h>
135+#include <mir/renderer/gl/context_source.h>
136+
137+namespace
138+{
139+auto as_context_source(mir::graphics::Display* display)
140+{
141+ auto const ctx = dynamic_cast<mir::renderer::gl::ContextSource*>(display->native_display());
142+ if (!ctx)
143+ throw std::logic_error("Display does not support GL rendering");
144+ return ctx;
145+}
146+}
147
148 // Qt supports one GL context per screen, but also shared contexts.
149 // The Mir "Display" generates a shared GL context for all DisplayBuffers
150@@ -45,7 +57,7 @@
151 #endif
152 {
153 // create a temporary GL context to fetch the EGL display and config, so Qt can determine the surface format
154- std::unique_ptr<mir::graphics::GLContext> mirContext = display.create_gl_context();
155+ std::unique_ptr<mir::renderer::gl::Context> mirContext = as_context_source(&display)->create_gl_context();
156 mirContext->make_current();
157
158 EGLDisplay eglDisplay = eglGetCurrentDisplay();
159
160=== modified file 'src/platforms/mirserver/mirserver.cpp'
161--- src/platforms/mirserver/mirserver.cpp 2016-05-19 13:45:08 +0000
162+++ src/platforms/mirserver/mirserver.cpp 2016-09-15 07:26:35 +0000
163@@ -42,6 +42,7 @@
164
165 // mir
166 #include <mir/graphics/cursor.h>
167+#include <mir/input/cursor_listener.h>
168
169 namespace mg = mir::graphics;
170 namespace mo = mir::options;
171@@ -50,7 +51,12 @@
172
173 namespace
174 {
175-void usingHiddenCursor(mir::Server& server);
176+class NullCursorListener : public mir::input::CursorListener
177+{
178+public:
179+ void cursor_moved_to(float, float) override {}
180+};
181+
182 }
183
184 MirServer::MirServer(int &argc, char **argv,
185@@ -89,10 +95,12 @@
186 return std::make_shared<QtCompositor>();
187 });
188
189+ /*
190 override_the_cursor_images([]
191 {
192 return std::make_shared<qtmir::MirCursorImages>();
193 });
194+ */
195
196 override_the_input_dispatcher([&screensModel]
197 {
198@@ -118,6 +126,11 @@
199 return windowManager;
200 });
201
202+ wrap_cursor_listener([](const std::shared_ptr<mir::input::CursorListener> &)
203+ {
204+ return std::make_shared<NullCursorListener>();
205+ });
206+
207 wrap_display_configuration_policy(
208 [](const std::shared_ptr<mg::DisplayConfigurationPolicy> &wrapped)
209 -> std::shared_ptr<mg::DisplayConfigurationPolicy>
210@@ -132,11 +145,9 @@
211 });
212
213 add_init_callback([this, &screensModel] {
214- screensModel->init(the_display(), the_compositor());
215+ screensModel->init(the_display(), the_compositor(), the_cursor());
216 });
217
218- usingHiddenCursor(*this);
219-
220 try {
221 apply_settings();
222 } catch (const std::exception &ex) {
223@@ -144,6 +155,8 @@
224 exit(1);
225 }
226
227+ the_cursor()->show();
228+
229 if (!unknownArgsFound) { // mir parsed all the arguments, so edit argv to pretend to have just argv[0]
230 argc = 1;
231 }
232@@ -210,25 +223,3 @@
233 return m_windowManager.lock().get();
234 }
235
236-namespace
237-{
238-struct HiddenCursorWrapper : mg::Cursor
239-{
240- HiddenCursorWrapper(std::shared_ptr<mg::Cursor> const& wrapped) :
241- wrapped{wrapped} { wrapped->hide(); }
242- void show() override { }
243- void show(mg::CursorImage const&) override { }
244- void hide() override { wrapped->hide(); }
245-
246- void move_to(mir::geometry::Point position) override { wrapped->move_to(position); }
247-
248-private:
249- std::shared_ptr<mg::Cursor> const wrapped;
250-};
251-
252-void usingHiddenCursor(mir::Server& server)
253-{
254- server.wrap_cursor([&](std::shared_ptr<mg::Cursor> const& wrapped)
255- { return std::make_shared<HiddenCursorWrapper>(wrapped); });
256-};
257-}
258
259=== modified file 'src/platforms/mirserver/mirserverstatuslistener.cpp'
260--- src/platforms/mirserver/mirserverstatuslistener.cpp 2015-08-11 12:08:32 +0000
261+++ src/platforms/mirserver/mirserverstatuslistener.cpp 2016-09-15 07:26:35 +0000
262@@ -35,3 +35,11 @@
263 void MirServerStatusListener::started()
264 {
265 }
266+
267+void MirServerStatusListener::ready_for_user_input()
268+{
269+}
270+
271+void MirServerStatusListener::stop_receiving_input()
272+{
273+}
274
275=== modified file 'src/platforms/mirserver/mirserverstatuslistener.h'
276--- src/platforms/mirserver/mirserverstatuslistener.h 2015-08-11 12:08:32 +0000
277+++ src/platforms/mirserver/mirserverstatuslistener.h 2016-09-15 07:26:35 +0000
278@@ -25,6 +25,8 @@
279 void paused() override;
280 void resumed() override;
281 void started() override;
282+ void ready_for_user_input() override;
283+ void stop_receiving_input() override;
284 };
285
286 #endif // MIRSERVERSTATUSLISTENER_H
287
288=== modified file 'src/platforms/mirserver/offscreensurface.cpp'
289--- src/platforms/mirserver/offscreensurface.cpp 2016-05-05 15:12:09 +0000
290+++ src/platforms/mirserver/offscreensurface.cpp 2016-09-15 07:26:35 +0000
291@@ -18,7 +18,6 @@
292
293 // Mir
294 #include <mir/graphics/display.h>
295-#include <mir/graphics/gl_context.h>
296
297 //Qt
298 #include <QOffscreenSurface>
299
300=== modified file 'src/platforms/mirserver/screen.cpp'
301--- src/platforms/mirserver/screen.cpp 2016-08-16 11:04:25 +0000
302+++ src/platforms/mirserver/screen.cpp 2016-09-15 07:26:35 +0000
303@@ -138,7 +138,7 @@
304
305 bool Screen::skipDBusRegistration = false;
306
307-Screen::Screen(const mir::graphics::DisplayConfigurationOutput &screen)
308+Screen::Screen(const mir::graphics::DisplayConfigurationOutput &screen, std::shared_ptr<mir::graphics::Cursor> const& cursor)
309 : QObject(nullptr)
310 , m_refreshRate(-1.0)
311 , m_scale(1.0)
312@@ -148,6 +148,7 @@
313 , m_orientationSensor(new QOrientationSensor(this))
314 , m_screenWindow(nullptr)
315 , m_unityScreen(nullptr)
316+ , m_cursor{cursor}
317 {
318 setMirDisplayConfiguration(screen, false);
319
320
321=== modified file 'src/platforms/mirserver/screen.h'
322--- src/platforms/mirserver/screen.h 2016-04-29 15:41:00 +0000
323+++ src/platforms/mirserver/screen.h 2016-09-15 07:26:35 +0000
324@@ -25,6 +25,7 @@
325
326 // Mir
327 #include <mir/graphics/display_configuration.h>
328+#include <mir/graphics/cursor.h>
329
330 // local
331 #include "cursor.h"
332@@ -40,7 +41,7 @@
333 {
334 Q_OBJECT
335 public:
336- Screen(const mir::graphics::DisplayConfigurationOutput &);
337+ Screen(const mir::graphics::DisplayConfigurationOutput &, std::shared_ptr<mir::graphics::Cursor> const& cursor);
338 ~Screen();
339
340 // QPlatformScreen methods.
341
342=== modified file 'src/platforms/mirserver/screensmodel.cpp'
343--- src/platforms/mirserver/screensmodel.cpp 2016-06-06 19:25:20 +0000
344+++ src/platforms/mirserver/screensmodel.cpp 2016-09-15 07:26:35 +0000
345@@ -47,10 +47,12 @@
346
347 // init only after MirServer has initialized - runs on MirServerThread!!!
348 void ScreensModel::init(const std::shared_ptr<mir::graphics::Display> &display,
349- const std::shared_ptr<mir::compositor::Compositor> &compositor)
350+ const std::shared_ptr<mir::compositor::Compositor> &compositor,
351+ const std::shared_ptr<mir::graphics::Cursor> &cursor)
352 {
353 m_display = display;
354 m_compositor = compositor;
355+ m_cursor = cursor;
356
357 // Use a Blocking Queued Connection to enforce synchronization of Qt GUI thread with Mir thread(s)
358 // on compositor shutdown. Compositor startup can be lazy.
359@@ -227,7 +229,7 @@
360
361 Screen* ScreensModel::createScreen(const mg::DisplayConfigurationOutput &output) const
362 {
363- return new Screen(output);
364+ return new Screen(output, m_cursor);
365 }
366
367 Screen* ScreensModel::findScreenWithId(const QList<Screen *> &list, const mg::DisplayConfigurationOutputId id)
368
369=== modified file 'src/platforms/mirserver/screensmodel.h'
370--- src/platforms/mirserver/screensmodel.h 2016-06-06 19:25:20 +0000
371+++ src/platforms/mirserver/screensmodel.h 2016-09-15 07:26:35 +0000
372@@ -27,7 +27,7 @@
373 #include <memory>
374
375 namespace mir {
376- namespace graphics { class Display; }
377+ namespace graphics { class Display; class Cursor;}
378 namespace compositor { class Compositor; }
379 }
380 class Screen;
381@@ -74,7 +74,8 @@
382 public:
383 // called by MirServer
384 void init(const std::shared_ptr<mir::graphics::Display> &display,
385- const std::shared_ptr<mir::compositor::Compositor> &compositor);
386+ const std::shared_ptr<mir::compositor::Compositor> &compositor,
387+ const std::shared_ptr<mir::graphics::Cursor> &cursor);
388 void terminate();
389
390 // override for testing purposes
391@@ -91,6 +92,7 @@
392
393 std::weak_ptr<mir::graphics::Display> m_display;
394 std::shared_ptr<mir::compositor::Compositor> m_compositor;
395+ std::shared_ptr<mir::graphics::Cursor> m_cursor;
396 QList<Screen*> m_screenList;
397 bool m_compositing;
398 };
399
400=== modified file 'tests/framework/fake_displayconfigurationoutput.h'
401--- tests/framework/fake_displayconfigurationoutput.h 2015-11-11 10:43:36 +0000
402+++ tests/framework/fake_displayconfigurationoutput.h 2016-09-15 07:26:35 +0000
403@@ -45,7 +45,10 @@
404 mir_power_mode_on,
405 mir_orientation_normal,
406 1.0f,
407- mir_form_factor_unknown
408+ mir_form_factor_unknown,
409+ mir_subpixel_arrangement_horizontal_rgb,
410+ mg::GammaCurves(),
411+ mir_output_gamma_supported
412 };
413
414 const mg::DisplayConfigurationOutput fakeOutput2
415@@ -71,7 +74,10 @@
416 mir_power_mode_on,
417 mir_orientation_left,
418 1.0f,
419- mir_form_factor_unknown
420+ mir_form_factor_unknown,
421+ mir_subpixel_arrangement_horizontal_rgb,
422+ mg::GammaCurves(),
423+ mir_output_gamma_supported
424 };
425
426 #endif // FAKE_DISPLAYCONFIGURATIONOUTPUT_H
427
428=== modified file 'tests/framework/mock_display.h'
429--- tests/framework/mock_display.h 2016-02-19 10:41:15 +0000
430+++ tests/framework/mock_display.h 2016-09-15 07:26:35 +0000
431@@ -18,7 +18,7 @@
432 #define MOCKDISPLAY_H
433
434 #include <mir/graphics/display.h>
435-#include <mir/graphics/gl_context.h>
436+//#include <mir/renderer/gl/context.h>
437 #include <mir/version.h>
438
439 #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 20, 0)
440@@ -56,11 +56,13 @@
441 MOCK_METHOD0(pause, void());
442 MOCK_METHOD0(resume, void());
443 MOCK_METHOD1(create_hardware_cursor, std::shared_ptr<mir::graphics::Cursor>(std::shared_ptr<mir::graphics::CursorImage> const&));
444- MOCK_METHOD0(create_gl_context, std::unique_ptr<mir::graphics::GLContext>());
445
446 #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 20, 0)
447 MOCK_METHOD2(create_virtual_output, std::unique_ptr<mir::graphics::VirtualOutput> (int width, int height));
448 #endif
449+#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
450+ MOCK_METHOD0(native_display, mir::graphics::NativeDisplay*());
451+#endif
452 };
453
454 #endif // MOCKDISPLAY_H
455
456=== modified file 'tests/mirserver/Screen/screen_test.cpp'
457--- tests/mirserver/Screen/screen_test.cpp 2016-02-15 16:02:18 +0000
458+++ tests/mirserver/Screen/screen_test.cpp 2016-09-15 07:26:35 +0000
459@@ -44,7 +44,7 @@
460
461 TEST_F(ScreenTest, OrientationSensorForExternalDisplay)
462 {
463- Screen *screen = new Screen(fakeOutput1); // is external display (dvi)
464+ Screen *screen = new Screen(fakeOutput1, nullptr); // is external display (dvi)
465
466 // Default state should be disabled
467 ASSERT_FALSE(screen->orientationSensorEnabled());
468@@ -58,7 +58,7 @@
469
470 TEST_F(ScreenTest, OrientationSensorForInternalDisplay)
471 {
472- Screen *screen = new Screen(fakeOutput2); // is internal display
473+ Screen *screen = new Screen(fakeOutput2, nullptr); // is internal display
474
475 // Default state should be active
476 ASSERT_TRUE(screen->orientationSensorEnabled());
477@@ -72,7 +72,7 @@
478
479 TEST_F(ScreenTest, ReadConfigurationFromDisplayConfig)
480 {
481- Screen *screen = new Screen(fakeOutput1);
482+ Screen *screen = new Screen(fakeOutput1, nullptr);
483
484 EXPECT_EQ(screen->geometry(), QRect(0, 0, 150, 200));
485 EXPECT_EQ(screen->availableGeometry(), QRect(0, 0, 150, 200));
486@@ -85,7 +85,7 @@
487
488 TEST_F(ScreenTest, ReadDifferentConfigurationFromDisplayConfig)
489 {
490- Screen *screen = new Screen(fakeOutput2);
491+ Screen *screen = new Screen(fakeOutput2, nullptr);
492
493 EXPECT_EQ(screen->geometry(), QRect(500, 600, 1500, 2000));
494 EXPECT_EQ(screen->availableGeometry(), QRect(500, 600, 1500, 2000));
495
496=== modified file 'tests/mirserver/ScreensModel/stub_screen.h'
497--- tests/mirserver/ScreensModel/stub_screen.h 2015-08-20 10:16:54 +0000
498+++ tests/mirserver/ScreensModel/stub_screen.h 2016-09-15 07:26:35 +0000
499@@ -23,7 +23,7 @@
500 {
501 Q_OBJECT
502 public:
503- StubScreen(const mir::graphics::DisplayConfigurationOutput &output) : Screen(output) {}
504+ StubScreen(const mir::graphics::DisplayConfigurationOutput &output) : Screen(output, nullptr) {}
505
506 void makeCurrent() { Screen::makeCurrent(); }
507 };
508
509=== modified file 'tests/mirserver/ScreensModel/testable_screensmodel.h'
510--- tests/mirserver/ScreensModel/testable_screensmodel.h 2016-04-29 15:41:00 +0000
511+++ tests/mirserver/ScreensModel/testable_screensmodel.h 2016-09-15 07:26:35 +0000
512@@ -30,7 +30,7 @@
513 void do_init(const std::shared_ptr<mir::graphics::Display> &display,
514 const std::shared_ptr<mir::compositor::Compositor> &compositor)
515 {
516- init(display, compositor);
517+ init(display, compositor, nullptr);
518 }
519
520 void do_terminate() { terminate(); }

Subscribers

People subscribed via source and target branches