X-Git-Url: https://git.distorted.org.uk/~mdw/xtoys/blobdiff_plain/fa64e43069529b159016b7e5f8cd8f09a11ba12d..f6795c17f9899da2759a2f5782e17b2ee5a0dbb9:/xatom.c diff --git a/xatom.c b/xatom.c deleted file mode 100644 index b5cdaa9..0000000 --- a/xatom.c +++ /dev/null @@ -1,105 +0,0 @@ -/* -*-c-*- - * - * $Id: xatom.c,v 1.2 2004/04/08 01:36:29 mdw Exp $ - * - * Set and fetch X atom properties - * - * (c) 1999 Straylight/Edgeware - */ - -/*----- Licensing notice --------------------------------------------------* - * - * This file is part of the Edgeware X tools collection. - * - * X tools is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * X tools is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with X tools; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/*----- Header files ------------------------------------------------------*/ - -#include -#include -#include - -#include -#include -#include - -/*----- Main code ---------------------------------------------------------*/ - -/* --- @xatom_set@ --- * - * - * Arguments: @Display *d@ = pointer to display - * @Window w@ = window to set - * @Atom p@ = property to set - * @Atom a@ = atom property value - * - * Returns: --- - * - * Use: Sets an atom property on a particular window. - */ - -void xatom_set(Display *d, Window w, Atom p, Atom a) -{ - XChangeProperty(d, w, p, XA_ATOM, 32, PropModeReplace, - (unsigned char *)&a, 1); -} - -/* --- @xatom_get@ --- * - * - * Arguments: @Display *d@ = pointer to display - * @Window w@ = window to set - * @Atom p@ = property to read - * - * Returns: Atom which is the value of the property. - * - * Use: Reads an atom property from a particular window. The value - * @None@ is returned if there is no atom value. - */ - -Atom xatom_get(Display *d, Window w, Atom p) -{ - Atom type, v; - unsigned long n, left; - int fmt; - unsigned char *buf; - - /* --- Fetch the property value --- */ - - if (XGetWindowProperty(d, w, p, /* Display, window, property */ - 0, 64, /* Offset, length (both in words) */ - False, /* Delete after return? */ - XA_ATOM, /* Data format type */ - &type, &fmt, /* Actual type and format */ - &n, &left, /* Amount read, and bytes left */ - &buf) /* Where to put the buffer */ - != Success || - type != XA_ATOM || - n < 1 || fmt < 32) - return (None); - - /* --- OK, get the atom and return --- * - * - * This assumes that atoms are 32-bit things. This may not be the case. - * That's a right pain, actually. It looks as if Xlib is trying to do the - * right thing, so I'll go with that rather than trying to do anything - * clever. This is actually a bit of a poor interface. - */ - - v = *(Atom *)buf; - XFree(buf); - return (v); -} - -/*----- That's all, folks -------------------------------------------------*/