Skip to content

Replace private/public macro hacks in waylib with explicit member accessors#873

Closed
Copilot wants to merge 2 commits into
masterfrom
copilot/refactor-private-access
Closed

Replace private/public macro hacks in waylib with explicit member accessors#873
Copilot wants to merge 2 commits into
masterfrom
copilot/refactor-private-access

Conversation

Copy link
Copy Markdown

Copilot AI commented May 18, 2026

This change removes the #define private public / #define protected public pattern used in waylib/src/server, which can silently alter unrelated declarations and make Qt private-header usage brittle. The refactor keeps the existing access points but moves them to a scoped, explicit mechanism.

  • Accessor mechanism

    • Add waylib/src/server/utils/memberaccessor_p.h
    • Implement a small explicit-instantiation-based accessor utility for private members/functions, following the same class of approach as cpp-member-accessor
    • Replace broad preprocessor visibility rewriting with per-member accessor declarations at each call site
  • Qt/QtQuick private access cleanup

    • Migrate private-member access in:
      • kernel/wcursor.cpp
      • kernel/wserver.cpp
      • qtquick/wqmlcreator.cpp
      • qtquick/woutputrenderwindow.cpp
      • qtquick/private/wqmlhelper.cpp
      • qtquick/private/wbufferrenderer.cpp
      • qtquick/private/wrenderbuffernode.cpp
    • Remove the corresponding private/protected -> public macro blocks from these files and related headers
  • QPA screen handling

    • Replace direct QScreen private-constructor access in platformplugin/qwlrootsintegration.cpp
    • For non-master mode, create the QScreen wrapper through QWindowSystemInterface::handleScreenAdded() and then detach it from QGuiApplication::screens() to preserve the previous behavior without using the private constructor directly
  • Surface area reduction

    • Drop now-unneeded macro-based include hacks from qwlrootsintegration.h, wqmlhelper_p.h, and wbufferrenderer_p.h
    • Keep the refactor local to the existing private access points rather than widening the abstraction boundary

Example of the new pattern:

WAYLIB_DECLARE_PRIVATE_ACCESSOR(QCursorDataShapeAccessor,
                                Qt::CursorShape QCursorData::*,
                                &QCursorData::cshape);

auto *cursorData = Waylib::PrivateAccessor::member<QCursorDataPointerAccessor>(cursor);
Waylib::PrivateAccessor::member<QCursorDataShapeAccessor>(*cursorData) =
    static_cast<Qt::CursorShape>(shape);

Copilot AI and others added 2 commits May 18, 2026 10:02
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Copilot, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Copilot

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot
Copy link
Copy Markdown

Hi @Copilot. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented May 22, 2026

TAG Bot

New tag: 0.8.7
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #886

@zccrs
Copy link
Copy Markdown
Member

zccrs commented May 25, 2026

已解决,这个pr不需要了

@zccrs zccrs closed this May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants