• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A generic touchscreen calibration program for X.Org


Commit MetaInfo

Révision03dadf55109bd43d3380f040debe9f82f66f2f35 (tree)
l'heure2014-02-14 07:24:23
AuteurTias Guns <tias@ulys...>
CommiterTias Guns

Message de Log

Merge pull request #51 from kreijack/screen_size

Correct screen size detection

Change Summary

Modification

--- a/src/gui/x11.cpp
+++ b/src/gui/x11.cpp
@@ -81,25 +81,12 @@ GuiCalibratorX11::GuiCalibratorX11(Calibrator* calibrator0)
8181 }
8282 }
8383
84-#ifdef HAVE_X11_XRANDR
85- // get screensize from xrandr
86- int nsizes;
87- XRRScreenSize* randrsize = XRRSizes(display, screen_num, &nsizes);
88- if (nsizes != 0) {
89- Rotation current = 0;
90- XRRRotations(display, screen_num, &current);
91- bool rot = current & RR_Rotate_90 || current & RR_Rotate_270;
92- int width = rot ? randrsize->height : randrsize->width;
93- int height = rot ? randrsize->width : randrsize->height;
94- set_display_size(width, height);
95- } else {
96- set_display_size(DisplayWidth(display, screen_num),
97- DisplayHeight(display, screen_num));
98- }
99-# else
100- set_display_size(DisplayWidth(display, screen_num),
101- DisplayHeight(display, screen_num));
102-#endif
84+ int width, height;
85+ detect_display_size(width, height);
86+ set_display_size(width, height);
87+
88+ fprintf(stderr, "INFO: width=%d, height=%d\n",
89+ display_width, display_height);
10390
10491 // parse geometry string
10592 const char* geo = calibrator->get_geometry();
@@ -166,6 +153,42 @@ GuiCalibratorX11::GuiCalibratorX11(Calibrator* calibrator0)
166153 #endif
167154 }
168155
156+void GuiCalibratorX11::detect_display_size( int &width, int &height) {
157+
158+#ifdef HAVE_X11_XRANDR
159+ // check that screensize did not change
160+ int nsizes;
161+ bool xrandr_ok = false;
162+ XRRScreenSize* randrsize = XRRSizes(display, screen_num, &nsizes);
163+ if (nsizes != 0) {
164+ Rotation current = 0;
165+ XRRScreenConfiguration * sc;
166+
167+ sc = XRRGetScreenInfo (display, RootWindow (display, screen_num));
168+ int current_size = XRRConfigCurrentConfiguration (sc, &current);
169+
170+ if (current_size < nsizes) {
171+
172+ XRRRotations(display, screen_num, &current);
173+ randrsize += current_size;
174+
175+ bool rot = current & RR_Rotate_90 || current & RR_Rotate_270;
176+ width = rot ? randrsize->height : randrsize->width;
177+ height = rot ? randrsize->width : randrsize->height;
178+ xrandr_ok = true;
179+ }
180+ }
181+ if (!xrandr_ok) {
182+ width = DisplayWidth(display, screen_num);
183+ height = DisplayHeight(display, screen_num);
184+ }
185+#else
186+ width = DisplayWidth(display, screen_num);
187+ height = DisplayHeight(display, screen_num);
188+#endif
189+
190+}
191+
169192 GuiCalibratorX11::~GuiCalibratorX11()
170193 {
171194 XUngrabPointer(display, CurrentTime);
@@ -195,24 +218,7 @@ void GuiCalibratorX11::redraw()
195218 if (calibrator->get_geometry() == NULL) {
196219 int width;
197220 int height;
198-#ifdef HAVE_X11_XRANDR
199- // check that screensize did not change
200- int nsizes;
201- XRRScreenSize* randrsize = XRRSizes(display, screen_num, &nsizes);
202- if (nsizes != 0) {
203- Rotation current = 0;
204- XRRRotations(display, screen_num, &current);
205- bool rot = current & RR_Rotate_90 || current & RR_Rotate_270;
206- width = rot ? randrsize->height : randrsize->width;
207- height = rot ? randrsize->width : randrsize->height;
208- } else {
209- width = DisplayWidth(display, screen_num);
210- height = DisplayHeight(display, screen_num);
211- }
212-#else
213- width = DisplayWidth(display, screen_num);
214- height = DisplayHeight(display, screen_num);
215-#endif
221+ detect_display_size(width, height);
216222 if (display_width != width || display_height != height) {
217223 set_display_size(width, height);
218224 }
--- a/src/gui/x11.hpp
+++ b/src/gui/x11.hpp
@@ -68,6 +68,7 @@ private:
6868 void on_button_press_event(XEvent event);
6969
7070 // Helper functions
71+ void detect_display_size(int &width, int &height);
7172 void set_display_size(int width, int height);
7273 void redraw();
7374 void draw_message(const char* msg);