diff options
author | Keith Packard <keithp@neko.keithp.com> | 2007-03-23 23:41:36 -0700 |
---|---|---|
committer | Keith Packard <keithp@neko.keithp.com> | 2007-03-24 00:01:47 -0700 |
commit | 804080a7096347d48c686f2c8fbfd06326bce400 (patch) | |
tree | cb229530ce3043cfd3da2a34e40981abe006e6fb /randr/rrproperty.c | |
parent | 1f77120775dc05fc84a00dd55190af2fa50ae509 (diff) |
Make pending properties force mode set. And, remove AttachScreen calls.
Yes, two changes in one commit. Sorry 'bout that.
The first change ensures that when pending property values have been
changed, a mode set to the current mode will actually do something, rather
than being identified as a no-op. In addition, the driver no longer needs to
manage the migration of pending to current values, that is handled both
within the xf86 mode setting code (to deal with non-RandR changes) as well
as within the RandR extension itself.
The second change eliminates the two-call Create/AttachScreen stuff that was
done in a failed attempt to create RandR resources before the screen
structures were allocated. Merging these back into the Create function is
cleaner.
(cherry picked from commit 57e87e0d006cbf1f5b175fe02eeb981f741d92f0)
Conflicts:
randr/randrstr.h
randr/rrcrtc.c
I think master and server-1.3-branch are more in sync now.
Diffstat (limited to 'randr/rrproperty.c')
-rw-r--r-- | randr/rrproperty.c | 89 |
1 files changed, 54 insertions, 35 deletions
diff --git a/randr/rrproperty.c b/randr/rrproperty.c index 148e4a27d..5ac073f81 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -27,7 +27,7 @@ static void RRDeliverEvent (ScreenPtr pScreen, xEvent *event, CARD32 mask) { - + } void @@ -50,7 +50,7 @@ RRDeleteAllOutputProperties (RROutputPtr output) xfree(prop->current.data); if (prop->pending.data) xfree(prop->pending.data); - xfree(prop); + xfree(prop); } } @@ -67,7 +67,7 @@ static RRPropertyPtr RRCreateOutputProperty (Atom property) { RRPropertyPtr prop; - + prop = (RRPropertyPtr)xalloc(sizeof(RRPropertyRec)); if (!prop) return NULL; @@ -139,7 +139,7 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, prop = RRQueryOutputProperty (output, property); if (!prop) /* just add to list */ { - prop = RRCreateOutputProperty (property); + prop = RRCreateOutputProperty (property); if (!prop) return(BadAlloc); add = TRUE; @@ -149,11 +149,11 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, prop_value = &prop->pending; else prop_value = &prop->current; - + /* To append or prepend to a property the request format and type - must match those of the already defined property. The - existing format and type are irrelevant when using the mode - "PropModeReplace" since they will be written over. */ + must match those of the already defined property. The + existing format and type are irrelevant when using the mode + "PropModeReplace" since they will be written over. */ if ((format != prop_value->format) && (mode != PropModeReplace)) return(BadMatch); @@ -167,8 +167,8 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, if (mode == PropModeReplace || len > 0) { - pointer new_data, old_data; - + pointer new_data = NULL, old_data = NULL; + total_size = total_len * size_in_bytes; new_value.data = (pointer)xalloc (total_size); if (!new_value.data && total_size) @@ -197,11 +197,12 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, (prop_value->size * size_in_bytes)); break; } - memcpy ((char *) new_data, (char *) value, len * size_in_bytes); + if (new_data) + memcpy ((char *) new_data, (char *) value, len * size_in_bytes); if (old_data) memcpy ((char *) old_data, (char *) prop_value->data, prop_value->size * size_in_bytes); - + if (pending && pScrPriv->rrOutputSetProperty && !pScrPriv->rrOutputSetProperty(output->pScreen, output, prop->propertyName, &new_value)) @@ -214,18 +215,21 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, xfree (prop_value->data); *prop_value = new_value; } - + else if (len == 0) { /* do nothing */ } - + if (add) { prop->next = output->properties; output->properties = prop; } + if (pending && prop->is_pending) + output->pendingProperties = TRUE; + if (sendevent) { event.type = RREventBase + RRNotify; @@ -240,30 +244,45 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, } Bool -RRPostPendingProperty (RROutputPtr output, Atom property) +RRPostPendingProperties (RROutputPtr output) { - RRPropertyPtr prop = RRQueryOutputProperty (output, property); - RRPropertyValuePtr pending_value; - RRPropertyValuePtr current_value; - - if (!prop) - return FALSE; - if (!prop->is_pending) - return FALSE; - pending_value = &prop->pending; - current_value = &prop->current; - - if (pending_value->type == current_value->type && - pending_value->format == current_value->format && - pending_value->size == current_value->size && - !memcmp (pending_value->data, current_value->data, pending_value->size)) + RRPropertyValuePtr pending_value; + RRPropertyValuePtr current_value; + RRPropertyPtr property; + Bool ret = TRUE; + + if (!output->pendingProperties) return TRUE; - if (RRChangeOutputProperty (output, property, - pending_value->type, pending_value->format, PropModeReplace, - pending_value->size, pending_value->data, TRUE, FALSE) != Success) - return FALSE; - return TRUE; + output->pendingProperties = FALSE; + for (property = output->properties; property; property = property->next) + { + /* Skip non-pending properties */ + if (!property->is_pending) + continue; + + pending_value = &property->pending; + current_value = &property->current; + + /* + * If the pending and current values are equal, don't mark it + * as changed (which would deliver an event) + */ + if (pending_value->type == current_value->type && + pending_value->format == current_value->format && + pending_value->size == current_value->size && + !memcmp (pending_value->data, current_value->data, + pending_value->size)) + continue; + + if (RRChangeOutputProperty (output, property->propertyName, + pending_value->type, pending_value->format, + PropModeReplace, pending_value->size, + pending_value->data, TRUE, + FALSE) != Success) + ret = FALSE; + } + return ret; } RRPropertyPtr |