Bug 254908

Summary: net/freerdp: mouse dragging broken in 2.3.2
Product: Ports & Packages Reporter: Felix Palmen <felix>
Component: Individual Port(s)Assignee: Tobias C. Berner <tcberner>
Status: Closed FIXED    
Severity: Affects Only Me CC: leres, sascha.folie, tcberner, vvd
Priority: --- Flags: vvd: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
0001-net-freerdp-add-workaround-for-focus-bug-of-WM.patch none

Description Felix Palmen 2021-04-09 08:29:54 UTC
OS: FreeBSD 13.0-RC5 amd64

Package: freerdp-2.3.2

Build options:
	ALSA           : off
	CUPS           : on
	FAAC           : on
	FAAD           : on
	FFMPEG         : on
	GSM            : on
	GSTREAMER      : on
	ICU            : on
	KERBEROS       : on
	LAME           : off
	MANPAGES       : on
	OPENH264       : on
	PCSC           : off
	PULSEAUDIO     : off
	SOXR           : off
	SSE            : on
	WAYLAND        : on
	X11            : on

Remote OS: Windows Server 2016

Symptom:
Simple mouse clicks work as expected, dragging something, e.g. windows (left mouse button held) does not work. Also, multi-selection with <ctrl>+<left mouse button> does not work.

Downgrading to 2.2.0_3 fixes this problem.
Comment 1 VVD 2021-04-09 10:03:09 UTC
(In reply to Felix Palmen from comment #0)
If it's upstream bug, then better report it here: https://github.com/FreeRDP/FreeRDP/issues
Comment 2 Felix Palmen 2021-04-09 10:55:22 UTC
Well, I can't be *sure* it's an upstream problem, but it seems likely, so here's the upstream issue for this:

https://github.com/FreeRDP/FreeRDP/issues/6948
Comment 3 VVD 2021-08-16 18:17:16 UTC
Please test with patch from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254914.
Comment 4 Felix Palmen 2021-08-17 13:00:19 UTC
(In reply to VVD from comment #3)
Tested, but mouse dragging is still broken with my remote Windows Server 2016.
Comment 5 Felix Palmen 2021-09-02 13:18:08 UTC
Update: The change that lead to this problem was finally identified here: https://github.com/FreeRDP/FreeRDP/issues/6948#issuecomment-910487696

Unfortunately, it's a change fixing other things and (see further discussion over there) the real problem seems to be that some window managers under some circumstances unfocus the window (and directly focus it again). Most certainly, this WM behavior is incorrect.

I'll now try to find out which configuration makes fvwm behave that way. But for this bug here, I assume it can be closed, as a "fix" in FreeRDP doesn't seem to be the correct way.
Comment 6 VVD 2021-09-02 18:46:33 UTC
(In reply to Felix Palmen from comment #5)
It's possible to create optional patch - option BROKEN_WM_MOUSE_FIX default off.
For me in KDE it work fine without patch.
Comment 7 Felix Palmen 2021-09-04 09:51:27 UTC
Created attachment 227657 [details]
0001-net-freerdp-add-workaround-for-focus-bug-of-WM.patch

(In reply to VVD from comment #6)

Sure, I'm attaching a possible commit to do just that. I don't know whether it's a good idea. Several people are affected, see upstream issue, but the workaround has its own problems and the real reason is strange WM behavior. Well, you decide ;)
Comment 8 VVD 2021-09-04 10:49:14 UTC
Comment on attachment 227657 [details]
0001-net-freerdp-add-workaround-for-focus-bug-of-WM.patch

Your patch look good for me.
Comment 9 Felix Palmen 2021-09-04 11:01:51 UTC
(In reply to VVD from comment #8)

Thanks! There's a somewhat lengthy commit message in it, explaining the details (get it by applying the patch with `git am`). I hope together with the reference to this PR in the option description, this would be good enough for everyone to decide whether they really need this optional patch.

Still, as soon as I find the time, I'll try to analyze the circumstances at least for fvwm that lead to this misbehavior. It would really be better to solve the root cause ;)
Comment 10 commit-hook freebsd_committer 2021-09-04 11:21:02 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ce0e0139a4eea8fb76d6a49558903f7a9653c574

commit ce0e0139a4eea8fb76d6a49558903f7a9653c574
Author:     Felix Palmen <felix@palmen-it.de>
AuthorDate: 2021-09-04 09:31:06 +0000
Commit:     Tobias C. Berner <tcberner@FreeBSD.org>
CommitDate: 2021-09-04 11:16:14 +0000

    net/freerdp: add workaround for focus bug of WM

    Some WMs (for example fvwm and fluxbox) intermittently steal focus
    during attempts to drag something with the mouse on the remote machine,
    effectively making it impossible to drag. This behavior seems to also
    depend on the configuration of the WM.

    Add an optional patch to work around this problem, activated by the new
    option BROKENFOCUS. Note that this workaround may lead to a wrong state
    of keyboard modifiers after focus changes, so only enable if if you
    really need to.

    PR:     254908
    Approved by:    VVD <vvd@unislabs.com> (maintainer)

 net/freerdp/Makefile                              |  8 ++++++--
 net/freerdp/files/extra-patch-focusbug.diff (new) | 10 ++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)
Comment 11 Tobias C. Berner freebsd_committer 2021-09-04 11:24:17 UTC
Committed. Thanks.