Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xwayland warning removed; documented; and debug info now contains whether x11 is running or xwayland #2823

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions docs/reST/ref/display.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ required).
::

Windows : windib, directx
Unix : x11, dga, fbcon, directfb, ggi, vgl, svgalib, aalib
Unix : x11, dga, fbcon, directfb, ggi, vgl, svgalib, aalib, wayland

:note: On wayland desktops, pygame-ce may choose to use the X11 video driver to run on Xwayland.
This behaviour is determined by the SDL library and might change in the future, so it's suggested
to account for this and not rely on the default behavior. The Wayland video driver can be forced
by setting the ``SDL_VIDEODRIVER`` environment variable to ``"wayland"``

On some platforms it is possible to embed the pygame display into an already
existing window. To do this, the environment variable ``SDL_WINDOWID`` must
Expand All @@ -86,6 +91,8 @@ required).

It is harmless to call this more than once, repeated calls have no effect.

.. versionchanged:: 2.5.0 the manylinux wheels distributed by us now support the ``wayland`` videodriver

.. ## pygame.display.init ##

.. function:: quit
Expand Down Expand Up @@ -214,6 +221,8 @@ required).

.. deprecated:: 2.4.0 The depth argument is ignored, and will be set to the optimal value

.. versionchanged:: 2.5.0 No longer emits warning when running on xwayland, see :func:`pygame.display.init` for details on running on wayland directly


Basic example:

Expand Down Expand Up @@ -836,6 +845,6 @@ required).
just like standard Python list indexing.

.. versionadded:: 2.4.0


.. ## pygame.display ##
17 changes: 0 additions & 17 deletions src_c/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,23 +1357,6 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
if (state->icon)
SDL_SetWindowIcon(win, pgSurface_AsSurface(state->icon));

if (!SDL_GetWindowWMInfo(win, &wm_info)) {
// don't complain, might be null mode
}
else if (wm_info.subsystem == SDL_SYSWM_X11) {
char *xdg_session_type = SDL_getenv("XDG_SESSION_TYPE");
char *wayland_display = SDL_getenv("WAYLAND_DISPLAY");
if (NULL != wayland_display ||
(NULL != xdg_session_type &&
SDL_strcmp(xdg_session_type, "wayland") == 0)) {
if (PyErr_WarnEx(PyExc_Warning,
"PyGame seems to be running through X11 "
"on top of wayland, instead of wayland directly",
1) != 0)
return NULL;
}
}

if (depth != 0 && PG_SURF_BitsPerPixel(surface->surf) != depth) {
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"The depth argument is deprecated, and is ignored",
Expand Down
10 changes: 9 additions & 1 deletion src_py/_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import traceback
import importlib
from typing import Tuple, Optional, Callable
from os import environ

from pygame.version import ver

Expand Down Expand Up @@ -156,7 +157,14 @@ def default_return(linked=True):
)

if display_init():
debug_str += f"Display Driver:\t\t{get_display_driver()}\n"
driver = get_display_driver()
if driver.upper() != "X11":
debug_str += f"Display Driver:\t\t{driver}\n"
else:
is_xwayland = (environ.get("XDG_SESSION_TYPE") == "wayland") or (
"WAYLAND_DISPLAY" in environ
)
debug_str += f"Display Driver:\t\t{driver} ( xwayland == {is_xwayland} )\n"
else:
debug_str += "Display Driver:\t\tDisplay Not Initialized\n"

Expand Down
Loading