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.1 by pcg, Mon Nov 24 17:28:08 2003 UTC vs.
Revision 1.7 by pcg, Fri Feb 13 12:16:21 2004 UTC

5 5
6#if XFT 6#if XFT
7# include <X11/Xft/Xft.h> 7# include <X11/Xft/Xft.h>
8#endif 8#endif
9 9
10#include "iom.h"
11
10#include "rxvtlib.h" 12#include "rxvtlib.h"
13#include "rxvtstl.h"
11 14
15#include "callback.h"
16
12struct rxvt_vars; 17struct rxvt_term;
18
19struct im_watcher;
20struct xevent_watcher;
21
22struct refcounted {
23 int referenced;
24 char *id;
25
26 refcounted (const char *id);
27 bool init () { }
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
55 rxvt_term *selection_owner;
56
57 io_manager_vec<xevent_watcher> xw;
58
59 io_watcher x_ev; void x_cb (io_watcher &w, short revents);
60
61 refcache<rxvt_xim> xims;
62 vector<im_watcher *> imw;
63
64 void im_change_cb ();
65
66//public
67 Display *display;
68 int depth;
69 int screen;
70 Visual *visual;
71 Colormap cmap;
72 Window root;
73
74 rxvt_display (const char *id);
75 bool init ();
76 ~rxvt_display ();
77
78 void flush ();
79
80 void reg (xevent_watcher *w);
81 void unreg (xevent_watcher *w);
82 void reg (im_watcher *w);
83 void unreg (im_watcher *w);
84
85 void set_selection_owner (rxvt_term *owner);
86
87 rxvt_xim *get_xim (const char *locale, const char *modifiers);
88 void put_xim (rxvt_xim *xim);
89};
90
91struct im_watcher : watcher, callback0<void> {
92 template<class O1, class O2>
93 im_watcher (O1 *object, void (O2::*method) ())
94 : callback0<void> (object,method)
95 { }
96
97 void start (rxvt_display *display)
98 {
99 display->reg (this);
100 }
101 void stop (rxvt_display *display)
102 {
103 display->unreg (this);
104 }
105};
106
107struct xevent_watcher : watcher, callback1<void, XEvent &> {
108 Window window;
109
110 template<class O1, class O2>
111 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
112 : callback1<void, XEvent &> (object,method)
113 { }
114
115 void start (rxvt_display *display, Window window)
116 {
117 this->window = window;
118 display->reg (this);
119 }
120 void stop (rxvt_display *display)
121 {
122 display->unreg (this);
123 }
124};
125
126extern refcache<rxvt_display> displays;
127
128/////////////////////////////////////////////////////////////////////////////
13 129
14typedef unsigned long Pixel; 130typedef unsigned long Pixel;
15 131
16struct rxvt_color { 132struct rxvt_color {
17#if XFT 133#if XFT
18 XftColor c; 134 XftColor c;
19 operator Pixel() const { return c.pixel; } 135 operator Pixel () const { return c.pixel; }
20#else 136#else
21 Pixel p; 137 Pixel p;
22 operator Pixel() const { return p; } 138 operator Pixel () const { return p; }
23#endif 139#endif
24 140
25 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); }
26 bool operator != (const rxvt_color &b) const { return Pixel(*this) != Pixel(b); } 142 bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
27 143
28 void get (pR_ unsigned short &cr, unsigned short &cg, unsigned short &cb); 144 void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);
29 145
30 bool set (pR_ Pixel p); 146 bool set (rxvt_display *display, Pixel p);
31 bool set (pR_ const char *name); 147 bool set (rxvt_display *display, const char *name);
32 bool set (pR_ unsigned short cr, unsigned short cg, unsigned short cb); 148 bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb);
149
150 void free (rxvt_display *display);
33}; 151};
34 152
35#endif 153#endif
36 154

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines