… | |
… | |
102 | |
102 | |
103 | ///////////////////////////////////////////////////////////////////////////// |
103 | ///////////////////////////////////////////////////////////////////////////// |
104 | |
104 | |
105 | rxvt_display::rxvt_display (const char *id) |
105 | rxvt_display::rxvt_display (const char *id) |
106 | : refcounted (id) |
106 | : refcounted (id) |
107 | , x_watcher (this, &rxvt_display::x_event) |
107 | , x_ev (this, &rxvt_display::x_cb) |
108 | , selection_owner (0) |
108 | , selection_owner (0) |
109 | { |
109 | { |
110 | } |
110 | } |
111 | |
111 | |
112 | bool rxvt_display::init () |
112 | bool rxvt_display::init () |
… | |
… | |
137 | } |
137 | } |
138 | } |
138 | } |
139 | #endif |
139 | #endif |
140 | |
140 | |
141 | int fd = XConnectionNumber (display); |
141 | int fd = XConnectionNumber (display); |
142 | x_watcher.start (fd, EVENT_READ); |
142 | x_ev.start (fd, EVENT_READ); |
143 | fcntl (fd, F_SETFL, FD_CLOEXEC); |
143 | fcntl (fd, F_SETFL, FD_CLOEXEC); |
144 | |
144 | |
145 | XSelectInput (display, root, PropertyChangeMask); |
145 | XSelectInput (display, root, PropertyChangeMask); |
146 | xa_xim_servers = XInternAtom (display, "XIM_SERVERS", 0); |
146 | xa_xim_servers = XInternAtom (display, "XIM_SERVERS", 0); |
147 | |
147 | |
|
|
148 | flush (); |
|
|
149 | |
148 | return true; |
150 | return true; |
149 | } |
151 | } |
150 | |
152 | |
151 | rxvt_display::~rxvt_display () |
153 | rxvt_display::~rxvt_display () |
152 | { |
154 | { |
153 | x_watcher.stop (); |
155 | x_ev.stop (); |
154 | |
156 | |
155 | XCloseDisplay (display); |
157 | XCloseDisplay (display); |
156 | } |
158 | } |
157 | |
159 | |
158 | void rxvt_display::im_change_cb () |
160 | void rxvt_display::im_change_cb () |
159 | { |
161 | { |
160 | for (im_watcher **i = imw.begin (); i != imw.end (); ++i) |
162 | for (im_watcher **i = imw.begin (); i != imw.end (); ++i) |
161 | (*i)->call (); |
163 | (*i)->call (); |
162 | } |
164 | } |
163 | |
165 | |
164 | void rxvt_display::x_event (io_watcher &w, short revents) |
166 | void rxvt_display::x_cb (io_watcher &w, short revents) |
165 | { |
167 | { |
166 | do |
168 | do |
167 | { |
169 | { |
168 | XEvent xev; |
170 | XEvent xev; |
169 | XNextEvent (display, &xev); |
171 | XNextEvent (display, &xev); |
… | |
… | |
182 | else if (xw[i]->window == xev.xany.window) |
184 | else if (xw[i]->window == xev.xany.window) |
183 | xw[i]->call (xev); |
185 | xw[i]->call (xev); |
184 | } |
186 | } |
185 | } |
187 | } |
186 | while (XPending (display)); |
188 | while (XPending (display)); |
|
|
189 | |
|
|
190 | flush (); |
|
|
191 | } |
|
|
192 | |
|
|
193 | void rxvt_display::flush () |
|
|
194 | { |
|
|
195 | for (;;) |
|
|
196 | { |
|
|
197 | XFlush (display); |
|
|
198 | |
|
|
199 | if (!XPending (display)) |
|
|
200 | break; |
|
|
201 | |
|
|
202 | x_cb (x_ev, 0); |
|
|
203 | } |
187 | } |
204 | } |
188 | |
205 | |
189 | void rxvt_display::reg (xevent_watcher *w) |
206 | void rxvt_display::reg (xevent_watcher *w) |
190 | { |
207 | { |
191 | xw.push_back (w); |
208 | xw.push_back (w); |
… | |
… | |
322 | rxvt_color::free (rxvt_display *display) |
339 | rxvt_color::free (rxvt_display *display) |
323 | { |
340 | { |
324 | #if XFT |
341 | #if XFT |
325 | XftColorFree (display->display, display->visual, display->cmap, &c); |
342 | XftColorFree (display->display, display->visual, display->cmap, &c); |
326 | #else |
343 | #else |
327 | XFreeColors (display->display, display->cmap, &c, 1, AllPlanes); |
344 | XFreeColors (display->display, display->cmap, &p, 1, AllPlanes); |
328 | #endif |
345 | #endif |
329 | } |
346 | } |
330 | |
347 | |