Skip to content

Commit 5179690

Browse files
committed
Restore Wine functionality
1 parent daaa8ec commit 5179690

File tree

3 files changed

+17
-29
lines changed

3 files changed

+17
-29
lines changed

modules/juce_graphics/native/juce_Direct2DImage_windows.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,22 +1015,24 @@ auto Direct2DPixelData::getNativeExtensions() -> NativeExtensions
10151015
return NativeExtensions { Wrapped { this } };
10161016
}
10171017

1018+
extern bool juce_isRunningInWine();
1019+
10181020
//==============================================================================
10191021
ImagePixelData::Ptr NativeImageType::create (Image::PixelFormat format, int width, int height, bool clearImage) const
10201022
{
1021-
SharedResourcePointer<DirectX> directX;
1022-
1023-
if (directX->adapters.getFactory() == nullptr)
1023+
if (! juce_isRunningInWine())
10241024
{
1025+
SharedResourcePointer<DirectX> directX;
1026+
10251027
// Make sure the DXGI factory exists
10261028
//
10271029
// The caller may be trying to create an Image from a static variable; if this is a DLL, then this is
1028-
// probably called from DllMain. You can't create a DXGI factory from DllMain, so fall back to a
1029-
// software image.
1030-
return new SoftwarePixelData { format, width, height, clearImage };
1030+
// probably called from DllMain. You can't create a DXGI factory from DllMain.
1031+
if (directX->adapters.getFactory() != nullptr)
1032+
return new Direct2DPixelData (format, width, height, clearImage);
10311033
}
10321034

1033-
return new Direct2DPixelData (format, width, height, clearImage);
1035+
return new SoftwarePixelData { format, width, height, clearImage };
10341036
}
10351037

10361038
//==============================================================================

modules/juce_graphics/native/juce_DirectWriteTypeface_windows.cpp

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ StringArray Font::findAllTypefaceStyles (const String& family)
5050
return factories->getFonts().findAllTypefaceStyles (family);
5151
}
5252

53-
extern bool juce_isRunningInWine();
54-
5553
class WindowsDirectWriteTypeface final : public Typeface
5654
{
5755
public:
@@ -416,25 +414,10 @@ class WindowsDirectWriteTypeface final : public Typeface
416414

417415
struct DefaultFontNames
418416
{
419-
DefaultFontNames()
420-
{
421-
if (juce_isRunningInWine())
422-
{
423-
// If we're running in Wine, then use fonts that might be available on Linux.
424-
defaultSans = "Bitstream Vera Sans";
425-
defaultSerif = "Bitstream Vera Serif";
426-
defaultFixed = "Bitstream Vera Sans Mono";
427-
}
428-
else
429-
{
430-
defaultSans = "Verdana";
431-
defaultSerif = "Times New Roman";
432-
defaultFixed = "Lucida Console";
433-
defaultFallback = "Tahoma"; // (contains plenty of unicode characters)
434-
}
435-
}
436-
437-
String defaultSans, defaultSerif, defaultFixed, defaultFallback;
417+
const String defaultSans { "Verdana" },
418+
defaultSerif { "Times New Roman" },
419+
defaultFixed { "Lucida Console" },
420+
defaultFallback { "Tahoma" }; // (contains plenty of unicode characters)
438421
};
439422

440423
Typeface::Ptr Font::Native::getDefaultPlatformTypefaceForFont (const Font& font)

modules/juce_gui_basics/native/juce_Windowing_windows.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4690,9 +4690,12 @@ class HWNDComponentPeer final : public ComponentPeer
46904690
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HWNDComponentPeer)
46914691
};
46924692

4693+
extern bool juce_isRunningInWine();
4694+
46934695
ComponentPeer* Component::createNewPeer (int styleFlags, void* parentHWND)
46944696
{
4695-
return new HWNDComponentPeer { *this, styleFlags, (HWND) parentHWND, false, 1 };
4697+
const auto renderer = juce_isRunningInWine() ? 0 : 1;
4698+
return new HWNDComponentPeer { *this, styleFlags, (HWND) parentHWND, false, renderer };
46964699
}
46974700

46984701
Image createSnapshotOfNativeWindow (void* nativeWindowHandle)

0 commit comments

Comments
 (0)