ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.h
Revision: 1.2
Committed: Wed Aug 25 02:33:09 2004 UTC (19 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-3_8
Changes since 1.1: +1 -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 #endif
71
72 //public
73 Display *display;
74 int depth;
75 int screen;
76 Visual *visual;
77 Colormap cmap;
78 Window root;
79 rxvt_term *selection_owner;
80 #ifndef NO_SLOW_LINK_SUPPORT
81 bool is_local;
82 #endif
83
84 rxvt_display (const char *id);
85 bool init ();
86 ~rxvt_display ();
87
88 void flush ();
89
90 void set_selection_owner (rxvt_term *owner);
91
92 void reg (xevent_watcher *w);
93 void unreg (xevent_watcher *w);
94
95 #ifdef USE_XIM
96 void reg (im_watcher *w);
97 void unreg (im_watcher *w);
98
99 rxvt_xim *get_xim (const char *locale, const char *modifiers);
100 void put_xim (rxvt_xim *xim);
101 #endif
102
103 Atom atom (const char *name);
104 };
105
106 #ifdef USE_XIM
107 struct im_watcher : watcher, callback0<void> {
108 template<class O1, class O2>
109 im_watcher (O1 *object, void (O2::*method) ())
110 : callback0<void> (object,method)
111 { }
112
113 void start (rxvt_display *display)
114 {
115 display->reg (this);
116 }
117 void stop (rxvt_display *display)
118 {
119 display->unreg (this);
120 }
121 };
122 #endif
123
124 struct xevent_watcher : watcher, callback1<void, XEvent &> {
125 Window window;
126
127 template<class O1, class O2>
128 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
129 : callback1<void, XEvent &> (object,method)
130 { }
131
132 void start (rxvt_display *display, Window window)
133 {
134 this->window = window;
135 display->reg (this);
136 }
137 void stop (rxvt_display *display)
138 {
139 display->unreg (this);
140 }
141 };
142
143 extern refcache<rxvt_display> displays;
144
145 /////////////////////////////////////////////////////////////////////////////
146
147 typedef unsigned long Pixel;
148
149 struct rxvt_color {
150 #if XFT
151 XftColor c;
152 operator Pixel () const { return c.pixel; }
153 #else
154 Pixel p;
155 operator Pixel () const { return p; }
156 #endif
157
158 bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
159 bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
160
161 void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);
162
163 bool set (rxvt_display *display, Pixel p);
164 bool set (rxvt_display *display, const char *name);
165 bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb);
166
167 rxvt_color fade (rxvt_display *, int percent);
168
169 void free (rxvt_display *display);
170 };
171
172 #endif
173