I am creating a program that uses face detection coordinates to move/resize a window in real-time. The GTK+ component of this program is fairly simple I believe, but I cannot seem to figure out what is going wrong. I would like the window to stay visible the entire time without having to call "gtk_main_iteration".
I am trying to model this after OpenCV's "moveWindow" function, which uses GTK+ and the same "gtk_window_move" function that I am using. If you are interested in comparing my code to the OpenCV source code you can find these at https://github.com/opencv/opencv/tree/master/modules/highgui/src under window.cpp and window_gtk.cpp.
This project is at a standstill because of this issue so any insight is appreciated!
The OpenCV window_gtk.cpp isn't so simple. A lot of tough concepts there. For example the code is written for compiling with both GTK2 and GTK3, makes use of threads, creates a custom GTK widget, uses GTK OpenGL if it can, etc.
The GTK functions can only be called on the "main" thread of the program. This means that the OpenCV drawing can happen on a worker thread and you can keep track of the worker thread progress with the use of locking. When OpenCV is done you can notify the GTK main loop it is done and update the window. The following shows how something like this might work in a little simpler program.
Have you made custom widgets with GTK? You can incorporate threads and the functionality that you are looking for and build it into a widget. There is an experimental gauge widget that draws on a separate thread at the following. That way the gauge drawing only gets redrawn entirely when the window gets resized. Speeds things up when using a frame clock and multiple gauges. Causes some screen flicker though on resizes.