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

Move floating window to negative coordinates doesn't work #321

Closed
tlaemmlein opened this issue Oct 21, 2022 · 4 comments
Closed

Move floating window to negative coordinates doesn't work #321

tlaemmlein opened this issue Oct 21, 2022 · 4 comments

Comments

@tlaemmlein
Copy link

Thank you for fixing #75

But a floating window can't moved to negative coordinates.

Example: You have two monitors horizontal arranged. The right monitor is the main monitor, which means the left/top corner is the origin.
Hence the left monitor has negative X values.

If you want to move the floating window to the left monitor with this code:
floating_window>resize(size);
floating_window->move(QPoint(-250, 200);
floating_window>show();

Then the window is open at the right monitor.

And yes it is possible to switch around the code:
floating_window>show();
floating_window>resize(size);
floating_window->move(QPoint(-250, 200);

But then we have the flickering described in #75

Kind Regards,

Thomas

@iamsergio
Copy link
Contributor

iamsergio commented Oct 21, 2022

Does that even work with non-KDDW pure-Qt code ? I'm happy to support it if it's supported by Qt as well

@iamsergio
Copy link
Contributor

It should work, but there's a few snags.

Can you print this (in your application, not in a testcase):

    for (auto screen : qApp->screens()) {
        qDebug() << screen << screen->geometry() << screen->virtualGeometry() << screen->devicePixelRatio();
    }

@tlaemmlein
Copy link
Author

tlaemmlein commented Oct 24, 2022

System: Windows 10 / VS 2019
kddockwidgets version: 1.7.x

I have observed if the floating window is only a little bit in the negative area then it won't be moved. but if the floating window is total in the negative area then the kddockwidget lib moves it to zero.

Steps:

Change MyMainWindow.cpp to

  QAction *newAction = fileMenu->addAction(QStringLiteral("New DockWidget -400x100"));

   connect(newAction, &QAction::triggered, this, [] {
       static int count = 0;
       count++;
       auto w = newMyWidget();
       w->setGeometry(50, 50, 400, 400);
       auto dock = new KDDockWidgets::DockWidget(QStringLiteral("new dock %1").arg(count));
       dock->setWidget(w);
       dock->setGeometry(-400, 100, 500, 500);
       dock->show();
   });

   QAction *newAction1 = fileMenu->addAction(QStringLiteral("New DockWidget -600x100"));

   connect(newAction1, &QAction::triggered, this, [] {
       static int count = 0;
       count++;
       auto w = newMyWidget();
       w->setGeometry(50, 50, 400, 400);
       auto dock = new KDDockWidgets::DockWidget(QStringLiteral("new dock %1").arg(count));
       dock->setWidget(w);
       dock->setGeometry(-600, 100, 500, 500);
       dock->show();
   });

   QAction *newAction2 = fileMenu->addAction(QStringLiteral("New QWidget -600x100"));

   connect(newAction2, &QAction::triggered, this, [] {
       static int count = 0;
       count++;
       auto w = newMyWidget();
       w->setGeometry(-600, 100, 500, 500);
       w->show();
   });

  • Setup your two screens: Screen 2 is left to Screen 1 and Screen 1 is the main display.
  • Then start kddockwidget example with -k
  • Click the three actions

Here see the animation:
wrong_coordinates

By the way: I suppose this is also a problem with the y axis. I didn't test it but the testcase is that the screen2 should be above screen 1so that screen 2 has negative y values.

Kind Regards,

Thomas

iamsergio added a commit that referenced this issue Oct 28, 2022
QScreen::geometry() is already in "virtual coordinate space", no
need to map again. Bug wasn't noticeable since most setups
have virtual top left at 0,0, so it was a no-op in most cases.

Fixes bug #321
@tlaemmlein
Copy link
Author

Thanks.

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

No branches or pull requests

2 participants