diff --git a/changes/4572.feature.md b/changes/4572.feature.md new file mode 100644 index 0000000000..a800dc88ad --- /dev/null +++ b/changes/4572.feature.md @@ -0,0 +1 @@ +Force Wayland on WSL2 if the WSL2 GUI apps feature is enabled diff --git a/gtk/src/toga_gtk/libs/gtk.py b/gtk/src/toga_gtk/libs/gtk.py index 0880b8d265..ec89812182 100644 --- a/gtk/src/toga_gtk/libs/gtk.py +++ b/gtk/src/toga_gtk/libs/gtk.py @@ -98,7 +98,12 @@ "environment variable set correctly?" ) -IS_WAYLAND = not isinstance(Gdk.Display.get_default(), GdkX11.X11Display) +IS_WSL2_GUI_ENABLED = os.getenv("WSL2_GUI_APPS_ENABLED", "0") == "1" + +# Force Wayland on WSL2 if the WSL2 GUI apps feature is enabled +IS_WAYLAND = ( + not isinstance(Gdk.Display.get_default(), GdkX11.X11Display) or IS_WSL2_GUI_ENABLED +) # The following imports will fail if the underlying libraries or their API wrappers # aren't installed; handle failure gracefully (see