Beispiel #1
0
void remove_client(Client *c) {
  Client *p;

  LOG_DEBUG("remove_client() : Removing...\n");

  if (!c || !c->xstuff) return;

  XGrabServer(dpy);
  ignore_xerror = 1;

  /* ICCCM 4.1.3.1
   * "When the window is withdrawn, the window manager will either
   *  change the state field's value to WithdrawnState or it will
   *  remove the WM_STATE property entirely."
   * EWMH 1.3
   * "The Window Manager should remove the property whenever a
   *  window is withdrawn but it should leave the property in
   *  place when it is shutting down." (both _NET_WM_DESKTOP and
   *  _NET_WM_STATE) */

  if (c->remove) {
    LOG_DEBUG("\tremove_client() : setting WithdrawnState\n");
    set_wm_state(c, WithdrawnState);
    XDeleteProperty(dpy, c->xstuff->window, xa_net_wm_desktop);
    XDeleteProperty(dpy, c->xstuff->window, xa_net_wm_state);
  }

  ungravitate(c);
  if (c->xstuff->screen)
      XReparentWindow(dpy, c->xstuff->window, c->xstuff->screen->root, c->x, c->y);
  XSetWindowBorderWidth(dpy, c->xstuff->window, c->old_border);
  XRemoveFromSaveSet(dpy, c->xstuff->window);
  if (c->xstuff->parent)
    XDestroyWindow(dpy, c->xstuff->parent);

  if (head_client == c) head_client = c->next;
  else for (p = head_client; p && p->next; p = p->next)
    if (p->next == c) p->next = c->next;

  if (current == c)
    current = NULL;  /* an enter event should set this up again */

  free(c->xstuff);
  free(c);
#ifdef DEBUG
  {
    Client *pp;
    int i = 0;
    for (pp = head_client; pp; pp = pp->next)
      i++;
    LOG_DEBUG("\tremove_client() : free(), window count now %d\n", i);
  }
#endif

  XUngrabServer(dpy);
  XFlush(dpy);
  ignore_xerror = 0;
  LOG_DEBUG("remove_client() returning\n");
}
Beispiel #2
0
void remove_client(Client *c, int from_cleanup)
{
	Client *p = NULL;

	XGrabServer(dpy);
	XSetErrorHandler(ignore_xerror);

	if (c->name && c->name != null_str)
		XFree(c->name);

	if (from_cleanup)
		unhide(c, NO_RAISE);
	else if (!from_cleanup)
		set_wm_state(c, WithdrawnState);

	ungravitate(c);
	XReparentWindow(dpy, c->window, root, c->x, c->y);
	XRemoveFromSaveSet(dpy, c->window);
	XSetWindowBorderWidth(dpy, c->window, 1);

	XDestroyWindow(dpy, c->parent);

	if (head_client == c)
		head_client = c->next;
	else {
		for (p = head_client; p && p->next; p = p->next)
			if (p->next == c) p->next = c->next;
	}

	if (c->size)
		XFree(c->size);

	/* an enter event should set this up again */
	if (c == current) {
		current = NULL;
		if (prev_focused[c->vdesk] == c)
			prev_focused[c->vdesk] = NULL;
	}

	free(c);

	XSync(dpy, False);
	XSetErrorHandler(handle_xerror);
	XUngrabServer(dpy);
}