--- rxvt-unicode/src/rxvtcolor.h 2004/02/09 07:11:49 1.3 +++ rxvt-unicode/src/rxvtcolor.h 2004/07/29 14:05:27 1.12 @@ -14,16 +14,67 @@ #include "callback.h" -struct rxvt_vars; +extern class byteorder { + uint32_t e; +public: + byteorder (); + + bool big_endian () { return e == 0x11223344; }; + bool network () { return e == 0x11223344; }; + bool little_endian () { return e == 0x44332211; }; + bool vax () { return e == 0x44332211; }; +} byteorder; +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 () { return false; } + ~refcounted (); +}; + +template +struct refcache : vector { + T *get (const char *id); + void put (T *obj); + ~refcache (); +}; + +///////////////////////////////////////////////////////////////////////////// + +#ifdef USE_XIM +struct rxvt_xim : refcounted { + void destroy (); + rxvt_display *display; + +//public + XIM xim; + + rxvt_xim (const char *id) : refcounted (id) { } + bool init (); + ~rxvt_xim (); +}; +#endif + +struct rxvt_display : refcounted { + Atom xa_xim_servers; + io_manager_vec xw; - io_watcher x_watcher; void x_event (io_watcher &w, short revents); + + io_watcher x_ev; void x_cb (io_watcher &w, short revents); + +#ifdef USE_XIM + refcache xims; + vector imw; + + void im_change_cb (); +#endif //public Display *display; @@ -32,23 +83,54 @@ Visual *visual; Colormap cmap; Window root; + rxvt_term *selection_owner; + + rxvt_display (const char *id); + bool init (); + ~rxvt_display (); - bool open (); - void close (); + void flush (); + + void set_selection_owner (rxvt_term *owner); void reg (xevent_watcher *w); void unreg (xevent_watcher *w); - rxvt_display (const char *name); - ~rxvt_display (); +#ifdef USE_XIM + void reg (im_watcher *w); + void unreg (im_watcher *w); + + rxvt_xim *get_xim (const char *locale, const char *modifiers); + void put_xim (rxvt_xim *xim); +#endif + + Atom atom (const char *name); }; +#ifdef USE_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); + } +}; +#endif + struct xevent_watcher : watcher, callback1 { Window window; template - xevent_watcher (O1 *object, void (O2::*method)(XEvent &)) - : callback1(object,method) + xevent_watcher (O1 *object, void (O2::*method) (XEvent &)) + : callback1 (object,method) { } void start (rxvt_display *display, Window window) @@ -62,28 +144,23 @@ } }; -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; struct rxvt_color { #if XFT XftColor c; - operator Pixel() const { return c.pixel; } + operator Pixel () const { return c.pixel; } #else Pixel p; - operator Pixel() const { return p; } + operator Pixel () const { return p; } #endif - bool operator == (const rxvt_color &b) const { return Pixel(*this) == Pixel(b); } - bool operator != (const rxvt_color &b) const { return Pixel(*this) != Pixel(b); } + bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); } + bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); } void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);