x11: Get rid of GdkAtom and APIs supporting it.

replace all uses with const char * (non-interned).
Also remove a lot fo juggling from atom to GdkAtom to string and back.

The X Atom hash table is now mapping to (again, non-interned) strings.
This commit is contained in:
Benjamin Otte 2020-02-23 01:33:56 +01:00
parent 4280ca2263
commit 6e935d469a
14 changed files with 200 additions and 268 deletions

View File

@ -842,8 +842,6 @@ gdk_x11_surface_set_frame_sync_enabled
gdk_x11_keymap_get_group_for_state
gdk_x11_keymap_key_is_modifier
gdk_x11_visual_get_xvisual
gdk_x11_atom_to_xatom_for_display
gdk_x11_xatom_to_atom_for_display
gdk_x11_get_xatom_by_name_for_display
gdk_x11_get_xatom_name_for_display
gdk_x11_set_sm_client_id

View File

@ -210,7 +210,7 @@ translate_valuator_class (GdkDisplay *display,
static gboolean initialized = FALSE;
static Atom label_atoms [GDK_AXIS_LAST] = { 0 };
GdkAxisUse use = GDK_AXIS_IGNORE;
GdkAtom label;
const char *label;
gint i;
if (!initialized)
@ -234,12 +234,12 @@ translate_valuator_class (GdkDisplay *display,
}
if (valuator_label != None)
label = gdk_x11_xatom_to_atom_for_display (display, valuator_label);
label = gdk_x11_get_xatom_name_for_display (display, valuator_label);
else
label = NULL;
_gdk_device_add_axis (device, label, use, min, max, resolution);
GDK_DISPLAY_NOTE (display, INPUT, g_message ("\n\taxis: %s %s", (const char *)label, use == GDK_AXIS_IGNORE ? "(ignored)" : "(used)"));
GDK_DISPLAY_NOTE (display, INPUT, g_message ("\n\taxis: %s %s", label, use == GDK_AXIS_IGNORE ? "(ignored)" : "(used)"));
}
static void

View File

@ -605,12 +605,6 @@ gdk_check_edge_constraints_changed (GdkSurface *surface)
do_net_wm_state_changes (surface);
}
static Atom
get_cm_atom (GdkDisplay *display)
{
return _gdk_x11_get_xatom_for_display_printf (display, "_NET_WM_CM_S%d", DefaultScreen (GDK_DISPLAY_XDISPLAY (display)));
}
static Window
get_event_xwindow (const XEvent *xevent)
{
@ -1417,10 +1411,10 @@ gdk_x11_display_open (const gchar *display_name)
GdkX11Display *display_x11;
gint argc;
gchar *argv[1];
XClassHint *class_hint;
gint ignore;
gint maj, min;
char *cm_name;
XInitThreads ();
@ -1663,10 +1657,12 @@ gdk_x11_display_open (const gchar *display_name)
* notification, and then setup the initial state of
* is_composited to avoid a race condition here.
*/
gdk_x11_display_request_selection_notification (display,
gdk_x11_xatom_to_atom_for_display (display, get_cm_atom (display)));
cm_name = g_strdup_printf ("_NET_WM_CM_S%d", DefaultScreen (GDK_DISPLAY_XDISPLAY (display)));
gdk_x11_display_request_selection_notification (display, cm_name);
gdk_display_set_composited (GDK_DISPLAY (display),
XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), get_cm_atom (display)) != None);
XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display),
gdk_x11_get_xatom_by_name_for_display (display, cm_name)) != None);
g_free (cm_name);
gdk_display_emit_opened (display);
@ -1961,8 +1957,8 @@ gdk_x11_display_finalize (GObject *object)
g_slist_free_full (display_x11->streams, g_object_unref);
/* Atom Hashtable */
g_hash_table_destroy (display_x11->atom_from_virtual);
g_hash_table_destroy (display_x11->atom_to_virtual);
g_hash_table_destroy (display_x11->atom_from_string);
g_hash_table_destroy (display_x11->atom_to_string);
/* Leader Window */
XDestroyWindow (display_x11->xdisplay, display_x11->leader_window);

View File

