--- rxvt-unicode/src/rxvtcolor.h 2004/02/10 00:40:39 1.4 +++ rxvt-unicode/src/rxvtcolor.h 2004/02/11 08:13:45 1.5 @@ -16,17 +16,53 @@ struct rxvt_term; +struct im_watcher; struct xevent_watcher; -struct rxvt_display { +struct refcounted { int referenced; - char *name; + char *id; + + refcounted (const char *id); + bool init () { } + ~refcounted (); +}; + +template +struct refcache : vector { + T *get (const char *id); + void put (T *obj); + ~refcache (); +}; + +///////////////////////////////////////////////////////////////////////////// + +struct rxvt_xim : refcounted { + void destroy (); + rxvt_display *display; + +//public + XIM xim; + + rxvt_xim (const char *id) : refcounted (id) { } + bool init (); + ~rxvt_xim (); +}; + +struct rxvt_display : refcounted { + Atom xa_xim_servers; rxvt_term *selection_owner; io_manager_vec xw; + io_watcher x_watcher; void x_event (io_watcher &w, short revents); + refcache xims; + vector imw; + + void im_change_cb (); + //public Display *display; int depth; @@ -35,16 +71,35 @@ Colormap cmap; Window root; - bool open (); - void close (); + rxvt_display (const char *id); + bool init (); + ~rxvt_display (); void reg (xevent_watcher *w); void unreg (xevent_watcher *w); - - rxvt_display (const char *name); - ~rxvt_display (); + void reg (im_watcher *w); + void unreg (im_watcher *w); void set_selection_owner (rxvt_term *owner); + + rxvt_xim *get_xim (const char *locale, const char *modifiers); + void put_xim (rxvt_xim *xim); +}; + +struct im_watcher : watcher, callback0 { + template + im_watcher (O1 *object, void (O2::*method)()) + : callback0(object,method) + { } + + void start (rxvt_display *display) + { + display->reg (this); + } + void stop (rxvt_display *display) + { + display->unreg (this); + } }; struct xevent_watcher : watcher, callback1 { @@ -66,14 +121,9 @@ } }; -struct rxvt_displays { - vector list; - - rxvt_display *get (const char *name); - void release (rxvt_display *display); -}; +extern refcache displays; -extern rxvt_displays displays; +///////////////////////////////////////////////////////////////////////////// typedef unsigned long Pixel;