| @@ -948,7 +948,6 @@ public: | |||
| #if ! JucePlugin_EditorRequiresKeyboardFocus | |||
| setWantsKeyboardFocus (false); | |||
| #else | |||
| setComponentProperty ("juce_disallowFocus", true); | |||
| setWantsKeyboardFocus (true); | |||
| #endif | |||
| } | |||
| @@ -1230,7 +1229,6 @@ private: | |||
| #if ! JucePlugin_EditorRequiresKeyboardFocus | |||
| addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses); | |||
| setWantsKeyboardFocus (false); | |||
| setComponentProperty ("juce_disallowFocus", true); | |||
| #else | |||
| addToDesktop (ComponentPeer::windowIsTemporary); | |||
| setWantsKeyboardFocus (true); | |||
| @@ -1339,6 +1337,19 @@ private: | |||
| recursive = false; | |||
| } | |||
| } | |||
| bool keyPressed (const KeyPress& kp) | |||
| { | |||
| if (! kp.getModifiers().isCommandDown()) | |||
| { | |||
| // If we have an unused keypress, move the key-focus to a host window | |||
| // and re-inject the event.. | |||
| [[hostWindow parentWindow] makeKeyWindow]; | |||
| [NSApp postEvent: [NSApp currentEvent] atStart: YES]; | |||
| } | |||
| return false; | |||
| } | |||
| private: | |||
| HIViewRef parentView; | |||
| @@ -110,4 +110,38 @@ void removeSubWindow (void* nsWindow, Component* comp) | |||
| [hostWindow release]; | |||
| } | |||
| static bool isJuceWindow (WindowRef w) throw() | |||
| { | |||
| for (int i = ComponentPeer::getNumPeers(); --i >= 0;) | |||
| { | |||
| ComponentPeer* peer = ComponentPeer::getPeer(i); | |||
| NSView* view = (NSView*) peer->getNativeHandle(); | |||
| if ([[view window] windowRef] == w) | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| void forwardCurrentKeyEventToHostWindow() | |||
| { | |||
| WindowRef w = FrontNonFloatingWindow(); | |||
| WindowRef original = w; | |||
| while (IsValidWindowPtr (w) && isJuceWindow (w)) | |||
| { | |||
| w = GetNextWindowOfClass (w, kDocumentWindowClass, true); | |||
| if (w == original) | |||
| break; | |||
| } | |||
| if (! isJuceWindow (w)) | |||
| { | |||
| ActivateWindow (w, true); | |||
| [NSApp postEvent: [NSApp currentEvent] atStart: YES]; | |||
| } | |||
| } | |||
| #endif | |||
| @@ -154,6 +154,7 @@ BEGIN_JUCE_NAMESPACE | |||
| extern void detachComponentFromWindowRef (Component* component, void* nsWindow); | |||
| extern void setNativeHostWindowSize (void* nsWindow, Component* editorComp, int newWidth, int newHeight); | |||
| extern void checkWindowVisibility (void* nsWindow, Component* component); | |||
| extern void forwardCurrentKeyEventToHost (Component* component); | |||
| #endif | |||
| #if JUCE_LINUX | |||
| @@ -279,10 +280,6 @@ public: | |||
| editor->setTopLeftPosition (0, 0); | |||
| addAndMakeVisible (editor); | |||
| #if ! JucePlugin_EditorRequiresKeyboardFocus | |||
| setComponentProperty ("juce_disallowFocus", true); | |||
| #endif | |||
| #if JUCE_WIN32 | |||
| addMouseListener (this, true); | |||
| #endif | |||
| @@ -306,6 +303,16 @@ public: | |||
| triggerAsyncUpdate(); | |||
| } | |||
| #if JUCE_MAC | |||
| bool keyPressed (const KeyPress& kp) | |||
| { | |||
| // If we have an unused keypress, move the key-focus to a host window | |||
| // and re-inject the event.. | |||
| forwardCurrentKeyEventToHost (this); | |||
| return true; | |||
| } | |||
| #endif | |||
| AudioProcessorEditor* getEditorComp() const | |||
| { | |||
| return dynamic_cast <AudioProcessorEditor*> (getChildComponent (0)); | |||
| @@ -240,6 +240,14 @@ void checkWindowVisibility (void* nsWindow, Component* comp) | |||
| comp->setVisible ([hostWindow isVisible]); | |||
| } | |||
| void forwardCurrentKeyEventToHost (Component* comp) | |||
| { | |||
| NSWindow* win = [(NSView*) comp->getWindowHandle() window]; | |||
| [[win parentWindow] makeKeyWindow]; | |||
| [NSApp postEvent: [NSApp currentEvent] atStart: YES]; | |||
| } | |||
| END_JUCE_NAMESPACE | |||
| #endif | |||
| @@ -51812,14 +51812,12 @@ public: | |||
| void updateComponents() | |||
| { | |||
| int xAdjust = 0, yAdjust = 0; | |||
| const int visibleTop = -getY(); | |||
| const int visibleBottom = visibleTop + getParentHeight(); | |||
| BitArray itemsToKeep; | |||
| TreeViewItem* item = owner->rootItem; | |||
| int y = -yAdjust; | |||
| int y = (item != 0 && !owner->rootItemVisible) ? -item->itemHeight : 0; | |||
| while (item != 0 && y < visibleBottom) | |||
| { | |||
| @@ -51865,7 +51863,7 @@ public: | |||
| const TreeViewItem* const item = (TreeViewItem*) rowComponentItems.getUnchecked(i); | |||
| Rectangle pos (item->getItemPosition (false)); | |||
| pos.setSize (pos.getWidth() + xAdjust, item->itemHeight); | |||
| pos.setSize (pos.getWidth(), item->itemHeight); | |||
| if (pos.getBottom() >= visibleTop && pos.getY() < visibleBottom) | |||
| { | |||
| @@ -66497,7 +66495,8 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||
| dic->setOpaque (true); | |||
| dic->addToDesktop (ComponentPeer::windowIgnoresMouseClicks | |||
| | ComponentPeer::windowIsTemporary); | |||
| | ComponentPeer::windowIsTemporary | |||
| | ComponentPeer::windowIgnoresKeyPresses); | |||
| } | |||
| else | |||
| thisComp->addChildComponent (dic); | |||
| @@ -69739,7 +69738,8 @@ public: | |||
| { | |||
| setSize (1, 1); // to keep the OS happy by not having zero-size windows | |||
| addToDesktop (ComponentPeer::windowIgnoresMouseClicks | |||
| | ComponentPeer::windowIsTemporary); | |||
| | ComponentPeer::windowIsTemporary | |||
| | ComponentPeer::windowIgnoresKeyPresses); | |||
| } | |||
| else if (owner_->getParentComponent() != 0) | |||
| { | |||
| @@ -74210,7 +74210,8 @@ void TooltipWindow::showFor (Component* const c, const String& tip) | |||
| if (getParentComponent() == 0) | |||
| { | |||
| addToDesktop (ComponentPeer::windowHasDropShadow | |||
| | ComponentPeer::windowIsTemporary); | |||
| | ComponentPeer::windowIsTemporary | |||
| | ComponentPeer::windowIgnoresKeyPresses); | |||
| } | |||
| toFront (false); | |||
| @@ -231868,21 +231869,14 @@ SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() throw() | |||
| { | |||
| switch (info.dwMajorVersion) | |||
| { | |||
| case 5: | |||
| return (info.dwMinorVersion == 0) ? Win2000 : WinXP; | |||
| case 6: | |||
| return (info.dwMinorVersion == 0) ? WinVista : Windows7; | |||
| default: | |||
| jassertfalse // !! not a supported OS! | |||
| break; | |||
| case 5: return (info.dwMinorVersion == 0) ? Win2000 : WinXP; | |||
| case 6: return (info.dwMinorVersion == 0) ? WinVista : Windows7; | |||
| default: jassertfalse; break; // !! not a supported OS! | |||
| } | |||
| } | |||
| else if (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) | |||
| { | |||
| jassert (info.dwMinorVersion != 0); // !! still running on Windows 95?? | |||
| return Win98; | |||
| } | |||
| @@ -231895,25 +231889,12 @@ const String SystemStats::getOperatingSystemName() throw() | |||
| switch (getOperatingSystemType()) | |||
| { | |||
| case WinVista: | |||
| name = "Windows Vista"; | |||
| break; | |||
| case WinXP: | |||
| name = "Windows XP"; | |||
| break; | |||
| case Win2000: | |||
| name = "Windows 2000"; | |||
| break; | |||
| case Win98: | |||
| name = "Windows 98"; | |||
| break; | |||
| default: | |||
| jassertfalse // !! new type of OS? | |||
| break; | |||
| case Windows7: name = "Windows 7"; break; | |||
| case WinVista: name = "Windows Vista"; break; | |||
| case WinXP: name = "Windows XP"; break; | |||
| case Win2000: name = "Windows 2000"; break; | |||
| case Win98: name = "Windows 98"; break; | |||
| default: jassertfalse; break; // !! new type of OS? | |||
| } | |||
| return name; | |||
| @@ -231924,7 +231905,7 @@ bool SystemStats::isOperatingSystem64Bit() throw() | |||
| #ifdef _WIN64 | |||
| return true; | |||
| #else | |||
| typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); | |||
| typedef BOOL (WINAPI* LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); | |||
| LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress (GetModuleHandle (L"kernel32"), "IsWow64Process"); | |||
| @@ -231938,9 +231919,10 @@ bool SystemStats::isOperatingSystem64Bit() throw() | |||
| int SystemStats::getMemorySizeInMegabytes() throw() | |||
| { | |||
| MEMORYSTATUS mem; | |||
| GlobalMemoryStatus (&mem); | |||
| return (int) (mem.dwTotalPhys / (1024 * 1024)) + 1; | |||
| MEMORYSTATUSEX mem; | |||
| mem.dwLength = sizeof (mem); | |||
| GlobalMemoryStatusEx (&mem); | |||
| return (int) (mem.ullTotalPhys / (1024 * 1024)) + 1; | |||
| } | |||
| int SystemStats::getNumCpus() throw() | |||
| @@ -259868,11 +259850,7 @@ void NSViewComponentPeer::drawRect (NSRect r) | |||
| bool NSViewComponentPeer::canBecomeKeyWindow() | |||
| { | |||
| // If running as a plugin, let the component decide whether it's going to allow the window to get focused. | |||
| return ((getStyleFlags() & juce::ComponentPeer::windowIsTemporary) == 0) | |||
| && (JUCEApplication::getInstance() != 0 | |||
| || (isValidPeer (this) | |||
| && ! getComponent()->getComponentPropertyBool ("juce_disallowFocus", false, false))); | |||
| return (getStyleFlags() & juce::ComponentPeer::windowIgnoresKeyPresses) == 0; | |||
| } | |||
| bool NSViewComponentPeer::windowShouldClose() | |||
| @@ -175,14 +175,12 @@ public: | |||
| void updateComponents() | |||
| { | |||
| int xAdjust = 0, yAdjust = 0; | |||
| const int visibleTop = -getY(); | |||
| const int visibleBottom = visibleTop + getParentHeight(); | |||
| BitArray itemsToKeep; | |||
| TreeViewItem* item = owner->rootItem; | |||
| int y = -yAdjust; | |||
| int y = (item != 0 && !owner->rootItemVisible) ? -item->itemHeight : 0; | |||
| while (item != 0 && y < visibleBottom) | |||
| { | |||
| @@ -228,7 +226,7 @@ public: | |||
| const TreeViewItem* const item = (TreeViewItem*) rowComponentItems.getUnchecked(i); | |||
| Rectangle pos (item->getItemPosition (false)); | |||
| pos.setSize (pos.getWidth() + xAdjust, item->itemHeight); | |||
| pos.setSize (pos.getWidth(), item->itemHeight); | |||
| if (pos.getBottom() >= visibleTop && pos.getY() < visibleBottom) | |||
| { | |||
| @@ -434,7 +434,8 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||
| dic->setOpaque (true); | |||
| dic->addToDesktop (ComponentPeer::windowIgnoresMouseClicks | |||
| | ComponentPeer::windowIsTemporary); | |||
| | ComponentPeer::windowIsTemporary | |||
| | ComponentPeer::windowIgnoresKeyPresses); | |||
| } | |||
| else | |||
| thisComp->addChildComponent (dic); | |||
| @@ -57,7 +57,8 @@ public: | |||
| { | |||
| setSize (1, 1); // to keep the OS happy by not having zero-size windows | |||
| addToDesktop (ComponentPeer::windowIgnoresMouseClicks | |||
| | ComponentPeer::windowIsTemporary); | |||
| | ComponentPeer::windowIsTemporary | |||
| | ComponentPeer::windowIgnoresKeyPresses); | |||
| } | |||
| else if (owner_->getParentComponent() != 0) | |||
| { | |||
| @@ -105,7 +105,8 @@ void TooltipWindow::showFor (Component* const c, const String& tip) | |||
| if (getParentComponent() == 0) | |||
| { | |||
| addToDesktop (ComponentPeer::windowHasDropShadow | |||
| | ComponentPeer::windowIsTemporary); | |||
| | ComponentPeer::windowIsTemporary | |||
| | ComponentPeer::windowIgnoresKeyPresses); | |||
| } | |||
| toFront (false); | |||
| @@ -1457,11 +1457,7 @@ void NSViewComponentPeer::drawRect (NSRect r) | |||
| bool NSViewComponentPeer::canBecomeKeyWindow() | |||
| { | |||
| // If running as a plugin, let the component decide whether it's going to allow the window to get focused. | |||
| return ((getStyleFlags() & juce::ComponentPeer::windowIsTemporary) == 0) | |||
| && (JUCEApplication::getInstance() != 0 | |||
| || (isValidPeer (this) | |||
| && ! getComponent()->getComponentPropertyBool ("juce_disallowFocus", false, false))); | |||
| return (getStyleFlags() & juce::ComponentPeer::windowIgnoresKeyPresses) == 0; | |||
| } | |||
| bool NSViewComponentPeer::windowShouldClose() | |||