telegramdesktop / tdesktop

Telegram Desktop messaging app
https://desktop.telegram.org/
Other
26.23k stars 5.2k forks source link

Context menus are incorrectly scaled with Flatpak #27575

Closed ansipunk closed 7 months ago

ansipunk commented 7 months ago

Steps to reproduce

No clue, for some reason the issue is apparent on one PC running latest Fedora with GNOME without any custom themes, however, on other PC with latest Fedora and GNOME everything is ok. I reset all of my flatpak overrides, there should not be a single custom setting. I flipped different switches with OpenGL, hardware acceleration, scaling, Qt window frames, but the problem persists. Obviously I tried updating all of my rpm and flatpak packages, restarting, changing Flatpak and Qt/GTK themes, etc.

Expected behaviour

Everything should look ok.

Actual behaviour

Context menus on messages look wrong. Behavior is also weird, clicks are registered on wrong places. I checked with other issues, there were bunch of different issues with the same problem, but all were closed with some magic trick that worked for them, but not for me. Happens with any scaling factors. When I turn on experimental scaling, context menus look and behave correctly, however, performance massively drops when opening media, so I cannot use that workaround.

image

Operating system

Fedora 39

Version of Telegram Desktop

4.15.1

Installation source

Flatpak

Crash ID

No response

Logs

No response

ilya-fedin commented 7 months ago

Advanced -> Experimental settings -> Restore default values

If this didn't help, provide the log.txt as explained by the issue template

ansipunk commented 7 months ago

@ilya-fedin there's no such button. https://pastebin.mozilla.org/kMo6Yjcc

ansipunk commented 7 months ago

Turns out #27576 is the correct issue. I disconnected second screen and everything worked just fine. You may close this issue.

ilya-fedin commented 7 months ago

https://pastebin.mozilla.org/kMo6Yjcc

Is it any better if you remove QT_SCALE_FACTOR environment variable?

ilya-fedin commented 7 months ago

Are scale factors the same on both screens? Would it get fixed if you make them use the same ones?

ilya-fedin commented 7 months ago

Turns out #27576 is the correct issue.

I'm not sure... They look related but I'm not sure they have the same cause and can be fixed by one change.

ansipunk commented 7 months ago

@ilya-fedin I restarded my PC and the problem appeared again. I tried setting QT_SCALE_FACTOR to 1, 1.0 and none, nothing helped.

ilya-fedin commented 7 months ago

@ansipunk please try to unset it. It's a debug variable and shouldn't really be used for everyday use.

ansipunk commented 7 months ago

none

I did. QT_SCALE_FACTOR= flatpak run org.telegram.dekstop

ansipunk commented 7 months ago

Screencast from 2024-03-14 16-42-11.webm

ilya-fedin commented 7 months ago

I did. QT_SCALE_FACTOR= flatpak run org.telegram.dekstop

Try env -u QT_SCALE_FACTOR flatpak run org.telegram.desktop. Unset is not the same as set to empty value on Linux.

ansipunk commented 7 months ago

Issue persists.

ilya-fedin commented 7 months ago

Thank you for screencast, that's helpful

ilya-fedin commented 7 months ago

Are scale factors the same on both screens? Would it get fixed if you make them use the same ones?

Please answer these questions

ansipunk commented 7 months ago

Yes, they are. They are exact same models. One is placed vertically.

ansipunk commented 7 months ago

Arranged like this: image

ilya-fedin commented 7 months ago

Can you run tdesktop like WAYLAND_DEBUG=1 org.telegram.desktop > wayland_debug.txt 2>&1, open the menu at the point where it's displayed right and then open it in the bugged state, quit tdesktop (so there's no more changes to the file) and upload the file?

ansipunk commented 7 months ago

Interesting. It works right click a link in the message, however, when i right click the whole message instead it breaks.

https://pastebin.mozilla.org/rAkwJV4F

ilya-fedin commented 7 months ago

Perhaps it needs a very intensive debugging... Which I can't do due to the lack of a second screen and I don't want to install GNOME on real hardware. I can give you instruction what to change in tdesktop source code if you want to help. If you don't want then you perhaps have to wait unless someone else would like to look on the issue (if it happens at all).

ansipunk commented 7 months ago

I see. I might be able to come up with a solution if you tell me where to look.

ilya-fedin commented 7 months ago

Try to add LOG(("PopupMenu DPR: %1").arg(devicePixelRatio())); to PopupMenu::paintEvent. The issue looks like the scaling factor gets changed in while drawing and that should show whether that's what happens...

ilya-fedin commented 7 months ago

Can you reproduce this on beta versions that use Qt 6.7.0? Maybe this issue will get different behavior just like #27576?

ansipunk commented 7 months ago

Fixed with new Qt.