… | |
… | |
254 | selection_owner = owner; |
254 | selection_owner = owner; |
255 | } |
255 | } |
256 | |
256 | |
257 | rxvt_xim *rxvt_display::get_xim (const char *locale, const char *modifiers) |
257 | rxvt_xim *rxvt_display::get_xim (const char *locale, const char *modifiers) |
258 | { |
258 | { |
259 | // asprintf is a GNU and *BSD extension.. sorry... |
|
|
260 | char *id; |
259 | char *id; |
|
|
260 | int l, m; |
261 | |
261 | |
262 | if (asprintf (&id, "%s\n%s", locale, modifiers) < 0) |
262 | l = strlen (locale); |
|
|
263 | m = strlen (modifiers); |
|
|
264 | |
|
|
265 | if (!(id = (char *)malloc (l + m + 2))) |
263 | return 0; |
266 | return 0; |
264 | |
267 | |
|
|
268 | memcpy (id, locale, l); id[l] = '\n'; |
|
|
269 | memcpy (id + l + 1, modifiers, m); id[l + m + 1] = 0; |
|
|
270 | |
265 | rxvt_xim *xim = xims.get (id); |
271 | rxvt_xim *xim = xims.get (id); |
266 | |
272 | |
267 | free (id); |
273 | free (id); |
268 | |
274 | |
269 | return xim; |
275 | return xim; |
270 | } |
276 | } |
271 | |
277 | |
272 | void rxvt_display::put_xim (rxvt_xim *xim) |
278 | void rxvt_display::put_xim (rxvt_xim *xim) |
273 | { |
279 | { |
274 | xims.put (xim); |
280 | xims.put (xim); |
|
|
281 | } |
|
|
282 | |
|
|
283 | Atom rxvt_display::atom (const char *name) |
|
|
284 | { |
|
|
285 | return XInternAtom (display, name, False); |
275 | } |
286 | } |
276 | |
287 | |
277 | ///////////////////////////////////////////////////////////////////////////// |
288 | ///////////////////////////////////////////////////////////////////////////// |
278 | |
289 | |
279 | template refcache<rxvt_display>; |
290 | template refcache<rxvt_display>; |