Logo Search packages:      
Sourcecode: xdotool version File versions  Download package

int xdo_window_search ( const xdo_t xdo,
const xdo_search_t search,
Window **  windowlist_ret,
int *  nwindows_ret 
)

Search for windows.

Parameters:
search the search query.
windowlist_ret the list of matching windows to return
nwindows_ret the number of windows (length of windowlist_ret)
See also:
xdo_search_t

Definition at line 29 of file xdo_search.c.

References xdo_search::max_depth, xdo_search::screen, SEARCH_SCREEN, xdo_search::searchmask, xdo_window_search(), and xdo::xdpy.

Referenced by xdo_window_search().

                                                                  {
  Window *candidate_window_list = NULL;
  int ncandidate_windows = 0;
  int candidate_window_list_size = 0;
  int matched_window_list_size = 100;
  int i = 0;

  *nwindows_ret = 0;
  *windowlist_ret = calloc(sizeof(Window), matched_window_list_size);

  /* TODO(sissel): Support multiple screens */
  if (search->searchmask & SEARCH_SCREEN) {
    _xdo_get_child_windows(xdo, RootWindow(xdo->xdpy, search->screen), search->max_depth,
                           &candidate_window_list, &ncandidate_windows,
                           &candidate_window_list_size);
  } else {
    const int screencount = ScreenCount(xdo->xdpy);
    for (i = 0; i < screencount; i++) {
      _xdo_get_child_windows(xdo, RootWindow(xdo->xdpy, i), search->max_depth,
                             &candidate_window_list, &ncandidate_windows,
                             &candidate_window_list_size);
    }
  }
  //printf("Window count: %d\n", (int)ncandidate_windows);
  //printf("Search:\n");
  //printf("onlyvisible: %d\n", search->only_visible);
  //printf("pid: %lu\n", search->pid);
  //printf("title: %s\n", search->title);
  //printf("name: %s\n", search->winname);
  //printf("class: %s\n", search->winclass);
  //printf("classname: %s\n", search->winclassname);
  //printf("//Search\n");

  for (i = 0; i < ncandidate_windows; i++) {
    Window wid = candidate_window_list[i];
    if (!check_window_match(xdo, wid, search))
      continue;

    (*windowlist_ret)[*nwindows_ret] = wid;
    (*nwindows_ret)++;

    if (matched_window_list_size == *nwindows_ret) {
      matched_window_list_size *= 2;
      *windowlist_ret = realloc(*windowlist_ret, 
                                matched_window_list_size * sizeof(Window));
    }
  }
  free(candidate_window_list);

  return XDO_SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index