Blob Blame History Raw
From bf760f3eeaf4552ee60c1ab3027cbb2198c1d203 Mon Sep 17 00:00:00 2001
From: Fedora X Ninjas <x@fedoraproject.org>
Date: Wed, 12 Dec 2012 15:15:38 +1000
Subject: [PATCH] autoconfig: fixup tell changed so randr clients can tell

This lets the gnome applet update if a usb device appears/disappears
---
 hw/xfree86/common/xf86platformBus.c |  7 +++++--
 hw/xfree86/modes/xf86Crtc.c         |  2 ++
 hw/xfree86/modes/xf86RandR12.c      |  2 ++
 randr/randr.c                       | 26 +++++++++++++++++++++++++-
 randr/randrstr.h                    |  4 ++++
 randr/rrcrtc.c                      |  2 +-
 randr/rrinfo.c                      |  2 +-
 randr/rroutput.c                    |  2 +-
 randr/rrscreen.c                    |  2 +-
 9 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index 057b5b6..197bde8 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -47,6 +47,7 @@
 #include "Pci.h"
 #include "xf86platformBus.h"
 
+#include "randrstr.h"
 int platformSlotClaimed;
 
 int xf86_num_platform_devices;
@@ -462,7 +463,8 @@ xf86platformAddDevice(int index)
    /* attach unbound to 0 protocol screen */
    AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
    xf86AutoConfigOutputDevice(xf86GPUScreens[i], xf86Screens[0]);
-
+   
+   RRTellChanged(xf86Screens[0]->pScreen);
    return 0;
 }
 
@@ -500,12 +502,13 @@ xf86platformRemoveDevice(int index)
     xf86GPUScreens[i]->pScreen->CloseScreen(xf86GPUScreens[i]->pScreen);
 
     RemoveGPUScreen(xf86GPUScreens[i]->pScreen);
+
     xf86DeleteScreen(xf86GPUScreens[i]);
 
     xf86UnclaimPlatformSlot(&xf86_platform_devices[index], NULL);
 
     xf86_remove_platform_device(index);
-
+    RRTellChanged(xf86Screens[0]->pScreen);
  out:
     return;
 }
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 1263dd7..263a1dc 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -3346,6 +3346,7 @@ void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master)
         unbound = TRUE;
         AttachOffloadGPU(master->pScreen, pScrn->pScreen);
         slave_config->randr_provider->offload_sink = master_provider;
+	RRSetChanged(master->pScreen);
     }
     if ((master->capabilities & RR_Capability_SourceOutput) &&
                pScrn->capabilities & RR_Capability_SinkOutput) {
@@ -3354,5 +3355,6 @@ void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master)
             DetachUnboundGPU(pScrn->pScreen);
         AttachOutputGPU(master->pScreen, pScrn->pScreen);
         slave_config->randr_provider->output_source = master_provider;
+	RRSetChanged(master->pScreen);
     }
 }
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 01fc9c5..9d96c4f 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -1895,10 +1895,12 @@ xf86RandR14ProviderDestroy(ScreenPtr screen, RRProviderPtr provider)
         if (config->randr_provider->offload_sink) {
             DetachOffloadGPU(screen);
             config->randr_provider->offload_sink = NULL;
+	    RRSetChanged(screen);
         }
         else if (config->randr_provider->output_source) {
             DetachOutputGPU(screen);
             config->randr_provider->output_source = NULL;
+	    RRSetChanged(screen);
         }
         else if (screen->current_master)
             DetachUnboundGPU(screen);
diff --git a/randr/randr.c b/randr/randr.c
index f0decfc..0528bfd 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -464,6 +464,30 @@ TellChanged(WindowPtr pWin, pointer value)
     return WT_WALKCHILDREN;
 }
 
+void
+RRSetChanged(ScreenPtr pScreen)
+{
+    /* set changed bits on the master screen only */
+    ScreenPtr master;
+    rrScrPriv(pScreen);
+    rrScrPrivPtr mastersp;
+
+    if (pScreen->isGPU) {
+        master = pScreen->current_master;
+	if (!master)
+	  return;
+        mastersp = rrGetScrPriv(master);
+        if (!mastersp)
+            return;
+    }
+    else {
+        master = pScreen;
+        mastersp = pScrPriv;
+    }
+
+    mastersp->changed = TRUE;
+}
+
 /*
  * Something changed; send events and adjust pointer position
  */
@@ -484,7 +508,7 @@ RRTellChanged(ScreenPtr pScreen)
         mastersp = pScrPriv;
     }
 
-    if (pScrPriv->changed) {
+    if (mastersp->changed) {
         UpdateCurrentTimeIf();
         if (mastersp->configChanged) {
             mastersp->lastConfigTime = currentTime;
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 55faaed..73132e3 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -486,6 +486,10 @@ extern _X_EXPORT void
  RRDeliverScreenEvent(ClientPtr client, WindowPtr pWin, ScreenPtr pScreen);
 
 /* randr.c */
+/* set a screen change on the primary screen */
+extern _X_EXPORT void
+RRSetChanged(ScreenPtr pScreen);
+
 /*
  * Send all pending events
  */
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index e82d050..d0add47 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -39,7 +39,7 @@ RRCrtcChanged(RRCrtcPtr crtc, Bool layoutChanged)
     if (pScreen) {
         rrScrPriv(pScreen);
 
-        pScrPriv->changed = TRUE;
+	RRSetChanged(pScreen);
         /*
          * Send ConfigureNotify on any layout change
          */
diff --git a/randr/rrinfo.c b/randr/rrinfo.c
index 1408d6f..fc57bd4 100644
--- a/randr/rrinfo.c
+++ b/randr/rrinfo.c
@@ -225,7 +225,7 @@ RRScreenSetSizeRange(ScreenPtr pScreen,
     pScrPriv->minHeight = minHeight;
     pScrPriv->maxWidth = maxWidth;
     pScrPriv->maxHeight = maxHeight;
-    pScrPriv->changed = TRUE;
+    RRSetChanged(pScreen);
     pScrPriv->configChanged = TRUE;
 }
 
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 88781ba..195bef9 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -36,7 +36,7 @@ RROutputChanged(RROutputPtr output, Bool configChanged)
     output->changed = TRUE;
     if (pScreen) {
         rrScrPriv(pScreen);
-        pScrPriv->changed = TRUE;
+	RRSetChanged(pScreen);
         if (configChanged)
             pScrPriv->configChanged = TRUE;
     }
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 39340cc..36179ae 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -143,7 +143,7 @@ RRScreenSizeNotify(ScreenPtr pScreen)
     pScrPriv->height = pScreen->height;
     pScrPriv->mmWidth = pScreen->mmWidth;
     pScrPriv->mmHeight = pScreen->mmHeight;
-    pScrPriv->changed = TRUE;
+    RRSetChanged(pScreen);
 /*    pScrPriv->sizeChanged = TRUE; */
 
     RRTellChanged(pScreen);
-- 
1.8.1