1 |
pcg |
1.1 |
#ifndef RXVT_COLOR_H |
2 |
|
|
#define RXVT_COLOR_H |
3 |
|
|
|
4 |
|
|
#include <X11/Xlib.h> |
5 |
|
|
|
6 |
|
|
#if XFT |
7 |
|
|
# include <X11/Xft/Xft.h> |
8 |
|
|
#endif |
9 |
|
|
|
10 |
pcg |
1.3 |
#include "iom.h" |
11 |
|
|
|
12 |
pcg |
1.1 |
#include "rxvtlib.h" |
13 |
pcg |
1.3 |
#include "rxvtstl.h" |
14 |
|
|
|
15 |
|
|
#include "callback.h" |
16 |
pcg |
1.1 |
|
17 |
|
|
struct rxvt_vars; |
18 |
|
|
|
19 |
pcg |
1.3 |
struct xevent_watcher; |
20 |
|
|
|
21 |
|
|
struct rxvt_display { |
22 |
|
|
int referenced; |
23 |
|
|
char *name; |
24 |
|
|
|
25 |
|
|
io_manager_vec<xevent_watcher> xw; |
26 |
|
|
io_watcher x_watcher; void x_event (io_watcher &w, short revents); |
27 |
|
|
|
28 |
|
|
//public |
29 |
|
|
Display *display; |
30 |
|
|
int depth; |
31 |
|
|
int screen; |
32 |
|
|
Visual *visual; |
33 |
|
|
Colormap cmap; |
34 |
|
|
Window root; |
35 |
|
|
|
36 |
|
|
bool open (); |
37 |
|
|
void close (); |
38 |
|
|
|
39 |
|
|
void reg (xevent_watcher *w); |
40 |
|
|
void unreg (xevent_watcher *w); |
41 |
|
|
|
42 |
|
|
rxvt_display (const char *name); |
43 |
|
|
~rxvt_display (); |
44 |
|
|
}; |
45 |
|
|
|
46 |
|
|
struct xevent_watcher : watcher, callback1<void, XEvent &> { |
47 |
|
|
Window window; |
48 |
|
|
|
49 |
|
|
template<class O1, class O2> |
50 |
|
|
xevent_watcher (O1 *object, void (O2::*method)(XEvent &)) |
51 |
|
|
: callback1<void, XEvent &>(object,method) |
52 |
|
|
{ } |
53 |
|
|
|
54 |
|
|
void start (rxvt_display *display, Window window) |
55 |
|
|
{ |
56 |
|
|
this->window = window; |
57 |
|
|
display->reg (this); |
58 |
|
|
} |
59 |
|
|
void stop (rxvt_display *display) |
60 |
|
|
{ |
61 |
|
|
display->unreg (this); |
62 |
|
|
} |
63 |
|
|
}; |
64 |
|
|
|
65 |
|
|
struct rxvt_displays { |
66 |
|
|
vector<rxvt_display *> list; |
67 |
|
|
|
68 |
|
|
rxvt_display *get (const char *name); |
69 |
|
|
void release (rxvt_display *display); |
70 |
|
|
}; |
71 |
|
|
|
72 |
|
|
extern rxvt_displays displays; |
73 |
|
|
|
74 |
pcg |
1.1 |
typedef unsigned long Pixel; |
75 |
|
|
|
76 |
|
|
struct rxvt_color { |
77 |
|
|
#if XFT |
78 |
pcg |
1.3 |
XftColor c; |
79 |
|
|
operator Pixel() const { return c.pixel; } |
80 |
pcg |
1.1 |
#else |
81 |
pcg |
1.3 |
Pixel p; |
82 |
|
|
operator Pixel() const { return p; } |
83 |
pcg |
1.1 |
#endif |
84 |
|
|
|
85 |
pcg |
1.3 |
bool operator == (const rxvt_color &b) const { return Pixel(*this) == Pixel(b); } |
86 |
|
|
bool operator != (const rxvt_color &b) const { return Pixel(*this) != Pixel(b); } |
87 |
pcg |
1.1 |
|
88 |
pcg |
1.3 |
void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb); |
89 |
|
|
|
90 |
|
|
bool set (rxvt_display *display, Pixel p); |
91 |
|
|
bool set (rxvt_display *display, const char *name); |
92 |
|
|
bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb); |
93 |
|
|
|
94 |
|
|
void free (rxvt_display *display); |
95 |
pcg |
1.1 |
}; |
96 |
|
|
|
97 |
|
|
#endif |
98 |
|
|
|