Browse Source

Sorted out some mac window maximising peculiarities.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
a6f3466852
4 changed files with 392 additions and 247 deletions
  1. +299
    -174
      juce_amalgamated.cpp
  2. +46
    -41
      juce_amalgamated.h
  3. +1
    -1
      src/core/juce_StandardHeader.h
  4. +46
    -31
      src/native/mac/juce_mac_NSViewComponentPeer.mm

+ 299
- 174
juce_amalgamated.cpp
File diff suppressed because it is too large
View File


+ 46
- 41
juce_amalgamated.h View File

@@ -73,7 +73,7 @@ namespace JuceDummyNamespace {}
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 98
#define JUCE_BUILDNUMBER 99

/** Current Juce version number.

@@ -7134,9 +7134,9 @@ public:
{
const ScopedLockType lock (getLock());
const ElementType* e = data.elements.getData();
const ElementType* const end = e + numUsed;
const ElementType* const end_ = e + numUsed;

for (; e != end; ++e)
for (; e != end_; ++e)
if (elementToLookFor == *e)
return static_cast <int> (e - data.elements.getData());

@@ -7152,9 +7152,9 @@ public:
{
const ScopedLockType lock (getLock());
const ElementType* e = data.elements.getData();
const ElementType* const end = e + numUsed;
const ElementType* const end_ = e + numUsed;

for (; e != end; ++e)
for (; e != end_; ++e)
if (elementToLookFor == *e)
return true;

@@ -7486,11 +7486,11 @@ public:

const ScopedLockType lock (getLock());
int start = 0;
int end = numUsed;
int end_ = numUsed;

for (;;)
{
if (start >= end)
if (start >= end_)
{
return -1;
}
@@ -7500,14 +7500,14 @@ public:
}
else
{
const int halfway = (start + end) >> 1;
const int halfway = (start + end_) >> 1;

if (halfway == start)
return -1;
else if (comparator.compareElements (elementToLookFor, data.elements [halfway]) >= 0)
start = halfway;
else
end = halfway;
end_ = halfway;
}
}
}
@@ -8470,7 +8470,10 @@ private:
any kind of ReferenceCountedObject. The var class is intended to act like
the kind of values used in dynamic scripting languages.

@see DynamicObject
You can save/load var objects either in a small, proprietary binary format
using writeToStream()/readFromStream(), or as JSON by using the JSON class.

@see JSON, DynamicObject
*/
class JUCE_API var
{
@@ -8630,12 +8633,14 @@ public:

/** Writes a binary representation of this value to a stream.
The data can be read back later using readFromStream().
@see JSON
*/
void writeToStream (OutputStream& output) const;

/** Reads back a stored binary representation of a value.
The data in the stream must have been written using writeToStream(), or this
will have unpredictable results.
@see JSON
*/
static var readFromStream (InputStream& input);

@@ -9692,9 +9697,9 @@ public:
{
const ScopedLockType lock (getLock());
ObjectClass* const* e = data.elements.getData();
ObjectClass* const* const end = e + numUsed;
ObjectClass* const* const end_ = e + numUsed;

for (; e != end; ++e)
for (; e != end_; ++e)
if (objectToLookFor == *e)
return static_cast <int> (e - data.elements.getData());

@@ -9710,9 +9715,9 @@ public:
{
const ScopedLockType lock (getLock());
ObjectClass* const* e = data.elements.getData();
ObjectClass* const* const end = e + numUsed;
ObjectClass* const* const end_ = e + numUsed;

for (; e != end; ++e)
for (; e != end_; ++e)
if (objectToLookFor == *e)
return true;

@@ -9969,11 +9974,11 @@ public:
const ScopedLockType lock (getLock());

int start = 0;
int end = numUsed;
int end_ = numUsed;

for (;;)
{
if (start >= end)
if (start >= end_)
{
return -1;
}
@@ -9983,14 +9988,14 @@ public:
}
else
{
const int halfway = (start + end) >> 1;
const int halfway = (start + end_) >> 1;

if (halfway == start)
return -1;
else if (comparator.compareElements (objectToLookFor, data.elements [halfway]) >= 0)
start = halfway;
else
end = halfway;
end_ = halfway;
}
}
}
@@ -10570,7 +10575,7 @@ public:
will be the "upperLimit" parameter that is passed to your generateHash() function. The number
of hash slots will grow automatically if necessary, or it can be remapped manually using remapTable().
*/
HashMap (const int numberOfSlots = defaultHashTableSize)
explicit HashMap (const int numberOfSlots = defaultHashTableSize)
: totalNumItems (0)
{
slots.insertMultiple (0, nullptr, numberOfSlots);
@@ -14088,9 +14093,9 @@ public:
{
const ScopedLockType lock (getLock());
ObjectClass** e = data.elements.getData();
ObjectClass** const end = e + numUsed;
ObjectClass** const end_ = e + numUsed;

while (e != end)
while (e != end_)
{
if (objectToLookFor == *e)
return static_cast <int> (e - data.elements.getData());
@@ -14110,9 +14115,9 @@ public:
{
const ScopedLockType lock (getLock());
ObjectClass** e = data.elements.getData();
ObjectClass** const end = e + numUsed;
ObjectClass** const end_ = e + numUsed;

while (e != end)
while (e != end_)
{
if (objectToLookFor == *e)
return true;
@@ -14418,12 +14423,12 @@ public:
const ScopedLockType lock (getLock());

const int start = jlimit (0, numUsed, startIndex);
const int end = jlimit (0, numUsed, startIndex + numberToRemove);
const int end_ = jlimit (0, numUsed, startIndex + numberToRemove);

if (end > start)
if (end_ > start)
{
int i;
for (i = start; i < end; ++i)
for (i = start; i < end_; ++i)
{
if (data.elements[i] != nullptr)
{
@@ -14432,9 +14437,9 @@ public:
}
}

const int rangeSize = end - start;
const int rangeSize = end_ - start;
ObjectClass** e = data.elements + start;
i = numUsed - end;
i = numUsed - end_;
numUsed -= rangeSize;

while (--i >= 0)
@@ -14959,11 +14964,11 @@ public:
const ScopedLockType lock (getLock());

int start = 0;
int end = numUsed;
int end_ = numUsed;

for (;;)
{
if (start >= end)
if (start >= end_)
{
return -1;
}
@@ -14973,12 +14978,12 @@ public:
}
else
{
const int halfway = (start + end) >> 1;
const int halfway = (start + end_) >> 1;

if (halfway == start)
return -1;
else if (elementToLookFor < data.elements [halfway])
end = halfway;
end_ = halfway;
else
start = halfway;
}
@@ -14995,11 +15000,11 @@ public:
const ScopedLockType lock (getLock());

int start = 0;
int end = numUsed;
int end_ = numUsed;

for (;;)
{
if (start >= end)
if (start >= end_)
{
return false;
}
@@ -15009,12 +15014,12 @@ public:
}
else
{
const int halfway = (start + end) >> 1;
const int halfway = (start + end_) >> 1;

if (halfway == start)
return false;
else if (elementToLookFor < data.elements [halfway])
end = halfway;
end_ = halfway;
else
start = halfway;
}
@@ -15031,13 +15036,13 @@ public:
const ScopedLockType lock (getLock());

int start = 0;
int end = numUsed;
int end_ = numUsed;

for (;;)
{
if (start >= end)
if (start >= end_)
{
jassert (start <= end);
jassert (start <= end_);
insertInternal (start, newElement);
break;
}
@@ -15047,7 +15052,7 @@ public:
}
else
{
const int halfway = (start + end) >> 1;
const int halfway = (start + end_) >> 1;

if (halfway == start)
{
@@ -15059,7 +15064,7 @@ public:
break;
}
else if (newElement < data.elements [halfway])
end = halfway;
end_ = halfway;
else
start = halfway;
}


+ 1
- 1
src/core/juce_StandardHeader.h View File

@@ -33,7 +33,7 @@
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 98
#define JUCE_BUILDNUMBER 99
/** Current Juce version number.


+ 46
- 31
src/native/mac/juce_mac_NSViewComponentPeer.mm View File

@@ -165,7 +165,9 @@ public:
bool isMinimised() const;
void setFullScreen (bool shouldBeFullScreen);
bool isFullScreen() const;
void updateFullscreenStatus();
bool contains (const Point<int>& position, bool trueIfInAChildWindow) const;
bool hasNativeTitleBar() const { return (getStyleFlags() & windowHasTitleBar) != 0; }
const BorderSize<int> getFrameSize() const;
bool setAlwaysOnTop (bool alwaysOnTop);
void toFront (bool makeActiveWindow);
@@ -269,6 +271,17 @@ public:
: (num == 2 ? ModifierKeys::middleButtonModifier : 0));
}
static unsigned int getNSWindowStyleMask (const int flags) noexcept
{
unsigned int style = (flags & windowHasTitleBar) != 0 ? NSTitledWindowMask
: NSBorderlessWindowMask;
if ((flags & windowHasMinimiseButton) != 0) style |= NSMiniaturizableWindowMask;
if ((flags & windowHasCloseButton) != 0) style |= NSClosableWindowMask;
if ((flags & windowIsResizable) != 0) style |= NSResizableWindowMask;
return style;
}
//==============================================================================
virtual void viewFocusGain();
virtual void viewFocusLoss();
@@ -701,7 +714,7 @@ END_JUCE_NAMESPACE
if (JUCE_NAMESPACE::Component::getCurrentlyModalComponent() != nullptr
&& owner->getComponent()->isCurrentlyBlockedByAnotherModalComponent()
&& (owner->getStyleFlags() & JUCE_NAMESPACE::ComponentPeer::windowHasTitleBar) != 0)
&& owner->hasNativeTitleBar())
JUCE_NAMESPACE::Component::getCurrentlyModalComponent()->inputAttemptWhenModal();
return frameRect.size;
@@ -712,6 +725,8 @@ END_JUCE_NAMESPACE
isZooming = true;
[super zoom: sender];
isZooming = false;
owner->redirectMovedOrResized();
}
- (void) windowWillMove: (NSNotification*) notification
@@ -720,7 +735,7 @@ END_JUCE_NAMESPACE
if (JUCE_NAMESPACE::Component::getCurrentlyModalComponent() != nullptr
&& owner->getComponent()->isCurrentlyBlockedByAnotherModalComponent()
&& (owner->getStyleFlags() & JUCE_NAMESPACE::ComponentPeer::windowHasTitleBar) != 0)
&& owner->hasNativeTitleBar())
JUCE_NAMESPACE::Component::getCurrentlyModalComponent()->inputAttemptWhenModal();
}
@@ -805,7 +820,7 @@ NSViewComponentPeer::NSViewComponentPeer (Component* const component_,
#endif
recursiveToFrontCall (false)
{
NSRect r = NSMakeRect (0, 0, (float) component->getWidth(), (float) component->getHeight());
NSRect r = NSMakeRect (0, 0, (CGFloat) component->getWidth(), (CGFloat) component->getHeight());
view = [[JuceNSView alloc] initWithOwner: this withFrame: r];
[view setPostsFrameChangedNotifications: YES];
@@ -817,27 +832,12 @@ NSViewComponentPeer::NSViewComponentPeer (Component* const component_,
}
else
{
r.origin.x = (float) component->getX();
r.origin.y = (float) component->getY();
r.origin.x = (CGFloat) component->getX();
r.origin.y = (CGFloat) component->getY();
r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - (r.origin.y + r.size.height);
unsigned int style = 0;
if ((windowStyleFlags & windowHasTitleBar) == 0)
style = NSBorderlessWindowMask;
else
style = NSTitledWindowMask;
if ((windowStyleFlags & windowHasMinimiseButton) != 0)
style |= NSMiniaturizableWindowMask;
if ((windowStyleFlags & windowHasCloseButton) != 0)
style |= NSClosableWindowMask;
if ((windowStyleFlags & windowIsResizable) != 0)
style |= NSResizableWindowMask;
window = [[JuceNSWindow alloc] initWithContentRect: r
styleMask: style
styleMask: getNSWindowStyleMask (windowStyleFlags)
backing: NSBackingStoreBuffered
defer: YES];
@@ -932,7 +932,7 @@ void NSViewComponentPeer::setBounds (int x, int y, int w, int h, bool isNowFullS
{
fullScreen = isNowFullScreen;
NSRect r = NSMakeRect ((float) x, (float) y, (float) jmax (0, w), (float) jmax (0, h));
NSRect r = NSMakeRect ((CGFloat) x, (CGFloat) y, (CGFloat) jmax (0, w), (CGFloat) jmax (0, h));
if (isSharedWindow)
{
@@ -1073,7 +1073,7 @@ void NSViewComponentPeer::setMinimised (bool shouldBeMinimised)
bool NSViewComponentPeer::isMinimised() const
{
return window != nil && [window isMiniaturized];
return [window isMiniaturized];
}
void NSViewComponentPeer::setFullScreen (bool shouldBeFullScreen)
@@ -1082,11 +1082,12 @@ void NSViewComponentPeer::setFullScreen (bool shouldBeFullScreen)
{
Rectangle<int> r (lastNonFullscreenBounds);
setMinimised (false);
if (isMinimised())
setMinimised (false);
if (fullScreen != shouldBeFullScreen)
{
if (shouldBeFullScreen && (getStyleFlags() & windowHasTitleBar) != 0)
if (shouldBeFullScreen && hasNativeTitleBar())
{
fullScreen = true;
[window performZoom: nil];
@@ -1094,7 +1095,7 @@ void NSViewComponentPeer::setFullScreen (bool shouldBeFullScreen)
else
{
if (shouldBeFullScreen)
r = Desktop::getInstance().getMainMonitorArea();
r = component->getParentMonitorArea();
// (can't call the component's setBounds method because that'll reset our fullscreen flag)
if (r != getComponent()->getBounds() && ! r.isEmpty())
@@ -1192,8 +1193,7 @@ void NSViewComponentPeer::toBehind (ComponentPeer* other)
else
{
[window orderWindow: NSWindowBelow
relativeTo: otherPeer->window != nil ? [otherPeer->window windowNumber]
: 0 ];
relativeTo: [otherPeer->window windowNumber]];
}
}
}
@@ -1250,7 +1250,7 @@ void juce_HandleProcessFocusChange()
bool NSViewComponentPeer::isFocused() const
{
return isSharedWindow ? this == currentlyFocusedPeer
: (window != nil && [window isKeyWindow]);
: [window isKeyWindow];
}
void NSViewComponentPeer::grabFocus()
@@ -1610,8 +1610,23 @@ bool NSViewComponentPeer::windowShouldClose()
return NO;
}
void NSViewComponentPeer::updateFullscreenStatus()
{
if (hasNativeTitleBar())
{
const Rectangle<int> screen (getFrameSize().subtractedFrom (component->getParentMonitorArea()));
const Rectangle<int> window (component->getScreenBounds());
fullScreen = std::abs (screen.getX() - window.getX()) <= 2
&& std::abs (screen.getY() - window.getY()) <= 2
&& std::abs (screen.getRight() - window.getRight()) <= 2
&& std::abs (screen.getBottom() - window.getBottom()) <= 2;
}
}
void NSViewComponentPeer::redirectMovedOrResized()
{
updateFullscreenStatus();
handleMovedOrResized();
}
@@ -1682,8 +1697,8 @@ void NSViewComponentPeer::repaint (const Rectangle<int>& area)
}
else
{
[view setNeedsDisplayInRect: NSMakeRect ((float) area.getX(), [view frame].size.height - (float) area.getBottom(),
(float) area.getWidth(), (float) area.getHeight())];
[view setNeedsDisplayInRect: NSMakeRect ((CGFloat) area.getX(), [view frame].size.height - (CGFloat) area.getBottom(),
(CGFloat) area.getWidth(), (CGFloat) area.getHeight())];
}
}


Loading…
Cancel
Save