API: window: Remove suppport for changing wmclass_name/group

X11 was the only backend to support it and people can just override it
using XSetClassHint() directly.
The docs already advertised the function as "Do not use".

Keep the existing call to XSetClassHint() in place, so that we keep
setting the same values as in GTK3.
This commit is contained in:
Benjamin Otte 2016-09-29 22:23:51 +02:00
parent fe24fcbc3e
commit 2fd5048943
8 changed files with 9 additions and 94 deletions

View File

@ -93,7 +93,6 @@ typedef enum
* @GDK_WA_Y: Honor the Y coordinate field
* @GDK_WA_CURSOR: Honor the cursor field
* @GDK_WA_VISUAL: Honor the visual field
* @GDK_WA_WMCLASS: Honor the wmclass_class and wmclass_name fields
* @GDK_WA_NOREDIR: Honor the override_redirect field
* @GDK_WA_TYPE_HINT: Honor the type_hint field
*
@ -111,9 +110,8 @@ typedef enum
GDK_WA_Y = 1 << 3,
GDK_WA_CURSOR = 1 << 4,
GDK_WA_VISUAL = 1 << 5,
GDK_WA_WMCLASS = 1 << 6,
GDK_WA_NOREDIR = 1 << 7,
GDK_WA_TYPE_HINT = 1 << 8
GDK_WA_NOREDIR = 1 << 6,
GDK_WA_TYPE_HINT = 1 << 7
} GdkWindowAttributesType;
/* Size restriction enumeration.
@ -343,8 +341,6 @@ typedef enum
* @visual: #GdkVisual for window
* @window_type: type of window
* @cursor: cursor for the window (see gdk_window_set_cursor())
* @wmclass_name: dont use (see gtk_window_set_wmclass())
* @wmclass_class: dont use (see gtk_window_set_wmclass())
* @override_redirect: %TRUE to bypass the window manager
* @type_hint: a hint of the function of the window
*
@ -361,8 +357,6 @@ struct _GdkWindowAttr
GdkVisual *visual;
GdkWindowType window_type;
GdkCursor *cursor;
gchar *wmclass_name;
gchar *wmclass_class;
gboolean override_redirect;
GdkWindowTypeHint type_hint;
};

View File

@ -734,9 +734,9 @@ _gdk_win32_display_create_window_impl (GdkDisplay *display,
remaining_mask &= ~GDK_WA_NOREDIR;
}
if ((remaining_mask & ~(GDK_WA_WMCLASS|GDK_WA_VISUAL|GDK_WA_CURSOR|GDK_WA_TITLE|GDK_WA_TYPE_HINT)) != 0)
if ((remaining_mask & ~(GDK_WA_VISUAL|GDK_WA_CURSOR|GDK_WA_TITLE|GDK_WA_TYPE_HINT)) != 0)
g_warning ("_gdk_window_impl_new: uexpected attribute 0x%X",
remaining_mask & ~(GDK_WA_WMCLASS|GDK_WA_VISUAL|GDK_WA_CURSOR|GDK_WA_TITLE|GDK_WA_TYPE_HINT));
remaining_mask & ~(GDK_WA_VISUAL|GDK_WA_CURSOR|GDK_WA_TITLE|GDK_WA_TYPE_HINT));
hparent = GDK_WINDOW_HWND (real_parent);
@ -752,10 +752,6 @@ _gdk_win32_display_create_window_impl (GdkDisplay *display,
impl->layered = FALSE;
impl->layered_opacity = 1.0;
/* wclass is not any longer set always, but if is ... */
if ((attributes_mask & GDK_WA_WMCLASS) == GDK_WA_WMCLASS)
g_assert ((attributes->wclass == GDK_INPUT_OUTPUT) == !window->input_only);
if (!window->input_only)
{
dwExStyle = 0;

View File

@ -1127,14 +1127,11 @@ _gdk_x11_display_create_window_impl (GdkDisplay *display,
gdk_window_set_title (window, title);
if (attributes_mask & GDK_WA_WMCLASS)
{
class_hint = XAllocClassHint ();
class_hint->res_name = attributes->wmclass_name;
class_hint->res_class = attributes->wmclass_class;
XSetClassHint (xdisplay, impl->xid, class_hint);
XFree (class_hint);
}
class_hint = XAllocClassHint ();
class_hint->res_name = (char *) g_get_prgname ();
class_hint->res_class = (char *) gdk_get_program_class ();
XSetClassHint (xdisplay, impl->xid, class_hint);
XFree (class_hint);
setup_toplevel_window (window, window->parent);
break;

View File

@ -1009,7 +1009,6 @@ gtk_plug_realize (GtkWidget *widget)
GdkWindow *gdk_window;
GdkWindowAttr attributes;
const gchar *title;
gchar *wmclass_name, *wmclass_class;
gint attributes_mask;
GdkScreen *screen;
@ -1020,13 +1019,10 @@ gtk_plug_realize (GtkWidget *widget)
g_warning ("GtkPlug only works under X11");
title = gtk_window_get_title (window);
_gtk_window_get_wmclass (window, &wmclass_name, &wmclass_class);
gtk_widget_get_allocation (widget, &allocation);
attributes.window_type = GDK_WINDOW_CHILD; /* XXX GDK_WINDOW_PLUG ? */
attributes.title = (gchar *) title;
attributes.wmclass_name = wmclass_name;
attributes.wmclass_class = wmclass_class;
attributes.width = allocation.width;
attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
@ -1044,7 +1040,6 @@ gtk_plug_realize (GtkWidget *widget)
attributes_mask = GDK_WA_VISUAL;
attributes_mask |= (title ? GDK_WA_TITLE : 0);
attributes_mask |= (wmclass_name ? GDK_WA_WMCLASS : 0);
if (gtk_widget_is_toplevel (widget))
{

View File

@ -203,7 +203,6 @@ gtk_win32_embed_widget_realize (GtkWidget *widget)
attributes.window_type = GDK_WINDOW_CHILD;
attributes.title = (gchar *) gtk_window_get_title (window);
_gtk_window_get_wmclass (window, &attributes.wmclass_name, &attributes.wmclass_class);
attributes.width = allocation.width;
attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
@ -222,7 +221,6 @@ gtk_win32_embed_widget_realize (GtkWidget *widget)
attributes_mask = GDK_WA_VISUAL;
attributes_mask |= (attributes.title ? GDK_WA_TITLE : 0);
attributes_mask |= (attributes.wmclass_name ? GDK_WA_WMCLASS : 0);
gdk_window = gdk_window_new (embed_widget->parent_window,
&attributes, attributes_mask);

View File

@ -192,8 +192,6 @@ struct _GtkWindowPrivate
gchar *startup_id;
gchar *title;
gchar *wmclass_class;
gchar *wmclass_name;
gchar *wm_role;
guint keys_changed_handler;
@ -1649,8 +1647,6 @@ gtk_window_init (GtkWindow *window)
gtk_container_set_default_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE);
priv->title = NULL;
priv->wmclass_name = g_strdup (g_get_prgname ());
priv->wmclass_class = g_strdup (gdk_get_program_class ());
priv->wm_role = NULL;
priv->geometry_info = NULL;
priv->type = GTK_WINDOW_TOPLEVEL;
@ -2381,43 +2377,6 @@ gtk_window_get_title (GtkWindow *window)
return window->priv->title;
}
/**
* gtk_window_set_wmclass:
* @window: a #GtkWindow
* @wmclass_name: window name hint
* @wmclass_class: window class hint
*
* Dont use this function. It sets the X Window System class and
* name hints for a window. According to the ICCCM, you should
* always set these to the same value for all windows in an
* application, and GTK+ sets them to that value by default, so calling
* this function is sort of pointless. However, you may want to call
* gtk_window_set_role() on each window in your application, for the
* benefit of the session manager. Setting the role allows the window
* manager to restore window positions when loading a saved session.
*
**/
void
gtk_window_set_wmclass (GtkWindow *window,
const gchar *wmclass_name,
const gchar *wmclass_class)
{
GtkWindowPrivate *priv;
g_return_if_fail (GTK_IS_WINDOW (window));
priv = window->priv;
g_free (priv->wmclass_name);
priv->wmclass_name = g_strdup (wmclass_name);
g_free (priv->wmclass_class);
priv->wmclass_class = g_strdup (wmclass_class);
if (_gtk_widget_get_realized (GTK_WIDGET (window)))
g_warning ("gtk_window_set_wmclass: shouldn't set wmclass after window is realized!");
}
/**
* gtk_window_set_role:
* @window: a #GtkWindow
@ -5820,8 +5779,6 @@ gtk_window_finalize (GObject *object)
GtkMnemonicHash *mnemonic_hash;
g_free (priv->title);
g_free (priv->wmclass_name);
g_free (priv->wmclass_class);
g_free (priv->wm_role);
gtk_window_release_application (window);
@ -7139,8 +7096,6 @@ gtk_window_realize (GtkWidget *widget)
#endif
attributes.title = priv->title;
attributes.wmclass_name = priv->wmclass_name;
attributes.wmclass_class = priv->wmclass_class;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
@ -7169,7 +7124,6 @@ gtk_window_realize (GtkWidget *widget)
attributes_mask |= GDK_WA_VISUAL | GDK_WA_TYPE_HINT;
attributes_mask |= (priv->title ? GDK_WA_TITLE : 0);
attributes_mask |= (priv->wmclass_name ? GDK_WA_WMCLASS : 0);
gdk_window = gdk_window_new (parent_window, &attributes, attributes_mask);
}
@ -11553,17 +11507,6 @@ gtk_window_set_focus_visible (GtkWindow *window,
}
}
void
_gtk_window_get_wmclass (GtkWindow *window,
gchar **wmclass_name,
gchar **wmclass_class)
{
GtkWindowPrivate *priv = window->priv;
*wmclass_name = priv->wmclass_name;
*wmclass_class = priv->wmclass_class;
}
/**
* gtk_window_set_has_user_ref_count:
* @window: a #GtkWindow

View File

@ -151,10 +151,6 @@ void gtk_window_set_title (GtkWindow *window,
GDK_AVAILABLE_IN_ALL
const gchar * gtk_window_get_title (GtkWindow *window);
GDK_AVAILABLE_IN_ALL
void gtk_window_set_wmclass (GtkWindow *window,
const gchar *wmclass_name,
const gchar *wmclass_class);
GDK_AVAILABLE_IN_ALL
void gtk_window_set_role (GtkWindow *window,
const gchar *role);
GDK_AVAILABLE_IN_ALL

View File

@ -57,10 +57,6 @@ void _gtk_window_set_is_active (GtkWindow *window,
void _gtk_window_set_is_toplevel (GtkWindow *window,
gboolean is_toplevel);
void _gtk_window_get_wmclass (GtkWindow *window,
gchar **wmclass_name,
gchar **wmclass_class);
void _gtk_window_set_allocation (GtkWindow *window,
const GtkAllocation *allocation,
GtkAllocation *allocation_out);