A generic touchscreen calibration program for X.Org
Révision | 0aabb155d351656bbb804619279dd497b06c48b0 (tree) |
---|---|
l'heure | 2012-06-19 19:45:52 |
Auteur | Plamen Kolev <multyrealm@gmai...> |
Commiter | Plamen Kolev |
take rotation into account when calculating display size
changed GuiCalibratorX11::redraw() to fall back to X if xrandr is not available
@@ -95,7 +95,12 @@ GuiCalibratorX11::GuiCalibratorX11(Calibrator* calibrator0) | ||
95 | 95 | int nsizes; |
96 | 96 | XRRScreenSize* randrsize = XRRSizes(display, screen_num, &nsizes); |
97 | 97 | if (nsizes != 0) { |
98 | - set_display_size(randrsize->width, randrsize->height); | |
98 | + Rotation current = 0; | |
99 | + XRRRotations(display, screen_num, ¤t); | |
100 | + bool rot = current & RR_Rotate_90 || current & RR_Rotate_270; | |
101 | + int width = rot ? randrsize->height : randrsize->width; | |
102 | + int height = rot ? randrsize->width : randrsize->height; | |
103 | + set_display_size(width, height); | |
99 | 104 | } else { |
100 | 105 | set_display_size(DisplayWidth(display, screen_num), |
101 | 106 | DisplayHeight(display, screen_num)); |
@@ -183,17 +188,31 @@ void GuiCalibratorX11::set_display_size(int width, int height) { | ||
183 | 188 | |
184 | 189 | void GuiCalibratorX11::redraw() |
185 | 190 | { |
186 | -#ifdef HAVE_X11_XRANDR | |
187 | 191 | if (calibrator->get_geometry() == NULL) { |
192 | + int width; | |
193 | + int height; | |
194 | +#ifdef HAVE_X11_XRANDR | |
188 | 195 | // check that screensize did not change |
189 | 196 | int nsizes; |
190 | 197 | XRRScreenSize* randrsize = XRRSizes(display, screen_num, &nsizes); |
191 | - if (nsizes != 0 && (display_width != randrsize->width || | |
192 | - display_height != randrsize->height)) { | |
193 | - set_display_size(randrsize->width, randrsize->height); | |
198 | + if (nsizes != 0) { | |
199 | + Rotation current = 0; | |
200 | + XRRRotations(display, screen_num, ¤t); | |
201 | + bool rot = current & RR_Rotate_90 || current & RR_Rotate_270; | |
202 | + width = rot ? randrsize->height : randrsize->width; | |
203 | + height = rot ? randrsize->width : randrsize->height; | |
204 | + } else { | |
205 | + width = DisplayWidth(display, screen_num); | |
206 | + height = DisplayHeight(display, screen_num); | |
194 | 207 | } |
195 | - } | |
208 | +#else | |
209 | + width = DisplayWidth(display, screen_num); | |
210 | + height = DisplayHeight(display, screen_num); | |
196 | 211 | #endif |
212 | + if (display_width != width || display_height != height) { | |
213 | + set_display_size(width, height); | |
214 | + } | |
215 | + } | |
197 | 216 | |
198 | 217 | // Print the text |
199 | 218 | int text_height = font_info->ascent + font_info->descent; |