Made options to hide search bar, private mode, clear, and/or settings buttons & fixed Paste on Select bug.#534
Made options to hide search bar, private mode, clear, and/or settings buttons & fixed Paste on Select bug.#534JaredTweed wants to merge 36 commits intoTudmotu:masterfrom
Conversation
… buttons. Also made pressing Enter and clicking on an item have consistent behaviour. Fixed glitch where Paste on Select only worked when pressing Enter, and not when clicking.
… my version but forgot to include them in the commit), and fixed whitespace edits
…. Hopefully eliminates unsuccessful pasting attempts.
|
Hi @JaredTweed,
You claimed in other PRs the extension "works better" with these changes, but I am a very heavy user of this extension and I rarely encounter any issues. In addition, other than the paste-on-select, none of the changes seem meaningful (some seem detrimental). Can you please elaborate on the issues you encountered? |
|
Q1) Meta.Laters is Mutter’s frame-synchronized scheduler. It runs callbacks at compositor phases like AFTER_REDRAW, which is ideal for preview image swaps and avoids UI races that idle/timers can’t. The code falls back to GLib.idle_add() if Meta.Laters isn’t present, keeping compatibility across versions. Q2) Yes, the original delay buffered against focus and relayout churn while the menu opened. In #529 the focus delay is preserved using GLib.idle_add() so it doesn’t fight Shell’s animation, but the separate selection delay is removed and replaced with synchronous selection. This prevents the paste-ordering races caused by timers, and #534 then fully replaces them with event-driven sequencing. Q3) The pasting fix can not be split, because the way it loads the menu causes it to load differently, causing some issues in the timers and the order in which they load things. #529 introduced the unified activation path and the _pastePending/owner-change hooks. #534 builds on this by replacing the last timeouts with sequential, signal-driven logic and fixing the “previous vs current selection” problem. While it could be split, #534 is a direct continuation of #529 and simpler to test together. Q4) I had it on my last computer (a very old slow computer), where it would occasionally paste the second most recent instead of the most recent code (only when I copied large sections of text. Paste-on-select also failed when clicking an entry, because the paste is attempted before the clipboard owner switches and before focus returns to the target app. With #529 and #534, activation is unified: the menu closes first to return focus, the clipboard is updated, and the paste only happens once the owner-change signal is seen. This guarantees correct ordering and consistent behavior for both click and Enter. On my newer computer I don't have that issue. |
|
The other benefit of making it run sequentially, is that it will be more reliable, and not rely on specific animation/loading speeds. |
|
If you want, I can modify PR #529 to evade the same bugs as #534, but avoid using meta.laters instead of glib (so as to keep the change minimal). Would you like me to do that? I could get that done by tomorrow night. I just think it will be less reliable for future updates if we don't make this change. |
|
The delay has nothing to do with animations or layouts. You can see the delay is only used when the "move item to top" setting is enabled. This is because otherwise, iterating through the list of items via shortcuts becomes impossible: every time you select an entry it moves to the top, you select the next entry it moves to the top, the previous entry is now in place 2, you move to the next item and it's actually the previous entry, so you are effectively stuck in a loop between 2 entries. This delay should not be removed as it is crucial. This PR has some issues which makes me uncomfortable merging it. I am leaving a review, but I highly suggest that you try first submitting a smaller PR, that does not include any fundamental changes to the way this extension works. Thousands of people if not more use it every day, and if it was this broken then I'd hear about it. The scenario you are describing with the paste-on-select window focus race condition might present an actual issue. If that's the case, I suggest you find a reproducible example. I think maybe a moving the paste action to the "activate" handler is all that is needed (not sure about it). In any case, for me to be able to test a fix like that, I need to be able to first reproduce the underlying issue. I know you put a lot of effort into this PR and I don't want to discourage you. But I have to consider the many many many users of this extension when I merge PRs, especially ones that make fundamental changes to the code. Thank you. |
|
Okay, I did all the changes I found to be necessary and did a thorough bug search as well. Is this code sufficient? You can ignore PR #529 now and just pull this instead. |
|
Sorry for not checking it better before. |
|
This is the smallest I know how to make this PR, I am sorry. Thank you so much for the work you have put into this project!! I really appreciate your time. |
|
@Tudmotu, I made the changes as clean as possible for you. Is it clean enough to be added to the extension? |
|
@Tudmotu I made the PR much smaller now, and kept your version of the timeouts that you like so that there is no longer that risk of making it create breaking changes. I also updated the code so that it has no conflicts with the base and can now be merged with the click of a button. I hope these additions are sufficient. |
|
@Tudmotu I also got rid of all that Meta.Laters stuff and all those unnecessary changes that I made before |
There was a problem hiding this comment.
I left another review. This PR is still too much of a mess. Follow the comments I left you and I will review it again afterwards. I'm not sure if you are using claude or if it's you that is adding all these unnecessary changes, but please stop. If you are using an agent to help, you need to double review its changes and make sure everything works properly.
One more thing: DO NOT resolve comments on your own. Only the reviewer should resolve comments. Resolving comments others leave makes it harder to see if you actually implemented the proper changes. This is basic open source etiquette.
| if (currentlySelected && currentlySelected.entry) | ||
| this.#updateClipboard(currentlySelected.entry); |
There was a problem hiding this comment.
In what situation is currentlySelected not defined?
prefs.js
Outdated
| // Toggleable UI rows | ||
| this.field_show_search_bar = new Adw.SwitchRow({title: _("Show Search Bar")}); | ||
| this.ui.add(this.field_show_search_bar); | ||
| this.field_show_private_mode = new Adw.SwitchRow({title: _("Show Private Mode")}); | ||
| this.ui.add(this.field_show_private_mode); | ||
| this.field_show_settings_button = new Adw.SwitchRow({title: _("Show Settings Button")}); | ||
| this.ui.add(this.field_show_settings_button); | ||
| this.field_show_clear_history_button = new Adw.SwitchRow({title: _("Show Clear History Button")}); | ||
| this.ui.add(this.field_show_clear_history_button); | ||
|
|
There was a problem hiding this comment.
Why do you create the fields and add them here instead of following the pattern used throughout the rest of the file where the fields are created on top and are only attached here?
extension.js
Outdated
| if (ENABLE_KEYBINDING) | ||
| that._bindShortcuts(); | ||
| else | ||
| that._unbindShortcuts(); | ||
| if (ENABLE_KEYBINDING) that._bindShortcuts(); | ||
| else that._unbindShortcuts(); |
There was a problem hiding this comment.
Meaningless whitespace changes like these clutter your PR. Please undo this change unless it is meaningful somehow. Avoid any changes that do not affect functionality.
extension.js
Outdated
|
|
||
| // NEW toggles |
There was a problem hiding this comment.
What does "NEW" mean here? If someone sees this code in 3 years, would these still be "NEW"?
Please remove this comment and just maintain the same code style and patterns of the surrounding code.
| this.#selectNextMenuItem(menuItem); | ||
| this._removeEntry(menuItem, 'delete'); | ||
| break; | ||
| return Clutter.EVENT_STOP; |
There was a problem hiding this comment.
Why do you need to return these EVENT_STOP consts?
There was a problem hiding this comment.
I think we may want to return Clutter.EVENT_STOP to prevent the event from propagating up the actor hierarchy — otherwise GNOME Shell may also handle it (e.g., close the popup or trigger other UI reactions).
| // Ensure MOVE_ITEM_FIRST also applies when PASTE_ON_SELECT fast-path skips _refreshIndicator() | ||
| if (PASTE_ON_SELECT && MOVE_ITEM_FIRST && !menuItem.entry.isFavorite()) { | ||
| this._moveItemFirst(menuItem); | ||
| } |
There was a problem hiding this comment.
Why do you need to manually move the item here?
extension.js
Outdated
| menuItem.icoBtn.visible = DELETE_ENABLED; | ||
| menuItem.deletePressId = icoBtn.connect('clicked', () => { | ||
| if (!DELETE_ENABLED) return; | ||
| this._removeEntry(menuItem, 'delete'); | ||
| }); |
There was a problem hiding this comment.
Why did you re-enable support for this feature? It's long gone as far as I can see.
extension.js
Outdated
| // Create menu sections for items | ||
| // Favorites | ||
| // Favorites section |
There was a problem hiding this comment.
Undo every unnecessary change. I will not accept a PR that has any unnecessary changes. Keep you PR as clean as possible and adhere to the style and patterns used in the existing code.
extension.js
Outdated
|
|
||
| // NEW: toggleable UI elements |
There was a problem hiding this comment.
Remove the "NEW" comment here as well.
|
@Tudmotu, as a grateful user of your extension who curiously follows this topic here (as I like the idea), I just want to take the opportunity to thank you for insisting on high quality standards and appropriate workflows. 👍 |
|
@Tudmotu I will be more careful with the changes. Sorry about resolving the comments. I will let you resolve those. Thank you so much for being willing to take the time to review my code, I really appreciate your discipline in that. I really hope my contributions make it into the final product. Let me know if you would like any more changes. |
|
@Tudmotu Thank you for your patience with me. Just so you know, I am ready for you to review it! |
This pull request is built on top of my other pull request.
This ensures that:
Both of those bugs were frequent especially on slower hardware, but I think I entirely fixed those errors.