@@ -104,10 +104,17 @@
-- find where window is in case we drag it offscreen
mwi.origx = WindowInfo (win, 10)
mwi.origy = WindowInfo (win, 11)
+ -- find where the friends are relative to the window
+ for i,v in ipairs(mwi.window_friends) do
+ if (v ~= nil) then
+ mwi.window_friend_deltas[i] = {WindowInfo(v, 10) - mwi.origx, WindowInfo(v, 11) - mwi.origy}
+ end -- if
+ end -- for
+
end -- mousedown
end -- make_mousedown_handler
-- make a mouse drag-move handler with the movement information as an upvalue
@@ -123,10 +130,17 @@
WindowInfo (win, 18) - mwi.starty
-- move the window to the new location - offset by how far mouse was into window
WindowPosition(win, posx, posy, 0, 2);
+ -- move the friends if they still exist
+ for i,v in ipairs(mwi.window_friends) do
+ if (v ~= nil) then
+ WindowPosition(v, posx+mwi.window_friend_deltas[i][1], posy+mwi.window_friend_deltas[i][2], 0, WindowInfo(v, 8))
+ end -- if
+ end -- for
+
-- change the mouse cursor shape appropriately
if posx < mwi.margin - WindowInfo (win, 3) or
posx > GetInfo (281) - mwi.margin or
posy < 0 or -- don't drag title out of view
posy > GetInfo (280) - mwi.margin then
@@ -212,29 +226,33 @@
end -- make_check_map_position_handler
-- call movewindow.install in OnPluginInstall to find the position of the window, before creating it
-- - it also creates the handler functions ready for use later
-function movewindow.install (win, default_position, default_flags, nocheck)
+function movewindow.install (win, default_position, default_flags, nocheck, default_friends)
win = win or GetPluginID () -- default to current plugin ID
assert (not string.match (win, "[^A-Za-z0-9_]"), "Invalid window name in movewindow.install: " .. win)
default_position = default_position or 7 -- on right, center top/bottom
default_flags = default_flags or 0
+ if (default_friends == nil) then
+ default_friends = {}
+ end
-- set up handlers and where window should be shown (from saved state, if any)
local movewindow_info = {
win = win, -- save window ID
-- save current position in table (obtained from state file)
window_left = tonumber (GetVariable ("mw_" .. win .. "_windowx")) or 0,
window_top = tonumber (GetVariable ("mw_" .. win .. "_windowy")) or 0,
window_mode = tonumber (GetVariable ("mw_" .. win .. "_windowmode")) or default_position,
window_flags = tonumber (GetVariable ("mw_" .. win .. "_windowflags")) or default_flags,
-
+ window_friends = default_friends,
+ window_friend_deltas = {},
margin = 20 -- how close we can put to the edge of the window
}
-- handler to reposition window
movewindow_info.check_map_position = make_check_map_position_handler (movewindow_info) -- for startup
|