@@ -33,7 +33,7 @@ namespace py = pybind11;
33
33
using namespace pybind11 ::literals;
34
34
35
35
static bool
36
- mpl_display_is_valid (void )
36
+ mpl_xdisplay_is_valid (void )
37
37
{
38
38
#ifdef __linux__
39
39
void * libX11;
@@ -57,6 +57,19 @@ mpl_display_is_valid(void)
57
57
return true ;
58
58
}
59
59
}
60
+ return false ;
61
+ #else
62
+ return true ;
63
+ #endif
64
+ }
65
+
66
+ static bool
67
+ mpl_display_is_valid (void )
68
+ {
69
+ #ifdef __linux__
70
+ if (mpl_xdisplay_is_valid ()) {
71
+ return true ;
72
+ }
60
73
void * libwayland_client;
61
74
if (getenv (" WAYLAND_DISPLAY" )
62
75
&& (libwayland_client = dlopen (" libwayland-client.so.0" , RTLD_LAZY))) {
@@ -194,6 +207,16 @@ PYBIND11_MODULE(_c_internal_utils, m)
194
207
succeeds, or $WAYLAND_DISPLAY is set and wl_display_connect(NULL)
195
208
succeeds.
196
209
210
+ On other platforms, always returns True.)""" );
211
+ m.def (
212
+ " xdisplay_is_valid" , &mpl_xdisplay_is_valid,
213
+ R"""( --
214
+ Check whether the current X11 display is valid.
215
+
216
+ On Linux, returns True if either $DISPLAY is set and XOpenDisplay(NULL)
217
+ succeeds. Use this function if you need to specifically check for X11
218
+ only (e.g., for Tkinter).
219
+
197
220
On other platforms, always returns True.)""" );
198
221
m.def (
199
222
" Win32_GetCurrentProcessExplicitAppUserModelID" ,
0 commit comments