Skip to content
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

Make preview window non-focusable #644

Closed
93-infinity opened this issue May 4, 2020 · 16 comments
Closed

Make preview window non-focusable #644

93-infinity opened this issue May 4, 2020 · 16 comments

Comments

@93-infinity
Copy link

In Windows Explorer, the arrow keys navigate icons. This behaviour is retained using QuickLook, as expected. Pressing the arrow keys while QuickLook is open switches the preview to the newly selected icon

However if a video is previewed, and a part of the QuickLook UI is clicked (seeking, mute button, etc), focus is now transferred to the QuickLook window. Now, the arrow keys no longer work to switch items because QuickLook has focus, not windows explorer. The only solution is to either click the explorer window to give it focus (however, QuickLook will now be under the explorer window unless always on top is enabled), or to exit the preview by tapping space, then re-entering it by tapping space again, before the arrow keys work again.

Basically QuickLook steals focus when the window is clicked and the arrow keys no longer work to switch items. In macOS QuickLook does not steal focus, the uppermost window remains uppermost even if the QuickLook UI is clicked.

@xupefei
Copy link
Member

xupefei commented May 5, 2020

There is another issue - sorry I can't find it now - discussing whether QL should steal focus.
There are two solutions:

  1. Make QL non-focusable at all, even by clicking the preview window.
  2. Pass keypresses back to the underlying window.

Solution 1 is very simple to implement and was exactly how QL behaviours ~2y ago. Then changed it to the current behaviour since CTRL-C in TextViewer does not work when the preview is non-focusable.

