Nheko-Reborn / nheko

Desktop client for Matrix using Qt and C++20.
https://nheko-reborn.github.io/
GNU General Public License v3.0
1.9k stars 199 forks source link

Full screen image appears on wrong monitor #1016

Open UgnilJoZ opened 2 years ago

UgnilJoZ commented 2 years ago

Describe the bug

When using nheko on a secondary screen, clicking on an image displays the image in fullscreen on the primary monitor.

To Reproduce

  1. Enter a Gnome Wayland session (Nvidia on my side) with a two-monitor setup
  2. Put nheko on the secondary monitor
  3. Select a chat
  4. Click on an image to display it full-screen

What happened?

The image is displayed in full screen on the other (primary) monitor.

(Subsequent clicks on the image open more and more image viewers on top of the first one.)

Additionally, sometimes on the first try after starting nheko, the image message is only selected instead of show in full screen.

Expected behavior

I would have expected the image to appear as overlay on top of the chat window.

Screenshots

Primary monitor on the bottom, secondary on top

Version

0.9.3-9bac429

Operating system

Linux

Installation method

Flathub

Qt version

No response

C++ compiler

No response

Desktop Environment

Gnome (Wayland)

Did you use profiles?

Relevant log output

No logs are generated during the event of showing images.

Backtrace

No response

deepbluev7 commented 2 years ago

Nheko uses a separate window to display images. It should open on the same monitor, but we have no control over that on wayland. So you need to configure your window manager to do the right thing, I think?

ceandreasen commented 1 year ago

I also am encountering this same issue on Pop OS 22.04 using X11, so it isn't just a wayland issue. Nheko opens on my primary monitor, but regardless of where I put the nheko window, the image viewer always pops up over my secondary display (and clicking the image again in confusion opens more image previews)

I personally would think that further image previews shouldn't open if you keep clicking, unless there's a use case for that I'm missing, but that's obviously a lower priority/basically a non-issue if the popup was always covering the main UI.

MayeulC commented 1 year ago

I also have the same issue on sway/wayland. The fullscreen image viewer seems to favor my rightmost monitor currently, which is a tiny Steam Deck screen...

Also, it's weird that the window is a fullscreened borderless pop-up. I would have imagined a normal window, or a fullscreen window. Preferably with server-side decorations still (decorations are hidden when full-screen anyway).

`swaymsg -t get_tree` output with nheko preview window ```json "floating_nodes": [ { "id": 133, "type": "floating_con", "orientation": "none", "percent": 1.1010752688172043, "urgent": false, "marks": [], "focused": false, "layout": "none", "border": "csd", "current_border_width": 2, "rect": { "x": 2688, "y": 0, "width": 1280, "height": 800 }, "deco_rect": { "x": 0, "y": 0, "width": 0, "height": 0 }, "window_rect": { "x": 0, "y": 0, "width": 1280, "height": 800 }, "geometry": { "x": 0, "y": 0, "width": 500, "height": 500 }, "name": "nheko", "window": null, "nodes": [], "floating_nodes": [], "focus": [], "fullscreen_mode": 1, "sticky": false, "pid": 32405, "app_id": "io.github.NhekoReborn.Nheko", "visible": true, "max_render_time": 0, "shell": "xdg_shell", "inhibit_idle": false, "idle_inhibitors": { "user": "none", "application": "none" } } ], ```
TomTheDragon commented 8 months ago

The bug is still persistent on X11 and wayland. Any updates on this?

deepbluev7 commented 8 months ago

The bug is still persistent on X11 and wayland. Any updates on this?

Sure: Nobody fixed it in Qt yet.

ceandreasen commented 8 months ago

Sure: Nobody fixed it in Qt yet.

Thanks! Is there an upstream bug report we can track or work on?

UgnilJoZ commented 6 months ago

Nheko uses a separate window to display images.

If it is not possible to control where it is opened, then may there be a better technical approach to the image preview than opening an additional window? Something like an overlay component within the existing window?

It should open on the same monitor, but we have no control over that on wayland.

There seems to be some kind of influence an application can exert.

If I click on an image in Telegram desktop, it opens a new window on top the existing one and on the same monitor. (Unless the window spans over multiple screens, then it seems to be a little more random).

forkiesassds commented 2 months ago

How is this an upstream QT issue? Is there any issue on their issue tracker? I'm using KDE Plasma 6 in Wayland and I haven't encountered any problems where windows open on a different monitor than the one where my cursor is at other than with some X11 programs. But with this application I do encounter this issue. Originally I thought this was because for SOME REASON it was using X11, turns out not. Even making it forcefully use Wayland causes this issue.

deepbluev7 commented 2 months ago

Actually, I can't find the issue anymore, that I thought was there. I thought there was one like https://bugreports.qt.io/browse/QTBUG-30724, but for Linux, but I can't find it anymore.

But for anyone interested in it, the code is here: https://github.com/Nheko-Reborn/nheko/blob/0c222689f47991bcc47fd68566deb82592e370e3/resources/qml/Root.qml#L254

Possibly the parent needs to be set differently to show on the same screen or something? I always assumed "showFullScreen" would just open on the same monitor. Possibly the transientParent needs to be set on the Window. In theory that property is set automatically though, but maybe that doesn't work if there is no Window above it in qml (and the window is instead the QQuickWindow created in C++).

forkiesassds commented 2 months ago

Wouldn't it be better if the image was just shown within the same window? Something like how Element and Discord does it. Doing so would probably eliminate a whole dozen of weird issues like these.

deepbluev7 commented 2 months ago

Not for me, I usually put the image manually on a different monitor, so that it doesn't block the chat and I can discuss it.

forkiesassds commented 2 months ago

Then it's a feature, not a bug. :trollface: