… | |
… | |
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 | |
17 | struct rxvt_vars; |
17 | struct rxvt_term; |
18 | |
18 | |
|
|
19 | struct im_watcher; |
19 | struct xevent_watcher; |
20 | struct xevent_watcher; |
20 | |
21 | |
21 | struct rxvt_display { |
22 | struct refcounted { |
22 | int referenced; |
23 | int referenced; |
23 | char *name; |
24 | char *id; |
|
|
25 | |
|
|
26 | refcounted (const char *id); |
|
|
27 | bool init () { } |
|
|
28 | ~refcounted (); |
|
|
29 | }; |
|
|
30 | |
|
|
31 | template<class T> |
|
|
32 | struct refcache : vector<T *> { |
|
|
33 | T *get (const char *id); |
|
|
34 | void put (T *obj); |
|
|
35 | ~refcache (); |
|
|
36 | }; |
|
|
37 | |
|
|
38 | ///////////////////////////////////////////////////////////////////////////// |
|
|
39 | |
|
|
40 | struct rxvt_xim : refcounted { |
|
|
41 | void destroy (); |
|
|
42 | rxvt_display *display; |
|
|
43 | |
|
|
44 | //public |
|
|
45 | XIM xim; |
|
|
46 | |
|
|
47 | rxvt_xim (const char *id) : refcounted (id) { } |
|
|
48 | bool init (); |
|
|
49 | ~rxvt_xim (); |
|
|
50 | }; |
|
|
51 | |
|
|
52 | struct rxvt_display : refcounted { |
|
|
53 | Atom xa_xim_servers; |
|
|
54 | |
|
|
55 | rxvt_term *selection_owner; |
24 | |
56 | |
25 | io_manager_vec<xevent_watcher> xw; |
57 | io_manager_vec<xevent_watcher> xw; |
|
|
58 | |
26 | io_watcher x_watcher; void x_event (io_watcher &w, short revents); |
59 | io_watcher x_ev; void x_cb (io_watcher &w, short revents); |
|
|
60 | |
|
|
61 | refcache<rxvt_xim> xims; |
|
|
62 | vector<im_watcher *> imw; |
|
|
63 | |
|
|
64 | void im_change_cb (); |
27 | |
65 | |
28 | //public |
66 | //public |
29 | Display *display; |
67 | Display *display; |
30 | int depth; |
68 | int depth; |
31 | int screen; |
69 | int screen; |
32 | Visual *visual; |
70 | Visual *visual; |
33 | Colormap cmap; |
71 | Colormap cmap; |
34 | Window root; |
72 | Window root; |
35 | |
73 | |
|
|
74 | rxvt_display (const char *id); |
36 | bool open (); |
75 | bool init (); |
|
|
76 | ~rxvt_display (); |
|
|
77 | |
37 | void close (); |
78 | void flush (); |
38 | |
79 | |
39 | void reg (xevent_watcher *w); |
80 | void reg (xevent_watcher *w); |
40 | void unreg (xevent_watcher *w); |
81 | void unreg (xevent_watcher *w); |
|
|
82 | void reg (im_watcher *w); |
|
|
83 | void unreg (im_watcher *w); |
41 | |
84 | |
42 | rxvt_display (const char *name); |
85 | void set_selection_owner (rxvt_term *owner); |
43 | ~rxvt_display (); |
86 | |
|
|
87 | rxvt_xim *get_xim (const char *locale, const char *modifiers); |
|
|
88 | void put_xim (rxvt_xim *xim); |
|
|
89 | }; |
|
|
90 | |
|
|
91 | struct im_watcher : watcher, callback0<void> { |
|
|
92 | template<class O1, class O2> |
|
|
93 | im_watcher (O1 *object, void (O2::*method)()) |
|
|
94 | : callback0<void>(object,method) |
|
|
95 | { } |
|
|
96 | |
|
|
97 | void start (rxvt_display *display) |
|
|
98 | { |
|
|
99 | display->reg (this); |
|
|
100 | } |
|
|
101 | void stop (rxvt_display *display) |
|
|
102 | { |
|
|
103 | display->unreg (this); |
|
|
104 | } |
44 | }; |
105 | }; |
45 | |
106 | |
46 | struct xevent_watcher : watcher, callback1<void, XEvent &> { |
107 | struct xevent_watcher : watcher, callback1<void, XEvent &> { |
47 | Window window; |
108 | Window window; |
48 | |
109 | |
… | |
… | |
60 | { |
121 | { |
61 | display->unreg (this); |
122 | display->unreg (this); |
62 | } |
123 | } |
63 | }; |
124 | }; |
64 | |
125 | |
65 | struct rxvt_displays { |
126 | extern refcache<rxvt_display> displays; |
66 | vector<rxvt_display *> list; |
|
|
67 | |
|
|
68 | rxvt_display *get (const char *name); |
|
|
69 | void release (rxvt_display *display); |
|
|
70 | }; |
|
|
71 | |
127 | |
72 | extern rxvt_displays displays; |
128 | ///////////////////////////////////////////////////////////////////////////// |
73 | |
129 | |
74 | typedef unsigned long Pixel; |
130 | typedef unsigned long Pixel; |
75 | |
131 | |
76 | struct rxvt_color { |
132 | struct rxvt_color { |
77 | #if XFT |
133 | #if XFT |