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

MacOS: Pinned image jumps from original spot #3022

Open
bsavant opened this issue Dec 14, 2022 · 7 comments
Open

MacOS: Pinned image jumps from original spot #3022

bsavant opened this issue Dec 14, 2022 · 7 comments
Labels
MacOS MacOS related

Comments

@bsavant
Copy link

bsavant commented Dec 14, 2022

Flameshot Version

Flameshot v12.1.0 (96c2c82)
Compiled with Qt 5.15.5
darwin: 22.1.0
osx: 13.0

Installation Type

Using the ready-made package from Github Releases

Operating System type and version

MacOS

Description

After selecting a region and pinning the image, the pinned image moves from the original selection. This does not happen with the same version of flameshot on Linux Mint.

Steps to reproduce

  1. launch flameshot app
  2. Use hotkey to capture region
  3. select a region to capture an image
  4. pin image

Screenshots or screen recordings

MacOS

MacOS

Linux Mint

Linux Mint

System Information

MacOS 13.0.1 Ventura (Intel)

@bsavant bsavant added the Unconfirmed Bug The bug is not confirmed by anyone else. label Dec 14, 2022
@mmahmoudian
Copy link
Member

This is how macOS works. You can make Finder full screen and then back to windowed and see the same animation. There is nothing we can do about this until and unless Qt implements a feature that let us bypass this behavior (very unlikely)

@mmahmoudian mmahmoudian added MacOS MacOS related and removed Unconfirmed Bug The bug is not confirmed by anyone else. labels Dec 16, 2022
@bsavant
Copy link
Author

bsavant commented Dec 16, 2022

I'm not referring to the animation, I understand that's a feature of MacOS. What I'm referring to is the fact that the pinned screenshot that remains is offset from the original selection region.

@mmahmoudian mmahmoudian reopened this Dec 19, 2022
@mmahmoudian
Copy link
Member

@bsavant Thanks for the explanation. I re-opened this. I don't have access to a mac to test/reproduce this. Let's see if other devs have.

@jorpilo
Copy link

jorpilo commented Aug 5, 2023

I believe this is similar to #2612.

I can verify the issue happens on my M1 and window is shifted downwards regardless if it's full screen or not or the bar status

@mmahmoudian how can I help to solve this issue? this is being a very frustrating problem for me

@mmahmoudian
Copy link
Member

@jorpilo I have a hunch that this downward shift is due to the top menu bar in mac. Would you please move your menu bar once to left and once to bottom and see if the shift is always downwards or it is dependent on the bar position

@jorpilo
Copy link

jorpilo commented Oct 5, 2023

I can confirm that the issue still happens regardless if menu bar is on the left, right or bottom position and the screen always shifts a few pixels down losing the bottom part of the screen.

toofar referenced this issue in toofar/flameshot Dec 29, 2023
The docs for `setTopLeft()` say

    "Set the top-left corner of the rectangle to the given position. May
    change the size, but will never change the bottom-right corner of
    the rectangle."

For some reason on windows when calling `setTopLeft()` here when the
widget is at an offset it is moving the top left of the rect but not
keeping the size the same. I believe all we want to do here is move the
rect, so this commit changes this adjustment to definitively do that.
There are various instances of `move()`, `moveTo()` and `moveTopLeft()`
in the codebase, and only one other if `setTopLeft()`. I picked
`moveTopLeft()` because it makes the diff smaller ;)

This error has the following implications 1) causing the pin widget
to shift a little from where the selection was 2) causing the reported
geometry to not match the pixmap size, which didn't have much effect
unless you wanted to use the geometry later (for example for allowing
editing pins). I guess the pin widget got its size from the pixmap or
something and that's why it wasn't huge?

You can reproduce this like so:

* have a windows machine with two monitors
* change the display settings so monitor one is to the right of monitor
  two (which causes monitor two to have a negative offset)
* pin a selection and watch the pinned window shift a bit from where the
  selection was; or
* observe this modified geometry somehow, like this patch which changes
  the size measurement painted on the selection widget to include the
  modified geometry alongside the original one:

    diff --git c/src/widgets/capture/capturewidget.cpp w/src/widgets/capture/capturewidget.cpp
    index 49ebff9720a0..16c7d04dbed6 100644
    --- c/src/widgets/capture/capturewidget.cpp
    +++ w/src/widgets/capture/capturewidget.cpp
    @@ -551,11 +633,18 @@ void CaptureWidget::paintEvent(QPaintEvent* paintEvent)
             QRect xybox;
             QFontMetrics fm = painter.fontMetrics();

    -        QString xy = QString("%1x%2+%3+%4")
    +        QRect final_geometry(m_context.selection);
    +        final_geometry.setTopLeft(final_geometry.topLeft() + m_context.widgetOffset);
    +        QString xy = QString("%1x%2+%3+%4\n%5x%6+%7+%8")
                            .arg(static_cast<int>(selection.width() * scale))
                            .arg(static_cast<int>(selection.height() * scale))
                            .arg(static_cast<int>(selection.left() * scale))
    -                       .arg(static_cast<int>(selection.top() * scale));
    +                       .arg(static_cast<int>(selection.top() * scale))
    +                       .arg(static_cast<int>(final_geometry.width() * scale))
    +                       .arg(static_cast<int>(final_geometry.height() * scale))
    +                       .arg(static_cast<int>(final_geometry.left() * scale))
    +                       .arg(static_cast<int>(final_geometry.top() * scale))
    +                       ;

             xybox = fm.boundingRect(xy);
             // the small numbers here are just margins so the text doesn't

https://doc.qt.io/qt-6/qrect.html#setTopLeft
@yzq-del
Copy link

yzq-del commented Feb 22, 2024

This is how macOS works. You can make Finder full screen and then back to windowed and see the same animation. There is nothing we can do about this until and unless Qt implements a feature that let us bypass this behavior (very unlikely)

Why do other QT screenshot tools not have this animation effect?such as snipaste

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

No branches or pull requests

4 participants