@ -90,8 +90,8 @@ struct _GdkX11Display
GdkDrop *current_drop;
/* Mapping to/from virtual atoms */
GHashTable *atom_from_virtual;
GHashTable *atom_to_virtual;
GHashTable *atom_from_string;
GHashTable *atom_to_string;
/* Session Management leader window see ICCCM */
char *program_class;

View File

@ -1055,8 +1055,8 @@ xdnd_send_enter (GdkX11Drag *drag_x11)
GdkDrag *drag = GDK_DRAG (drag_x11);
GdkDisplay *display = gdk_drag_get_display (drag);
GdkContentFormats *formats;
const char * const *atoms;
gsize i, n_atoms;
const char * const *mime_types;
gsize i, n_mime_types;
XEvent xev;
xev.xclient.type = ClientMessage;
@ -1077,9 +1077,9 @@ xdnd_send_enter (GdkX11Drag *drag_x11)
formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
formats = gdk_content_formats_union_serialize_mime_types (formats);
atoms = gdk_content_formats_get_mime_types (formats, &n_atoms);
mime_types = gdk_content_formats_get_mime_types (formats, &n_mime_types);
if (n_atoms > 3)
if (n_mime_types > 3)
{
if (!drag_x11->xdnd_targets_set)
xdnd_set_targets (drag_x11);
@ -1087,9 +1087,9 @@ xdnd_send_enter (GdkX11Drag *drag_x11)
}
else
{
for (i = 0; i < n_atoms; i++)
for (i = 0; i < n_mime_types; i++)
{
xev.xclient.data.l[i + 2] = gdk_x11_atom_to_xatom_for_display (display, atoms[i]);
xev.xclient.data.l[i + 2] = gdk_x11_get_xatom_by_name_for_display (display, mime_types[i]);
}
}

View File

