[wayland] BasicScreens can serve multiple screens
For this AbstractBackend has a new virtual screenGeometries() method which returns a QVector<QRect>. By default it's just one QRect at 0/0 with the size of the one screenSize().
This commit is contained in:
parent
7c5fc2ff96
commit
ee7f70afc8
4 changed files with 37 additions and 7 deletions
|
@ -335,4 +335,9 @@ QSize AbstractBackend::screenSize() const
|
|||
return QSize();
|
||||
}
|
||||
|
||||
QVector<QRect> AbstractBackend::screenGeometries() const
|
||||
{
|
||||
return QVector<QRect>({QRect(QPoint(0, 0), screenSize())});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,6 +67,13 @@ public:
|
|||
* Base implementation returns an invalid size.
|
||||
**/
|
||||
virtual QSize screenSize() const;
|
||||
/**
|
||||
* Implementing subclasses should provide all geometries in case the backend represents
|
||||
* a basic screen and uses the BasicScreens.
|
||||
*
|
||||
* Base implementation returns one QRect positioned at 0/0 with screenSize() as size.
|
||||
**/
|
||||
virtual QVector<QRect> screenGeometries() const;
|
||||
|
||||
bool usesSoftwareCursor() const {
|
||||
return m_softWareCursor;
|
||||
|
|
30
screens.cpp
30
screens.cpp
|
@ -205,29 +205,45 @@ void BasicScreens::init()
|
|||
|
||||
QRect BasicScreens::geometry(int screen) const
|
||||
{
|
||||
if (screen == 0) {
|
||||
return QRect(QPoint(0, 0), size(screen));
|
||||
if (screen < m_geometries.count()) {
|
||||
return m_geometries.at(screen);
|
||||
}
|
||||
return QRect();
|
||||
}
|
||||
|
||||
QSize BasicScreens::size(int screen) const
|
||||
{
|
||||
if (screen == 0) {
|
||||
return m_backend->screenSize();
|
||||
if (screen < m_geometries.count()) {
|
||||
return m_geometries.at(screen).size();
|
||||
}
|
||||
return QSize();
|
||||
}
|
||||
|
||||
void BasicScreens::updateCount()
|
||||
{
|
||||
setCount(1);
|
||||
m_geometries = m_backend->screenGeometries();
|
||||
setCount(m_geometries.count());
|
||||
}
|
||||
|
||||
int BasicScreens::number(const QPoint &pos) const
|
||||
{
|
||||
Q_UNUSED(pos)
|
||||
return 0;
|
||||
int bestScreen = 0;
|
||||
int minDistance = INT_MAX;
|
||||
for (int i = 0; i < m_geometries.count(); ++i) {
|
||||
const QRect &geo = m_geometries.at(i);
|
||||
if (geo.contains(pos)) {
|
||||
return i;
|
||||
}
|
||||
int distance = QPoint(geo.topLeft() - pos).manhattanLength();
|
||||
distance = qMin(distance, QPoint(geo.topRight() - pos).manhattanLength());
|
||||
distance = qMin(distance, QPoint(geo.bottomRight() - pos).manhattanLength());
|
||||
distance = qMin(distance, QPoint(geo.bottomLeft() - pos).manhattanLength());
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance;
|
||||
bestScreen = i;
|
||||
}
|
||||
}
|
||||
return bestScreen;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <QObject>
|
||||
#include <QRect>
|
||||
#include <QTimer>
|
||||
#include <QVector>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -167,6 +168,7 @@ public:
|
|||
|
||||
private:
|
||||
AbstractBackend *m_backend;
|
||||
QVector<QRect> m_geometries;
|
||||
};
|
||||
|
||||
inline
|
||||
|
|
Loading…
Reference in a new issue