File: only_metadata.cpp

package info (click to toggle)
libhyprcursor 0.1.13-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 284 kB
  • sloc: cpp: 1,546; ansic: 130; makefile: 16
file content (80 lines) | stat: -rw-r--r-- 2,003 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

/*
    only_metadata.cpp

    This is a mode in which you probably do NOT want to operate,
    but major DEs might want their own renderer for
    cursor shapes.

    Prefer full_rendering.cpp for consistency and simplicity.
*/

#include <iostream>
#include <hyprcursor/hyprcursor.hpp>

void logFunction(enum eHyprcursorLogLevel level, char* message) {
    std::cout << "[hc] " << message << "\n";
}

int main(int argc, char** argv) {
    /*
        Create a manager. You can optionally pass a logger function.
    */
    Hyprcursor::CHyprcursorManager mgr(nullptr, logFunction);

    /*
        Manager could be invalid if no themes were found, or
        a specified theme was invalid.
    */
    if (!mgr.valid()) {
        std::cout << "mgr is invalid\n";
        return 1;
    }

    /*
        If you are planning on using your own renderer,
        you do not want to load in any styles, as those
        are rendered once you make your call.

        Instead, let's request left_ptr's metadata
    */
    auto RAWDATA = mgr.getRawShapeData("left_ptr");

    /*
        if images are empty, check overridenBy
    */
    if (RAWDATA.images.empty()) {

        /*
            if overridenBy is empty, the current theme doesn't have this shape.
        */
        if (RAWDATA.overridenBy.empty())
            return false;

        /*
            load what it's overriden by.
        */
        RAWDATA = mgr.getRawShapeData(RAWDATA.overridenBy.c_str());
    }

    /*
        If we still have no images, the theme seems broken.
    */
    if (RAWDATA.images.empty()) {
        std::cout << "failed querying left_ptr\n";
        return 1;
    }

    /*
        You can query the images (animation frames)
        or their properties.

        Every image has .data and .type for you to handle.
    */
    std::cout << "left_ptr images: " << RAWDATA.images.size() << "\n";
    for (auto& i : RAWDATA.images)
        std::cout << "left_ptr data size: " << i.data.size() << "\n";

    
    return 0;
}