forked from hyprwm/aquamarine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
864 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,6 @@ | |
build/ | ||
.vscode/ | ||
.cache/ | ||
|
||
protocols/*.cpp | ||
protocols/*.hpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#pragma once | ||
|
||
#include "./Backend.hpp" | ||
#include "../output/Output.hpp" | ||
#include "../input/Input.hpp" | ||
#include <hyprutils/memory/WeakPtr.hpp> | ||
#include <wayland-client.h> | ||
#include <wayland.hpp> | ||
#include <xdg-shell.hpp> | ||
|
||
namespace Aquamarine { | ||
class CBackend; | ||
class CWaylandBackend; | ||
|
||
class CWaylandOutput : public IOutput { | ||
public: | ||
virtual ~CWaylandOutput(); | ||
virtual void commit(); | ||
|
||
private: | ||
CWaylandOutput(const std::string& name_, Hyprutils::Memory::CWeakPointer<CWaylandBackend> backend_); | ||
|
||
std::string name; | ||
Hyprutils::Memory::CWeakPointer<CWaylandBackend> backend; | ||
|
||
struct { | ||
Hyprutils::Memory::CSharedPointer<CWlSurface> surface; | ||
Hyprutils::Memory::CSharedPointer<CXdgSurface> xdgSurface; | ||
Hyprutils::Memory::CSharedPointer<CXdgToplevel> xdgToplevel; | ||
} waylandState; | ||
|
||
friend class CWaylandBackend; | ||
friend class CWaylandPointer; | ||
}; | ||
|
||
class CWaylandKeyboard : public IKeyboard { | ||
public: | ||
CWaylandKeyboard(Hyprutils::Memory::CSharedPointer<CWlKeyboard> keyboard_, Hyprutils::Memory::CWeakPointer<CWaylandBackend> backend_); | ||
virtual ~CWaylandKeyboard(); | ||
|
||
virtual const std::string& getName(); | ||
|
||
Hyprutils::Memory::CSharedPointer<CWlKeyboard> keyboard; | ||
Hyprutils::Memory::CWeakPointer<CWaylandBackend> backend; | ||
|
||
private: | ||
const std::string name = "wl_keyboard"; | ||
}; | ||
|
||
class CWaylandPointer : public IPointer { | ||
public: | ||
CWaylandPointer(Hyprutils::Memory::CSharedPointer<CWlPointer> pointer_, Hyprutils::Memory::CWeakPointer<CWaylandBackend> backend_); | ||
virtual ~CWaylandPointer(); | ||
|
||
virtual const std::string& getName(); | ||
|
||
Hyprutils::Memory::CSharedPointer<CWlPointer> pointer; | ||
Hyprutils::Memory::CWeakPointer<CWaylandBackend> backend; | ||
|
||
private: | ||
const std::string name = "wl_pointer"; | ||
}; | ||
|
||
class CWaylandBackend : public IBackendImplementation { | ||
public: | ||
virtual ~CWaylandBackend(); | ||
virtual eBackendType type(); | ||
virtual bool start(); | ||
virtual int pollFD(); | ||
virtual bool dispatchEvents(); | ||
|
||
Hyprutils::Memory::CWeakPointer<CWaylandBackend> self; | ||
|
||
private: | ||
CWaylandBackend(Hyprutils::Memory::CSharedPointer<CBackend> backend); | ||
|
||
void initSeat(); | ||
void initShell(); | ||
void createOutput(const std::string& szName); | ||
|
||
// | ||
Hyprutils::Memory::CWeakPointer<CBackend> backend; | ||
std::vector<Hyprutils::Memory::CSharedPointer<CWaylandOutput>> outputs; | ||
std::vector<Hyprutils::Memory::CSharedPointer<CWaylandKeyboard>> keyboards; | ||
std::vector<Hyprutils::Memory::CSharedPointer<CWaylandPointer>> pointers; | ||
|
||
// pointer focus | ||
Hyprutils::Memory::CWeakPointer<CWaylandOutput> focusedOutput; | ||
uint32_t lastEnterSerial = 0; | ||
|
||
struct { | ||
wl_display* display = nullptr; | ||
|
||
// hw-s types | ||
Hyprutils::Memory::CSharedPointer<CWlRegistry> registry; | ||
Hyprutils::Memory::CSharedPointer<CWlSeat> seat; | ||
Hyprutils::Memory::CSharedPointer<CXdgWmBase> xdg; | ||
Hyprutils::Memory::CSharedPointer<CWlCompositor> compositor; | ||
} waylandState; | ||
|
||
friend class CBackend; | ||
friend class CWaylandKeyboard; | ||
friend class CWaylandPointer; | ||
friend class CWaylandOutput; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#pragma once | ||
|
||
#include <array> | ||
#include <tuple> | ||
#include <hyprutils/signal/Signal.hpp> | ||
#include <hyprutils/math/Region.hpp> | ||
|
||
namespace Aquamarine { | ||
enum eBufferCapability { | ||
BUFFER_CAPABILITY_DATAPTR = (1 << 0), | ||
}; | ||
|
||
enum eBufferType { | ||
BUFFER_TYPE_DMABUF = 0, | ||
BUFFER_TYPE_SHM, | ||
BUFFER_TYPE_MISC, | ||
}; | ||
|
||
class CWLBufferResource; | ||
|
||
struct SDMABUFAttrs { | ||
bool success = false; | ||
Hyprutils::Math::Vector2D size; | ||
uint32_t format = 0; // fourcc | ||
uint64_t modifier = 0; | ||
|
||
int planes = 1; | ||
std::array<uint32_t, 4> offsets = {0}; | ||
std::array<uint32_t, 4> strides = {0}; | ||
std::array<int, 4> fds = {-1, -1, -1, -1}; | ||
}; | ||
|
||
struct SSHMAttrs { | ||
bool success = false; | ||
int fd = 0; | ||
uint32_t format = 0; | ||
Hyprutils::Math::Vector2D size; | ||
int stride = 0; | ||
int64_t offset = 0; | ||
}; | ||
|
||
class IBuffer { | ||
public: | ||
virtual ~IBuffer() { | ||
; | ||
}; | ||
|
||
virtual eBufferCapability caps() = 0; | ||
virtual eBufferType type() = 0; | ||
virtual void update(const Hyprutils::Math::CRegion& damage) = 0; | ||
virtual bool isSynchronous() = 0; // whether the updates to this buffer are synchronous, aka happen over cpu | ||
virtual SDMABUFAttrs dmabuf(); | ||
virtual SSHMAttrs shm(); | ||
virtual std::tuple<uint8_t*, uint32_t, size_t> beginDataPtr(uint32_t flags); | ||
virtual void endDataPtr(); | ||
virtual void sendRelease(); | ||
virtual void lock(); | ||
virtual void unlock(); | ||
virtual bool locked(); | ||
|
||
Hyprutils::Math::Vector2D size; | ||
bool opaque = false; | ||
|
||
struct { | ||
Hyprutils::Signal::CSignal destroy; | ||
} events; | ||
|
||
private: | ||
int locks = 0; | ||
}; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.