ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.h
Revision: 1.7
Committed: Mon Jan 17 00:59:24 2005 UTC (19 years, 4 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-5_5, rel-5_4, rel-5_7, rel-5_1, rel-5_0, rel-5_3, rel-5_2, rel-4_8, rel-4_9
Changes since 1.5: +16 -8 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 void clear ();
40
41 ~refcache ()
42 {
43 clear ();
44 }
45 };
46
47 /////////////////////////////////////////////////////////////////////////////
48
49 #ifdef USE_XIM
50 struct rxvt_xim : refcounted {
51 void destroy ();
52 rxvt_display *display;
53
54 //public
55 XIM xim;
56
57 rxvt_xim (const char *id) : refcounted (id) { }
58 bool init ();
59 ~rxvt_xim ();
60 };
61 #endif
62
63 struct 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 #ifdef USE_XIM
71 refcache<rxvt_xim> xims;
72 vector<im_watcher *> imw;
73
74 void im_change_cb ();
75 void im_change_check ();
76 #endif
77
78 //public
79 Display *display;
80 int depth;
81 int screen;
82 Visual *visual;
83 Colormap cmap;
84 Window root;
85 rxvt_term *selection_owner;
86 #ifndef NO_SLOW_LINK_SUPPORT
87 bool is_local;
88 #endif
89 #ifdef POINTER_BLANK
90 Cursor blank_cursor;
91 #endif
92
93 rxvt_display (const char *id);
94 bool init ();
95 ~rxvt_display ();
96
97 operator Display *() const { return display; }
98
99 void flush ();
100 Atom atom (const char *name);
101 void set_selection_owner (rxvt_term *owner);
102
103 void reg (xevent_watcher *w);
104 void unreg (xevent_watcher *w);
105
106 #ifdef USE_XIM
107 void reg (im_watcher *w);
108 void unreg (im_watcher *w);
109
110 rxvt_xim *get_xim (const char *locale, const char *modifiers);
111 void put_xim (rxvt_xim *xim);
112 #endif
113 };
114
115 #ifdef USE_XIM
116 struct im_watcher : watcher, callback0<void> {
117 template<class O1, class O2>
118 im_watcher (O1 *object, void (O2::*method) ())
119 : callback0<void> (object,method)
120 { }
121
122 void start (rxvt_display *display)
123 {
124 display->reg (this);
125 }
126 void stop (rxvt_display *display)
127 {
128 display->unreg (this);
129 }
130 };
131 #endif
132
133 struct xevent_watcher : watcher, callback1<void, XEvent &> {
134 Window window;
135
136 template<class O1, class O2>
137 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
138 : callback1<void, XEvent &> (object,method)
139 { }
140
141 void start (rxvt_display *display, Window window)
142 {
143 this->window = window;
144 display->reg (this);
145 }
146 void stop (rxvt_display *display)
147 {
148 display->unreg (this);
149 }
150 };
151
152 extern refcache<rxvt_display> displays;
153
154 /////////////////////////////////////////////////////////////////////////////
155
156 typedef unsigned long Pixel;
157
158 struct rxvt_color {
159 #if XFT
160 XftColor c;
161 operator Pixel () const { return c.pixel; }
162 #else
163 Pixel p;
164 operator Pixel () const { return p; }
165 #endif
166
167 bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
168 bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
169
170 void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);
171
172 bool set (rxvt_display *display, Pixel p);
173 bool set (rxvt_display *display, const char *name);
174 bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb);
175
176 rxvt_color fade (rxvt_display *, int percent);
177
178 void free (rxvt_display *display);
179 };
180
181 #endif
182