hyprwm / Hyprland

Hyprland is a highly customizable dynamic tiling Wayland compositor that doesn't sacrifice on its looks.

Home Page:https://hyprland.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mouse cursor not forced to the center in Minecraft GUIs

LivingCodeX opened this issue · comments

Hyprland Version

System/Version info
Hyprland, built from branch  at commit d72ea5f2a7fdb0d0a7bf914412327195b05199b0  ().
Date: 2024-03-02
Tag:

flags: (if any)


System Information:
System name: Linux
Node name: nixos-pc
Release: 6.6.24
Version: #1-NixOS SMP PREEMPT_DYNAMIC Wed Apr  3 13:29:04 UTC 2024


GPU information:
0a:00.0 VGA compatible controller [0300]: NVIDIA Corporation TU106 [GeForce RTX 2060 Rev. A] [10de:1f08] (rev a1) (prog-if 00 [VGA controller])


os-release: ANSI_COLOR="1;34"
BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"
BUILD_ID="24.05.20240403.fd281bd"
DOCUMENTATION_URL="https://nixos.org/learn.html"
HOME_URL="https://nixos.org/"
ID=nixos
IMAGE_ID=""
IMAGE_VERSION=""
LOGO="nix-snowflake"
NAME=NixOS
PRETTY_NAME="NixOS 24.05 (Uakari)"
SUPPORT_URL="https://nixos.org/community.html"
VERSION="24.05 (Uakari)"
VERSION_CODENAME=uakari
VERSION_ID="24.05"


plugins:

Bug or Regression?

Regression

Description

This regression happened after merging #4889 in commit d72ea5f.

When opening any GUI in Minecraft, the mouse cursor is not forced to the center of the screen.

Instead in full-screen mode, the cursor either appears in the position the mouse was moved to while looking around or it is forced to the bottom right corner of the screen specifically when moving the mouse any distance towards the top left while opening the GUI. Moving the mouse exclusively upwards or to the left while opening the GUI doesn't force it to the bottom right corner but keeps it in the position where it was moved to.

For example, when closing and reopening an inventory and the mouse hasn't been moved meanwhile, the cursor will still be in exactly the same position and not centered. If the player turned to the right before reopening the inventory, the cursor will appear to the right of the last position.

In windowed mode, the cursor is always forced to the bottom right corner of the game window when opening any GUI.

How to reproduce

  1. Enter a Minecraft world
  2. Look around
  3. Open your inventory

The cursor will not be centered.

Crash reports, logs, images, videos

No response

Your build is from before at least one commit that fixed some lingering mouse issues, is it still happening on master? I believe the bug you're describing was fixed with 335506d.
I've just tested it on a much more recent build and the mouse is centering whenever I open the inventory as intended.

It is still happening on master (582d623).

I think I know why this is happening but I'm not sure how to fix it in a clean way.

I use a 4K monitor and apply a scale of 2 in hyprland.conf. I also set xwayland.force_zero_scaling=true, so that xwayland apps aren't blurry.

However, because Minecraft runs under xwayland, this makes Minecraft in full-screen mode think that the screen is 4K and not 1080p and so it wants to warp the cursor to x=1920 and y=1080 (which it thinks is the center of the screen), which doesn't work because for wlr it's just barely over the edge of the screen and so it does nothing.

This could be fixed by dividing m_vPositionHint by m_pOwner->m_fLastScale in src/desktop/Constraint.cpp:CConstraint::onCommit().

I feel like this won't work for native wayland apps, but I'm not sure. Maybe only apply the scale for xwayland apps when xwayland.force_zero_scaling=true is set?

Any thoughts about this?