diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp index 0c05361f2e..db5cae2f4e 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp @@ -42,7 +42,7 @@ public: Component* getComponentUnderMouse() const { - return static_cast (componentUnderMouse); + return componentUnderMouse.get(); } ModifierKeys getCurrentModifiers() const diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 80a8924b3b..7c866aff61 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -112,11 +112,13 @@ typedef BOOL (WINAPI* RegisterTouchWindowFunc) (HWND, ULONG); typedef BOOL (WINAPI* GetTouchInputInfoFunc) (HTOUCHINPUT, UINT, TOUCHINPUT*, int); typedef BOOL (WINAPI* CloseTouchInputHandleFunc) (HTOUCHINPUT); typedef BOOL (WINAPI* GetGestureInfoFunc) (HGESTUREINFO, GESTUREINFO*); +typedef BOOL (WINAPI* SetProcessDPIAwareFunc)(); static RegisterTouchWindowFunc registerTouchWindow = nullptr; static GetTouchInputInfoFunc getTouchInputInfo = nullptr; static CloseTouchInputHandleFunc closeTouchInputHandle = nullptr; static GetGestureInfoFunc getGestureInfo = nullptr; +static SetProcessDPIAwareFunc setProcessDPIAware = nullptr; static bool hasCheckedForMultiTouch = false; @@ -140,6 +142,27 @@ static inline Rectangle rectangleFromRECT (const RECT& r) noexcept return Rectangle::leftTopRightBottom ((int) r.left, (int) r.top, (int) r.right, (int) r.bottom); } +static void setDPIAwareness() +{ + if (JUCEApplication::isStandaloneApp()) + { + if (setProcessDPIAware == nullptr) + setProcessDPIAware = (SetProcessDPIAwareFunc) getUser32Function ("SetProcessDPIAware"); + + if (setProcessDPIAware != nullptr) + setProcessDPIAware(); + } +} + +inline float getDisplayScale() +{ + HDC dc = GetDC (0); + const float scale = (GetDeviceCaps (dc, LOGPIXELSX) + + GetDeviceCaps (dc, LOGPIXELSY)) / (2.0f * 96.0f); + ReleaseDC (0, dc); + return scale; +} + //============================================================================== Desktop::DisplayOrientation Desktop::getCurrentOrientation() const { @@ -1322,6 +1345,7 @@ private: if (canUseMultiTouch()) registerTouchWindow (hwnd, 0); + setDPIAwareness(); updateBorderSize(); // Calling this function here is (for some reason) necessary to make Windows @@ -1777,8 +1801,13 @@ private: return false; } - void doTouchEvent (const int numInputs, HTOUCHINPUT eventHandle) + LRESULT doTouchEvent (const int numInputs, HTOUCHINPUT eventHandle) { + if ((styleFlags & windowIgnoresMouseClicks) != 0) + if (HWNDComponentPeer* const parent = getOwnerOfWindow (GetParent (hwnd))) + if (parent != this) + return parent->doTouchEvent (numInputs, eventHandle); + HeapBlock inputInfo (numInputs); if (getTouchInputInfo (eventHandle, numInputs, inputInfo, sizeof (TOUCHINPUT))) @@ -1791,12 +1820,13 @@ private: { if (! handleTouchInput (inputInfo[i], (flags & TOUCHEVENTF_DOWN) != 0, (flags & TOUCHEVENTF_UP) != 0)) - return; // abandon method if this window was deleted by the callback + return 0; // abandon method if this window was deleted by the callback } } } closeTouchInputHandle (eventHandle); + return 0; } bool handleTouchInput (const TOUCHINPUT& touch, const bool isDown, const bool isUp) @@ -2243,7 +2273,8 @@ private: case WM_NCHITTEST: if ((styleFlags & windowIgnoresMouseClicks) != 0) return HTTRANSPARENT; - else if (! hasTitleBar()) + + if (! hasTitleBar()) return HTCLIENT; break; @@ -2295,11 +2326,10 @@ private: return 0; case WM_TOUCH: - if (getTouchInputInfo == nullptr) - break; + if (getTouchInputInfo != nullptr) + return doTouchEvent ((int) wParam, (HTOUCHINPUT) lParam); - doTouchEvent ((int) wParam, (HTOUCHINPUT) lParam); - return 0; + break; case 0x119: /* WM_GESTURE */ if (doGestureEvent (lParam)) @@ -3158,6 +3188,8 @@ static BOOL CALLBACK enumMonitorsProc (HMONITOR, HDC, LPRECT r, LPARAM userInfo) void Desktop::Displays::findDisplays() { + setDPIAwareness(); + Array > monitors; EnumDisplayMonitors (0, 0, &enumMonitorsProc, (LPARAM) &monitors); diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 12f259f975..fcbcf7c4f6 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -72,8 +72,8 @@ struct Target class PositionedTexture { public: - PositionedTexture (OpenGLTexture& texture, const EdgeTable& et, const Rectangle& clip_) - : clip (clip_.getIntersection (et.getMaximumBounds())) + PositionedTexture (OpenGLTexture& texture, const EdgeTable& et, const Rectangle& clipRegion) + : clip (clipRegion.getIntersection (et.getMaximumBounds())) { if (clip.contains (et.getMaximumBounds())) { @@ -87,8 +87,8 @@ public: } } - PositionedTexture (GLuint textureID_, const Rectangle area_, const Rectangle clip_) noexcept - : textureID (textureID_), area (area_), clip (clip_) + PositionedTexture (GLuint texture, const Rectangle r, const Rectangle clipRegion) noexcept + : textureID (texture), area (r), clip (clipRegion) {} GLuint textureID; @@ -937,9 +937,10 @@ struct StateHelpers } context.extensions.glGenBuffers (2, buffers); - context.extensions.glBindBuffer (GL_ARRAY_BUFFER, buffers[0]); - context.extensions.glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, buffers[1]); + context.extensions.glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, buffers[0]); context.extensions.glBufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indexData), indexData, GL_STATIC_DRAW); + context.extensions.glBindBuffer (GL_ARRAY_BUFFER, buffers[1]); + context.extensions.glBufferData (GL_ARRAY_BUFFER, sizeof (vertexData), vertexData, GL_DYNAMIC_DRAW); JUCE_CHECK_OPENGL_ERROR } @@ -1012,10 +1013,10 @@ struct StateHelpers GLuint colour; }; - #if ! (JUCE_MAC || JUCE_ANDROID || JUCE_IOS) - enum { numQuads = 64 }; // (had problems with my drivers segfaulting when these buffers are any larger) + #if JUCE_MAC || JUCE_ANDROID || JUCE_IOS + enum { numQuads = 256 }; #else - enum { numQuads = 8192 }; + enum { numQuads = 64 }; // (had problems with my drivers segfaulting when these buffers are any larger) #endif GLuint buffers[2]; @@ -1026,7 +1027,7 @@ struct StateHelpers void draw() noexcept { - context.extensions.glBufferData (GL_ARRAY_BUFFER, numVertices * sizeof (VertexInfo), vertexData, GL_DYNAMIC_DRAW); + context.extensions.glBufferSubData (GL_ARRAY_BUFFER, 0, numVertices * sizeof (VertexInfo), vertexData); glDrawElements (GL_TRIANGLES, (numVertices * 3) / 2, GL_UNSIGNED_SHORT, 0); JUCE_CHECK_OPENGL_ERROR numVertices = 0; @@ -1104,11 +1105,11 @@ struct StateHelpers class GLState { public: - GLState (const Target& target_) noexcept - : target (target_), - activeTextures (target_.context), - currentShader (target_.context), - shaderQuadQueue (target_.context), + GLState (const Target& t) noexcept + : target (t), + activeTextures (t.context), + currentShader (t.context), + shaderQuadQueue (t.context), previousFrameBufferTarget (OpenGLFrameBuffer::getCurrentFrameBufferTarget()) { // This object can only be created and used when the current thread has an active OpenGL context.