Merge lp:~muktupavels/unity-greeter/add-primary-monitor-support into lp:unity-greeter

Proposed by Alberts Muktupāvels
Status: Merged
Approved by: Robert Ancell
Approved revision: 1102
Merged at revision: 1145
Proposed branch: lp:~muktupavels/unity-greeter/add-primary-monitor-support
Merge into: lp:unity-greeter
Diff against target: 45 lines (+12/-2)
1 file modified
src/main-window.vala (+12/-2)
To merge this branch: bzr merge lp:~muktupavels/unity-greeter/add-primary-monitor-support
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Robert Ancell Approve
Review via email: mp+202627@code.launchpad.net

Commit message

Add primary monitor support

Description of the change

In unity-greeter my monitor order was different from desktop session. Found
that I can copy ~/.config/monitors.xml to /var/lib/lightdm/.config/monitors.xml.

Now my monitors order is same in unity-greeter and desktop session, but primary
monitor is not respected. This commit will fix that.

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

The primary variable being added to the Monitor structure seems redundant - instead why not just have?

    private List<Monitor> monitors;
    private Monitor? primary_monitor;

...

    primary_monitor = null;

...

        var monitor = new Monitor (geometry.x, geometry.y, geometry.width, geometry.height)
        monitors.append (monitor);
        if (primary_monitor == null || i == primary)
            primary_monitor = monitor;

Otherwise logic looks good

review: Needs Fixing
1102. By Alberts Muktupāvels

Update

Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

Updated as you asked.

Revision history for this message
Robert Ancell (robert-ancell) :
review: Approve
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Thanks Alberts!

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)
Revision history for this message
LukeKendall (luke-zeta) wrote :

Thanks, I had the same problem on a desktop system with dual monitors (connected via HDMI and DVI). Primary monitor was HDMI when logged in, but before login, the authentication panel was plugged in to the 2nd display (which I normally have turned off). Which makes sense: how would the system know which user's monitors.xml file to use, before login?

BTW, it might be a good idea in a multi-monitor system, to choose the monitor that's powered on, rather than one that's powered off, to present tyhe login panel on. Just a thought.

luke

Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

On Wed, Jul 16, 2014 at 5:58 AM, LukeKendall <email address hidden> wrote:

> Thanks, I had the same problem on a desktop system with dual monitors
> (connected via HDMI and DVI). Primary monitor was HDMI when logged in, but
> before login, the authentication panel was plugged in to the 2nd display
> (which I normally have turned off). Which makes sense: how would the
> system know which user's monitors.xml file to use, before login?
>

System does not know it. It will use /var/lib/lightdm/.config/monitors.xml
if you create it. You can copy your configuration file
/home/[user]/.config/monitors.xml to /var/lib/lightdm/.config/ if you want.

> BTW, it might be a good idea in a multi-monitor system, to choose the
> monitor that's powered on, rather than one that's powered off, to present
> tyhe login panel on. Just a thought.
>

You could try open new bug for that. I don't know how to detect if monitor
is powered on or off.

Revision history for this message
Christian González (droetker) wrote :

For reference, the bug seems to be here: https://bugs.launchpad.net/lightdm-gtk-greeter/+bug/813566

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main-window.vala'
2--- src/main-window.vala 2014-01-07 01:53:04 +0000
3+++ src/main-window.vala 2014-02-27 05:09:49 +0000
4@@ -24,6 +24,7 @@
5 public MenuBar menubar;
6
7 private List<Monitor> monitors;
8+ private Monitor? primary_monitor;
9 private Monitor active_monitor;
10 private Background background;
11 private Gtk.Box login_box;
12@@ -181,8 +182,11 @@
13
14 private void monitors_changed_cb (Gdk.Screen screen)
15 {
16+ int primary = screen.get_primary_monitor ();
17 debug ("Screen is %dx%d pixels", screen.get_width (), screen.get_height ());
18 monitors = new List<Monitor> ();
19+ primary_monitor = null;
20+
21 for (var i = 0; i < screen.get_n_monitors (); i++)
22 {
23 Gdk.Rectangle geometry;
24@@ -190,13 +194,19 @@
25 debug ("Monitor %d is %dx%d pixels at %d,%d", i, geometry.width, geometry.height, geometry.x, geometry.y);
26
27 if (monitor_is_unique_position (screen, i))
28- monitors.append (new Monitor (geometry.x, geometry.y, geometry.width, geometry.height));
29+ {
30+ var monitor = new Monitor (geometry.x, geometry.y, geometry.width, geometry.height);
31+ monitors.append (monitor);
32+
33+ if (primary_monitor == null || i == primary)
34+ primary_monitor = monitor;
35+ }
36 }
37
38 background.set_monitors (monitors);
39 resize (screen.get_width (), screen.get_height ());
40 move (0, 0);
41- move_to_monitor (monitors.nth_data (0));
42+ move_to_monitor (primary_monitor);
43 }
44
45 /* Check if a monitor has a unique position */

Subscribers

People subscribed via source and target branches