summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Waddell <jwaddell@nvidia.com>2017-04-03 16:36:06 -0700
committerAaron Plattner <aplattner@nvidia.com>2017-06-05 15:29:51 -0700
commit3a2b35de1b91efab60d10152800508fcbaee13c3 (patch)
tree5c1898b732a1f9241a0e36bc0001fa3e99d87f90
parentc0f088abbb8f0ca91abf867466434ac2fc5e472f (diff)
Update the configuration with the Bus ID when merging with an existing config file.
When nvidia-settings merges a new configuration file with the old one, we currently drop the Bus ID due to how the xconfig parser generates and merges the files. This change copies the Bus ID string if it exists from the old to the new file.
-rw-r--r--src/gtk+-2.x/ctkdisplayconfig.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/gtk+-2.x/ctkdisplayconfig.c b/src/gtk+-2.x/ctkdisplayconfig.c
index d17d441..16b722e 100644
--- a/src/gtk+-2.x/ctkdisplayconfig.c
+++ b/src/gtk+-2.x/ctkdisplayconfig.c
@@ -9155,6 +9155,36 @@ static int generateXConfig(CtkDisplayConfig *ctk_object, XConfigPtr *pConfig)
+/** preserve_busid() **************************************************
+ *
+ * Copies the BusID value from the source to the destination
+ * configuration for devices with matching identifiers.
+ *
+ **/
+
+static void preserve_busid(XConfigPtr dstConfig, XConfigPtr srcConfig)
+{
+ XConfigDevicePtr dstDevice, srcDevice;
+
+ for (srcDevice = srcConfig->devices;
+ srcDevice;
+ srcDevice = srcDevice->next) {
+
+ if (!srcDevice->busid) {
+ continue;
+ }
+
+ dstDevice =
+ xconfigFindDevice(srcDevice->identifier, dstConfig->devices);
+
+ if (dstDevice) {
+ dstDevice->busid = xconfigStrdup(srcDevice->busid);
+ }
+ }
+}
+
+
+
/** xconfig_generate() ***********************************************
*
* Callback to generate an X config structure based on the current
@@ -9184,6 +9214,11 @@ static XConfigPtr xconfig_generate(XConfigPtr xconfCur,
return xconfGen;
}
+ /* The Bus ID of devices may not be set by generateXConfig above so to
+ * preserve this field, we have to copy the Bus IDs over before merging.
+ */
+ preserve_busid(xconfGen, xconfCur);
+
/* Merge xconfGen into xconfCur */
result = xconfigMergeConfigs(xconfCur, xconfGen);
if (!result) {