[Xfce4-commits] <xfce4-panel:xfce-4.8> Directly start the panel on the correct screen (bug #7161).
Nick Schermer
noreply at xfce.org
Sat Jan 29 21:26:14 CET 2011
Updating branch refs/heads/xfce-4.8
to 87f60627fdc292007041ee3833ae3c324ab2b1f4 (commit)
from 83eed7240c8cb8b4afbc813141b5337fbd3390c5 (commit)
commit 87f60627fdc292007041ee3833ae3c324ab2b1f4
Author: Nick Schermer <nick at xfce.org>
Date: Sun Jan 23 17:27:17 2011 +0100
Directly start the panel on the correct screen (bug #7161).
The panel sometimes never made it to the correct screen and
it could even crash on startup, so don't try on the binding
to position the screen, but pass it along when creating the
panel window.
panel/panel-application.c | 28 +++++++++++++++++++++++-----
panel/panel-window.c | 6 +++++-
panel/panel-window.h | 2 +-
3 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/panel/panel-application.c b/panel/panel-application.c
index d3101c4..bd9be09 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -310,16 +310,37 @@ panel_application_load (PanelApplication *application)
GdkScreen *screen;
GPtrArray *array;
const GValue *value;
+ gchar *output_name;
+ gint screen_num;
+ GdkDisplay *display;
panel_return_if_fail (PANEL_IS_APPLICATION (application));
panel_return_if_fail (XFCONF_IS_CHANNEL (application->xfconf));
+ display = gdk_display_get_default ();
+
/* walk all the panel in the configuration */
n_panels = xfconf_channel_get_uint (application->xfconf, "/panels", 0);
for (i = 0; i < n_panels; i++)
{
+ screen = NULL;
+
+ /* start the panel directly on the correct screen */
+ g_snprintf (buf, sizeof (buf), "/panels/panel-%u/output-name", i);
+ output_name = xfconf_channel_get_string (application->xfconf, buf, NULL);
+ if (output_name != NULL
+ && strncmp (output_name, "screen-", 7) == 0
+ && sscanf (output_name, "screen-%d", &screen_num) == 1)
+ {
+ if (screen_num < gdk_display_get_n_screens (display))
+ screen = gdk_display_get_screen (display, screen_num);
+ }
+ g_free (output_name);
+
/* create a new window */
- window = panel_application_new_window (application, NULL, FALSE);
+ window = panel_application_new_window (application, screen, FALSE);
+
+ /* get the screen the window if eventually shown on */
screen = gtk_window_get_screen (GTK_WINDOW (window));
/* walk all the plugins on the panel */
@@ -1273,15 +1294,12 @@ panel_application_new_window (PanelApplication *application,
panel_return_val_if_fail (XFCONF_IS_CHANNEL (application->xfconf), NULL);
/* create panel window */
- window = panel_window_new ();
+ window = panel_window_new (screen);
/* monitor window destruction */
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (panel_application_window_destroyed), application);
- /* put on the correct screen */
- gtk_window_set_screen (GTK_WINDOW (window), screen ? screen : gdk_screen_get_default ());
-
/* add the window to internal list */
application->windows = g_slist_append (application->windows, window);
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 352c7e5..2f20130 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -2431,12 +2431,16 @@ panel_window_set_plugin_screen_position (GtkWidget *widget,
GtkWidget *
-panel_window_new (void)
+panel_window_new (GdkScreen *screen)
{
+ if (screen == NULL)
+ screen = gdk_screen_get_default ();
+
return g_object_new (PANEL_TYPE_WINDOW,
"type", GTK_WINDOW_TOPLEVEL,
"decorated", FALSE,
"resizable", FALSE,
+ "screen", screen,
"type-hint", GDK_WINDOW_TYPE_HINT_DOCK,
"gravity", GDK_GRAVITY_STATIC,
"name", "XfcePanelWindow",
diff --git a/panel/panel-window.h b/panel/panel-window.h
index efb6072..103ad7d 100644
--- a/panel/panel-window.h
+++ b/panel/panel-window.h
@@ -35,7 +35,7 @@ typedef struct _PanelWindow PanelWindow;
GType panel_window_get_type (void) G_GNUC_CONST;
-GtkWidget *panel_window_new (void) G_GNUC_MALLOC;
+GtkWidget *panel_window_new (GdkScreen *screen) G_GNUC_MALLOC;
void panel_window_set_povider_info (PanelWindow *window,
GtkWidget *provider);
More information about the Xfce4-commits
mailing list