Skip to content

Fix XWayland menu positioning by initializing spec from cached geometry#4512

Merged
mattkae merged 2 commits intomainfrom
copilot/fix-clion-menu-positioning
Dec 9, 2025
Merged

Fix XWayland menu positioning by initializing spec from cached geometry#4512
mattkae merged 2 commits intomainfrom
copilot/fix-clion-menu-positioning

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 8, 2025

Closes #???

Related: #???, https://..., ...

What's new?

XWayland menus (e.g., CLion's project menu) were centering on their parent window instead of anchoring to the opening widget. Root cause: during surface creation, spec.top_left wasn't initialized from cached.geometry, causing prep_surface_spec to skip the aux_rect conversion logic that positions child windows relative to their parent.

Fix: Initialize spec.top_left from cached.geometry.top_left at surface creation (line 725), matching the existing pattern for width/height initialization.

// May be overridden by anything in the pending spec
spec.top_left = cached.geometry.top_left;  // <- Added
spec.width = cached.geometry.size.width;
spec.height = cached.geometry.size.height;

With position set, prep_surface_spec now:

  1. Detects parent relationship via effective_parent
  2. Converts absolute position to parent-relative coordinates
  3. Populates aux_rect + placement hints
  4. Window manager positions correctly instead of falling back to centering

How to test

  1. Run miral-app --enable-x11 true
  2. Launch CLion under XWayland
  3. Open the projects menu
  4. Verify menu anchors to the button, not center of window

Checklist

  • Tests added and pass
  • Adequate documentation added
  • (optional) Added Screenshots or videos
Original prompt

This section details on the original issue you should resolve

<issue_title>The menu on CLion when running under XWayland is positioned in the center of the window instead of being anchored to the widget to wihich it is attached</issue_title>
<issue_description>### Version

v2.23.0

Environment

All of them

What happened? What did you expect to happen?

When running CLion under XWayland, the projects menu is positioned in the center of the CLion widget when opened instead of being anchored to the widget that opened the menu.

Reproduction steps

  1. Run miral-app
  2. Run CLion under Xwayland
  3. Open the projects menu
  4. See that the projects menu opens in the center of the screen

Expected: The project menu opens attached to the button that opened it.

Relevant log output

```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ed geometry

Co-authored-by: mattkae <25062299+mattkae@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix projects menu positioning in CLion under XWayland Fix XWayland menu positioning by initializing spec from cached geometry Dec 8, 2025
Copilot AI requested a review from mattkae December 8, 2025 19:01
@mattkae mattkae marked this pull request as ready for review December 8, 2025 19:46
@mattkae mattkae requested a review from a team as a code owner December 8, 2025 19:46
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 8, 2025

TICS Quality Gate

✔️ Passed

mir

Coding Standards: ✔️ Passed

✔️ Condition “No new Coding Standard Violations for level 1, 2, 3 with respect to Previous analysis” passed.

See the results in the TICS Viewer

The following files have been checked for this project
  • src/server/frontend_xwayland/xwayland_surface.cpp

TICS / TICS / Run TICS analysis

Copy link
Copy Markdown
Contributor

@mattkae mattkae left a comment

Choose a reason for hiding this comment

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

Yup!

@mattkae mattkae enabled auto-merge December 8, 2025 21:04
@mattkae mattkae requested a review from a team December 8, 2025 21:05
Copy link
Copy Markdown
Contributor

@AlanGriffiths AlanGriffiths left a comment

Choose a reason for hiding this comment

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

Works for menus. (not for tips when hovering over button)

@mattkae mattkae added this pull request to the merge queue Dec 9, 2025
Merged via the queue into main with commit b41c3d5 Dec 9, 2025
57 of 72 checks passed
@mattkae mattkae deleted the copilot/fix-clion-menu-positioning branch December 9, 2025 10:02
Copilot AI mentioned this pull request Dec 11, 2025
3 tasks
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Dec 18, 2025
https://build.opensuse.org/request/show/1323421
by user sfalken + anag_factory
- Update to 2.25.1:
  * mirplatform ABI bumped to 34
  * mirserver ABI bumped to 66
  * Bugs Fixed:
    - Cursor icons don't change with XTerm (gh#canonical/mir#4134)
    - Fix magnifier filter not consuming events when magnifications
      is greater/less than the max/min (gh#canonical/mir#4386)
    - If no specified cursor theme loads, then internal theme
      (gh#canonical/mir#439)
    - Renderer: Ensure current EGL context when destroying GL
      resources (gh#canonical/mir#4460)
    - Fix XWayland menu positioning by initializing spec from
      cached geometry (gh#canonical/mir#4512)
    - Implement wl_subsurface.place_above and place_below with
      parent z-ordering (gh#canonical/mir#4332)
    - WindowInfo::clip_area is incorrect if the output is scaled
      (gh#canonical/mir#44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The menu on CLion when running under XWayland is positioned in the center of the window instead of being anchored to the widget to wihich it is attached

3 participants