|
|
1 | /*--------------------------------*-C-*---------------------------------* |
|
|
2 | * File: rxvtcolor.C |
|
|
3 | *----------------------------------------------------------------------* |
|
|
4 | * |
|
|
5 | * All portions of code are copyright by their respective author/s. |
|
|
6 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
|
|
7 | * |
|
|
8 | * This program is free software; you can redistribute it and/or modify |
|
|
9 | * it under the terms of the GNU General Public License as published by |
|
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
|
11 | * (at your option) any later version. |
|
|
12 | * |
|
|
13 | * This program is distributed in the hope that it will be useful, |
|
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
16 | * GNU General Public License for more details. |
|
|
17 | * |
|
|
18 | * You should have received a copy of the GNU General Public License |
|
|
19 | * along with this program; if not, write to the Free Software |
|
|
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
|
21 | *----------------------------------------------------------------------*/ |
|
|
22 | |
1 | #include "../config.h" |
23 | #include "../config.h" |
2 | #include <rxvt.h> |
24 | #include <rxvt.h> |
3 | #include <rxvtcolor.h> |
25 | #include <rxvtcolor.h> |
4 | |
26 | |
5 | #include <unistd.h> |
27 | #include <unistd.h> |
… | |
… | |
158 | } |
180 | } |
159 | #endif |
181 | #endif |
160 | |
182 | |
161 | int fd = XConnectionNumber (display); |
183 | int fd = XConnectionNumber (display); |
162 | x_ev.start (fd, EVENT_READ); |
184 | x_ev.start (fd, EVENT_READ); |
163 | fcntl (fd, F_SETFL, FD_CLOEXEC); |
185 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
164 | |
186 | |
165 | XSelectInput (display, root, PropertyChangeMask); |
187 | XSelectInput (display, root, PropertyChangeMask); |
166 | xa_xim_servers = XInternAtom (display, "XIM_SERVERS", 0); |
188 | xa_xim_servers = XInternAtom (display, "XIM_SERVERS", 0); |
167 | |
189 | |
168 | flush (); |
190 | flush (); |
… | |
… | |
254 | selection_owner = owner; |
276 | selection_owner = owner; |
255 | } |
277 | } |
256 | |
278 | |
257 | rxvt_xim *rxvt_display::get_xim (const char *locale, const char *modifiers) |
279 | rxvt_xim *rxvt_display::get_xim (const char *locale, const char *modifiers) |
258 | { |
280 | { |
259 | // asprintf is a GNU and *BSD extension.. sorry... |
|
|
260 | char *id; |
281 | char *id; |
|
|
282 | int l, m; |
261 | |
283 | |
262 | if (asprintf (&id, "%s\n%s", locale, modifiers) < 0) |
284 | l = strlen (locale); |
|
|
285 | m = strlen (modifiers); |
|
|
286 | |
|
|
287 | if (!(id = (char *)malloc (l + m + 2))) |
263 | return 0; |
288 | return 0; |
264 | |
289 | |
|
|
290 | memcpy (id, locale, l); id[l] = '\n'; |
|
|
291 | memcpy (id + l + 1, modifiers, m); id[l + m + 1] = 0; |
|
|
292 | |
265 | rxvt_xim *xim = xims.get (id); |
293 | rxvt_xim *xim = xims.get (id); |
266 | |
294 | |
267 | free (id); |
295 | free (id); |
268 | |
296 | |
269 | return xim; |
297 | return xim; |
270 | } |
298 | } |
271 | |
299 | |
272 | void rxvt_display::put_xim (rxvt_xim *xim) |
300 | void rxvt_display::put_xim (rxvt_xim *xim) |
273 | { |
301 | { |
274 | xims.put (xim); |
302 | xims.put (xim); |
|
|
303 | } |
|
|
304 | |
|
|
305 | Atom rxvt_display::atom (const char *name) |
|
|
306 | { |
|
|
307 | return XInternAtom (display, name, False); |
275 | } |
308 | } |
276 | |
309 | |
277 | ///////////////////////////////////////////////////////////////////////////// |
310 | ///////////////////////////////////////////////////////////////////////////// |
278 | |
311 | |
279 | template refcache<rxvt_display>; |
312 | template refcache<rxvt_display>; |