@ -120,7 +120,7 @@ void _gdk_x11_display_queue_events (GdkDisplay *display);
GdkAppLaunchContext *_gdk_x11_display_get_app_launch_context (GdkDisplay *display);
gint _gdk_x11_display_text_property_to_utf8_list (GdkDisplay *display,
GdkAtom encoding,
const char *encoding,
gint format,
const guchar *text,
gint length,
@ -162,12 +162,6 @@ void gdk_x11_device_xi2_store_axes (GdkX11DeviceXI2 *device,
gdouble *axes,
gint n_axes);
GdkAtom _gdk_x11_display_manager_atom_intern (GdkDisplayManager *manager,
const gchar *atom_name,
gboolean copy_name);
gchar * _gdk_x11_display_manager_get_atom_name (GdkDisplayManager *manager,
GdkAtom atom);
gboolean _gdk_x11_display_supports_cursor_alpha (GdkDisplay *display);
gboolean _gdk_x11_display_supports_cursor_color (GdkDisplay *display);
void _gdk_x11_display_get_default_cursor_size (GdkDisplay *display,

View File

@ -35,167 +35,35 @@
static void
insert_atom_pair (GdkDisplay *display,
GdkAtom virtual_atom,
const char *string,
Atom xatom)
{
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
char *s;
if (!display_x11->atom_from_virtual)
if (!display_x11->atom_from_string)
{
display_x11->atom_from_virtual = g_hash_table_new (g_direct_hash, NULL);
display_x11->atom_to_virtual = g_hash_table_new (g_direct_hash, NULL);
display_x11->atom_from_string = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
display_x11->atom_to_string = g_hash_table_new (NULL, NULL);
}
g_hash_table_insert (display_x11->atom_from_virtual, (gpointer)virtual_atom,
GUINT_TO_POINTER (xatom));
g_hash_table_insert (display_x11->atom_to_virtual,
GUINT_TO_POINTER (xatom), (gpointer)virtual_atom);
s = g_strdup (string);
g_hash_table_insert (display_x11->atom_from_string, s, GUINT_TO_POINTER (xatom));
g_hash_table_insert (display_x11->atom_to_string, GUINT_TO_POINTER (xatom), s);
}
static Atom
lookup_cached_xatom (GdkDisplay *display,
GdkAtom atom)
const char *string)
{
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
if (display_x11->atom_from_virtual)
return GPOINTER_TO_UINT (g_hash_table_lookup (display_x11->atom_from_virtual, atom));
if (display_x11->atom_from_string)
return GPOINTER_TO_UINT (g_hash_table_lookup (display_x11->atom_from_string, string));
return None;
}
/**
* gdk_x11_atom_to_xatom_for_display:
* @display: (type GdkX11Display): A #GdkDisplay
* @atom: A #GdkAtom, or %NULL
*
* Converts from a #GdkAtom to the X atom for a #GdkDisplay
* with the same string value. The special value %NULL
* is converted to %None.
*
* Returns: the X atom corresponding to @atom, or %None
**/
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 == NULL)
return None;
if (gdk_display_is_closed (display))
return None;
xatom = lookup_cached_xatom (display, atom);
if (!xatom)
{
const char *name = (const char *)atom;
xatom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), 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 = g_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)
XInternAtoms (GDK_DISPLAY_XDISPLAY (display),
(char **)xatom_names, n_xatoms, False, xatoms);
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);
}
/**
* gdk_x11_xatom_to_atom_for_display:
* @display: (type GdkX11Display): A #GdkDisplay
* @xatom: an X atom
*
* Convert from an X atom for a #GdkDisplay to the corresponding
* #GdkAtom.
*
* Returns: (transfer none): the corresponding #GdkAtom.
**/
GdkAtom
gdk_x11_xatom_to_atom_for_display (GdkDisplay *display,
Atom xatom)
{
GdkX11Display *display_x11;
GdkAtom virtual_atom = NULL;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
if (xatom == None)
return NULL;
if (gdk_display_is_closed (display))
return NULL;
display_x11 = GDK_X11_DISPLAY (display);
if (display_x11->atom_to_virtual)
virtual_atom = g_hash_table_lookup (display_x11->atom_to_virtual,
GUINT_TO_POINTER (xatom));
if (!virtual_atom)
{
/* If this atom doesn't exist, we'll die with an X error unless
* we take precautions
*/
char *name;
gdk_x11_display_error_trap_push (display);
name = XGetAtomName (GDK_DISPLAY_XDISPLAY (display), xatom);
if (gdk_x11_display_error_trap_pop (display))
{
g_warning (G_STRLOC " invalid X atom: %ld", xatom);
}
else
{
virtual_atom = g_intern_string (name);
XFree (name);
insert_atom_pair (display, virtual_atom, xatom);
}
}
return virtual_atom;
}
/**
* gdk_x11_get_xatom_by_name_for_display:
* @display: (type GdkX11Display): a #GdkDisplay
@ -211,8 +79,120 @@ Atom
gdk_x11_get_xatom_by_name_for_display (GdkDisplay *display,
const gchar *atom_name)
{
Atom xatom = None;
g_return_val_if_fail (GDK_IS_DISPLAY (display), None);
return gdk_x11_atom_to_xatom_for_display (display, g_intern_string (atom_name));
if (atom_name == NULL)
return None;
if (gdk_display_is_closed (display))
return None;
xatom = lookup_cached_xatom (display, atom_name);
if (!xatom)
{
xatom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), atom_name, FALSE);
insert_atom_pair (display, atom_name, xatom);
}
return xatom;
}
void
_gdk_x11_precache_atoms (GdkDisplay *display,
const gchar * const *atom_names,
gint n_atoms)
{
Atom *xatoms;
const char **xatom_names;
gint n_xatoms;
gint i;
xatoms = g_new (Atom, n_atoms);
xatom_names = g_new (const char *, n_atoms);
n_xatoms = 0;
for (i = 0; i < n_atoms; i++)
{
if (lookup_cached_xatom (display, atom_names[i]) == None)
{
xatom_names[n_xatoms] = atom_names[i];
n_xatoms++;
}
}
if (n_xatoms)
XInternAtoms (GDK_DISPLAY_XDISPLAY (display),
(char **) xatom_names, n_xatoms, False, xatoms);
for (i = 0; i < n_xatoms; i++)
insert_atom_pair (display, xatom_names[i], xatoms[i]);
g_free (xatoms);
g_free (xatom_names);
}
/**
* gdk_x11_get_xatom_name_for_display:
* @display: (type GdkX11Display): the #GdkDisplay where @xatom is defined
* @xatom: an X atom
*
* Returns the name of an X atom for its display. This
* function is meant mainly for debugging, so for convenience, unlike
* XAtomName() and the result doesnt need to
* be freed.
*
* Returns: name of the X atom; this string is owned by GDK,
* so it shouldnt be modifed or freed.
**/
const gchar *
gdk_x11_get_xatom_name_for_display (GdkDisplay *display,
Atom xatom)
{
GdkX11Display *display_x11;
const char *string;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
if (xatom == None)
return NULL;
if (gdk_display_is_closed (display))
return NULL;
display_x11 = GDK_X11_DISPLAY (display);
if (display_x11->atom_to_string)
string = g_hash_table_lookup (display_x11->atom_to_string,
GUINT_TO_POINTER (xatom));
else
string = NULL;
if (!string)
{
/* If this atom doesn't exist, we'll die with an X error unless
* we take precautions
*/
char *name;
gdk_x11_display_error_trap_push (display);
name = XGetAtomName (GDK_DISPLAY_XDISPLAY (display), xatom);
if (gdk_x11_display_error_trap_pop (display))
{
g_warning (G_STRLOC " invalid X atom: %ld", xatom);
}
else
{
insert_atom_pair (display, name, xatom);
XFree (name);
string = g_hash_table_lookup (display_x11->atom_to_string,
GUINT_TO_POINTER (xatom));
}
}
return string;
}
Atom
@ -235,25 +215,3 @@ _gdk_x11_get_xatom_for_display_printf (GdkDisplay *display,
return atom;
}
/**
* gdk_x11_get_xatom_name_for_display:
* @display: (type GdkX11Display): the #GdkDisplay where @xatom is defined
* @xatom: an X atom
*
* Returns the name of an X atom for its display. This
* function is meant mainly for debugging, so for convenience, unlike
* XAtomName() and the result doesnt need to
* be freed.
*
* Returns: name of the X atom; this string is owned by GDK,
* so it shouldnt be modifed or freed.
**/
const gchar *
gdk_x11_get_xatom_name_for_display (GdkDisplay *display,
Atom xatom)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
return (const char *)gdk_x11_xatom_to_atom_for_display (display, xatom);
}

