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.
This commit is contained in:
Campbell Barton 2022-12-15 11:48:08 +11:00
parent 230744d6fd
commit c969a533f9
Notes: blender-bot 2023-12-08 16:39:08 +01:00
Referenced by issue #102967, 3.4: Potential candidates for corrective releases
2 changed files with 26 additions and 0 deletions

View File

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

View File

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