ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.h
Revision: 1.4
Committed: Sat Dec 11 23:01:36 2004 UTC (19 years, 5 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-4_4
Changes since 1.3: +2 -0 lines
Log Message:
*** empty log message ***

File Contents

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