⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdkasync.c

📁 linux下电话本所依赖的一些图形库
💻 C
📖 第 1 页 / 共 2 页
字号:
  ListChildrenState *state = (ListChildrenState *)data;  if (dpy->last_request_read != state->get_property_req)    return False;    if (rep->generic.type == X_Error)    {      state->have_error = TRUE;      return False;    }  else    {      xGetPropertyReply replbuf;      xGetPropertyReply *repl;	          repl = (xGetPropertyReply *)	_XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,			(sizeof(xGetPropertyReply) - sizeof(xReply)) >> 2,			True);      state->has_wm_state = repl->propertyType != None;      /* Since we called GetProperty with longLength of 0, we don't       * have to worry about consuming the property data that would       * normally follow after the reply       */      return True;    }}static gbooleanlist_children_and_wm_state (Display      *dpy,			    Window        w,			    Atom          wm_state_atom,			    gboolean     *has_wm_state,			    Window      **children,			    unsigned int *nchildren){  ListChildrenState state;  _XAsyncHandler async;  long nbytes;  xQueryTreeReply rep;  register xResourceReq *req;  xGetPropertyReq *prop_req;  LockDisplay(dpy);  *children = NULL;  *nchildren = 0;  *has_wm_state = FALSE;    state.have_error = FALSE;  state.has_wm_state = FALSE;  if (wm_state_atom)    {      async.next = dpy->async_handlers;      async.handler = list_children_handler;      async.data = (XPointer) &state;      dpy->async_handlers = &async;      GetReq (GetProperty, prop_req);      prop_req->window = w;      prop_req->property = wm_state_atom;      prop_req->type = AnyPropertyType;      prop_req->delete = False;      prop_req->longOffset = 0;      prop_req->longLength = 0;            state.get_property_req = dpy->request;    }    GetResReq(QueryTree, w, req);  if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))    {      state.have_error = TRUE;      goto out;    }  if (rep.nChildren != 0)    {      nbytes = rep.nChildren << 2;      if (state.have_error)	{	  _XEatData(dpy, (unsigned long) nbytes);	  goto out;	}      *children = g_new (Window, rep.nChildren);      _XRead32 (dpy, (long *) *children, nbytes);    }  *nchildren = rep.nChildren;  *has_wm_state = state.has_wm_state; out:  if (wm_state_atom)    DeqAsyncHandler(dpy, &async);  UnlockDisplay(dpy);  SyncHandle();    return !state.have_error;}static voidhandle_get_wa_reply (Display                   *dpy,		     ChildInfoState            *state,		     xGetWindowAttributesReply *repl){  GdkChildInfoX11 *child = &state->child_info[state->n_children_found];  child->is_mapped = repl->mapState != IsUnmapped;  child->window_class = repl->class;}static voidhandle_get_geometry_reply (Display           *dpy,			   ChildInfoState    *state,			   xGetGeometryReply *repl){  GdkChildInfoX11 *child = &state->child_info[state->n_children_found];    child->x = cvtINT16toInt (repl->x);  child->y = cvtINT16toInt (repl->y);  child->width = repl->width;  child->height = repl->height;}static voidhandle_get_property_reply (Display           *dpy,			   ChildInfoState    *state,			   xGetPropertyReply *repl){  GdkChildInfoX11 *child = &state->child_info[state->n_children_found];  child->has_wm_state = repl->propertyType != None;  /* Since we called GetProperty with longLength of 0, we don't   * have to worry about consuming the property data that would   * normally follow after the reply   */}static voidnext_child (ChildInfoState *state){  if (state->current_request == CHILD_INFO_GET_GEOMETRY)    {      if (!state->have_error && !state->child_has_error)	{	  state->child_info[state->n_children_found].window = state->children[state->current_child];	  state->n_children_found++;	}      state->current_child++;      if (state->get_wm_state)	state->current_request = CHILD_INFO_GET_PROPERTY;      else	state->current_request = CHILD_INFO_GET_WA;      state->child_has_error = FALSE;      state->have_error = FALSE;    }  else    state->current_request++;}static Boolget_child_info_handler (Display *dpy,			xReply  *rep,			char    *buf,			int      len,			XPointer data){  Bool result = True;    ChildInfoState *state = (ChildInfoState *)data;  if (dpy->last_request_read != state->child_states[state->current_child].seq[state->current_request])    return False;    if (rep->generic.type == X_Error)    {      state->child_has_error = TRUE;      if (rep->error.errorCode != BadDrawable ||	  rep->error.errorCode != BadWindow)	{	  state->have_error = TRUE;	  result = False;	}    }  else    {      switch (state->current_request)	{	case CHILD_INFO_GET_PROPERTY:	  {	    xGetPropertyReply replbuf;	    xGetPropertyReply *repl;	    	    repl = (xGetPropertyReply *)	      _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,			      (sizeof(xGetPropertyReply) - sizeof(xReply)) >> 2,			      True);	    	    handle_get_property_reply (dpy, state, repl);	  }	  break;	case CHILD_INFO_GET_WA:	  {	    xGetWindowAttributesReply replbuf;	    xGetWindowAttributesReply *repl;	    	    repl = (xGetWindowAttributesReply *)	      _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,			      (sizeof(xGetWindowAttributesReply) - sizeof(xReply)) >> 2,			      True);	    	    handle_get_wa_reply (dpy, state, repl);	  }	  break;	case CHILD_INFO_GET_GEOMETRY:	  {	    xGetGeometryReply replbuf;	    xGetGeometryReply *repl;	    	    repl = (xGetGeometryReply *)	      _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,			      (sizeof(xGetGeometryReply) - sizeof(xReply)) >> 2,			      True);	    	    handle_get_geometry_reply (dpy, state, repl);	  }	  break;	}    }  next_child (state);  return result;}gboolean_gdk_x11_get_window_child_info (GdkDisplay       *display,				Window            window,				gboolean          get_wm_state,				gboolean         *win_has_wm_state,				GdkChildInfoX11 **children,				guint            *nchildren){  Display *dpy;  _XAsyncHandler async;  ChildInfoState state;  Atom wm_state_atom;  gboolean has_wm_state;  Bool result;  guint i;  *children = NULL;  *nchildren = 0;    dpy = GDK_DISPLAY_XDISPLAY (display);  if (get_wm_state)    wm_state_atom = gdk_x11_get_xatom_by_name_for_display (display, "WM_STATE");  else    wm_state_atom = None;  gdk_error_trap_push ();  result = list_children_and_wm_state (dpy, window,				       win_has_wm_state ? wm_state_atom : None,				       &has_wm_state,				       &state.children, &state.nchildren);  gdk_error_trap_pop ();  if (!result)    return FALSE;  if (has_wm_state)    {      if (win_has_wm_state)	*win_has_wm_state = TRUE;      return TRUE;    }  else    {      if (win_has_wm_state)	*win_has_wm_state = FALSE;    }  state.get_wm_state = get_wm_state;  state.child_info = g_new (GdkChildInfoX11, state.nchildren);  state.child_states = g_new (ChildInfoChildState, state.nchildren);  state.current_child = 0;  state.n_children_found = 0;  if (get_wm_state)    state.current_request = CHILD_INFO_GET_PROPERTY;  else    state.current_request = CHILD_INFO_GET_WA;  state.have_error = FALSE;  state.child_has_error = FALSE;  LockDisplay(dpy);  async.next = dpy->async_handlers;  async.handler = get_child_info_handler;  async.data = (XPointer) &state;  dpy->async_handlers = &async;    for (i = 0; i < state.nchildren; i++)    {      xResourceReq *resource_req;      xGetPropertyReq *prop_req;      Window window = state.children[i];            if (get_wm_state)	{	  GetReq (GetProperty, prop_req);	  prop_req->window = window;	  prop_req->property = wm_state_atom;	  prop_req->type = AnyPropertyType;	  prop_req->delete = False;	  prop_req->longOffset = 0;	  prop_req->longLength = 0;	  state.child_states[i].seq[CHILD_INFO_GET_PROPERTY] = dpy->request;	}            GetResReq(GetWindowAttributes, window, resource_req);      state.child_states[i].seq[CHILD_INFO_GET_WA] = dpy->request;            GetResReq(GetGeometry, window, resource_req);      state.child_states[i].seq[CHILD_INFO_GET_GEOMETRY] = dpy->request;    }  if (i != 0)    {      /* Wait for the last reply       */      xGetGeometryReply rep;      /* On error, our async handler will get called       */      if (_XReply (dpy, (xReply *)&rep, 0, xTrue))	handle_get_geometry_reply (dpy, &state, &rep);      next_child (&state);    }  if (!state.have_error)    {      *children = state.child_info;      *nchildren = state.n_children_found;    }  else    {      g_free (state.child_info);    }  g_free (state.children);  g_free (state.child_states);    DeqAsyncHandler(dpy, &async);  UnlockDisplay(dpy);  SyncHandle();  return !state.have_error;}#define __GDK_ASYNC_C__#include "gdkaliasdef.c"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -