6363 property int appTitleSpacing: 0
6464 property bool popupItem: root .itemKind === " group" || root .itemKind === " folder"
6565 readonly property bool resizeOptimizationActive: Panel .isResizing || (Panel .rootObject && Panel .rootObject .isDragging )
66+ readonly property bool dockPopupContext: Window .window && Panel .popupWindow && Window .window === Panel .popupWindow
6667 property bool deferredWindowIconGeometryUpdate: false
6768 property bool deferredPhysicalPixelFix: false
6869 property var iconGlobalPoint: {
@@ -79,9 +80,53 @@ Item {
7980
8081 implicitWidth: appItem .implicitWidth
8182
83+ function dockWindowGlobalPoint () {
84+ if (! Panel .rootObject ) {
85+ return Qt .point (0 , 0 )
86+ }
87+
88+ return Qt .point (Panel .rootObject .x , Panel .rootObject .y )
89+ }
90+
91+ function mapPointToDockWindow (targetItem , localPoint ) {
92+ const item = targetItem || appItem
93+ const point = localPoint || Qt .point (item .width / 2 , item .height / 2 )
94+
95+ if (! item) {
96+ return Qt .point (0 , 0 )
97+ }
98+
99+ if (! dockPopupContext) {
100+ return item .mapToItem (null , point .x , point .y )
101+ }
102+
103+ const globalPoint = item .mapToGlobal (point .x , point .y )
104+ const dockGlobalPoint = dockWindowGlobalPoint ()
105+ return Qt .point (globalPoint .x - dockGlobalPoint .x , globalPoint .y - dockGlobalPoint .y )
106+ }
107+
108+ function dockRelativeRect (targetItem ) {
109+ const item = targetItem || root
110+ const topLeft = mapPointToDockWindow (item, Qt .point (0 , 0 ))
111+ return Qt .rect (topLeft .x , topLeft .y , item .width , item .height )
112+ }
113+
114+ function dockPopupRect () {
115+ if (! dockPopupContext || ! Window .window || ! Window .window .contentItem ) {
116+ return dockRelativeRect (root)
117+ }
118+
119+ const popupTopLeftGlobal = Window .window .contentItem .mapToGlobal (0 , 0 )
120+ const dockGlobalPoint = dockWindowGlobalPoint ()
121+ return Qt .rect (popupTopLeftGlobal .x - dockGlobalPoint .x ,
122+ popupTopLeftGlobal .y - dockGlobalPoint .y ,
123+ Window .window .contentItem .width ,
124+ Window .window .contentItem .height )
125+ }
126+
82127 function mapSpotlightPoint (localPoint ) {
83128 const point = localPoint || Qt .point (appItem .width / 2 , appItem .height / 2 )
84- return appItem . mapToItem ( null , point . x , point . y )
129+ return mapPointToDockWindow (appItem , point)
85130 }
86131
87132 function updateSpotlight (localPoint ) {
@@ -108,7 +153,7 @@ Item {
108153 }
109154
110155 deferredWindowIconGeometryUpdate = false
111- var pos = icon . mapToItem ( null , 0 , 0 )
156+ var pos = mapPointToDockWindow (icon, Qt . point ( 0 , 0 ) )
112157 taskmanager .Applet .requestUpdateWindowIconGeometry (root .modelIndex ,
113158 Qt .rect (pos .x , pos .y , icon .width , icon .height ),
114159 Panel .rootObject )
@@ -785,7 +830,7 @@ Item {
785830 }
786831
787832 function showToolTipNow () {
788- var point = root . mapToItem ( null , root .width / 2 , root .height / 2 )
833+ var point = mapPointToDockWindow (root, Qt . point ( root .width / 2 , root .height / 2 ) )
789834 toolTip .DockPanelPositioner .bounding = Qt .rect (point .x , point .y , toolTip .width , toolTip .height )
790835 toolTip .open ()
791836 }
@@ -795,7 +840,9 @@ Item {
795840 Panel .rootObject ,
796841 xOffset,
797842 yOffset,
798- Panel .position )
843+ dockPopupContext
844+ ? (Panel .position === Dock .Top ? Dock .Top : Dock .Bottom )
845+ : Panel .position )
799846 }
800847
801848 function onEntered () {
@@ -817,14 +864,24 @@ Item {
817864 return
818865 }
819866
820- var itemPos = root . mapToItem ( null , 0 , 0 )
867+ const itemRect = dockRelativeRect (root )
821868 let xOffset, yOffset, interval = 10
822- if (Panel .position % 2 === 0 ) {
823- xOffset = itemPos .x + (root .width / 2 )
824- yOffset = (Panel .position == 2 ? - interval : interval + Panel .dockSize )
869+ if (dockPopupContext) {
870+ const popupRect = dockPopupRect ()
871+ xOffset = popupRect .x + popupRect .width / 2
872+ yOffset = Panel .position === Dock .Top
873+ ? popupRect .y + popupRect .height + interval
874+ : popupRect .y - interval
875+ } else if (Panel .position % 2 === 0 ) {
876+ xOffset = itemRect .x + itemRect .width / 2
877+ yOffset = Panel .position === Dock .Bottom
878+ ? itemRect .y - interval
879+ : itemRect .y + itemRect .height + interval
825880 } else {
826- xOffset = (Panel .position == 1 ? - interval : interval + Panel .dockSize )
827- yOffset = itemPos .y + (root .height / 2 )
881+ xOffset = Panel .position === Dock .Left
882+ ? itemRect .x + itemRect .width + interval
883+ : itemRect .x - interval
884+ yOffset = itemRect .y + itemRect .height / 2
828885 }
829886 if (root .windows .length > 0 && taskmanager .previewSwitchActive ) {
830887 taskmanager .endPreviewSwitch ()
@@ -985,7 +1042,7 @@ Item {
9851042 if (root .itemId === " dde-trash" ) {
9861043 dragToolTipCloseTimer .stop ()
9871044 if (! dragToolTip .toolTipVisible ) {
988- var point = root . mapToItem ( null , root .width / 2 , root .height / 2 )
1045+ var point = mapPointToDockWindow (root, Qt . point ( root .width / 2 , root .height / 2 ) )
9891046 dragToolTip .DockPanelPositioner .bounding = Qt .rect (point .x , point .y , dragToolTip .width , dragToolTip .height )
9901047 dragToolTip .open ()
9911048 }
0 commit comments