feat: add layershell support

This commit is contained in:
outfoxxed 2024-02-04 04:58:58 -08:00
parent 56502b79f6
commit d76100781f
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
12 changed files with 677 additions and 11 deletions

84
src/cpp/qmlscreen.cpp Normal file
View file

@ -0,0 +1,84 @@
#include "qmlscreen.hpp"
#include <qdebug.h>
#include <qlogging.h>
#include <qnamespace.h>
#include <qtypes.h>
bool QtShellScreenInfo::operator==(QtShellScreenInfo& other) const {
return this->screen == other.screen;
}
void warnNull() { qWarning() << "attempted to use dangling screen object"; }
QString QtShellScreenInfo::name() const {
if (this->screen == nullptr) {
warnNull();
return "{ DANGLING SCREEN POINTER }";
}
return this->screen->name();
}
qint32 QtShellScreenInfo::width() const {
if (this->screen == nullptr) {
warnNull();
return 0;
}
return this->screen->size().width();
}
qint32 QtShellScreenInfo::height() const {
if (this->screen == nullptr) {
warnNull();
return 0;
}
return this->screen->size().height();
}
qreal QtShellScreenInfo::pixelDensity() const {
if (this->screen == nullptr) {
warnNull();
return 0.0;
}
return this->screen->physicalDotsPerInch() / 25.4;
}
qreal QtShellScreenInfo::logicalPixelDensity() const {
if (this->screen == nullptr) {
warnNull();
return 0.0;
}
return this->screen->logicalDotsPerInch() / 25.4;
}
qreal QtShellScreenInfo::devicePixelRatio() const {
if (this->screen == nullptr) {
warnNull();
return 0.0;
}
return this->screen->devicePixelRatio();
}
Qt::ScreenOrientation QtShellScreenInfo::orientation() const {
if (this->screen == nullptr) {
warnNull();
return Qt::PrimaryOrientation;
}
return this->screen->orientation();
}
Qt::ScreenOrientation QtShellScreenInfo::primaryOrientation() const {
if (this->screen == nullptr) {
warnNull();
return Qt::PrimaryOrientation;
}
return this->screen->primaryOrientation();
}