|
@@ -83,10 +83,15 @@ public class OsdManager {
|
83
|
83
|
|
84
|
84
|
/**
|
85
|
85
|
* Create a new OSD window with "message".
|
|
86
|
+ * <p>
|
|
87
|
+ * This method needs to be synchronised to ensure that the window list is
|
|
88
|
+ * not modified in between the invocation of {@link #getYPosition()} and
|
|
89
|
+ * the point at which the {@link OSDWindow} is added to the windowList.
|
86
|
90
|
*
|
|
91
|
+ * @see #getYPosition()
|
87
|
92
|
* @param message Text to display in the OSD window.
|
88
|
93
|
*/
|
89
|
|
- private void displayWindow(final String message) {
|
|
94
|
+ private synchronized void displayWindow(final String message) {
|
90
|
95
|
windowList.add(UIUtilities.invokeAndWait(
|
91
|
96
|
new ReturnableThread<OsdWindow>() {
|
92
|
97
|
|
|
@@ -97,7 +102,8 @@ public class OsdManager {
|
97
|
102
|
IdentityManager.getGlobalConfig().getOptionInt(
|
98
|
103
|
plugin.getDomain(), "locationX"), getYPosition(),
|
99
|
104
|
plugin, OsdManager.this));
|
100
|
|
- }}));
|
|
105
|
+ }
|
|
106
|
+ }));
|
101
|
107
|
}
|
102
|
108
|
|
103
|
109
|
/**
|
|
@@ -106,38 +112,37 @@ public class OsdManager {
|
106
|
112
|
*
|
107
|
113
|
* @param window The window that we are destroying.
|
108
|
114
|
*/
|
109
|
|
- public void closeWindow(final OsdWindow window) {
|
|
115
|
+ public synchronized void closeWindow(final OsdWindow window) {
|
110
|
116
|
final String policy = IdentityManager.getGlobalConfig().getOption(
|
111
|
117
|
plugin.getDomain(), "newbehaviour");
|
112
|
118
|
|
113
|
|
- synchronized (OsdManager.this) {
|
114
|
|
- UIUtilities.invokeAndWait(new Runnable() {
|
115
|
|
- /** {@inheritDoc} */
|
116
|
|
- @Override
|
117
|
|
- public void run() {
|
118
|
|
- int oldY = window.getY();
|
119
|
|
- final int closedIndex = windowList.indexOf(window);
|
|
119
|
+ int oldY = window.getDesiredY();
|
|
120
|
+ final int closedIndex = windowList.indexOf(window);
|
120
|
121
|
|
121
|
|
- if (closedIndex == -1) {
|
122
|
|
- return;
|
123
|
|
- }
|
|
122
|
+ if (closedIndex == -1) {
|
|
123
|
+ return;
|
|
124
|
+ }
|
124
|
125
|
|
125
|
|
- windowList.remove(window);
|
126
|
|
- window.dispose();
|
|
126
|
+ windowList.remove(window);
|
127
|
127
|
|
128
|
|
- final List<OsdWindow> newList = getWindowList();
|
|
128
|
+ UIUtilities.invokeLater(new Runnable() {
|
|
129
|
+ /** {@inheritDoc} */
|
|
130
|
+ @Override
|
|
131
|
+ public void run() {
|
|
132
|
+ window.dispose();
|
|
133
|
+ }
|
|
134
|
+ });
|
129
|
135
|
|
130
|
|
- for (OsdWindow otherWindow : newList.subList(closedIndex, newList.size())) {
|
131
|
|
- final int currentY = otherWindow.getY();
|
|
136
|
+ final List<OsdWindow> newList = getWindowList();
|
|
137
|
+ for (OsdWindow otherWindow : newList.subList(closedIndex, newList.size())) {
|
|
138
|
+ final int currentY = otherWindow.getDesiredY();
|
132
|
139
|
|
133
|
|
- if ("down".equals(policy) || "up".equals(policy)) {
|
134
|
|
- otherWindow.setLocation(otherWindow.getX(), oldY);
|
135
|
|
- oldY = currentY;
|
136
|
|
- }
|
137
|
|
- }
|
138
|
|
- }
|
139
|
|
- });
|
|
140
|
+ if ("down".equals(policy) || "up".equals(policy)) {
|
|
141
|
+ otherWindow.setDesiredLocation(otherWindow.getDesiredX(), oldY);
|
|
142
|
+ oldY = currentY;
|
|
143
|
+ }
|
140
|
144
|
}
|
|
145
|
+
|
141
|
146
|
displayWindows();
|
142
|
147
|
}
|
143
|
148
|
|
|
@@ -170,6 +175,13 @@ public class OsdManager {
|
170
|
175
|
|
171
|
176
|
/**
|
172
|
177
|
* Get the Y position for the next window.
|
|
178
|
+ * <p>
|
|
179
|
+ * In order to ensure that windows are displayed at the correct position,
|
|
180
|
+ * the calling party MUST ensure that the window list is not altered between
|
|
181
|
+ * this method's invocation and the time at which the window is displayed.
|
|
182
|
+ * If the window list is altered, multiple windows may appear on top of
|
|
183
|
+ * each other instead of stacking correctly, or there may be gaps in up/down
|
|
184
|
+ * policy layouts.
|
173
|
185
|
*
|
174
|
186
|
* @return the Y position for the next window.
|
175
|
187
|
*/
|