Skip to content

Commit

Permalink
Fix up initial display of buffers and force white buffer for blight-c…
Browse files Browse the repository at this point in the history
…lient
  • Loading branch information
Eeems committed Feb 1, 2024
1 parent 966d556 commit c0336be
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 24 deletions.
8 changes: 4 additions & 4 deletions applications/display-server/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ std::shared_ptr<Surface> Connection::addSurface(int fd, QRect geometry, int stri
auto id = ++m_surfaceId;
auto surface = std::shared_ptr<Surface>(new Surface(this, fd, id, geometry, stride, format));
surfaces.insert_or_assign(id, surface);
dbusInterface->sortZ();
surface->repaint();
return surface;
}

Expand Down Expand Up @@ -382,8 +384,7 @@ void Connection::readSocket(){
surface->move(move.x, move.y);
guiThread->enqueue(
surface,
// Surface repaints are local to their coordinates, thus (0,0)
QRect(QPoint(0, 0), surface->size()),
surface->rect(),
EPFrameBuffer::WaveformMode::HighQualityGrayscale,
message->header.ackid,
false,
Expand Down Expand Up @@ -467,8 +468,7 @@ void Connection::readSocket(){
#ifdef EPAPER
guiThread->enqueue(
surface,
// Surface repaints are local to their coordinates, thus (0,0)
QRect(QPoint(0, 0), surface->size()),
surface->rect(),
EPFrameBuffer::WaveformMode::HighQualityGrayscale,
message->header.ackid,
false,
Expand Down
6 changes: 5 additions & 1 deletion applications/display-server/dbusinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ void DbusInterface::lower(QString identifier, QDBusMessage message){
if(surface != nullptr){
surface->setVisible(false);
sortZ();
surface->repaint();
return;
}
auto connection = getConnection(identifier);
Expand All @@ -299,6 +300,7 @@ void DbusInterface::lower(QString identifier, QDBusMessage message){
}
for(auto& surface : connection->getSurfaces()){
surface->setVisible(false);
surface->repaint();
}
sortZ();
}
Expand All @@ -311,6 +313,7 @@ void DbusInterface::raise(QString identifier, QDBusMessage message){
surface->setVisible(true);
surface->setZ(std::numeric_limits<int>::max());
sortZ();
surface->repaint();
return;
}
auto connection = getConnection(identifier);
Expand All @@ -321,6 +324,7 @@ void DbusInterface::raise(QString identifier, QDBusMessage message){
for(auto& surface : connection->getSurfaces()){
surface->setVisible(true);
surface->setZ(std::numeric_limits<int>::max());
surface->repaint();
}
sortZ();
}
Expand Down Expand Up @@ -549,7 +553,7 @@ void DbusInterface::sortZ(){
if(
!connection->isRunning()
|| connection->isStopped()
|| connection->has("system")
|| connection->has("system")
){
continue;
}
Expand Down
32 changes: 22 additions & 10 deletions applications/display-server/surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ Surface::Surface(
connect(widget, &SurfaceWidget::activeFocusChanged, this, &Surface::activeFocusChanged);
emit connection->focused();
setVisible(true);
setZ(std::numeric_limits<int>::max());
S_INFO("Surface created");
}

Surface::~Surface(){
S_INFO("Surface destroyed");
file.close();
setVisible(false);
#ifdef EPAPER
repaint();
#endif
if(component != nullptr){
component->deleteLater();
component = nullptr;
Expand All @@ -87,14 +91,31 @@ bool Surface::isValid(){ return component != nullptr; }

std::shared_ptr<QImage> Surface::image(){ return m_image; }

void Surface::repaint(){ emit update(QRect(QPoint(0, 0), m_geometry.size())); }
void Surface::repaint(QRect rect){
if(rect.isEmpty()){
rect = this->rect();
}
#ifdef EPAPER
guiThread->enqueue(
nullptr,
geometry(),
EPFrameBuffer::HighQualityGrayscale,
0,
true
);
#else
emit update(rect);
#endif
}

int Surface::fd(){ return file.handle(); }

const QRect& Surface::geometry(){ return m_geometry; }

const QSize Surface::size(){ return m_geometry.size(); }

const QRect Surface::rect(){ return QRect(QPoint(0, 0), size()); }

int Surface::stride(){ return m_stride; }

QImage::Format Surface::format(){ return m_format; }
Expand All @@ -108,15 +129,6 @@ void Surface::move(int x, int y){
void Surface::setVisible(bool visible){
if(component != nullptr){
component->setVisible(visible);
#ifdef EPAPER
guiThread->enqueue(
nullptr,
geometry(),
EPFrameBuffer::HighQualityGrayscale,
0,
true
);
#endif
}
}

Expand Down
3 changes: 2 additions & 1 deletion applications/display-server/surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ class Surface : public QObject {
Blight::surface_id_t identifier(){ return m_identifier; }
bool isValid();
std::shared_ptr<QImage> image();
void repaint();
void repaint(QRect rect = QRect());
int fd();
const QRect& geometry();
const QSize size();
const QRect rect();
int stride();
QImage::Format format();
void move(int x, int y);
Expand Down
3 changes: 2 additions & 1 deletion assets/opt/usr/share/applications/codes.eeems.anxiety.oxide
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"bin": "/opt/bin/anxiety",
"icon": "oxide:image-48",
"type": "foreground",
"permissions": ["screen"]
"permissions": ["screen"],
"flags": ["nopreload"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"displayName": "Task Switcher",
"description": "Handles switching applications",
"bin": "/opt/bin/corrupt",
"flags": ["hidden", "nosavescreen", "nosplash"],
"flags": ["hidden", "nosavescreen", "nosplash", "nopreload"],
"type": "backgroundable",
"permissions": ["apps"]
}
2 changes: 1 addition & 1 deletion assets/opt/usr/share/applications/codes.eeems.decay.oxide
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"displayName": "Startup application",
"description": "Handles the password screen on resume",
"bin": "/opt/bin/decay",
"flags": ["hidden"],
"flags": ["hidden", "nopreload"],
"type": "foreground",
"permissions": ["apps", "power", "system", "wifi"]
}
3 changes: 2 additions & 1 deletion assets/opt/usr/share/applications/codes.eeems.erode.oxide
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"displayName": "Process Manager",
"description": "List and kill running processes",
"icon": "oxide:erode-48",
"bin": "/opt/bin/erode"
"bin": "/opt/bin/erode",
"flags": ["nopreload"]
}
2 changes: 1 addition & 1 deletion assets/opt/usr/share/applications/codes.eeems.fret.oxide
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"displayName": "Screenshot daemon",
"description": "Takes screenshots and displays notifications",
"bin": "/opt/bin/fret",
"flags": ["autoStart", "hidden"],
"flags": ["autoStart", "hidden", "nopreload"],
"type": "background",
"permissions": ["notification", "screen", "system"]
}
2 changes: 1 addition & 1 deletion assets/opt/usr/share/applications/codes.eeems.oxide.oxide
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"description": "Application launcher",
"bin": "/opt/bin/oxide",
"type": "foreground",
"flags": ["hidden"],
"flags": ["hidden", "nopreload"],
"permissions": ["apps", "wifi", "power", "system", "notification"]
}
5 changes: 3 additions & 2 deletions shared/libblight_client/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,10 @@ int __open(const char* pathname, int flags){
if(res < 0){
_CRIT("Failed to create buffer: %s", std::strerror(errno));
std::exit(errno);
}else{
_INFO("Created buffer %s on fd %d", blightBuffer->uuid.c_str(), blightBuffer->fd);
}
// Initialize the buffer with white
memset((std::uint16_t*)blightBuffer->data, std::uint16_t(0xFFFFFFFF), 2808 * 1872);
_INFO("Created buffer %s on fd %d", blightBuffer->uuid.c_str(), blightBuffer->fd);
return res;
}
}else if(actualpath.starts_with("/dev/input/event")){
Expand Down

0 comments on commit c0336be

Please sign in to comment.