1*2b949d04SAndroid Build Coastguard Worker /* 2*2b949d04SAndroid Build Coastguard Worker * Copyright © 2013 Ran Benita 3*2b949d04SAndroid Build Coastguard Worker * 4*2b949d04SAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining a 5*2b949d04SAndroid Build Coastguard Worker * copy of this software and associated documentation files (the "Software"), 6*2b949d04SAndroid Build Coastguard Worker * to deal in the Software without restriction, including without limitation 7*2b949d04SAndroid Build Coastguard Worker * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8*2b949d04SAndroid Build Coastguard Worker * and/or sell copies of the Software, and to permit persons to whom the 9*2b949d04SAndroid Build Coastguard Worker * Software is furnished to do so, subject to the following conditions: 10*2b949d04SAndroid Build Coastguard Worker * 11*2b949d04SAndroid Build Coastguard Worker * The above copyright notice and this permission notice (including the next 12*2b949d04SAndroid Build Coastguard Worker * paragraph) shall be included in all copies or substantial portions of the 13*2b949d04SAndroid Build Coastguard Worker * Software. 14*2b949d04SAndroid Build Coastguard Worker * 15*2b949d04SAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16*2b949d04SAndroid Build Coastguard Worker * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17*2b949d04SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18*2b949d04SAndroid Build Coastguard Worker * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19*2b949d04SAndroid Build Coastguard Worker * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20*2b949d04SAndroid Build Coastguard Worker * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21*2b949d04SAndroid Build Coastguard Worker * DEALINGS IN THE SOFTWARE. 22*2b949d04SAndroid Build Coastguard Worker */ 23*2b949d04SAndroid Build Coastguard Worker 24*2b949d04SAndroid Build Coastguard Worker #ifndef _XKBCOMMON_X11_PRIV_H 25*2b949d04SAndroid Build Coastguard Worker #define _XKBCOMMON_X11_PRIV_H 26*2b949d04SAndroid Build Coastguard Worker 27*2b949d04SAndroid Build Coastguard Worker #include <xcb/xkb.h> 28*2b949d04SAndroid Build Coastguard Worker 29*2b949d04SAndroid Build Coastguard Worker #include "keymap.h" 30*2b949d04SAndroid Build Coastguard Worker #include "xkbcommon/xkbcommon-x11.h" 31*2b949d04SAndroid Build Coastguard Worker 32*2b949d04SAndroid Build Coastguard Worker struct x11_atom_interner { 33*2b949d04SAndroid Build Coastguard Worker struct xkb_context *ctx; 34*2b949d04SAndroid Build Coastguard Worker xcb_connection_t *conn; 35*2b949d04SAndroid Build Coastguard Worker bool had_error; 36*2b949d04SAndroid Build Coastguard Worker /* Atoms for which we send a GetAtomName request */ 37*2b949d04SAndroid Build Coastguard Worker struct { 38*2b949d04SAndroid Build Coastguard Worker xcb_atom_t from; 39*2b949d04SAndroid Build Coastguard Worker xkb_atom_t *out; 40*2b949d04SAndroid Build Coastguard Worker xcb_get_atom_name_cookie_t cookie; 41*2b949d04SAndroid Build Coastguard Worker } pending[128]; 42*2b949d04SAndroid Build Coastguard Worker size_t num_pending; 43*2b949d04SAndroid Build Coastguard Worker /* Atoms which were already pending but queried again */ 44*2b949d04SAndroid Build Coastguard Worker struct { 45*2b949d04SAndroid Build Coastguard Worker xcb_atom_t from; 46*2b949d04SAndroid Build Coastguard Worker xkb_atom_t *out; 47*2b949d04SAndroid Build Coastguard Worker } copies[128]; 48*2b949d04SAndroid Build Coastguard Worker size_t num_copies; 49*2b949d04SAndroid Build Coastguard Worker /* These are not interned, but saved directly (after XkbEscapeMapName) */ 50*2b949d04SAndroid Build Coastguard Worker struct { 51*2b949d04SAndroid Build Coastguard Worker xcb_get_atom_name_cookie_t cookie; 52*2b949d04SAndroid Build Coastguard Worker char **out; 53*2b949d04SAndroid Build Coastguard Worker } escaped[4]; 54*2b949d04SAndroid Build Coastguard Worker size_t num_escaped; 55*2b949d04SAndroid Build Coastguard Worker }; 56*2b949d04SAndroid Build Coastguard Worker 57*2b949d04SAndroid Build Coastguard Worker void 58*2b949d04SAndroid Build Coastguard Worker x11_atom_interner_init(struct x11_atom_interner *interner, 59*2b949d04SAndroid Build Coastguard Worker struct xkb_context *ctx, xcb_connection_t *conn); 60*2b949d04SAndroid Build Coastguard Worker 61*2b949d04SAndroid Build Coastguard Worker void 62*2b949d04SAndroid Build Coastguard Worker x11_atom_interner_round_trip(struct x11_atom_interner *interner); 63*2b949d04SAndroid Build Coastguard Worker 64*2b949d04SAndroid Build Coastguard Worker /* 65*2b949d04SAndroid Build Coastguard Worker * Make a xkb_atom_t's from X atoms. The actual write is delayed until the next 66*2b949d04SAndroid Build Coastguard Worker * call to x11_atom_interner_round_trip() or when too many atoms are pending. 67*2b949d04SAndroid Build Coastguard Worker */ 68*2b949d04SAndroid Build Coastguard Worker void 69*2b949d04SAndroid Build Coastguard Worker x11_atom_interner_adopt_atom(struct x11_atom_interner *interner, 70*2b949d04SAndroid Build Coastguard Worker const xcb_atom_t atom, xkb_atom_t *out); 71*2b949d04SAndroid Build Coastguard Worker 72*2b949d04SAndroid Build Coastguard Worker /* 73*2b949d04SAndroid Build Coastguard Worker * Get a strdup'd and XkbEscapeMapName'd name of an X atom. The actual write is 74*2b949d04SAndroid Build Coastguard Worker * delayed until the next call to x11_atom_interner_round_trip(). 75*2b949d04SAndroid Build Coastguard Worker */ 76*2b949d04SAndroid Build Coastguard Worker void 77*2b949d04SAndroid Build Coastguard Worker x11_atom_interner_get_escaped_atom_name(struct x11_atom_interner *interner, 78*2b949d04SAndroid Build Coastguard Worker xcb_atom_t atom, char **out); 79*2b949d04SAndroid Build Coastguard Worker 80*2b949d04SAndroid Build Coastguard Worker #endif 81