Fix menu misalignment on first open after login#13786
Open
H09-0 wants to merge 1 commit into
Open
Conversation
- Add _calculatePosition() + set_position() in onComplete of the animation path to ensure the menu snaps to the correct position immediately after the visual transition finishes. Without this, _allocationChanged is blocked by this.animating during the animation, so any deferred layout changes (e.g. app buttons shown via Mainloop.idle_add) cannot correct the position until after the animation ends and the next allocation change fires. - Replace separate this.actor.x / this.actor.y assignments with this.actor.set_position() in the non-animation path to avoid a race where setting x triggers _allocationChanged synchronously, which calls set_position(), and then the subsequent y assignment overwrites the corrected Y coordinate with the stale value. Closes linuxmint#13780
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix #13780 - the menu appears at the wrong horizontal position on the
first click after login, then snaps to the correct position ~1 second
later.
Root cause
Two interacting defects in
js/ui/popupMenu.jsopen():1. Animation path:
_allocationChangedblocked during animationThe
_allocationChangedhandler is guarded by!this.animating(line 2128).When animation is enabled and
open()runs:this.animating = trueis set (line 1851)_calculatePosition()runs but the menu layout is incomplete - theapplet's
_onOpenStateChangedonly showsINITIAL_BUTTON_LOADbuttonssynchronously and defers the rest via
Mainloop.idle_add(applet.js:1554)_allocationChangedbails becauseanimatingis stilltrueanimating = falsedoes the nextallocation change trigger
_allocationChanged- the ~1 second snap2. Non-animation path: separate x/y assignment races
With
this.actor.x = xPos; this.actor.y = yPos;, settingxfiresnotify::allocation->_allocationChanged->set_position(x', y'),then
this.actor.y = yPosoverwrites the corrected Y with the stale value.Fix (3 insertions, 2 deletions in popupMenu.js)
Change 1 - Animation path onComplete (line 1859-1862)
Recalculates and sets the correct position the instant the animation
finishes, no longer relying on a delayed
_allocationChanged.Change 2 - Non-animation path (line 1893-1896)
Atomic set eliminates the race between separate x/y assignments and the
synchronous
_allocationChangedthey trigger.Testing
Side effects
None. Adds a position recalibration at the natural completion point of the
animation (idempotent). Replaces racy two-step assignment with an atomic
call already used in this class (
shiftToPosition,_allocationChanged).