Bug 649274 - MeeGo Display turns off after 60 seconds without touch r=romaxa,glandium
authorJeremias Bosch <jeremias.bosch@gmail.com>
Wed, 25 May 2011 16:27:58 -0400
changeset 70180 17ecc803b4bd13bae4f97feb9d5c3671a171b794
parent 70179 db2292d1f68cce4f212c335a09e33916d685aaab
child 70181 db398bf9cffe596a723387ce1d2a014849bf39e0
push idunknown
push userunknown
push dateunknown
reviewersromaxa, glandium
bugs649274
milestone7.0a1
Bug 649274 - MeeGo Display turns off after 60 seconds without touch r=romaxa,glandium
config/autoconf.mk.in
configure.in
widget/src/qt/nsScreenQt.cpp
widget/src/qt/nsScreenQt.h
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -545,16 +545,17 @@ MOZ_ENABLE_D3D9_LAYER	= @MOZ_ENABLE_D3D9
 MOZ_ENABLE_D3D10_LAYER  = @MOZ_ENABLE_D3D10_LAYER@
 
 MOZ_GTK2_CFLAGS		= @MOZ_GTK2_CFLAGS@
 MOZ_GTK2_LIBS		= @MOZ_GTK2_LIBS@
 
 MOZ_QT_CFLAGS		= @MOZ_QT_CFLAGS@
 MOZ_QT_LIBS		= @MOZ_QT_LIBS@
 MOZ_ENABLE_QTNETWORK    = @MOZ_ENABLE_QTNETWORK@
+MOZ_ENABLE_QMSYSTEM2    = @MOZ_ENABLE_QMSYSTEM2@
 MOZ_ENABLE_QTMOBILITY   = @MOZ_ENABLE_QTMOBILITY@
 MOZ_ENABLE_CONTENTACTION   = @MOZ_ENABLE_CONTENTACTION@
 MOZ_ENABLE_MEEGOTOUCHSHARE = @MOZ_ENABLE_MEEGOTOUCHSHARE@
 
 MOZ_DBUS_CFLAGS         = @MOZ_DBUS_CFLAGS@
 MOZ_DBUS_LIBS           = @MOZ_DBUS_LIBS@
 MOZ_DBUS_GLIB_CFLAGS    = @MOZ_DBUS_GLIB_CFLAGS@
 MOZ_DBUS_GLIB_LIBS      = @MOZ_DBUS_GLIB_LIBS@
--- a/configure.in
+++ b/configure.in
@@ -5247,16 +5247,28 @@ then
         HOST_MOC="$QTDIR/bin/moc"
     fi
     if test -z "$HOST_MOC"; then
         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
 incorrect])
     fi
     MOC=$HOST_MOC
 
+    MOZ_ENABLE_QMSYSTEM2=
+    PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2,
+                      MOZ_ENABLE_QMSYSTEM2=1,
+                      MOZ_ENABLE_QMSYSTEM2=)
+
+    if test "$MOZ_ENABLE_QMSYSTEM2"; then
+      MOZ_ENABLE_QMSYSTEM2=1
+      MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS"
+      MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS"
+      AC_DEFINE(MOZ_ENABLE_QMSYSTEM2)
+    fi
+
     MOZ_ENABLE_QTNETWORK=
     PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
                       MOZ_ENABLE_QTNETWORK=1,
                       MOZ_ENABLE_QTNETWORK=)
 
     if test "$MOZ_ENABLE_QTNETWORK"; then
       MOZ_ENABLE_QTNETWORK=1
       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
@@ -5286,16 +5298,17 @@ fi
 AC_SUBST(GTK_CONFIG)
 AC_SUBST(TK_CFLAGS)
 AC_SUBST(TK_LIBS)
 
 AC_SUBST(MOZ_ENABLE_GTK2)
 AC_SUBST(MOZ_ENABLE_PHOTON)
 AC_SUBST(MOZ_ENABLE_QT)
 AC_SUBST(MOZ_ENABLE_QTNETWORK)
+AC_SUBST(MOZ_ENABLE_QMSYSTEM2)
 AC_SUBST(MOZ_ENABLE_QTMOBILITY)
 AC_SUBST(MOZ_ENABLE_XREMOTE)
 AC_SUBST(MOZ_GTK2_CFLAGS)
 AC_SUBST(MOZ_GTK2_LIBS)
 AC_SUBST(MOZ_QT_CFLAGS)
 AC_SUBST(MOZ_QT_LIBS)
 
 AC_SUBST(MOC)
