diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index 127f47909b..3b970ae44c 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -344,6 +344,8 @@ void ComponentPeer::handleFocusGain() ModifierKeys::updateCurrentModifiers(); if (component.isParentOf (lastFocusedComponent)) + && lastFocusedComponent->isShowing() + && lastFocusedComponent->getWantsKeyboardFocus()) { Component::currentlyFocusedComponent = lastFocusedComponent; Desktop::getInstance().triggerFocusCallback(); @@ -424,7 +426,7 @@ namespace DragHelpers { static bool isFileDrag (const ComponentPeer::DragInfo& info) { - return info.files.size() > 0; + return ! info.files.isEmpty(); } static bool isSuitableTarget (const ComponentPeer::DragInfo& info, Component* target) @@ -439,7 +441,7 @@ namespace DragHelpers : dynamic_cast (target)->isInterestedInTextDrag (info.text); } - static Component* findDragAndDropTarget (Component* c, const ComponentPeer::DragInfo& info, Component* const lastOne) + static Component* findDragAndDropTarget (Component* c, const ComponentPeer::DragInfo& info, Component* lastOne) { for (; c != nullptr; c = c->getParentComponent()) if (isSuitableTarget (info, c) && (c == lastOne || isInterested (info, c))) @@ -453,9 +455,8 @@ bool ComponentPeer::handleDragMove (const ComponentPeer::DragInfo& info) { ModifierKeys::updateCurrentModifiers(); - Component* const compUnderMouse = component.getComponentAt (info.position); - - Component* const lastTarget = dragAndDropTargetComponent; + auto* compUnderMouse = component.getComponentAt (info.position); + auto* lastTarget = dragAndDropTargetComponent; Component* newTarget = nullptr; if (compUnderMouse != lastDragAndDropCompUnderMouse)