ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.h
Revision: 1.5
Committed: Wed Dec 15 00:53:23 2004 UTC (19 years, 5 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-4_6, rel-4_7
Changes since 1.4: +1 -3 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.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 root 1.2 struct rxvt_display;
22 root 1.1
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 root 1.3 void im_change_check ();
71 root 1.1 #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 root 1.4 operator Display *() const { return display; }
90    
91 root 1.1 void flush ();
92 root 1.5 Atom atom (const char *name);
93 root 1.1 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    
107     #ifdef USE_XIM
108     struct im_watcher : watcher, callback0<void> {
109     template<class O1, class O2>
110     im_watcher (O1 *object, void (O2::*method) ())
111     : callback0<void> (object,method)
112     { }
113    
114     void start (rxvt_display *display)
115     {
116     display->reg (this);
117     }
118     void stop (rxvt_display *display)
119     {
120     display->unreg (this);
121     }
122     };
123     #endif
124    
125     struct xevent_watcher : watcher, callback1<void, XEvent &> {
126     Window window;
127    
128     template<class O1, class O2>
129     xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
130     : callback1<void, XEvent &> (object,method)
131     { }
132    
133     void start (rxvt_display *display, Window window)
134     {
135     this->window = window;
136     display->reg (this);
137     }
138     void stop (rxvt_display *display)
139     {
140     display->unreg (this);
141     }
142     };
143    
144     extern refcache<rxvt_display> displays;
145    
146     /////////////////////////////////////////////////////////////////////////////
147    
148     typedef unsigned long Pixel;
149    
150     struct rxvt_color {
151     #if XFT
152     XftColor c;
153     operator Pixel () const { return c.pixel; }
154     #else
155     Pixel p;
156     operator Pixel () const { return p; }
157     #endif
158    
159     bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
160     bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
161    
162     void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);
163    
164     bool set (rxvt_display *display, Pixel p);
165     bool set (rxvt_display *display, const char *name);
166     bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb);
167    
168     rxvt_color fade (rxvt_display *, int percent);
169    
170     void free (rxvt_display *display);
171     };
172    
173     #endif
174