Login screen is centered between two monitors with dual head setup

Bug #693151 reported by Matt Janus on 2010-12-21
56
This bug affects 9 people
Affects Status Importance Assigned to Milestone
LTSP5
Low
Warren W Thompson

Bug Description

modified "gtkgreet/greeter.c" in ubuntu lucid's ldm source.

replace (line #473?):
gdk_drawable_get_size(root, &width, &height);

with the following:
GdkRectangle my_rect;
display = gdk_display_get_default();
screen = gdk_display_get_default_screen(display);
gdk_screen_get_monitor_geometry(screen,0,&my_rect);
width = my_rect.width;
height = my_rect.height;

description: updated
description: updated
Matt Janus (hello-mattjan) wrote :

Not sure where to post but it's semi related. I was having a problem getting the bootsplash to display with my thinclient that has an intel 945gm chipset. Disabling LVDS in pxelinux.cfg/default by adding "video=LVDS-1:d" to the command line resolves this issue for me.

Stéphane Graber (stgraber) wrote :

Hi,

Can you confirm that your patch still works with >= 2.2?

I don't have a dual-head setup around to confirm and the code was changed quite a lot (close to a full rewrite of the greeter) so I'd like to triple-check before applying the fix.

Thanks

Hi:

I have just applied this patch to LTSP running under Ubuntu 10.04.3 LTS (Lucid Lynx) and it corrected the issue perfectly on my dual-headed WYSE R50L thin clients. Here is a Web site that has some more details on the patch and a suggestion for adding an MOTD field to the LDM LTSP login : http://mattjan.us/blog/?cat=10

Warren

Changed in ltsp:
status: New → Confirmed

This problem also exists in the ldm package that is included with LTSP in Ubuntu 12.04. I am attaching a modified copy of greeter.c (Attached as greeter.c.1204) that not only places the ldm login screen on the primary display, but also centers the mouse pointer on that display.

Suco (sucotronic) wrote :

Just installed Ubuntu 12.04.4 LTSP and the error persist. To solve it follow the steps indicated by Warren:

sudo aptitude install dpkg-dev libgtk2.0-dev intltool libglib2.0-dev libtool automake
apt-get source ldm
cd ldm-2.2.9/
wget https://launchpadlibrarian.net/110513396/greeter.c.1204
cp greeter.c.1204 gtkgreet/greeter.c
sh ./autogen.sh
./configure --prefix=/usr
make
cp /opt/ltsp/amd64/usr/lib/ldm/ldmgtkgreet /opt/ltsp/amd64/usr/lib/ldm/ldmgtkgreet.bak
cp gtkgreet/ldmgtkgreet /opt/ltsp/amd64/usr/lib/ldm/
ltsp-update-image

Michael Blinn (mblinn-gmail) wrote :

But still exists in 14.04 final

Workaround:

chroot /opt/ltsp/$arch
edit /etc/ltsp/update_kernels.conf -- add "video=LVDS-1:d" after 'quiet splash'

run /usr/share/ltsp/update_kernels

exit chroot

sudo ltsp-update-kernels

map7 (map7-iinet) wrote :

Another workaround where you don't have to rebuild the kernels and will work for different thin clients is to put the XRANDR commands in the lts.conf file to turn off the second display during login

[80:EE:73:73:42:26]
        XRANDR_COMMAND_1 = "xrandr --output HDMI2 --auto --output VGA1 --off"

Then use https://github.com/gdi2k/mac2xrandr to setup your dual monitors once logged in.

Changed in ltsp:
importance: Undecided → Low

Hi:

This issue is still present with LTSP 5.5.1 and LDM 2.2.13 on Ubuntu 14.04 LTS. So, I am including a copy of greeter.c that has been updated for 14.04.

Warren

The instructions to create and install the patched copy of ldmgtkgreet posted by Suco still work, with a few minor changes:

1. sudo apt-get install dpkg-dev libgtk2.0-dev intltool libglib2.0-dev libtool automake
2. sudo apt-get source ldm
3. cd ldm-2.2.13/
4. wget https://launchpadlibrarian.net/226741553/greeter.c.1404
5. cp greeter.c.1404 gtkgreet/greeter.c
6. sh ./autogen.sh
7. ./configure --prefix=/usr LIBS=-lX11
8. make
9. cp /opt/ltsp/amd64/usr/lib/ldm/ldmgtkgreet
9. cp /opt/ltsp/amd64/usr/lib/x86_64-linux-gnu/ldm/ldmgtkgreet /opt/ltsp/amd64/usr/lib/x86_64-linux-gnu/ldm/ldmgtkgreet.bak
10. cp gtkgreet/ldmgtkgreet /opt/ltsp/amd64/usr/lib/x86_64-linux-gnu/ldm/
11. ltsp-update-image

There were changes made to greeter.c since Ubuntu 12.04 LTS, mostly related to language support. So, it would appear that this package is still being maintained. Does anyone know why they would not roll the changes that we have proposed to greeter.c in to the upstream package? Perhaps this is not the correct place to report the issue and the maintainers are unaware of the problem? Can anyone point me to a better place to get this resolved?

Thanks!

Warren

Alkis Georgopoulos (alkisg) wrote :

Hi Warren,

yes, this is the correct place to report LTSP/LDM bugs.

The idea is to replace LDM with LightDM or some other DM, that's why noone is working on it anymore.

Thanks for the patch, I'll try to arrange a dual monitor setup in order to reproduce/commit it.

ben-Nabiy Derush (bennabiy) wrote :

I tested the patch, and for the issue of the non-existant LVDS display as reported in #1 it does not fix the issue. I still get a non-centered login screen.

The fix in #6 works for me.

HP t5742 thin client.

Alkis Georgopoulos (alkisg) wrote :

Warren, there are many cosmetic changes in your patch, could you resubmit it without them?

E.g.
- custom_command = getenv(custom_env_var);
+ custom_command=getenv(custom_env_var);

- *(dest + MAXSTRSZ - 1) = '\0'; /* ensure null termination */
+ *(dest + MAXSTRSZ - 1) = '\0'; /* ensure null termination */

...which only involve spaces and wrapping, and make it hard to see the actual changes proposed.

Alkis Georgopoulos (alkisg) wrote :

Also, I had issues while compiling the following:
    Display *xdisplay = XOpenDisplay(NULL);
    Window xrootwin = XRootWindow(xdisplay, 0);
    XSelectInput(xdisplay, xrootwin, KeyReleaseMask);
    XWarpPointer(xdisplay, None, xrootwin, 0, 0, 0, 0, (width / 2), (height / 2));
    XFlush(xdisplay);
    XCloseDisplay(xdisplay);

...maybe some missing header or linker parameter there?

Hi:

I will attempt to address each of the above comments in the order that they were posted ...

ben-Nabiy, I am not sure why the greeter.c.1404 that I posted would not work for you. I have verified that I posted the correctly updated copy of greeter.c.1404 and also verified that it works on three different multi-headed thin-clients that I have access to. (WYSE Z50D, HP t610, and INTEL NUC)

Alkis, the lines that you have listed with cosmetic changes were not changed by me. I created my file based on the greeter.c file that was included in the source .deb from the Ubuntu repos. I have attached greeter.c.1404.patch to this comment that contains the specific lines that I changed.

Alkis, the code that you are having problems with centers the X mouse pointer above the username / password box. (This code was added to insure that the input text box has focus as soon as the X display is ready. It will link if you include 'LIBS=-lX11' as an argument to 'make'. (See step 7 in comment #9.) This was not necessary under Ubuntu 12.04 LTS, so I am not exactly sure what is broken / missing from the makefile.

Thank you both for working on this, it has been a speed bump that I have hit each time that I deploy a new LTSP server and I would very much like to see it fixed!

Warren

Alkis Georgopoulos (alkisg) wrote :

Thank you Warren, this looks much better, maybe the issue was between 12.04 and the version in ldm trunk:
http://bazaar.launchpad.net/~ltsp-upstream/ltsp/ldm-trunk/view/head:/gtkgreet/greeter.c

About centering the mouse, since LDM is using GDK, maybe we could use gdk_display_warp_pointer() instead of XWarpPointer()?
https://developer.gnome.org/gdk2/stable/GdkDisplay.html#gdk-display-warp-pointer

Also, the second screen stays black, wouldn't it be better if it showed some background?

Alkis Georgopoulos (alkisg) wrote :

Displaying LDM in the primary monitor isn't always what the user will want. His primary monitor might be the one that is turned off, and the (active) secondary monitor then will only display a black background, making it very hard for him to log in.

Instead of patching LDM, another idea is to modify the /usr/share/ltsp/xinitrc.d/I10-xrandr script, so that it autodetects and runs something like:
xrandr --output LVDS1 --auto --scale 1x1 --output VGA1 --auto --same-as LVDS1 --scale-from 1400x1050
...where 1400x1050 is the primary (LVDS1 in this case) monitor resolution.

The result will be a perfectly stretched cloned output, so that the user will be able to see LDM centered in all monitors and use any one of them to login.
He can then keep using that arrangement inside the user session if he likes (which is a very good default when e.g. using a projector to show the teacher screen, even if they have different resolutions), or he could use the gnome monitor control panel to arrange them however he wants.

I'm going to implement that ^ method and discard the proposed LDM patch if there are no objections.

That seems reasonable, but I have a couple questions about this approach ...

1. Can the /usr/share/ltsp/xinitrc.d/I10-xrandr script be made generic enough to determine the correct names of the output devices? For instance, between all of the various thin clients that I have, the xrandr output devices range in name from 'VGA-X', 'DisplayPort-X', 'DVI-X', 'DP-X', 'HDMI-X', etc. (It seems to be dependent on the driver being used and the release of xrandr.)

2. I have a few clients with four heads, so having the login dialog displayed on all four heads simultaneously may be a bit visually odd. (I think it would look weird on even two heads.) If we move to this approach, would we also have to use an approach like comment #7 mentions above using mac2xrandr to disable / re-enable the displays before / after login?

Alkis Georgopoulos (alkisg) wrote :

1) Sure, it's easy to get the output names.

2a) I'm not sure what the purpose of mac2xrandr is. lts.conf supports defining custom xrandr modes etc by mac address. Does mac2xrandr do the same thing? Does it extent it to per user AND per mac address layouts? If so, I think that scripts that run in the user account after login should be done in a more generic way, not like that.

2b) You are right, I didn't think of this scenario:
A sysadmin wants to use XRANDR_* to set up a non-cloned display, with e.g. LVDS1 as the primary monitor and VGA1 as --right-of LVDS1. He wants to do that for all users, not for each user separately from the gnome monitors dialog.
My proposed solution in this case is not appropriate, it would either do nothing, or it would need to change the xrandr layout two times, one before and one after login like you said, which isn't nice.

