… | |
… | |
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_watcher; void x_event (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; |
62 | vector<im_watcher *> imw; |
71 | vector<im_watcher *> imw; |
63 | |
72 | |
64 | void im_change_cb (); |
73 | void im_change_cb (); |
… | |
… | |
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 (); |
|
|
87 | |
|
|
88 | void flush (); |
77 | |
89 | |
78 | void reg (xevent_watcher *w); |
90 | void reg (xevent_watcher *w); |
79 | void unreg (xevent_watcher *w); |
91 | void unreg (xevent_watcher *w); |
80 | void reg (im_watcher *w); |
92 | void reg (im_watcher *w); |
81 | void unreg (im_watcher *w); |
93 | void unreg (im_watcher *w); |
… | |
… | |
86 | void put_xim (rxvt_xim *xim); |
98 | void put_xim (rxvt_xim *xim); |
87 | }; |
99 | }; |
88 | |
100 | |
89 | struct im_watcher : watcher, callback0<void> { |
101 | struct im_watcher : watcher, callback0<void> { |
90 | template<class O1, class O2> |
102 | template<class O1, class O2> |
91 | im_watcher (O1 *object, void (O2::*method)()) |
103 | im_watcher (O1 *object, void (O2::*method) ()) |
92 | : callback0<void>(object,method) |
104 | : callback0<void> (object,method) |
93 | { } |
105 | { } |
94 | |
106 | |
95 | void start (rxvt_display *display) |
107 | void start (rxvt_display *display) |
96 | { |
108 | { |
97 | display->reg (this); |
109 | display->reg (this); |
… | |
… | |
104 | |
116 | |
105 | struct xevent_watcher : watcher, callback1<void, XEvent &> { |
117 | struct xevent_watcher : watcher, callback1<void, XEvent &> { |
106 | Window window; |
118 | Window window; |
107 | |
119 | |
108 | template<class O1, class O2> |
120 | template<class O1, class O2> |
109 | xevent_watcher (O1 *object, void (O2::*method)(XEvent &)) |
121 | xevent_watcher (O1 *object, void (O2::*method) (XEvent &)) |
110 | : callback1<void, XEvent &>(object,method) |
122 | : callback1<void, XEvent &> (object,method) |
111 | { } |
123 | { } |
112 | |
124 | |
113 | void start (rxvt_display *display, Window window) |
125 | void start (rxvt_display *display, Window window) |
114 | { |
126 | { |
115 | this->window = window; |
127 | this->window = window; |
… | |
… | |
128 | typedef unsigned long Pixel; |
140 | typedef unsigned long Pixel; |
129 | |
141 | |
130 | struct rxvt_color { |
142 | struct rxvt_color { |
131 | #if XFT |
143 | #if XFT |
132 | XftColor c; |
144 | XftColor c; |
133 | operator Pixel() const { return c.pixel; } |
145 | operator Pixel () const { return c.pixel; } |
134 | #else |
146 | #else |
135 | Pixel p; |
147 | Pixel p; |
136 | operator Pixel() const { return p; } |
148 | operator Pixel () const { return p; } |
137 | #endif |
149 | #endif |
138 | |
150 | |
139 | 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); } |
140 | 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); } |
141 | |
153 | |
142 | 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); |
143 | |
155 | |
144 | bool set (rxvt_display *display, Pixel p); |
156 | bool set (rxvt_display *display, Pixel p); |
145 | bool set (rxvt_display *display, const char *name); |
157 | bool set (rxvt_display *display, const char *name); |