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

Issue with Preview #2355

Open
specter78 opened this issue May 6, 2020 · 10 comments
Open

Issue with Preview #2355

specter78 opened this issue May 6, 2020 · 10 comments

Comments

@specter78
Copy link

specter78 commented May 6, 2020

I have the following script.

function previewWatcher(appName, eventType, appObject)
  if ((eventType == hs.application.watcher.activated) or (eventType == hs.application.watcher.launched)) then
    if (appName == "Preview") then
      local win = hs.window.focusedWindow()
      local f = win:frame()
      local screen = win:screen()
      local max = screen:frame()

      f.x = max.x
      f.y = max.y
      f.w = max.w
      f.h = max.h
      win:setFrame(f)
    end
  end
end
hs.application.watcher.new(previewWatcher):start()

This script only runs when preview window is activated and doesn't run when launched. Also when the window is closed, the preview icon stays in the dock, instead of going away.

On clicking the app icon in dock, file open dialog appears which becomes full screen.

@specter78
Copy link
Author

Also when the window is closed, the preview icon stays in the dock, instead of going away.
On clicking the app icon in dock, file open dialog appears which becomes full screen.

In fact, even when I make the window full screen using keyboard shortcut and then close the window, same issue occurs.

@specter78
Copy link
Author

I also tried the left and right half screen scripts with preview. And it doesn’t work. The two windows overlap for some portion.

@cmsj
Copy link
Member

cmsj commented May 10, 2020

Icons staying in the Dock when you close an application's window, is normal behaviour in macOS.

I think you probably need more logic to check to see what kind of window the focused one is, and if it's an Open window, ignore it.

I'm not sure why you're not getting the launched event, that's probably worth investigating.

@specter78
Copy link
Author

Icons staying in the Dock when you close an application's window, is normal behaviour in macOS.

For other applications, yes. For preview, no.

They only stay in dock if Hammerspoon is used.

I'm not sure why you're not getting the launched event, that's probably worth investigating.

I think I have some idea. It triggers when the application is launched after quitting.

However once opened and closed which removes it from dock and Force Quit menu, launched is not triggered. (But if the app is not in Force Quit menu, I assume that launched should be called.)

@cmsj
Copy link
Member

cmsj commented May 11, 2020

@specter78
Copy link
Author

I suspect you might be seeing something like https://apple.stackexchange.com/questions/133158/preview-is-closed-in-mavericks-when-last-window-is-closed

Yes. That is what should happen, but isn’t happening when I resize preview window using hammer spoon.

@cmsj
Copy link
Member

cmsj commented May 12, 2020

Sorry, I specifically meant this comment: https://apple.stackexchange.com/a/196536 - I suspect that some part of Preview is still running, which would explain why you don’t get the launched event.

Hammerspoon does not stop Preview from quitting, and I don’t think there is even a way that that could happen. I’d forgotten about the app termination thing in some versions of macOS, but the “app stays open after the last window closes” behaviour is traditionally normal for macOS and isn’t related to Hammerspoon.

@specter78
Copy link
Author

Sorry, I specifically meant this comment: https://apple.stackexchange.com/a/196536 - I suspect that some part of Preview is still running, which would explain why you don’t get the launched event.

I also think so.

Also when the window is closed, the preview icon stays in the dock, instead of going away.

I think the following video may help you understand the issue better.

video

@specter78
Copy link
Author

I’ve found that the same thing happens for pages, QuickTime, etc. for which the dock icon used to automatically disappear.

@cmsj
Copy link
Member

cmsj commented May 19, 2020

Perhaps Catalina has broken the automatic app?
I’m not really sure what Hammerspoon can do about any of this though - how the OS manages apps is not really our business.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants