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.2 by pcg, Sat Jan 31 00:20:21 2004 UTC vs.
Revision 1.10 by pcg, Mon Mar 29 21:02:11 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
17extern class byteorder {
18 uint32_t e;
19public:
20 byteorder ();
21
22 bool big_endian () { return e == 0x11223344; };
23 bool network () { return e == 0x11223344; };
24 bool little_endian () { return e == 0x44332211; };
25 bool vax () { return e == 0x44332211; };
26} byteorder;
27
12struct rxvt_vars; 28struct rxvt_term;
29
30struct im_watcher;
31struct xevent_watcher;
32
33struct refcounted {
34 int referenced;
35 char *id;
36
37 refcounted (const char *id);
38 bool init () { return false; }
39 ~refcounted ();
40};
41
42template<class T>
43struct refcache : vector<T *> {
44 T *get (const char *id);
45 void put (T *obj);
46 ~refcache ();
47};
48
49/////////////////////////////////////////////////////////////////////////////
50
51struct rxvt_xim : refcounted {
52 void destroy ();
53 rxvt_display *display;
54
55//public
56 XIM xim;
57
58 rxvt_xim (const char *id) : refcounted (id) { }
59 bool init ();
60 ~rxvt_xim ();
61};
62
63struct rxvt_display : refcounted {
64 Atom xa_xim_servers;
65
66 io_manager_vec<xevent_watcher> xw;
67
68 io_watcher x_ev; void x_cb (io_watcher &w, short revents);
69
70 refcache<rxvt_xim> xims;
71 vector<im_watcher *> imw;
72
73 void im_change_cb ();
74
75//public
76 Display *display;
77 int depth;
78 int screen;
79 Visual *visual;
80 Colormap cmap;
81 Window root;
82 rxvt_term *selection_owner;
83
84 rxvt_display (const char *id);
85 bool init ();
86 ~rxvt_display ();
87
88 void flush ();
89
90 void reg (xevent_watcher *w);
91 void unreg (xevent_watcher *w);
92 void reg (im_watcher *w);
93 void unreg (im_watcher *w);
94
95 void set_selection_owner (rxvt_term *owner);
96
97 rxvt_xim *get_xim (const char *locale, const char *modifiers);
98 void put_xim (rxvt_xim *xim);
99};
100
101struct im_watcher : watcher, callback0<void> {
102 template<class O1, class O2>
103 im_watcher (O1 *object, void (O2::*method) ())
104 : callback0<void> (object,method)
105 { }
106
107 void start (rxvt_display *display)
108 {
109 display->reg (this);
110 }
111 void stop (rxvt_display *display)
112 {
113 display->unreg (this);
114 }
115};
116
117struct xevent_watcher : watcher, callback1<void, XEvent &> {
118 Window window;
119
120 template<class O1, class O2>
121 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
122 : callback1<void, XEvent &> (object,method)
123 { }
124
125 void start (rxvt_display *display, Window window)
126 {
127 this->window = window;
128 display->reg (this);
129 }
130 void stop (rxvt_display *display)
131 {
132 display->unreg (this);
133 }
134};
135
136extern refcache<rxvt_display> displays;
137
138/////////////////////////////////////////////////////////////////////////////
13 139
14typedef unsigned long Pixel; 140typedef unsigned long Pixel;
15 141
16struct rxvt_color { 142struct rxvt_color {
17#if XFT 143#if XFT
18 XftColor c; 144 XftColor c;
19 operator Pixel() const { return c.pixel; } 145 operator Pixel () const { return c.pixel; }
20#else 146#else
21 Pixel p; 147 Pixel p;
22 operator Pixel() const { return p; } 148 operator Pixel () const { return p; }
23#endif 149#endif
24 150
25 bool operator == (const rxvt_color &b) const { return Pixel(*this) == Pixel(b); } 151 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); } 152 bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
27 153
28 void get (rxvt_term *t, unsigned short &cr, unsigned short &cg, unsigned short &cb); 154 void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);
29 155
30 bool set (rxvt_term *t, Pixel p); 156 bool set (rxvt_display *display, Pixel p);
31 bool set (rxvt_term *t, const char *name); 157 bool set (rxvt_display *display, const char *name);
32 bool set (rxvt_term *t, unsigned short cr, unsigned short cg, unsigned short cb); 158 bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb);
159
160 void free (rxvt_display *display);
33}; 161};
34 162
35#endif 163#endif
36 164

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines