diff --git a/src/xfce-desktop.c b/src/xfce-desktop.c index 40d74037..bb108343 100644 --- a/src/xfce-desktop.c +++ b/src/xfce-desktop.c @@ -93,6 +93,7 @@ struct _XfceDesktopPrivate GdkScreen *gscreen; WnckScreen *wnck_screen; gboolean updates_frozen; + guint primary_monitor; XfconfChannel *channel; gchar *property_prefix; @@ -689,10 +690,21 @@ xfce_desktop_monitors_changed(GdkScreen *gscreen, TRACE("entering"); + desktop->priv->primary_monitor = 0; + + /* Update the primary monitor number */ + for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { + if(gdk_monitor_is_primary(gdk_display_get_monitor(gdk_screen_get_display(gscreen), i))) { + desktop->priv->primary_monitor = i; + break; + } + } + /* Update the workspaces */ for(i = 0; i < desktop->priv->nworkspaces; i++) { xfce_workspace_monitors_changed(desktop->priv->workspaces[i], - gscreen); + gscreen, + desktop->priv->primary_monitor); } /* fake a screen size changed, so the background is properly set */ @@ -725,7 +737,7 @@ workspace_backdrop_changed_cb(XfceWorkspace *workspace, /* Update the backdrop! * In spanning mode, ignore updates to monitors other than the primary */ - if(!xfce_workspace_get_xinerama_stretch(workspace) || monitor == 0) { + if(!xfce_workspace_get_xinerama_stretch(workspace) || monitor == desktop->priv->primary_monitor) { backdrop_changed_cb(backdrop, user_data); } } @@ -789,7 +801,8 @@ workspace_created_cb(WnckScreen *wnck_screen, nlast_workspace); xfce_workspace_monitors_changed(desktop->priv->workspaces[nlast_workspace], - desktop->priv->gscreen); + desktop->priv->gscreen, + 0); g_signal_connect(desktop->priv->workspaces[nlast_workspace], "workspace-backdrop-changed", diff --git a/src/xfce-workspace.c b/src/xfce-workspace.c index 69b972f6..9ad18eea 100644 --- a/src/xfce-workspace.c +++ b/src/xfce-workspace.c @@ -76,6 +76,7 @@ struct _XfceWorkspacePrivate { GdkScreen *gscreen; + guint primary; XfconfChannel *channel; gchar *property_prefix; @@ -123,17 +124,17 @@ G_DEFINE_TYPE_WITH_PRIVATE(XfceWorkspace, xfce_workspace, G_TYPE_OBJECT) * xfce_workspace_get_xinerama_stretch: * @workspace: An #XfceWorkspace. * - * returns whether the first backdrop is set to spanning screens since it's - * the only backdrop where that setting is applicable. + * returns whether the backdrop of the primary monitor is set to spanning screens + * since it's the only backdrop where that setting is applicable. **/ gboolean xfce_workspace_get_xinerama_stretch(XfceWorkspace *workspace) { g_return_val_if_fail(XFCE_IS_WORKSPACE(workspace), FALSE); g_return_val_if_fail(workspace->priv->backdrops != NULL, FALSE); - g_return_val_if_fail(XFCE_IS_BACKDROP(workspace->priv->backdrops[0]), FALSE); + g_return_val_if_fail(XFCE_IS_BACKDROP(workspace->priv->backdrops[workspace->priv->primary]), FALSE); - return xfce_backdrop_get_image_style(workspace->priv->backdrops[0]) == XFCE_BACKDROP_IMAGE_SPANNING_SCREENS; + return xfce_backdrop_get_image_style(workspace->priv->backdrops[workspace->priv->primary]) == XFCE_BACKDROP_IMAGE_SPANNING_SCREENS; } static void @@ -282,13 +283,15 @@ backdrop_changed_cb(XfceBackdrop *backdrop, gpointer user_data) /** * xfce_workspace_monitors_changed: * @workspace: An #XfceWorkspace. - * @GdkScreen: screen the workspace is on. + * @gscreen: screen the workspace is on. + * @primary: primary monitor number * * Updates the backdrops to correctly display the right settings. **/ void xfce_workspace_monitors_changed(XfceWorkspace *workspace, - GdkScreen *gscreen) + GdkScreen *gscreen, + guint primary) { guint i; guint n_monitors; @@ -298,6 +301,9 @@ xfce_workspace_monitors_changed(XfceWorkspace *workspace, g_return_if_fail(gscreen); + /* Set primary monitor number */ + workspace->priv->primary = primary; + vis = gdk_screen_get_rgba_visual(gscreen); if(vis == NULL) vis = gdk_screen_get_system_visual(gscreen); @@ -749,6 +755,7 @@ xfce_workspace_new(GdkScreen *gscreen, gscreen = gdk_display_get_default_screen(gdk_display_get_default()); workspace->priv->gscreen = gscreen; + workspace->priv->primary = 0; workspace->priv->workspace_num = number; workspace->priv->channel = XFCONF_CHANNEL(g_object_ref(G_OBJECT(channel))); workspace->priv->property_prefix = g_strdup(property_prefix); diff --git a/src/xfce-workspace.h b/src/xfce-workspace.h index aabf13e3..f9d0c4a9 100644 --- a/src/xfce-workspace.h +++ b/src/xfce-workspace.h @@ -66,11 +66,11 @@ gint xfce_workspace_get_workspace_num(XfceWorkspace *workspace); void xfce_workspace_set_workspace_num(XfceWorkspace *workspace, gint number); void xfce_workspace_monitors_changed(XfceWorkspace *workspace, - GdkScreen *gscreen); + GdkScreen *gscreen, + guint primary); gboolean xfce_workspace_get_xinerama_stretch(XfceWorkspace *workspace); - XfceBackdrop *xfce_workspace_get_backdrop(XfceWorkspace *workspace, guint monitor);