~ci-train-bot/qtubuntu/qtubuntu-ubuntu-xenial-landing-005

« back to all changes in this revision

Viewing changes to src/ubuntumirclient/window.h

  • Committer: CI Train Bot
  • Author(s): Alberto Aguirre
  • Date: 2015-11-17 14:49:21 UTC
  • mfrom: (258.6.46 use-mir-surface-apis)
  • Revision ID: ci-train-bot@canonical.com-20151117144921-nrpn5zal5ncrjxvt
Add support for Qt popups and dialog windows.

I have done some refactoring, cleanup and some bug fixing.

- An UbuntuWindow internally creates UbuntuSurface
- UbuntuSurface is responsible for creating the mir surfaces and calling mir apis
- Fix mutex locking (now really protecting access to mSurface) was not locked properly (QMutexLocker temporaries were created : QMutexLocker(&d->mutex) instead of QMutexLocker lock(&d->mutex).
- Handling resize events from the server has been improved.
-- Old resize events are dropped - meaning no redraw requests are issued if we know there are newer resize events in the queue
-- Redraw requests are never issued through the rendering thread only through the Qt event dispatch thread.
-- No flushing of event queue which leads to fewer interruptions in other surfaces (specially noticeable on surfaces that do animations).
- Workaround QtCreator not assigning a parent to its menu bar menus
-- The last focused window is tracked and used if a Qt popup is created without a parent
- Client requested resizes (through setGeometry) is now supported
- Resizing constraints are supported (propagateSizeHints)
- Visibility and window state are tracked separately
- Better focusing event handling
-- When an app has multiple windows, mir will send focus lost/gain pairs,
   in which case we need to peek into the queue to avoid telling Qt to unfocus all windows prematurely.
Approved by: PS Jenkins bot, Daniel d'Andrada

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
#include <qpa/qplatformwindow.h>
21
21
#include <QSharedPointer>
 
22
#include <QMutex>
22
23
 
23
 
#include <mir_toolkit/mir_client_library.h>
 
24
#include <memory>
24
25
 
25
26
class UbuntuClipboard;
26
27
class UbuntuInput;
27
28
class UbuntuScreen;
28
 
class UbuntuWindowPrivate;
 
29
class UbuntuSurface;
 
30
struct MirConnection;
 
31
struct MirSurface;
29
32
 
30
33
class UbuntuWindow : public QObject, public QPlatformWindow
31
34
{
32
35
    Q_OBJECT
33
36
public:
34
37
    UbuntuWindow(QWindow *w, QSharedPointer<UbuntuClipboard> clipboard, UbuntuScreen *screen,
35
 
                 UbuntuInput *input, MirConnection *mir_connection);
 
38
                 UbuntuInput *input, MirConnection *mirConnection);
36
39
    virtual ~UbuntuWindow();
37
40
 
38
41
    // QPlatformWindow methods.
41
44
    void setWindowState(Qt::WindowState state) override;
42
45
    void setVisible(bool visible) override;
43
46
    void setWindowTitle(const QString &title) override;
 
47
    void propagateSizeHints() override;
44
48
 
45
49
    // New methods.
46
 
    void* eglSurface() const;
47
 
    void handleSurfaceResize(int width, int height);
48
 
    void handleSurfaceFocusChange(bool focused);
49
 
    void onBuffersSwapped_threadSafe(int newBufferWidth, int newBufferHeight);
50
 
 
51
 
    UbuntuWindowPrivate* priv() { return d; }
 
50
    void *eglSurface() const;
 
51
    MirSurface *mirSurface() const;
 
52
    void handleSurfaceResized(int width, int height);
 
53
    void handleSurfaceFocused();
 
54
    void onSwapBuffersDone();
52
55
 
53
56
private:
54
 
    void createWindow();
55
 
    void moveResize(const QRect& rect);
56
 
 
57
 
    UbuntuWindowPrivate *d;
 
57
    mutable QMutex mMutex;
 
58
    const WId mId;
 
59
    const QSharedPointer<UbuntuClipboard> mClipboard;
 
60
    std::unique_ptr<UbuntuSurface> mSurface;
58
61
};
59
62
 
60
63
#endif // UBUNTU_WINDOW_H