@@ -26,7 +26,7 @@ namespace py = pybind11;
26
26
using namespace pybind11 ::literals;
27
27
28
28
static bool
29
- mpl_display_is_valid (void )
29
+ mpl_xdisplay_is_valid (void )
30
30
{
31
31
#ifdef __linux__
32
32
void * libX11;
@@ -50,6 +50,19 @@ mpl_display_is_valid(void)
50
50
return true ;
51
51
}
52
52
}
53
+ return false ;
54
+ #else
55
+ return true ;
56
+ #endif
57
+ }
58
+
59
+ static bool
60
+ mpl_display_is_valid (void )
61
+ {
62
+ #ifdef __linux__
63
+ if (mpl_xdisplay_is_valid ()) {
64
+ return true ;
65
+ }
53
66
void * libwayland_client;
54
67
if (getenv (" WAYLAND_DISPLAY" )
55
68
&& (libwayland_client = dlopen (" libwayland-client.so.0" , RTLD_LAZY))) {
@@ -183,6 +196,16 @@ PYBIND11_MODULE(_c_internal_utils, m)
183
196
succeeds, or $WAYLAND_DISPLAY is set and wl_display_connect(NULL)
184
197
succeeds.
185
198
199
+ On other platforms, always returns True.)""" );
200
+ m.def (
201
+ " xdisplay_is_valid" , &mpl_xdisplay_is_valid,
202
+ R"""( --
203
+ Check whether the current X11 display is valid.
204
+
205
+ On Linux, returns True if either $DISPLAY is set and XOpenDisplay(NULL)
206
+ succeeds. Use this function if you need to specifically check for X11
207
+ only (e.g., for Tkinter).
208
+
186
209
On other platforms, always returns True.)""" );
187
210
m.def (
188
211
" Win32_GetCurrentProcessExplicitAppUserModelID" ,
0 commit comments