Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ShirasawaSama committed Dec 22, 2022
1 parent 4087244 commit 4d08a6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const patchs = {
'JUCE/modules/juce_gui_basics/native/juce_win32_Windowing.cpp': {
from: 'hwnd = CreateWindowEx',
to: 'hwnd = parentToAddTo != nullptr && (styleFlags & (1 << 28)) ? CreateWindow(WindowClassHolder::getInstance()->getWindowClassName(), L"",\
WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | ((type & windowIsResizable) ? WS_MAXIMIZEBOX | WS_THICKFRAME : 0),\
WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | ((type & windowIsResizable) ? WS_MAXIMIZEBOX | WS_THICKFRAME : 0),\
0, 0, 0, 0, parentToAddTo, nullptr, (HINSTANCE)Process::getCurrentModuleInstanceHandle(), nullptr) : CreateWindowEx'
},
'JUCE/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp': {
Expand Down
16 changes: 6 additions & 10 deletions src/PluginWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@ class PluginWindow : public juce::ResizableWindow {

if (_width == 0) _width = component->getWidth();
if (_height == 0) _height = component->getHeight();
setSize(_width, _height);

if (_x > 20 && _y > 20) setTopLeftPosition(_x, _y);
else centreWithSize(_width, _height);

setContentOwned(component, true);

auto screenBounds = juce::Desktop::getInstance().getDisplays().getTotalBounds(true).toFloat();
auto scaleFactor = juce::jmin((screenBounds.getWidth() - 50) / getWidth(), (screenBounds.getHeight() - 50) / getHeight());
auto trueWidth = scaleFactor < 1.0f ? (int)(_width * scaleFactor) : _width;
auto trueHeight = scaleFactor < 1.0f ? (int)(_height * scaleFactor) : _height;
if (_x > 20 && _y > 20) setBounds(_x, _y, trueWidth, trueHeight); else centreWithSize(trueWidth, trueHeight);

if (scaleFactor < 1.0f)
setSize((int)(getWidth() * scaleFactor), (int)(getHeight() * scaleFactor));

setContentOwned(component, true);
setVisible(true);

#ifdef JUCE_WINDOWS
Expand All @@ -53,7 +48,8 @@ class PluginWindow : public juce::ResizableWindow {

int getDesktopWindowStyleFlags() const override {
return ResizableWindow::getDesktopWindowStyleFlags()
| juce::ComponentPeer::windowHasMaximiseButton
| juce::ComponentPeer::windowHasMinimiseButton
| (isResizable() ? juce::ComponentPeer::windowHasMaximiseButton : 0)
| juce::ComponentPeer::windowHasCloseButton
| 1 << 28;
}
Expand Down

0 comments on commit 4d08a6d

Please sign in to comment.