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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#ifndef MONMON_HH
#define MONMON_HH
#include <memory>
#include <mutex>
#include "animator.hh"
#include "cairo.hh"
#include "io.hh"
#include "pango.hh"
#include "poll_looper.hh"
#include "x.hh"
class MonMon : protected virtual Animator::Observer {
public:
virtual ~MonMon();
void init(x::shared_connection const& conn, xcb_screen_t const* screen,
x::Format format, std::shared_ptr<x::Atoms> const& atoms,
std::shared_ptr<x::Ewmh> const& ewmh,
uint16_t width, uint16_t height, bool normal, bool black);
void quit_from_xcb();
#if FAKE_MONITOR
void toggle_fakes();
#endif
void expose(int16_t x, int16_t y, uint16_t w, uint16_t h);
bool match(xcb_window_t wnd) const {
return wnd == wnd_.get();
}
void configure(int16_t x, int16_t y, uint16_t w, uint16_t h);
void update_desktop_window();
void update_desktop_window(xcb_window_t window, xcb_atom_t property);
static void preload(x::Atoms* atoms);
protected:
MonMon(std::shared_ptr<PollLooper> const& looper);
virtual void width_changed() {
}
#if FAKE_MONITOR
virtual void do_toggle_fakes() {
}
#endif
virtual void stop_all_animations() {
}
virtual void internal_quit() {
}
virtual void draw_content(cairo_t* cairo, PangoLayout* layout,
uint16_t w, uint16_t h) = 0;
static void rounded_path(cairo_t* cr, double x, double y,
double width, double height);
void draw();
std::shared_ptr<PollLooper> looper_;
std::unique_ptr<Animator> animator_;
x::unique_window wnd_;
double box_height_;
private:
void unset_desktop_window();
void update_desktop_pixmap();
void close_pipe();
void pipe(Looper*, int, uint8_t event);
void internal_draw();
void force_draw();
void tick(Animator*) override;
io::pipe pipe_;
std::shared_ptr<x::Atoms> atoms_;
x::unique_gcontext gcontext_;
x::unique_colormap cmap_;
uint8_t depth_;
uint32_t black_pixel_;
xcb_screen_t const* screen_;
std::mutex mutex_;
cairo::unique_surface surface_;
cairo::unique cairo_;
pango::unique_layout layout_;
x::unique_pixmap pixmap_;
int16_t x_, y_;
uint16_t w_, h_;
xcb_atom_t rootpmap_;
xcb_window_t desktop_window_;
xcb_pixmap_t desktop_pixmap_;
cairo::unique_surface desktop_surface_;
};
#endif // MONMON_HH
|