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