<commit_before>package com.johnuckele.vivarium.visualization.util;

import java.awt.Window;

import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.platform.unix.X11;
import com.sun.jna.platform.unix.X11.Display;
import com.sun.jna.platform.unix.X11.XClientMessageEvent;
import com.sun.jna.platform.unix.X11.XEvent;

public class Fullscreen
{
    private static final int _NET_WM_STATE_REMOVE = 0;
    private static final int _NET_WM_STATE_ADD = 1;

    public static void setFullScreenWindow(Window window, boolean fullScreen)
    {
        String osName = System.getProperty("os.name");
        if (osName.equals("Linux"))
        {
            setFullScreenWindowLinux(window, fullScreen);
        }
        else
        {
            setFullScreenWindowLightweight(window, fullScreen);
        }
    }

    private static boolean setFullScreenWindowLightweight(Window window, boolean fullScreen)
    {
        throw new UnsupportedOperationException("I should get a windows / OS X machine to test this.");
    }

    private static void setFullScreenWindowLinux(Window window, boolean fullScreen)
    {
        X11 x11Instance = X11.INSTANCE;
        Display display = null;
        try
        {
            display = x11Instance.XOpenDisplay(null);
            long windowID = Native.getWindowID(window);

            // Event set up
            XEvent xEvent = new XEvent();
            xEvent.setType(XClientMessageEvent.class);

            xEvent.xclient.type = X11.ClientMessage;
            xEvent.xclient.message_type = x11Instance.XInternAtom(display, "_NET_WM_STATE", false);
            xEvent.xclient.format = 32;<commit_msg>Fullscreen for non-linux (I think, still untested)<commit_after>package com.johnuckele.vivarium.visualization.util;

import java.awt.Window;

import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.platform.unix.X11;
import com.sun.jna.platform.unix.X11.Display;
import com.sun.jna.platform.unix.X11.XClientMessageEvent;
import com.sun.jna.platform.unix.X11.XEvent;

public class Fullscreen
{
    private static final int _NET_WM_STATE_REMOVE = 0;
    private static final int _NET_WM_STATE_ADD = 1;

    public static void setFullScreenWindow(Window window, boolean fullScreen)
    public static void setFullScreenWindow(JFrame window, boolean fullScreen)
    {
        String osName = System.getProperty("os.name");
        if (osName.equals("Linux"))
        {
            setFullScreenWindowLinux(window, fullScreen);
        }
        else
        {
            setFullScreenWindowLightweight(window, fullScreen);
        }
    }

    private static void setFullScreenWindowLightweight(JFrame window, boolean fullScreen)
    {
        window.setUndecorated(true);
        GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        gd.setFullScreenWindow(window);
    }

    private static void setFullScreenWindowLinux(Window window, boolean fullScreen)
    {
        X11 x11Instance = X11.INSTANCE;
        Display display = null;
        try
        {
            display = x11Instance.XOpenDisplay(null);
            long windowID = Native.getWindowID(window);

            // Event set up
            XEvent xEvent = new XEvent();
            xEvent.setType(XClientMessageEvent.class);

            xEvent.xclient.type = X11.ClientMessage;
            xEvent.xclient.message_type = x11Instance.XInternAtom(display, "_NET_WM_STATE", false);
            xEvent.xclient.format = 32;
{'fraction_non_alphanumeric': 0.08752486501847116, 'fraction_numerical': 0.013640238704177323, 'mean_word_length': 2.8302502720348204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6276684', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1018, 'n_words': 210}