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

Comparing rxvt-unicode/src/rxvtcolor.h (file contents):
Revision 1.3 by pcg, Mon Feb 9 07:11:49 2004 UTC vs.
Revision 1.9 by pcg, Wed Feb 25 15:06:05 2004 UTC

12#include "rxvtlib.h" 12#include "rxvtlib.h"
13#include "rxvtstl.h" 13#include "rxvtstl.h"
14 14
15#include "callback.h" 15#include "callback.h"
16 16
17struct rxvt_vars; 17struct rxvt_term;
18 18
19struct im_watcher;
19struct xevent_watcher; 20struct xevent_watcher;
20 21
21struct rxvt_display { 22struct refcounted {
22 int referenced; 23 int referenced;
23 char *name; 24 char *id;
24 25
26 refcounted (const char *id);
27 bool init () { return false; }
28 ~refcounted ();
29};
30
31template<class T>
32struct refcache : vector<T *> {
33 T *get (const char *id);
34 void put (T *obj);
35 ~refcache ();
36};
37
38/////////////////////////////////////////////////////////////////////////////
39
40struct rxvt_xim : refcounted {
41 void destroy ();
42 rxvt_display *display;
43
44//public
45 XIM xim;
46
47 rxvt_xim (const char *id) : refcounted (id) { }
48 bool init ();
49 ~rxvt_xim ();
50};
51
52struct rxvt_display : refcounted {
53 Atom xa_xim_servers;
54
25 io_manager_vec<xevent_watcher> xw; 55 io_manager_vec<xevent_watcher> xw;
56
26 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);
58
59 refcache<rxvt_xim> xims;
60 vector<im_watcher *> imw;
61
62 void im_change_cb ();
27 63
28//public 64//public
29 Display *display; 65 Display *display;
30 int depth; 66 int depth;
31 int screen; 67 int screen;
32 Visual *visual; 68 Visual *visual;
33 Colormap cmap; 69 Colormap cmap;
34 Window root; 70 Window root;
71 rxvt_term *selection_owner;
35 72
73 rxvt_display (const char *id);
36 bool open (); 74 bool init ();
75 ~rxvt_display ();
76
37 void close (); 77 void flush ();
38 78
39 void reg (xevent_watcher *w); 79 void reg (xevent_watcher *w);
40 void unreg (xevent_watcher *w); 80 void unreg (xevent_watcher *w);
81 void reg (im_watcher *w);
82 void unreg (im_watcher *w);
41 83
42 rxvt_display (const char *name); 84 void set_selection_owner (rxvt_term *owner);
43 ~rxvt_display (); 85
86 rxvt_xim *get_xim (const char *locale, const char *modifiers);
87 void put_xim (rxvt_xim *xim);
88};
89
90struct im_watcher : watcher, callback0<void> {
91 template<class O1, class O2>
92 im_watcher (O1 *object, void (O2::*method) ())
93 : callback0<void> (object,method)
94 { }
95
96 void start (rxvt_display *display)
97 {
98 display->reg (this);
99 }
100 void stop (rxvt_display *display)
101 {
102 display->unreg (this);
103 }
44}; 104};
45 105
46struct xevent_watcher : watcher, callback1<void, XEvent &> { 106struct xevent_watcher : watcher, callback1<void, XEvent &> {
47 Window window; 107 Window window;
48 108
49 template<class O1, class O2> 109 template<class O1, class O2>
50 xevent_watcher (O1 *object, void (O2::*method)(XEvent &)) 110 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
51 : callback1<void, XEvent &>(object,method) 111 : callback1<void, XEvent &> (object,method)
52 { } 112 { }
53 113
54 void start (rxvt_display *display, Window window) 114 void start (rxvt_display *display, Window window)
55 { 115 {
56 this->window = window; 116 this->window = window;
60 { 120 {
61 display->unreg (this); 121 display->unreg (this);
62 } 122 }
63}; 123};
64 124
65struct rxvt_displays { 125extern refcache<rxvt_display> displays;
66 vector<rxvt_display *> list;
67
68 rxvt_display *get (const char *name);
69 void release (rxvt_display *display);
70};
71 126
72extern rxvt_displays displays; 127/////////////////////////////////////////////////////////////////////////////
73 128
74typedef unsigned long Pixel; 129typedef unsigned long Pixel;
75 130
76struct rxvt_color { 131struct rxvt_color {
77#if XFT 132#if XFT
78 XftColor c; 133 XftColor c;
79 operator Pixel() const { return c.pixel; } 134 operator Pixel () const { return c.pixel; }
80#else 135#else
81 Pixel p; 136 Pixel p;
82 operator Pixel() const { return p; } 137 operator Pixel () const { return p; }
83#endif 138#endif
84 139
85 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); }
86 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); }
87 142
88 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);
89 144
90 bool set (rxvt_display *display, Pixel p); 145 bool set (rxvt_display *display, Pixel p);
91 bool set (rxvt_display *display, const char *name); 146 bool set (rxvt_display *display, const char *name);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines