diff --git a/makepanda/installpanda.py b/makepanda/installpanda.py index a84fb02ac6..fa9c744927 100644 --- a/makepanda/installpanda.py +++ b/makepanda/installpanda.py @@ -127,7 +127,7 @@ def GetLibDir(): something like "lib" or "lib64" or in some cases, something similar to "lib/x86_64-linux-gnu". """ - if sys.platform in ("darwin", "win32"): + if sys.platform in ("darwin", "win32", "cygwin"): return "lib" # This one's a bit tricky. Some systems require us to install diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 00c250acb4..69d9d6171c 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1361,9 +1361,11 @@ def CompileIgate(woutd,wsrc,opts): cmd += ' -srcdir %s -I%s' % (srcdir, srcdir) cmd += ' -DCPPPARSER -D__STDC__=1 -D__cplusplus=201103L' if (COMPILER=="MSVC"): - cmd += ' -D_X86_ -DWIN32_VC -DWIN32 -D_WIN32' + cmd += ' -DWIN32_VC -DWIN32 -D_WIN32' if GetTargetArch() == 'x64': - cmd += ' -DWIN64_VC -DWIN64 -D_WIN64' + cmd += ' -DWIN64_VC -DWIN64 -D_WIN64 -D_M_X64 -D_M_AMD64' + else: + cmd += ' -D_M_IX86' # NOTE: this 1600 value is the version number for VC2010. cmd += ' -D_MSC_VER=1600 -D"__declspec(param)=" -D__cdecl -D_near -D_far -D__near -D__far -D__stdcall' if (COMPILER=="GCC"): @@ -2631,7 +2633,7 @@ if (PkgSkip("DIRECT")==0): os.remove(GetOutputDir() + '/direct/ffi/panda3d.pyc') # This used to exist; no longer. -if sys.platform == 'win32': +if GetTarget() == 'windows': core_so = GetOutputDir() + '/panda3d/core.pyd' direct_so = GetOutputDir() + '/panda3d/direct.pyd' dtoolconfig_so = GetOutputDir() + '/panda3d/dtoolconfig.pyd' diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index dd6c06c191..4c4c2581ce 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -508,14 +508,14 @@ def oscmd(cmd, ignoreError = False): print(GetColor("blue") + cmd.split(" ", 1)[0] + " " + GetColor("magenta") + cmd.split(" ", 1)[1] + GetColor()) sys.stdout.flush() - if sys.platform in ("win32", "cygwin"): + if sys.platform == "win32": exe = cmd.split()[0] exe_path = LocateBinary(exe) if exe_path is None: exit("Cannot find "+exe+" on search path") res = os.spawnl(os.P_WAIT, exe_path, cmd) else: - res = os.system(cmd) + res = subprocess.call(cmd, shell=True) sig = res & 0x7F if (GetVerbose() and res != 0): print(ColorText("red", "Process exited with exit status %d and signal code %d" % ((res & 0xFF00) >> 8, sig))) @@ -539,7 +539,7 @@ def oscmd(cmd, ignoreError = False): if sys.platform == "win32": os.spawnl(os.P_WAIT, exe_path, verbose_cmd) else: - os.system(verbose_cmd) + subprocess.call(verbose_cmd, shell=True) exit("The following command returned a non-zero value: " + str(cmd)) return res @@ -2219,7 +2219,11 @@ def SdkAutoDisableSpeedTree(): def AddToPathEnv(path,add): if path in os.environ: - os.environ[path] = add + os.pathsep + os.environ[path] + if sys.platform == 'cygwin' and path != "PATH": + # INCLUDE, LIB, etc. must remain in Windows-style in cygwin. + os.environ[path] = add + ';' + os.environ[path] + else: + os.environ[path] = add + os.pathsep + os.environ[path] else: os.environ[path] = add @@ -2551,6 +2555,10 @@ def CopyFile(dstfile, srcfile): os.symlink(os.readlink(srcfile), dstfile) else: WriteBinaryFile(dstfile, ReadBinaryFile(srcfile)) + + if sys.platform == 'cygwin' and os.path.splitext(dstfile)[1].lower() in ('.dll', '.exe'): + os.chmod(dstfile, 0o755) + JustBuilt([dstfile], [srcfile]) def CopyAllFiles(dstdir, srcdir, suffix=""): @@ -2585,7 +2593,9 @@ def CopyTree(dstdir, srcdir, omitVCS=True): if not omitVCS or entry not in VCS_DIRS: CopyTree(dstpth, srcpth) else: - if sys.platform == 'win32': + if GetHost() == 'windows': + srcdir = srcdir.replace('/', '\\') + dstdir = dstdir.replace('/', '\\') cmd = 'xcopy /I/Y/E/Q "' + srcdir + '" "' + dstdir + '"' else: cmd = 'cp -R -f ' + srcdir + ' ' + dstdir diff --git a/panda/src/windisplay/config_windisplay.cxx b/panda/src/windisplay/config_windisplay.cxx index e0bda2979e..4d8f8efc5b 100644 --- a/panda/src/windisplay/config_windisplay.cxx +++ b/panda/src/windisplay/config_windisplay.cxx @@ -71,6 +71,14 @@ ConfigVariableBool dpi_aware "that is introduced in Windows 8.1. Set this to false if you are " "experiencing problems with this setting.")); +ConfigVariableBool dpi_window_resize +("dpi-window-resize", false, + PRC_DESC("Set this to true to let Panda3D resize the window according to the " + "DPI settings whenever the window is dragged to a monitor with " + "different DPI, or when the DPI setting is changed in the control " + "panel. Only available in Windows 8.1 and later, and requires " + "dpi-aware to be set as well.")); + ConfigVariableBool swapbuffer_framelock ("swapbuffer-framelock", false, PRC_DESC("Set this true to enable HW swapbuffer frame-lock on 3dlabs cards")); diff --git a/panda/src/windisplay/config_windisplay.h b/panda/src/windisplay/config_windisplay.h index f3f7cb1ea4..a620b4e64a 100644 --- a/panda/src/windisplay/config_windisplay.h +++ b/panda/src/windisplay/config_windisplay.h @@ -31,6 +31,7 @@ extern ConfigVariableBool ime_aware; extern ConfigVariableBool ime_hide; extern ConfigVariableBool request_dxdisplay_information; extern ConfigVariableBool dpi_aware; +extern ConfigVariableBool dpi_window_resize; extern EXPCL_PANDAWIN ConfigVariableBool swapbuffer_framelock; diff --git a/panda/src/windisplay/winGraphicsPipe.cxx b/panda/src/windisplay/winGraphicsPipe.cxx index eb56ec2f10..8fd031ffef 100644 --- a/panda/src/windisplay/winGraphicsPipe.cxx +++ b/panda/src/windisplay/winGraphicsPipe.cxx @@ -32,6 +32,12 @@ TypeHandle WinGraphicsPipe::_type_handle; #define MAXIMUM_PROCESSORS 32 #endif +typedef enum _Process_DPI_Awareness { + Process_DPI_Unaware = 0, + Process_System_DPI_Aware = 1, + Process_Per_Monitor_DPI_Aware = 2 +} Process_DPI_Awareness; + typedef struct _PROCESSOR_POWER_INFORMATION { ULONG Number; ULONG MaxMhz; @@ -686,7 +692,6 @@ WinGraphicsPipe() { // these fns arent defined on win95, so get dynamic ptrs to them // to avoid ugly DLL loader failures on w95 _pfnTrackMouseEvent = NULL; - _pfnSetProcessDPIAware = NULL; _hUser32 = (HINSTANCE)LoadLibrary("user32.dll"); if (_hUser32 != NULL) { @@ -694,13 +699,20 @@ WinGraphicsPipe() { (PFN_TRACKMOUSEEVENT)GetProcAddress(_hUser32, "TrackMouseEvent"); if (dpi_aware) { - _pfnSetProcessDPIAware = - (PFN_SETPROCESSDPIAWARE)GetProcAddress(_hUser32, "SetProcessDPIAware"); + typedef HRESULT (WINAPI *PFN_SETPROCESSDPIAWARENESS)(Process_DPI_Awareness); + PFN_SETPROCESSDPIAWARENESS pfnSetProcessDpiAwareness = + (PFN_SETPROCESSDPIAWARENESS)GetProcAddress(_hUser32, "SetProcessDpiAwarenessInternal"); - if (windisplay_cat.is_debug()) { - windisplay_cat.debug() << "Calling SetProcessDPIAware().\n"; + if (pfnSetProcessDpiAwareness == NULL) { + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "Unable to find SetProcessDpiAwareness in user32.dll.\n"; + } + } else { + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "Calling SetProcessDpiAwareness().\n"; + } + pfnSetProcessDpiAwareness(Process_Per_Monitor_DPI_Aware); } - _pfnSetProcessDPIAware(); } } diff --git a/panda/src/windisplay/winGraphicsPipe.h b/panda/src/windisplay/winGraphicsPipe.h index 2afeaf0b94..88d3e264d6 100644 --- a/panda/src/windisplay/winGraphicsPipe.h +++ b/panda/src/windisplay/winGraphicsPipe.h @@ -45,9 +45,6 @@ private: typedef BOOL (WINAPI *PFN_TRACKMOUSEEVENT)(LPTRACKMOUSEEVENT); PFN_TRACKMOUSEEVENT _pfnTrackMouseEvent; - typedef BOOL (WINAPI *PFN_SETPROCESSDPIAWARE)(void); - PFN_SETPROCESSDPIAWARE _pfnSetProcessDPIAware; - public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 5018fb8a4a..f270a70f61 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -26,6 +26,10 @@ #include +#ifndef WM_DPICHANGED +#define WM_DPICHANGED 0x02E0 +#endif + TypeHandle WinGraphicsWindow::_type_handle; TypeHandle WinGraphicsWindow::WinWindowHandle::_type_handle; @@ -2151,6 +2155,28 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { system_changed_properties(properties); break; + case WM_DPICHANGED: + // The window moved to a monitor of different DPI, or someone changed + // the DPI setting in the configuration panel. + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "DPI changed to " << LOWORD(wparam); + + if (LOWORD(wparam) != HIWORD(wparam)) { + windisplay_cat.debug(false) << "x" << HIWORD(wparam) << "\n"; + } else { + windisplay_cat.debug(false) << "\n"; + } + } + // Resize the window if requested to match the new DPI. + // Obviously, don't do this if a fixed size was requested. + if (!_properties.get_fixed_size() && dpi_window_resize) { + RECT &rect = *(LPRECT)lparam; + SetWindowPos(_hWnd, HWND_TOP, rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top, + SWP_NOZORDER | SWP_NOACTIVATE); + } + break; + #ifdef HAVE_WIN_TOUCHINPUT case WM_TOUCH: _numTouches = LOWORD(wparam);