Commit: c969a533f9c1b0e93d066331993286f8ee309d9c Author: Campbell Barton Date: Thu Dec 15 11:48:08 2022 +1100 Branches: master https://developer.blender.org/rBc969a533f9c1b0e93d066331993286f8ee309d9c
WM: support checking windowing capabilities Historically checks for windowing capabilities used platform pre-processor checks however that doesn't work when Blender is built with both X11 & Wayland. Add a capabilities flag which can be used to check which functionality is supported. This has the advantage of being more descriptive/readable. =================================================================== M source/blender/windowmanager/WM_api.h M source/blender/windowmanager/intern/wm_window.c =================================================================== diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 264b76472f7..df5659845fe 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -126,6 +126,15 @@ void WM_init_opengl(void); */ const char *WM_ghost_backend(void); +typedef enum eWM_CapabilitiesFlag { + /** Ability to warp the cursor (set it's location). */ + WM_CAPABILITY_CURSOR_WARP = (1 << 0), + /** Ability to access window positions & move them. */ + WM_CAPABILITY_WINDOW_POSITION = (1 << 1), +} eWM_CapabilitiesFlag; + +eWM_CapabilitiesFlag WM_capabilities_flag(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 f5dc18bb16e..7ee074660b0 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -1646,6 +1646,23 @@ GHOST_TDrawingContextType wm_ghost_drawing_context_type(const eGPUBackendType gp return GHOST_kDrawingContextTypeNone; } +eWM_CapabilitiesFlag WM_capabilities_flag(void) +{ + static eWM_CapabilitiesFlag flag = -1; + if (flag != -1) { + return flag; + } + + flag = 0; + if (GHOST_SupportsCursorWarp()) { + flag |= WM_CAPABILITY_CURSOR_WARP; + } + if (GHOST_SupportsWindowPosition()) { + flag |= WM_CAPABILITY_WINDOW_POSITION; + } + return flag; +} + /** \} */ /* -------------------------------------------------------------------- */ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs