File rotate-wacom-pointers.diff of Package kdebase4-workspace

Index: kcontrol/randr/randrscreen.cpp
===================================================================
--- kcontrol/randr/randrscreen.cpp.orig
+++ kcontrol/randr/randrscreen.cpp
@@ -543,6 +543,8 @@ bool RandRScreen::applyProposed(bool con
 	if (succeed && confirm)
 		succeed = RandR::confirm(r);
 
+	RandR::rotateWacom( m_unifiedRotation );
+
 	// if we succeeded applying and the user confirmed the changes,
 	// just return from here 
 	if (succeed)
Index: kcontrol/randr/randr.h
===================================================================
--- kcontrol/randr/randr.h.orig
+++ kcontrol/randr/randr.h
@@ -104,6 +104,7 @@ public:
 	static bool confirm(const QRect &rect = QRect());
 
 	static SizeList sortSizes(const SizeList &sizes);
+	static void rotateWacom( int rotation );
 };
 
 #endif
Index: kcontrol/randr/legacyrandrscreen.cpp
===================================================================
--- kcontrol/randr/legacyrandrscreen.cpp.orig
+++ kcontrol/randr/legacyrandrscreen.cpp
@@ -104,6 +104,7 @@ bool LegacyRandRScreen::applyProposed()
 		m_currentSize = m_proposedSize;
 		m_currentRotation = m_proposedRotation;
 		m_currentRefreshRate = m_proposedRefreshRate;
+		RandR::rotateWacom( m_currentRotation );	
 		return true;
 	}
 
Index: kcontrol/randr/randrcrtc.cpp
===================================================================
--- kcontrol/randr/randrcrtc.cpp.orig
+++ kcontrol/randr/randrcrtc.cpp
@@ -317,6 +317,7 @@ bool RandRCrtc::applyProposed()
 		m_currentRect = m_proposedRect;
 		m_currentRate = mode.refreshRate();
 		emit crtcChanged(m_id, RandR::ChangeMode);
+		RandR::rotateWacom( m_currentRotation );
 		ret = true;
 	}
 	else
Index: kcontrol/randr/randr.cpp
===================================================================
--- kcontrol/randr/randr.cpp.orig
+++ kcontrol/randr/randr.cpp
@@ -19,6 +19,8 @@
 
 #include "randr.h"
 #include <KIconLoader>
+#include <kstandarddirs.h>
+#include <qprocess.h>
 
 bool RandR::has_1_2 = false;
 bool RandR::has_1_3 = false;
@@ -179,5 +181,40 @@ SizeList RandR::sortSizes(const SizeList
 	return sorted;
 }
 
+void RandR::rotateWacom( int rotation )
+{
+	// search wacom utility and set orientation for available wacom pointers
+	QString xsetwacom = KStandardDirs::findExe("xsetwacom");
+	if (!xsetwacom.isEmpty()) {
+		QProcess proc;
+		proc.start( "xsetwacom", QStringList() << "list" );
+		if (!proc.waitForStarted() || !proc.waitForFinished()) {
+			kError("Could not ask xsetwacom for available pointers.");
+			return;
+		} else {
+			while( !proc.atEnd()) {
+				QString line = QString::fromLocal8Bit( proc.readLine());
+				QString pointer = line.split( ' ' ).first();
+				QStringList args;
+				args << "set" << pointer << "Rotate";
+				switch (rotation) {
+					case RR_Rotate_90:
+						args << "CW";
+						break;
+					case RR_Rotate_180:
+						args << "HALF";
+						break;
+					case RR_Rotate_270:
+						args << "CCW";
+						break;
+					default:
+						args << "NONE";
+			        }
+				if( QProcess::execute( "xsetwacom", args ) != 0 )
+					kError("Could not set orientation for wacom pointers.");
+			}
+		}
+	}
+}
 
 
openSUSE Build Service is sponsored by