Zakero's C++ Header Libraries
A collection of reusable C++ libraries
|
Zakero Yetani. More...
Go to the source code of this file.
Classes | |
struct | zakero::Yetani::CursorConfig |
Cursor configuration. More... | |
struct | zakero::Yetani::Key |
Key event information. More... | |
struct | zakero::Yetani::KeyModifier |
A collection modifier flags. More... | |
struct | zakero::Yetani::Window::Memory |
The shared memory. More... | |
struct | zakero::Yetani::Output |
Information about a output device. More... | |
struct | zakero::Yetani::PointerAxis |
Information about an Axis event. More... | |
struct | zakero::Yetani::PointerButton |
Information about a pointer button event. More... | |
struct | zakero::Yetani::PointMm |
A location that uses millimeters. More... | |
struct | zakero::Yetani::PointPercent |
A location that uses percentages. More... | |
struct | zakero::Yetani::PointPixel |
A location that uses pixels. More... | |
struct | zakero::Yetani::SizeMm |
Size measured in millimeters. More... | |
struct | zakero::Yetani::SizePercent |
Size measured as a percentage of the Output (Monitor) resolution. More... | |
struct | zakero::Yetani::SizePixel |
Size measured in pixels. More... | |
class | zakero::Yetani::Window |
A Window. More... | |
class | zakero::Yetani |
A wrapper class for Wayland. More... | |
Macros | |
#define | ZAKERO_YETANI_ENABLE_DEBUG |
Enable debugging output. More... | |
#define | ZAKERO_YETANI_ENABLE_DEBUG_STREAM |
The stream to use for debugging output. More... | |
#define | ZAKERO_YETANI_ENABLE_SAFE_MODE |
Add extra error checking. More... | |
#define | ZAKERO_YETANI_IMPLEMENTATION |
Activate the implementation code. More... | |
Functions | |
bool | zakero::operator== (Yetani::PointMm &lhs, Yetani::PointMm &rhs) noexcept |
Compare two Point objects. More... | |
bool | zakero::operator== (Yetani::PointPercent &lhs, Yetani::PointPercent &rhs) noexcept |
Compare two Point objects. More... | |
bool | zakero::operator== (Yetani::PointPixel &lhs, Yetani::PointPixel &rhs) noexcept |
Compare two Point objects. More... | |
bool | zakero::operator== (Yetani::SizeMm &lhs, Yetani::SizeMm &rhs) noexcept |
Compare two Point objects. More... | |
bool | zakero::operator== (Yetani::SizePercent &lhs, Yetani::SizePercent &rhs) noexcept |
Compare two Point objects. More... | |
bool | zakero::operator== (Yetani::SizePixel &lhs, Yetani::SizePixel &rhs) noexcept |
Compare two Size objects. More... | |
std::string | zakero::to_string (const std::error_code &error) noexcept |
Convert an std::error_code to a std::string. More... | |
std::string | zakero::to_string (const wl_shm_format &shm_format) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::Key &key) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::KeyModifier &key_modifier) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::KeyState &key_state) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::Output &output) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::PointerAxis &axis) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::PointerAxisSource &source) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::PointerAxisType &type) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::PointerButton &button) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::PointerButtonState &button_state) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::PointMm &point) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::PointPercent &point) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::PointPixel &point) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::SizeMm &size) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::SizePercent &size) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::SizePixel &size) noexcept |
Convert a value to a std::string. More... | |
std::string | zakero::to_string (const Yetani::WindowMode &window_mode) noexcept |
Convert a value to a std::string. More... | |
API | Dependencies | TL;DR | What Is It? | Why Use It? | How To Use It? | Version |
Making the Wayland windowing system easy to use.
This library makes it very easy to connect to Wayland and display windows. The developer must write pixel data directly into the window. No UI or graphics functionality is provided.
To use:
Wayland is a Windowing System and was intended to strip all the cruft that has built up in X11. The part of Wayland that does the rendering is called the "Wayland Compositor". The "Wayland Client" is the application that the user interacts with. Communication between the two is done using the "Wayland Protocol". This is a simplification. If you want more details, please do a search on the internet.
Implementing the "Wayland Protocol" for a "Wayland Client" is easy to do.
However, this code is verbose and tedious. Plus, once you start working on your second and third "Wayland Client", much of this code is duplicated.
Consolidating this redundant code is one of the reasons behind Yetani.
The zakero::Yetani class interacts with the basic Wayland functionality, such as determining what pixel formats are supported and which Output devices are currently available. Custom graphics for cursors is also supported.
The zakero::Yetani::Window class makes creating a window effortless. Rendering graphics has been simplified to the point where you just provide the graphics data to the window and it will take care of the rest. zakero::Yetani::Window also supports sizes in percentages of the output device size as well as in millimeters, in additional to the traditional pixel sizes.
Wayland was intended to strip all the cruft that has built up in X11 and focus on three things. The part of Wayland that does the rendering is the "Wayland Compositor". The part that is the application is the "Wayland Client". And they talk using the "Wayland Protocol". Again, this is a simplification. If you want more details, please do a search on the internet.
Implementing the "Wayland Protocol" in "Wayland Client" is easy to do.
However, this code is verbose and tedious. Once you start working on your second and third "Wayland Client", much of this code is duplicated.
Consolidating the redundant code is the purpose of the Yetani.
Step 0
Your compiler must support at least the C++20 standard. The location of the Zakero_*.h
header files must be in your compiler's include path.
Step 1
The first step is to select which C++ source code file will contain the Zakero Yetani implementation. Once the location has been determined, add the following to that file:
The macro ZAKERO_YETANI_IMPLEMENTATION tells the header file to include the implementation of the Yetani.
Notice that the Zakero MemoryPool implementation, ZAKERO_MEMORYPOLL_IMPLEMENTATION, is included before the Zakero_Yetain.h
header. Zakero Yetani depends on the memory pool for shared memory with the Wayland compositor. If the Zakero MemoryPool implementation was added else where, this define can be omitted.
In all other files that will use Yetani, they only need to include the header.
Step 2
Below is a simple program that will conncet to the Wayland Compositor and display a window.
The following commands will build and run the example program.
v0.6.1
v0.6.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
v0.1.0
struct zakero::Yetani::CursorConfig |
Class Members | ||
---|---|---|
wl_shm_format | format | The pixel format. |
int32_t | hotspot_x | The X location of the hotspot. |
int32_t | hotspot_y | The Y location of the hotspot. |
const vector< void * > & | image_data | A collection of image data. |
SizePixel | size | The size of the cursor. |
milliseconds | time_per_frame | How long to display each frame of animation. |
struct zakero::Yetani::Key |
Time is based on the "steady clock" and not system time.
Class Members | ||
---|---|---|
uint32_t | code | The key code of the event. |
KeyState | state | The state of the key. |
uint32_t | time | When the key event happened. |
struct zakero::Yetani::KeyModifier |
The meaning of the modifiers are:
struct zakero::Yetani::Window::Memory |
This structure holds the shared memory used by the Window.
Class Members | ||
---|---|---|
MemoryPool | memory_pool | The Window's Memory Pool. |
struct wl_shm_pool * | wl_shm_pool | A pointer to the Wayland Shared Memory Pool. |
struct zakero::Yetani::Output |
All the Wayland information about an output device in a single structure.
struct zakero::Yetani::PointerAxis |
Class Members | ||
---|---|---|
float | distance | The distance traveled. |
PointerAxisSource | source | The source of the event. |
int32_t | steps | The number of rotation steps. |
uint32_t | time | When the event occurred. |
PointerAxisType | type | The type of Axis. |
struct zakero::Yetani::PointerButton |
Class Members | ||
---|---|---|
uint32_t | code | The event code. |
PointerButtonState | state | The button state. |
#define ZAKERO_YETANI_ENABLE_DEBUG |
Enabled debugging messages to be written.
#define ZAKERO_YETANI_ENABLE_DEBUG_STREAM |
This macro holds the stream that will be written to for the debug messages.
If this macro is undefined at compile time, then std::cerr
will be used.
#define ZAKERO_YETANI_ENABLE_SAFE_MODE |
Before a method executes, it should validate the argument values that it receives. This is useful while developing code but adds overhead. If the calling code can guarantee that all argument data is valid, this macro can be enabled to reduce the validation checks and overhead.
#define ZAKERO_YETANI_IMPLEMENTATION |
Defining this macro will cause the Zakero Yetani implementation to be included. This should only be done once, since compiler and/or linker errors will typically be generated if more than a single implementation is found.
|
noexcept |
The X coordinates of both objects are considered to be equal if they are less than 0.001mm apart.
The same applies with the Y coordinates.
time
value is not compared.true | Equal |
false | Not Equal |
lhs | Left-Hand side |
rhs | Right-Hand side |
|
noexcept |
The X coordinates of both objects are considered to be equal if they are less than 0.001% apart.
The same applies with the Y coordinates.
time
value is not compared.true | Equal |
false | Not Equal |
lhs | Left-Hand side |
rhs | Right-Hand side |
|
noexcept |
Compare the X and Y values.
time
value is not compared.true | Equal |
false | Not Equal |
lhs | Left-Hand side |
rhs | Right-Hand side |
|
noexcept |
The width of both objects are considered to be equal if they are less than 0.001mm difference in length.
The same applies with the height.
true | Equal |
false | Not Equal |
lhs | Left-Hand side |
rhs | Right-Hand side |
|
noexcept |
The width of both objects are considered to be equal if they are less than 0.001% difference in length.
The same applies with the height.
true | Equal |
false | Not Equal |
lhs | Left-Hand side |
rhs | Right-Hand side |
|
noexcept |
Compare the width and height values.
true | Equal |
false | Not Equal |
lhs | Left-Hand side |
rhs | Right-Hand side |
|
inlinenoexcept |
The provided error
will be converted to a string.
error | The value |
|
noexcept |
The Wayland SHM color format will be converted into a std::string.
shm_format | The value |
|
noexcept |
The key
data will be converted into a JSON formatted std::string.
key | The value |
|
noexcept |
The key_modifier
data will be converted into a JSON formatted std::string.
key_modifier | The value |
|
noexcept |
The key_state
will be converted into a std::string.
key_state | The value |
|
noexcept |
The output
data will be converted into a JSON formatted std::string.
output | The value |
|
noexcept |
The axis
will be converted into a std::string.
axis | The value |
|
noexcept |
The source
will be converted into a std::string.
source | The value |
|
noexcept |
The type
will be converted into a std::string.
type | The value |
|
noexcept |
The button
will be converted into a std::string.
button | The value |
|
noexcept |
The button_state
will be converted into a std::string.
button_state | The value |
|
noexcept |
The point
will be converted into a std::string.
point | The value |
|
noexcept |
The point
will be converted into a std::string.
point | The value |
|
noexcept |
The point
will be converted into a std::string.
point | The value |
|
noexcept |
The size
will be converted into a std::string.
size | The value |
|
noexcept |
The size
will be converted into a std::string.
size | The value |
|
noexcept |
The size
will be converted into a std::string.
size | The value |
|
noexcept |
The window_mode
value will be converted into a std::string.
window_mode | The value |