forked from quickshell/quickshell
refactor(wayland): seperate cmake files for modularity
This commit is contained in:
parent
5bbd0333ef
commit
c6dde9ca9d
28 changed files with 32 additions and 33 deletions
110
src/core/qmlscreen.cpp
Normal file
110
src/core/qmlscreen.cpp
Normal file
|
@ -0,0 +1,110 @@
|
|||
#include "qmlscreen.hpp"
|
||||
|
||||
#include <qdebug.h>
|
||||
#include <qlogging.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qobject.h>
|
||||
#include <qscreen.h>
|
||||
#include <qtypes.h>
|
||||
|
||||
QuickShellScreenInfo::QuickShellScreenInfo(QObject* parent, QScreen* screen):
|
||||
QObject(parent), screen(screen) {
|
||||
|
||||
if (this->screen != nullptr) {
|
||||
// clang-format off
|
||||
QObject::connect(this->screen, &QScreen::geometryChanged, this, &QuickShellScreenInfo::geometryChanged);
|
||||
QObject::connect(this->screen, &QScreen::physicalDotsPerInchChanged, this, &QuickShellScreenInfo::physicalPixelDensityChanged);
|
||||
QObject::connect(this->screen, &QScreen::logicalDotsPerInchChanged, this, &QuickShellScreenInfo::logicalPixelDensityChanged);
|
||||
QObject::connect(this->screen, &QScreen::orientationChanged, this, &QuickShellScreenInfo::orientationChanged);
|
||||
QObject::connect(this->screen, &QScreen::primaryOrientationChanged, this, &QuickShellScreenInfo::primaryOrientationChanged);
|
||||
QObject::connect(this->screen, &QObject::destroyed, this, &QuickShellScreenInfo::screenDestroyed);
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
|
||||
bool QuickShellScreenInfo::operator==(QuickShellScreenInfo& other) const {
|
||||
return this->screen == other.screen;
|
||||
}
|
||||
|
||||
void QuickShellScreenInfo::warnDangling() const {
|
||||
if (this->dangling) {
|
||||
qWarning() << "attempted to use dangling screen object";
|
||||
}
|
||||
}
|
||||
|
||||
QString QuickShellScreenInfo::name() const {
|
||||
if (this->screen == nullptr) {
|
||||
this->warnDangling();
|
||||
return "{ NULL SCREEN }";
|
||||
}
|
||||
|
||||
return this->screen->name();
|
||||
}
|
||||
|
||||
qint32 QuickShellScreenInfo::width() const {
|
||||
if (this->screen == nullptr) {
|
||||
this->warnDangling();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this->screen->size().width();
|
||||
}
|
||||
|
||||
qint32 QuickShellScreenInfo::height() const {
|
||||
if (this->screen == nullptr) {
|
||||
this->warnDangling();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this->screen->size().height();
|
||||
}
|
||||
|
||||
qreal QuickShellScreenInfo::physicalPixelDensity() const {
|
||||
if (this->screen == nullptr) {
|
||||
this->warnDangling();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return this->screen->physicalDotsPerInch() / 25.4;
|
||||
}
|
||||
|
||||
qreal QuickShellScreenInfo::logicalPixelDensity() const {
|
||||
if (this->screen == nullptr) {
|
||||
this->warnDangling();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return this->screen->logicalDotsPerInch() / 25.4;
|
||||
}
|
||||
|
||||
qreal QuickShellScreenInfo::devicePixelRatio() const {
|
||||
if (this->screen == nullptr) {
|
||||
this->warnDangling();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return this->screen->devicePixelRatio();
|
||||
}
|
||||
|
||||
Qt::ScreenOrientation QuickShellScreenInfo::orientation() const {
|
||||
if (this->screen == nullptr) {
|
||||
this->warnDangling();
|
||||
return Qt::PrimaryOrientation;
|
||||
}
|
||||
|
||||
return this->screen->orientation();
|
||||
}
|
||||
|
||||
Qt::ScreenOrientation QuickShellScreenInfo::primaryOrientation() const {
|
||||
if (this->screen == nullptr) {
|
||||
this->warnDangling();
|
||||
return Qt::PrimaryOrientation;
|
||||
}
|
||||
|
||||
return this->screen->primaryOrientation();
|
||||
}
|
||||
|
||||
void QuickShellScreenInfo::screenDestroyed() {
|
||||
this->screen = nullptr;
|
||||
this->dangling = true;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue