… | |
… | |
5 | |
5 | |
6 | #if XFT |
6 | #if XFT |
7 | # include <X11/Xft/Xft.h> |
7 | # include <X11/Xft/Xft.h> |
8 | #endif |
8 | #endif |
9 | |
9 | |
|
|
10 | #include "iom.h" |
|
|
11 | |
10 | #include "rxvtlib.h" |
12 | #include "rxvtlib.h" |
|
|
13 | #include "rxvtstl.h" |
|
|
14 | |
|
|
15 | #include "callback.h" |
11 | |
16 | |
12 | struct rxvt_vars; |
17 | struct rxvt_vars; |
|
|
18 | |
|
|
19 | 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; |
13 | |
73 | |
14 | typedef unsigned long Pixel; |
74 | typedef unsigned long Pixel; |
15 | |
75 | |
16 | struct rxvt_color { |
76 | struct rxvt_color { |
17 | #if XFT |
77 | #if XFT |
18 | XftColor c; |
78 | XftColor c; |
19 | operator Pixel() const { return c.pixel; } |
79 | operator Pixel() const { return c.pixel; } |
20 | #else |
80 | #else |
21 | Pixel p; |
81 | Pixel p; |
22 | operator Pixel() const { return p; } |
82 | operator Pixel() const { return p; } |
23 | #endif |
83 | #endif |
24 | |
84 | |
25 | bool operator == (const rxvt_color &b) const { return Pixel(*this) == Pixel(b); } |
85 | bool operator == (const rxvt_color &b) const { return Pixel(*this) == Pixel(b); } |
26 | 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); } |
27 | |
87 | |
28 | void get (pR_ unsigned short &cr, unsigned short &cg, unsigned short &cb); |
88 | void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb); |
29 | |
89 | |
30 | bool set (pR_ Pixel p); |
90 | bool set (rxvt_display *display, Pixel p); |
31 | bool set (pR_ const char *name); |
91 | bool set (rxvt_display *display, const char *name); |
32 | bool set (pR_ unsigned short cr, unsigned short cg, unsigned short cb); |
92 | bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb); |
|
|
93 | |
|
|
94 | void free (rxvt_display *display); |
33 | }; |
95 | }; |
34 | |
96 | |
35 | #endif |
97 | #endif |
36 | |
98 | |