Skip to content

facade: frontend/widgets/OBSBasic.cpp and OBSBasic.hpp: move 27 platform conditionals behind frontend/utility/platform.hpp #871

Closed

Description

@zackees

Part of #847.

Inventory of platform conditionals in frontend/widgets/OBSBasic.cpp and OBSBasic.hpp measured on origin/master. Total: 27.

Conditionals

File Line Macro What the branch does
OBSBasic.cpp 47 _WIN32 or WHATSNEW_ENABLED include WhatsNewInfoThread.hpp
OBSBasic.cpp 58 ENABLE_WAYLAND include obs-nix-platform.h
OBSBasic.cpp 71 _WIN32 include windows.h
OBSBasic.cpp 372 __APPLE__ rename scene/source shortcut is Return
OBSBasic.cpp 388 __linux__ Exit shortcut Ctrl+Q
OBSBasic.cpp 475 !__APPLE__ connect aboutToQuit to closeWindow
OBSBasic.cpp 490 __APPLE__ DEFAULT_CONTAINER "hybrid_mov" vs the non-mac default
OBSBasic.cpp 933 _WIN32 && !_DEBUG LoadLibraryW(Qt6Network)
OBSBasic.cpp 1063 _WIN32 SetWin32DropStyle
OBSBasic.cpp 1073 ENABLE_WAYLAND isWayland detection
OBSBasic.cpp 1090 !_WIN32 show() window early unless hidden on start
OBSBasic.cpp 1168 __APPLE__ disableColorSpaceConversion(this)
OBSBasic.cpp 1184 (_WIN32 or __APPLE__) && pre-release automatically opt in to beta channel
OBSBasic.cpp 1212 !_WIN32 delete Repair action
OBSBasic.cpp 1215 !__APPLE__ delete crash-log actions (nested)
OBSBasic.cpp 1227 __APPLE__ delete Fullscreen Interface action
OBSBasic.cpp 1237 _WIN32 or __APPLE__ disable Check-for-Updates if updater disabled
OBSBasic.cpp 1240 _WIN32 disable Repair action (nested)
OBSBasic.cpp 1304 !__APPLE__ sendPostedEvents DeferredDelete
OBSBasic.cpp 1643 _WIN32 nativeEvent MSG handling
OBSBasic.cpp 1939 !__APPLE__ deleteLater() in close path
OBSBasic.cpp 2069 _WIN32 HWND-based window handling
OBSBasic.hpp 166 _WIN32 UpdateProcessPriority() inline
OBSBasic.hpp 726 __APPLE__ tray mask icon (active)
OBSBasic.hpp 748 __APPLE__ tray icon file (idle)
OBSBasic.hpp 758 __APPLE__ tray icon file (paused)
OBSBasic.hpp 767 __APPLE__ tray icon file (active)

Proposed facade operations

Declared in frontend/utility/platform.hpp; implemented in frontend/utility/platform-windows.cpp, platform-osx.mm, platform-x11.cpp (Linux/BSD). Names are proposals; one facade function per logical operation, moves kept small and mechanical so upstream merges stay manageable.

Facade function Implementation
platform_tray_icon(TrayState) returning QIcon (mask on macOS) osx returns *_macos.svg masks; others default icons. Shared with OBSBasic_SysTray / OBSBasic_Recording (see sibling issue)
platform_default_recording_container() osx: hybrid_mov, others the existing default
platform_set_main_window_shortcuts(ui) / platform_prune_menu_actions(ui, updater_disabled) osx: Return rename, delete fullscreen; windows: Repair; x11: Ctrl+Q
platform_window_post_create(QMainWindow*) / platform_window_pre_show(...) (drop style, colour-space conversion, Wayland check, Qt6Network preload) per platform
platform_handle_native_event(QByteArray, void*, qintptr*) windows: MSG; others false
platform_close_cleanup(QObject*) (deleteLater vs deferred-delete flush) osx differs
platform_update_process_priority() windows; no-op elsewhere
platform_is_wayland() x11 (ENABLE_WAYLAND stays inside platform-x11.cpp)

Likely must stay / caveats

  • Includes at 47, 58, 71 move into the platform impl files; WHATSNEW_ENABLED is a feature flag and stays.
  • OBSBasic.hpp inline functions become non-inline facade calls so no #if is left in headers.

Test approach

Characterisation tests for platform_default_recording_container and pure constants; UI behaviour (menus, tray, close) covered by native builds (ci-full).

RED first (failing characterisation test or facade stub), then GREEN, per docs/rust-port/testing-policy.md. Add the ci-full label since this touches shared frontend code built natively on all platforms.

Done when the listed files have no platform conditionals other than the documented exceptions, and the ratchet baseline (#848) is lowered accordingly.

Activity

  1. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Claiming: #871 (frontend/widgets/OBSBasic.cpp.hpp, 18 findings, plus OBSBasic.hpp, 5).

    Plan, following #865 and #867: self-guarded frontend/widgets/obsbasic-{windows,macos,linux}.hpp headers in the widgets PCH that define feature macros such as OBS_BASIC_MACOS_MENU, OBS_BASIC_WINDOWS_TASKBAR and OBS_BASIC_UPDATER, plus small inline hooks. OBSBasic tests those instead of OS macros.

    1. OBSBasic.cpp.hpp: dock/menu setup, the macOS menu, Windows startup bits, updater checks and the Wayland/X11 bits.
    2. OBSBasic.hpp: its _WIN32 member and its __APPLE__ declarations. This is a frontend-internal header, not public API, so moving them doesn't touch any public C header.

    First PR expected within a day.

  2. added
    claimed
    on Oct 24, 2026
  3. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Done in #2183. OBSBasic.cpp.hpp and OBSBasic.hpp now test feature macros instead of platforms:

    • OBS_BASIC_WINDOWS
    • OBS_BASIC_MACOS
    • OBS_BASIC_UPDATER
    • OBS_BASIC_CRASH_LOGS
    • OBS_BASIC_QUIT_SHORTCUT
    • OBS_BASIC_PROCESS_PRIORITY
    • the tray icon macros and DEFAULT_CONTAINER

    The self-guarded frontend/widgets/obsbasic-{windows,macos,linux}.hpp headers, included from OBSBasic.hpp, define them. All 23 findings have left the ratchet baseline, and test_frontend_obsbasic_host pins the Linux feature set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions