Skip to content

Added mechanism to set/toggle NORMAL window to TOPMOST window.#14872

Merged
alalek merged 2 commits intoopencv:3.4from
AhiyaHiya:feature/topmost_window
Sep 5, 2019
Merged

Added mechanism to set/toggle NORMAL window to TOPMOST window.#14872
alalek merged 2 commits intoopencv:3.4from
AhiyaHiya:feature/topmost_window

Conversation

@AhiyaHiya
Copy link
Copy Markdown
Contributor

This change adds the ability for the cv created normal window to be TOPMOST, in situations where it is needed for the Window to be above all of the others.

To make a normal window TOPMOST, call cvSetWindowProperty with property WND_PROP_TOPMOST and a non-zero property value. Passing in 0 for the prop_value will make the window TOP.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution!

Unfortunately there is no design decision (and consistency in existed code) about errors handling for U/I functionality (silent/log message/return value or exception) at this moment.

@AhiyaHiya
Copy link
Copy Markdown
Contributor Author

AhiyaHiya commented Jul 13, 2019

To ask for re-review @alalek , what is needed? Also, shall I rebase the commits into a smaller set?

@AhiyaHiya AhiyaHiya force-pushed the feature/topmost_window branch from d91ec9e to eb72e75 Compare August 4, 2019 14:29
@crackwitz
Copy link
Copy Markdown
Contributor

if anyone feels like adding it for Qt too, it's Qt::WindowStaysOnTopHint and setWindowFlags() as demonstrated in https://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@alalek alalek merged commit fafada2 into opencv:3.4 Sep 5, 2019
@alalek alalek mentioned this pull request Sep 5, 2019
@yumetodo
Copy link
Copy Markdown

yumetodo commented Sep 11, 2019

@AhiyaHiya Regression was reported at https://teratail.com/questions/211380 .

The reporter follow the step shown https://www.learnopencv.com/install-opencv-3-4-4-on-macos/ .

[ 44%] Linking CXX shared library ../../lib/libopencv_highgui.dylib
Undefined symbols for architecture x86_64:
  "cvGetPropTopmost_COCOA(char const*)", referenced from:
      _cvGetWindowProperty in window.cpp.o
      cv::getWindowProperty(cv::String const&, int) in window.cpp.o
  "cvSetPropTopmost_COCOA(char const*, bool)", referenced from:
      _cvSetWindowProperty in window.cpp.o
      cv::setWindowProperty(cv::String const&, int, double) in window.cpp.o
ld: symbol(s) not found for architecture x86_64

I don't have macOS env so that I don't know whether this PR actually trigger this error or not. However, according to my investigation shown below, the possibility is high, I think.

Defining HAVE_COCOA is not related to defining HAVE_QT.

if(APPLE)
if(WITH_CARBON)
set(HAVE_CARBON YES)
elseif(NOT IOS AND CV_CLANG)
set(HAVE_COCOA YES)
endif()
endif()

However, ${CMAKE_CURRENT_LIST_DIR}/src/window_cocoa.mm will be built only when HAVE_QT is not defined.

elseif(HAVE_QT)
if (HAVE_QT_OPENGL)
set(QT_USE_QTOPENGL TRUE)
endif()
include(${QT_USE_FILE})
QT4_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.qrc)
QT4_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h)
list(APPEND HIGHGUI_LIBRARIES ${QT_LIBRARIES})
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES})
ocv_check_flag_support(CXX -Wno-missing-declarations _have_flag "")
if(${_have_flag})
set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations)
endif()
elseif(WINRT)
if(NOT WINRT_8_0)
# Dependencies used by the implementation referenced
# below are not available on WinRT 8.0.
# Enabling it for WiRT 8.1+ only.
# WinRT 8.1+ detected. Adding WinRT API header.
message(STATUS " ${name}: WinRT detected. Adding WinRT API header")
list(APPEND highgui_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/highgui_winrt.hpp")
list(APPEND highgui_srcs
${CMAKE_CURRENT_LIST_DIR}/src/window_winrt.cpp
${CMAKE_CURRENT_LIST_DIR}/src/window_winrt_bridge.cpp)
list(APPEND highgui_hdrs
${CMAKE_CURRENT_LIST_DIR}/src/window_winrt_bridge.hpp)
endif()
# libraries below are neither available nor required
# on ARM devices and/or Windows Phone
if(WINRT_PHONE OR (OpenCV_ARCH STREQUAL "ARM"))
list(REMOVE_ITEM HIGHGUI_LIBRARIES "comctl32" "gdi32" "ole32" "setupapi")
if(WINRT_PHONE)
message(STATUS " ${name}: Windows Phone detected")
elseif(OpenCV_ARCH STREQUAL "ARM")
message(STATUS " ${name}: ARM detected")
if(WINRT_STORE)
list(REMOVE_ITEM HIGHGUI_LIBRARIES "ws2_32")
message(STATUS " ${name}: Removing 'ws2_32.lib'")
endif()
endif()
message(STATUS " ${name}: Removing 'comctl32.lib, gdi32.lib, ole32.lib, setupapi.lib'")
message(STATUS " ${name}: Leaving '${HIGHGUI_LIBRARIES}'")
endif()
elseif(HAVE_WIN32UI)
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_w32.cpp)
elseif(HAVE_GTK OR HAVE_GTK3)
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_gtk.cpp)
elseif(HAVE_CARBON)
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_carbon.cpp)
list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime")
elseif(HAVE_COCOA)
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_cocoa.mm)
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
endif()

As a result, cvGetPropTopmost_COCOA is undefined.

@AhiyaHiya AhiyaHiya deleted the feature/topmost_window branch September 12, 2019 13:33
@AhiyaHiya
Copy link
Copy Markdown
Contributor Author

@yumetodo I'm not entirely sure if the newly added code, as it is, is causing a linking problem when the Qt option is selected. I'm guessing, this may be a CMake issue for the Build folks to review/research.

@mshabunin
Copy link
Copy Markdown
Contributor

@yumetodo , I've been able to reproduce this issue on OSX with Qt. I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants