~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to libs/kephal/service/backendconfigurations.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2008 Aike J Sommer <dev@aikesommer.name>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU General Public License as
 
6
 *   published by the Free Software Foundation; either version 2,
 
7
 *   or (at your option) any later version.
 
8
 *
 
9
 *   This program is distributed in the hope that it will be useful,
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *   GNU General Public License for more details
 
13
 *
 
14
 *   You should have received a copy of the GNU Library General Public
 
15
 *   License along with this program; if not, write to the
 
16
 *   Free Software Foundation, Inc.,
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
 
 
21
#ifndef KEPHAL_BACKENDCONFIGURATIONS_H
 
22
#define KEPHAL_BACKENDCONFIGURATIONS_H
 
23
 
 
24
 
 
25
#include <QMap>
 
26
#include <QPoint>
 
27
#include <QRect>
 
28
 
 
29
#include "configurations.h"
 
30
 
 
31
 
 
32
namespace Kephal {
 
33
 
 
34
    /**
 
35
     * A configuration forming part of the backend (Kephal service)
 
36
     */
 
37
    class BackendConfiguration : public Configuration {
 
38
        Q_OBJECT
 
39
        public:
 
40
            BackendConfiguration(QObject * parent);
 
41
 
 
42
            /**
 
43
             * Returns the real layout, with screen-sizes
 
44
             * taken from the actual Outputs.
 
45
             *
 
46
             * @param simpleLayout The layout as returned
 
47
             *          from layout().
 
48
             * @param outputScreens A mapping of Outputs
 
49
             *          to Screens.
 
50
             * @param outputSizes The sizes to use for the
 
51
             *          Outputs instead of the current ones.
 
52
             * WILL: used by XMLConf::resizeLayout()
 
53
             */
 
54
            QMap<int, QRect> realLayout(const QMap<int, QPoint> & simpleLayout, const QMap<Output *, int> & outputScreens, const QMap<Output *, QSize> & outputSizes);
 
55
 
 
56
            /**
 
57
             * Returns the real layout, with screen-sizes
 
58
             * taken from the actual Outputs.
 
59
             *
 
60
             * @param simpleLayout The layout as returned
 
61
             *          from layout().
 
62
             * @param outputScreens A mapping of Outputs
 
63
             *          to Screens.
 
64
             */
 
65
            QMap<int, QRect> realLayout(const QMap<int, QPoint> & simpleLayout, const QMap<Output *, int> & outputScreens);
 
66
 
 
67
            /**
 
68
             * Returns the real layout, with screen-sizes
 
69
             * taken from the actual Outputs.
 
70
             * This will calculate the layout by calling
 
71
             * layout().
 
72
             *
 
73
             * @param outputScreens A mapping of Outputs
 
74
             *          to Screens.
 
75
             * WILL used by XMLConfiguration::activate(Configuration*)
 
76
             * WILL used by XMLConfiguration::calcMatchingLayout()
 
77
             * WILL used by XMLConfiguration::simpleConfigurationsPositions()
 
78
             */
 
79
            QMap<int, QRect> realLayout(const QMap<Output *, int> & outputScreens);
 
80
 
 
81
            /**
 
82
             * Returns the real layout, with screen-sizes
 
83
             * taken from the actual Outputs.
 
84
             * This will calculate the layout by calling
 
85
             * layout() and use the Output to Screen
 
86
             * mapping as currently active if possible.
 
87
             */
 
88
            QMap<int, QRect> realLayout();
 
89
 
 
90
            /**
 
91
             * Returns a set of points covered in the
 
92
             * layout returned by layout().
 
93
             */
 
94
            QSet<QPoint> positions();
 
95
 
 
96
            /**
 
97
             * Returns the positions as in positions
 
98
             * to which the Screen can be cloned.
 
99
             */
 
100
            QSet<QPoint> clonePositions(int screen);
 
101
 
 
102
            /**
 
103
             * Returns the layout if the Screen screen
 
104
             * was to be cloned to any of the other
 
105
             * Screens.
 
106
             */
 
107
            QMap<int, QPoint> cloneLayout(int screen);
 
108
 
 
109
            /**
 
110
             * Returns the possible positions as in
 
111
             * positions() to move the Screen screen
 
112
             * to.
 
113
             */
 
114
            QSet<QPoint> possiblePositions(int screen) const;
 
115
 
 
116
        private:
 
117
            void simpleToReal(QMap<int, QPoint> & simpleLayout, const QMap<int, QSize> & screenSizes, int index, QMap<int, QRect> & screens) const;
 
118
            QList<QSet<QPoint> > partition(int screen) const;
 
119
            QSet<QPoint> border(QSet<QPoint> screens) const;
 
120
    };
 
121
 
 
122
 
 
123
 
 
124
    /**
 
125
     * A manager of configurations, on the backend
 
126
     */
 
127
    class BackendConfigurations : public Configurations {
 
128
        Q_OBJECT
 
129
        public:
 
130
            static BackendConfigurations * self();
 
131
 
 
132
            BackendConfigurations(QObject * parent);
 
133
            virtual ~BackendConfigurations();
 
134
 
 
135
            /**
 
136
             * Find the Configuration for the currently
 
137
             * connected Outputs.
 
138
             */
 
139
            virtual Configuration * findConfiguration() = 0;
 
140
 
 
141
            /**
 
142
             * Apply Output-specific settings such as size,
 
143
             * refresh-rate and rotation.
 
144
             */
 
145
            virtual void applyOutputSettings() = 0;
 
146
 
 
147
            virtual BackendConfiguration * activeBackendConfiguration();
 
148
 
 
149
        private:
 
150
            static BackendConfigurations * s_instance;
 
151
    };
 
152
 
 
153
}
 
154
 
 
155
 
 
156
#endif // KEPHAL_BACKENDCONFIGURATIONS_H
 
157