/** * gdk_x11_atom_to_xatom_for_display: * @display: (type GdkX11Display): A #GdkDisplay * @atom: A #GdkAtom, or %GDK_NONE * * Converts from a #GdkAtom to the X atom for a #GdkDisplay * with the same string value. The special value %GDK_NONE * is converted to %None. * * Return value: the X atom corresponding to @atom, or %None * * Since: 2.2 **/ Atom gdk_x11_atom_to_xatom_for_display (GdkDisplay *display, GdkAtom atom) { Atom xatom = None; g_return_val_if_fail (GDK_IS_DISPLAY (display), None); if (atom == GDK_NONE) return None; if (gdk_display_is_closed (display)) return None; xatom = lookup_cached_xatom (display, atom); if (!xatom) { char *name = gdk_atom_name (atom); xatom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), name, FALSE); insert_atom_pair (display, atom, xatom); g_free (name); } return xatom; }
/** * gdk_x11_atom_to_xatom_for_display: * @display: A #GdkDisplay * @atom: A #GdkAtom, or %GDK_NONE * * Converts from a #GdkAtom to the X atom for a #GdkDisplay * with the same string value. The special value %GDK_NONE * is converted to %None. * * Return value: the X atom corresponding to @atom, or %None * * Since: 2.2 **/ Atom gdk_x11_atom_to_xatom_for_display (GdkDisplay *display, GdkAtom atom) { Atom xatom = None; g_return_val_if_fail (GDK_IS_DISPLAY (display), None); if (atom == GDK_NONE) return None; if (display->closed) return None; xatom = lookup_cached_xatom (display, atom); if (!xatom) { char *name; g_return_val_if_fail (ATOM_TO_INDEX (atom) < virtual_atom_array->len, None); name = g_ptr_array_index (virtual_atom_array, ATOM_TO_INDEX (atom)); xatom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), name, FALSE); insert_atom_pair (display, atom, xatom); } return xatom; }
/** * gdk_x11_atom_to_xatom_for_display: * @display: A #GdkDisplay * @atom: A #GdkAtom * * Converts from a #GdkAtom to the X atom for a #GdkDisplay * with the same string value. * * Return value: the X atom corresponding to @atom. * * Since: 2.2 **/ gi_atom_id_t gdk_x11_atom_to_xatom_for_display (GdkDisplay *display, GdkAtom atom) { gi_atom_id_t xatom = 0; g_return_val_if_fail (GDK_IS_DISPLAY (display), 0); if (display->closed) return 0; xatom = lookup_cached_xatom (display, atom); if (!xatom) { char *name; g_return_val_if_fail (ATOM_TO_INDEX (atom) < virtual_atom_array->len, 0); name = g_ptr_array_index (virtual_atom_array, ATOM_TO_INDEX (atom)); xatom = gi_intern_atom ( name, FALSE); insert_atom_pair (display, atom, xatom); } return xatom; }
void _gdk_x11_precache_atoms (GdkDisplay *display, const gchar * const *atom_names, gint n_atoms) { Atom *xatoms; GdkAtom *atoms; const gchar **xatom_names; gint n_xatoms; gint i; xatoms = g_new (Atom, n_atoms); xatom_names = g_new (const gchar *, n_atoms); atoms = g_new (GdkAtom, n_atoms); n_xatoms = 0; for (i = 0; i < n_atoms; i++) { GdkAtom atom = gdk_atom_intern_static_string (atom_names[i]); if (lookup_cached_xatom (display, atom) == None) { atoms[n_xatoms] = atom; xatom_names[n_xatoms] = atom_names[i]; n_xatoms++; } } if (n_xatoms) { #ifdef HAVE_XINTERNATOMS XInternAtoms (GDK_DISPLAY_XDISPLAY (display), (char **)xatom_names, n_xatoms, False, xatoms); #else for (i = 0; i < n_xatoms; i++) xatoms[i] = XInternAtom (GDK_DISPLAY_XDISPLAY (display), xatom_names[i], False); #endif } for (i = 0; i < n_xatoms; i++) insert_atom_pair (display, atoms[i], xatoms[i]); g_free (xatoms); g_free (xatom_names); g_free (atoms); }