Permalink
Browse files

Merge pull request tias#38 from Tokoyami/master

Take rotation into account when calculating display size
  • Loading branch information...
tias committed Jun 20, 2012
2 parents 084adde + 0aabb15 commit b0d30f1b2c9613f80db7e808b4c8cf70ed7919fa
Showing with 34 additions and 15 deletions.
  1. +5 −5 src/calibrator/Evdev.cpp
  2. +25 −6 src/gui/x11.cpp
  3. +4 −4 src/main_common.cpp
View
@@ -329,21 +329,21 @@ Display *display, const char *name, Bool only_extended)
for (loop=0; loop<len; loop++) {
if (!isdigit(name[loop])) {
is_id = False;
break;
is_id = False;
break;
}
}
if (is_id) {
id = atoi(name);
id = atoi(name);
}
devices = XListInputDevices(display, &num_devices);
for (loop=0; loop<num_devices; loop++) {
if ((!only_extended || (devices[loop].use >= IsXExtensionDevice)) &&
((!is_id && strcmp(devices[loop].name, name) == 0) ||
(is_id && devices[loop].id == id))) {
((!is_id && strcmp(devices[loop].name, name) == 0) ||
(is_id && devices[loop].id == id))) {
if (found) {
fprintf(stderr,
"Warning: There are multiple devices named \"%s\".\n"
View
@@ -95,7 +95,12 @@ GuiCalibratorX11::GuiCalibratorX11(Calibrator* calibrator0)
int nsizes;
XRRScreenSize* randrsize = XRRSizes(display, screen_num, &nsizes);
if (nsizes != 0) {
set_display_size(randrsize->width, randrsize->height);
Rotation current = 0;
XRRRotations(display, screen_num, &current);
bool rot = current & RR_Rotate_90 || current & RR_Rotate_270;
int width = rot ? randrsize->height : randrsize->width;
int height = rot ? randrsize->width : randrsize->height;
set_display_size(width, height);
} else {
set_display_size(DisplayWidth(display, screen_num),
DisplayHeight(display, screen_num));
@@ -183,17 +188,31 @@ void GuiCalibratorX11::set_display_size(int width, int height) {
void GuiCalibratorX11::redraw()
{
#ifdef HAVE_X11_XRANDR
if (calibrator->get_geometry() == NULL) {
int width;
int height;
#ifdef HAVE_X11_XRANDR
// check that screensize did not change
int nsizes;
XRRScreenSize* randrsize = XRRSizes(display, screen_num, &nsizes);
if (nsizes != 0 && (display_width != randrsize->width ||
display_height != randrsize->height)) {
set_display_size(randrsize->width, randrsize->height);
if (nsizes != 0) {
Rotation current = 0;
XRRRotations(display, screen_num, &current);
bool rot = current & RR_Rotate_90 || current & RR_Rotate_270;
width = rot ? randrsize->height : randrsize->width;
height = rot ? randrsize->width : randrsize->height;
} else {
width = DisplayWidth(display, screen_num);
height = DisplayHeight(display, screen_num);
}
}
#else
width = DisplayWidth(display, screen_num);
height = DisplayHeight(display, screen_num);
#endif
if (display_width != width || display_height != height) {
set_display_size(width, height);
}
}
// Print the text
int text_height = font_info->ascent + font_info->descent;
View
@@ -87,10 +87,10 @@ int Calibrator::find_device(const char* pre_device, bool list_devices,
// check whether the pre_device is an ID (only digits)
int len = strlen(pre_device);
for (int loop=0; loop<len; loop++) {
if (!isdigit(pre_device[loop])) {
pre_device_is_id = false;
break;
}
if (!isdigit(pre_device[loop])) {
pre_device_is_id = false;
break;
}
}
}

0 comments on commit b0d30f1

Please sign in to comment.