Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use moveWindow() using Ubuntu 22.04 using WAYLAND but can using X11 for desktop environment #25478

Closed
4 tasks done
Digital1O1 opened this issue Apr 23, 2024 · 2 comments
Closed
4 tasks done

Comments

@Digital1O1
Copy link

Digital1O1 commented Apr 23, 2024

System Information

OpenCV version: 4.9.0
Operating System / Platform: Ubuntu 22.04
Linux Kernal: 6.5.0-28-generic
Compiler & compiler version: G++/GCC : 11.4.0.

Detailed description

So........ There I was, writing a basic C++ program to make sure I understood how the moveWindow() command works for a project I'm working on.

After compiling the program, the generated window; in this case 'banana', wasn't moving as expected.

So a buddy of mine ran the same code on his Debian machine and the window moved as expected.

Below is the C++ code that was ran.

// g++ test.cpp -o cvTest `pkg-config --libs --cflags opencv4`

#include <stdlib.h>
#include <time.h>

#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>

int main()
{

    /* initialize random seed: */
    srand(time(NULL));

    /* generate secret number between 1 and 10: */
    cv::Mat test = cv::Mat::zeros(400, 300, CV_8UC3);

    cv::namedWindow("banana");

    int key, x, y;

    while (1)
    {

        cv::imshow("banana", test);
        key = cv::waitKey(500);

        if (key == 97)
        {
            break;
        }
        else if (key != 0)
        {

            x = rand() % 1000 + 1;
            y = rand() % 1000 + 1;

            cv::moveWindow("banana", x, y);
        }
    }
}

We both realized after Googling the issue for nearly an hour that I was using Wayland on my machine while my buddy was using X11 on his.

So after switching my machine from Wayland --> X11 I recompiled the code and ran it and observed that the window was moving as expected

Steps to reproduce

Steps to reproduce

  1. Ensure that you're using WAYLAND on your machine
  2. Compile the C++ program with the following G++ command : g++ test.cpp -o cvTest pkg-config --libs --cflags opencv4
  3. Run the C++ executable to verify that the window 'banana' isn't moving
  4. Switch over from WAYLAND to X11
  5. Re-run the C++ executable and verify that the window 'banana' is moving
// g++ test.cpp -o cvTest `pkg-config --libs --cflags opencv4`

#include <stdlib.h>
#include <time.h>

#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>

int main()
{

    /* initialize random seed: */
    srand(time(NULL));

    /* generate secret number between 1 and 10: */
    cv::Mat test = cv::Mat::zeros(400, 300, CV_8UC3);

    cv::namedWindow("banana");

    int key, x, y;

    while (1)
    {

        cv::imshow("banana", test);
        key = cv::waitKey(500);

        if (key == 97)
        {
            break;
        }
        else if (key != 0)
        {

            x = rand() % 1000 + 1;
            y = rand() % 1000 + 1;

            cv::moveWindow("banana", x, y);
        }
    }
}

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)
@Digital1O1 Digital1O1 added the bug label Apr 23, 2024
@Digital1O1 Digital1O1 changed the title Can't use moveWindow() using Ubuntu 22.04 using WAYLAND but can using X11 for desktop envionrment Can't use moveWindow() using Ubuntu 22.04 using WAYLAND but can using X11 for desktop environment Apr 23, 2024
@asmorkalov
Copy link
Contributor

@Digital1O1 Wailand backend for UI is experimental feature for now. Feel free to submit PR, if you have a solution.

@Kumataro
Copy link
Contributor

Hello, I investigated about this issue.

At Wayland, each window positions are controlled under the compositor, not application side.

So I think this is Wayland protocol limitation, and it cannot be fixed by application( or client backend in OpenCV) side approach.

And this limitation is described at document on 4.x branch.

https://docs.opencv.org/4.x/d7/dfc/group__highgui.html#ga8d86b207f7211250dbe6e28f76307ffb

If OK, please could you close this issue ?

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

No branches or pull requests

3 participants