<commit_before>var Window = require('./window');

var Workspace = function() {
  this.windows = [];

  this.element = document.createElement("div");
  this.element.className = "windowsill workspace";
  this.cursorX = 0;
  this.cursorY = 0;
  this.element.addEventListener('mousemove', function(event) {
    var rect    = this.element.getBoundingClientRect();

    this.cursorX = event.clientX - rect.left;
    this.cursorY = event.clientY - rect.top;
  }.bind(this));
};

Workspace.prototype.addWindow = function(window) {
  this.windows.push(window);
  this.element.appendChild(window.element);
};
Workspace.prototype.removeWindow = function(window) {
  this.windows.splice(this.windows.indexOf(window), 1);
  this.element.removeChild(window.element);
};
Workspace.prototype.createWindow = function(opts) {
  var window = new Window(opts);
  this.addWindow(window);
  return window;
};

module.exports = Workspace;<commit_msg>get cursor quadrant, change window focus<commit_after>var Window = require('./window');

var Workspace = function() {
  this.windows = [];

  this.element = document.createElement("div");
  this.element.className = "windowsill workspace";
  this.cursorX = 0;
  this.cursorY = 0;
  this.focusedWindow = null;
  this.element.addEventListener('mousemove', function(event) {
    var rect    = this.element.getBoundingClientRect();

    this.cursorX = event.clientX - rect.left;
    this.cursorY = event.clientY - rect.top;
  }.bind(this));
};

Workspace.prototype.addWindow = function(window) {
  this.windows.push(window);
  this.element.appendChild(window.element);
  this.focus(window);
};
Workspace.prototype.removeWindow = function(window) {
  this.windows.splice(this.windows.indexOf(window), 1);
  this.element.removeChild(window.element);
};
Workspace.prototype.createWindow = function(opts) {
  var window = new Window(opts);
  this.addWindow(window);
  return window;
};

Workspace.prototype.focus = function(window) {
  if(this.focusedWindow) {
    this.focusedWindow.element.style.zIndex = 1;
  }
  this.focusedWindow = window;
  this.focusedWindow.element.style.zIndex = 2;
};

Workspace.prototype.getCursorQuadrant = function() {
  var thisRect = this.element.getBoundingClientRect();
  var slope = thisRect.height / thisRect.width;
  var potentialQuadrants = [
    ['left', 'bottom'],
    ['top', 'right']
  ];
  var corner;
  if(this.cursorY > slope * this.cursorX) {
    corner = potentialQuadrants[0];
  }
  else {
    corner = potentialQuadrants[1];
  }

  if(this.cursorY < -slope * this.cursorX + thisRect.height) {
    return corner[0];
  }
  else {
    return corner[1];
  }
};

module.exports = Workspace;
{'fraction_non_alphanumeric': 0.14630467571644043, 'fraction_numerical': 0.004524886877828055, 'mean_word_length': 4.212180746561886, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2307834', 'n_tokens_mistral': 852, 'n_tokens_neox': 837, 'n_words': 146}