diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 98abb1780b..9d9b2ee843 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -3050,6 +3050,10 @@ class ShowBase(DirectObject.DirectObject): init_app_for_gui() + # Disable the Windows message loop, since Tcl wants to handle this all + # on its own. + ConfigVariableBool('disable-message-loop', False).value = True + if ConfigVariableBool('tk-main-loop', True): # Put Tkinter in charge of the main loop. It really # seems to like this better; the GUI otherwise becomes diff --git a/panda/src/windisplay/config_windisplay.cxx b/panda/src/windisplay/config_windisplay.cxx index 62040c553a..ca3dc64f72 100644 --- a/panda/src/windisplay/config_windisplay.cxx +++ b/panda/src/windisplay/config_windisplay.cxx @@ -91,6 +91,13 @@ ConfigVariableBool paste_emit_keystrokes PRC_DESC("Handle paste events (Ctrl-V) as separate keystroke events for each " "pasted character.")); +ConfigVariableBool disable_message_loop +("disable-message-loop", false, + PRC_DESC("If this is false, Panda will process messages from the Windows " + "message loop, which is required for normal operation. You may set " + "this to true if some other UI framework (such as Tcl/Tk) needs " + "exclusive ownership of the message loop.")); + /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/src/windisplay/config_windisplay.h b/panda/src/windisplay/config_windisplay.h index 7199b8603d..ae6568ec11 100644 --- a/panda/src/windisplay/config_windisplay.h +++ b/panda/src/windisplay/config_windisplay.h @@ -32,6 +32,7 @@ extern ConfigVariableBool request_dxdisplay_information; extern ConfigVariableBool dpi_aware; extern ConfigVariableBool dpi_window_resize; extern ConfigVariableBool paste_emit_keystrokes; +extern ConfigVariableBool disable_message_loop; extern EXPCL_PANDAWIN ConfigVariableBool swapbuffer_framelock; diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 0e33e55399..39559fce7d 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -254,10 +254,12 @@ process_events() { MSG msg; - // Handle all the messages on the queue in a row. Some of these might be - // for another window, but they will get dispatched appropriately. - while (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) { - process_1_event(); + if (!disable_message_loop) { + // Handle all the messages on the queue in a row. Some of these might be + // for another window, but they will get dispatched appropriately. + while (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) { + process_1_event(); + } } }