summaryrefslogtreecommitdiff
path: root/Servers/WindowServer/WSClipboard.h
blob: 945b5a582c8d6f0b140322e70f88ff3e2f051002 (plain)
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
#pragma once

#include <AK/Function.h>
#include <AK/SharedBuffer.h>
#include <AK/String.h>

class WSClipboard {
public:
    static WSClipboard& the();
    ~WSClipboard();

    bool has_data() const
    {
        return m_shared_buffer;
    }

    const String& data_type() const { return m_data_type; }
    const u8* data() const;
    int size() const;

    void clear();
    void set_data(NonnullRefPtr<SharedBuffer>&&, int contents_size, const String& data_type);

    Function<void()> on_content_change;

private:
    WSClipboard();

    String m_data_type;
    RefPtr<SharedBuffer> m_shared_buffer;
    int m_contents_size { 0 };
};