diff --git a/modules/corelib/ui/uiminiwindow.lua b/modules/corelib/ui/uiminiwindow.lua index 0e9f44ee0..0c8bc42ff 100644 --- a/modules/corelib/ui/uiminiwindow.lua +++ b/modules/corelib/ui/uiminiwindow.lua @@ -162,42 +162,39 @@ function UIMiniWindow:onDragEnter(mousePos) end function UIMiniWindow:onDragLeave(droppedWidget, mousePos) + if self.movedWidget then + self.setMovedChildMargin(self.movedOldMargin or 0) + self.movedWidget = nil + self.setMovedChildMargin = nil + self.movedOldMargin = nil + self.movedIndex = nil + end - if g_settings.getBoolean('moveWindowsToPanel') then - local children = rootWidget:recursiveGetChildrenByMarginPos(mousePos) - local dropInPanel = 0 - - for i=1,#children do - local child = children[i] - if child:getId() == 'gameLeftPanel' or child:getId() == 'gameRightPanel' then - dropInPanel = 1 - end - end + if g_settings.getBoolean('moveWindowsToPanel') then + local children = rootWidget:recursiveGetChildrenByMarginPos(mousePos) + local dropInPanel = 0 - if dropInPanel == 0 then - tmpp = self - if(modules.game_interface.getLeftPanel():isVisible()) then - if modules.game_interface.getRootPanel():getWidth() / 2 < mousePos.x then - addEvent(function() tmpp:setParent(modules.game_interface.getRightPanel()) end) - else - addEvent(function() tmpp:setParent(modules.game_interface.getLeftPanel()) end) - end - else - addEvent(function() tmpp:setParent(modules.game_interface.getRightPanel()) end) - end - end - - else - if self.movedWidget then - self.setMovedChildMargin(self.movedOldMargin or 0) - self.movedWidget = nil - self.setMovedChildMargin = nil - self.movedOldMargin = nil - self.movedIndex = nil + for i=1,#children do + local child = children[i] + if child:getId() == 'gameLeftPanel' or child:getId() == 'gameRightPanel' then + dropInPanel = 1 + end + end + + if dropInPanel == 0 then + if(modules.game_interface.getLeftPanel():isVisible()) then + if modules.game_interface.getRootPanel():getWidth() / 2 < mousePos.x then + self:setParent(modules.game_interface.getRightPanel()) + else + self:setParent(modules.game_interface.getLeftPanel()) end - - self:saveParent(self:getParent()) + else + self:setParent(modules.game_interface.getRightPanel()) + end end + end + + self:saveParent(self:getParent()) end function UIMiniWindow:onDragMove(mousePos, mouseMoved)