… | |
… | |
22 | struct refcounted { |
22 | struct refcounted { |
23 | int referenced; |
23 | int referenced; |
24 | char *id; |
24 | char *id; |
25 | |
25 | |
26 | refcounted (const char *id); |
26 | refcounted (const char *id); |
27 | bool init () { } |
27 | bool init () { return false; } |
28 | ~refcounted (); |
28 | ~refcounted (); |
29 | }; |
29 | }; |
30 | |
30 | |
31 | template<class T> |
31 | template<class T> |
32 | struct refcache : vector<T *> { |
32 | struct refcache : vector<T *> { |
… | |
… | |
50 | }; |
50 | }; |
51 | |
51 | |
52 | struct rxvt_display : refcounted { |
52 | struct rxvt_display : refcounted { |
53 | Atom xa_xim_servers; |
53 | Atom xa_xim_servers; |
54 | |
54 | |
55 | rxvt_term *selection_owner; |
|
|
56 | |
|
|
57 | io_manager_vec<xevent_watcher> xw; |
55 | io_manager_vec<xevent_watcher> xw; |
58 | |
56 | |
59 | io_watcher x_watcher; void x_event (io_watcher &w, short revents); |
57 | io_watcher x_ev; void x_cb (io_watcher &w, short revents); |
60 | |
58 | |
61 | refcache<rxvt_xim> xims; |
59 | refcache<rxvt_xim> xims; |
62 | vector<im_watcher *> imw; |
60 | vector<im_watcher *> imw; |
63 | |
61 | |
64 | void im_change_cb (); |
62 | void im_change_cb (); |
… | |
… | |
68 | int depth; |
66 | int depth; |
69 | int screen; |
67 | int screen; |
70 | Visual *visual; |
68 | Visual *visual; |
71 | Colormap cmap; |
69 | Colormap cmap; |
72 | Window root; |
70 | Window root; |
|
|
71 | rxvt_term *selection_owner; |
73 | |
72 | |
74 | rxvt_display (const char *id); |
73 | rxvt_display (const char *id); |
75 | bool init (); |
74 | bool init (); |
76 | ~rxvt_display (); |
75 | ~rxvt_display (); |
|
|
76 | |
|
|
77 | void flush (); |
77 | |
78 | |
78 | void reg (xevent_watcher *w); |
79 | void reg (xevent_watcher *w); |
79 | void unreg (xevent_watcher *w); |
80 | void unreg (xevent_watcher *w); |
80 | void reg (im_watcher *w); |
81 | void reg (im_watcher *w); |
81 | void unreg (im_watcher *w); |
82 | void unreg (im_watcher *w); |
… | |
… | |
86 | void put_xim (rxvt_xim *xim); |
87 | void put_xim (rxvt_xim *xim); |
87 | }; |
88 | }; |
88 | |
89 | |
89 | struct im_watcher : watcher, callback0<void> { |
90 | struct im_watcher : watcher, callback0<void> { |
90 | template<class O1, class O2> |
91 | template<class O1, class O2> |
91 | im_watcher (O1 *object, void (O2::*method)()) |
92 | im_watcher (O1 *object, void (O2::*method) ()) |
92 | : callback0<void>(object,method) |
93 | : callback0<void> (object,method) |
93 | { } |
94 | { } |
94 | |
95 | |
95 | void start (rxvt_display *display) |
96 | void start (rxvt_display *display) |
96 | { |
97 | { |
97 | display->reg (this); |
98 | display->reg (this); |
… | |
… | |
104 | |
105 | |
105 | struct xevent_watcher : watcher, callback1<void, XEvent &> { |
106 | struct xevent_watcher : watcher, callback1<void, XEvent &> { |
106 | Window window; |
107 | Window window; |
107 | |
108 | |
108 | template<class O1, class O2> |
109 | template<class O1, class O2> |
109 | xevent_watcher (O1 *object, void (O2::*method)(XEvent &)) |
110 | xevent_watcher (O1 *object, void (O2::*method) (XEvent &)) |
110 | : callback1<void, XEvent &>(object,method) |
111 | : callback1<void, XEvent &> (object,method) |
111 | { } |
112 | { } |
112 | |
113 | |
113 | void start (rxvt_display *display, Window window) |
114 | void start (rxvt_display *display, Window window) |
114 | { |
115 | { |
115 | this->window = window; |
116 | this->window = window; |
… | |
… | |
128 | typedef unsigned long Pixel; |
129 | typedef unsigned long Pixel; |
129 | |
130 | |
130 | struct rxvt_color { |
131 | struct rxvt_color { |
131 | #if XFT |
132 | #if XFT |
132 | XftColor c; |
133 | XftColor c; |
133 | operator Pixel() const { return c.pixel; } |
134 | operator Pixel () const { return c.pixel; } |
134 | #else |
135 | #else |
135 | Pixel p; |
136 | Pixel p; |
136 | operator Pixel() const { return p; } |
137 | operator Pixel () const { return p; } |
137 | #endif |
138 | #endif |
138 | |
139 | |
139 | 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); } |
140 | bool operator != (const rxvt_color &b) const { return Pixel(*this) != Pixel(b); } |
141 | bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); } |
141 | |
142 | |
142 | void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb); |
143 | void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb); |
143 | |
144 | |
144 | bool set (rxvt_display *display, Pixel p); |
145 | bool set (rxvt_display *display, Pixel p); |
145 | bool set (rxvt_display *display, const char *name); |
146 | bool set (rxvt_display *display, const char *name); |