So yup I agree that by default, no xrandr commands should be ran, and LDM should do whatever it can without relying on clones etc.

Could you replace the X11 calls to center the mouse with GDK calls? If not, I'll see if I can do it myself next week.

Cheers,
Alkis

Hi Alkis:

Yes, I can replace the X11 calls with the GDK calls. I may not be able to get to it until Monday though.

Warren

Here is the patch without the X11 calls. Additionally, the 'LIBS=-lX11' is no longer necessary when running './configure'.

Alkis Georgopoulos (alkisg) wrote :

Warren, thank you for the patch, but it doesn't apply against the current ldm.
Maybe you used some older Ubuntu ldm version instead of the upstream one?

Could you please rebase it using the version from ldm-trunk? Download and start from this:
http://bazaar.launchpad.net/~ltsp-upstream/ltsp/ldm-trunk/view/head:/gtkgreet/greeter.c

Alkis Georgopoulos (alkisg) wrote :

Warren, any progress on this?
(I'm pinging in case you didn't get the notification email from launchpad...)

Hi Alkis. My apologies for this taking so long. Here is the patch file generated against the copy of greeter.c from the 'trunk'.

Alkis Georgopoulos (alkisg) wrote :

Hi Warren! I tested the patch and it works fine, except for the following:

My test client was a laptop (LVDS) with an external monitor (VGA).
LDM showed up in VGA.
After login, the gnome menu showed up in LVDS.
This would confuse users. I believe it happens because the patch is not using the primary monitor (gdk_screen_get_primary_monitor), but it has monitor "0" hardcoded there.

Nevertheless the patch is better than what we have now, so if you don't want to spend some time to make it use the primary monitor, I'll commit it anyway in a couple of days. Thanks!

Alkis Georgopoulos (alkisg) wrote :

Thank you all, fix committed in http://bazaar.launchpad.net/~ltsp-upstream/ltsp/ldm-trunk/revision/1587.

Note that it's using the default monitor (0) to align LDM instead of the primary monitor.
This will be fine in some cases, but it will be worse than what we had in other cases:
Suppose LDM shows up in a projector that is turned off, and the user is looking at a completely blank screen at his VGA display. He won't realize that LDM is running, he'll think that Xorg doesn't load at all.

So it'd be nice if someone made this to work with the primary monitor instead of the default monitor.

Changed in ltsp:
status: Confirmed → Fix Committed
Walter (fullcircle01) wrote :

would be ideal if login screen was mirrored across all attached displays

Alkis Georgopoulos (alkisg) wrote :

Fix released in LDM 2.2.18.

Changed in ltsp:
assignee: nobody → Warren W Thompson (warren-w-thompson)
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers