Skip to content

Commit

Permalink
Lots of work to get splashscreens working again-ish
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems committed Jan 31, 2024
1 parent aa45ea2 commit 29934ea
Show file tree
Hide file tree
Showing 17 changed files with 232 additions and 116 deletions.
20 changes: 17 additions & 3 deletions applications/display-server/dbusinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,18 @@ void DbusInterface::setFlags(QString identifier, const QStringList& flags, QDBus
for(auto& flag : flags){
connection->set(flag);
}
sortZ();
return;
}
auto surface = getSurface(identifier);
if(surface == nullptr){
sendErrorReply(QDBusError::BadAddress, "Surface not found");
sendErrorReply(QDBusError::BadAddress, "Connection or Surface not found");
return;
}
for(auto& flag : flags){
surface->set(flag);
}
sortZ();
}

QStringList DbusInterface::getSurfaces(QDBusMessage message){
Expand Down Expand Up @@ -281,9 +283,15 @@ QDBusUnixFileDescriptor DbusInterface::frameBuffer(QDBusMessage message){
void DbusInterface::lower(QString identifier, QDBusMessage message){
Q_UNUSED(message);
// TODO - only allow tarnish to make this call
auto surface = getSurface(identifier);
if(surface != nullptr){
surface->setVisible(false);
sortZ();
return;
}
auto connection = getConnection(identifier);
if(connection == nullptr){
sendErrorReply(QDBusError::BadAddress, "Connection not found");
sendErrorReply(QDBusError::BadAddress, "Connection or Surface not found");
return;
}
if(m_focused == connection){
Expand All @@ -298,9 +306,15 @@ void DbusInterface::lower(QString identifier, QDBusMessage message){
void DbusInterface::raise(QString identifier, QDBusMessage message){
Q_UNUSED(message);
// TODO - only allow tarnish to make this call
auto surface = getSurface(identifier);
if(surface != nullptr){
surface->setVisible(true);
sortZ();
return;
}
auto connection = getConnection(identifier);
if(connection == nullptr){
sendErrorReply(QDBusError::BadAddress, "Connection not found");
sendErrorReply(QDBusError::BadAddress, "Connection or Surface not found");
return;
}
for(auto& surface : connection->getSurfaces()){
Expand Down
2 changes: 1 addition & 1 deletion applications/display-server/guithread.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public slots:
void notify();
void clearFrameBuffer();
int framebuffer();
void sendUpdate(const QRect& rect, EPFrameBuffer::WaveformMode waveform, unsigned int marker);

private:
GUIThread(QRect screenGeometry);
Expand All @@ -58,7 +59,6 @@ public slots:
void repaintSurface(QPainter* painter, QRect* rect, std::shared_ptr<Surface> surface);
void redraw(RepaintRequest& event);
void scheduleUpdate();
void sendUpdate(const QRect& rect, EPFrameBuffer::WaveformMode previousWaveform, unsigned int marker);
QList<std::shared_ptr<Surface>> visibleSurfaces();
};
#endif
20 changes: 17 additions & 3 deletions applications/settings-manager/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#include <QTextStream>

#include <liboxide.h>
#include <libblight/meta.h>

using namespace codes::eeems::oxide1;
using namespace codes::eeems::blight1;
using namespace Oxide::Sentry;
using namespace Oxide::JSON;

Expand All @@ -27,7 +29,7 @@ int main(int argc, char *argv[]){
parser.addHelpOption();
parser.applicationDescription();
parser.addVersionOption();
parser.addPositionalArgument("api", "settings\nwifi\npower\napps\nsystem\nscreen\nnotification");
parser.addPositionalArgument("api", "settings\nwifi\npower\napps\nsystem\nscreen\nnotification\ncompositor");
parser.addPositionalArgument("action","get\nset\nlisten\ncall");
QCommandLineOption objectOption(
{"o", "object"},
Expand All @@ -51,7 +53,7 @@ int main(int argc, char *argv[]){
parser.showHelp(EXIT_FAILURE);
}
auto apiName = args.at(0);
if(!(QSet<QString> {"settings", "power", "wifi", "apps", "system", "screen", "notification"}).contains(apiName)){
if(!(QSet<QString> {"settings", "power", "wifi", "apps", "system", "screen", "notification", "compositor"}).contains(apiName)){
qDebug() << "Unknown API" << apiName;
#ifdef SENTRY
sentry_breadcrumb("error", "Unknown API");
Expand Down Expand Up @@ -128,7 +130,7 @@ int main(int argc, char *argv[]){
return qExit(EXIT_FAILURE);
}
QString path = "";
if(apiName != "settings"){
if(apiName != "settings" && apiName != "compositor"){
General generalApi(OXIDE_SERVICE, OXIDE_SERVICE_PATH, bus);
auto reply = generalApi.requestAPI(apiName);
reply.waitForFinished();
Expand Down Expand Up @@ -293,6 +295,18 @@ int main(int argc, char *argv[]){
return qExit(EXIT_FAILURE);
}
}
}else if(apiName == "compositor"){
#ifdef SENTRY
sentry_breadcrumb("api", "compositor");
#endif
api = new Compositor(BLIGHT_SERVICE, "/", bus);
if(parser.isSet("object")){
qDebug() << "Paths are not valid for the compositor API";
#ifdef SENTRY
sentry_breadcrumb("error", "invalid arguments");
#endif
return qExit(EXIT_FAILURE);
}
}else{
qDebug() << "API not initialized? Please log a bug.";
#ifdef SENTRY
Expand Down
1 change: 1 addition & 0 deletions applications/settings-manager/settings-manager.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ target.path = /opt/bin
INSTALLS += target

include(../../qmake/liboxide.pri)
include(../../qmake/libblight.pri)
61 changes: 53 additions & 8 deletions applications/system-service/apibase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QWindow>
#include <liboxide/oxideqml.h>
#include <libblight/meta.h>
#include <libblight/types.h>

int APIBase::hasPermission(QString permission, const char* sender){
if(getpgid(getpid()) == getSenderPgid()){
Expand Down Expand Up @@ -33,14 +34,27 @@ int APIBase::getSenderPid() {
}
int APIBase::getSenderPgid() { return getpgid(getSenderPid()); }

QWindow* getFrameBufferWindow(){
static auto window = qApp->focusWindow();
return window;
}

QImage getFrameBuffer(){
static auto frameBuffer = Oxide::QML::getImageForWindow(getFrameBufferWindow());
return frameBuffer;
QImage* getFrameBuffer(){
static QImage* image = nullptr;
if(image == nullptr){
auto compositor = getCompositorDBus();
auto reply = compositor->frameBuffer();
reply.waitForFinished();
if(reply.isError()){
O_WARNING("Failed to get framebuffer fd" << reply.error().message());
return nullptr;
}
QDBusUnixFileDescriptor qfd = reply.value();
if(!qfd.isValid()){
O_WARNING("Framebuffer fd is not valid");
return nullptr;
}
QFile file;
file.open(dup(qfd.fileDescriptor()), QFile::ReadOnly);
auto data = file.map(0, file.size());
image = new QImage(data, 1404, 1872, 2808, QImage::Format_RGB16);
}
return image;
}

Compositor* getCompositorDBus(){
Expand All @@ -57,4 +71,35 @@ Compositor* getCompositorDBus(){
return compositor;
}

Blight::shared_buf_t createBuffer(const QRect& rect, unsigned int stride, Blight::Format format){
return Blight::createBuffer(
rect.x(),
rect.y(),
rect.width(),
rect.height(),
stride,
format
).value_or(nullptr);
}

Blight::shared_buf_t createBuffer(){
auto frameBuffer = getFrameBuffer();
return createBuffer(
frameBuffer->rect(),
frameBuffer->bytesPerLine(),
(Blight::Format)frameBuffer->format()
);
}

#include "moc_apibase.cpp"

void addSystemBuffer(Blight::shared_buf_t buffer){
if(buffer != nullptr){
Blight::addSurface(buffer);
auto compositor = getCompositorDBus();
compositor->setFlags(
QString("connection/%1/surface/%2").arg(getpid()).arg(buffer->surface),
QStringList() << "system"
);
}
}
9 changes: 6 additions & 3 deletions applications/system-service/apibase.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#include <QDBusMessage>
#include <QImage>

#include <unistd.h>
#include <liboxide.h>
#include <liboxide/dbus.h>
#include <unistd.h>
#include <libblight.h>

#ifdef Q_MOC_RUN
#include "../../shared/liboxide/meta.h"
Expand All @@ -31,8 +32,10 @@ class APIBase : public QObject, protected QDBusContext {
int getSenderPid();
int getSenderPgid();
};
QWindow* getFrameBufferWindow();
QImage getFrameBuffer();
QImage* getFrameBuffer();
Compositor* getCompositorDBus();
Blight::shared_buf_t createBuffer(const QRect& rect, unsigned int stride, Blight::Format format);
Blight::shared_buf_t createBuffer();
void addSystemBuffer(Blight::shared_buf_t buffer);

#endif // APIBASE_H
Loading

0 comments on commit 29934ea

Please sign in to comment.