=== modified file 'src/xsplash.c' --- src/xsplash.c 2009-10-21 13:06:01 +0000 +++ src/xsplash.c 2009-11-02 16:17:42 +0000 @@ -195,6 +195,8 @@ static gboolean fading = FALSE; +static gint default_monitor = 0; + static void xsplash_server_class_init (XsplashServerClass *class) { @@ -321,7 +323,29 @@ } static gint -get_monitor_width () +get_screen_width () +{ + GdkScreen *screen; + + screen = gdk_screen_get_default (); + + return gdk_screen_get_width (screen); +} + +static gint +get_screen_height () +{ + GdkScreen *screen; + + screen = gdk_screen_get_default (); + + return gdk_screen_get_height (screen); + +} + + +static gint +get_monitor_width (gint i) { GdkScreen *screen; GdkRectangle rect; @@ -329,14 +353,14 @@ screen = gdk_screen_get_default (); gdk_screen_get_monitor_geometry (screen, - 0, + i, &rect); return rect.width; } static gint -get_monitor_height () +get_monitor_height (gint i) { GdkScreen *screen; GdkRectangle rect; @@ -344,12 +368,42 @@ screen = gdk_screen_get_default (); gdk_screen_get_monitor_geometry (screen, - 0, + i, &rect); return rect.height; } +static gint +get_monitor_left (gint i) +{ + GdkScreen *screen; + GdkRectangle rect; + + screen = gdk_screen_get_default (); + + gdk_screen_get_monitor_geometry (screen, + i, + &rect); + + return rect.x; +} + +static gint +get_monitor_top (gint i) +{ + GdkScreen *screen; + GdkRectangle rect; + + screen = gdk_screen_get_default (); + + gdk_screen_get_monitor_geometry (screen, + i, + &rect); + + return rect.y; +} + static gchar * get_background_filename (void) { @@ -375,7 +429,7 @@ gchar *ret; gint width; - width = get_monitor_width (); + width = get_monitor_width (default_monitor); if (throbber_image != NULL) { @@ -401,7 +455,7 @@ gchar *ret; gint width; - width = get_monitor_width (); + width = get_monitor_width (default_monitor); if (logo_image != NULL) { @@ -491,23 +545,39 @@ XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server); GdkPixmap *pixmap; GdkPixbuf *pixbuf; + GdkScreen *screen; + gint i; - pixbuf = get_pixbuf (get_monitor_width (), - get_monitor_height ()); + pixbuf = get_pixbuf (get_monitor_width (default_monitor), + get_monitor_height (default_monitor)); pixmap = gdk_pixmap_new (priv->cow, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), + //gdk_pixbuf_get_width (pixbuf), + //gdk_pixbuf_get_height (pixbuf), + get_screen_width(), get_screen_height(), -1); - gdk_draw_pixbuf (pixmap, + screen = gdk_screen_get_default (); + + // TODO: this is still not optimal: the same image (the one for default screen) + // is used for all monitors without any scaling. This can cause problems for + // different monitor size setups. A better solution would be to + // get a separate image for every monitor. + for (i = 0; i < gdk_screen_get_n_monitors(screen); i++) + { + gint x = get_monitor_left(i); + gint y = get_monitor_top(i); + + gdk_draw_pixbuf (pixmap, NULL, pixbuf, - 0, 0, - 0, 0, - -1, -1, + MAX(0, (gdk_pixbuf_get_width (pixbuf) - get_monitor_width(i)) / 2), + MAX(0, (gdk_pixbuf_get_height (pixbuf) - get_monitor_height(i)) / 2), + x, y, + get_monitor_width(i), get_monitor_height(i), GDK_RGB_DITHER_MAX, 0, 0); + } if (!priv->background) { @@ -526,19 +596,22 @@ { XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server); + gint x = get_monitor_left(default_monitor); + gint y = get_monitor_top(default_monitor); + if (!priv->logo) { gchar *logo_filename = NULL; - logo_filename = get_logo_filename (get_monitor_width ()); + logo_filename = get_logo_filename (get_monitor_width (default_monitor)); priv->logo_pixbuf = gdk_pixbuf_new_from_file (logo_filename, NULL); priv->logo = gtk_image_new_from_pixbuf (priv->logo_pixbuf); gtk_fixed_put (GTK_FIXED (priv->fixed), priv->logo, - get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->logo_pixbuf) / 2, - get_monitor_height () / 3 - gdk_pixbuf_get_height (priv->logo_pixbuf) / 2); + get_monitor_width (default_monitor) / 2 - gdk_pixbuf_get_width (priv->logo_pixbuf) / 2 + x, + get_monitor_height (default_monitor) / 3 - gdk_pixbuf_get_height (priv->logo_pixbuf) / 2 + y); if (logo_filename != NULL) g_free (logo_filename); @@ -547,8 +620,8 @@ { gtk_fixed_move (GTK_FIXED (priv->fixed), priv->logo, - get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->logo_pixbuf) / 2, - get_monitor_height () / 3 - gdk_pixbuf_get_height (priv->logo_pixbuf) / 2); + get_monitor_width (default_monitor) / 2 - gdk_pixbuf_get_width (priv->logo_pixbuf) / 2 + x, + get_monitor_height (default_monitor) / 3 - gdk_pixbuf_get_height (priv->logo_pixbuf) / 2 + y); } } @@ -557,6 +630,9 @@ { XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server); + gint x = get_monitor_left(default_monitor); + gint y = get_monitor_top(default_monitor); + if (!priv->throbber) { gchar *throbber_filename = NULL; @@ -574,8 +650,8 @@ gtk_fixed_put (GTK_FIXED (priv->fixed), priv->throbber, - get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->throbber_pixbuf) / 2, - get_monitor_height () / 3 + gdk_pixbuf_get_height (priv->logo_pixbuf) / 2 + gdk_pixbuf_get_height (priv->throbber_pixbuf) / ((throbber_frames - 1) * 2)); + get_monitor_width (default_monitor) / 2 - gdk_pixbuf_get_width (priv->throbber_pixbuf) / 2 + x, + get_monitor_height (default_monitor) / 3 + gdk_pixbuf_get_height (priv->logo_pixbuf) / 2 + gdk_pixbuf_get_height (priv->throbber_pixbuf) / ((throbber_frames - 1) * 2) + y); start_throbber (server); } @@ -593,8 +669,8 @@ { gtk_fixed_move (GTK_FIXED (priv->fixed), priv->throbber, - get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->throbber_pixbuf) / 2, - get_monitor_height () / 3 + gdk_pixbuf_get_height (priv->logo_pixbuf) / 2 + gdk_pixbuf_get_height (priv->throbber_pixbuf) / ((throbber_frames - 1) * 2)); + get_monitor_width (default_monitor) / 2 - gdk_pixbuf_get_width (priv->throbber_pixbuf) / 2 + x, + get_monitor_height (default_monitor) / 3 + gdk_pixbuf_get_height (priv->logo_pixbuf) / 2 + gdk_pixbuf_get_height (priv->throbber_pixbuf) / ((throbber_frames - 1) * 2) + y); } } @@ -1036,7 +1112,9 @@ g_message ("logo_image = %s", logo_image); g_message ("throbber_image = %s", throbber_image); - system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL); + // In the case of being outside gdm session just use session bus + // instead of the system one (makes testing easier). + system_bus = dbus_g_bus_get (gdm_session ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION, NULL); bus_proxy = dbus_g_proxy_new_for_name (system_bus, DBUS_SERVICE_DBUS, @@ -1047,7 +1125,7 @@ XSPLASH_DBUS_NAME, 0, &nameret, &error)) { - g_warning ("Unable to call to request name. You probably don't have sufficient privileges."); + g_warning ("Unable to call to request name. You probably don't have sufficient privileges. (%s)", error->message); return 1; }