diff options
-rw-r--r-- | intern/ghost/GHOST_C-api.h | 4 | ||||
-rw-r--r-- | intern/ghost/GHOST_ISystem.h | 10 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_C-api.cpp | 7 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ISystem.cpp | 11 | ||||
-rw-r--r-- | release/scripts/modules/sys_info.py | 7 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/wm.py | 9 | ||||
-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 |
9 files changed, 93 insertions, 5 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index c9d18be750d..7fda535a7ac 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -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. diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index 0bf540bd4b6..9fb94ed1525 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -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; diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index 69fc6b5f2d0..158e979cdf2 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -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, diff --git a/intern/ghost/intern/GHOST_ISystem.cpp b/intern/ghost/intern/GHOST_ISystem.cpp index 304d7f0abe6..0a35d1af5a4 100644 --- a/intern/ghost/intern/GHOST_ISystem.cpp +++ b/intern/ghost/intern/GHOST_ISystem.cpp @@ -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; diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py index 026c39908c0..7f6d0b1e9bf 100644 --- a/release/scripts/modules/sys_info.py +++ b/release/scripts/modules/sys_info.py @@ -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", " "))) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 9d04cfd5bc8..3b81f75b08a 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -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") 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 +} + /** \} */ /* -------------------------------------------------------------------- */ |