-
Notifications
You must be signed in to change notification settings - Fork 38.7k
gui: Add GUIUtil::bringToFront #14123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@jonasschnelli @Sjors @ken2812221 review/test much appreciated. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
f2cd327 to
eed869b
Compare
|
I think it would make sense, for ease of review, to split off the fix to #13829 from pure refactoring. |
|
Which refactor? Note that the issue is observed in more places than the one reported in #13829. |
Sjors
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/qt/guiutil.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apple documentation suggests that this normally shouldn't be needed, which suggests there's a deeper problem somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also like to know a bit more about this, and the new <objc/objc-runtime.h> #include.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@promag Can you comment here on why we need to manually do this? For reference Apples docs state:
You rarely need to invoke this method. Under most circumstances, AppKit takes care of proper activation. However, you might find this method useful if you implement your own methods for inter-app communication.
so I'd have thought this would be something handled by Qt. There are a couple mentions of this specific flag in the cocoa integration plugin, as well as use in the QCocoaWindow::raise() method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the sel_getUid documentation:
The implementation of this method is identical to the implementation of
sel_registerName.
On master(7504157):
sel_registerNameused 4 timessel_getUidnot used at all
Could sel_getUid replace with sel_registerName?
|
Testing current master on macOS 10.13.6 2070a54.
Testing eed869b.
|
|
Thanks for the reviews! I'll fix it. BTW, in macOS "show/hide" action could be removed since it's already there natively. |
src/qt/bitcoingui.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is better
connect(signMessageAction, &QAction::triggered, [this]{ showNormalIfMinimized(); gotoSignMessageTab(); });
connect(verifyMessageAction, &QAction::triggered, [this]{ showNormalIfMinimized(); gotoSignMessageTab(); });
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping multiple connections for now for consistency with other actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the other actions are only done that way for historical reasons -- prior to Qt5/C++11 this was not possible, and we only switched to using lambdas instead of the older syntax in 0.17 I believe.
src/qt/bitcoingui.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the window was minimized, it might need to call showNormal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fixed.
eed869b to
242e61f
Compare
|
Rebased (so that testing takes #14133) and added a fixup that |
src/qt/guiutil.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this comment back done to line 710, given it's in reference to findStartupItemInList.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done.
242e61f to
d5284ed
Compare
src/qt/guiutil.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Qt docs
Note that the window must be visible, otherwise activateWindow() has no effect.
Therefore, the safer sequence may be:
w->showNormal(); // or w->show();
w->activateWindow();
w->raise();
|
IMO |
1aa064a to
56c61a3
Compare
ken2812221
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK d3becb175270d715daaffb75a037433a126a95f4
|
Tested d3becb175270d715daaffb75a037433a126a95f4:
Also a tiny nit left: #14123 (comment) |
This moves the Dock icon click reaction code to the common place and allows some cleanup in obj_c code. According to the Apple's docs `class_replaceMethod` behaves as `class_addMethod`, if the method identified by name does not yet exist; or as `method_setImplementation`, if it does exist.
Qt `setAsDockMenu()` does this work.
d3becb1 to
0a656f8
Compare
|
Rebased to account for the new fix and applied suggestion #14123 (comment).
I think it is worth a new PR. |
0a656f8 qt: All tray menu actions call showNormalIfMinimized (João Barbosa) 6fc21ac qt: Use GUIUtil::bringToFront where possible (João Barbosa) 5796671 qt: Add GUIUtil::bringToFront (João Barbosa) 6b1d297 Remove obj_c for macOS Dock icon menu (Hennadii Stepanov) 2464925 Use Qt signal for macOS Dock icon click event (Hennadii Stepanov) 53bb6be Remove obj_c for macOS Dock icon setting (Hennadii Stepanov) Pull request description: The sequence `show -> raise -> activateWindow` is factored out to the new function `GUIUtil::bringToFront` where a macOS fix is added in order to fix #13829. Also included: - simplification of `BitcoinGUI::showNormalIfMinimized` - simplified some connections to `BitcoinGUI::showNormalIfMinimized` - added missing connections to `BitcoinGUI::showNormalIfMinimized`. Tree-SHA512: a8e301aebc359aa353821e2af352ae356f44555724921b01da907e128653ef9dc55d8764a1bff72a579e5ff96df8a681f6804bfe83acba441da92fedff974a55
Github-Pull: bitcoin#14123 Rebased-From: 5796671
Github-Pull: bitcoin#14123 Rebased-From: 6fc21ac
Github-Pull: bitcoin#14123 Rebased-From: 0a656f8
27beb83 qt: All tray menu actions call showNormalIfMinimized (João Barbosa) c470bbd qt: Use GUIUtil::bringToFront where possible (João Barbosa) ac73c7d qt: Add GUIUtil::bringToFront (João Barbosa) 0c2fb87 Remove obj_c for macOS Dock icon menu (Hennadii Stepanov) 9034714 Use Qt signal for macOS Dock icon click event (Hennadii Stepanov) 4d4bc37 Remove obj_c for macOS Dock icon setting (Hennadii Stepanov) d2ed162 Clean systray icon menu for -disablewallet mode (Hennadii Stepanov) 298dc15 gui: Favor macOS show / hide action in dock menu (João Barbosa) Pull request description: Backport #14123 #14133 #14383 and #14597 to 0.17 branch to fix #13606 (comment). Tree-SHA512: 543c80e7e2130870e801e0c9a69b06b9eea27c288478fc5dddeb662f7f3ec5b56b30916e5a9a629fced3fffcb8be77e2cd155e75cfd0a4392299add9730840f4
a60b7cc qt: Replace objc_msgSend with native syntax (furszy) 5d6f9b5 qt: Use GUIUtil::bringToFront where possible (furszy) 9e85183 qt: Add GUIUtil::bringToFront (furszy) 188199a Remove obj_c for macOS Dock icon menu (furszy) 75a41e2 Use Qt signal for macOS Dock icon click event (furszy) ff319ad Remove obj_c for macOS Dock icon setting. (furszy) Pull request description: Updating `MacDockIconHandler` to latest upstream. Fixing #1512 . Back ported PRs: #### gui: Add GUIUtil::bringToFront [14123](bitcoin#14123): ``` The sequence show -> raise -> activateWindow is factored out to the new function GUIUtil::bringToFront where a macOS fix is added in order to fix bitcoin#13829. Also included: simplification of BitcoinGUI::showNormalIfMinimized ``` #### qt: Replace objc_msgSend() function calls with the native Objective-C syntax [16720](bitcoin#16720): ``` Changes in Xcode 11 Objective-C Runtime cause an error (bitcoin#16387) during building on MacOS 10.15 Catalina. This PR fixes this issue by replacing objc_msgSend() function calls with the native Objective-C syntax. Refs: changes in objc_msgSend function OBJC_OLD_DISPATCH_PROTOTYPES macro ``` ACKs for top commit: random-zebra: utACK a60b7cc Fuzzbawls: ACK a60b7cc Tree-SHA512: 95543a12d58187f17d27c6757351becd43a92c3edb8fcbc0a2b03a54d31cbad604ae149f2e866d82c3ce5f9a636571b8e51137fc5f639031a20080d8290889d9
* Remove obj_c for macOS Dock icon setting Qt `setWindowIcon()` does this work. * Use Qt signal for macOS Dock icon click event This moves the Dock icon click reaction code to the common place and allows some cleanup in obj_c code. According to the Apple's docs `class_replaceMethod` behaves as `class_addMethod`, if the method identified by name does not yet exist; or as `method_setImplementation`, if it does exist. * Remove obj_c for macOS Dock icon menu Qt `setAsDockMenu()` does this work. * qt: Add GUIUtil::bringToFront * qt: Use GUIUtil::bringToFront where possible * qt: All tray menu actions call showNormalIfMinimized * qt: Replace objc_msgSend with native syntax Co-authored-by: Hennadii Stepanov <[email protected]> Co-authored-by: João Barbosa <[email protected]>
a60b7cceb4d142239207ac2be2244aa999bdc1fd qt: Replace objc_msgSend with native syntax (furszy) 5d6f9b5c4c2288e1dd150c4e2722db2db2f5db5a qt: Use GUIUtil::bringToFront where possible (furszy) 9e851839737618f8215ec69768702ca6328ab9d9 qt: Add GUIUtil::bringToFront (furszy) 188199a77653bd548d293c5222e1a05773947918 Remove obj_c for macOS Dock icon menu (furszy) 75a41e2d3d7223da8381c9ce19e9454ee96a60b9 Use Qt signal for macOS Dock icon click event (furszy) ff319ad0e3d3319fb9a98087ac73686c8b6f4e17 Remove obj_c for macOS Dock icon setting. (furszy) Pull request description: Updating `MacDockIconHandler` to latest upstream. Fixing #1512 . Back ported PRs: #### gui: Add GUIUtil::bringToFront [14123](bitcoin/bitcoin#14123): ``` The sequence show -> raise -> activateWindow is factored out to the new function GUIUtil::bringToFront where a macOS fix is added in order to fix #13829. Also included: simplification of BitcoinGUI::showNormalIfMinimized ``` #### qt: Replace objc_msgSend() function calls with the native Objective-C syntax [16720](bitcoin/bitcoin#16720): ``` Changes in Xcode 11 Objective-C Runtime cause an error (#16387) during building on MacOS 10.15 Catalina. This PR fixes this issue by replacing objc_msgSend() function calls with the native Objective-C syntax. Refs: changes in objc_msgSend function OBJC_OLD_DISPATCH_PROTOTYPES macro ``` ACKs for top commit: random-zebra: utACK a60b7cceb4d142239207ac2be2244aa999bdc1fd Fuzzbawls: ACK a60b7cceb4d142239207ac2be2244aa999bdc1fd Tree-SHA512: 95543a12d58187f17d27c6757351becd43a92c3edb8fcbc0a2b03a54d31cbad604ae149f2e866d82c3ce5f9a636571b8e51137fc5f639031a20080d8290889d9 # Conflicts: # configure.ac # src/qt/macdockiconhandler.mm
* Remove obj_c for macOS Dock icon setting Qt `setWindowIcon()` does this work. * Use Qt signal for macOS Dock icon click event This moves the Dock icon click reaction code to the common place and allows some cleanup in obj_c code. According to the Apple's docs `class_replaceMethod` behaves as `class_addMethod`, if the method identified by name does not yet exist; or as `method_setImplementation`, if it does exist. * Remove obj_c for macOS Dock icon menu Qt `setAsDockMenu()` does this work. * qt: Add GUIUtil::bringToFront * qt: Use GUIUtil::bringToFront where possible * qt: All tray menu actions call showNormalIfMinimized * qt: Replace objc_msgSend with native syntax Co-authored-by: Hennadii Stepanov <[email protected]> Co-authored-by: João Barbosa <[email protected]>
The sequence
show -> raise -> activateWindowis factored out to the new functionGUIUtil::bringToFrontwhere a macOS fix is added in order to fix #13829.Also included:
BitcoinGUI::showNormalIfMinimizedBitcoinGUI::showNormalIfMinimizedBitcoinGUI::showNormalIfMinimized.