package dev.photosync.platform;

/**
 * The most recent window title, for the upload description's client name.
 *
 * <p>Static for the same reason as {@code ScreenshotBus} and {@code QuitGuard}:
 * the thing that notices the title changing is {@code TitleMixin}, woven into a
 * Minecraft class that nobody constructs, so it has nowhere to be handed a
 * collaborator. A static rendezvous point is the only option, and the mixin
 * writes here and the {@code GameAdapter} reads from here, so the storage has
 * exactly one owner.
 */
public final class WindowTitle {

    private static volatile String last = "";

    private WindowTitle() {
    }

    /** Called by {@code TitleMixin} whenever the window is given a title. */
    public static void record(String title) {
        last = title;
    }

    /** The current window title, or empty before the first {@code setTitle}. */
    public static String last() {
        return last;
    }
}
