Skip to content

fix: Fix secondary screen highlight display anomaly in 90° and 270° rotation#3178

Open
leibn123 wants to merge 1 commit intolinuxdeepin:masterfrom
leibn123:temp
Open

fix: Fix secondary screen highlight display anomaly in 90° and 270° rotation#3178
leibn123 wants to merge 1 commit intolinuxdeepin:masterfrom
leibn123:temp

Conversation

@leibn123
Copy link
Copy Markdown
Contributor

@leibn123 leibn123 commented Apr 17, 2026

1.修改副屏旋转90度和270度的高亮显示异常问题

PMS: BUG-355449

Summary by Sourcery

Fix secondary display highlight behavior and screen selection persistence when displays are rotated.

Bug Fixes:

  • Correct screen matching for X11 indicator creation when the display is rotated 90° or 270° so the proper Qt screen is targeted.
  • Ensure the active screen highlight and tab selection correctly track the currently selected virtual screen instead of desynchronizing after rotation or screen list changes.
  • Hide the screen highlight component when a display item is not selected to avoid incorrect visual emphasis.

Enhancements:

  • Persist and restore the last selected screen by name when the virtual screen list changes so user selection is maintained across updates.

…otation

1.修改副屏旋转90度和270度的高亮显示异常问题

PMS: BUG-355449
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: leibn123

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 @leibn123. 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.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 17, 2026

Reviewer's Guide

Adjusts how the selected/highlighted display is determined and rendered, particularly for rotated secondary screens, and preserves the last selected screen across virtual screen updates so that highlighting and indicator placement remain correct after rotation or configuration changes.

Sequence diagram for screen selection and highlight/indicator update

sequenceDiagram
    actor User
    participant DisplayMain as DisplayMain_qml
    participant ScreenItem as ScreenItem_qml
    participant dccData
    participant QtScreens as Qt_application_screens
    participant Indicator as indicator_component

    User->>ScreenItem: click()
    ScreenItem->>DisplayMain: onPressed / onScreenClicked(screen)
    DisplayMain->>DisplayMain: set root.screen = screen
    DisplayMain->>DisplayMain: set lastScreenName = screen.name

    alt dccData.isX11
        DisplayMain->>DisplayMain: getQtScreen(screen)
        loop for_each_s_in_Qt_application_screens
            DisplayMain->>QtScreens: read s.virtualX, s.virtualY, s.width, s.height, s.devicePixelRatio
            DisplayMain->>DisplayMain: isRotated = (screen.rotate == 2 || screen.rotate == 8)
            DisplayMain->>DisplayMain: targetW = isRotated ? screen.currentResolution.height : screen.currentResolution.width
            DisplayMain->>DisplayMain: targetH = isRotated ? screen.currentResolution.width : screen.currentResolution.height
            alt match_position_and_size
                DisplayMain-->>DisplayMain: return s
            end
        end
        DisplayMain-->>Indicator: createObject(parent, screen = matched_s)
    else not dccData.isX11
        DisplayMain-->>DisplayMain: no indicator created
    end

    DisplayMain->>ScreenItem: selected = (root.screen === item.screen && screen.rotate !== undefined)
    ScreenItem->>ScreenItem: Loader.active = selected
    ScreenItem->>ScreenItem: Loader.visible = selected
Loading

Class diagram for updated display selection and highlighting logic

classDiagram
    class DisplayMain_qml {
        +var screen
        +string lastScreenName
        +var activeDialogs
        +var scaleModelConst
        +getQtScreen(screen)
        +getControlCenterScreen()
        +closeInvalidDialogs()
        +onVirtualScreensChanged()
    }

    class ScreenItem_qml {
        +var screen
        +bool selected
        +real translationX
        +real translationY
        +real scale
        +Loader highlightLoader
    }

    class ScreenTabDelegate_qml {
        +var modelData
        +var screen
        +bool isSelect
        +bool hovered
    }

    class DccData {
        +var virtualScreens
        +bool isX11
    }

    class Indicator_component {
        +createObject(parent, screen)
    }

    DisplayMain_qml --> DccData : uses_virtualScreens
    DisplayMain_qml --> ScreenItem_qml : manages_selection
    DisplayMain_qml --> ScreenTabDelegate_qml : binds_screen_property
    DisplayMain_qml --> Indicator_component : creates_indicator

    ScreenItem_qml o-- DisplayMain_qml : root_reference
    ScreenItem_qml : Loader.active = selected
    ScreenItem_qml : Loader.visible = selected

    ScreenTabDelegate_qml : isSelect = modelData.name == screen.name
