mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-02 20:12:48 -05:00
Avoid treating non-X GDK display names as X ones
When running on Wayland, gdk_display_get_name() can return things like "wayland-0" rather than valid X display names. PuTTY nonetheless treated them as X display names, meaning that when running under Wayland, pterm would set DISPLAY to "wayland-0" in subprocesses, and PuTTY's X forwarding wouldn't work properly. To fix this, places that call gdk_display_get_name() now only do so on displays for which GDK_IS_X_DISPLAY() is true. As with GDK_IS_X_WINDOW(), this requires some backward-compatibility for GDK versions where everything is implicitly running on X. To make this work usefully, pterm now also won't unset DISPLAY if it can't get an X display name and instead will pass through whatever value of DISPLAY it received. I think that's better behaviour anyway. There are two separate parts of PuTTY that call gdk_display_get_name(). platform_get_x_display() in unix/putty.c is used for X forwarding, while gtk_seat_get_x_display() in unix/window.c is used used for setting DISPLAY and recording in utmp. I've updated both of them.
This commit is contained in:
@ -18,6 +18,10 @@
|
||||
|
||||
#include "gtkcompat.h"
|
||||
|
||||
#ifndef NOT_X_WINDOWS
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Stubs to avoid pty.c needing to be linked in.
|
||||
*/
|
||||
@ -62,8 +66,11 @@ const bool dup_check_launchable = true;
|
||||
|
||||
char *platform_get_x_display(void) {
|
||||
const char *display;
|
||||
#ifndef NOT_X_WINDOWS
|
||||
/* Try to take account of --display and what have you. */
|
||||
if (!(display = gdk_get_display()))
|
||||
if (!GDK_IS_X11_DISPLAY(gdk_display_get_default()) ||
|
||||
!(display = gdk_get_display()))
|
||||
#endif
|
||||
/* fall back to traditional method */
|
||||
display = getenv("DISPLAY");
|
||||
return dupstr(display);
|
||||
|
Reference in New Issue
Block a user