[gdm] daemon: warp pointer to convenient place at startup
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm] daemon: warp pointer to convenient place at startup
- Date: Wed, 9 Mar 2011 19:15:50 +0000 (UTC)
commit 90ab791544d676629800e80fcf7a28a628f94e94
Author: Ray Strode <rstrode redhat com>
Date: Wed Mar 9 14:13:36 2011 -0500
daemon: warp pointer to convenient place at startup
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 2e7e440..e5e4557 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,12 +76,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 3e0ed5c..f43ed64 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -1101,6 +1101,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 f0e93d5..2dc0323 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"
@@ -354,6 +355,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 = 0;
+ *y = 0;
+
+ 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 + .9 * crtc_info->width;
+ *y = crtc_info->y + .9 * crtc_info->height;
+ 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 af28b00..eda2e19 100644
--- a/daemon/gdm-slave.h
+++ b/daemon/gdm-slave.h
@@ -73,6 +73,9 @@ gboolean gdm_slave_switch_to_user_session (GdmSlave *slave,
const char *username);
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]