From e59873c96ba79c744b9f47347e6fd7f2b698536f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 13 Jul 2007 10:25:46 -0700 Subject: Add support for new RandR output dpms change event. --- configure.ac | 2 +- hw/xfree86/modes/xf86Crtc.c | 11 +++++++++++ randr/randr.c | 25 +++++++++++++++++++++++++ randr/randrstr.h | 8 ++++++++ randr/rrdispatch.c | 5 +++-- randr/rroutput.c | 31 +++++++++++++++++++++++++++++++ 6 files changed, 79 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index be8878a95..b9265d420 100644 --- a/configure.ac +++ b/configure.ac @@ -616,7 +616,7 @@ XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la' PIXMAN="[pixman >= 0.9.2]" dnl Core modules for most extensions, et al. -REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto [xproto >= 7.0.9] xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]" +REQUIRED_MODULES="[randrproto >= 1.3] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto [xproto >= 7.0.9] xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]" REQUIRED_LIBS="xfont xau fontenc $PIXMAN" if test "x$DBUS" = xauto; then diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index d20a3a338..16c3b89d9 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1955,6 +1955,10 @@ xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags) xf86OutputPtr output = config->output[i]; if (output->crtc != NULL) (*output->funcs->dpms) (output, mode); +#ifdef RANDR_12_INTERFACE + if (output->randr_output != NULL) + RROutputSetDPMS (output->randr_output, mode); +#endif } } @@ -1969,8 +1973,15 @@ xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags) xf86OutputPtr output = config->output[i]; if (output->crtc != NULL) (*output->funcs->dpms) (output, mode); +#ifdef RANDR_12_INTERFACE + if (output->randr_output != NULL) + RROutputSetDPMS (output->randr_output, mode); +#endif } } +#ifdef RANDR_12_INTERFACE + RRTellChanged (scrn->pScreen); +#endif } /** diff --git a/randr/randr.c b/randr/randr.c index 958f9c192..85ff587eb 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -175,6 +175,18 @@ SRROutputPropertyNotifyEvent(xRROutputPropertyNotifyEvent *from, cpswapl(from->timestamp, to->timestamp); } +static void +SRROutputDPMSChangeNotifyEvent(xRROutputDPMSChangeNotifyEvent *from, + xRROutputDPMSChangeNotifyEvent *to) +{ + to->type = from->type; + to->subCode = from->subCode; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->window, to->window); + cpswapl(from->output, to->output); + cpswaps(from->level, to->level); +} + static void SRRNotifyEvent (xEvent *from, xEvent *to) @@ -192,6 +204,10 @@ SRRNotifyEvent (xEvent *from, SRROutputPropertyNotifyEvent ((xRROutputPropertyNotifyEvent *) from, (xRROutputPropertyNotifyEvent *) to); break; + case RRNotify_OutputDPMSChange: + SRROutputDPMSChangeNotifyEvent((xRROutputDPMSChangeNotifyEvent *) from, + (xRROutputDPMSChangeNotifyEvent *) to); + break; default: break; } @@ -404,6 +420,15 @@ TellChanged (WindowPtr pWin, pointer value) RRDeliverOutputEvent (client, pWin, output); } } + if (pRREvent->mask & RROutputDPMSChangeNotifyMask) + { + for (i = 0; i < pScrPriv->numOutputs; i++) + { + RROutputPtr output = pScrPriv->outputs[i]; + if (output->dpmsChanged) + RRDeliverOutputDPMSEvent (client, pWin, output); + } + } } return WT_WALKCHILDREN; } diff --git a/randr/randrstr.h b/randr/randrstr.h index 4cc3a469e..6493716ac 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -139,6 +139,8 @@ struct _rrOutput { Bool changed; RRPropertyPtr properties; Bool pendingProperties; + CARD16 dpmsLevel; + Bool dpmsChanged; void *devPrivate; }; @@ -710,9 +712,15 @@ RROutputSetPhysicalSize (RROutputPtr output, int mmWidth, int mmHeight); +Bool +RROutputSetDPMS (RROutputPtr output, CARD16 level); + void RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output); +void +RRDeliverOutputDPMSEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output); + void RROutputDestroy (RROutputPtr output); diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index 5525427f6..11e5a7e4b 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -23,7 +23,7 @@ #include "randrstr.h" #define SERVER_RANDR_MAJOR 1 -#define SERVER_RANDR_MINOR 2 +#define SERVER_RANDR_MINOR 3 Bool RRClientKnowsRates (ClientPtr pClient) @@ -85,7 +85,8 @@ ProcRRSelectInput (ClientPtr client) if (stuff->enable & (RRScreenChangeNotifyMask| RRCrtcChangeNotifyMask| - RROutputChangeNotifyMask)) + RROutputChangeNotifyMask| + RROutputDPMSChangeNotifyMask)) { ScreenPtr pScreen = pWin->drawable.pScreen; rrScrPriv (pScreen); diff --git a/randr/rroutput.c b/randr/rroutput.c index e00116283..1e1c914c4 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -331,6 +331,22 @@ RROutputSetPhysicalSize (RROutputPtr output, return TRUE; } +Bool +RROutputSetDPMS(RROutputPtr output, CARD16 level) +{ + ScreenPtr pScreen = output->pScreen; + + if (output->dpmsLevel != level) { + output->dpmsChanged = TRUE; + if (pScreen) { + rrScrPriv (pScreen); + pScrPriv->changed = TRUE; + } + } + output->dpmsLevel = level; + + return TRUE; +} void RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) @@ -365,6 +381,21 @@ RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) WriteEventsToClient (client, 1, (xEvent *) &oe); } +void +RRDeliverOutputDPMSEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + xRROutputDPMSChangeNotifyEvent oe; + + oe.type = RRNotify + RREventBase; + oe.subCode = RRNotify_OutputDPMSChange; + oe.sequenceNumber = client->sequence; + oe.window = pWin->drawable.id; + oe.output = output->id; + oe.level = output->dpmsLevel; + WriteEventsToClient (client, 1, (xEvent *) &oe); +} + /* * Destroy a Output at shutdown */ -- cgit v1.2.3