Fix Alt-tabbing while using hand tool locks the hand tool (fix #325)#5601
Fix Alt-tabbing while using hand tool locks the hand tool (fix #325)#5601Gasparoken wants to merge 1 commit into
Conversation
07d276a to
84679d6
Compare
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
| (m_proj.scaleX() <= 1.0 && m_proj.scaleY() <= 1.0))); | ||
| } | ||
|
|
||
| void Editor::cancelOperation() |
There was a problem hiding this comment.
warning: method 'cancelOperation' can be made static [readability-convert-member-functions-to-static]
src/app/ui/editor/editor.h:114:
- void cancelOperation();
+ static void cancelOperation();|
|
||
| static CancelActionsCallback cancelActionsCallback = nullptr; | ||
|
|
||
| void Manager::setCancelActionsCallback(CancelActionsCallback callback) |
There was a problem hiding this comment.
warning: method 'setCancelActionsCallback' can be made static [readability-convert-member-functions-to-static]
src/ui/manager.h:146:
- void setCancelActionsCallback(CancelActionsCallback callback);
+ static void setCancelActionsCallback(CancelActionsCallback callback);| cancelActionsCallback = callback; | ||
| } | ||
|
|
||
| void Manager::cancelActions() |
There was a problem hiding this comment.
warning: method 'cancelActions' can be made static [readability-convert-member-functions-to-static]
src/ui/manager.h:147:
- void cancelActions();
+ static void cancelActions();84679d6 to
ede7521
Compare
|
@Gasparoken please give a proper title to the PR |
ede7521 to
62ac22f
Compare
Ok, no problem, by the way: @dacap If you're available, could you check if the approach is correct? I'm still testing on Windows and trying to address the hand tool issue with the mouse middle button. |
62ac22f to
35f8f99
Compare
35f8f99 to
b5e44aa
Compare
| enqueueMessage(msg); | ||
| break; | ||
| } | ||
| case os::Event::CancelActions: { |
There was a problem hiding this comment.
I'm not sure about introducing this new os.Event in laf as is...because it doesn't seem to map well to an actual OS event. Should this event be fired when the program's window is not the main/focused/active window any more?
| // when the os::Display is resized by the user. | ||
| static bool auto_window_adjustment = true; | ||
|
|
||
| static CancelActionsCallback cancelActionsCallback = nullptr; |
There was a problem hiding this comment.
I think we should avoid using a static callback for this.
| break; | ||
| } | ||
| case os::Event::CancelActions: { | ||
| cancelActions(); |
There was a problem hiding this comment.
I think we should follow the same principles as for the other events: translating the os Event into a Message. Then you will be able to handle that Message in the Editor's onProcessMessage method and call your Editor::cancelOperation() method.
1b55755 to
b9223cc
Compare
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
|
|
||
| case os::Event::AppLostFocus: { | ||
| if (mouse_widget) { | ||
| auto msg = new AppLostFocusMessage(); |
There was a problem hiding this comment.
warning: 'auto msg' can be declared as 'auto *msg' [readability-qualified-auto]
| auto msg = new AppLostFocusMessage(); | |
| auto *msg = new AppLostFocusMessage(); |
…te#325) AppLostFocusMessage was added to tell the Editor to disable the 'quick hand tool' when the application loses focus via Alt+tab.
b9223cc to
9eff071
Compare
|
I'm testing this one with https://github.com/gasparoken/laf/tree/fix-alt-tab (which is different from https://github.com/aseprite/laf/tree/fix-alt-tab). Probably I'll cherry-pick https://github.com/gasparoken/laf/tree/fix-alt-tab and rename the events to I'll try to make these events work on laf, and then go back to this PR. |
|
Merged the laf patch in aseprite/laf@c0a8427 but then implemented AppEnter/AppLeave/WindowEnter/WindowLeave in all platforms: aseprite/laf@592136b I'll continue with this PR tomorrow. |
dacap
left a comment
There was a problem hiding this comment.
Leaving some comments about the code and how I'm going to rebase this PR with these patches. There is no need for action from your side.
| ui::MouseMessage* msg = new ui::MouseMessage(ui::MessageType::kMouseUpMessage, | ||
| os::PointerType::Mouse, | ||
| ui::MouseButton::kButtonLeft, | ||
| os::KeyModifiers::kKeyNoneModifier, | ||
| manager->getMouse()->mousePosInDisplay()); | ||
| m_state->onMouseUp(this, msg); | ||
| ui::MouseMessage* msg2 = new ui::MouseMessage(ui::MessageType::kMouseUpMessage, | ||
| os::PointerType::Mouse, | ||
| ui::MouseButton::kButtonMiddle, | ||
| os::KeyModifiers::kKeyNoneModifier, | ||
| manager->getMouse()->mousePosInDisplay()); | ||
| m_state->onMouseUp(this, msg2); |
There was a problem hiding this comment.
Both new ui::MouseMessage(...) generate memory leaks as they are not queued in the manager, I'm going to replace both of them with:
| ui::MouseMessage* msg = new ui::MouseMessage(ui::MessageType::kMouseUpMessage, | |
| os::PointerType::Mouse, | |
| ui::MouseButton::kButtonLeft, | |
| os::KeyModifiers::kKeyNoneModifier, | |
| manager->getMouse()->mousePosInDisplay()); | |
| m_state->onMouseUp(this, msg); | |
| ui::MouseMessage* msg2 = new ui::MouseMessage(ui::MessageType::kMouseUpMessage, | |
| os::PointerType::Mouse, | |
| ui::MouseButton::kButtonMiddle, | |
| os::KeyModifiers::kKeyNoneModifier, | |
| manager->getMouse()->mousePosInDisplay()); | |
| m_state->onMouseUp(this, msg2); | |
| ui::MouseMessage msg(ui::MessageType::kMouseUpMessage, | |
| os::PointerType::Mouse, | |
| ui::MouseButton::kButtonLeft, | |
| os::KeyModifiers::kKeyNoneModifier, | |
| manager->getMouse()->mousePosInDisplay()); | |
| m_state->onMouseUp(this, &msg); | |
| ui::MouseMessage msg2(ui::MessageType::kMouseUpMessage, | |
| os::PointerType::Mouse, | |
| ui::MouseButton::kButtonMiddle, | |
| os::KeyModifiers::kKeyNoneModifier, | |
| manager->getMouse()->mousePosInDisplay()); | |
| m_state->onMouseUp(this, &msg2); |
Another important thing, after merging this I'll try to refactor the ui-lib in some way automatically or to handle this in a more generic way (e.g. the Timeline has the same problem)
| break; | ||
| } | ||
|
|
||
| case os::Event::AppLostFocus: { |
There was a problem hiding this comment.
I'll try to use the WindowLeave event instead of the app one (both messages should be received, but I have to test on all platforms yet):
| case os::Event::AppLostFocus: { | |
| case os::Event::WindowLeave: { |
|
|
||
| case os::Event::AppLostFocus: { | ||
| if (mouse_widget) { | ||
| auto msg = new AppLostFocusMessage(); |
There was a problem hiding this comment.
There is no need for a new Message sub-class if the message doesn't contain any extra information, I'm going to replace this with:
| auto msg = new AppLostFocusMessage(); | |
| auto* msg = new Message(kWinLeaveMessage); |
The kWinLeaveMessage name is temptative, but probably we could add something like kMouseLostMessage or see if we can just send a kMouseLeaveMessage.
| case os::Event::AppLostFocus: { | ||
| if (mouse_widget) { | ||
| auto msg = new AppLostFocusMessage(); | ||
| msg->setRecipient(mouse_widget); |
There was a problem hiding this comment.
After furthering testing, this AppLostFocus (or another one like WindowLeave message) cannot be received by the mouse_widget only (we should setPropagateToParent(true)), but the message should be sent to the display window.
For this specific fix, I'll try another approach, probably a MouseLeave message when os::Event::WindowLeave is received (instead of creating a new AppLostFocusMessage), something to solve every case of all widgets that have the mouse captured.
, aseprite#5601) Switching to another app will generate a kMouseUpMessage without button (kButtonNone) for the capture_widget so it can release the mouse and go back to its idle state.
, aseprite#5601) Switching to another app will generate a kMouseUpMessage without button (kButtonNone) for the capture_widget so it can release the mouse and go back to its idle state.
, aseprite#5601) Switching to another app will generate a kMouseUpMessage without button (kButtonNone) for the capture_widget so it can release the mouse and go back to its idle state.
On XWayland, FocusOut events can be sent spuriously by the compositor (e.g. when focus moves between Aseprite's own windows in multi-display mode). Using WindowLeave to release capture caused popup windows like the color picker to close prematurely. Change to AppLeave which only fires when focus leaves the application entirely (e.g. Alt+Tab to another app), preserving the original fix for aseprite#325 and aseprite#5601.
fix #325