-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Feature: Improved behavior when dragging items from an unfocused Files window #16508
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
…itialized & Added unregisteration
@Jack251970 the behavior is working nicely when Files is maximized. Is there a way to also do this when Files isn't maximized? |
@yaira2 Sorry, I cannot get your meaning. What is the difference between the behaviour when File is maximized and when it is not? |
https://github.com/user-attachments/assets/91b17452-b706-47fe-be16-89460ec12508 |
I meant that Files is brought to the foreground if the window isn't maximized. |
Sorry, still no idea about why Files needs to be brought to the foreground if the window isn't maximized. (Under what situation?) As you can see in the video above, my codes implement a function that the Files will stay in the current z index (not be brought to front for covering another topper window that need to drag files into) if dragging selected files so that it will have the same experience as system File Explorer. |
Putting aside the behavior, you can use DidPositionChanged from AppWindow.Changed event instead of utilizing win32 apis. |
I am not quite familiar with this api. Will it make some differences? |
@Jack251970 I'm referring to the behavior (around two seconds into your recording) where the Files window is brought to the foreground.
Isn't the expected behavior for File Explorer to remain the topmost window? |
Get it. I will try to make this work. |
Thanks! I should note, your current changes already helped to resolve this issue when the window is maximized. |
Yeah you don't have to hook/unhook win32 window message loop, there's high-level API wrapper called WinRT API as opposed to low-level Win32 API. This API let you just subscribe an event. Go to MainWindow and subscribe this.AppWindow.Changed event and get args.DidPositionChange property value. |
Sure, I will have a try. |
@yaira2 Sorry about the misunderstanding description (I have removed the useless step that asks you to maximize the Files window). This feature can work while Files isn't a maximized window. |
@0x5bfa Yeah I have found that AppWindow.Changed event contains information about DidPositionChange & ZOrderChange, but I cannot handle these changes. (AppWindowChangedEventArgs does not have Handle property, and I cannot stop those changing event) So I think WindowMessageReceived event in WinUIEx.WindowManager is the only way to implement this and WinUIEx package has provided a good solution for this. |
@Jack251970 thank you for clarifying. I'll test again to confirm the behavior works on my side. |
Thanks, I missed that. I'll file a feature request on WinAppSdk for this later. |
@Jack251970 I can confirm the behavior is working as expected. I'm going to wait for a review from @hishitetsu, but as far as I'm concerned I have no requested changes. |
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 improvement does not work once the app goes to the background and then reopens.
I also found a few behaviors that differ from Explorer.
- In Files, if you try to drag a file that is not selected, the Files window comes into focus; this is not the case in Explorer.
- Once dragged to another window, returning the cursor and releasing the mouse button on the original window will focus the original window in Explorer, but not in Files.
@hishitetsu Thank you for testing this function so carefully! As for few behaviors that differ from Explorer above, I don not think it is necessary to ensure Files has the same behavior as the Explorer and I wonder what is the difference in user experience. (Sorry, I am not familiar with focus behaviors.) For |
|
@hishitetsu Now fixed, I think it can work when you close window and keep it in the background. |
For what it's worth, it's probably better if we only implement the behaviors as they are requested. Thanks for all your work! |
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.
It seems to work fine, but there are a few comments about the code quality.
@hishitetsu Resolved. |
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.
LGTM
Co-authored-by: hishitetsu <66369541+hishitetsu@users.noreply.github.com>
@Jack251970 thank you for all your work on this improvement! @hishitetsu thank you for testing and reviewing the PR! |
Resolved / Related Issues
Steps used to test these changes
Stability is a top priority for Files and all changes are required to go through testing before being merged into the repo. Please include a list of steps that you used to test this PR.