change to how movewindow saves x,y position

Posted by Fiendish on Mon 27 Aug 2012 12:30 AM — 6 posts, 21,433 views.

USA Global Moderator #0
I ran into a glitch saving/restoring movewindow position when multiple plugins allowed dragging of a single shared miniwindow. Surely there are other ways of handling this situation across the plugins themselves, but the simplest solution seems to be the following change to movewindow.lua, where the actual miniwindow position is saved instead of the imagined position which is in this case not always correct (if the window doesn't exist, nothing is written to those variables).


@@ -392,9 +392,13 @@
     return
   end -- no such window
   
-  -- remember where the window was 
-  SetVariable ("mw_" .. win .. "_windowx",      mwi.window_left)
-  SetVariable ("mw_" .. win .. "_windowy",      mwi.window_top)
+  -- remember where the window was
+  if WindowInfo(win, 10) then
+    SetVariable ("mw_" .. win .. "_windowx",    WindowInfo(win, 10))
+  end
+  if WindowInfo(win, 11) then
+    SetVariable ("mw_" .. win .. "_windowy",    WindowInfo(win, 11))
+  end
   SetVariable ("mw_" .. win .. "_windowmode",   mwi.window_mode)
   SetVariable ("mw_" .. win .. "_windowflags",  mwi.window_flags)


I'm guessing only one if check is actually necessary, but wasn't willing to risk it without going and looking at the MUSHclient code, which I haven't done.
Amended on Mon 27 Aug 2012 12:34 AM by Fiendish
Australia Forum Administrator #1
Does that work properly in your testing? I suppose it does or you wouldn't suggest it, but just checking.
USA Global Moderator #2
It solved my 2-plugins-1-window issue, of course, and I have not noticed any problems yet in limited testing. I speculate that the only noticable behavior change that this could cause is that a miniwindow cannot save last position state post-deletion. I think that's probably a silly thing to want to do anyway.
Amended on Mon 27 Aug 2012 10:57 PM by Fiendish
Australia Forum Administrator #3
What if we leave in those two line you deleted? Then the fallback is the current behaviour.
USA Global Moderator #4
Hmm. I consider it undesirable to ever use window_left/window_top for saving, but sidestepping the situation of calling movewindow.save_state while the window's existence is in flux is trivial. So sure.
Amended on Tue 28 Aug 2012 01:48 AM by Fiendish
Australia Forum Administrator #5
Added to version 4.82:

https://github.com/nickgammon/mushclient/commit/46cef19a76