screen coordinates massaged so that movewindow command works to
    restore the window to the same position
    returns x, y
168226
def get_active_window_pos():
    '''
    '''
    # http://stackoverflow.com/questions/26050788/in-bash-on-ubuntu-14-04-unity-how-can-i-get-the-total-size-of-an-open-window-i/26060527#26060527
    cmd = ['xdotool','getactivewindow', 'getwindowgeometry']
    res = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr= subprocess.PIPE).communicate()
    stdout = res[0].decode('utf-8').splitlines()
    pos = stdout[1].split(':')[1].split(',')
    geo = stdout[2].split(':')[1].split('x')
    x, y = int(pos[0].strip()), int(pos[1].split('(')[0].strip())
    w, h = int(geo[0].strip()), int(geo[1].strip())

    # get the window decorations
    window_id = get_window_id()
    cmd = ['xprop', '_NET_FRAME_EXTENTS', '-id', window_id]
    res = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr= subprocess.PIPE).communicate()
    decos = res[0].decode('utf-8').split('=')[1].split(',')
    l, r = int(decos[0].strip()), int(decos[1].strip())
    t, b = int(decos[2].strip()), int(decos[3].strip())

    return x-l, y-t
791447
def window(self, windowNum=0):
        
        if self._pid == -1:
            return None
        x,y,w,h = PlatformManager.getWindowRect(PlatformManager.getWindowByPID(self._pid, windowNum))
        return Region(x,y,w,h).clipRegionToScreen()
1052869
public Point getScreenCoords (int x, int y)
    {
        return MisoUtil.fullToScreen(_metrics, x, y, new Point());
    }
262893
def set_cursor(self, x, y):
        
        curses.curs_set(1)
        self.screen.move(y, x)
1360079
def window_locations(pos, windows):
    
    start_locs = np.searchsorted(pos, windows[:, 0])
    stop_locs = np.searchsorted(pos, windows[:, 1], side='right')
    locs = np.column_stack((start_locs, stop_locs))
    return locs
344156
def move(self, place, distance = 1):
        """"""
        x, y = self._get_position()
        if place == 'up':
            y -= distance
        elif place == 'down':
            for i in range(distance): print
            nx, ny = self._get_position()
            y = ny
            self.move('beginning of line')
        elif place == 'left':
            x -= distance
        elif place == 'right':
            x += distance
        elif place == 'beginning of line':
            x = 0
        elif place == 'beginning of screen':
            x = 0
            y = self._get_console_info()['window']['top']
        else:
            raise ValueError("invalid place to move")
        self._set_position((x, y))
772290
public static void snapWindowTo(Window win, int location)
	{
		Dimension _screen = Toolkit.getDefaultToolkit().getScreenSize();
		Dimension _window = win.getSize();
		int _wx = 0;
		int _wy = 0;
		switch (location)
		{
			case TOP_LEFT:
				break;
			case TOP_CENTER:
				_wx = (_screen.width - _window.width) / 2;
				break;
			case TOP_RIGHT:
				_wx = _screen.width - _window.width;
				break;
			case MIDDLE_LEFT:
				_wy = (_screen.height - _window.height) / 2;
				break;
			case MIDDLE_CENTER:
				_wx = (_screen.width - _window.width) / 2;
				_wy = (_screen.height - _window.height) / 2;
				break;
			case MIDDLE_RIGHT:
				_wx = _screen.width - _window.width;
				_wy = (_screen.height - _window.height) / 2;
				break;
			case BOTTOM_LEFT:
				_wy = _screen.height - _window.height;
				break;
			case BOTTOM_CENTER:
				_wx = (_screen.width - _window.width) / 2;
				_wy = _screen.height - _window.height;
				break;
			case BOTTOM_RIGHT:
				_wx = _screen.width - _window.width;
				_wy = _screen.height - _window.height;
				break;
		}
		win.setLocation(new Point(_wx, _wy));
	}
679382
def click_at_coordinates(self, x, y):
        
        self.device.click(int(x), int(y))
388873
def move_mouse(self, x, y, screen=0):
        
        # todo: apparently the "screen" argument is not behaving properly
        #       and sometimes even making the interpreter crash..
        #       Figure out why (changed API / using wrong header?)

        # >>> xdo.move_mouse(3000,200,1)

        # X Error of failed request:  BadWindow (invalid Window parameter)
        #   Major opcode of failed request:  41 (X_WarpPointer)
        #   Resource id in failed request:  0x2a4fca0
        #   Serial number of failed request:  25
        #   Current serial number in output stream:  26

        # Just to be safe..
        # screen = 0

        x = ctypes.c_int(x)
        y = ctypes.c_int(y)
        screen = ctypes.c_int(screen)

        _libxdo.xdo_move_mouse(self._xdo, x, y, screen)
443559
function( x, y, w, h ){
    this._dat[ 0|VIEWPORT_X ] = x;
    this._dat[ 0|VIEWPORT_Y ] = y;
    this._dat[ 0|VIEWPORT_W ] = w;
    this._dat[ 0|VIEWPORT_H ] = h;
    this._set |= VIEWPORT_SET|0;
    return this;
  }
479077
def fetch_transform_screen_position(cli, transform_path):
    

    message_payload = {
        "transform_path": transform_path
    }
    msg = message.Message("fetch.unity.transform.screenPosition", message_payload)
    cli.send_message(msg)

    response = cli.read_message()
    verify_response(response)
    return [
            response['payload']['x'],
            response['payload']['y']
    ]
117380
function (x, y) {
      var target = this._currentTransform.target;
      target.lockMovementX || target.set('left', x - this._currentTransform.offsetX);
      target.lockMovementY || target.set('top', y - this._currentTransform.offsetY);
    }
1056597
def acknowledge_gnome_notification():
    
    x0, y0 = mouse_pos()
    mouse_move(10000, 10000)  # TODO: What if the screen is larger? Loop until mouse position does not change anymore?
    x, y = mouse_pos()
    mouse_rmove(-x/2, 0)
    mouse_click(LEFT)
    time.sleep(.2)
    mouse_move(x0, y0)
486555
def window_xy x,y
      s = ""
      s << "+" if x > 0
      s << x.to_s
      s << "+" if y > 0
      s << y.to_s
      @root.geometry s
    end
384121
public double fromScreenY(double y)
    {
        Point2D src = srcPnt.get();
        Point2D dst = dstPnt.get();
        src.setLocation(0, y);
        inverse.transform(src, dst);
        return dst.getY();
    }
1267239
function getCursorPosition(event) {
  let cursorX;
  let cursorY;
  let rect = htmlElement.getBoundingClientRect();
  if (event.touches !== undefined) {
    cursorX = event.touches[0].clientX;
    cursorY = event.touches[0].clientY;
  } else {
    cursorX = event.clientX;
    cursorY = event.clientY;
  }
  return {
    x: cursorX - rect.left,
    y: cursorY - rect.top,
  };
}
446081
def get_rect(self):
        
        if self.handle:
            left, top, right, bottom = win32gui.GetWindowRect(self.handle)
            return RECT(left, top, right, bottom)
        else:
            desktop = win32gui.GetDesktopWindow()
            left, top, right, bottom = win32gui.GetWindowRect(desktop)
            return RECT(left, top, right, bottom)