static gboolean
wm_hints_from_results (GetPropertyResults *results,
                       XWMHints          **hints_p)
{
  XWMHints *hints;
  xPropWMHints *raw;
  
  *hints_p = NULL;
  
  if (!validate_or_free_results (results, 32, XA_WM_HINTS, TRUE))
    return FALSE;  

  /* pre-R3 bogusly truncated window_group, don't fail on them */  
  if (results->n_items < (NumPropWMHintsElements - 1))
    {
      meta_verbose ("WM_HINTS property too short: %d should be %d\n",
                    (int) results->n_items, NumPropWMHintsElements - 1);
      if (results->prop)
        {
          XFree (results->prop);
          results->prop = NULL;
        }
      return FALSE;
    }
  
  hints = ag_Xmalloc0 (sizeof (XWMHints));

  raw = (xPropWMHints*) results->prop;
  
  hints->flags = raw->flags;
  hints->input = (raw->input ? True : False);
  hints->initial_state = cvtINT32toInt (raw->initialState);
  hints->icon_pixmap = raw->iconPixmap;
  hints->icon_window = raw->iconWindow;
  hints->icon_x = cvtINT32toInt (raw->iconX);
  hints->icon_y = cvtINT32toInt (raw->iconY);
  hints->icon_mask = raw->iconMask;
  if (results->n_items >= NumPropWMHintsElements)
    hints->window_group = raw->windowGroup;
  else
    hints->window_group = 0;

  if (results->prop)
    {
      XFree (results->prop);
      results->prop = NULL;
    }

  *hints_p = hints;

  return TRUE;
}
Exemple #2
0
int
XDrawImageString(
    register Display *dpy,
    Drawable d,
    GC gc,
    int x,
    int y,
    _Xconst char *string,
    int length)
{   
    register xImageText8Req *req;
    char *CharacterOffset = (char *)string;
    int FirstTimeThrough = True;
    int lastX = 0;

    LockDisplay(dpy);
    FlushGC(dpy, gc);

    while (length > 0) 
    {
	int Unit;

	if (length > 255) Unit = 255;
	else Unit = length;

   	if (FirstTimeThrough)
	{
	    FirstTimeThrough = False;
        }
	else
	{
	    char buf[512];
	    char *ptr, *str;
	    xQueryTextExtentsReq *qreq;
	    xQueryTextExtentsReply rep;
	    int i;

	    GetReq(QueryTextExtents, qreq);
	    qreq->fid = gc->gid;
	    qreq->length += (510 + 3)>>2;
	    qreq->oddLength = 1;
	    str = CharacterOffset - 255;
	    for (ptr = buf, i = 255; --i >= 0; ) {
		*ptr++ = 0;
		*ptr++ = *str++;
	    }
	    Data (dpy, buf, 510);
	    if (!_XReply (dpy, (xReply *)&rep, 0, xTrue))
		break;

	    x = lastX + cvtINT32toInt (rep.overallWidth);
	}

        GetReq (ImageText8, req);
        req->length += (Unit + 3) >> 2;
        req->nChars = Unit;
        req->drawable = d;
        req->gc = gc->gid;
        req->y = y;

	lastX = req->x = x;
        Data (dpy, CharacterOffset, (long)Unit);
        CharacterOffset += Unit;
	length -= Unit;
    }
    UnlockDisplay(dpy);
    SyncHandle();
    return 0;
}
static gboolean
size_hints_from_results (GetPropertyResults *results,
                         XSizeHints        **hints_p,
                         gulong             *flags_p)
{
  xPropSizeHints *raw;
  XSizeHints *hints;
  
  *hints_p = NULL;
  *flags_p = 0;
  
  if (!validate_or_free_results (results, 32, XA_WM_SIZE_HINTS, FALSE))
    return FALSE;

  if (results->n_items < OldNumPropSizeElements)
    return FALSE;

  raw = (xPropSizeHints*) results->prop;

  hints = ag_Xmalloc (sizeof (XSizeHints));
  
  /* XSizeHints misdeclares these as int instead of long */
  hints->flags = raw->flags;
  hints->x = cvtINT32toInt (raw->x);
  hints->y = cvtINT32toInt (raw->y);
  hints->width = cvtINT32toInt (raw->width);
  hints->height = cvtINT32toInt (raw->height);
  hints->min_width  = cvtINT32toInt (raw->minWidth);
  hints->min_height = cvtINT32toInt (raw->minHeight);
  hints->max_width  = cvtINT32toInt (raw->maxWidth);
  hints->max_height = cvtINT32toInt (raw->maxHeight);
  hints->width_inc  = cvtINT32toInt (raw->widthInc);
  hints->height_inc = cvtINT32toInt (raw->heightInc);
  hints->min_aspect.x = cvtINT32toInt (raw->minAspectX);
  hints->min_aspect.y = cvtINT32toInt (raw->minAspectY);
  hints->max_aspect.x = cvtINT32toInt (raw->maxAspectX);
  hints->max_aspect.y = cvtINT32toInt (raw->maxAspectY);

  *flags_p = (USPosition | USSize | PAllHints);
  if (results->n_items >= NumPropSizeElements)
    {
      hints->base_width= cvtINT32toInt (raw->baseWidth);
      hints->base_height= cvtINT32toInt (raw->baseHeight);
      hints->win_gravity= cvtINT32toInt (raw->winGravity);
      *flags_p |= (PBaseSize | PWinGravity);
    }

  hints->flags &= (*flags_p);	/* get rid of unwanted bits */
  
  XFree (results->prop);
  results->prop = NULL;

  *hints_p = hints;
  
  return TRUE;
}
Exemple #4
0
Status XGetWMSizeHints (
    Display *dpy,
    Window w,
    XSizeHints *hints,
    long *supplied,
    Atom property)
{
    xPropSizeHints *prop = NULL;
    Atom actual_type;
    int actual_format;
    unsigned long leftover;
    unsigned long nitems;

    if (XGetWindowProperty (dpy, w, property, 0L,
			    (long)NumPropSizeElements,
			    False, XA_WM_SIZE_HINTS, &actual_type,
			    &actual_format, &nitems, &leftover,
			    (unsigned char **)&prop)
	!= Success)
      return False;

    if ((actual_type != XA_WM_SIZE_HINTS) ||
	(nitems < OldNumPropSizeElements) || (actual_format != 32)) {
	if (prop != NULL) Xfree ((char *)prop);
	return False;
    }

    hints->flags	  = prop->flags;
    /* XSizeHints misdeclares these as int instead of long */
    hints->x = cvtINT32toInt (prop->x);
    hints->y = cvtINT32toInt (prop->y);
    hints->width = cvtINT32toInt (prop->width);
    hints->height = cvtINT32toInt (prop->height);
    hints->min_width  = cvtINT32toInt (prop->minWidth);
    hints->min_height = cvtINT32toInt (prop->minHeight);
    hints->max_width  = cvtINT32toInt (prop->maxWidth);
    hints->max_height = cvtINT32toInt (prop->maxHeight);
    hints->width_inc  = cvtINT32toInt (prop->widthInc);
    hints->height_inc = cvtINT32toInt (prop->heightInc);
    hints->min_aspect.x = cvtINT32toInt (prop->minAspectX);
    hints->min_aspect.y = cvtINT32toInt (prop->minAspectY);
    hints->max_aspect.x = cvtINT32toInt (prop->maxAspectX);
    hints->max_aspect.y = cvtINT32toInt (prop->maxAspectY);

    *supplied = (USPosition | USSize | PAllHints);
    if (nitems >= NumPropSizeElements) {
	hints->base_width= cvtINT32toInt (prop->baseWidth);
	hints->base_height= cvtINT32toInt (prop->baseHeight);
	hints->win_gravity= cvtINT32toInt (prop->winGravity);
	*supplied |= (PBaseSize | PWinGravity);
    }
    hints->flags &= (*supplied);	/* get rid of unwanted bits */
    Xfree((char *)prop);
    return True;
}