From ab02610378780df3d369ebd46f14a77b067a0b6b Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Fri, 11 Sep 2009 11:16:06 +0100 Subject: [PATCH] Added a browser plugin fix for Safari on Windows. --- .../wrapper/juce_NPAPI_GlueCode.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp b/extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp index f421d4ab6a..08e119f154 100644 --- a/extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp +++ b/extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp @@ -318,13 +318,24 @@ private: HWND parentHWND; WNDPROC oldWinProc; - void resizeToParentWindow() + void resizeToParentWindow (const int requestedWidth = 0, const int requestedHeight = 0) { if (IsWindow (parentHWND)) { RECT r; GetWindowRect (parentHWND, &r); - setBounds (0, 0, r.right - r.left, r.bottom - r.top); + + int w = r.right - r.left; + int h = r.bottom - r.top; + + if (w == 0 || h == 0) + { + w = requestedWidth; // On Safari, the HWND can have a zero-size, so we might need to + h = requestedHeight; // force it to the size that the NPAPI call asked for.. + MoveWindow (parentHWND, r.left, r.top, w, h, TRUE); + } + + setBounds (0, 0, w, h); } } @@ -392,7 +403,7 @@ public: oldWinProc = SubclassWindow (parentHWND, (WNDPROC) interceptingWinProc); SetWindowLongPtr (parentHWND, GWL_USERDATA, (LONG_PTR) this); - resizeToParentWindow(); + resizeToParentWindow (window->width, window->height); } } }