… | |
… | |
12 | #include "rxvtlib.h" |
12 | #include "rxvtlib.h" |
13 | #include "rxvtstl.h" |
13 | #include "rxvtstl.h" |
14 | |
14 | |
15 | #include "callback.h" |
15 | #include "callback.h" |
16 | |
16 | |
|
|
17 | extern class byteorder { |
|
|
18 | uint32_t e; |
|
|
19 | public: |
|
|
20 | byteorder (); |
|
|
21 | |
|
|
22 | bool big_endian () { return e == 0x11223344; }; |
|
|
23 | bool network () { return e == 0x11223344; }; |
|
|
24 | bool little_endian () { return e == 0x44332211; }; |
|
|
25 | bool vax () { return e == 0x44332211; }; |
|
|
26 | } byteorder; |
|
|
27 | |
17 | struct rxvt_term; |
28 | struct rxvt_term; |
18 | |
29 | |
19 | struct im_watcher; |
30 | struct im_watcher; |
20 | struct xevent_watcher; |
31 | struct xevent_watcher; |
21 | |
32 | |
22 | struct refcounted { |
33 | struct refcounted { |
23 | int referenced; |
34 | int referenced; |
24 | char *id; |
35 | char *id; |
25 | |
36 | |
26 | refcounted (const char *id); |
37 | refcounted (const char *id); |
27 | bool init () { } |
38 | bool init () { return false; } |
28 | ~refcounted (); |
39 | ~refcounted (); |
29 | }; |
40 | }; |
30 | |
41 | |
31 | template<class T> |
42 | template<class T> |
32 | struct refcache : vector<T *> { |
43 | struct refcache : vector<T *> { |
… | |
… | |
50 | }; |
61 | }; |
51 | |
62 | |
52 | struct rxvt_display : refcounted { |
63 | struct rxvt_display : refcounted { |
53 | Atom xa_xim_servers; |
64 | Atom xa_xim_servers; |
54 | |
65 | |
55 | rxvt_term *selection_owner; |
|
|
56 | |
|
|
57 | io_manager_vec<xevent_watcher> xw; |
66 | io_manager_vec<xevent_watcher> xw; |
58 | |
67 | |
59 | io_watcher x_ev; void x_cb (io_watcher &w, short revents); |
68 | io_watcher x_ev; void x_cb (io_watcher &w, short revents); |
60 | |
69 | |
61 | refcache<rxvt_xim> xims; |
70 | refcache<rxvt_xim> xims; |
… | |
… | |
68 | int depth; |
77 | int depth; |
69 | int screen; |
78 | int screen; |
70 | Visual *visual; |
79 | Visual *visual; |
71 | Colormap cmap; |
80 | Colormap cmap; |
72 | Window root; |
81 | Window root; |
|
|
82 | rxvt_term *selection_owner; |
73 | |
83 | |
74 | rxvt_display (const char *id); |
84 | rxvt_display (const char *id); |
75 | bool init (); |
85 | bool init (); |
76 | ~rxvt_display (); |
86 | ~rxvt_display (); |
77 | |
87 | |
… | |
… | |
88 | void put_xim (rxvt_xim *xim); |
98 | void put_xim (rxvt_xim *xim); |
89 | }; |
99 | }; |
90 | |
100 | |
91 | struct im_watcher : watcher, callback0<void> { |
101 | struct im_watcher : watcher, callback0<void> { |
92 | template<class O1, class O2> |
102 | template<class O1, class O2> |
93 | im_watcher (O1 *object, void (O2::*method)()) |
103 | im_watcher (O1 *object, void (O2::*method) ()) |
94 | : callback0<void>(object,method) |
104 | : callback0<void> (object,method) |
95 | { } |
105 | { } |
96 | |
106 | |
97 | void start (rxvt_display *display) |
107 | void start (rxvt_display *display) |
98 | { |
108 | { |
99 | display->reg (this); |
109 | display->reg (this); |
… | |
… | |
106 | |
116 | |
107 | struct xevent_watcher : watcher, callback1<void, XEvent &> { |
117 | struct xevent_watcher : watcher, callback1<void, XEvent &> { |
108 | Window window; |
118 | Window window; |
109 | |
119 | |
110 | template<class O1, class O2> |
120 | template<class O1, class O2> |
111 | xevent_watcher (O1 *object, void (O2::*method)(XEvent &)) |
121 | xevent_watcher (O1 *object, void (O2::*method) (XEvent &)) |
112 | : callback1<void, XEvent &>(object,method) |
122 | : callback1<void, XEvent &> (object,method) |
113 | { } |
123 | { } |
114 | |
124 | |
115 | void start (rxvt_display *display, Window window) |
125 | void start (rxvt_display *display, Window window) |
116 | { |
126 | { |
117 | this->window = window; |
127 | this->window = window; |
… | |
… | |
130 | typedef unsigned long Pixel; |
140 | typedef unsigned long Pixel; |
131 | |
141 | |
132 | struct rxvt_color { |
142 | struct rxvt_color { |
133 | #if XFT |
143 | #if XFT |
134 | XftColor c; |
144 | XftColor c; |
135 | operator Pixel() const { return c.pixel; } |
145 | operator Pixel () const { return c.pixel; } |
136 | #else |
146 | #else |
137 | Pixel p; |
147 | Pixel p; |
138 | operator Pixel() const { return p; } |
148 | operator Pixel () const { return p; } |
139 | #endif |
149 | #endif |
140 | |
150 | |
141 | bool operator == (const rxvt_color &b) const { return Pixel(*this) == Pixel(b); } |
151 | bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); } |
142 | bool operator != (const rxvt_color &b) const { return Pixel(*this) != Pixel(b); } |
152 | bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); } |
143 | |
153 | |
144 | void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb); |
154 | void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb); |
145 | |
155 | |
146 | bool set (rxvt_display *display, Pixel p); |
156 | bool set (rxvt_display *display, Pixel p); |
147 | bool set (rxvt_display *display, const char *name); |
157 | bool set (rxvt_display *display, const char *name); |