#include <mce/mode-names.h>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusMessage>
-#endif
+
QMaemo5Rotator::QMaemo5Rotator(RotationBehavior behavior, QWidget *parent)
: QObject(parent),
QMaemo5Rotator::~QMaemo5Rotator()
{
-#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)
QDBusConnection::systemBus().call(QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, MCE_ACCELEROMETER_DISABLE_REQ));
-#endif
}
const QMaemo5Rotator::RotationBehavior QMaemo5Rotator::currentBehavior()
void QMaemo5Rotator::setCurrentBehavior(QMaemo5Rotator::RotationBehavior value)
{
-#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)
if (value == _currentBehavior && isSetUp)
return;
setCurrentOrientation(QMaemo5Rotator::LandscapeOrientation);
}
}
-#endif
+}
+void QMaemo5Rotator::test()
+{
+ QMaemo5Rotator::setRotation(up);
}
void QMaemo5Rotator::setCurrentOrientation(QMaemo5Rotator::Orientation value)
case QMaemo5Rotator::PortraitOrientation:
if (par != NULL)
{
-#if defined(Q_WS_MAEMO_5)
par->setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);
par->setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
-#endif
}
orientationChanged(QMaemo5Rotator::PortraitOrientation);
break;
case QMaemo5Rotator::LandscapeOrientation:
if (par != NULL)
{
-#if defined(Q_WS_MAEMO_5)
par->setAttribute(Qt::WA_Maemo5PortraitOrientation, false);
par->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
-#endif
}
orientationChanged(QMaemo5Rotator::LandscapeOrientation);
}
QApplication::desktop()->updateGeometry();
}
+
+
+
+
+
+
+
+static bool QMaemo5Rotator::setRotation(direction dir)
+{
+ Rotation rotation = dir;
+ int reflection = 0;
+ Display * dpy = XOpenDisplay(NULL);
+ if ( dpy == NULL )
+ {
+ printf ( "Cannot open display %s\n", displayname ) ;
+ return false ;
+ }
+ int screen = DefaultScreen ( dpy ) ;
+ Window root = RootWindow ( dpy, screen ) ;
+
+ XSelectInput (dpy, root, StructureNotifyMask);
+ XRRSelectInput (dpy, root, RRScreenChangeNotifyMask);
+ int eventbase ;
+ int errorbase ;
+ XRRQueryExtension ( dpy, &eventbase, &errorbase ) ;
+
+ XRRScreenConfiguration * sc = XRRGetScreenInfo (dpy, root);
+ if ( sc == NULL )
+ {
+ printf ( "Cannot get screen info\n" ) ;
+ return false ;
+ }
+ int nsize ;
+ XRRScreenSize * sizes = XRRConfigSizes(sc, &nsize);
+ int sizeindex = 0 ;
+ if ( nsize = 0 )
+ {
+ printf ( "XRandr not available\n") ;
+ return false ;
+ }
+ Status status = XRRSetScreenConfig ( dpy, sc, DefaultRootWindow (dpy), (SizeID) sizeindex, (Rotation) (rotation | reflection), CurrentTime);
+ XEvent event;
+ bool rcvdrrnotify = false ;
+ bool rcvdconfignotify = false ;
+ if ( status == RRSetConfigSuccess)
+ {
+ printf("Screen rotation changed");
+ }
+ XCloseDisplay(dpy);
+ return true ;
+}
+#endif