Skip to content

Conversation

@tokejepsen
Copy link
Collaborator

What's changed?
Added an window.activateWindow to each tool.
When running the tools standalone triggered from a different window, the tools can get hidden behind the triggering window. This will bring them to the front of the user attention.

Copy link
Collaborator

@davidlatwe davidlatwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for Photoshop integration ?
Just tested in other DCCs (Houdini, Maya, Nuke) and everything is fine. :)
Nice work !

Copy link
Collaborator

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I recall reading somewhere this doesn't work on all OS platforms. Could be wrong but might something you want to check up on. It won't error but just wouldn't give the expected results.

For example here it describes using .raise() on Mac OS X.

@mottosso
Copy link
Contributor

mottosso commented Feb 4, 2020

Roy is right, raising a window is a big mess cross-platform with Qt. Here's what QML does. Each of those are necessary, in that order, to cover all edge cases and platforms. Though I've still heard some having issues with it appearing behind another window? It's been rare though, but took a while to figure out.

@tokejepsen
Copy link
Collaborator Author

Is this for Photoshop integration ?

Yes, this is in particular for the Photoshop integration where the python process runs in the background, so the windows get hidden behind the Photoshop window.

For example here it describes using .raise() on Mac OS X.

I cant test on OSX but adding the call does hurt anything.

Here's what QML does.

Using WindowStaysOnTopHint does help with the initial showing of the window as well!
Will need to account for when showing in DCCs, but can just query parentWidget().

Will update the PR in a bit.

- When in standalone add WindowStaysOnTopHint.
- For MacOS "raise_()".
@BigRoy
Copy link
Collaborator

BigRoy commented Feb 4, 2020

The latest commit made it so that the Windows always stay on top of all Windows when standalone right? So even over other applications. I'm expecting we wouldn't want that. Correct?

@tokejepsen
Copy link
Collaborator Author

The latest commit made it so that the Windows always stay on top of all Windows when standalone right? So even over other applications. I'm expecting we wouldn't want that. Correct?

It only stays ontop of the windows within the QApplication, so not other OS windows.

@BigRoy
Copy link
Collaborator

BigRoy commented Feb 4, 2020

It only stays ontop of the windows within the QApplication, so not other OS windows.

If that's the case then it's fine with me. But are you sure?

I quickly tried on a random Qt application window that I had running in Houdini and with that flag set it would never go behind other applications. As such it was always on top in front of my Browser, Windows Explorer, everything. (except for Windows Task Manager, it would appear behind that one - until I disabled "Options > Always on Top" for Task Manager)

E.g. this always stays on top:

# assumes a running QApplication instance
from PySide2 import QtWidgets, QtCore

class Window(QtWidgets.QDialog):

    def __init__(self, parent=None):
        super(Window, self).__init__(parent=parent)
        
        self.setWindowFlags(
                self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint
        )
        
window = Window()
window.show()

@tokejepsen
Copy link
Collaborator Author

I quickly tried on a random Qt application window that I had running in Houdini and with that flag set it would never go behind other applications. As such it was always on top in front of my Browser, Windows Explorer, everything. (except for Windows Task Manager, it would appear behind that one - until I disabled "Options > Always on Top" for Task Manager)

The flag is only added when we use the tools standalone, so Maya/Nuke/Houdini would not be affected.

In standalone (Photoshop) I get this behaviour:

Untitled_ Feb 4, 2020 10_42 AM

@BigRoy
Copy link
Collaborator

BigRoy commented Feb 4, 2020

In standalone (Photoshop) I get this behaviour:

That is odd. That is not at all what I'm seeing in my standalone runs. I wonder where the behavior differs.

I pulled your branch into my repository to give it a go and ran a standalone Loader from the Launcher. It stays on top of everything... then I run it again, suddenly it's allowed to go behind. Then I run it again, and it's the opposite. It seems a bit random.

It seems whenever I run that application and do nothing as a user in-between so it comes in with focus... then suddenly it will always stay on top of everything. If however I shift focus and continue in another browser for example during the launch of the application then suddenly the Show on Top behavior does not happen? @tokejepsen can you reproduce this?

window_stay_on_top

@tokejepsen
Copy link
Collaborator Author

It seems whenever I run that application and do nothing as a user in-between so it comes in with focus... then suddenly it will always stay on top of everything. If however I shift focus and continue in another browser for example during the launch of the application then suddenly the Show on Top behavior does not happen? @tokejepsen can you reproduce this?

I cant reproduce the oddness, but can reproduce the always ontop issue. I can just remove the flag setting?

@BigRoy
Copy link
Collaborator

BigRoy commented Feb 4, 2020

I cant reproduce the oddness, but can reproduce the always ontop issue. I can just remove the flag setting?

👍 I think there's reason why @mottosso did this for Pyblish QML too so it could be worth actually doing that too if it's there with good reason. Or maybe it's redundant by now, no idea.

@jasperges
Copy link
Contributor

Tiling window manager anyone? Who needs floating windows, they are so 90's. 😛 😬

@tokejepsen
Copy link
Collaborator Author

How do we feel about this PR?

@davidlatwe
Copy link
Collaborator

Just looked through the commits and comments, I think this is good to merge.
Let's merge this tomorrow if no other objections. 🚀

…ate_window

# Conflicts:
#	avalon/tools/contextmanager/app.py
@tokejepsen
Copy link
Collaborator Author

tokejepsen commented May 13, 2020

Apart from the errors with coveralls, this is ready to be merged now.

@mottosso mottosso merged commit 4ab2bbb into getavalon:master May 19, 2020
@tokejepsen tokejepsen deleted the activate_window branch May 24, 2020 20:39
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

Successfully merging this pull request may close these issues.

5 participants