From 829f0c8dde033b9eaca44ba1a53e8af446ca7543 Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 1 May 2009 15:53:57 +0000 Subject: [PATCH] Small fix to ALSA audio; small fix for Linux window border sizes; fix to stop win32 incorrectly making windows always-on-top; added a constructor for MidiBuffer. --- .../juce_linux_Audio.cpp | 8 +++- .../juce_linux_Windowing.cpp | 22 +++++---- .../juce_win32_Windowing.cpp | 10 +++- juce_amalgamated.cpp | 47 ++++++++++++++----- juce_amalgamated.h | 3 ++ .../audio/midi/juce_MidiBuffer.cpp | 7 +++ .../audio/midi/juce_MidiBuffer.h | 3 ++ 7 files changed, 74 insertions(+), 26 deletions(-) diff --git a/build/linux/platform_specific_code/juce_linux_Audio.cpp b/build/linux/platform_specific_code/juce_linux_Audio.cpp index ead09e3e88..249f2e1007 100644 --- a/build/linux/platform_specific_code/juce_linux_Audio.cpp +++ b/build/linux/platform_specific_code/juce_linux_Audio.cpp @@ -395,8 +395,8 @@ public: close(); } - void open (const BitArray& inputChannels, - const BitArray& outputChannels, + void open (BitArray inputChannels, + BitArray outputChannels, const double sampleRate_, const int bufferSize_) { @@ -447,6 +447,8 @@ public: return; } + currentOutputChans.setRange (0, minChansIn, true); + if (! outputDevice->setParameters ((unsigned int) sampleRate, jlimit ((int) minChansOut, (int) maxChansOut, currentOutputChans.getHighestBit() + 1), bufferSize)) @@ -468,6 +470,8 @@ public: return; } + currentInputChans.setRange (0, minChansIn, true); + if (! inputDevice->setParameters ((unsigned int) sampleRate, jlimit ((int) minChansIn, (int) maxChansIn, currentInputChans.getHighestBit() + 1), bufferSize)) diff --git a/build/linux/platform_specific_code/juce_linux_Windowing.cpp b/build/linux/platform_specific_code/juce_linux_Windowing.cpp index c7b3bb0c9a..2c07d3d159 100644 --- a/build/linux/platform_specific_code/juce_linux_Windowing.cpp +++ b/build/linux/platform_specific_code/juce_linux_Windowing.cpp @@ -817,19 +817,23 @@ public: // Make sure the Window manager does what we want XSizeHints* hints = XAllocSizeHints(); hints->flags = USSize | USPosition; - hints->width = ww + windowBorder.getLeftAndRight(); - hints->height = wh + windowBorder.getTopAndBottom(); - hints->x = wx - windowBorder.getLeft(); - hints->y = wy - windowBorder.getTop(); + hints->width = ww; + hints->height = wh; + hints->x = wx; + hints->y = wy; + + if ((getStyleFlags() & (windowHasTitleBar | windowIsResizable)) == windowHasTitleBar) + { + hints->min_width = hints->max_width = hints->width; + hints->min_height = hints->max_height = hints->height; + hints->flags |= PMinSize | PMaxSize; + } + XSetWMNormalHints (display, windowH, hints); XFree (hints); } - XMoveResizeWindow (display, windowH, - wx - windowBorder.getLeft(), - wy - windowBorder.getTop(), - ww + windowBorder.getLeftAndRight(), - wh + windowBorder.getTopAndBottom()); + XMoveResizeWindow (display, windowH, wx, wy, ww, wh); if (! deletionChecker.hasBeenDeleted()) { diff --git a/build/win32/platform_specific_code/juce_win32_Windowing.cpp b/build/win32/platform_specific_code/juce_win32_Windowing.cpp index 13218f80a1..e5aad8c970 100644 --- a/build/win32/platform_specific_code/juce_win32_Windowing.cpp +++ b/build/win32/platform_specific_code/juce_win32_Windowing.cpp @@ -760,8 +760,14 @@ public: { setMinimised (false); - SetWindowPos (hwnd, otherPeer->hwnd, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); + // must be careful not to try to put a topmost window behind a normal one, or win32 + // promotes the normal one to be topmost! + if (getComponent()->isAlwaysOnTop() == otherPeer->getComponent()->isAlwaysOnTop()) + SetWindowPos (hwnd, otherPeer->hwnd, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); + else if (otherPeer->getComponent()->isAlwaysOnTop()) + SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); } } diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index e3efaaafdc..44dd7b68ee 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -25024,6 +25024,13 @@ MidiBuffer::MidiBuffer() throw() { } +MidiBuffer::MidiBuffer (const MidiMessage& message) throw() + : ArrayAllocationBase (32), + bytesUsed (0) +{ + addEvent (message, 0); +} + MidiBuffer::MidiBuffer (const MidiBuffer& other) throw() : ArrayAllocationBase (32), bytesUsed (other.bytesUsed) @@ -243801,8 +243808,14 @@ public: { setMinimised (false); - SetWindowPos (hwnd, otherPeer->hwnd, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); + // must be careful not to try to put a topmost window behind a normal one, or win32 + // promotes the normal one to be topmost! + if (getComponent()->isAlwaysOnTop() == otherPeer->getComponent()->isAlwaysOnTop()) + SetWindowPos (hwnd, otherPeer->hwnd, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); + else if (otherPeer->getComponent()->isAlwaysOnTop()) + SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); } } @@ -258057,8 +258070,8 @@ public: close(); } - void open (const BitArray& inputChannels, - const BitArray& outputChannels, + void open (BitArray inputChannels, + BitArray outputChannels, const double sampleRate_, const int bufferSize_) { @@ -258109,6 +258122,8 @@ public: return; } + currentOutputChans.setRange (0, minChansIn, true); + if (! outputDevice->setParameters ((unsigned int) sampleRate, jlimit ((int) minChansOut, (int) maxChansOut, currentOutputChans.getHighestBit() + 1), bufferSize)) @@ -258130,6 +258145,8 @@ public: return; } + currentInputChans.setRange (0, minChansIn, true); + if (! inputDevice->setParameters ((unsigned int) sampleRate, jlimit ((int) minChansIn, (int) maxChansIn, currentInputChans.getHighestBit() + 1), bufferSize)) @@ -262059,19 +262076,23 @@ public: // Make sure the Window manager does what we want XSizeHints* hints = XAllocSizeHints(); hints->flags = USSize | USPosition; - hints->width = ww + windowBorder.getLeftAndRight(); - hints->height = wh + windowBorder.getTopAndBottom(); - hints->x = wx - windowBorder.getLeft(); - hints->y = wy - windowBorder.getTop(); + hints->width = ww; + hints->height = wh; + hints->x = wx; + hints->y = wy; + + if ((getStyleFlags() & (windowHasTitleBar | windowIsResizable)) == windowHasTitleBar) + { + hints->min_width = hints->max_width = hints->width; + hints->min_height = hints->max_height = hints->height; + hints->flags |= PMinSize | PMaxSize; + } + XSetWMNormalHints (display, windowH, hints); XFree (hints); } - XMoveResizeWindow (display, windowH, - wx - windowBorder.getLeft(), - wy - windowBorder.getTop(), - ww + windowBorder.getLeftAndRight(), - wh + windowBorder.getTopAndBottom()); + XMoveResizeWindow (display, windowH, wx, wy, ww, wh); if (! deletionChecker.hasBeenDeleted()) { diff --git a/juce_amalgamated.h b/juce_amalgamated.h index b0bbc648f8..d1b3fda28f 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -25955,6 +25955,9 @@ public: /** Creates an empty MidiBuffer. */ MidiBuffer() throw(); + /** Creates a MidiBuffer containing a single midi message. */ + MidiBuffer (const MidiMessage& message) throw(); + /** Creates a copy of another MidiBuffer. */ MidiBuffer (const MidiBuffer& other) throw(); diff --git a/src/juce_appframework/audio/midi/juce_MidiBuffer.cpp b/src/juce_appframework/audio/midi/juce_MidiBuffer.cpp index fad79b3314..3350174371 100644 --- a/src/juce_appframework/audio/midi/juce_MidiBuffer.cpp +++ b/src/juce_appframework/audio/midi/juce_MidiBuffer.cpp @@ -43,6 +43,13 @@ MidiBuffer::MidiBuffer() throw() { } +MidiBuffer::MidiBuffer (const MidiMessage& message) throw() + : ArrayAllocationBase (32), + bytesUsed (0) +{ + addEvent (message, 0); +} + MidiBuffer::MidiBuffer (const MidiBuffer& other) throw() : ArrayAllocationBase (32), bytesUsed (other.bytesUsed) diff --git a/src/juce_appframework/audio/midi/juce_MidiBuffer.h b/src/juce_appframework/audio/midi/juce_MidiBuffer.h index 314fc39909..8837d8eaa8 100644 --- a/src/juce_appframework/audio/midi/juce_MidiBuffer.h +++ b/src/juce_appframework/audio/midi/juce_MidiBuffer.h @@ -51,6 +51,9 @@ public: //============================================================================== /** Creates an empty MidiBuffer. */ MidiBuffer() throw(); + + /** Creates a MidiBuffer containing a single midi message. */ + MidiBuffer (const MidiMessage& message) throw(); /** Creates a copy of another MidiBuffer. */ MidiBuffer (const MidiBuffer& other) throw();