From f72c72b36a25ace7825684567e877eb7e92a0055 Mon Sep 17 00:00:00 2001 From: LD Date: Thu, 28 Nov 2019 22:24:30 +0100 Subject: [PATCH 1/7] MacOS: Force disable application HiDPI support on NSView, fixes #794 --- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 42490b43da..5f7dfde474 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -549,6 +549,11 @@ open_window() { _parent_window_handle->attach_child(_window_handle); } + // Always disable application HiDPI support, Cocoa will do the eventual upscaling for us. + // Note: setWantsBestResolutionOpenGLSurface method is supported from MacOS 10.7 onwards + if ([_view respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) { + [_view setWantsBestResolutionOpenGLSurface:NO]; + } if (_properties.has_icon_filename()) { NSImage *image = load_image(_properties.get_icon_filename()); if (image != nil) { From 791be4766a07d0da7ee971ed57101114a77d3f04 Mon Sep 17 00:00:00 2001 From: LD Date: Thu, 28 Nov 2019 23:37:33 +0100 Subject: [PATCH 2/7] MacOS: Don't crash if no elements are returned by IOHIDDeviceCopyMatchingElements Fixes #797 --- panda/src/device/ioKitInputDevice.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/panda/src/device/ioKitInputDevice.cxx b/panda/src/device/ioKitInputDevice.cxx index 8468fd4816..1d8bf38f0f 100644 --- a/panda/src/device/ioKitInputDevice.cxx +++ b/panda/src/device/ioKitInputDevice.cxx @@ -114,12 +114,14 @@ IOKitInputDevice(IOHIDDeviceRef device) : } CFArrayRef elements = IOHIDDeviceCopyMatchingElements(device, nullptr, 0); - CFIndex count = CFArrayGetCount(elements); - for (CFIndex i = 0; i < count; ++i) { - IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(elements, i); - parse_element(element); + if (elements) { + CFIndex count = CFArrayGetCount(elements); + for (CFIndex i = 0; i < count; ++i) { + IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(elements, i); + parse_element(element); + } + CFRelease(elements); } - CFRelease(elements); if (_hat_element != nullptr) { _hat_left_button = (int)_buttons.size(); From 4f4b79295fff50d3db62ff600efb9e19fbb6a233 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 7 Dec 2019 14:32:09 +0100 Subject: [PATCH 3/7] makepanda: fix error when building on Android without specifying --target --- makepanda/makepandacore.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 0ba33518e8..18be690671 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -2479,6 +2479,8 @@ def SdkLocateAndroid(): return # Allow ANDROID_API/ANDROID_ABI to be used in makepanda.py. + if ANDROID_API is None: + SetTarget('android') api = ANDROID_API SDK["ANDROID_API"] = api From 97a19c278b5758689ca20bd6d9bcad612f30779c Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Dec 2019 10:27:46 +0100 Subject: [PATCH 4/7] parser-inc: define __SIZE_TYPE__ and __PTRDIFF_TYPE__ This fixes an Interrogate parse error in termux when /usr/include gets added as -S argument --- dtool/src/parser-inc/stdtypedefs.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dtool/src/parser-inc/stdtypedefs.h b/dtool/src/parser-inc/stdtypedefs.h index 873ba9425d..bd49086295 100644 --- a/dtool/src/parser-inc/stdtypedefs.h +++ b/dtool/src/parser-inc/stdtypedefs.h @@ -27,16 +27,18 @@ typedef unsigned long ulong; typedef unsigned short ushort; typedef unsigned char uchar; -inline namespace std { #ifdef _WIN64 - typedef unsigned long long size_t; - typedef long long ssize_t; - typedef long long ptrdiff_t; +#define __SIZE_TYPE__ unsigned long long +#define __PTRDIFF_TYPE__ long long #else - typedef unsigned long size_t; - typedef long ssize_t; - typedef long ptrdiff_t; +#define __SIZE_TYPE__ unsigned long +#define __PTRDIFF_TYPE__ long #endif + +inline namespace std { + typedef __SIZE_TYPE__ size_t; + typedef __PTRDIFF_TYPE__ ssize_t; + typedef __PTRDIFF_TYPE__ ptrdiff_t; } struct timeval; From 6e36abf5ba355551107e09ad8707cb8068bf334f Mon Sep 17 00:00:00 2001 From: kamgha Date: Sun, 1 Dec 2019 00:28:53 +0100 Subject: [PATCH 5/7] makepanda: build against OpenEXR 2.4 (MSVC) Fixes #799 Closes #800 --- makepanda/makepanda.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 48b2ef1da9..39e6805f61 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -735,8 +735,11 @@ if (COMPILER == "MSVC"): suffix = "-2_2" elif os.path.isfile(GetThirdpartyDir() + "openexr/lib/IlmImf-2_3.lib"): suffix = "-2_3" + elif os.path.isfile(GetThirdpartyDir() + "openexr/lib/IlmImf-2_4.lib"): + suffix = "-2_4" + LibName("OPENEXR", GetThirdpartyDir() + "openexr/lib/Imath" + suffix + ".lib") if os.path.isfile(GetThirdpartyDir() + "openexr/lib/IlmImf" + suffix + "_s.lib"): - suffix += "_s" + suffix += "_s" # _s suffix observed for OpenEXR 2.3 only so far LibName("OPENEXR", GetThirdpartyDir() + "openexr/lib/IlmImf" + suffix + ".lib") LibName("OPENEXR", GetThirdpartyDir() + "openexr/lib/IlmThread" + suffix + ".lib") LibName("OPENEXR", GetThirdpartyDir() + "openexr/lib/Iex" + suffix + ".lib") From b43b0c9fad0381c863a76260aeb9a004e106a6c8 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Dec 2019 12:40:37 +0100 Subject: [PATCH 6/7] dist: ship regular "distutils" even when in PyPI "virtualenv" env Fixes #747 --- direct/src/dist/FreezeTool.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/direct/src/dist/FreezeTool.py b/direct/src/dist/FreezeTool.py index 18ecbf109a..9c318b8438 100644 --- a/direct/src/dist/FreezeTool.py +++ b/direct/src/dist/FreezeTool.py @@ -2372,6 +2372,17 @@ class PandaModuleFinder(modulefinder.ModuleFinder): path = self.path + if fullname == 'distutils' and hasattr(sys, 'real_prefix'): + # The PyPI version of virtualenv inserts a special version of + # distutils that does some bizarre stuff that won't work in our + # deployed application. Force it to find the regular one. + try: + fp, fn, stuff = self.find_module('opcode') + if fn: + path = [os.path.dirname(fn)] + path + except ImportError: + pass + # Look for the module on the search path. for dir_path in path: basename = os.path.join(dir_path, name.split('.')[-1]) From 55f624e073f0eb35b2520ebec872958fd6d9f571 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Dec 2019 15:04:06 +0100 Subject: [PATCH 7/7] 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 --- direct/src/showbase/ShowBase.py | 4 ++++ panda/src/windisplay/config_windisplay.cxx | 7 +++++++ panda/src/windisplay/config_windisplay.h | 1 + panda/src/windisplay/winGraphicsWindow.cxx | 10 ++++++---- 4 files changed, 18 insertions(+), 4 deletions(-) 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(); + } } }