highgui: cleanup and fixes
authorAlexander Alekhin <alexander.alekhin@intel.com>
Fri, 28 May 2021 01:41:20 +0000 (01:41 +0000)
committerAlexander Alekhin <alexander.alekhin@intel.com>
Mon, 31 May 2021 17:03:53 +0000 (17:03 +0000)
modules/CMakeLists.txt
modules/highgui/cmake/detect_gtk.cmake
modules/highgui/misc/plugins/plugin_gtk/CMakeLists.txt
modules/highgui/src/plugin_wrapper.impl.hpp
modules/highgui/src/window.cpp

index f2389d0..6a80040 100644 (file)
@@ -1,5 +1,3 @@
-ocv_cmake_dump_vars("" TOFILE "CMakeVars2.txt")
-set(OCV_TEST_VAR 123)
 add_definitions(-D__OPENCV_BUILD=1)
 
 if(NOT OPENCV_MODULES_PATH)
index 0ffa473..1f91986 100644 (file)
@@ -1,15 +1,16 @@
 # --- GTK ---
 ocv_clear_vars(HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT)
-if(WITH_GTK AND NOT HAVE_QT)
+if(WITH_GTK)
   if(NOT WITH_GTK_2_X)
     ocv_check_modules(GTK3 gtk+-3.0)
     if(HAVE_GTK3)
       ocv_add_external_target(gtk3 "${GTK3_INCLUDE_DIRS}" "${GTK3_LIBRARIES}" "HAVE_GTK3;HAVE_GTK")
       set(HAVE_GTK TRUE)
+      set(HAVE_GTK3 ${HAVE_GTK3} PARENT_SCOPE)
       set(GTK3_VERSION "${GTK3_VERSION}" PARENT_SCOPE) # informational
     endif()
   endif()
-  if(TRUE)
+  if((PROJECT_NAME STREQUAL "OpenCV" AND HIGHGUI_ENABLE_PLUGINS) OR NOT HAVE_GTK3)
     ocv_check_modules(GTK2 gtk+-2.0)
     if(HAVE_GTK2)
       set(MIN_VER_GTK "2.18.0")
@@ -18,6 +19,7 @@ if(WITH_GTK AND NOT HAVE_QT)
       else()
         ocv_add_external_target(gtk2 "${GTK2_INCLUDE_DIRS}" "${GTK2_LIBRARIES}" "HAVE_GTK2;HAVE_GTK")
         set(HAVE_GTK TRUE)
+        set(HAVE_GTK2 ${HAVE_GTK2} PARENT_SCOPE)
         set(GTK2_VERSION "${GTK2_VERSION}" PARENT_SCOPE) # informational
       endif()
     endif()
@@ -38,7 +40,8 @@ if(WITH_GTK AND NOT HAVE_QT)
       set(GTKGLEXT_VERSION "${GTKGLEXT_VERSION}" PARENT_SCOPE) # informational
     endif()
   endif()
+elseif(HAVE_GTK)
+  ocv_add_external_target(gtk "${GTK_INCLUDE_DIRS}" "${GTK_LIBRARIES}" "${GTK_DEFINES};HAVE_GTK")
 endif()
 
 set(HAVE_GTK ${HAVE_GTK} PARENT_SCOPE)
-set(HAVE_GTK3 ${HAVE_GTK3} PARENT_SCOPE)
index ad86905..2246290 100644 (file)
@@ -8,6 +8,10 @@ include("${OpenCV_SOURCE_DIR}/cmake/OpenCVPluginStandalone.cmake")
 set(WITH_GTK ON)
 include("${OpenCV_SOURCE_DIR}/modules/highgui/cmake/init.cmake")
 
+if(NOT HAVE_GTK)
+  message(FATAL_ERROR "GTK: NO")
+endif()
+
 ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
 
 set(OPENCV_PLUGIN_DEPS core imgproc imgcodecs)
@@ -22,23 +26,23 @@ else()
 endif()
 ocv_create_plugin(highgui "opencv_highgui_gtk" "${__deps}" "GTK" "src/window_gtk.cpp")
 
-message(STATUS "GTK: ${GTK2_VERSION}")
 if(HAVE_GTK3)
-  message(STATUS "GTK+: ver ${GTK3_VERSION}")
-elseif(HAVE_GTK)
-  message(STATUS "GTK+: ver ${GTK2_VERSION}")
+  message(STATUS "GTK3+: ver ${GTK3_VERSION}")
+elseif(HAVE_GTK3)
+  message(STATUS "GTK2+: ver ${GTK2_VERSION}")
+elseif(DEFINED GTK_VERSION)
+  message(STATUS "GTK+: ver ${GTK_VERSION}")
+else()
+  message(STATUS "GTK+: YES")
+endif()
+
+if(HAVE_GTHREAD)
+  message(STATUS "GThread : YES (ver ${GTHREAD_VERSION})")
 else()
-  message(FATAL_ERROR "GTK+: NO")
+  message(STATUS "GThread : NO")
 endif()
-if(HAVE_GTK)
-  if(HAVE_GTHREAD)
-    message(STATUS "GThread : YES (ver ${GTHREAD_VERSION})")
-  else()
-    message(STATUS "GThread : NO")
-  endif()
-  if(HAVE_GTKGLEXT)
-    message(STATUS "GtkGlExt: YES (ver ${GTKGLEXT_VERSION})")
-  else()
-    message(STATUS "GtkGlExt: NO")
-  endif()
+if(HAVE_GTKGLEXT)
+  message(STATUS "GtkGlExt: YES (ver ${GTKGLEXT_VERSION})")
+else()
+  message(STATUS "GtkGlExt: NO")
 endif()
index e68f73c..3fa2cfa 100644 (file)
@@ -40,7 +40,8 @@ protected:
                 CV_LOG_INFO(NULL, "UI: plugin is incompatible (can't be initialized): " << lib_->getName());
                 return;
             }
-            if (!checkCompatibility(plugin_api_->api_header, ABI_VERSION, API_VERSION, false))
+            // NB: force strict minor version check (ABI is not preserved for now)
+            if (!checkCompatibility(plugin_api_->api_header, ABI_VERSION, API_VERSION, true))
             {
                 plugin_api_ = NULL;
                 return;
index 7824808..7a4532e 100644 (file)
@@ -198,7 +198,7 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
     //change between fullscreen or not.
     case CV_WND_PROP_FULLSCREEN:
 
-        if (!name || (prop_value!=CV_WINDOW_NORMAL && prop_value!=CV_WINDOW_FULLSCREEN))//bad argument
+        if (prop_value != CV_WINDOW_NORMAL && prop_value != CV_WINDOW_FULLSCREEN)  // bad argument
             break;
 
         #if defined (HAVE_QT)