-
Notifications
You must be signed in to change notification settings - Fork 37.8k
qt: Cleanup MacDockIconHandler class #14597
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
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
Concept ACK. |
Concept ACK Net change: -189 lines. Nice cleanup! |
Concept ACK There's at least one bug here. Using e0d1883, if you close the main window using the red cross, you can no longer bring the window back by clicking on the dock icon. |
Qt `setWindowIcon()` does this work.
e0d1883
to
b913e68
Compare
b913e68
to
43627b9
Compare
@fanquake @promag @practicalswift |
src/qt/macdockiconhandler.mm
Outdated
@@ -49,61 +44,22 @@ void setupDockClickHandler() { | |||
setupDockClickHandler(); | |||
this->m_dummyWidget = new QWidget(); | |||
this->m_dockMenu = new QMenu(this->m_dummyWidget); | |||
this->setMainWindow(nullptr); | |||
#if QT_VERSION >= 0x050200 |
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.
You can drop the QT_VERSION
check here, as our next release will require at least 5.2. master currently requires 5.4 IIRC.
461806f
to
14e7e16
Compare
14e7e16
to
efb681d
Compare
@fanquake Your comment is addressed. Please re-review. |
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.
tACK efb681d on macOS 10.14.1, thanks for reducing the amount of OS specific code we need to reason about!
src/qt/macdockiconhandler.mm
Outdated
class_replaceMethod(delClass, shouldHandle, (IMP)dockClickHandler, "B@:"); | ||
else | ||
class_addMethod(delClass, shouldHandle, (IMP)dockClickHandler,"B@:"); | ||
class_replaceMethod(delClass, shouldHandle, (IMP)dockClickHandler, "B@:"); |
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.
Why did/do we need this class_replaceMethod
stuff?
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 implements the method of the application delegate which handles the reopen application
event (i.e., the user clicks application icon in the Dock).
Ref: How Cocoa Applications Handle Apple Events
Qt cannot handle the reopen application
event for now.
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.
efb681d
to
6b1d297
Compare
Fixed bug with hidden/inactive/obscured main window: |
This needs proper testing on macOS 10.9 up till 10.14. Also, I'm not sure that this works reliable with older Qt5 versions. We should probably also test against Qt5.4 till Qt5.9. |
https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes.md:
What is the reason to choose so wide range of the tested platforms? |
The "official" binaries are using Qt5.9 which doesn't mean that we drop support self-compilation with an older Qt version. We should at least do some tests on something between OSX 10.10 and 10.14 with Qt5.5 and Qt5.9 (and not just only 10.14&Qt5.9). |
I'm not a fan of testing older macOS versions, at least not every PR. There's very few core devs that work on both macOS and the GUI (very on the GUI period) and have old versions of macOS lying around. Meanwhile Apple hasn't increased hardware requirements for their recent OS updates and they make it really easy. I think this leads to a bit of vicious circle where work on the GUI is very slow, leading to very few people using it, leading to very few devs working on it. I think it would be better for users if each major release only supports the current macOS version. If there's a killer feature that we really want people on older macOS versions to have, we could always backport that. |
Qt `setWindowIcon()` does this work. Github-Pull: bitcoin#14597 Rebased-From: 53bb6be
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. Github-Pull: bitcoin#14597 Rebased-From: 2464925
Qt `setAsDockMenu()` does this work. Github-Pull: bitcoin#14597 Rebased-From: 6b1d297
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
The Objective-C
MacDockIconHandler
class currently does such jobs on macOS:Qt does the first job natively.
Qt has native support the Dock icon menu only since version 5.2
Qt does not handle
applicationShouldHandleReopen
event. And this brakes all Qt support for the Dock icon click event.This PR:
setWindowIcon()
does this worksetAsDockMenu()
does this work