<commit_before>import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.image.BufferStrategy;
import java.awt.Graphics;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Robot;
import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import javax.swing.SwingUtilities;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
public class GameWindow
{
  private final JFrame frame;
  private BufferStrategy bStrat;
  //used to move mouse
  private Robot robot;
  private final Keyboard input;
  private Canvas canvas;
  private final Point origin;

  public GameWindow(String title, Dimension windowSize,final  Keyboard input)
  {
     try{
      robot = new Robot();
    } catch(AWTException e) {
      //TODO maybe.
    }
    this.input = input;
    //set up the JFrame
    frame = new JFrame(title);
    frame.setSize(windowSize);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    frame.setResizable(false);
    frame.setIgnoreRepaint(true);


    canvas = new Canvas();
    canvas.setPreferredSize(windowSize);
    canvas.setIgnoreRepaint(true);
    canvas.addKeyListener(input);
    canvas.addMouseMotionListener(input);
    frame.add(canvas);

    frame.pack();
    frame.setVisible(true);

    canvas.createBufferStrategy(2);
    bStrat = canvas.getBufferStrategy();
    origin = new Point();
    frame.addComponentListener(new ComponentAdapter() {
      public void componentMoved(ComponentEvent e)
      {
        origin.setLocation(frame.getLocationOnScreen());
        origin.translate(frame.getWidth()/2,frame.getHeight()/2);
        input.setOrigin(origin);
      }
    });

  }

  public JFrame getFrame() {return frame;}
  public BufferStrategy getBufferStrategy() {return bStrat;}

  public void resetMousePos()
  {
    robot.mouseMove((int)origin.getX(),(int)origin.getY());
  }

  //test
  public static void main(String[] args)
  {
    GameWindow gWind = new GameWindow("test window", new Dimension(800, 600),null);
    BufferStrategy bStrateg = gWind.getBufferStrategy();
    Graphics g = bStrateg.getDrawGraphics();
    g.setColor(Color.BLACK);
    g.fillRect(50, 50, 300, 300);<commit_msg>Mouse pointer resets to center of JFrame<commit_after>import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.image.BufferStrategy;
import java.awt.Graphics;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Robot;
import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import javax.swing.SwingUtilities;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
public class GameWindow
{
  private final JFrame frame;
  private BufferStrategy bStrat;
  //used to move mouse
  private Robot robot;
  private final Keyboard input;
  private Canvas canvas;
  private final Point origin;

  public GameWindow(String title, Dimension windowSize,final  Keyboard input)
  {
     try{
      robot = new Robot();
    } catch(AWTException e) {
      //TODO maybe.
    }
    this.input = input;
    //set up the JFrame
    frame = new JFrame(title);
    frame.setSize(windowSize);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    frame.setResizable(false);
    frame.setIgnoreRepaint(true);


    canvas = new Canvas();
    canvas.setPreferredSize(windowSize);
    canvas.setIgnoreRepaint(true);
    canvas.addKeyListener(input);
    canvas.addMouseMotionListener(input);
    frame.add(canvas);

    frame.pack();
    frame.setVisible(true);

    canvas.createBufferStrategy(2);
    bStrat = canvas.getBufferStrategy();
    origin = frame.getLocationOnScreen();
    origin.setLocation(origin.getX()+canvas.getWidth()/2, origin.getY()+canvas.getHeight()/2);
    frame.addComponentListener(new ComponentAdapter() {
      public void componentMoved(ComponentEvent e)
      {
        Point frameLoc = frame.getLocationOnScreen();
        origin.setLocation(frameLoc.getX()+canvas.getWidth()/2, frameLoc.getY()+canvas.getHeight()/2);
        input.setOrigin(origin);
      }
    });

  }

  public JFrame getFrame() {return frame;}
  public BufferStrategy getBufferStrategy() {return bStrat;}

  public void resetMousePos()
  {
    robot.mouseMove((int)origin.getX(), (int)origin.getY());
  }

  //test
  public static void main(String[] args)
  {
    GameWindow gWind = new GameWindow("test window", new Dimension(800, 600),null);
    BufferStrategy bStrateg = gWind.getBufferStrategy();
    Graphics g = bStrateg.getDrawGraphics();
    g.setColor(Color.BLACK);
    g.fillRect(50, 50, 300, 300);
{'fraction_non_alphanumeric': 0.11482649842271293, 'fraction_numerical': 0.008412197686645636, 'mean_word_length': 3.943866943866944, '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': '1250741', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1459, 'n_words': 312}