Loading

Flow diagram for rotation-aware getQtScreen matching

flowchart TD
    A["Start getQtScreen(screen)"] --> B[Initialize matchedScreen to null]
    B --> C{Are there Qt application screens?}
    C -->|no| Z[Return null]
    C -->|yes| D[Iterate s over Qt.application.screens]

    D --> E[Compute isRotated = screen.rotate == 2 or screen.rotate == 8]
    E --> F["If isRotated: targetW = screen.currentResolution.height<br>else: targetW = screen.currentResolution.width"]
    F --> G["If isRotated: targetH = screen.currentResolution.width<br>else: targetH = screen.currentResolution.height"]

    G --> H["Position and size match?<br>(s.virtualX == screen.x<br>and s.virtualY == screen.y<br>and abs(s.width * s.devicePixelRatio - targetW) < 1<br>and abs(s.height * s.devicePixelRatio - targetH) < 1)"]

    H -->|yes| I[matchedScreen = s]
    I --> J[Return matchedScreen]

    H -->|no| K{More screens?}
    K -->|yes| D
    K -->|no| Z[Return null]
Loading

File-Level Changes

Change Details Files
Fix Qt screen matching for rotated displays so indicator/highlight uses the correct resolution orientation at 90°/270°.
  • Update getQtScreen() to treat 90°/270° rotations as swapped width/height when comparing against Qt.application.screens.
  • Introduce isRotated, targetW, and targetH to compute expected physical dimensions based on rotation.
  • Maintain existing matching on virtualX/virtualY and devicePixelRatio while using the rotated dimensions.
src/plugin-display/qml/DisplayMain.qml
Preserve and restore the last selected virtual screen across configuration updates to keep the correct screen highlighted.
  • Add lastScreenName property on the root object and initialize it on component completion when a screen is available.
  • Update virtualScreensChanged handler to re-select the screen by lastScreenName if possible, otherwise fall back to the first virtual screen.
  • Update monitor press and screen-click handlers to assign root.lastScreenName when the user explicitly selects a screen.
src/plugin-display/qml/DisplayMain.qml
Tighten selection logic so highlighting is based on screen identity (name) and only shown when selection is valid.
  • Modify ScreenItem delegate to consider a screen selected only when root.screen equals the delegate's screen and the screen has a defined rotate property.
  • Change ScreenTab delegate isSelect computation to compare screen.name values rather than object identity, with null checks for safety.
  • Ensure the ScreenItem highlight Loader is only visible when the item is selected, preventing stray highlights.
src/plugin-display/qml/DisplayMain.qml
src/plugin-display/qml/ScreenTab.qml
src/plugin-display/qml/ScreenItem.qml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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.

Hey - I've left some high level feedback:

  • In onVirtualScreensChanged, lastScreenName is not updated when root.screen is reassigned (either to the matched screen or the first screen), which means subsequent changes may no longer track the actually selected screen; consider updating lastScreenName whenever root.screen changes or centralizing that logic in an onScreenChanged handler.
  • In ScreenTab.qml, the temporary variables modelName and screenName inside the isSelect property are computed but never used; they can be removed to simplify the binding and avoid confusion.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `onVirtualScreensChanged`, `lastScreenName` is not updated when `root.screen` is reassigned (either to the matched screen or the first screen), which means subsequent changes may no longer track the actually selected screen; consider updating `lastScreenName` whenever `root.screen` changes or centralizing that logic in an `onScreenChanged` handler.
- In `ScreenTab.qml`, the temporary variables `modelName` and `screenName` inside the `isSelect` property are computed but never used; they can be removed to simplify the binding and avoid confusion.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented Apr 23, 2026

TAG Bot

New tag: 6.1.82
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3187

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented Apr 24, 2026

TAG Bot

New tag: 6.1.83
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3190

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.

2 participants