mirror of
https://github.com/hyprwm/aquamarine.git
synced 2025-12-20 02:30:02 +01:00
core: Use new typed signals from hyprutils (#178)
This commit is contained in:
parent
7cef49d261
commit
dd92142139
13 changed files with 106 additions and 94 deletions
|
|
@ -29,7 +29,7 @@ pkg_check_modules(
|
|||
libinput>=1.26.0
|
||||
wayland-client
|
||||
wayland-protocols
|
||||
hyprutils>=0.5.2
|
||||
hyprutils>=0.8.0
|
||||
pixman-1
|
||||
libdrm
|
||||
gbm
|
||||
|
|
|
|||
18
flake.lock
generated
18
flake.lock
generated
|
|
@ -10,11 +10,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1749135356,
|
||||
"narHash": "sha256-Q8mAKMDsFbCEuq7zoSlcTuxgbIBVhfIYpX0RjE32PS0=",
|
||||
"lastModified": 1750960192,
|
||||
"narHash": "sha256-AbaeiQAFq66XRMkhnwzxe8uZO2d81RdqO2XuuMzZU8U=",
|
||||
"owner": "hyprwm",
|
||||
"repo": "hyprutils",
|
||||
"rev": "e36db00dfb3a3d3fdcc4069cb292ff60d2699ccb",
|
||||
"rev": "d844a08d830e87d023ba2838e645004cb08118f6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -33,11 +33,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1749145760,
|
||||
"narHash": "sha256-IHaGWpGrv7seFWdw/1A+wHtTsPlOGIKMrk1TUIYJEFI=",
|
||||
"lastModified": 1750371869,
|
||||
"narHash": "sha256-lGk4gLjgZQ/rndUkzmPYcgbHr8gKU5u71vyrjnwfpB4=",
|
||||
"owner": "hyprwm",
|
||||
"repo": "hyprwayland-scanner",
|
||||
"rev": "817918315ea016cc2d94004bfb3223b5fd9dfcc6",
|
||||
"rev": "aa38edd6e3e277ae6a97ea83a69261a5c3aab9fd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -48,11 +48,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1748929857,
|
||||
"narHash": "sha256-lcZQ8RhsmhsK8u7LIFsJhsLh/pzR9yZ8yqpTzyGdj+Q=",
|
||||
"lastModified": 1750776420,
|
||||
"narHash": "sha256-/CG+w0o0oJ5itVklOoLbdn2dGB0wbZVOoDm4np6w09A=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c2a03962b8e24e669fb37b7df10e7c79531ff1a4",
|
||||
"rev": "30a61f056ac492e3b7cdcb69c1e6abdcf00e39cf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,15 @@
|
|||
#include "Session.hpp"
|
||||
|
||||
namespace Aquamarine {
|
||||
class IOutput;
|
||||
class IPointer;
|
||||
class IKeyboard;
|
||||
class ITouch;
|
||||
class ISwitch;
|
||||
class ITablet;
|
||||
class ITabletTool;
|
||||
class ITabletPad;
|
||||
|
||||
enum eBackendType : uint32_t {
|
||||
AQ_BACKEND_WAYLAND = 0,
|
||||
AQ_BACKEND_DRM,
|
||||
|
|
@ -123,16 +132,21 @@ namespace Aquamarine {
|
|||
void onNewGpu(std::string path);
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal newOutput;
|
||||
Hyprutils::Signal::CSignal newPointer;
|
||||
Hyprutils::Signal::CSignal newKeyboard;
|
||||
Hyprutils::Signal::CSignal newTouch;
|
||||
Hyprutils::Signal::CSignal newSwitch;
|
||||
Hyprutils::Signal::CSignal newTablet;
|
||||
Hyprutils::Signal::CSignal newTabletTool;
|
||||
Hyprutils::Signal::CSignal newTabletPad;
|
||||
private:
|
||||
template <typename T>
|
||||
using SP = Hyprutils::Memory::CSharedPointer<T>;
|
||||
|
||||
Hyprutils::Signal::CSignal pollFDsChanged;
|
||||
public:
|
||||
Hyprutils::Signal::CSignalT<SP<IOutput>> newOutput;
|
||||
Hyprutils::Signal::CSignalT<SP<IPointer>> newPointer;
|
||||
Hyprutils::Signal::CSignalT<SP<IKeyboard>> newKeyboard;
|
||||
Hyprutils::Signal::CSignalT<SP<ITouch>> newTouch;
|
||||
Hyprutils::Signal::CSignalT<SP<ISwitch>> newSwitch;
|
||||
Hyprutils::Signal::CSignalT<SP<ITablet>> newTablet;
|
||||
Hyprutils::Signal::CSignalT<SP<ITabletTool>> newTabletTool;
|
||||
Hyprutils::Signal::CSignalT<SP<ITabletPad>> newTabletPad;
|
||||
|
||||
Hyprutils::Signal::CSignalT<> pollFDsChanged;
|
||||
} events;
|
||||
|
||||
Hyprutils::Memory::CSharedPointer<IAllocator> primaryAllocator;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace Aquamarine {
|
|||
bool active = true;
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal destroy;
|
||||
Hyprutils::Signal::CSignalT<> destroy;
|
||||
} events;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ namespace Aquamarine {
|
|||
};
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal change;
|
||||
Hyprutils::Signal::CSignal remove;
|
||||
Hyprutils::Signal::CSignalT<SChangeEvent> change;
|
||||
Hyprutils::Signal::CSignalT<> remove;
|
||||
} events;
|
||||
|
||||
private:
|
||||
|
|
@ -224,9 +224,9 @@ namespace Aquamarine {
|
|||
};
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal changeActive;
|
||||
Hyprutils::Signal::CSignal addDrmCard;
|
||||
Hyprutils::Signal::CSignal destroy;
|
||||
Hyprutils::Signal::CSignalT<> changeActive;
|
||||
Hyprutils::Signal::CSignalT<SAddDrmCardEvent> addDrmCard;
|
||||
Hyprutils::Signal::CSignalT<> destroy;
|
||||
} events;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ namespace Aquamarine {
|
|||
CAttachmentManager attachments;
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal destroy;
|
||||
Hyprutils::Signal::CSignal backendRelease;
|
||||
Hyprutils::Signal::CSignalT<> destroy;
|
||||
Hyprutils::Signal::CSignalT<> backendRelease;
|
||||
} events;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ namespace Aquamarine {
|
|||
};
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal destroy;
|
||||
Hyprutils::Signal::CSignal key;
|
||||
Hyprutils::Signal::CSignal modifiers;
|
||||
Hyprutils::Signal::CSignalT<> destroy;
|
||||
Hyprutils::Signal::CSignalT<SKeyEvent> key;
|
||||
Hyprutils::Signal::CSignalT<SModifiersEvent> modifiers;
|
||||
} events;
|
||||
};
|
||||
|
||||
|
|
@ -128,23 +128,23 @@ namespace Aquamarine {
|
|||
};
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal destroy;
|
||||
Hyprutils::Signal::CSignal move;
|
||||
Hyprutils::Signal::CSignal warp;
|
||||
Hyprutils::Signal::CSignal button;
|
||||
Hyprutils::Signal::CSignal axis;
|
||||
Hyprutils::Signal::CSignal frame;
|
||||
Hyprutils::Signal::CSignalT<> destroy;
|
||||
Hyprutils::Signal::CSignalT<SMoveEvent> move;
|
||||
Hyprutils::Signal::CSignalT<SWarpEvent> warp;
|
||||
Hyprutils::Signal::CSignalT<SButtonEvent> button;
|
||||
Hyprutils::Signal::CSignalT<SAxisEvent> axis;
|
||||
Hyprutils::Signal::CSignalT<> frame;
|
||||
|
||||
Hyprutils::Signal::CSignal swipeBegin;
|
||||
Hyprutils::Signal::CSignal swipeUpdate;
|
||||
Hyprutils::Signal::CSignal swipeEnd;
|
||||
Hyprutils::Signal::CSignalT<SSwipeBeginEvent> swipeBegin;
|
||||
Hyprutils::Signal::CSignalT<SSwipeUpdateEvent> swipeUpdate;
|
||||
Hyprutils::Signal::CSignalT<SSwipeEndEvent> swipeEnd;
|
||||
|
||||
Hyprutils::Signal::CSignal pinchBegin;
|
||||
Hyprutils::Signal::CSignal pinchUpdate;
|
||||
Hyprutils::Signal::CSignal pinchEnd;
|
||||
Hyprutils::Signal::CSignalT<SPinchBeginEvent> pinchBegin;
|
||||
Hyprutils::Signal::CSignalT<SPinchUpdateEvent> pinchUpdate;
|
||||
Hyprutils::Signal::CSignalT<SPinchEndEvent> pinchEnd;
|
||||
|
||||
Hyprutils::Signal::CSignal holdBegin;
|
||||
Hyprutils::Signal::CSignal holdEnd;
|
||||
Hyprutils::Signal::CSignalT<SHoldBeginEvent> holdBegin;
|
||||
Hyprutils::Signal::CSignalT<SHoldEndEvent> holdEnd;
|
||||
} events;
|
||||
};
|
||||
|
||||
|
|
@ -182,12 +182,12 @@ namespace Aquamarine {
|
|||
};
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal destroy;
|
||||
Hyprutils::Signal::CSignal move;
|
||||
Hyprutils::Signal::CSignal down;
|
||||
Hyprutils::Signal::CSignal up;
|
||||
Hyprutils::Signal::CSignal cancel;
|
||||
Hyprutils::Signal::CSignal frame;
|
||||
Hyprutils::Signal::CSignalT<> destroy;
|
||||
Hyprutils::Signal::CSignalT<SMotionEvent> move;
|
||||
Hyprutils::Signal::CSignalT<SDownEvent> down;
|
||||
Hyprutils::Signal::CSignalT<SUpEvent> up;
|
||||
Hyprutils::Signal::CSignalT<SCancelEvent> cancel;
|
||||
Hyprutils::Signal::CSignalT<> frame;
|
||||
} events;
|
||||
};
|
||||
|
||||
|
|
@ -213,8 +213,8 @@ namespace Aquamarine {
|
|||
};
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal destroy;
|
||||
Hyprutils::Signal::CSignal fire;
|
||||
Hyprutils::Signal::CSignalT<> destroy;
|
||||
Hyprutils::Signal::CSignalT<SFireEvent> fire;
|
||||
} events;
|
||||
};
|
||||
|
||||
|
|
@ -277,11 +277,11 @@ namespace Aquamarine {
|
|||
};
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal axis;
|
||||
Hyprutils::Signal::CSignal proximity;
|
||||
Hyprutils::Signal::CSignal tip;
|
||||
Hyprutils::Signal::CSignal button;
|
||||
Hyprutils::Signal::CSignal destroy;
|
||||
Hyprutils::Signal::CSignalT<SAxisEvent> axis;
|
||||
Hyprutils::Signal::CSignalT<SProximityEvent> proximity;
|
||||
Hyprutils::Signal::CSignalT<STipEvent> tip;
|
||||
Hyprutils::Signal::CSignalT<SButtonEvent> button;
|
||||
Hyprutils::Signal::CSignalT<> destroy;
|
||||
} events;
|
||||
};
|
||||
|
||||
|
|
@ -321,7 +321,7 @@ namespace Aquamarine {
|
|||
uint32_t capabilities = 0; // enum eTabletToolCapabilities
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal destroy;
|
||||
Hyprutils::Signal::CSignalT<> destroy;
|
||||
} events;
|
||||
};
|
||||
|
||||
|
|
@ -379,11 +379,11 @@ namespace Aquamarine {
|
|||
};
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal destroy;
|
||||
Hyprutils::Signal::CSignal button;
|
||||
Hyprutils::Signal::CSignal ring;
|
||||
Hyprutils::Signal::CSignal strip;
|
||||
Hyprutils::Signal::CSignal attach;
|
||||
Hyprutils::Signal::CSignalT<> destroy;
|
||||
Hyprutils::Signal::CSignalT<SButtonEvent> button;
|
||||
Hyprutils::Signal::CSignalT<SRingEvent> ring;
|
||||
Hyprutils::Signal::CSignalT<SStripEvent> strip;
|
||||
Hyprutils::Signal::CSignalT<> attach;
|
||||
} events;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,12 +209,12 @@ namespace Aquamarine {
|
|||
};
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CSignal destroy;
|
||||
Hyprutils::Signal::CSignal frame;
|
||||
Hyprutils::Signal::CSignal needsFrame;
|
||||
Hyprutils::Signal::CSignal present;
|
||||
Hyprutils::Signal::CSignal commit;
|
||||
Hyprutils::Signal::CSignal state;
|
||||
Hyprutils::Signal::CSignalT<> destroy;
|
||||
Hyprutils::Signal::CSignalT<> frame;
|
||||
Hyprutils::Signal::CSignalT<> needsFrame;
|
||||
Hyprutils::Signal::CSignalT<SPresentEvent> present;
|
||||
Hyprutils::Signal::CSignalT<> commit;
|
||||
Hyprutils::Signal::CSignalT<SStateEvent> state;
|
||||
} events;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ using namespace Hyprutils::Memory;
|
|||
#define WP CWeakPointer
|
||||
|
||||
Aquamarine::CDRMDumbBuffer::CDRMDumbBuffer(const SAllocatorBufferParams& params, Hyprutils::Memory::CWeakPointer<CDRMDumbAllocator> allocator_,
|
||||
Hyprutils::Memory::CSharedPointer<CSwapchain> swapchain) : allocator(allocator_) {
|
||||
Hyprutils::Memory::CSharedPointer<CSwapchain> swapchain) :
|
||||
allocator(allocator_) {
|
||||
attrs.format = params.format;
|
||||
|
||||
if (int ret = drmModeCreateDumbBuffer(allocator->drmFD(), params.size.x, params.size.y, 32, 0, &handle, &stride, &bufferLen); ret < 0) {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ static SDRMFormat guessFormatFrom(std::vector<SDRMFormat> formats, bool cursor,
|
|||
}
|
||||
|
||||
Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hyprutils::Memory::CWeakPointer<CGBMAllocator> allocator_,
|
||||
Hyprutils::Memory::CSharedPointer<CSwapchain> swapchain) : allocator(allocator_) {
|
||||
Hyprutils::Memory::CSharedPointer<CSwapchain> swapchain) :
|
||||
allocator(allocator_) {
|
||||
if (!allocator)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ using namespace Hyprutils::Math;
|
|||
#define SP CSharedPointer
|
||||
|
||||
Aquamarine::CDRMBackend::CDRMBackend(SP<CBackend> backend_) : backend(backend_) {
|
||||
listeners.sessionActivate = backend->session->events.changeActive.registerListener([this](std::any d) {
|
||||
listeners.sessionActivate = backend->session->events.changeActive.listen([this] {
|
||||
if (backend->session->active) {
|
||||
// session got activated, we need to restore
|
||||
restoreAfterVT();
|
||||
|
|
@ -736,8 +736,7 @@ bool Aquamarine::CDRMBackend::registerGPU(SP<CSessionDevice> gpu_, SP<CDRMBacken
|
|||
|
||||
drmFreeVersion(drmVer);
|
||||
|
||||
listeners.gpuChange = gpu->events.change.registerListener([this](std::any d) {
|
||||
auto E = std::any_cast<CSessionDevice::SChangeEvent>(d);
|
||||
listeners.gpuChange = gpu->events.change.listen([this](const CSessionDevice::SChangeEvent& E) {
|
||||
if (E.type == CSessionDevice::AQ_SESSION_EVENT_CHANGE_HOTPLUG) {
|
||||
backend->log(AQ_LOG_DEBUG, std::format("drm: Got a hotplug event for {}", gpuName));
|
||||
recheckOutputs();
|
||||
|
|
@ -747,7 +746,7 @@ bool Aquamarine::CDRMBackend::registerGPU(SP<CSessionDevice> gpu_, SP<CDRMBacken
|
|||
}
|
||||
});
|
||||
|
||||
listeners.gpuRemove = gpu->events.remove.registerListener([this](std::any d) {
|
||||
listeners.gpuRemove = gpu->events.remove.listen([this] {
|
||||
std::erase_if(backend->implementations, [this](const auto& impl) { return impl->drmFD() == this->drmFD(); });
|
||||
backend->events.pollFDsChanged.emit();
|
||||
});
|
||||
|
|
@ -2073,7 +2072,7 @@ void Aquamarine::CDRMFB::import() {
|
|||
|
||||
closeHandles();
|
||||
|
||||
listeners.destroyBuffer = buffer->events.destroy.registerListener([this](std::any d) {
|
||||
listeners.destroyBuffer = buffer->events.destroy.listen([this] {
|
||||
drop();
|
||||
dead = true;
|
||||
id = 0;
|
||||
|
|
|
|||
|
|
@ -1114,6 +1114,7 @@ bool CDRMRenderer::verifyDestinationDMABUF(const SDMABUFAttrs& attrs) {
|
|||
|
||||
CDRMRendererBufferAttachment::CDRMRendererBufferAttachment(Hyprutils::Memory::CWeakPointer<CDRMRenderer> renderer_, Hyprutils::Memory::CSharedPointer<IBuffer> buffer,
|
||||
EGLImageKHR image, GLuint fbo_, GLuint rbo_, SGLTex&& tex_, std::vector<uint8_t> intermediateBuf_) :
|
||||
eglImage(image), fbo(fbo_), rbo(rbo_), tex(makeUnique<SGLTex>(std::move(tex_))), intermediateBuf(intermediateBuf_), renderer(renderer_) {
|
||||
bufferDestroy = buffer->events.destroy.registerListener([this](std::any d) { renderer->onBufferAttachmentDrop(this); });
|
||||
eglImage(image),
|
||||
fbo(fbo_), rbo(rbo_), tex(makeUnique<SGLTex>(std::move(tex_))), intermediateBuf(intermediateBuf_), renderer(renderer_) {
|
||||
bufferDestroy = buffer->events.destroy.listen([this] { renderer->onBufferAttachmentDrop(this); });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,28 +60,24 @@ int main(int argc, char** argv, char** envp) {
|
|||
|
||||
auto aqBackend = Aquamarine::CBackend::create(implementations, options);
|
||||
|
||||
newOutputListener = aqBackend->events.newOutput.registerListener([](std::any data) {
|
||||
output = std::any_cast<SP<Aquamarine::IOutput>>(data);
|
||||
newOutputListener = aqBackend->events.newOutput.listen([](const SP<Aquamarine::IOutput> newOutput) {
|
||||
output = newOutput;
|
||||
|
||||
std::cout << "[Client] Got a new output named " << output->name << "\n";
|
||||
|
||||
outputFrameListener = output->events.frame.registerListener([](std::any data) { onFrame(); });
|
||||
outputStateListener = output->events.state.registerListener([](std::any data) { onState(std::any_cast<Aquamarine::IOutput::SStateEvent>(data)); });
|
||||
outputFrameListener = output->events.frame.listen([] { onFrame(); });
|
||||
outputStateListener = output->events.state.listen([](const Aquamarine::IOutput::SStateEvent& event) { onState(event); });
|
||||
});
|
||||
|
||||
newMouseListener = aqBackend->events.newPointer.registerListener([] (std::any pointer) {
|
||||
auto p = std::any_cast<SP<Aquamarine::IPointer>>(pointer);
|
||||
mouseMotionListener = p->events.warp.registerListener([] (std::any data) {
|
||||
auto e = std::any_cast<Aquamarine::IPointer::SWarpEvent>(data);
|
||||
std::cout << "[Client] Mouse warped to " << std::format("{}", e.absolute) << "\n";
|
||||
newMouseListener = aqBackend->events.newPointer.listen([](const SP<Aquamarine::IPointer>& pointer) {
|
||||
mouseMotionListener = pointer->events.warp.listen([](const Aquamarine::IPointer::SWarpEvent& event) {
|
||||
std::cout << "[Client] Mouse warped to " << std::format("{}", event.absolute) << "\n";
|
||||
});
|
||||
});
|
||||
|
||||
newKeyboardListener = aqBackend->events.newKeyboard.registerListener([] (std::any keeb) {
|
||||
auto k = std::any_cast<SP<Aquamarine::IKeyboard>>(keeb);
|
||||
keyboardKeyListener = k->events.key.registerListener([] (std::any data) {
|
||||
auto e = std::any_cast<Aquamarine::IKeyboard::SKeyEvent>(data);
|
||||
std::cout << "[Client] Key " << std::format("{}", e.key) << " state: " << e.pressed << " \n";
|
||||
newKeyboardListener = aqBackend->events.newKeyboard.listen([](const SP<Aquamarine::IKeyboard>& keyboard) {
|
||||
keyboardKeyListener = keyboard->events.key.listen([](const Aquamarine::IKeyboard::SKeyEvent& event) {
|
||||
std::cout << "[Client] Key " << std::format("{}", event.key) << " state: " << event.pressed << " \n";
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -94,4 +90,4 @@ int main(int argc, char** argv, char** envp) {
|
|||
// aqBackend->enterLoop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue