make panda window the active window?

Hello my fellow Panda users, it’s been a while.

I’ve been noticing this issue more and more in my game. Sometimes during initialization the Panda window fails to become the active window and ends up behind others.

This might be a bug and could be fixed, but meanwhile…

So I’m wondering, is there a function to make the Panda window the active window? (so it will be drawn on top of others, become visible and accept input)

Windows OS.

Thanks.

You should be able to do so by calling requestProperties with a WindowProperties object that has setForeground set.

Doesn’t work, probably doing it wrong. Example:

winprops = WindowProperties()
winprops.setForeground(True)
base.win.requestProperties(winprops)

Which version of Windows are you using? Also, does requestProperties cause any warnings to be emitted?

Windows 7 64bit.

Here’s a way to test this out:

from panda3d.core import *
import direct.directbase.DirectStart
from direct.task import Task

winprops = WindowProperties()
winprops.setForeground(True)

def makeWindowActive(task):
	base.win.requestProperties(winprops)
	return task.again

taskMgr.doMethodLater(0.5, makeWindowActive, "makeWindowActive")

run()

Switch windows and see what happens.
You will get bunch of these:

:display:windisplay(warning): SetForegroundWindow() failed!

But not each 0.5 seconds and it will actually work, each 10th time or so, but only if the currently active window is a Python console window.

Hmm, I believe that Windows only allows a process to move its window to the foreground if a window from another process isn’t currently active. If this is the case, then I’m afraid that this is simply an OS limitation.