ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtcolor.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtcolor.C (file contents):
Revision 1.6 by pcg, Wed Feb 11 08:13:45 2004 UTC vs.
Revision 1.9 by pcg, Sun Mar 14 17:33:08 2004 UTC

102 102
103///////////////////////////////////////////////////////////////////////////// 103/////////////////////////////////////////////////////////////////////////////
104 104
105rxvt_display::rxvt_display (const char *id) 105rxvt_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
112bool rxvt_display::init () 112bool rxvt_display::init ()
113{ 113{
114 display = XOpenDisplay (id); 114 display = XOpenDisplay (id);
115
116 if (!display)
117 return false;
115 118
116 screen = DefaultScreen (display); 119 screen = DefaultScreen (display);
117 root = DefaultRootWindow (display); 120 root = DefaultRootWindow (display);
118 visual = DefaultVisual (display, screen); 121 visual = DefaultVisual (display, screen);
119 cmap = DefaultColormap (display, screen); 122 cmap = DefaultColormap (display, screen);
137 } 140 }
138 } 141 }
139#endif 142#endif
140 143
141 int fd = XConnectionNumber (display); 144 int fd = XConnectionNumber (display);
142 x_watcher.start (fd, EVENT_READ); 145 x_ev.start (fd, EVENT_READ);
143 fcntl (fd, F_SETFL, FD_CLOEXEC); 146 fcntl (fd, F_SETFL, FD_CLOEXEC);
144 147
145 XSelectInput (display, root, PropertyChangeMask); 148 XSelectInput (display, root, PropertyChangeMask);
146 xa_xim_servers = XInternAtom (display, "XIM_SERVERS", 0); 149 xa_xim_servers = XInternAtom (display, "XIM_SERVERS", 0);
147 150
151 flush ();
152
148 return true; 153 return true;
149} 154}
150 155
151rxvt_display::~rxvt_display () 156rxvt_display::~rxvt_display ()
152{ 157{
153 x_watcher.stop (); 158 x_ev.stop ();
154 159
160 if (display)
155 XCloseDisplay (display); 161 XCloseDisplay (display);
156} 162}
157 163
158void rxvt_display::im_change_cb () 164void rxvt_display::im_change_cb ()
159{ 165{
160 for (im_watcher **i = imw.begin (); i != imw.end (); ++i) 166 for (im_watcher **i = imw.begin (); i != imw.end (); ++i)
161 (*i)->call (); 167 (*i)->call ();
162} 168}
163 169
164void rxvt_display::x_event (io_watcher &w, short revents) 170void rxvt_display::x_cb (io_watcher &w, short revents)
165{ 171{
166 do 172 do
167 { 173 {
168 XEvent xev; 174 XEvent xev;
169 XNextEvent (display, &xev); 175 XNextEvent (display, &xev);
182 else if (xw[i]->window == xev.xany.window) 188 else if (xw[i]->window == xev.xany.window)
183 xw[i]->call (xev); 189 xw[i]->call (xev);
184 } 190 }
185 } 191 }
186 while (XPending (display)); 192 while (XPending (display));
193
194 flush ();
195}
196
197void rxvt_display::flush ()
198{
199 for (;;)
200 {
201 XFlush (display);
202
203 if (!XPending (display))
204 break;
205
206 x_cb (x_ev, 0);
207 }
187} 208}
188 209
189void rxvt_display::reg (xevent_watcher *w) 210void rxvt_display::reg (xevent_watcher *w)
190{ 211{
191 xw.push_back (w); 212 xw.push_back (w);
322rxvt_color::free (rxvt_display *display) 343rxvt_color::free (rxvt_display *display)
323{ 344{
324#if XFT 345#if XFT
325 XftColorFree (display->display, display->visual, display->cmap, &c); 346 XftColorFree (display->display, display->visual, display->cmap, &c);
326#else 347#else
327 XFreeColors (display->display, display->cmap, &c, 1, AllPlanes); 348 XFreeColors (display->display, display->cmap, &p, 1, AllPlanes);
328#endif 349#endif
329} 350}
330 351

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines