Skip to content

Commit b6933db

Browse files
committed
highgui(pollKey): properly handle no-GUI case
1 parent 9d22764 commit b6933db

File tree

5 files changed

+15
-30
lines changed

5 files changed

+15
-30
lines changed

modules/highgui/src/window.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,17 @@ int cv::waitKey(int delay)
297297
return (code != -1) ? (code & 0xff) : -1;
298298
}
299299

300-
// NOTE: cv::pollKey has no C API equivalent. it is implemented in each backend source file.
300+
#if defined(HAVE_WIN32UI)
301+
// pollKey() implemented in window_w32.cpp
302+
#elif defined(HAVE_GTK) || defined(HAVE_COCOA) || defined(HAVE_QT) || (defined (WINRT) && !defined (WINRT_8_0))
303+
// pollKey() fallback implementation
304+
int cv::pollKey()
305+
{
306+
CV_TRACE_FUNCTION();
307+
// fallback. please implement a proper polling function
308+
return cvWaitKey(1);
309+
}
310+
#endif
301311

302312
int cv::createTrackbar(const String& trackbarName, const String& winName,
303313
int* value, int count, TrackbarCallback callback,
@@ -789,6 +799,10 @@ CV_IMPL int cvCreateButton(const char*, void (*)(int, void*), void*, int, int)
789799
CV_NO_GUI_ERROR("cvCreateButton");
790800
}
791801

802+
int cv::pollKey()
803+
{
804+
CV_NO_GUI_ERROR("cv::pollKey()");
805+
}
792806

793807
#endif
794808

modules/highgui/src/window_QT.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,6 @@ CV_IMPL int cvWaitKey(int delay)
382382
}
383383

384384

385-
int cv::pollKey()
386-
{
387-
CV_TRACE_FUNCTION();
388-
// fallback. please implement a proper polling function
389-
return cvWaitKey(1);
390-
}
391-
392385
//Yannick Verdie
393386
//This function is experimental and some functions (such as cvSet/getWindowProperty will not work)
394387
//We recommend not using this function for now

modules/highgui/src/window_cocoa.mm

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -632,13 +632,6 @@ CV_IMPL int cvWaitKey (int maxWait)
632632
return returnCode;
633633
}
634634

635-
int cv::pollKey()
636-
{
637-
CV_TRACE_FUNCTION();
638-
// fallback. please implement a proper polling function
639-
return cvWaitKey(1);
640-
}
641-
642635
CvRect cvGetWindowRect_COCOA( const char* name )
643636
{
644637
CvRect result = cvRect(-1, -1, -1, -1);

modules/highgui/src/window_gtk.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,13 +1950,6 @@ CV_IMPL int cvWaitKey( int delay )
19501950
return last_key;
19511951
}
19521952

1953-
int cv::pollKey()
1954-
{
1955-
CV_TRACE_FUNCTION();
1956-
// fallback. please implement a proper polling function
1957-
return cvWaitKey(1);
1958-
}
1959-
19601953

19611954
#endif // HAVE_GTK
19621955
#endif // _WIN32

modules/highgui/src/window_winrt.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,6 @@ CV_IMPL int cvGetTrackbarPos(const char* trackbar_name, const char* window_name)
205205

206206
/********************************** Not YET implemented API ****************************************************/
207207

208-
int cv::pollKey()
209-
{
210-
CV_TRACE_FUNCTION();
211-
CV_WINRT_NO_GUI_ERROR("cvPollKey");
212-
213-
// TODO: implement appropriate logic here
214-
}
215-
216208
CV_IMPL int cvWaitKey(int delay)
217209
{
218210
CV_WINRT_NO_GUI_ERROR("cvWaitKey");

0 commit comments

Comments
 (0)