~osomon/oxide/backport-42-patch-for-isError

« back to all changes in this revision

Viewing changes to qt/core/common/oxide_qt_screen_utils.cc

  • Committer: Chris Coulson
  • Date: 2015-01-24 15:38:34 UTC
  • Revision ID: chris.coulson@canonical.com-20150124153834-gct1fij8itnawpbk
Use QScreen::angleBetween rather than implementing our own calculation

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
  }
49
49
}
50
50
 
51
 
uint16_t GetOrientationAngleFromScreenOrientation(
52
 
    Qt::ScreenOrientation primary,
53
 
    Qt::ScreenOrientation orientation) {
54
 
  DCHECK(primary == Qt::PortraitOrientation ||
55
 
         primary == Qt::LandscapeOrientation);
56
 
  bool portrait = primary == Qt::PortraitOrientation;
57
 
 
58
 
  switch (orientation) {
59
 
    case Qt::PortraitOrientation:
60
 
      return portrait ? 0 : 270;
61
 
    case Qt::LandscapeOrientation:
62
 
      return portrait ? 90 : 0;
63
 
    case Qt::InvertedPortraitOrientation:
64
 
      return portrait ? 180 : 90;
65
 
    case Qt::InvertedLandscapeOrientation:
66
 
      return portrait ? 270 : 180;
67
 
    default:
68
 
      NOTREACHED();
69
 
      return 0;
70
 
  }
71
 
}
72
 
 
73
51
}
74
52
 
75
53
float GetDeviceScaleFactorFromQScreen(QScreen* screen) {
147
125
  result.orientationType =
148
126
      GetOrientationTypeFromScreenOrientation(screen->orientation());
149
127
  result.orientationAngle =
150
 
      GetOrientationAngleFromScreenOrientation(screen->primaryOrientation(),
151
 
                                               screen->orientation());
 
128
      screen->angleBetween(screen->orientation(),
 
129
                           screen->primaryOrientation());
152
130
 
153
131
  return result;
154
132
}