Skip to content

Commit

Permalink
Remove epaper from liboxide, only have it in display-server
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems committed Feb 5, 2024
1 parent 5f69146 commit 0bc40f6
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 88 deletions.
4 changes: 3 additions & 1 deletion applications/display-server/dbusinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
#include <unistd.h>
#include <QDBusMetaType>
#include <liboxide/debug.h>
#include <liboxide/epaper.h>
#include <liboxide/devicesettings.h>
#include <libblight/types.h>
#include <libblight/socket.h>
#include <cstring>
#ifdef EPAPER
#include <epframebuffer.h>
#endif

DbusInterface::DbusInterface(QObject* parent)
: QObject(parent),
Expand Down
1 change: 1 addition & 0 deletions applications/display-server/display-server.pro
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ INCLUDEPATH += ../../shared/mxcfb

include(../../qmake/liboxide.pri)
include(../../qmake/libblight.pri)
include(../../qmake/epaper.pri)

QMAKE_POST_LINK += sh $$_PRO_FILE_PWD_/generate_xml.sh

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 @@ -4,7 +4,7 @@
#include <QWaitCondition>
#include <QSemaphore>
#include <QQueue>
#include <liboxide/epaper.h>
#include <epframebuffer.h>
#include <liboxide/threading.h>
#include <libblight/concurrentqueue.h>

Expand Down
5 changes: 5 additions & 0 deletions applications/display-server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
#include <filesystem>
#include <liboxide.h>

#ifdef EPAPER
#include <QtPlugin>
Q_IMPORT_PLUGIN(QsgEpaperPlugin)
#endif

#include "dbusinterface.h"
#include "evdevhandler.h"

Expand Down
52 changes: 40 additions & 12 deletions applications/system-service/apibase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#include <liboxide/oxideqml.h>
#include <libblight/meta.h>
#include <libblight/types.h>
#ifdef EPAPER
#include <liboxide/epaper.h>
#endif

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

QImage* getFrameBuffer(){
#ifdef EPAPER
if(deviceSettings.getDeviceType() == Oxide::DeviceSettings::RM1){
return EPFrameBuffer::instance()->framebuffer();
}
#endif
static QImage* image = nullptr;
static QFile* file = nullptr;
if(image == nullptr){
file = new QFile();
auto compositor = getCompositorDBus();
auto reply = compositor->frameBuffer();
reply.waitForFinished();
Expand All @@ -58,10 +51,45 @@ QImage* getFrameBuffer(){
O_WARNING("Framebuffer fd is not valid");
return nullptr;
}
file = new QFile();
file->open(dup(qfd.fileDescriptor()), QFile::ReadWrite);
uchar* data = file->map(0, file->size());
image = new QImage(data, 1404, 1872, 2808, QImage::Format_RGB16);
int fd = dup(qfd.fileDescriptor());
if(fd < 0){
O_WARNING("Failed to get framebuffer fd" << std::strerror(errno));
return nullptr;
}
if(!file->open(fd, QFile::ReadWrite)){
O_WARNING("Failed to open framebuffer" << file->errorString());
::close(fd);
delete file;
file = nullptr;
return nullptr;
}
auto stride = deviceSettings.getDeviceType() == Oxide::DeviceSettings::RM1 ? 2816 : 2808;
uchar* data = file->map(0, stride * 1872);
if(data == nullptr){
O_WARNING("Failed to map framebuffer" << file->errorString());
file->close();
delete file;
file = nullptr;
return nullptr;
}
image = new QImage(data, 1404, 1872, stride, QImage::Format_RGB16);
if(image->isNull()){
O_WARNING("Framebuffer is null" << image->size());
delete image;
image = nullptr;
file->unmap(data);
file->close();
delete file;
file = nullptr;
}else if(image->size().isEmpty()){
O_WARNING("Image is empty" << image->size());
delete image;
image = nullptr;
file->unmap(data);
file->close();
delete file;
file = nullptr;
}
}
return image;
}
Expand Down
5 changes: 2 additions & 3 deletions applications/system-service/screenapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "systemapi.h"

#include <liboxide/oxideqml.h>
#include <liboxide/epaper.h>

QDBusObjectPath ScreenAPI::screenshot(){
if(!hasPermission("screen")){
Expand All @@ -21,9 +20,9 @@ QDBusObjectPath ScreenAPI::screenshot(){
);
notification->display();
auto screen = getFrameBuffer();
bool saved = false;
QDBusObjectPath path("/");
if(screen->size().isEmpty()){
bool saved = false;
if(screen == nullptr || screen->size().isEmpty()){
O_WARNING("Could not get copy of screen");
}else{
if(systemAPI->landscape()){
Expand Down
1 change: 0 additions & 1 deletion qmake/liboxide.pri
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ QT += gui

QML_IMPORT_PATH += qrc:/codes.eeems.oxide
include(sentry.pri)
include(epaper.pri)
include(libblight.pri)
69 changes: 0 additions & 69 deletions shared/liboxide/epaper.h

This file was deleted.

1 change: 0 additions & 1 deletion shared/liboxide/liboxide.pro
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ HEADERS += \
dbus.h \
debug.h \
devicesettings.h \
epaper.h \
event_device.h \
eventfilter.h \
liboxide_global.h \
Expand Down

0 comments on commit 0bc40f6

Please sign in to comment.