[PATCH 1/3] randr: send RRProviderChangeNotify event

Michal Srb msrb at suse.com
Mon Oct 7 03:26:31 PDT 2013


Send RRProviderChangeNotify event when a provider becomes output source or
offload sink.
---
 randr/randr.c      | 36 ++++++++++++++++++++++++++++++++++++
 randr/randrstr.h   |  4 ++++
 randr/rrprovider.c | 25 +++++++++++++++++++++++++
 3 files changed, 65 insertions(+)
 mode change 100644 => 100755 randr/randr.c
 mode change 100644 => 100755 randr/randrstr.h
 mode change 100644 => 100755 randr/rrprovider.c

diff --git a/randr/randr.c b/randr/randr.c
old mode 100644
new mode 100755
index cb6fce7..fa0a4da
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -426,6 +426,8 @@ TellChanged(WindowPtr pWin, pointer value)
     RREventPtr *pHead, pRREvent;
     ClientPtr client;
     ScreenPtr pScreen = pWin->drawable.pScreen;
+    ScreenPtr iter;
+    rrScrPrivPtr pSlaveScrPriv;
 
     rrScrPriv(pScreen);
     int i;
@@ -460,6 +462,24 @@ TellChanged(WindowPtr pWin, pointer value)
                     RRDeliverOutputEvent(client, pWin, output);
             }
         }
+
+        if (pRREvent->mask & RRProviderChangeNotifyMask) {
+            xorg_list_for_each_entry(iter, &pScreen->output_slave_list, output_head) {
+                pSlaveScrPriv = rrGetScrPriv(iter);
+                if (pSlaveScrPriv->provider->changed)
+                    RRDeliverProviderEvent(client, pWin, pSlaveScrPriv->provider);
+            }
+            xorg_list_for_each_entry(iter, &pScreen->offload_slave_list, offload_head) {
+                pSlaveScrPriv = rrGetScrPriv(iter);
+                if (pSlaveScrPriv->provider->changed)
+                    RRDeliverProviderEvent(client, pWin, pSlaveScrPriv->provider);
+            }
+            xorg_list_for_each_entry(iter, &pScreen->unattached_list, unattached_head) {
+                pSlaveScrPriv = rrGetScrPriv(iter);
+                if (pSlaveScrPriv->provider->changed)
+                    RRDeliverProviderEvent(client, pWin, pSlaveScrPriv->provider);
+            }
+        }
     }
     return WT_WALKCHILDREN;
 }
@@ -496,6 +516,8 @@ RRTellChanged(ScreenPtr pScreen)
     rrScrPriv(pScreen);
     rrScrPrivPtr mastersp;
     int i;
+    ScreenPtr iter;
+    rrScrPrivPtr pSlaveScrPriv;
 
     if (pScreen->isGPU) {
         master = pScreen->current_master;
@@ -519,6 +541,20 @@ RRTellChanged(ScreenPtr pScreen)
             pScrPriv->outputs[i]->changed = FALSE;
         for (i = 0; i < pScrPriv->numCrtcs; i++)
             pScrPriv->crtcs[i]->changed = FALSE;
+
+        xorg_list_for_each_entry(iter, &master->output_slave_list, output_head) {
+            pSlaveScrPriv = rrGetScrPriv(iter);
+            pSlaveScrPriv->provider->changed = FALSE;
+        }
+        xorg_list_for_each_entry(iter, &master->offload_slave_list, offload_head) {
+            pSlaveScrPriv = rrGetScrPriv(iter);
+            pSlaveScrPriv->provider->changed = FALSE;
+        }
+        xorg_list_for_each_entry(iter, &master->unattached_list, unattached_head) {
+            pSlaveScrPriv = rrGetScrPriv(iter);
+            pSlaveScrPriv->provider->changed = FALSE;
+        }
+
         if (mastersp->layoutChanged) {
             pScrPriv->layoutChanged = FALSE;
             RRPointerScreenConfigured(master);
diff --git a/randr/randrstr.h b/randr/randrstr.h
old mode 100644
new mode 100755
index 2babfed..c933349
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -164,6 +164,7 @@ struct _rrProvider {
     int nameLength;
     RRPropertyPtr properties;
     Bool pendingProperties;
+    Bool changed;
     struct _rrProvider *offload_sink;
     struct _rrProvider *output_source;
 };
@@ -923,6 +924,9 @@ RRProviderSetCapabilities(RRProviderPtr provider, uint32_t capabilities);
 extern _X_EXPORT Bool
 RRProviderLookup(XID id, RRProviderPtr *provider_p);
 
+extern _X_EXPORT void
+RRDeliverProviderEvent(ClientPtr client, WindowPtr pWin, RRProviderPtr provider);
+
 /* rrproviderproperty.c */
 
 extern _X_EXPORT void
diff --git a/randr/rrprovider.c b/randr/rrprovider.c
old mode 100644
new mode 100755
index b321e62..2334ad2
--- a/randr/rrprovider.c
+++ b/randr/rrprovider.c
@@ -304,6 +304,9 @@ ProcRRSetProviderOutputSource(ClientPtr client)
 
     pScrPriv->rrProviderSetOutputSource(pScreen, provider, source_provider);
 
+    provider->changed = TRUE;
+    RRSetChanged(pScreen);
+
     RRTellChanged (pScreen);
 
     return Success;
@@ -333,6 +336,9 @@ ProcRRSetProviderOffloadSink(ClientPtr client)
 
     pScrPriv->rrProviderSetOffloadSink(pScreen, provider, sink_provider);
 
+    provider->changed = TRUE;
+    RRSetChanged(pScreen);
+
     RRTellChanged (pScreen);
 
     return Success;
@@ -357,6 +363,7 @@ RRProviderCreate(ScreenPtr pScreen, const char *name,
     provider->nameLength = nameLength;
     memcpy(provider->name, name, nameLength);
     provider->name[nameLength] = '\0';
+    provider->changed = FALSE;
 
     if (!AddResource (provider->id, RRProviderType, (pointer) provider))
         return NULL;
@@ -416,3 +423,21 @@ RRProviderLookup(XID id, RRProviderPtr *provider_p)
         return TRUE;
     return FALSE;
 }
+
+void
+RRDeliverProviderEvent(ClientPtr client, WindowPtr pWin, RRProviderPtr provider)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+
+    rrScrPriv(pScreen);
+
+    xRRProviderChangeNotifyEvent pe = {
+        .type = RRNotify + RREventBase,
+        .subCode = RRNotify_ProviderChange,
+        .timestamp = pScrPriv->lastSetTime.milliseconds,
+        .window = pWin->drawable.id,
+        .provider = provider->id
+    };
+
+    WriteEventsToClient(client, 1, (xEvent *) &pe);
+}
-- 
1.8.4



More information about the xorg-devel mailing list