windisplay: add a variable to disable Panda's message pump

This is particularly important for Tcl/Tk, which assumes it is in charge of the Windows event loop.

Fixes #586
This commit is contained in:
rdb 2019-12-08 15:04:06 +01:00
parent b43b0c9fad
commit 55f624e073
4 changed files with 18 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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();
}
}
}