first step for fixing the wacom problem on linux

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent 70a204a920
commit e42bb6c098
  1. 63
      src/board/UBBoardView.cpp

@ -282,86 +282,82 @@ UBBoardView::event (QEvent * e)
return QGraphicsView::event (e); return QGraphicsView::event (e);
} }
void void UBBoardView::tabletEvent (QTabletEvent * event)
UBBoardView::tabletEvent (QTabletEvent * event)
{
if (!mUseHighResTabletEvent)
{ {
if (!mUseHighResTabletEvent) {
event->setAccepted (false); event->setAccepted (false);
return; return;
} }
qDebug() << "tableEvent position " << event->pos();
qDebug() << "tableEvent global position " << event->globalPos();
UBDrawingController *dc = UBDrawingController::drawingController (); UBDrawingController *dc = UBDrawingController::drawingController ();
QPointF tabletPos = UBGeometryUtils::pointConstrainedInRect (event->hiResGlobalPos () QPointF tabletPos = UBGeometryUtils::pointConstrainedInRect (event->hiResGlobalPos () - mapToGlobal (QPoint (0, 0)), rect ());
- mapToGlobal (QPoint (0, 0)), rect ());
// QPointF tabletPos = event->pos();
qDebug() << "tabletPos " << tabletPos;
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool ();
if (event->type () == QEvent::TabletPress || event->type () == QEvent::TabletEnterProximity) if (event->type () == QEvent::TabletPress || event->type () == QEvent::TabletEnterProximity) {
{ if (event->pointerType () == QTabletEvent::Eraser) {
if (event->pointerType () == QTabletEvent::Eraser)
{
dc->setStylusTool (UBStylusTool::Eraser); dc->setStylusTool (UBStylusTool::Eraser);
mUsingTabletEraser = true; mUsingTabletEraser = true;
} }
else else {
{
if (mUsingTabletEraser && currentTool == UBStylusTool::Eraser) if (mUsingTabletEraser && currentTool == UBStylusTool::Eraser)
{
dc->setStylusTool (dc->latestDrawingTool ()); dc->setStylusTool (dc->latestDrawingTool ());
}
mUsingTabletEraser = false; mUsingTabletEraser = false;
} }
} }
// if event are not Pen events, we drop the tablet stuff and route everything through mouse event // if event are not Pen events, we drop the tablet stuff and route everything through mouse event
if (currentTool != UBStylusTool::Pen if (currentTool != UBStylusTool::Pen && currentTool != UBStylusTool::Line && currentTool != UBStylusTool::Marker && !mMarkerPressureSensitive){
&& currentTool != UBStylusTool::Line
&& currentTool != UBStylusTool::Marker
&& !mMarkerPressureSensitive)
{
event->setAccepted (false); event->setAccepted (false);
return; return;
} }
QPointF scenePos = viewportTransform ().inverted ().map (tabletPos); QPointF scenePos = viewportTransform ().inverted ().map (tabletPos);
qDebug() << "scene Pos " << scenePos;
qreal pressure = 1.0; qreal pressure = 1.0;
if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line) if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line)
&& mPenPressureSensitive) && mPenPressureSensitive)
|| (currentTool == UBStylusTool::Marker && mMarkerPressureSensitive)) || (currentTool == UBStylusTool::Marker && mMarkerPressureSensitive))
{
pressure = event->pressure (); pressure = event->pressure ();
}
bool acceptEvent = true; bool acceptEvent = true;
switch (event->type ()) switch (event->type ()) {
{ case QEvent::TabletPress: {
case QEvent::TabletPress: qDebug() << "TabletPress";
{
mTabletStylusIsPressed = true;
mTabletStylusIsPressed = true;
scene()->inputDevicePress (scenePos, pressure); scene()->inputDevicePress (scenePos, pressure);
break; break;
} }
case QEvent::TabletMove: case QEvent::TabletMove: {
{ qDebug() << "TabletMove";
if (mTabletStylusIsPressed) if (mTabletStylusIsPressed)
{
scene ()->inputDeviceMove (scenePos, pressure); scene ()->inputDeviceMove (scenePos, pressure);
}
acceptEvent = false; // rerouted to mouse move acceptEvent = false; // rerouted to mouse move
break; break;
} }
case QEvent::TabletRelease: case QEvent::TabletRelease: {
{ qDebug() << "TabletRelease";
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool ();
scene ()->setToolCursor (currentTool); scene ()->setToolCursor (currentTool);
setToolCursor (currentTool); setToolCursor (currentTool);
@ -375,8 +371,7 @@ UBBoardView::tabletEvent (QTabletEvent * event)
break; break;
} }
default: default: {
{
//NOOP - avoid compiler warning //NOOP - avoid compiler warning
} }
} }

Loading…
Cancel
Save