示例#1
0
文件: main.c 项目: rofl0r/libxauto
void TEST_window_y() {
    char *routine = "TEST_window_y";
    printf(testing, routine);
    //First a valid window
    Window win = active_window();
    int y = window_y(win);
    assert(y > INT_MIN);

    //Then an invalid window
    assert(window_y(20) == INT_MIN);
    printf(done, routine);
}
示例#2
0
文件: xaut.c 项目: hw94/ucognito
BOOL _normalize_wincoords(int *x, int *y, unsigned long win) {
    if (!_check_init()) {
        return FALSE;
    }
    XWindowAttributes *attribs = calloc(1, sizeof(XWindowAttributes));
    if(attribs == NULL) {
        fprintf(stderr, "Unable to allocate space for XWindowAttributes");
        return FALSE;
    }
    XSetErrorHandler(_invalid_window_error_handler);
    int status = XGetWindowAttributes(defaults->display, win, attribs);
    XSetErrorHandler(NULL);
    BOOL ret;
    if (status) {
        int winx = window_x(win);
        int winy = window_y(win);
        *x = winx + *x;
        *y = winy + *y;
        logit(LOG_LEVEL_VERBOSE, "Window at %d X %d\n", winx, winy);
        logit(LOG_LEVEL_VERBOSE, "Relative location %d X %d\n", *x, *y);
        ret = TRUE;
    } else {
        fprintf(stderr, "Window handle %lu appears to be invalid\n", win);
        fprintf(stderr, "Not moving the mouse\n");
        *x = mouse_x(0);
        *y = mouse_y(0);
        ret = FALSE;
    }
    free(attribs);
    //In case the window is partially off the screen
    _normalize_coords(x, y);
    return ret;
}
示例#3
0
文件: window.c 项目: isbadawi/badavi
size_t window_y(struct window *window) {
  if (!window->parent) {
    return 0;
  }

  switch (window->parent->split_type) {
  case WINDOW_SPLIT_VERTICAL:
    return window_y(window->parent);
  case WINDOW_SPLIT_HORIZONTAL:
    if (window == window->parent->split.first) {
      return window_y(window->parent);
    }
    return window_y(window->parent) + window_h(window_sibling(window));
  case WINDOW_LEAF:
    assert(0);
  }

  return 0;
}
示例#4
0
文件: main.c 项目: rofl0r/libxauto
void TEST_move_window() {
    char *routine = "TEST_move_window";
    printf(testing, routine);
    //First with a valid window
    Window win = active_window();
    int before_x = window_x(win);
    int before_y = window_y(win);
    assert(move_window(win, before_x + 10, before_y + 10, -1));
    int after_x = window_x(win);
    int after_y = window_y(win);

    //"Snap to grid" makes this a bit hard to test.
    //What if the grid isn't "10"?  If it's e.g. 12,
    //then we'll be off by 2 pixels.
    assert(before_x != after_x);
    assert(before_y != after_y);
    move_window(win, before_x, before_y, -1);
    activate_window(win);

    //Now with an invalid window
    assert(move_window(20, 0, 0, -1) == FALSE);
    printf(done, routine);
}