Subject: Bug#872: Turn xinerama.conf file related code inside X2Go Client into legacy code (for NX agents << 3.6)

From: Mike Gabriel <[email-masked]>
Date: Fri, 15 May 2015 11:59:12 +0000

Package: x2goclient
Severity: important
Version: 4.0.4.0

Hi Uli, hi Alex,

I turn this discussion into a bug report against X2Go Client.

Short summary for Alex: Ulrich has completely revisited [2] Xinerama  
in nx-libs recently for the 3.6.x branch of nx-libs [1].

The complete Xinerama code has been rewritten and moved mainly into  
the hw/nxagent/Screen.c file, so that we can soon drop your patched  
libNX_Xinerama.so library and all that LD_LIBRARY_PATH stuff from  
x2goruncommand.

With Ulrichs work, the hacky part in X2Go Client of writing and  
continuously updating a xinerama.conf file server-side from the  
client-side becomes obsolete and should only be kepts as legacy code  
for cases where X2Go Client talks to nxagent servers << 3.6.

I'd also appreciate it if you could give feedback on the below question.

Thanks,
Mike

[1] https://github.com/ArcticaProject/nx-libs
[2] https://github.com/ArcticaProject/nx-libs/pull/23

On  Do 14 Mai 2015 23:32:03 CEST, Ulrich Sibiller wrote:

> while testing my xinerama re-implementation I noticed that x2goclient
> reports a wrong width sometimes when simply moving the window without
> changing the size. The reported size differs by one pixel  (too much
> or too little). When running x2goclient --debug you can see this:
>
> x2go-DEBUG-../src/onmainwindow.cpp:10160> "New proxy geometry: (x:
> 329, y: 214, w: 1440, h: 900"
> x2go-DEBUG-../src/onmainwindow.cpp:10160> "New proxy geometry: (x:
> 365, y: 213, w: 1440, h: 900"
> x2go-DEBUG-../src/onmainwindow.cpp:10160> "New proxy geometry: (x:
> 825, y: 190, w: 1440, h: 900"
> x2go-DEBUG-../src/sshprocess.cpp:189> executing remote command via
> SshProcess object (24): "export DISPLAY=:50;printf '\''1095 0 345
> 900\n0 0 1095 900'\'' >
> $HOME/.x2go/C-uli-50-1431636769_stDKDE_dp24/xinerama.conf"
>
> -> here the 345 should have been a 344.
>
> Interestingly my patched x2goagent (that completely ignores
> xinerama.conf) sees that value. So I conclude that x2goclient is
> manipulating the nxproxy window size by one pixel itself. Disabling
> xinerama in the session's configuration fixes the problem.
>
> That off-by-one behaviour is caused by this code in onmainwindow.cpp:
>
> void ONMainWindow::slotXineramaConfigured()
> {
>     if (resumingSession.fullscreen)
>         return;
>     if (xinSizeInc == -1)
>         xinSizeInc=1;
>     else
>         xinSizeInc=-1;
> #ifdef Q_OS_LINUX
>     lastDisplayGeometry.setWidth(lastDisplayGeometry.width()+xinSizeInc);
>     XSync(QX11Info::display(),false);
>     XResizeWindow(QX11Info::display(), proxyWinId,
>                   lastDisplayGeometry.width(),lastDisplayGeometry.height());
>     XSync(QX11Info::display(),false);
> #endif
> #ifdef Q_OS_WIN
>     QRect geom;
>     wapiWindowRect ( (HWND) proxyWinId, geom );
>     wapiMoveWindow( (HWND) proxyWinId, geom.x(), geom.y(),
> geom.width()+xinSizeInc, geom.height(),true);
>     lastDisplayGeometry=proxyWinGeometry();
> #endif
>     xineramaTimer->start(500);
> }
>
> If I set xinSizeInc to zero in all cases the off-by-one behaviour is
> completely gone. Why does xinSizeInc exist at all?

-- 

DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
fon: +49 (1520) 1976 148

GnuPG Key ID 0x25771B31
mail: [email-masked], http://das-netzwerkteam.de

freeBusy:
https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb

---

From: Mike Gabriel <[email-masked]>
Date: Mon, 18 May 2015 08:40:55 +0000