My idea is to bring the old behaviour back and add a context menu (for copying selected text") to the TextViewer.

@rabelux
Copy link
Member

rabelux commented May 5, 2020

It was #338

@xupefei
Copy link
Member

xupefei commented May 7, 2020

I have modified the code according to Solution 1: [download] Code: 472ccc1 and WindowHelper

The only bug I found is about the window z-order: if you switch between multiple Explorer windows and manage to make QL window not top-most, you are unable to bring it back to top-most by clicking in the title bar area. This is because that, clicking on the title bar does not generate a MouseDown event (ref) hence our PreviewMouseDown listener didn't get fired.

I could think of two solutions for this bug:

1. Make the preview topmost, i.e., force image, so we don't need to bring a window back to top anymore
2. Switch to Solution 2
3. Get rid of the system title bar and implement drag/double click/AeroSnap by code. But this one is really tricky: https://stackoverflow.com/questions/11703833/dragmove-and-maximize

Any comments?

Fixed. See below.

@xupefei xupefei changed the title Seeking a video removes focus from explorer, can this be changed? Make preview window non-focusable May 9, 2020
@rabelux
Copy link
Member

rabelux commented May 13, 2020

Can this be tested by downloading the latest nightly? Or does the nightly only reflect changes made in the master-branch

@xupefei
Copy link
Member

xupefei commented May 13, 2020

@rabelux
Copy link
Member

rabelux commented May 14, 2020

Thanks!
It's all looking good so far, just came across 2 issues:

  1. When using the trackpad of my laptop scrolling/zooming is possible, but not with a (USB-)connected mouse. Any idea what could cause this?
  2. Not really a bug, just a minor inconvenience:
    The dragging-behaviour feels broken, as it doesn't show the frame of the original window

@simioni
Copy link

simioni commented May 14, 2020

@xupefei Thank you! QL is so much more usable now, you just made a lot of people very happy here. Great work!

version_info
@rabelux Can you confirm you're running v3.6.7-16-g1cd5019? Did you install from the MSI or are running directly from the .exe in the zip archive? What type of file are you previewing when you perceive the bug?

I could not reproduce either of these issues. Zooming / scrolling is working fine with trackpad and mouse (and touchscreen) for me. Dragging the QuickLook window also appears to be working correctly.

@xupefei
Copy link
Member

xupefei commented May 14, 2020

@rabelux for the second issue: it might be related to your GPU driver. Could you upload a screen-recording?

@rabelux
Copy link
Member

rabelux commented May 14, 2020

@simioni Confirming the version and I used the MSI-installer.
image
The bug appears on actually any format. I have tried with txt, pdf, xlsx, jpg, rtf, bak and png so far.

@xupefei
Copy link
Member

xupefei commented May 14, 2020

Are you using Windows 8? Then you might have this scrolling issue because

  1. Prior to Windows 10, there is no "scroll window under cursor" feature: https://www.nextofwindows.com/turn-onoff-scroll-inactive-window-under-mouse-cursor-in-windows-10
  2. When "scroll window under cursor" is off, a window must be focused to receive mouse wheel events
  3. Now QL window is non-focusable

I think I should disable this "non-focusable" behaviour for Windows 7 and 8/8.1.

@rabelux
Copy link
Member

rabelux commented May 14, 2020

I'm still on Win 7. That explains why scrolling with the mouse is not working. But why does the trackpad work? Is that some magic the synaptics driver does?
And is the dragging-issue connected to Win 7 not being able to handle non-focussed windows?
I just installed the last official release (v3.6.7) and dragging works fine.
Dragging with old version:
oldver
Dragging with new version:
dragissue

@xupefei
Copy link
Member

xupefei commented May 15, 2020

I see. Let me grab a Windows 8 VM and try again.

@xupefei xupefei reopened this May 15, 2020
@xupefei
Copy link
Member

xupefei commented May 16, 2020

Fixed!

xupefei added a commit that referenced this issue May 21, 2020
This reverts commit 452574e.

Revert "Fix #644 step 1: correctly bring window back to top when clicked"

This reverts commit af608dc.
@xupefei xupefei reopened this May 21, 2020
@xupefei
Copy link
Member

xupefei commented May 21, 2020

As you may have discovered, Windows has some bugs regarding the non-focusable window. The Z-order becomes messy when you do the follows:

  1. In an explorer window, select a file and preview it.
  2. Click on the title bar of the preview window (or move/resize the preview window).
  3. Go back to the explorer window and press up/down arrow keys.

After step 3, you will find the up/down arrow keys no longer change the selected file. Meanwhile, the focus switched to nowhere unless you close the preview window.

I will investigate this issue later, but now I have to roll back the change.

simioni added a commit to simioni/QuickLook that referenced this issue May 22, 2020
Keep window non-focusable. Feature added on this commit:
QL-Win@a7115f6
But removed for some issue discussed here:
QL-Win#644
mmasters1287 pushed a commit to mmasters1287/QuickLook that referenced this issue Oct 28, 2020
Jethro-Alter added a commit to Jethro-Alter/QuickLook that referenced this issue Dec 21, 2020
* Update Translations.config

* Update Translations.config

* Update Translations.config

* Create Privacy.md

* Rename Privacy.md to PRIVACY.md

* Update PRIVACY.md

* Update PRIVACY.md

* Fix QL-Win#579: search box changed in Windows 10 1909

* Fix QL-Win#579: also deal with non-English UIs

* don't bring existing window to the front

* Revert "Fix QL-Win#644: still use focusable window on Windows 7 and 8"

This reverts commit 452574e.

Revert "Fix QL-Win#644 step 1: correctly bring window back to top when clicked"

This reverts commit af608dc.

* Fix QL-Win#401: use the native image provider to render static GIFs

* Update Translations.config

Hungarian language added.

* Fix QL-Win#669: convert image to sRGB only when the original ColorSpace is RGB, sRGB, or scRGB

* Upgrade Magick.NET packages

* Fix QL-Win#669 again: stupid syntax mistake :(

* Bulk update NuGet packages

* Update Translations.config

Typo correction on line 61 and 69. Fixing slight translation mistakes and some words also replaced with more commonly used words.

* Support File Path longer than 260 (tweak needed: https://www.tenforums.com/tutorials/51704-enable-disable-win32-long-paths-windows-10-a.html)

* Add EXR to ImageViewer

* Add MXF to VideoViewer

* Decrease update checking frequency to monthly

* Fix QL-Win#715: add 1s timeout before any previewing request

* Fix QL-Win#711: adjust UI before loading any PDF page

* Fix QL-Win#729: add a config flag to hide the tray icon

* Fix QL-Win#731: use app folder for saving data in the portable mode

* Fix QL-Win#733: detect Markdown encoding

* Fix QL-Win#734: add AVIF format

* Update .appveyor.yml

* added german translation for newly added string

* fix a typo

* Fix QL-Win#744: Components are not correctly disposed upon exit

* Fix QL-Win#477: Add JFIF files

* Update bug_report.md

* typo

* Fix QL-Win#420, QL-Win#452, QL-Win#757: windows positioning for monitors with different DPIs

* Update Common to fix plugin resize

* Fix QL-Win#759: fix thumbnail orientation for some camera models

* Fix QL-Win#760, support CR3

* removed dup of ".asf" and added ".mka" for testing

Co-authored-by: Piteriuz <piteriuz@outlook.com>
Co-authored-by: Pengfei Xu <xupaddy@gmail.com>
Co-authored-by: Bobcruise <bobcruise07@gmail.com>
Co-authored-by: davinhanif <39960696+davinhanif@users.noreply.github.com>
Co-authored-by: Alexander Raab <alexander.raab1@gmx.de>
@hansbizarre
Copy link

If anyone is still looking for a workaround to this, you can install AutoHotkey (free) and use the script in this thread:
https://www.autohotkey.com/boards/viewtopic.php?f=82&t=121811

@emako
Copy link
Member

emako commented Jan 5, 2025

Currently nightly build version has canceled focusable window

@emako emako closed this as completed Jan 5, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants