From 38de5011e1a365d496c0265c059c6cd7e4d5d547 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 18 Jan 2012 19:25:16 +0000 Subject: [PATCH] remove-callback-window --- direct/src/showbase/ShowBase.py | 9 ++++--- direct/src/wxwidgets/WxPandaWindow.py | 36 +++++++++++++++------------ 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 39b8799eb9..7ddb78496d 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -792,12 +792,14 @@ class ShowBase(DirectObject.DirectObject): return win - def closeWindow(self, win, keepCamera = 0): + def closeWindow(self, win, keepCamera = False, removeWindow = True): """ Closes the indicated window and removes it from the list of windows. If it is the main window, clears the main window pointer to None. """ + win.setActive(False) + # First, remove all of the cameras associated with display # regions on the window. numRegions = win.getNumDisplayRegions() @@ -838,7 +840,8 @@ class ShowBase(DirectObject.DirectObject): self.winControls.remove(winCtrl) break # Now we can actually close the window. - self.graphicsEngine.removeWindow(win) + if removeWindow: + self.graphicsEngine.removeWindow(win) self.winList.remove(win) mainWindow = False @@ -896,7 +899,7 @@ class ShowBase(DirectObject.DirectObject): which case base.win may be either None, or the previous, closed window). """ - keepCamera = kw.get('keepCamera', 0) + keepCamera = kw.get('keepCamera', False) success = 1 oldWin = self.win diff --git a/direct/src/wxwidgets/WxPandaWindow.py b/direct/src/wxwidgets/WxPandaWindow.py index 09fcdaa5f1..1761d19777 100644 --- a/direct/src/wxwidgets/WxPandaWindow.py +++ b/direct/src/wxwidgets/WxPandaWindow.py @@ -54,13 +54,12 @@ class EmbeddedPandaWindow(wx.Window): event.Skip() def cleanup(self): - """ Parent windows should call cleanp() to clean up the + """ Parent windows should call cleanup() to clean up the wxPandaWindow explicitly (since we can't catch EVT_CLOSE directly). """ if self.win: base.closeWindow(self.win) self.win = None - self.Destroy() def onSize(self, event): wp = WindowProperties() @@ -77,6 +76,8 @@ else: within the wx GLCanvas object. It is supported whenever OpenGL is Panda's rendering engine, and GLCanvas is available in wx. """ + removeCallbackWindow = ConfigVariableBool('remove-callback-window', True) + Keymap = { wx.WXK_BACK : KeyboardButton.backspace(), wx.WXK_TAB : KeyboardButton.tab(), @@ -204,13 +205,15 @@ else: event.Skip() def cleanup(self): - """ Parent windows should call cleanp() to clean up the + """ Parent windows should call cleanup() to clean up the wxPandaWindow explicitly (since we can't catch EVT_CLOSE directly). """ if self.win: - base.closeWindow(self.win) + self.win.clearEventsCallback() + self.win.clearPropertiesCallback() + self.win.clearRenderCallback() + base.closeWindow(self.win, removeWindow = self.removeCallbackWindow) self.win = None - self.Destroy() def __buttonDown(self, button): self.inputDevice.buttonDown(button) @@ -304,7 +307,7 @@ else: event.Skip() def onPaint(self, event): - """ This is called whenever we get the fisrt paint event, + """ This is called whenever we get the first paint event, at which point we can conclude that the window has actually been manifested onscreen. (In X11, there appears to be no way to know this otherwise.) """ @@ -315,17 +318,18 @@ else: #event.Skip() def onIdle(self, event): - size = None - properties = self.win.getProperties() - if properties.hasSize(): - size = (properties.getXSize(), properties.getYSize()) + if self.win: + size = None + properties = self.win.getProperties() + if properties.hasSize(): + size = (properties.getXSize(), properties.getYSize()) - if tuple(self.GetClientSize()) != size: - # The window has changed size during the idle call. - # This seems to be possible in Linux. - wp = WindowProperties() - wp.setSize(*self.GetClientSize()) - self.win.requestProperties(wp) + if tuple(self.GetClientSize()) != size: + # The window has changed size during the idle call. + # This seems to be possible in Linux. + wp = WindowProperties() + wp.setSize(*self.GetClientSize()) + self.win.requestProperties(wp) event.Skip()