20 #include "vehicle_base.h" |
20 #include "vehicle_base.h" |
21 #include "settings_type.h" |
21 #include "settings_type.h" |
22 |
22 |
23 #include "table/sprites.h" |
23 #include "table/sprites.h" |
24 |
24 |
25 static Point _drag_delta; //< delta between mouse cursor and upper left corner of dragged window |
25 static Point _drag_delta; ///< delta between mouse cursor and upper left corner of dragged window |
|
26 static Window *_mouseover_last_w = NULL; ///< Window of the last MOUSEOVER event |
26 |
27 |
27 static Window _windows[MAX_NUMBER_OF_WINDOWS]; |
28 static Window _windows[MAX_NUMBER_OF_WINDOWS]; |
28 |
29 |
29 /** |
30 /** |
30 * List of windows opened at the screen. |
31 * List of windows opened at the screen. |
420 SetWindowDirty(w); |
421 SetWindowDirty(w); |
421 free(w->widget); |
422 free(w->widget); |
422 w->widget = NULL; |
423 w->widget = NULL; |
423 w->widget_count = 0; |
424 w->widget_count = 0; |
424 w->parent = NULL; |
425 w->parent = NULL; |
|
426 |
|
427 /* Prevent Mouseover() from resetting mouse-over coordinates on a non-existing window */ |
|
428 if (_mouseover_last_w == w) _mouseover_last_w = NULL; |
425 |
429 |
426 /* Find the window in the z-array, and effectively remove it |
430 /* Find the window in the z-array, and effectively remove it |
427 * by moving all windows after it one to the left */ |
431 * by moving all windows after it one to the left */ |
428 Window **wz = FindWindowZPosition(w); |
432 Window **wz = FindWindowZPosition(w); |
429 if (wz == NULL) return; |
433 if (wz == NULL) return; |
1195 return false; |
1199 return false; |
1196 } |
1200 } |
1197 |
1201 |
1198 static bool HandleMouseOver() |
1202 static bool HandleMouseOver() |
1199 { |
1203 { |
1200 Window *w; |
|
1201 WindowEvent e; |
1204 WindowEvent e; |
1202 static Window *last_w = NULL; |
1205 |
1203 |
1206 Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y); |
1204 w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y); |
|
1205 |
1207 |
1206 /* We changed window, put a MOUSEOVER event to the last window */ |
1208 /* We changed window, put a MOUSEOVER event to the last window */ |
1207 if (last_w != NULL && last_w != w) { |
1209 if (_mouseover_last_w != NULL && _mouseover_last_w != w) { |
|
1210 /* Reset mouse-over coordinates of previous window */ |
1208 e.event = WE_MOUSEOVER; |
1211 e.event = WE_MOUSEOVER; |
1209 e.we.mouseover.pt.x = -1; |
1212 e.we.mouseover.pt.x = -1; |
1210 e.we.mouseover.pt.y = -1; |
1213 e.we.mouseover.pt.y = -1; |
1211 if (last_w->wndproc) last_w->wndproc(last_w, &e); |
1214 if (_mouseover_last_w->wndproc != NULL) _mouseover_last_w->wndproc(_mouseover_last_w, &e); |
1212 } |
1215 } |
1213 last_w = w; |
1216 |
|
1217 /* _mouseover_last_w will get reset when the window is deleted, see DeleteWindow() */ |
|
1218 _mouseover_last_w = w; |
1214 |
1219 |
1215 if (w != NULL) { |
1220 if (w != NULL) { |
1216 /* send an event in client coordinates. */ |
1221 /* send an event in client coordinates. */ |
1217 e.event = WE_MOUSEOVER; |
1222 e.event = WE_MOUSEOVER; |
1218 e.we.mouseover.pt.x = _cursor.pos.x - w->left; |
1223 e.we.mouseover.pt.x = _cursor.pos.x - w->left; |