Hi Alex,
(re-adding #872 to Cc:, dropping x2go-dev instead)

(my answers in-line at end of mail text)

On  So 17 Mai 2015 08:45:57 CEST, Oleksandr Shneyder wrote:

> Am 15.05.2015 um 13:59 schrieb Mike Gabriel:
>> Package: x2goclient
>> Severity: important
>> Version: 4.0.4.0
>>
>> Hi Uli, hi Alex,
>>
>> Short summary for Alex: Ulrich has completely revisited [2] Xinerama in
>> nx-libs recently for the 3.6.x branch of nx-libs [1].
>>
>> The complete Xinerama code has been rewritten and moved mainly into the
>> hw/nxagent/Screen.c file, so that we can soon drop your patched
>> client-side becomes obsolete and should only be kepts as legacy code for
>> cases where X2Go Client talks to nxagent servers << 3.6.
>>

> It's a great news. Do we need to make a changes in the X2Go Client for

X2Go Client needs to test the remote x2goagent version and check  
whether it is << 3.5.99.0 or >= 3.5.99.0. If it is >= 3.5.99.0, the  
new Xinerama support will be present (once we have released 3.5.99.0,  
at the moment the code has not been merged). If the new Xinerama code  
is present, then there is no need for the xinerama.conf server-side  
writing/updating anymore.

> this? I think it should be sufficient to make changes in x2goruncommand.

I think that too, see X2GoBTS #873 [1].

> Should user still have possibility to turn Xinerama off? I can still

This is a good question. I don't think that we should include the  
xinerama.conf part in nxagent anymore, but a way for switching off the  
Xinerama extension should be possible, indeed.

The current plan is to make the cmdline options +xinerama / -xinerama  
(or -extension Xinerama) functional in nxagent. With all previous  
versions of nxagent, this did not have any effect, so far. Ulrich is  
working on that.

> imagine the use case when user have an x2goagent window in the middle of
> two physical monitors but want to see agent window as one display.

Indeed.

> regards
> Alex

Mike

[1] https://bugs.x2go.org/cgi-bin/bugreport.cgi?bug=873
-- 

DAS-NETZWERKTEAM

GnuPG Key ID 0x25771B31

freeBusy:

---

From: Oleksandr Shneyder <[email-masked]>
Date: Mon, 18 May 2015 11:23:06 +0200

ok, let's wait till this feature is available in nxagent and I'll put
support for it in x2go client.

regards,
Alex

Am 18.05.2015 um 10:40 schrieb Mike Gabriel:
> X2Go Client needs to test the remote x2goagent version and check whether
> it is << 3.5.99.0 or >= 3.5.99.0. If it is >= 3.5.99.0, the new Xinerama
> support will be present (once we have released 3.5.99.0, at the moment
> the code has not been merged). If the new Xinerama code is present, then
> there is no need for the xinerama.conf server-side writing/updating
> anymore.
> 

-- 
-----------------------------------------------------------
Oleksandr Shneyder        | Email: [email-masked]
phoca GmbH                | Tel. : 0911 - 14870374 0
Ludwig-Feuerbach-str. 18  | Fax. : 0911 - 14870374 9
D-90489 Nürnberg          | Mobil: 0163 - 49 64 461

Geschäftsführung:
Dipl.-Inf. Oleksandr Shneyder

Amtsgericht München | http://www.phoca-gmbh.de
HRB 196 658         | http://www.x2go.org
USt-IdNr.: DE281977973
-----------------------------------------------------------

---

From: Ulrich Sibiller <[email-masked]>
Date: Mon, 18 May 2015 13:28:49 +0200

> support for it in x2go client.

Ok. But can you please explain the reason for that off-by-one window
size code I found (see below)?

>>>>> completely gone. Why does xinSizeInc exist at all?

Uli

---

From: Oleksandr Shneyder <[email-masked]>
Date: Mon, 18 May 2015 15:41:12 +0200

Hi Ulrich,

yes, if you moving window between two physical displays, without
resizing it, x2goagent doesn't know, that display configuration is
changed, because geometry of the x2goagent stays same. So I resized a
window to refresh a display configurations.

regards,
Alex

Geschäftsführung:

---

From: Ulrich Sibiller <[email-masked]>
Date: Mon, 18 May 2015 21:01:31 +0200

> window to refresh a display configurations.

Why does nxagent/x2goagent need know about that? In the current
solution with xinerama.conf I don't see why x2goagent should be
informed in this case. And if it really needs to know, this patch
_should_ help (I have not tested this patch alone):

https://github.com/uli42/nx-libs/commit/61018cd39d02fbda1f2f766d8320c53866fa55d3

Uli

---

From: Oleksandr Shneyder <[email-masked]>
Date: Tue, 19 May 2015 10:09:54 +0200

Imagine that you have agent window in the middle of two screens. Window
size is 1024x768. You current displays configuration in that case is:
left-512x768, right-512x768. Imagine, that you moved your window 100 px
left. Now your displays configuration is: left-612x768, right-412x768.
But from the view of x2goagent nothing is changed, agent has no idea
about the display geometry on the client side. This is why client
updating xinerama.conf and resizing a window to apply new settings. I
hope it's understandable.

regards,
Alex

Geschäftsführung:

---

From: Ulrich Sibiller <[email-masked]>
Date: Tue, 19 May 2015 10:50:20 +0200

> hope it's understandable.

Yes, it is understandable. But this only relevant for xinerama
information. And that information is coming from the config file
(which is correctly updated in this case by x2goclient). So I still do
not see why x2goagent needs to be triggered in any way. If a software
needs to know the xinerama setup it issues a XineramaQueryScreens()
request. This is intercepted by the libNX_xinerama.so and answered
with the information from the config file. The x2goagent does not even
see this request and thus does noot need to be updated. The only
problem that your code solves might be the window manager in the
session that caches xinerama information.

Do you have a use case that does not work without the resize?

Uli

---

From: Oleksandr Shneyder <[email-masked]>
Date: Tue, 19 May 2015 10:54:05 +0200

Yes, It was exactly the problem, the different WM didn't update the
configuration without resizing.

Geschäftsführung:

---

From: Mike Gabriel <[email-masked]>
Date: Tue, 19 May 2015 08:59:24 +0000

Hi Alex,

> hope it's understandable.

This is exactly what Ulrich is working on [1]. In the first test  
builds with his patches, the nxagent window adapts the Xinerama layout  
inside the nxagent whenever nxagent is moved over the client-side  
screen area. Especially check the changes in hw/nxagent/Screen.c, and  
there the intersect() function.

With Ulrich's patches, nxagent has Xinerama support without being in  
need of a xinerama.conf file. I tested that with Python X2Go (i.e.,  
via nxproxy) and via command line session startups (i.e., all on the  
same host).

There are still some kinks we observe with several window managers,  
but I am pretty sure that those issues need to be fixed in the window  
managers (esp. MATE's window manager and also openbox).

Mike

https://github.com/ArcticaProject/nx-libs/pull/23/files
-- 

DAS-NETZWERKTEAM

GnuPG Key ID 0x25771B31

freeBusy:

---

From: Ulrich Sibiller <[email-masked]>
Date: Tue, 19 May 2015 10:59:05 +0200

> configuration without resizing.

This should be solved with the posted nxagent patch which will also be
included in my xinerama rewrite. However, I'd suggest to modify the
current x2goclient code to perform TWO resizes in order to achieve the
same configuration as before. I had situations where the window stayed
with on pixel too big or too small.

Uli

---

From: Mihai Moldovan <[email-masked]>
Date: Wed, 13 Jul 2016 06:06:16 +0200

Now that Xinerama functionality has been reimplemented in nx-libs 3.6.x, we
shall add an option to X2Go Client session configs to *disable* Xinerama.

XINERAMA is now enabled by default. We want to keep that default and not enable
this option by default in X2Go Client. This is different from the old behavior,
which defaulted to XINERAMA being off and thus had to be explicitly enabled.

Code that created and periodically updated the xinerama.conf file shall be kept
for legacy versions of nx-libs, but is not necessary with nx-libs 3.6.x anymore.

See #873 for how XINERAMA can be disabled.

Mihai

---

From: Mike Gabriel <[email-masked]>
Date: Thu, 14 Jul 2016 10:56:03 +0000

Hi Mihai,

> for legacy versions of nx-libs, but is not necessary with nx-libs  

The above can be done conditionally:

   x2gofeature X2GOAGENT_RANDRXINERAMA

should return "ok" on stdout, if the feature is present.

In Python X2Go I load the "x2gofeaturelist" on every server  
connection, so that I know what features are supported and what not.  
Note, that X2Go Client so far has not been using this  
x2gofeature(list) thingy. I wrote that for Python X2Go to be more  
flexible on the client side when it comes to new server features and  
legacy support for older servers.

Also note, that x2goserver-x2goagent for Debian was actually buggy  
regarding that new feature, see:

http://code.x2go.org/gitweb?p=x2goserver.git;a=commitdiff;h=43510ec2ddd5d0fcfbec71d32e5f9ffb992f585c

Mike

-- 

DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
mobile: +49 (1520) 1976 148
landline: +49 (4354) 8390 139

GnuPG Fingerprint: 9BFB AEE8 6C0A A5FF BF22  0782 9AF4 6B30 2577 1B31
mail: [email-masked], http://das-netzwerkteam.de