JFLib

ui/winstate.rs#

Source: lib/ui/winstate.rs

winstate -- the placement of the windows kept between runs (AF_SAVE_STATE)

  state_save(&mut ini)    the main window (position, size, maximized) into [window], the
                          tool windows (open, placement) into [window ID]
  state_load(&ini)        read them back: the main window at once (window_place(0)), a
                          tool window when window_begin meets its id next (its open flag
                          and WinRect written into the app's Shared values)

AF_SAVE_STATE in the AppDesc: the runtime reads config://windows.ini before it creates the
main window (at the saved size and position, maximized when it was; --size wins) and
writes it at the end of a window run, before UIC_EXIT.  jfgui_STATE=PATH uses another
file, jfgui_STATE=0 none.  Headless runs (--shot, --script, agents) never touch the file;
state_save / state_load work there as well (the main window: its size only).

[window]: x / y (screen px of the client area's top left; Wayland places windows itself
and ignores them), w / h (DIP, the size before maximizing or minimizing), max (0 / 1).  A
position off every monitor (a monitor that is gone) is centred on the work area of the
nearest one.  [window ID] (decimal id): open (0 / 1) and x / y / w / h (DIP, relative to
the owner's client area: the WinRect; off every monitor: centred like the main window).  Only tool windows (WF_TOOL, not WF_DIALOG /
WF_MODAL) are kept; sections of windows that did not run this time stay in the file.

impl Ui

  • fn state_save(&mut self, ini: &mut Ini) write the placement of the main window and of the tool windows into ini (see the module header)
  • fn state_load(&mut self, ini: &Ini) read the placements of state_save back (the main window now, the tool windows when window_begin meets them)

Source: docs/API.md in the JFLib repository.