diff options
author | Campbell Barton <campbell@blender.org> | 2022-10-10 02:56:05 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-10-10 03:22:41 +0300 |
commit | a24f11e0ec96ef9f4298f5ffe754146aa8319b72 (patch) | |
tree | 063916e2a4f122e04b79c61526627f0c9da6de69 /source | |
parent | 210f4db81c8d5501b27e75f7e9718fb1c52a5d8a (diff) |
UI: show the windowing environment in the "About" splash
Show the windowing environment on non MS-Windows/Apple systems,
since X11/WAYLAND are selected startup there was no convenient way
for users to know which back-end was being used.
Include the windowing environment in the About splash & system-info.txt
since it will be useful for handling bug reports.
This commit adds a private API call not intended for general use
as I would like to be able to remove this later and it's only needed
in the specific case of testing if Blender is using WAYLAND or X11
(which maybe be used via XWayland).
Python scripts can already inspect the system to check which windowing
environment used, the API call is mainly useful for troubleshooting.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/intern/bpy.c | 25 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 7 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 18 |
3 files changed, 46 insertions, 4 deletions
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 77710d6df37..36d53d69eff 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -29,6 +29,8 @@ #include "GPU_state.h" +#include "WM_api.h" /* For #WM_ghost_backend */ + #include "bpy.h" #include "bpy_app.h" #include "bpy_capi_utils.h" @@ -536,6 +538,17 @@ static PyObject *bpy_rna_enum_items_static(PyObject *UNUSED(self)) return result; } +/* This is only exposed for (Unix/Linux), see: #GHOST_ISystem::getSystemBackend for details. */ +PyDoc_STRVAR(bpy_ghost_backend_doc, + ".. function:: _ghost_backend()\n" + "\n" + " :return: An identifier for the GHOST back-end.\n" + " :rtype: string\n"); +static PyObject *bpy_ghost_backend(PyObject *UNUSED(self)) +{ + return PyUnicode_FromString(WM_ghost_backend()); +} + static PyMethodDef bpy_methods[] = { {"script_paths", (PyCFunction)bpy_script_paths, METH_NOARGS, bpy_script_paths_doc}, {"blend_paths", @@ -552,10 +565,6 @@ static PyMethodDef bpy_methods[] = { (PyCFunction)bpy_resource_path, METH_VARARGS | METH_KEYWORDS, bpy_resource_path_doc}, - {"_driver_secure_code_test", - (PyCFunction)bpy_driver_secure_code_test, - METH_VARARGS | METH_KEYWORDS, - bpy_driver_secure_code_test_doc}, {"escape_identifier", (PyCFunction)bpy_escape_identifier, METH_O, bpy_escape_identifier_doc}, {"unescape_identifier", (PyCFunction)bpy_unescape_identifier, @@ -566,6 +575,14 @@ static PyMethodDef bpy_methods[] = { (PyCFunction)bpy_rna_enum_items_static, METH_NOARGS, bpy_rna_enum_items_static_doc}, + + /* Private functions (not part of the public API and may be removed at any time). */ + {"_driver_secure_code_test", + (PyCFunction)bpy_driver_secure_code_test, + METH_VARARGS | METH_KEYWORDS, + bpy_driver_secure_code_test_doc}, + {"_ghost_backend", (PyCFunction)bpy_ghost_backend, METH_NOARGS, bpy_ghost_backend_doc}, + {NULL, NULL, 0, NULL}, }; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 5b6f7939ab9..1f9de8040f6 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -119,6 +119,13 @@ void WM_init_splash(struct bContext *C); void WM_init_opengl(void); +/** + * Return an identifier for the underlying GHOST implementation. + * \warning Use of this function should be limited & never for compatibility checks. + * see: #GHOST_ISystem::getSystemBackend for details. + */ +const char *WM_ghost_backend(void); + void WM_check(struct bContext *C); void WM_reinit_gizmomap_all(struct Main *bmain); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index a4f92da2774..b1b13390932 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -91,6 +91,9 @@ /* the global to talk to ghost */ static GHOST_SystemHandle g_system = NULL; +#if !(defined(WIN32) || defined(__APPLE__)) +static const char *g_system_backend_id = NULL; +#endif typedef enum eWinOverrideFlag { WIN_OVERRIDE_GEOM = (1 << 0), @@ -1552,6 +1555,9 @@ void wm_ghost_init(bContext *C) /* This will leak memory, it's preferable to crashing. */ exit(1); } +#if !(defined(WIN32) || defined(__APPLE__)) + g_system_backend_id = GHOST_SystemBackend(); +#endif GHOST_Debug debug = {0}; if (G.debug & G_DEBUG_GHOST) { @@ -1597,6 +1603,18 @@ void wm_ghost_exit(void) g_system = NULL; } +const char *WM_ghost_backend(void) +{ +#if !(defined(WIN32) || defined(__APPLE__)) + return g_system_backend_id ? g_system_backend_id : "NONE"; +#else + /* While this could be supported, at the moment it's only needed with GHOST X11/WAYLAND + * to check which was selected and the API call may be removed after that's no longer needed. + * Use dummy values to prevent this being used on other systems. */ + return g_system ? "DEFAULT" : "NONE"; +#endif +} + /** \} */ /* -------------------------------------------------------------------- */ |