Browse Source

Fixes for Windows 8 DPI awareness, Windows GL window touch events, and some GL compatibility tweaks.

tags/2021-05-28
jules 12 years ago
parent
commit
b26cc92546
3 changed files with 56 additions and 23 deletions
  1. +1
    -1
      modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp
  2. +39
    -7
      modules/juce_gui_basics/native/juce_win32_Windowing.cpp
  3. +16
    -15
      modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp

+ 1
- 1
modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp View File

@@ -42,7 +42,7 @@ public:
Component* getComponentUnderMouse() const Component* getComponentUnderMouse() const
{ {
return static_cast <Component*> (componentUnderMouse);
return componentUnderMouse.get();
} }
ModifierKeys getCurrentModifiers() const ModifierKeys getCurrentModifiers() const


+ 39
- 7
modules/juce_gui_basics/native/juce_win32_Windowing.cpp View File

@@ -112,11 +112,13 @@ typedef BOOL (WINAPI* RegisterTouchWindowFunc) (HWND, ULONG);
typedef BOOL (WINAPI* GetTouchInputInfoFunc) (HTOUCHINPUT, UINT, TOUCHINPUT*, int); typedef BOOL (WINAPI* GetTouchInputInfoFunc) (HTOUCHINPUT, UINT, TOUCHINPUT*, int);
typedef BOOL (WINAPI* CloseTouchInputHandleFunc) (HTOUCHINPUT); typedef BOOL (WINAPI* CloseTouchInputHandleFunc) (HTOUCHINPUT);
typedef BOOL (WINAPI* GetGestureInfoFunc) (HGESTUREINFO, GESTUREINFO*); typedef BOOL (WINAPI* GetGestureInfoFunc) (HGESTUREINFO, GESTUREINFO*);
typedef BOOL (WINAPI* SetProcessDPIAwareFunc)();
static RegisterTouchWindowFunc registerTouchWindow = nullptr; static RegisterTouchWindowFunc registerTouchWindow = nullptr;
static GetTouchInputInfoFunc getTouchInputInfo = nullptr; static GetTouchInputInfoFunc getTouchInputInfo = nullptr;
static CloseTouchInputHandleFunc closeTouchInputHandle = nullptr; static CloseTouchInputHandleFunc closeTouchInputHandle = nullptr;
static GetGestureInfoFunc getGestureInfo = nullptr; static GetGestureInfoFunc getGestureInfo = nullptr;
static SetProcessDPIAwareFunc setProcessDPIAware = nullptr;
static bool hasCheckedForMultiTouch = false; static bool hasCheckedForMultiTouch = false;
@@ -140,6 +142,27 @@ static inline Rectangle<int> rectangleFromRECT (const RECT& r) noexcept
return Rectangle<int>::leftTopRightBottom ((int) r.left, (int) r.top, (int) r.right, (int) r.bottom); return Rectangle<int>::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 Desktop::DisplayOrientation Desktop::getCurrentOrientation() const
{ {
@@ -1322,6 +1345,7 @@ private:
if (canUseMultiTouch()) if (canUseMultiTouch())
registerTouchWindow (hwnd, 0); registerTouchWindow (hwnd, 0);
setDPIAwareness();
updateBorderSize(); updateBorderSize();
// Calling this function here is (for some reason) necessary to make Windows // Calling this function here is (for some reason) necessary to make Windows
@@ -1777,8 +1801,13 @@ private:
return false; 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<TOUCHINPUT> inputInfo (numInputs); HeapBlock<TOUCHINPUT> inputInfo (numInputs);
if (getTouchInputInfo (eventHandle, numInputs, inputInfo, sizeof (TOUCHINPUT))) if (getTouchInputInfo (eventHandle, numInputs, inputInfo, sizeof (TOUCHINPUT)))
@@ -1791,12 +1820,13 @@ private:
{ {
if (! handleTouchInput (inputInfo[i], (flags & TOUCHEVENTF_DOWN) != 0, if (! handleTouchInput (inputInfo[i], (flags & TOUCHEVENTF_DOWN) != 0,
(flags & TOUCHEVENTF_UP) != 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); closeTouchInputHandle (eventHandle);
return 0;
} }
bool handleTouchInput (const TOUCHINPUT& touch, const bool isDown, const bool isUp) bool handleTouchInput (const TOUCHINPUT& touch, const bool isDown, const bool isUp)
@@ -2243,7 +2273,8 @@ private:
case WM_NCHITTEST: case WM_NCHITTEST:
if ((styleFlags & windowIgnoresMouseClicks) != 0) if ((styleFlags & windowIgnoresMouseClicks) != 0)
return HTTRANSPARENT; return HTTRANSPARENT;
else if (! hasTitleBar())
if (! hasTitleBar())
return HTCLIENT; return HTCLIENT;
break; break;
@@ -2295,11 +2326,10 @@ private:
return 0; return 0;
case WM_TOUCH: 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 */ case 0x119: /* WM_GESTURE */
if (doGestureEvent (lParam)) if (doGestureEvent (lParam))
@@ -3158,6 +3188,8 @@ static BOOL CALLBACK enumMonitorsProc (HMONITOR, HDC, LPRECT r, LPARAM userInfo)
void Desktop::Displays::findDisplays() void Desktop::Displays::findDisplays()
{ {
setDPIAwareness();
Array <Rectangle<int> > monitors; Array <Rectangle<int> > monitors;
EnumDisplayMonitors (0, 0, &enumMonitorsProc, (LPARAM) &monitors); EnumDisplayMonitors (0, 0, &enumMonitorsProc, (LPARAM) &monitors);


+ 16
- 15
modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp View File

@@ -72,8 +72,8 @@ struct Target
class PositionedTexture class PositionedTexture
{ {
public: public:
PositionedTexture (OpenGLTexture& texture, const EdgeTable& et, const Rectangle<int>& clip_)
: clip (clip_.getIntersection (et.getMaximumBounds()))
PositionedTexture (OpenGLTexture& texture, const EdgeTable& et, const Rectangle<int>& clipRegion)
: clip (clipRegion.getIntersection (et.getMaximumBounds()))
{ {
if (clip.contains (et.getMaximumBounds())) if (clip.contains (et.getMaximumBounds()))
{ {
@@ -87,8 +87,8 @@ public:
} }
} }
PositionedTexture (GLuint textureID_, const Rectangle<int> area_, const Rectangle<int> clip_) noexcept
: textureID (textureID_), area (area_), clip (clip_)
PositionedTexture (GLuint texture, const Rectangle<int> r, const Rectangle<int> clipRegion) noexcept
: textureID (texture), area (r), clip (clipRegion)
{} {}
GLuint textureID; GLuint textureID;
@@ -937,9 +937,10 @@ struct StateHelpers
} }
context.extensions.glGenBuffers (2, buffers); 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.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 JUCE_CHECK_OPENGL_ERROR
} }
@@ -1012,10 +1013,10 @@ struct StateHelpers
GLuint colour; 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 #else
enum { numQuads = 8192 };
enum { numQuads = 64 }; // (had problems with my drivers segfaulting when these buffers are any larger)
#endif #endif
GLuint buffers[2]; GLuint buffers[2];
@@ -1026,7 +1027,7 @@ struct StateHelpers
void draw() noexcept 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); glDrawElements (GL_TRIANGLES, (numVertices * 3) / 2, GL_UNSIGNED_SHORT, 0);
JUCE_CHECK_OPENGL_ERROR JUCE_CHECK_OPENGL_ERROR
numVertices = 0; numVertices = 0;
@@ -1104,11 +1105,11 @@ struct StateHelpers
class GLState class GLState
{ {
public: 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()) previousFrameBufferTarget (OpenGLFrameBuffer::getCurrentFrameBufferTarget())
{ {
// This object can only be created and used when the current thread has an active OpenGL context. // This object can only be created and used when the current thread has an active OpenGL context.


Loading…
Cancel
Save