From f2b01dbcb8a5c027fcd386f3f45e6ef720a31081 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Jul 2025 10:57:17 +1000 Subject: [PATCH] Cleanup: order capability flags as defined When setting GHOST capability flags, use the order they are defined to make the code easier to follow when manually updating. --- intern/ghost/intern/GHOST_SystemCocoa.mm | 7 +++-- intern/ghost/intern/GHOST_SystemHeadless.hh | 33 +++++++++++++++++---- intern/ghost/intern/GHOST_SystemSDL.cc | 11 +++---- intern/ghost/intern/GHOST_SystemWayland.cc | 12 ++++---- intern/ghost/intern/GHOST_SystemWin32.cc | 1 + intern/ghost/intern/GHOST_SystemX11.cc | 22 +++++++------- 6 files changed, 57 insertions(+), 29 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 64df895c5d2..48c0e037a1f 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -971,14 +971,15 @@ GHOST_TCapabilityFlag GHOST_SystemCocoa::getCapabilities() const { return GHOST_TCapabilityFlag( GHOST_CAPABILITY_FLAG_ALL & + /* NOTE: order the following flags as they they're declared in the source. */ ~( /* Cocoa has no support for a primary selection clipboard. */ GHOST_kCapabilityPrimaryClipboard | - /* No support yet for RGBA mouse cursors. */ - GHOST_kCapabilityRGBACursors | /* Cocoa doesn't define a Hyper modifier key, * it's possible another modifier could be optionally used in it's place. */ - GHOST_kCapabilityKeyboardHyperKey)); + GHOST_kCapabilityKeyboardHyperKey | + /* No support yet for RGBA mouse cursors. */ + GHOST_kCapabilityRGBACursors)); } /* -------------------------------------------------------------------- diff --git a/intern/ghost/intern/GHOST_SystemHeadless.hh b/intern/ghost/intern/GHOST_SystemHeadless.hh index e41bf7f3655..0ed14d338a9 100644 --- a/intern/ghost/intern/GHOST_SystemHeadless.hh +++ b/intern/ghost/intern/GHOST_SystemHeadless.hh @@ -50,12 +50,33 @@ class GHOST_SystemHeadless : public GHOST_System { { return GHOST_TCapabilityFlag( GHOST_CAPABILITY_FLAG_ALL & - /* No windowing functionality supported. */ - ~(GHOST_kCapabilityWindowPosition | GHOST_kCapabilityCursorWarp | - GHOST_kCapabilityPrimaryClipboard | GHOST_kCapabilityDesktopSample | - GHOST_kCapabilityClipboardImages | GHOST_kCapabilityInputIME | - GHOST_kCapabilityWindowDecorationStyles | GHOST_kCapabilityKeyboardHyperKey | - GHOST_kCapabilityRGBACursors)); + /* No windowing functionality supported. + * In most cases this value doesn't matter for the headless backend. + * + * Nevertheless, don't advertise support. + * + * NOTE: order the following flags as they they're declared in the source. */ + ~( + /* Wrap. */ + GHOST_kCapabilityWindowPosition | + /* Wrap. */ + GHOST_kCapabilityCursorWarp | + /* Wrap. */ + GHOST_kCapabilityPrimaryClipboard | + /* Wrap. */ + GHOST_kCapabilityClipboardImages | + /* Wrap. */ + GHOST_kCapabilityDesktopSample | + /* Wrap. */ + GHOST_kCapabilityInputIME | + /* Wrap. */ + GHOST_kCapabilityWindowDecorationStyles | + /* Wrap. */ + GHOST_kCapabilityKeyboardHyperKey | + /* Wrap. */ + GHOST_kCapabilityRGBACursors) + + ); } char *getClipboard(bool /*selection*/) const override { diff --git a/intern/ghost/intern/GHOST_SystemSDL.cc b/intern/ghost/intern/GHOST_SystemSDL.cc index 16fbbf51b23..f0fbd3e1da3 100644 --- a/intern/ghost/intern/GHOST_SystemSDL.cc +++ b/intern/ghost/intern/GHOST_SystemSDL.cc @@ -784,21 +784,22 @@ GHOST_TCapabilityFlag GHOST_SystemSDL::getCapabilities() const { return GHOST_TCapabilityFlag( GHOST_CAPABILITY_FLAG_ALL & + /* NOTE: order the following flags as they they're declared in the source. */ ~( /* This SDL back-end has not yet implemented primary clipboard. */ GHOST_kCapabilityPrimaryClipboard | - /* This SDL back-end has not yet implemented color sampling the desktop. */ - GHOST_kCapabilityDesktopSample | /* This SDL back-end has not yet implemented image copy/paste. */ GHOST_kCapabilityClipboardImages | + /* This SDL back-end has not yet implemented color sampling the desktop. */ + GHOST_kCapabilityDesktopSample | /* No support yet for IME input methods. */ GHOST_kCapabilityInputIME | - /* No support yet for RGBA mouse cursors. */ - GHOST_kCapabilityRGBACursors | /* No support for window decoration styles. */ GHOST_kCapabilityWindowDecorationStyles | /* No support for a Hyper modifier key. */ - GHOST_kCapabilityKeyboardHyperKey)); + GHOST_kCapabilityKeyboardHyperKey | + /* No support yet for RGBA mouse cursors. */ + GHOST_kCapabilityRGBACursors)); } char *GHOST_SystemSDL::getClipboard(bool /*selection*/) const diff --git a/intern/ghost/intern/GHOST_SystemWayland.cc b/intern/ghost/intern/GHOST_SystemWayland.cc index 2c26776564a..dd71f1a44f0 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cc +++ b/intern/ghost/intern/GHOST_SystemWayland.cc @@ -8776,6 +8776,7 @@ GHOST_TCapabilityFlag GHOST_SystemWayland::getCapabilities() const return GHOST_TCapabilityFlag( GHOST_CAPABILITY_FLAG_ALL & + /* NOTE: order the following flags as they they're declared in the source. */ ~( /* WAYLAND doesn't support accessing the window position. */ GHOST_kCapabilityWindowPosition | @@ -8796,14 +8797,15 @@ GHOST_TCapabilityFlag GHOST_SystemWayland::getCapabilities() const GHOST_kCapabilityGPUReadFrontBuffer | /* This WAYLAND back-end has not yet implemented desktop color sample. */ GHOST_kCapabilityDesktopSample | + /* This flag will eventually be removed when support + * for the old track-pad protocol is dropped. */ + ((has_wl_trackpad_physical_direction == 1) ? + 0 : + GHOST_kCapabilityTrackpadPhysicalDirection) | /* This WAYLAND back-end doesn't have support for window decoration styles. * In all likelihood, this back-end will eventually need to support client-side * decorations, see #113795. */ - GHOST_kCapabilityWindowDecorationStyles | - /* This flag will eventually be removed. */ - ((has_wl_trackpad_physical_direction == 1) ? - 0 : - GHOST_kCapabilityTrackpadPhysicalDirection))); + GHOST_kCapabilityWindowDecorationStyles)); } bool GHOST_SystemWayland::cursor_grab_use_software_display_get(const GHOST_TGrabCursorMode mode) diff --git a/intern/ghost/intern/GHOST_SystemWin32.cc b/intern/ghost/intern/GHOST_SystemWin32.cc index b977c9584d0..a5df0b8f577 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cc +++ b/intern/ghost/intern/GHOST_SystemWin32.cc @@ -610,6 +610,7 @@ GHOST_TCapabilityFlag GHOST_SystemWin32::getCapabilities() const { return GHOST_TCapabilityFlag( GHOST_CAPABILITY_FLAG_ALL & + /* NOTE: order the following flags as they they're declared in the source. */ ~( /* WIN32 has no support for a primary selection clipboard. */ GHOST_kCapabilityPrimaryClipboard | diff --git a/intern/ghost/intern/GHOST_SystemX11.cc b/intern/ghost/intern/GHOST_SystemX11.cc index e83386ec3f8..47365b457a0 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cc +++ b/intern/ghost/intern/GHOST_SystemX11.cc @@ -1818,16 +1818,18 @@ GHOST_TSuccess GHOST_SystemX11::setCursorPosition(int32_t x, int32_t y) GHOST_TCapabilityFlag GHOST_SystemX11::getCapabilities() const { - return GHOST_TCapabilityFlag(GHOST_CAPABILITY_FLAG_ALL & - ~( - /* No support yet for image copy/paste. */ - GHOST_kCapabilityClipboardImages | - /* No support yet for IME input methods. */ - GHOST_kCapabilityInputIME | - /* No support yet for RGBA mouse cursors. */ - GHOST_kCapabilityRGBACursors | - /* No support for window decoration styles. */ - GHOST_kCapabilityWindowDecorationStyles)); + return GHOST_TCapabilityFlag( + GHOST_CAPABILITY_FLAG_ALL & + /* NOTE: order the following flags as they they're declared in the source. */ + ~( + /* No support yet for image copy/paste. */ + GHOST_kCapabilityClipboardImages | + /* No support yet for IME input methods. */ + GHOST_kCapabilityInputIME | + /* No support for window decoration styles. */ + GHOST_kCapabilityWindowDecorationStyles | + /* No support yet for RGBA mouse cursors. */ + GHOST_kCapabilityRGBACursors)); } void GHOST_SystemX11::addDirtyWindow(GHOST_WindowX11 *bad_wind)