core: allow specifying names for outputs

This commit is contained in:
Vaxry 2024-07-01 14:52:50 +02:00
parent 51cd6f4374
commit 13f94112aa
7 changed files with 19 additions and 24 deletions

View file

@ -75,7 +75,7 @@ namespace Aquamarine {
virtual void onReady() = 0; virtual void onReady() = 0;
virtual std::vector<SDRMFormat> getRenderFormats() = 0; virtual std::vector<SDRMFormat> getRenderFormats() = 0;
virtual std::vector<SDRMFormat> getCursorFormats() = 0; virtual std::vector<SDRMFormat> getCursorFormats() = 0;
virtual bool createOutput() = 0; virtual bool createOutput(const std::string& name = "") = 0; // "" means auto
}; };
class CBackend { class CBackend {

View file

@ -289,7 +289,7 @@ namespace Aquamarine {
virtual void onReady(); virtual void onReady();
virtual std::vector<SDRMFormat> getRenderFormats(); virtual std::vector<SDRMFormat> getRenderFormats();
virtual std::vector<SDRMFormat> getCursorFormats(); virtual std::vector<SDRMFormat> getCursorFormats();
virtual bool createOutput(); virtual bool createOutput(const std::string& name = "");
Hyprutils::Memory::CWeakPointer<CDRMBackend> self; Hyprutils::Memory::CWeakPointer<CDRMBackend> self;

View file

@ -44,7 +44,7 @@ namespace Aquamarine {
virtual void onReady(); virtual void onReady();
virtual std::vector<SDRMFormat> getRenderFormats(); virtual std::vector<SDRMFormat> getRenderFormats();
virtual std::vector<SDRMFormat> getCursorFormats(); virtual std::vector<SDRMFormat> getCursorFormats();
virtual bool createOutput(); virtual bool createOutput(const std::string& name = "");
Hyprutils::Memory::CWeakPointer<CHeadlessBackend> self; Hyprutils::Memory::CWeakPointer<CHeadlessBackend> self;

View file

@ -132,7 +132,7 @@ namespace Aquamarine {
virtual void onReady(); virtual void onReady();
virtual std::vector<SDRMFormat> getRenderFormats(); virtual std::vector<SDRMFormat> getRenderFormats();
virtual std::vector<SDRMFormat> getCursorFormats(); virtual std::vector<SDRMFormat> getCursorFormats();
virtual bool createOutput(); virtual bool createOutput(const std::string& name = "");
Hyprutils::Memory::CWeakPointer<CWaylandBackend> self; Hyprutils::Memory::CWeakPointer<CWaylandBackend> self;
@ -142,7 +142,6 @@ namespace Aquamarine {
void initSeat(); void initSeat();
void initShell(); void initShell();
bool initDmabuf(); bool initDmabuf();
void createOutput(const std::string& szName);
// //
Hyprutils::Memory::CWeakPointer<CBackend> backend; Hyprutils::Memory::CWeakPointer<CBackend> backend;

View file

@ -117,8 +117,8 @@ std::vector<SDRMFormat> Aquamarine::CHeadlessBackend::getCursorFormats() {
return {}; // No cursor support return {}; // No cursor support
} }
bool Aquamarine::CHeadlessBackend::createOutput() { bool Aquamarine::CHeadlessBackend::createOutput(const std::string& name) {
auto output = SP<CHeadlessOutput>(new CHeadlessOutput(std::format("HEADLESS-{}", ++outputIDCounter), self.lock())); auto output = SP<CHeadlessOutput>(new CHeadlessOutput(name.empty() ? std::format("HEADLESS-{}", ++outputIDCounter) : name, self.lock()));
outputs.emplace_back(output); outputs.emplace_back(output);
output->swapchain = CSwapchain::create(backend->allocator, self.lock()); output->swapchain = CSwapchain::create(backend->allocator, self.lock());
output->self = output; output->self = output;

View file

@ -134,10 +134,11 @@ int Aquamarine::CWaylandBackend::drmFD() {
return drmState.fd; return drmState.fd;
} }
void Aquamarine::CWaylandBackend::createOutput(const std::string& szName) { bool Aquamarine::CWaylandBackend::createOutput(const std::string& szName) {
auto o = outputs.emplace_back(SP<CWaylandOutput>(new CWaylandOutput(szName, self))); auto o = outputs.emplace_back(SP<CWaylandOutput>(new CWaylandOutput(szName.empty() ? std::format("WAYLAND-{}", ++lastOutputID) : szName, self)));
o->self = o; o->self = o;
idleCallbacks.emplace_back([this, o]() { backend->events.newOutput.emit(SP<IOutput>(o)); }); idleCallbacks.emplace_back([this, o]() { backend->events.newOutput.emit(SP<IOutput>(o)); });
return true;
} }
std::vector<Hyprutils::Memory::CSharedPointer<SPollFD>> Aquamarine::CWaylandBackend::pollFDs() { std::vector<Hyprutils::Memory::CSharedPointer<SPollFD>> Aquamarine::CWaylandBackend::pollFDs() {
@ -431,11 +432,6 @@ std::vector<SDRMFormat> Aquamarine::CWaylandBackend::getCursorFormats() {
return dmabufFormats; return dmabufFormats;
} }
bool Aquamarine::CWaylandBackend::createOutput() {
createOutput(std::format("WAYLAND-{}", ++lastOutputID));
return true;
}
Aquamarine::CWaylandOutput::CWaylandOutput(const std::string& name_, Hyprutils::Memory::CWeakPointer<CWaylandBackend> backend_) : backend(backend_) { Aquamarine::CWaylandOutput::CWaylandOutput(const std::string& name_, Hyprutils::Memory::CWeakPointer<CWaylandBackend> backend_) : backend(backend_) {
name = name_; name = name_;

View file

@ -651,7 +651,7 @@ std::vector<SDRMFormat> Aquamarine::CDRMBackend::getCursorFormats() {
return {}; return {};
} }
bool Aquamarine::CDRMBackend::createOutput() { bool Aquamarine::CDRMBackend::createOutput(const std::string&) {
return false; return false;
} }