File gnome-panel-fix-applet-xinerama.patch of Package gnome-panel

commit cb969e989477e2671d1e0cdd1519866d61d0c98c
Author: Vincent Untz <vuntz@gnome.org>
Date:   Tue Feb 1 13:55:34 2011 +0100

    panel: Fix dbus applets to work in multiscreen environment
    
    When the applet is created, the frame itself is not yet added to a
    widget hierarchy, and is therefore not associated with any screen. So we
    always sent the default screen as the one to be used to the applet.
    
    We can simply use the screen of the PanelWidget that will contain the
    applet instead.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=632369

diff --git a/gnome-panel/libpanel-applet-private/panel-applet-container.c b/gnome-panel/libpanel-applet-private/panel-applet-container.c
index eef163a..3fa947c 100644
--- a/gnome-panel/libpanel-applet-private/panel-applet-container.c
+++ b/gnome-panel/libpanel-applet-private/panel-applet-container.c
@@ -446,6 +446,7 @@ on_factory_appeared (GDBusConnection   *connection,
 
 static void
 panel_applet_container_get_applet (PanelAppletContainer *container,
+				   GdkScreen            *screen,
 				   const gchar          *iid,
 				   GVariant             *props,
 				   GCancellable         *cancellable,
@@ -454,7 +455,7 @@ panel_applet_container_get_applet (PanelAppletContainer *container,
 {
 	GSimpleAsyncResult *result;
 	AppletFactoryData  *data;
-	gint                screen;
+	gint                screen_number;
 	gchar              *bus_name;
 	gchar              *factory_id;
 	gchar              *applet_id;
@@ -479,12 +480,14 @@ panel_applet_container_get_applet (PanelAppletContainer *container,
 	factory_id = g_strndup (iid, strlen (iid) - strlen (applet_id));
 	applet_id += 2;
 
-	screen = gdk_screen_get_number (gtk_widget_get_screen (container->priv->socket));
+	/* we can't use the screen of the container widget since it's not in a
+	 * widget hierarchy yet */
+	screen_number = gdk_screen_get_number (screen);
 
 	data = g_new (AppletFactoryData, 1);
 	data->result = result;
 	data->factory_id = factory_id;
-	data->parameters = g_variant_new ("(si*)", applet_id, screen, props);
+	data->parameters = g_variant_new ("(si*)", applet_id, screen_number, props);
 	data->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
 
 	bus_name = g_strdup_printf (PANEL_APPLET_BUS_NAME, factory_id);
@@ -503,6 +506,7 @@ panel_applet_container_get_applet (PanelAppletContainer *container,
 
 void
 panel_applet_container_add (PanelAppletContainer *container,
+			    GdkScreen            *screen,
 			    const gchar          *iid,
 			    GCancellable         *cancellable,
 			    GAsyncReadyCallback   callback,
@@ -514,7 +518,7 @@ panel_applet_container_add (PanelAppletContainer *container,
 
 	panel_applet_container_cancel_pending_operations (container);
 
-	panel_applet_container_get_applet (container, iid, properties,
+	panel_applet_container_get_applet (container, screen, iid, properties,
 					   cancellable, callback, user_data);
 }
 
diff --git a/gnome-panel/libpanel-applet-private/panel-applet-container.h b/gnome-panel/libpanel-applet-private/panel-applet-container.h
index 130bf16..e4de97a 100644
--- a/gnome-panel/libpanel-applet-private/panel-applet-container.h
+++ b/gnome-panel/libpanel-applet-private/panel-applet-container.h
@@ -73,6 +73,7 @@ GtkWidget *panel_applet_container_new                     (void);
 
 
 void       panel_applet_container_add                     (PanelAppletContainer *container,
+							   GdkScreen            *screen,
 							   const gchar          *iid,
 							   GCancellable        *cancellable,
 							   GAsyncReadyCallback  callback,
diff --git a/gnome-panel/libpanel-applet-private/panel-applet-frame-dbus.c b/gnome-panel/libpanel-applet-private/panel-applet-frame-dbus.c
index 9aaac15..dd3aecb 100644
--- a/gnome-panel/libpanel-applet-private/panel-applet-frame-dbus.c
+++ b/gnome-panel/libpanel-applet-private/panel-applet-frame-dbus.c
@@ -411,6 +411,7 @@ panel_applet_frame_dbus_load (const gchar                 *iid,
 	PanelAppletFrameDBus *dbus_frame;
 	PanelAppletFrame     *frame;
 	GVariantBuilder       builder;
+	GdkScreen            *screen;
 	gchar                *conf_path;
 	gchar                *background;
 	guint                 orient;
@@ -425,6 +426,7 @@ panel_applet_frame_dbus_load (const gchar                 *iid,
 	frame = PANEL_APPLET_FRAME (dbus_frame);
 	_panel_applet_frame_set_iid (frame, iid);
 
+	screen = panel_applet_frame_activating_get_screen (frame_act);
 	orient = get_panel_applet_orient (panel_applet_frame_activating_get_orientation (frame_act));
 	conf_path = panel_applet_frame_activating_get_conf_path (frame_act);
 	/* we can't really get a background string at this point since we don't
@@ -456,7 +458,7 @@ panel_applet_frame_dbus_load (const gchar                 *iid,
 	g_object_set_data (G_OBJECT (frame), "panel-applet-frame-activating", frame_act);
 
 	panel_applet_container_add (dbus_frame->priv->container,
-				    iid, NULL,
+				    screen, iid, NULL,
 				    (GAsyncReadyCallback) panel_applet_frame_dbus_activated,
 				    frame,
 				    g_variant_builder_end (&builder));
diff --git a/gnome-panel/panel-applet-frame.c b/gnome-panel/panel-applet-frame.c
index a411bf0..114e32f 100644
--- a/gnome-panel/panel-applet-frame.c
+++ b/gnome-panel/panel-applet-frame.c
@@ -805,6 +805,12 @@ panel_applet_frame_activating_free (PanelAppletFrameActivating *frame_act)
 	g_slice_free (PanelAppletFrameActivating, frame_act);
 }
 
+GdkScreen *
+panel_applet_frame_activating_get_screen (PanelAppletFrameActivating *frame_act)
+{
+	return gtk_widget_get_screen (frame_act->panel);
+}
+
 PanelOrientation
 panel_applet_frame_activating_get_orientation (PanelAppletFrameActivating *frame_act)
 {
diff --git a/gnome-panel/panel-applet-frame.h b/gnome-panel/panel-applet-frame.h
index a459bb7..a551c4c 100644
--- a/gnome-panel/panel-applet-frame.h
+++ b/gnome-panel/panel-applet-frame.h
@@ -105,6 +105,7 @@ void  panel_applet_frame_set_panel          (PanelAppletFrame    *frame,
 
 typedef struct _PanelAppletFrameActivating        PanelAppletFrameActivating;
 
+GdkScreen        *panel_applet_frame_activating_get_screen      (PanelAppletFrameActivating *frame_act);
 PanelOrientation  panel_applet_frame_activating_get_orientation (PanelAppletFrameActivating *frame_act);
 guint32           panel_applet_frame_activating_get_size        (PanelAppletFrameActivating *frame_act);
 gboolean          panel_applet_frame_activating_get_locked      (PanelAppletFrameActivating *frame_act);
diff --git a/gnome-panel/panel-test-applets.c b/gnome-panel/panel-test-applets.c
index 58b1a3a..b302bc2 100644
--- a/gnome-panel/panel-test-applets.c
+++ b/gnome-panel/panel-test-applets.c
@@ -164,6 +164,7 @@ load_applet_into_window (const char *title,
 	g_variant_builder_add (&builder, "{sv}",
 			       "orient", g_variant_new_uint32 (orientation));
 	panel_applet_container_add (PANEL_APPLET_CONTAINER (container),
+				    gtk_widget_get_screen (applet_window),
 				    title, NULL,
 				    (GAsyncReadyCallback)applet_activated_cb,
 				    applet_window,