summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2002-09-01 09:51:54 +0000
committerDana Jansens <danakj@orodu.net>2002-09-01 09:51:54 +0000
commite93ce605685968ca9c48ca2141dd458f9457a6db (patch)
treef941413e346ba94d5056f7a83a11fcd05fba8923 /src
parent923c381dc177aa64b1da847ae6a27bff19ec817c (diff)
sync with the 2.0 branch (make XAtom::getValue not use an XGrabServer)
Diffstat (limited to 'src')
-rw-r--r--src/XAtom.cc21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/XAtom.cc b/src/XAtom.cc
index f751743b..bfd58483 100644
--- a/src/XAtom.cc
+++ b/src/XAtom.cc
@@ -364,15 +364,9 @@ bool XAtom::getValue(Window win, Atom atom, Atom type,
int ret_size;
unsigned long ret_bytes;
int result;
- const unsigned long maxread = nelements;
+ unsigned long maxread = nelements;
bool ret = False;
- /*
- Grab the server because this takes 2 reads and if it changes between, it
- totally screws everything up.
- */
- XGrabServer(_display);
-
// try get the first element
result = XGetWindowProperty(_display, win, atom, 0l, 1l, False,
AnyPropertyType, &ret_type, &ret_size,
@@ -395,13 +389,20 @@ bool XAtom::getValue(Window win, Atom atom, Atom type,
result = XGetWindowProperty(_display, win, atom, 0l, remain, False, type,
&ret_type, &ret_size, &nelements, &ret_bytes,
&c_val);
- assert(result == Success);
- assert(ret_bytes == 0);
+ ret = (result == Success && ret_type == type && ret_size == size &&
+ ret_bytes == 0);
+ /*
+ If the property has changed type/size, or has grown since our first
+ read of it, then stop here and try again. If it shrank, then this will
+ still work.
+ */
+ if (! ret)
+ return getValue(win, atom, type, maxread, value, size);
+
*value = new unsigned char[nelements * size/8 + 1];
memcpy(*value, c_val, nelements * size/8 + 1);
}
}
- XUngrabServer(_display);
if (c_val) XFree(c_val);
return ret;
}