| 1088 | // TODO: preferences to alter this behavior (on/off, snap distance) |
| 1089 | // TODO: allow user to override this behavior in a reasonable way |
| 1090 | |
| 1091 | BRect frame = fFrame; |
| 1092 | BPoint offsetWithinFrame; |
| 1093 | // TODO: Obtain the usable area (not covered by the tracker) |
| 1094 | BRect screenFrame = fDesktop->ActiveScreen()->Frame(); |
| 1095 | |
| 1096 | if (fDecorator) { |
| 1097 | BRegion reg; |
| 1098 | fDecorator->GetFootprint(®); |
| 1099 | frame = reg.Frame(); |
| 1100 | offsetWithinFrame.x = fFrame.left - frame.left; |
| 1101 | offsetWithinFrame.y = fFrame.top - frame.top; |
| 1102 | } |
| 1103 | |
| 1104 | frame.OffsetBy(delta); |
| 1105 | |
| 1106 | if (frame.top < screenFrame.top + 4 |
| 1107 | && frame.top > screenFrame.top - 4) { |
| 1108 | frame.bottom -= frame.top; |
| 1109 | frame.top = 0; |
| 1110 | } |
| 1111 | |
| 1112 | if (frame.left < screenFrame.left + 4 |
| 1113 | && frame.left > screenFrame.left - 4) { |
| 1114 | frame.right -= frame.left; |
| 1115 | frame.left = 0; |
| 1116 | } |
| 1117 | |
| 1118 | if (frame.bottom > screenFrame.bottom - 4 |
| 1119 | && frame.bottom < screenFrame.bottom + 4) { |
| 1120 | frame.top -= frame.bottom - screenFrame.bottom; |
| 1121 | frame.bottom = screenFrame.bottom; |
| 1122 | } |
| 1123 | |
| 1124 | if (frame.right > screenFrame.right - 4 |
| 1125 | && frame.right < screenFrame.right + 4) { |
| 1126 | frame.left -= frame.right - screenFrame.right; |
| 1127 | frame.right = screenFrame.right; |
| 1128 | } |
| 1129 | |
| 1130 | frame.top += offsetWithinFrame.y; |
| 1131 | frame.left += offsetWithinFrame.x; |
| 1132 | |
| 1133 | delta.y = frame.top - fFrame.top; |
| 1134 | delta.x = frame.left - fFrame.left; |
| 1135 | } |
| 1136 | |