~alan-griffiths/miral/debug

« back to all changes in this revision

Viewing changes to miral-qt/src/platforms/mirserver/surfaceobserver.h

  • Committer: Gerry Boland
  • Date: 2016-06-01 22:06:51 UTC
  • mto: This revision was merged to the branch mainline in revision 178.
  • Revision ID: gerry.boland@canonical.com-20160601220651-ge508tffql4e7u7c
Import QtMir code into miral-qt subdirectory. Disabled by default, use -DMIRAL_ENABLE_QT=1 to build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2014-2015 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it under
 
5
 * the terms of the GNU Lesser General Public License version 3, as published by
 
6
 * the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
 
9
 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
 
10
 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
 * Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#ifndef SESSIONOBSERVER_H
 
18
#define SESSIONOBSERVER_H
 
19
 
 
20
#include <QByteArray>
 
21
#include <QCursor>
 
22
#include <QObject>
 
23
#include <QMap>
 
24
#include <QMutex>
 
25
#include <QSize>
 
26
#include <mir/scene/surface_observer.h>
 
27
 
 
28
namespace mir {
 
29
    namespace scene {
 
30
        class Surface;
 
31
    }
 
32
    namespace shell {
 
33
        class SurfaceSpecification;
 
34
    }
 
35
}
 
36
 
 
37
class SurfaceObserver : public QObject, public mir::scene::SurfaceObserver
 
38
{
 
39
    Q_OBJECT
 
40
 
 
41
public:
 
42
    SurfaceObserver();
 
43
    virtual ~SurfaceObserver();
 
44
 
 
45
    void setListener(QObject *listener);
 
46
 
 
47
    void attrib_changed(MirSurfaceAttrib, int) override;
 
48
    void resized_to(mir::geometry::Size const&) override;
 
49
    void moved_to(mir::geometry::Point const&) override {}
 
50
    void hidden_set_to(bool) override {}
 
51
 
 
52
    // Get new frame notifications from Mir, called from a Mir thread.
 
53
    void frame_posted(int frames_available, mir::geometry::Size const& size ) override;
 
54
 
 
55
    void alpha_set_to(float) override {}
 
56
    void transformation_set_to(glm::mat4 const&) override {}
 
57
    void reception_mode_set_to(mir::input::InputReceptionMode) override {}
 
58
    void cursor_image_set_to(mir::graphics::CursorImage const&) override;
 
59
    void orientation_set_to(MirOrientation) override {}
 
60
    void client_surface_close_requested() override {}
 
61
    void keymap_changed(MirInputDeviceId, std::string const& model, std::string const& layout,
 
62
                        std::string const& variant, std::string const& options) override;
 
63
    void renamed(char const * name) override;
 
64
    void cursor_image_removed() override;
 
65
 
 
66
    void notifySurfaceModifications(const mir::shell::SurfaceSpecification&);
 
67
 
 
68
    static SurfaceObserver *observerForSurface(const mir::scene::Surface *surface);
 
69
    static void registerObserverForSurface(SurfaceObserver *observer, const mir::scene::Surface *surface);
 
70
    static QMutex mutex;
 
71
 
 
72
Q_SIGNALS:
 
73
    void attributeChanged(const MirSurfaceAttrib attribute, const int value);
 
74
    void framesPosted();
 
75
    void resized(const QSize &size);
 
76
    void keymapChanged(const QString &rules, const QString &variant);
 
77
    void nameChanged(const QString &name);
 
78
    void cursorChanged(const QCursor &cursor);
 
79
 
 
80
    void minimumWidthChanged(int);
 
81
    void minimumHeightChanged(int);
 
82
    void maximumWidthChanged(int);
 
83
    void maximumHeightChanged(int);
 
84
    void widthIncrementChanged(int);
 
85
    void heightIncrementChanged(int);
 
86
    void shellChromeChanged(MirShellChrome);
 
87
 
 
88
private:
 
89
    QCursor createQCursorFromMirCursorImage(const mir::graphics::CursorImage &cursorImage);
 
90
    QObject *m_listener;
 
91
    bool m_framesPosted;
 
92
    QMap<QByteArray, Qt::CursorShape> m_cursorNameToShape;
 
93
    static QMap<const mir::scene::Surface*, SurfaceObserver*> m_surfaceToObserverMap;
 
94
};
 
95
 
 
96
#endif