! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
xfwm4 & Citrix: window placement vs RandR primary monitor
Status:
RESOLVED: FIXED

Comments

Description Jason Plum 2016-05-24 22:27:51 CEST
Let me state first, that I have only replicated this with Citrix Receiver and Wfica_Seamless (class name) application windows. (https://www.citrix.com/products/citrix-cloud/try.html)

Problem:
Citrix wfica in seamless application mode, attempts to create a window on the RandR primary monitor. However, if the RandR primary monitor is not the bottom-most & right-most in the display configuration, xfwm4 can cause the window to be drawn on an alternate monitor based on mouse cursor activity (location). The end result is that the application is drawn (with Xv) onto the non-primary monitor, based on the coordinates and size of the RandR primary. The window is drawn on this alternate monitor, and while keyboard input is transmitted when this window is active, mouse is not as the cursor coordinates do not line up.

This can be resolved by hide/minimizing the window and restoring after ~1 second.

Our only workaround at this point is to ensure that the bottom-most, right-most monitor is set as RandR primary.

I suspect that this is related to either https://bugzilla.xfce.org/show_bug.cgi?id=9351 or https://bugzilla.xfce.org/show_bug.cgi?id=8866

I have confirmed that this occurs in 4.10.x, and 4.12.x in our own Yocto based distribution, Xubuntu 14.04, Xubuntu 16.04, Arch Linux (fully up to date). I have tried fiddling with xfwm4-tweak-settings Placement & Focus to no avail.
Comment 1 Jason Plum 2016-05-24 22:37:28 CEST
I should also add, this has been confirmed to not be an issue on openbox, kde, gnome
Comment 2 Olivier Fourdan editbugs 2016-05-25 08:09:22 CEST
Yes, this is likely related to bug 9351, as gtk+ reorders the monitors putting primary first and then based on decreasing size, and xfwm4 uses the gtk+ order instead of the XRandR order.

Yet you mention that the result depends on the mouse cursor location? That's odd, because the only case where xfwm4 would do that is when the client doesn't specify a location.

Note: I am not really willing to put my details, register and install proprietary software on my laptop, so ideally a simple reproducer would be better.
Comment 3 Jason Plum 2016-05-25 15:58:12 CEST
Citrix -- I can provide an account, as we are a Citrix partner, however I can not post such account in the ticket details.

Mouse position -- Yes, it is tied to the mouse position. As for window position, I don't know exactly how citrix does it, but I make a small assumption that it may providing a window with a small size, and allowing the window manager to do placement, which might be tripping smart placement.
Comment 4 Jason Plum 2016-05-25 21:09:34 CEST
Created attachment 6670 
xprop output of misplaced Citrix_Seamless window
Comment 5 Jason Plum 2016-05-25 21:11:12 CEST
Created attachment 6671 
xwininfo output of misplaced window
Comment 6 Jason Plum 2016-05-25 21:31:36 CEST
Created attachment 6672 
xwininfo output of misplaced window
Comment 7 Jason Plum 2016-05-25 21:32:23 CEST
Created attachment 6673 
xwininfo output of misplaced windows parent
Comment 8 Jason Plum 2016-05-25 21:32:51 CEST
Created attachment 6674 
xprop output of misplaced Citrix_Seamless window Excel
Comment 9 Olivier Fourdan editbugs 2016-05-26 09:43:45 CEST
From the captures, it shows that it's definitely not fullscreen so not related to bug 9351 (we kinda knew that since you mentioned that the behavior depends on the mouse pointer location).

The window is maximized though:

  _NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT


Motif hints tell us it's not decorated by the WM:

_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x0, 0x0, 0x0

The applications expects the window to be placed in 0,31:

WM_NORMAL_HINTS(WM_SIZE_HINTS):
		program specified location: 0, 31
		program specified size: 1920 by 1000

So my guess is you have a pretty default xfce setup with the panel on top (thus y=31).

This is also seen in the xprop:

 Normal window size hints:
      Program supplied location: 0, 31
      Program supplied size: 1920 by 1000

However the window is actually placed on the other monitor:

  Corners:  +1920+31  -0+31  -0-180  +1920-180

Basically, the application asked for its window to be maximized in (0,31) but the WM places it on (1920,31).

The WM might have good reasons not to grant the requested location (and is absolutely free to  do so) and the app should adapt (it receives a configure notification with the actual location, it should use it).

So, for now, I'm leading toward a bug in the application (Citrix) which wrongly assume a window location.

To be sure, can you please post the output of "xrandr" in that particular setup?
Comment 10 Jason Plum 2016-05-26 15:58:54 CEST
Created attachment 6675 
xrandr output of problem case
Comment 11 Jason Plum 2016-05-26 16:00:07 CEST
I wonder:
- Why it is that this is not an issue on other WM
- What messages or hints are delivered to cause the window to be relocated when minimized and then restored.
Comment 12 Olivier Fourdan editbugs 2016-05-26 16:17:28 CEST
(In reply to Jason Plum from comment #10)
> Created attachment 6675 
> xrandr output of problem case

DP3 connected 1440x900+1920+0 (normal left inverted right x axis y axis) 408mm x 255mm
HDMI1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 476mm x 268mm

So you have a 1920x1080 monitor on the left and a 1440x900 on the right next to it.

The monitor on the left is at (0,0) so the requested position of (0,31) falls within that one, and yet the WM maximizes the window on the monitor on the right:

  Absolute upper-left X:  1920
  Absolute upper-left Y:  31
  Width: 1440
  Height: 869

I wonder why. Could you please capture the xprop of the misplaced window's parent as well?

(In reply to Jason Plum from comment #11)
> I wonder:
> - Why it is that this is not an issue on other WM

Different window managers may have different placement policies.

> - What messages or hints are delivered to cause the window to be relocated
> when minimized and then restored.

That's something that could be found in the client's (Citrix) source code, I cannot tell.
Comment 13 Jason Plum 2016-05-26 16:27:59 CEST
The parent's xprop is empty.
Comment 14 Olivier Fourdan editbugs 2016-05-26 16:46:27 CEST
Would you be able to rebuild xfwm4 from sources to try a patch?
Comment 15 Olivier Fourdan editbugs 2016-05-26 17:01:25 CEST
Sorry, just to clarify, I didn't mean that in a bad way, I meant willing to rather than able to (installing all the deps to build from source can be time consuming, not everyone may have the will to do it)
Comment 16 Jason Plum 2016-05-26 17:06:47 CEST
I can, and will.

I am attaching two x11trace logs. One from openbox and one from xfwm4.
Comment 17 Jason Plum 2016-05-26 17:08:15 CEST
Created attachment 6676 
x11trace xfwm4

x11trace (xtrace) logs for wfica (Citrix) application on xfwm4 for comparison against what occurred in openbox.

This includes the re-positioning via minimize/restore.
Comment 18 Jason Plum 2016-05-26 17:10:07 CEST
Created attachment 6677 
x11trace openbox

x11trace (xtrace) of wfica on openbox for comparison against xfwm.

This does not include minimize/restore
Comment 19 Jason Plum 2016-05-26 18:13:27 CEST
Final & problematic window is created @
- L5229 of xfwm x11trace
- L5770 of openbox x11trace
Comment 20 Olivier Fourdan editbugs 2016-05-26 19:14:24 CEST
Created attachment 6678 
[PATCH] client: Make sure we use pre-ICCCM fields

Does this patch make any difference?
Comment 21 Jason Plum 2016-05-26 19:54:12 CEST
I applied this to 4.12.3, with a small alteration at add the `clientGetMWMHints (c, TRUE);` in clientFrame.

The result is mixed.
- dialogs from wfica get thrown to the corners of the diaply on which the mouse is located. (-1)
- The final window draws onto the display on which the mouse is located (+1)
- The size of the final window matches the display on which the mouse is located (+1)
- The mouse input is properly accepted by the final window (+1)
- From maximized, Restore will relocate the final window to the Primary display. (-1), though input follows correctly (+1)
- Minimize and Restore of the final window will result in the window being relocated to the Primary display (-1)
Comment 22 Olivier Fourdan editbugs 2016-05-26 21:01:52 CEST
(In reply to Jason Plum from comment #21)
> I applied this to 4.12.3, with a small alteration at add the
> `clientGetMWMHints (c, TRUE);` in clientFrame.
> [...]

Nope, please try without any other change, changing the param is wrong here.
Comment 23 Jason Plum 2016-05-26 21:16:01 CEST
The patch does not otherwise apply to the 4.12.3 release. I will simply remove the line entirely.
Comment 24 Jason Plum 2016-05-26 21:20:48 CEST
Removing that edit:
- final window behavior is the same (-1)
- dialogs are still thrown to corners (-1)
Comment 25 Olivier Fourdan editbugs 2016-05-26 22:33:00 CEST
(In reply to Jason Plum from comment #24)
> Removing that edit:
> - final window behavior is the same (-1)
> - dialogs are still thrown to corners (-1)

Sorry, I'm getting confused, could you please attach the source file client.c from your build with the patch applied?
Comment 26 Jason Plum 2016-05-26 23:43:47 CEST
Created attachment 6679 
post-patch client.c

http://git.xfce.org/xfce/xfwm4/tree/src/client.c?id=xfwm4-4.12.3#n1664
Comment 27 Olivier Fourdan editbugs 2016-05-27 10:44:00 CEST
Comment on attachment 6678 
[PATCH] client: Make sure we use pre-ICCCM fields

(In reply to Jason Plum from comment #26)
> Created attachment 6679 
> post-patch client.c

Oh right, my bad, I didn't realize master was so different from 4.12 in this regard. Let's forget about this patch then.
Comment 28 Olivier Fourdan editbugs 2016-05-27 10:53:47 CEST
Created attachment 6680 
[PATCH] placement: Don't relocate on monitor if position is specificed

Could you please try this one instead (simply discard the previous changes, try this patch alone)?
Comment 29 Jason Plum 2016-05-27 15:59:44 CEST
Dialogs always result @ 1921,201 and final window ends up with Primary display geometry, but right,bottom-most Display
Comment 30 Olivier Fourdan editbugs 2016-05-27 17:53:25 CEST
Created attachment 6682 
[PATCH] placement: Relocate dialogs only

Can you try this patch instead?

That should nail it...
Comment 31 Jason Plum 2016-05-27 19:01:21 CEST
At least here, not quite. Dialogs behave as expected. Final windo still on non-primary display, though geometry is more accurate to the size of the display the mouse is/was on, it is not on the correct (primary) display.
Comment 32 Olivier Fourdan editbugs 2016-05-28 10:56:35 CEST
(In reply to Jason Plum from comment #31)
> At least here, not quite. Dialogs behave as expected. Final windo still on
> non-primary display, though geometry is more accurate to the size of the
> display the mouse is/was on, it is not on the correct (primary) display.

That's with attachment 6682  alone applied, not with any of the previous patches, right?

This is weird, it behaves correctly here...
Comment 33 Jason Plum 2016-05-29 22:20:09 CEST
Yes, only your last attachment.
Comment 34 Jason Plum 2016-06-01 22:54:09 CEST
Do you have your Primary display set to the left-most?
Comment 35 Olivier Fourdan editbugs 2016-06-03 16:49:58 CEST
(In reply to Jason Plum from comment #34)
> Do you have your Primary display set to the left-most?
Yeap, tried with all sort of different resolutions, layouts, etc. it worked fine in all cases here...
Comment 36 Jason Plum 2016-06-03 16:56:04 CEST
What method might I be able to use to show you the state of this system where the problem is occurring?
Comment 37 Olivier Fourdan editbugs 2016-06-03 17:43:30 CEST
Created attachment 6691 
Updated patch with logs

Can you try the following:

1. Start from a clean, un-patched, freshly downloaded source tree
2. Apply the (new) patch attached and rebuild
3. From the source tree, re-start the new xfwm4 with:

   ./src/xfwm4 --replace &

4. Reproduce the issue and attach the messages that xfwm4 will print on the terminal
Comment 38 Jason Plum 2016-06-03 18:15:07 CEST
On which branch of the source tree?

Currently I have been patching with modification to : https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/xfwm4

Getting the source tarball from http://archive.xfce.org/src/xfce/xfwm4/4.12/xfwm4-4.12.3.tar.bz2)
Comment 39 Jason Plum 2016-06-03 18:46:33 CEST
Success! This does indeed appear to apply & Fix the issue.
Comment 40 Olivier Fourdan editbugs 2016-06-14 14:58:38 CEST
Patch pushed to git, closing.

Bug #12587

Reported by:
Jason Plum
Reported on: 2016-05-24
Last modified on: 2016-06-14

People

Assignee:
Olivier Fourdan
CC List:
0 users

Version

Version:
unspecified

Attachments

xprop output of misplaced Citrix_Seamless window (2.34 KB, text/plain)
2016-05-25 21:09 CEST , Jason Plum
no flags
xwininfo output of misplaced window (1.76 KB, text/plain)
2016-05-25 21:11 CEST , Jason Plum
no flags
xwininfo output of misplaced window (1.76 KB, text/plain)
2016-05-25 21:31 CEST , Jason Plum
no flags
xwininfo output of misplaced windows parent (2.18 KB, text/plain)
2016-05-25 21:32 CEST , Jason Plum
no flags
xprop output of misplaced Citrix_Seamless window Excel (2.34 KB, text/plain)
2016-05-25 21:32 CEST , Jason Plum
no flags
xrandr output of problem case (1.44 KB, text/plain)
2016-05-26 15:58 CEST , Jason Plum
no flags
x11trace xfwm4 (752.91 KB, text/plain)
2016-05-26 17:08 CEST , Jason Plum
no flags
x11trace openbox (816.06 KB, text/plain)
2016-05-26 17:10 CEST , Jason Plum
no flags
[PATCH] client: Make sure we use pre-ICCCM fields (2.43 KB, patch)
2016-05-26 19:14 CEST , Olivier Fourdan
no flags
post-patch client.c (112.93 KB, text/x-csrc)
2016-05-26 23:43 CEST , Jason Plum
no flags
[PATCH] placement: Don't relocate on monitor if position is specificed (1.44 KB, patch)
2016-05-27 10:53 CEST , Olivier Fourdan
no flags
[PATCH] placement: Relocate dialogs only (2.91 KB, patch)
2016-05-27 17:53 CEST , Olivier Fourdan
no flags
Updated patch with logs (5.52 KB, patch)
2016-06-03 17:43 CEST , Olivier Fourdan
no flags

Additional information