View File

@ -1208,7 +1208,7 @@ fetch_net_wm_check_window (GdkX11Screen *x11_screen)
/**
* gdk_x11_screen_supports_net_wm_hint:
* @screen: the relevant #GdkX11Screen.
* @property: a property atom.
* @property_name: name of the WM property
*
* This function is specific to the X11 backend of GDK, and indicates
* whether the window manager supports a certain hint from the
@ -1227,7 +1227,7 @@ fetch_net_wm_check_window (GdkX11Screen *x11_screen)
**/
gboolean
gdk_x11_screen_supports_net_wm_hint (GdkX11Screen *x11_screen,
GdkAtom property)
const char *property_name)
{
gulong i;
NetWmSupportedAtoms *supported_atoms;
@ -1281,7 +1281,7 @@ gdk_x11_screen_supports_net_wm_hint (GdkX11Screen *x11_screen,
if (supported_atoms->atoms == NULL)
return FALSE;
atom = gdk_x11_atom_to_xatom_for_display (display, property);
atom = gdk_x11_get_xatom_by_name_for_display (display, property_name);
for (i = 0; i < supported_atoms->n_atoms; i++)
{
@ -1382,7 +1382,6 @@ static guint32
get_netwm_cardinal_property (GdkX11Screen *x11_screen,
const gchar *name)
{
GdkAtom atom;
guint32 prop = 0;
Atom type;
gint format;
@ -1390,9 +1389,7 @@ get_netwm_cardinal_property (GdkX11Screen *x11_screen,
gulong bytes_after;
guchar *data;
atom = g_intern_static_string (name);
if (!gdk_x11_screen_supports_net_wm_hint (x11_screen, atom))
if (!gdk_x11_screen_supports_net_wm_hint (x11_screen, name))
return 0;
XGetWindowProperty (x11_screen->xdisplay,

View File

@ -35,8 +35,8 @@
/**
* gdk_x11_display_text_property_to_text_list:
* @display: (type GdkX11Display): The #GdkDisplay where the encoding is defined
* @encoding: an atom representing the encoding. The most
* common values for this are STRING, or COMPOUND_TEXT.
* @encoding: a string representing the encoding. The most
* common values for this are "STRING", or "COMPOUND_TEXT".
* This is value used as the type for the property
* @format: the format of the property
* @text: The text data
@ -55,7 +55,7 @@
*/
gint
gdk_x11_display_text_property_to_text_list (GdkDisplay *display,
GdkAtom encoding,
const char *encoding,
gint format,
const guchar *text,
gint length,
@ -74,7 +74,7 @@ gdk_x11_display_text_property_to_text_list (GdkDisplay *display,
return 0;
property.value = (guchar *)text;
property.encoding = gdk_x11_atom_to_xatom_for_display (display, encoding);
property.encoding = gdk_x11_get_xatom_by_name_for_display (display, encoding);
property.format = format;
property.nitems = length;
res = XmbTextPropertyToTextList (GDK_DISPLAY_XDISPLAY (display), &property,
@ -188,17 +188,17 @@ make_list (const gchar *text,
gint
_gdk_x11_display_text_property_to_utf8_list (GdkDisplay *display,
GdkAtom encoding,
const char *encoding,
gint format,
const guchar *text,
gint length,
gchar ***list)
{
if (encoding == g_intern_static_string ("STRING"))
if (g_str_equal (encoding, "STRING"))
{
return make_list ((gchar *)text, length, TRUE, list);
}
else if (encoding == g_intern_static_string ("UTF8_STRING"))
else if (g_str_equal (encoding, "UTF8_STRING"))
{
return make_list ((gchar *)text, length, FALSE, list);
}
@ -273,7 +273,7 @@ _gdk_x11_display_text_property_to_utf8_list (GdkDisplay *display,
* gdk_x11_display_string_to_compound_text:
* @display: (type GdkX11Display): the #GdkDisplay where the encoding is defined
* @str: a nul-terminated string
* @encoding: (out) (transfer none): location to store the encoding atom
* @encoding: (out) (transfer none): location to store the encoding
* (to be used as the type for the property)
* @format: (out): location to store the format of the property
* @ctext: (out) (array length=length): location to store newly
@ -287,8 +287,8 @@ _gdk_x11_display_text_property_to_utf8_list (GdkDisplay *display,
*/
gint
gdk_x11_display_string_to_compound_text (GdkDisplay *display,
const gchar *str,
GdkAtom *encoding,
const char *str,
const char **encoding,
gint *format,
guchar **ctext,
gint *length)
@ -313,7 +313,7 @@ gdk_x11_display_string_to_compound_text (GdkDisplay *display,
}
if (encoding)
*encoding = gdk_x11_xatom_to_atom_for_display (display, property.encoding);
*encoding = gdk_x11_get_xatom_name_for_display (display, property.encoding);
if (format)
*format = property.format;
if (ctext)
@ -328,7 +328,7 @@ gdk_x11_display_string_to_compound_text (GdkDisplay *display,
* gdk_x11_display_utf8_to_compound_text:
* @display: (type GdkX11Display): a #GdkDisplay
* @str: a UTF-8 string
* @encoding: (out): location to store resulting encoding
* @encoding: (out) (transfer none): location to store resulting encoding
* @format: (out): location to store format of the result
* @ctext: (out) (array length=length): location to store the data of the result
* @length: location to store the length of the data
@ -341,8 +341,8 @@ gdk_x11_display_string_to_compound_text (GdkDisplay *display,
*/
gboolean
gdk_x11_display_utf8_to_compound_text (GdkDisplay *display,
const gchar *str,
GdkAtom *encoding,
const char *str,
const char **encoding,
gint *format,
guchar **ctext,
gint *length)
@ -377,7 +377,7 @@ gdk_x11_display_utf8_to_compound_text (GdkDisplay *display,
g_error_free (error);
if (encoding)
*encoding = None;
*encoding = NULL;
if (format)
*format = None;
if (ctext)

View File

@ -1626,7 +1626,6 @@ get_netwm_cardinal_property (GdkSurface *surface,
const gchar *name)
{
GdkX11Screen *x11_screen = GDK_SURFACE_SCREEN (surface);
GdkAtom atom;
guint32 prop = 0;
Atom type;
gint format;
@ -1634,9 +1633,7 @@ get_netwm_cardinal_property (GdkSurface *surface,
gulong bytes_after;
guchar *data;
atom = g_intern_static_string (name);
if (!gdk_x11_screen_supports_net_wm_hint (x11_screen, atom))
if (!gdk_x11_screen_supports_net_wm_hint (x11_screen, name))
return 0;
XGetWindowProperty (x11_screen->xdisplay,
@ -1683,13 +1680,12 @@ void
gdk_x11_surface_move_to_desktop (GdkSurface *surface,
guint32 desktop)
{
GdkAtom atom;
const char *atom_name = "_NET_WM_DESKTOP";
XClientMessageEvent xclient;
g_return_if_fail (GDK_IS_SURFACE (surface));
atom = g_intern_static_string ("_NET_WM_DESKTOP");
if (!gdk_x11_screen_supports_net_wm_hint (GDK_SURFACE_SCREEN (surface), atom))
if (!gdk_x11_screen_supports_net_wm_hint (GDK_SURFACE_SCREEN (surface), atom_name))
return;
memset (&xclient, 0, sizeof (xclient));
@ -1697,7 +1693,7 @@ gdk_x11_surface_move_to_desktop (GdkSurface *surface,
xclient.serial = 0;
xclient.send_event = True;
xclient.window = GDK_SURFACE_XID (surface);
xclient.message_type = gdk_x11_atom_to_xatom_for_display (GDK_SURFACE_DISPLAY (surface), atom);
xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_SURFACE_DISPLAY (surface), atom_name);
xclient.format = 32;
xclient.data.l[0] = desktop;
@ -1897,10 +1893,10 @@ gdk_x11_surface_get_type_hint (GdkSurface *surface)
}
static void
gdk_wmspec_change_state (gboolean add,
gdk_wmspec_change_state (gboolean add,
GdkSurface *surface,
GdkAtom state1,
GdkAtom state2)
const char *state1,
const char *state2)
{
GdkDisplay *display = GDK_SURFACE_DISPLAY (surface);
XClientMessageEvent xclient;
@ -1915,8 +1911,8 @@ gdk_wmspec_change_state (gboolean add,
xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE");
xclient.format = 32;
xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1);
xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2);
xclient.data.l[1] = gdk_x11_get_xatom_by_name_for_display (display, state1);
xclient.data.l[2] = gdk_x11_get_xatom_by_name_for_display (display, state2);
xclient.data.l[3] = 1; /* source indication */
xclient.data.l[4] = 0;
@ -1936,7 +1932,7 @@ gdk_x11_surface_set_modal_hint (GdkSurface *surface,
if (GDK_SURFACE_IS_MAPPED (surface))
gdk_wmspec_change_state (modal, surface,
g_intern_static_string ("_NET_WM_STATE_MODAL"),
"_NET_WM_STATE_MODAL",
NULL);
}
@ -1962,7 +1958,7 @@ gdk_x11_surface_set_skip_taskbar_hint (GdkSurface *surface,
if (GDK_SURFACE_IS_MAPPED (surface))
gdk_wmspec_change_state (skips_taskbar, surface,
g_intern_static_string ("_NET_WM_STATE_SKIP_TASKBAR"),
"_NET_WM_STATE_SKIP_TASKBAR",
NULL);
}
@ -1988,7 +1984,7 @@ gdk_x11_surface_set_skip_pager_hint (GdkSurface *surface,
if (GDK_SURFACE_IS_MAPPED (surface))
gdk_wmspec_change_state (skips_pager, surface,
g_intern_static_string ("_NET_WM_STATE_SKIP_PAGER"),
"_NET_WM_STATE_SKIP_PAGER",
NULL);
}
@ -2242,12 +2238,12 @@ set_text_property (GdkDisplay *display,
}
else
{
GdkAtom gdk_type;
const char *gdk_type;
gdk_x11_display_utf8_to_compound_text (display,
utf8_str, &gdk_type, &prop_format,
(guchar **)&prop_text, &prop_length);
prop_type = gdk_x11_atom_to_xatom_for_display (display, gdk_type);
prop_type = gdk_x11_get_xatom_by_name_for_display (display, gdk_type);
is_compound_text = TRUE;
}
@ -3091,7 +3087,7 @@ gdk_x11_surface_minimize (GdkSurface *surface)
/* Flip our client side flag, the real work happens on map. */
gdk_synthesize_surface_state (surface, 0, GDK_SURFACE_STATE_MINIMIZED);
gdk_wmspec_change_state (TRUE, surface,
g_intern_static_string ("_NET_WM_STATE_HIDDEN"),
"_NET_WM_STATE_HIDDEN",
NULL);
}
}
@ -3106,7 +3102,7 @@ gdk_x11_surface_unminimize (GdkSurface *surface)
{
gdk_surface_show (surface);
gdk_wmspec_change_state (FALSE, surface,
g_intern_static_string ("_NET_WM_STATE_HIDDEN"),
"_NET_WM_STATE_HIDDEN",
NULL);
}
else
@ -3114,7 +3110,7 @@ gdk_x11_surface_unminimize (GdkSurface *surface)
/* Flip our client side flag, the real work happens on map. */
gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_MINIMIZED, 0);
gdk_wmspec_change_state (FALSE, surface,
g_intern_static_string ("_NET_WM_STATE_HIDDEN"),
"_NET_WM_STATE_HIDDEN",
NULL);
}
}
@ -3135,7 +3131,7 @@ gdk_x11_surface_stick (GdkSurface *surface)
/* Request stick during viewport scroll */
gdk_wmspec_change_state (TRUE, surface,
g_intern_static_string ("_NET_WM_STATE_STICKY"),
"_NET_WM_STATE_STICKY",
NULL);
/* Request desktop 0xFFFFFFFF */
@ -3176,7 +3172,7 @@ gdk_x11_surface_unstick (GdkSurface *surface)
{
/* Request unstick from viewport */
gdk_wmspec_change_state (FALSE, surface,
g_intern_static_string ("_NET_WM_STATE_STICKY"),
"_NET_WM_STATE_STICKY",
NULL);
move_to_current_desktop (surface);
@ -3199,8 +3195,8 @@ gdk_x11_surface_maximize (GdkSurface *surface)
if (GDK_SURFACE_IS_MAPPED (surface))
gdk_wmspec_change_state (TRUE, surface,
g_intern_static_string ("_NET_WM_STATE_MAXIMIZED_VERT"),
g_intern_static_string ("_NET_WM_STATE_MAXIMIZED_HORZ"));
"_NET_WM_STATE_MAXIMIZED_VERT",
"_NET_WM_STATE_MAXIMIZED_HORZ");
else
gdk_synthesize_surface_state (surface,
0,
@ -3215,8 +3211,8 @@ gdk_x11_surface_unmaximize (GdkSurface *surface)
if (GDK_SURFACE_IS_MAPPED (surface))
gdk_wmspec_change_state (FALSE, surface,
g_intern_static_string ("_NET_WM_STATE_MAXIMIZED_VERT"),
g_intern_static_string ("_NET_WM_STATE_MAXIMIZED_HORZ"));
"_NET_WM_STATE_MAXIMIZED_VERT",
"_NET_WM_STATE_MAXIMIZED_HORZ");
else
gdk_synthesize_surface_state (surface,
GDK_SURFACE_STATE_MAXIMIZED,
@ -3323,7 +3319,7 @@ gdk_x11_surface_fullscreen (GdkSurface *surface)
if (GDK_SURFACE_IS_MAPPED (surface))
{
gdk_wmspec_change_state (TRUE, surface,
g_intern_static_string ("_NET_WM_STATE_FULLSCREEN"),
"_NET_WM_STATE_FULLSCREEN",
NULL);
/* Actual XRandR layout may have change since we computed the fullscreen
* monitors in GDK_FULLSCREEN_ON_ALL_MONITORS mode.
@ -3361,7 +3357,7 @@ gdk_x11_surface_unfullscreen (GdkSurface *surface)
if (GDK_SURFACE_IS_MAPPED (surface))
gdk_wmspec_change_state (FALSE, surface,
g_intern_static_string ("_NET_WM_STATE_FULLSCREEN"),
"_NET_WM_STATE_FULLSCREEN",
NULL);
else
@ -3383,10 +3379,10 @@ gdk_x11_surface_set_keep_above (GdkSurface *surface,
{
if (setting)
gdk_wmspec_change_state (FALSE, surface,
g_intern_static_string ("_NET_WM_STATE_BELOW"),
"_NET_WM_STATE_BELOW",
NULL);
gdk_wmspec_change_state (setting, surface,
g_intern_static_string ("_NET_WM_STATE_ABOVE"),
"_NET_WM_STATE_ABOVE",
NULL);
}
else
@ -3407,10 +3403,10 @@ gdk_x11_surface_set_keep_below (GdkSurface *surface, gboolean setting)
{
if (setting)
gdk_wmspec_change_state (FALSE, surface,
g_intern_static_string ("_NET_WM_STATE_ABOVE"),
"_NET_WM_STATE_ABOVE",
NULL);
gdk_wmspec_change_state (setting, surface,
g_intern_static_string ("_NET_WM_STATE_BELOW"),
"_NET_WM_STATE_BELOW",
NULL);
}
else

View File

@ -222,7 +222,7 @@ gdk_x11_text_list_converter_encode (GdkX11TextListConverter *conv,
{
GConverterResult result;
guchar *text;
GdkAtom encoding;
const char *encoding;
gint format;
gint new_length;
char *tmp;
@ -231,7 +231,7 @@ gdk_x11_text_list_converter_encode (GdkX11TextListConverter *conv,
if (gdk_x11_display_utf8_to_compound_text (conv->display, tmp,
&encoding, &format, &text, &new_length))
{
if (encoding == g_intern_string (conv->encoding) &&
if (g_str_equal (encoding, conv->encoding) &&
format == conv->format)
{
result = write_output (outbuf, outbuf_size, bytes_written, text, new_length, error);

View File

@ -36,13 +36,6 @@
G_BEGIN_DECLS
/* Functions to get the X Atom equivalent to the GdkAtom */
GDK_AVAILABLE_IN_ALL
Atom gdk_x11_atom_to_xatom_for_display (GdkDisplay *display,
GdkAtom atom);
GDK_AVAILABLE_IN_ALL
GdkAtom gdk_x11_xatom_to_atom_for_display (GdkDisplay *display,
Atom xatom);
GDK_AVAILABLE_IN_ALL
Atom gdk_x11_get_xatom_by_name_for_display (GdkDisplay *display,
const gchar *atom_name);

View File

@ -59,7 +59,7 @@ const char* gdk_x11_screen_get_window_manager_name (GdkX11Screen *screen);
GDK_AVAILABLE_IN_ALL
gboolean gdk_x11_screen_supports_net_wm_hint (GdkX11Screen *screen,
GdkAtom property);
const char *property_name);
GDK_AVAILABLE_IN_ALL
XID gdk_x11_screen_get_monitor_output (GdkX11Screen *screen,

View File

@ -38,7 +38,7 @@ G_BEGIN_DECLS
GDK_AVAILABLE_IN_ALL
gint gdk_x11_display_text_property_to_text_list (GdkDisplay *display,
GdkAtom encoding,
const char *encoding,
gint format,
const guchar *text,
gint length,
@ -47,15 +47,15 @@ GDK_AVAILABLE_IN_ALL
void gdk_x11_free_text_list (gchar **list);
GDK_AVAILABLE_IN_ALL
gint gdk_x11_display_string_to_compound_text (GdkDisplay *display,
const gchar *str,
GdkAtom *encoding,
const char *str,
const char **encoding,
gint *format,
guchar **ctext,
gint *length);
GDK_AVAILABLE_IN_ALL
gboolean gdk_x11_display_utf8_to_compound_text (GdkDisplay *display,
const gchar *str,
GdkAtom *encoding,
const char *str,
const char **encoding,
gint *format,
guchar **ctext,
gint *length);