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.4 by pcg, Tue Feb 10 00:40:39 2004 UTC vs.
Revision 1.14 by root, Wed Aug 4 03:29:28 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
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
17struct rxvt_term; 28struct rxvt_term;
18 29
30struct im_watcher;
19struct xevent_watcher; 31struct xevent_watcher;
20 32
21struct rxvt_display { 33struct refcounted {
22 int referenced; 34 int referenced;
23 char *name; 35 char *id;
24 36
25 rxvt_term *selection_owner; 37 refcounted (const char *id);
26 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
51#ifdef USE_XIM
52struct rxvt_xim : refcounted {
53 void destroy ();
54 rxvt_display *display;
55
56//public
57 XIM xim;
58
59 rxvt_xim (const char *id) : refcounted (id) { }
60 bool init ();
61 ~rxvt_xim ();
62};
63#endif
64
65struct rxvt_display : refcounted {
66 Atom xa_xim_servers;
67
27 io_manager_vec<xevent_watcher> xw; 68 io_manager_vec<xevent_watcher> xw;
69
28 io_watcher x_watcher; void x_event (io_watcher &w, short revents); 70 io_watcher x_ev; void x_cb (io_watcher &w, short revents);
71
72#ifdef USE_XIM
73 refcache<rxvt_xim> xims;
74 vector<im_watcher *> imw;
75
76 void im_change_cb ();
77#endif
29 78
30//public 79//public
31 Display *display; 80 Display *display;
32 int depth; 81 int depth;
33 int screen; 82 int screen;
34 Visual *visual; 83 Visual *visual;
35 Colormap cmap; 84 Colormap cmap;
36 Window root; 85 Window root;
86 rxvt_term *selection_owner;
87#ifndef NO_SLOW_LINK_SUPPORT
88 bool is_local;
89#endif
37 90
91 rxvt_display (const char *id);
38 bool open (); 92 bool init ();
93 ~rxvt_display ();
94
39 void close (); 95 void flush ();
96
97 void set_selection_owner (rxvt_term *owner);
40 98
41 void reg (xevent_watcher *w); 99 void reg (xevent_watcher *w);
42 void unreg (xevent_watcher *w); 100 void unreg (xevent_watcher *w);
43 101
44 rxvt_display (const char *name); 102#ifdef USE_XIM
45 ~rxvt_display (); 103 void reg (im_watcher *w);
104 void unreg (im_watcher *w);
46 105
47 void set_selection_owner (rxvt_term *owner); 106 rxvt_xim *get_xim (const char *locale, const char *modifiers);
107 void put_xim (rxvt_xim *xim);
108#endif
109
110 Atom atom (const char *name);
48}; 111};
112
113#ifdef USE_XIM
114struct im_watcher : watcher, callback0<void> {
115 template<class O1, class O2>
116 im_watcher (O1 *object, void (O2::*method) ())
117 : callback0<void> (object,method)
118 { }
119
120 void start (rxvt_display *display)
121 {
122 display->reg (this);
123 }
124 void stop (rxvt_display *display)
125 {
126 display->unreg (this);
127 }
128};
129#endif
49 130
50struct xevent_watcher : watcher, callback1<void, XEvent &> { 131struct xevent_watcher : watcher, callback1<void, XEvent &> {
51 Window window; 132 Window window;
52 133
53 template<class O1, class O2> 134 template<class O1, class O2>
54 xevent_watcher (O1 *object, void (O2::*method)(XEvent &)) 135 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
55 : callback1<void, XEvent &>(object,method) 136 : callback1<void, XEvent &> (object,method)
56 { } 137 { }
57 138
58 void start (rxvt_display *display, Window window) 139 void start (rxvt_display *display, Window window)
59 { 140 {
60 this->window = window; 141 this->window = window;
64 { 145 {
65 display->unreg (this); 146 display->unreg (this);
66 } 147 }
67}; 148};
68 149
69struct rxvt_displays { 150extern refcache<rxvt_display> displays;
70 vector<rxvt_display *> list;
71
72 rxvt_display *get (const char *name);
73 void release (rxvt_display *display);
74};
75 151
76extern rxvt_displays displays; 152/////////////////////////////////////////////////////////////////////////////
77 153
78typedef unsigned long Pixel; 154typedef unsigned long Pixel;
79 155
80struct rxvt_color { 156struct rxvt_color {
81#if XFT 157#if XFT
82 XftColor c; 158 XftColor c;
83 operator Pixel() const { return c.pixel; } 159 operator Pixel () const { return c.pixel; }
84#else 160#else
85 Pixel p; 161 Pixel p;
86 operator Pixel() const { return p; } 162 operator Pixel () const { return p; }
87#endif 163#endif
88 164
89 bool operator == (const rxvt_color &b) const { return Pixel(*this) == Pixel(b); } 165 bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
90 bool operator != (const rxvt_color &b) const { return Pixel(*this) != Pixel(b); } 166 bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
91 167
92 void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb); 168 void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);
93 169
94 bool set (rxvt_display *display, Pixel p); 170 bool set (rxvt_display *display, Pixel p);
95 bool set (rxvt_display *display, const char *name); 171 bool set (rxvt_display *display, const char *name);
96 bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb); 172 bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb);
97 173
174 rxvt_color fade (rxvt_display *, int percent);
175
98 void free (rxvt_display *display); 176 void free (rxvt_display *display);
99}; 177};
100 178
101#endif 179#endif
102 180

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines