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.
This commit is contained in:
Campbell Barton 2022-10-10 10:56:05 +11:00
parent 210f4db81c
commit a24f11e0ec
9 changed files with 93 additions and 5 deletions

View File

@ -36,6 +36,10 @@ extern GHOST_SystemHandle GHOST_CreateSystemBackground(void);
*/
extern void GHOST_SystemInitDebug(GHOST_SystemHandle systemhandle, GHOST_Debug debug);
#if !(defined(WIN32) || defined(__APPLE__))
extern const char *GHOST_SystemBackend(void);
#endif
/**
* Disposes the one and only system.
* \param systemhandle: The handle to the system.

View File

@ -134,6 +134,15 @@ class GHOST_ISystem {
* \return A pointer to the system.
*/
static GHOST_ISystem *getSystem();
/**
* Return an identifier for the one and only system.
* \warning while it may be tempting this should never be used to check for supported features,
* in that case, the GHOST API should be extended to query capabilities.
* This is needed for X11/WAYLAND on Unix, without this - there is no convenient way for users to
* check if WAYLAND or XWAYLAND are in use since they are dynamically selected at startup.
* When dynamically switching between X11/WAYLAND is removed, this function can go too.
*/
static const char *getSystemBackend();
static GHOST_TBacktraceFn getBacktraceFn();
static void setBacktraceFn(GHOST_TBacktraceFn backtrace_fn);
@ -515,6 +524,7 @@ class GHOST_ISystem {
/** The one and only system */
static GHOST_ISystem *m_system;
static const char *m_system_backend_id;
/** Function to call that sets the back-trace. */
static GHOST_TBacktraceFn m_backtrace_fn;

View File

@ -52,6 +52,13 @@ GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle)
return system->disposeSystem();
}
#if !(defined(WIN32) || defined(__APPLE__))
const char *GHOST_SystemBackend()
{
return GHOST_ISystem::getSystemBackend();
}
#endif
void GHOST_ShowMessageBox(GHOST_SystemHandle systemhandle,
const char *title,
const char *message,

View File

@ -30,6 +30,7 @@
#endif
GHOST_ISystem *GHOST_ISystem::m_system = nullptr;
const char *GHOST_ISystem::m_system_backend_id = nullptr;
GHOST_TBacktraceFn GHOST_ISystem::m_backtrace_fn = nullptr;
@ -122,7 +123,10 @@ GHOST_TSuccess GHOST_ISystem::createSystem(bool verbose)
m_system = new GHOST_SystemCocoa();
#endif
if ((m_system == nullptr) && verbose) {
if (m_system) {
m_system_backend_id = backends_attempted[backends_attempted_num - 1];
}
else if (verbose) {
fprintf(stderr, "GHOST: failed to initialize display for back-end(s): [");
for (int i = 0; i < backends_attempted_num; i++) {
if (i != 0) {
@ -186,6 +190,11 @@ GHOST_ISystem *GHOST_ISystem::getSystem()
return m_system;
}
const char *GHOST_ISystem::getSystemBackend()
{
return m_system_backend_id;
}
GHOST_TBacktraceFn GHOST_ISystem::getBacktraceFn()
{
return GHOST_ISystem::m_backtrace_fn;

View File

@ -53,6 +53,13 @@ def write_sysinfo(filepath):
output.write("build linkflags: %s\n" % prepr(bpy.app.build_linkflags))
output.write("build system: %s\n" % prepr(bpy.app.build_system))
# Windowing Environment (include when dynamically selectable).
from _bpy import _ghost_backend
ghost_backend = _ghost_backend()
if ghost_backend not in {'NONE', 'DEFAULT'}:
output.write("windowing environment: %s\n" % prepr(ghost_backend))
del _ghost_backend, ghost_backend
# Python info.
output.write(title("Python"))
output.write("version: %s\n" % (sys.version.replace("\n", " ")))

View File

@ -3158,6 +3158,15 @@ class WM_MT_splash_about(Menu):
bpy.app.build_commit_time.decode('utf-8', 'replace')), translate=False)
col.label(text=iface_("Hash: %s") % bpy.app.build_hash.decode('ascii'), translate=False)
col.label(text=iface_("Branch: %s") % bpy.app.build_branch.decode('utf-8', 'replace'), translate=False)
# This isn't useful information on MS-Windows or Apple systems as dynamically switching
# between windowing systems is only supported between X11/WAYLAND.
from _bpy import _ghost_backend
ghost_backend = _ghost_backend()
if ghost_backend not in {'NONE', 'DEFAULT'}:
col.label(text=iface_("Windowing Environment: %s") % _ghost_backend(), translate=False)
del _ghost_backend, ghost_backend
col.separator(factor=2.0)
col.label(text="Blender is free software")
col.label(text="Licensed under the GNU General Public License")

View File

@ -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},
};

View File

@ -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);

View File

@ -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
}
/** \} */
/* -------------------------------------------------------------------- */