mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 14:39:24 -05:00
Replace deprecated gtk_window_set_wmclass with raw Xlib.
Calling gtk_widget_realize to enforce the existence of an underlying GdkWindow, followed by gdk_window_ensure_native to enforce an underlying X window in turn, allows me to get hold of an X window id on which I can call the Xlib function for setting WM_CLASS, still before the window is mapped. With this change, plus Colin's preceding patches, the whole code base _actually_ compiles and links against GTK 3.22 without any deprecation warnings. (My claim in commit 8ce237234 that it previously did appears to have been completely wrong - my guess is that I'd forgotten to 'make clean' before testing against 3.22 and so some source files had already been compiled against earlier GTK headers.)
This commit is contained in:
parent
921afd3716
commit
af08a7a3b1
@ -4387,9 +4387,34 @@ struct gui_data *new_session_window(Conf *conf, const char *geometry_string)
|
|||||||
gtk_widget_set_name(GTK_WIDGET(inst->window), "top-level");
|
gtk_widget_set_name(GTK_WIDGET(inst->window), "top-level");
|
||||||
{
|
{
|
||||||
const char *winclass = conf_get_str(inst->conf, CONF_winclass);
|
const char *winclass = conf_get_str(inst->conf, CONF_winclass);
|
||||||
if (*winclass)
|
if (*winclass) {
|
||||||
|
#if GTK_CHECK_VERSION(3,22,0)
|
||||||
|
#ifndef NOT_X_WINDOWS
|
||||||
|
GdkWindow *gdkwin;
|
||||||
|
gtk_widget_realize(GTK_WIDGET(inst->window));
|
||||||
|
gdkwin = gtk_widget_get_window(GTK_WIDGET(inst->window));
|
||||||
|
if (gdk_window_ensure_native(gdkwin)) {
|
||||||
|
Display *disp =
|
||||||
|
GDK_DISPLAY_XDISPLAY(gdk_window_get_display(gdkwin));
|
||||||
|
XClassHint *xch = XAllocClassHint();
|
||||||
|
xch->res_name = (char *)winclass;
|
||||||
|
xch->res_class = (char *)winclass;
|
||||||
|
XSetClassHint(disp, GDK_WINDOW_XID(gdkwin), xch);
|
||||||
|
XFree(xch);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* If we do have NOT_X_WINDOWS set, then we don't have any
|
||||||
|
* function in GTK 3.22 equivalent to the above. But then,
|
||||||
|
* surely in that situation the deprecated
|
||||||
|
* gtk_window_set_wmclass wouldn't have done anything
|
||||||
|
* meaningful in previous GTKs either.
|
||||||
|
*/
|
||||||
|
#else
|
||||||
gtk_window_set_wmclass(GTK_WINDOW(inst->window),
|
gtk_window_set_wmclass(GTK_WINDOW(inst->window),
|
||||||
winclass, winclass);
|
winclass, winclass);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user