aplteam / Fire

GUI for Find and Replace operations in Dyalog APL
MIT License
3 stars 0 forks source link

Fire does not reposition to existing monitor after being closed on nonexistent monitor #13

Closed norberturkiewicz closed 5 years ago

norberturkiewicz commented 5 years ago

If I close fire while its position is on monitor B and unplug the monitor, fire will not reposition on the main monitor.

This fixes the issue

 n←CreateGUI debugFlag;isAv;posn;size;IsPosnAvailable
⍝
 n←##.CreateGuiRefContainer
 n←CreateIcon n
 n←CreateMainForm debugFlag n
 n←CreateHiddenButtons n
 n←CreateFind n
 n←CreateWhereToLook n
 n←CreateTabs n
 n←CreateTab1Children n
 n←CreateTab2Children n
 n←CreatePushButtons n
 n←CreateCheckBoxes n
 n←CreateHitList n
 n←SetStateAndActive n
 n←CheckStartButton n

 IsPosnAvailable←{
 ⍝ check if coords are actually available to be displayed on
     ⎕USING←'System.Windows.Forms,System.Windows.Forms.dll' 'System.Drawing,System.Drawing.dll'
     (y x)(h w)←⍵
     pt←⎕NEW Point(x y)
     screens←Screen.AllScreens
     contains←screens.Bounds.Contains pt
     ∨/contains
 }

 :Trap 0
     :If IsPosnAvailable ##.G.(Posn Size)
         posn←##.G.Posn
         size←##.G.Size
     :EndIf
 :EndTrap

 n.Form.Posn←posn
 n.Form.Size←size
⍝Done
aplteam commented 5 years ago

I don't want to add Windows dependencies. You can get easily around this by either restart from a fresh instance of Dyalog or by specifying ]fire -fl (fl stands for "force load") since this will center Fire's GUI on the main monitor.

Fire remembers the last position only during the current session.

norberturkiewicz commented 5 years ago

My argument is that Fire GUI is Windows only and a restart or needing to know command switches aren’t really a good solution to a bug.

aplteam commented 5 years ago

Well, whether it will stay "Windows only" is something I am not so sure about.

Also, from my point of view it's not a bug: when you move some window to a monitor and then unplug that monitor, well, ….

Paul?

aplteam commented 5 years ago

I've changed Fire so that when ]Fire is issued while the Form is both in existence and visible the Posn is reset to ⍬ ⍬. That way you still have to restart, but not your APL session but just Fire.

Comments are welcome.