[gdm/wip/multi-seat-2-30] This makes sure we always start the greeter window in a consistent place, and it makes sure the poin



commit e5519ceed4ca40a72c85d06d65091d8cb3890563
Author: Brian Cameron <brian cameron oracle com>
Date:   Fri Jun 29 02:55:10 2012 -0500

    This makes sure we always start the greeter window in a consistent
    place, and it makes sure the pointer doesn't start up on top of
    the greeter window.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=644327

 configure.ac              |    4 +-
 daemon/gdm-simple-slave.c |    3 ++
 daemon/gdm-slave.c        |   80 +++++++++++++++++++++++++++++++++++++++++++++
 daemon/gdm-slave.h        |    3 ++
 4 files changed, 88 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 304bdc5..3cd0df0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,12 +74,12 @@ PKG_CHECK_MODULES(DAEMON,
 AC_SUBST(DAEMON_CFLAGS)
 AC_SUBST(DAEMON_LIBS)
 
-PKG_CHECK_MODULES(XLIB, x11 xau, ,
+PKG_CHECK_MODULES(XLIB, x11 xau xrandr, ,
   [AC_PATH_XTRA
     if test "x$no_x" = xyes; then
       AC_MSG_ERROR("no (requires X development libraries)")
     else
-      XLIB_LIBS="$X_PRE_LIBS $X_LIBS -lXau -lX11 -lXext $X_EXTRA_LIBS"
+      XLIB_LIBS="$X_PRE_LIBS $X_LIBS -lXau -lX11 -lXext -lXrandr $X_EXTRA_LIBS"
       XLIB_CFLAGS=$X_CFLAGS
     fi])
 AC_SUBST(XLIB_CFLAGS)
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index ffb8b13..58ce5fb 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -918,6 +918,9 @@ on_start_session_later (GdmGreeterServer *session,
 static void
 setup_server (GdmSimpleSlave *slave)
 {
+        /* Put cursor out of the way on first head */
+        gdm_slave_set_initial_cursor_position (GDM_SLAVE (slave));
+
         /* Set the busy cursor */
         gdm_slave_set_busy_cursor (GDM_SLAVE (slave));
 }
diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c
index cb2a6a9..2b1749d 100644
--- a/daemon/gdm-slave.c
+++ b/daemon/gdm-slave.c
@@ -44,6 +44,7 @@
 
 #include <X11/Xlib.h> /* for Display */
 #include <X11/cursorfont.h> /* for watch cursor */
+#include <X11/extensions/Xrandr.h>
 #include <X11/Xatom.h>
 
 #include "gdm-common.h"
@@ -359,6 +360,85 @@ gdm_slave_run_script (GdmSlave   *slave,
         return ret;
 }
 
+static void
+determine_initial_cursor_position (GdmSlave *slave,
+                                   int      *x,
+                                   int      *y)
+{
+        XRRScreenResources *resources;
+        RROutput primary_output;
+        int i;
+
+        /* If this function fails for whatever reason,
+         * put the pointer in the upper left corner of the
+         * first monitor
+         */
+        *x = 100;
+        *y = 75;
+
+        gdm_error_trap_push ();
+        resources = XRRGetScreenResources (slave->priv->server_display,
+                                           DefaultRootWindow (slave->priv->server_display));
+        primary_output = XRRGetOutputPrimary (slave->priv->server_display,
+                                              DefaultRootWindow (slave->priv->server_display));
+        gdm_error_trap_pop ();
+
+        if (resources == NULL) {
+                return;
+        }
+
+        for (i = 0; i < resources->noutput; i++) {
+                XRROutputInfo *output_info;
+
+                if (primary_output == None) {
+                        primary_output = resources->outputs[0];
+                }
+
+                if (resources->outputs[i] != primary_output) {
+                        continue;
+                }
+
+                output_info = XRRGetOutputInfo (slave->priv->server_display,
+                                                resources,
+                                                resources->outputs[i]);
+
+                if (output_info->connection != RR_Disconnected &&
+                    output_info->crtc != 0) {
+                        XRRCrtcInfo *crtc_info;
+
+                        crtc_info = XRRGetCrtcInfo (slave->priv->server_display,
+                                                    resources,
+                                                    output_info->crtc);
+                        /* position it sort of in the lower right
+                         */
+                        *x = crtc_info->x + 100;
+                        *y = crtc_info->y + 75;
+                        XRRFreeCrtcInfo (crtc_info);
+                }
+
+                XRRFreeOutputInfo (output_info);
+                break;
+        }
+
+        XRRFreeScreenResources (resources);
+}
+
+void
+gdm_slave_set_initial_cursor_position (GdmSlave *slave)
+{
+        if (slave->priv->server_display != NULL) {
+                int x, y;
+
+                determine_initial_cursor_position (slave, &x, &y);
+                XWarpPointer(slave->priv->server_display,
+                             None,
+                             DefaultRootWindow (slave->priv->server_display),
+                             0, 0,
+                             0, 0,
+                             x, y);
+        }
+}
+
 void
 gdm_slave_set_busy_cursor (GdmSlave *slave)
 {
diff --git a/daemon/gdm-slave.h b/daemon/gdm-slave.h
index 610b7d6..4d89ead 100644
--- a/daemon/gdm-slave.h
+++ b/daemon/gdm-slave.h
@@ -77,6 +77,9 @@ void                gdm_slave_block_console_session_requests_on_display   (GdmSl
 void                gdm_slave_unblock_console_session_requests_on_display (GdmSlave *slave);
 
 gboolean            gdm_slave_connect_to_x11_display (GdmSlave   *slave);
+
+void                gdm_slave_set_initial_cursor_position (GdmSlave *slave);
+
 void                gdm_slave_set_busy_cursor        (GdmSlave   *slave);
 gboolean            gdm_slave_run_script             (GdmSlave   *slave,
                                                       const char *dir,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]