Relayout on monitor layout changes

Currently we only relayout when the screen size changes, this gets
 the cases where a monitor gets added/removed but not when the primary
 monitor changes.

 We need to relayout on all monitor layout changes.

 Remove ShellGlobal::screen-size-changed signal as it is no longer used, Gdk is
 used to track changes now.

 A ShellGlobal::gdk-screen property is added for this purpose.

https://bugzilla.gnome.org/show_bug.cgi?id=620377
This commit is contained in:
Adel Gadllah 2010-06-03 17:14:58 +02:00
parent 84efaac52b
commit ccbf247970
4 changed files with 36 additions and 38 deletions

View File

@ -159,7 +159,7 @@ function start() {
global.stage.add_actor(background); global.stage.add_actor(background);
background.lower_bottom(); background.lower_bottom();
global.connect('screen-size-changed', _relayout); global.gdk_screen.connect('monitors-changed', _relayout);
ExtensionSystem.init(); ExtensionSystem.init();
ExtensionSystem.loadExtensions(); ExtensionSystem.loadExtensions();

View File

@ -452,8 +452,8 @@ MessageTray.prototype = {
Main.chrome.trackActor(this._notificationBin); Main.chrome.trackActor(this._notificationBin);
Main.chrome.trackActor(this._summaryNotificationBin); Main.chrome.trackActor(this._summaryNotificationBin);
global.connect('screen-size-changed', global.gdk_screen.connect('monitors-changed', Lang.bind(this, this._setSizePosition));
Lang.bind(this, this._setSizePosition));
this._setSizePosition(); this._setSizePosition();
Main.overview.connect('showing', Lang.bind(this, Main.overview.connect('showing', Lang.bind(this,

View File

@ -69,6 +69,7 @@ enum {
PROP_OVERLAY_GROUP, PROP_OVERLAY_GROUP,
PROP_SCREEN, PROP_SCREEN,
PROP_GDK_SCREEN,
PROP_SCREEN_WIDTH, PROP_SCREEN_WIDTH,
PROP_SCREEN_HEIGHT, PROP_SCREEN_HEIGHT,
PROP_STAGE, PROP_STAGE,
@ -79,17 +80,8 @@ enum {
PROP_USERDATADIR, PROP_USERDATADIR,
}; };
/* Signals */
enum
{
SCREEN_SIZE_CHANGED,
LAST_SIGNAL
};
G_DEFINE_TYPE(ShellGlobal, shell_global, G_TYPE_OBJECT); G_DEFINE_TYPE(ShellGlobal, shell_global, G_TYPE_OBJECT);
static guint shell_global_signals [LAST_SIGNAL] = { 0 };
static void static void
shell_global_set_property(GObject *object, shell_global_set_property(GObject *object,
guint prop_id, guint prop_id,
@ -120,6 +112,9 @@ shell_global_get_property(GObject *object,
case PROP_SCREEN: case PROP_SCREEN:
g_value_set_object (value, shell_global_get_screen (global)); g_value_set_object (value, shell_global_get_screen (global));
break; break;
case PROP_GDK_SCREEN:
g_value_set_object (value, shell_global_get_gdk_screen (global));
break;
case PROP_SCREEN_WIDTH: case PROP_SCREEN_WIDTH:
{ {
int width, height; int width, height;
@ -207,15 +202,6 @@ shell_global_class_init (ShellGlobalClass *klass)
gobject_class->get_property = shell_global_get_property; gobject_class->get_property = shell_global_get_property;
gobject_class->set_property = shell_global_set_property; gobject_class->set_property = shell_global_set_property;
shell_global_signals[SCREEN_SIZE_CHANGED] =
g_signal_new ("screen-size-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ShellGlobalClass, screen_size_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_OVERLAY_GROUP, PROP_OVERLAY_GROUP,
g_param_spec_object ("overlay-group", g_param_spec_object ("overlay-group",
@ -230,6 +216,15 @@ shell_global_class_init (ShellGlobalClass *klass)
"Metacity screen object for the shell", "Metacity screen object for the shell",
META_TYPE_SCREEN, META_TYPE_SCREEN,
G_PARAM_READABLE)); G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_GDK_SCREEN,
g_param_spec_object ("gdk-screen",
"GdkScreen",
"Gdk screen object for the shell",
GDK_TYPE_SCREEN,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_SCREEN_WIDTH, PROP_SCREEN_WIDTH,
g_param_spec_int ("screen-width", g_param_spec_int ("screen-width",
@ -425,6 +420,19 @@ shell_global_get_screen (ShellGlobal *global)
return mutter_plugin_get_screen (global->plugin); return mutter_plugin_get_screen (global->plugin);
} }
/**
* shell_global_get_gdk_screen:
*
* Return value: (transfer none): Gdk screen object for the shell
*/
GdkScreen *
shell_global_get_gdk_screen (ShellGlobal *global)
{
g_return_val_if_fail (SHELL_IS_GLOBAL (global), NULL);
return gdk_screen_get_default ();
}
/** /**
* shell_global_get_windows: * shell_global_get_windows:
* *
@ -441,9 +449,10 @@ shell_global_get_windows (ShellGlobal *global)
} }
static gboolean static gboolean
update_screen_size (ShellGlobal *global) update_screen_size (gpointer data)
{ {
int width, height; int width, height;
ShellGlobal *global = SHELL_GLOBAL (data);
mutter_plugin_query_screen_size (global->plugin, &width, &height); mutter_plugin_query_screen_size (global->plugin, &width, &height);
@ -458,17 +467,6 @@ update_screen_size (ShellGlobal *global)
clutter_actor_set_size (CLUTTER_ACTOR (global->root_pixmap), clutter_actor_set_size (CLUTTER_ACTOR (global->root_pixmap),
width, height); width, height);
return TRUE;
}
static gboolean
on_screen_size_changed_cb (gpointer data)
{
ShellGlobal *global = SHELL_GLOBAL (data);
if (update_screen_size (global))
g_signal_emit (G_OBJECT (global), shell_global_signals[SCREEN_SIZE_CHANGED], 0);
return FALSE; return FALSE;
} }
@ -482,7 +480,7 @@ global_stage_notify_width (GObject *gobject,
g_object_notify (G_OBJECT (global), "screen-width"); g_object_notify (G_OBJECT (global), "screen-width");
meta_later_add (META_LATER_BEFORE_REDRAW, meta_later_add (META_LATER_BEFORE_REDRAW,
on_screen_size_changed_cb, update_screen_size,
global, global,
NULL); NULL);
} }
@ -497,7 +495,7 @@ global_stage_notify_height (GObject *gobject,
g_object_notify (G_OBJECT (global), "screen-height"); g_object_notify (G_OBJECT (global), "screen-height");
meta_later_add (META_LATER_BEFORE_REDRAW, meta_later_add (META_LATER_BEFORE_REDRAW,
on_screen_size_changed_cb, update_screen_size,
global, global,
NULL); NULL);
} }
@ -1167,7 +1165,7 @@ shell_global_get_monitors (ShellGlobal *global)
GdkRectangle * GdkRectangle *
shell_global_get_primary_monitor (ShellGlobal *global) shell_global_get_primary_monitor (ShellGlobal *global)
{ {
GdkScreen *screen = gdk_screen_get_default (); GdkScreen *screen = shell_global_get_gdk_screen (global);
GdkRectangle rect; GdkRectangle rect;
gint primary = 0; gint primary = 0;

View File

@ -25,8 +25,6 @@ typedef struct _ShellGlobalClass ShellGlobalClass;
struct _ShellGlobalClass struct _ShellGlobalClass
{ {
GObjectClass parent_class; GObjectClass parent_class;
void (*screen_size_changed) (ShellGlobal *global);
}; };
GType shell_global_get_type (void) G_GNUC_CONST; GType shell_global_get_type (void) G_GNUC_CONST;
@ -40,6 +38,8 @@ ShellGlobal *shell_global_get (void);
MetaScreen *shell_global_get_screen (ShellGlobal *global); MetaScreen *shell_global_get_screen (ShellGlobal *global);
GdkScreen *shell_global_get_gdk_screen (ShellGlobal *global);
gboolean shell_global_add_extension_importer (ShellGlobal *global, gboolean shell_global_add_extension_importer (ShellGlobal *global,
const char *target_object_script, const char *target_object_script,
const char *target_property, const char *target_property,