obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
60.19k stars 7.97k forks source link

"Add Source" context menu not visible on Linux Wayland tiling window manager on display in portrait mode. #5476

Open dzintars opened 3 years ago

dzintars commented 3 years ago

Operating System Info

Other

Other OS

Fedora 34

OBS Studio Version

27.1.3

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/dgMTPu_SLy5OCxVr

OBS Studio Crash Log URL

No response

Expected Behavior

As a user i want to see the context menu when adding new source on a Linux Wayland portrait mode display when OBS occupies full display.

Current Behavior

Dual display setup with the OBS opened on portrait mode display (full screen). Capturing primary ultra-wide screen. Fedora 34, Wayland, Sway. When clicked on + "Add Sources" the menu is not visible and goes somewhere outside of the viewport (below the viewport?). Desktop environment is configured and positioned correctly. I tried to illustrate current behavior. In a green border you can see that menu is displayed and positioned correctly, but only if there is "something" below it. Red and green is the same display, just in different layout scenarios. Frame 3 I can't check it on other environment, so it's hard to say is it a Wayland issue, desktop environments issue or other.

Steps to Reproduce

  1. Linux, Wayland desktop environment ( + potentially tiling window manager like Sway)
  2. Multi display setup with one display in portrait mode
  3. Open OBS on portrait mode display
  4. Click on "Add Source"

Anything else we should know?

Relevant config in Sway DE output 'Dell Inc. DELL U2312HM 59DJP1AQFPQL' pos 2560 0 transform 270

WizardCM commented 3 years ago

We position the menu using QCursor::pos(), so there's likely nothing we can do here - it's up to Qt and Wayland to sort it out.

https://github.com/obsproject/obs-studio/blob/c7de39830936d9e375ff9ac6d874db3700a2fc2f/UI/window-basic-main.cpp#L5431

dzintars commented 3 years ago

On the landscape (normal) display there is no such issue. But... when recording the portrait mode screen the image is turned by 270* which means... that "portrait mode" is not set/recognized correctly... this means, that context menu is also positioned incorectly. I will try to tinker with it a bit. I think i need somehow to override display size (wild guess). Frame 6

pkupper commented 3 years ago

KDEs Wayland Porting Guideline which was already linked in #5043 explicitly states that QCursor::pos() should not be used to position context menus. The provided alternative (see below) is to use the globalPos() function on the QContextMenuEvent instead.

void SomeWidget::contextMenuEvent(QContextMenuEvent* event)
{
    auto menu = new QMenu(this);
    // Wrong. It is unreliable
    QAction* action = menu->exec(QCursor::pos());
    // Good.
    QAction* action =  menu->exec(event->globalPos());
}
agausmann commented 2 years ago

Improvements are being made on the Qt side: https://bugreports.qt.io/browse/QTBUG-99618

maks commented 1 year ago

Just FYI for others coming to this issue, its not just for tiling WM's, I see this behaviour with default WM on Ubuntu 22.04 as well, note in the screenshot below the screenshot ends at the bottom of the actual screen, so the menu is getting clipped. I note that this only happens when I have scaling applied (eg. 200%), when I reset scaling back to 100%, the menu is displayed as expected.

image