--- a/widget/src/qt/nsScreenQt.cpp
+++ b/widget/src/qt/nsScreenQt.cpp
@@ -46,31 +46,50 @@
 
 #include "nsScreenQt.h"
 #include "nsXULAppAPI.h"
 
 #ifdef MOZ_ENABLE_QTMOBILITY
 #include "mozqorientationsensorfilter.h"
 #endif
 
+#ifdef MOZ_ENABLE_QMSYSTEM2
+#include <qmdisplaystate.h>
+using namespace mozilla;
+
+const int DISPLAY_BLANK_TIMEOUT = 10800; /*3 * 60 * 60 seconds*/
+const int DISPLAY_DIM_TIMEOUT = 10620; /*3 * 59 * 60 seconds*/
+
+#endif
+
 nsScreenQt::nsScreenQt(int aScreen)
     : mScreen(aScreen)
+#ifdef MOZ_ENABLE_QMSYSTEM2
+    , mDisplayState(nsnull)
+#endif
 {
     // nothing else to do. I guess we could cache a bunch of information
     // here, but we want to ask the device at runtime in case anything
     // has changed.
 }
 
 nsScreenQt::~nsScreenQt()
 {
-    // nothing to see here.
+#ifdef MOZ_ENABLE_QMSYSTEM2
+    delete mDisplayState;
+    mDisplayState = nsnull;
+#endif
 }
 
 // addref, release, QI
+#ifdef MOZ_ENABLE_QMSYSTEM2
+NS_IMPL_ISUPPORTS2(nsScreenQt, nsIScreen, nsIScreen_MOZILLA_2_0_BRANCH)
+#else
 NS_IMPL_ISUPPORTS1(nsScreenQt, nsIScreen)
+#endif
 
 NS_IMETHODIMP
 nsScreenQt::GetRect(PRInt32 *outLeft,PRInt32 *outTop,
                     PRInt32 *outWidth,PRInt32 *outHeight)
 {
     QRect r = QApplication::desktop()->screenGeometry(mScreen);
 #ifdef MOZ_ENABLE_QTMOBILITY
     r = MozQOrientationSensorFilter::GetRotationTransform().mapRect(r);
@@ -110,8 +129,32 @@ nsScreenQt::GetPixelDepth(PRInt32 *aPixe
 }
 
 NS_IMETHODIMP
 nsScreenQt::GetColorDepth(PRInt32 *aColorDepth)
 {
     // ###############
     return GetPixelDepth(aColorDepth);
 }
+
+#ifdef MOZ_ENABLE_QMSYSTEM2
+void
+nsScreenQt::ApplyMinimumBrightness(PRUint32 aType)
+{
+    // resets all we did before,
+    // 1) there is no interface to get default values
+    // 2) user might have changed system settings while fennec is running
+    //    there is no notification about that.
+    delete mDisplayState;
+    mDisplayState = nsnull;
+
+    if( aType == BRIGHTNESS_FULL) {
+        mDisplayState = new MeeGo::QmDisplayState();
+
+        // no way to keep display from blanking than setting a huge timeout
+        // parameter is seconds. setting timeout to huge time this should work for 99.9% of our usecases
+        mDisplayState->setDisplayBlankTimeout( DISPLAY_BLANK_TIMEOUT /*in seconds*/ );
+        mDisplayState->setDisplayDimTimeout( DISPLAY_DIM_TIMEOUT /*in seconds*/ );
+        mDisplayState->setDisplayBrightnessValue( mDisplayState->getMaxDisplayBrightnessValue() );
+        mDisplayState->set(MeeGo::QmDisplayState::On);
+     }
+}
+#endif
--- a/widget/src/qt/nsScreenQt.h
+++ b/widget/src/qt/nsScreenQt.h
@@ -38,24 +38,41 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsScreenQt_h___
 #define nsScreenQt_h___
 
 #include "nsIScreen.h"
 
+#ifdef MOZ_ENABLE_QMSYSTEM2
+#include "WidgetUtils.h"
+namespace MeeGo
+{
+    class QmDisplayState;
+}
+#endif
+
+
 //------------------------------------------------------------------------
 
 class nsScreenQt : public nsIScreen
+#ifdef MOZ_ENABLE_QMSYSTEM2
+                , public mozilla::widget::BrightnessLockingWidget
+#endif
 {
 public:
   nsScreenQt (int aScreen);
   virtual ~nsScreenQt();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISCREEN
 
+#ifdef MOZ_ENABLE_QMSYSTEM2
+  void ApplyMinimumBrightness(PRUint32 aType);
+private:
+  MeeGo::QmDisplayState* mDisplayState;
+#endif
 private:
   int mScreen;
 };
 
 #endif  // nsScreenQt_h___