[gnome-shell] Relayout on monitor layout changes
- From: Adel Gadllah <agadllah src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Relayout on monitor layout changes
- Date: Fri, 4 Jun 2010 13:20:55 +0000 (UTC)
commit ccbf24797079b3bdda59ee2d5cb09d22b661b814
Author: Adel Gadllah <adel gadllah gmail com>
Date: Thu Jun 3 17:14:58 2010 +0200
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
js/ui/main.js | 2 +-
js/ui/messageTray.js | 4 +-
src/shell-global.c | 64 ++++++++++++++++++++++++-------------------------
src/shell-global.h | 4 +-
4 files changed, 36 insertions(+), 38 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index 7c9d34e..b54ee20 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -159,7 +159,7 @@ function start() {
global.stage.add_actor(background);
background.lower_bottom();
- global.connect('screen-size-changed', _relayout);
+ global.gdk_screen.connect('monitors-changed', _relayout);
ExtensionSystem.init();
ExtensionSystem.loadExtensions();
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index c71ce88..aaba10b 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -452,8 +452,8 @@ MessageTray.prototype = {
Main.chrome.trackActor(this._notificationBin);
Main.chrome.trackActor(this._summaryNotificationBin);
- global.connect('screen-size-changed',
- Lang.bind(this, this._setSizePosition));
+ global.gdk_screen.connect('monitors-changed', Lang.bind(this, this._setSizePosition));
+
this._setSizePosition();
Main.overview.connect('showing', Lang.bind(this,
diff --git a/src/shell-global.c b/src/shell-global.c
index 47ac928..25afb7b 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -69,6 +69,7 @@ enum {
PROP_OVERLAY_GROUP,
PROP_SCREEN,
+ PROP_GDK_SCREEN,
PROP_SCREEN_WIDTH,
PROP_SCREEN_HEIGHT,
PROP_STAGE,
@@ -79,17 +80,8 @@ enum {
PROP_USERDATADIR,
};
-/* Signals */
-enum
-{
- SCREEN_SIZE_CHANGED,
- LAST_SIGNAL
-};
-
G_DEFINE_TYPE(ShellGlobal, shell_global, G_TYPE_OBJECT);
-static guint shell_global_signals [LAST_SIGNAL] = { 0 };
-
static void
shell_global_set_property(GObject *object,
guint prop_id,
@@ -120,6 +112,9 @@ shell_global_get_property(GObject *object,
case PROP_SCREEN:
g_value_set_object (value, shell_global_get_screen (global));
break;
+ case PROP_GDK_SCREEN:
+ g_value_set_object (value, shell_global_get_gdk_screen (global));
+ break;
case PROP_SCREEN_WIDTH:
{
int width, height;
@@ -207,15 +202,6 @@ shell_global_class_init (ShellGlobalClass *klass)
gobject_class->get_property = shell_global_get_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,
PROP_OVERLAY_GROUP,
g_param_spec_object ("overlay-group",
@@ -230,6 +216,15 @@ shell_global_class_init (ShellGlobalClass *klass)
"Metacity screen object for the shell",
META_TYPE_SCREEN,
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,
PROP_SCREEN_WIDTH,
g_param_spec_int ("screen-width",
@@ -426,6 +421,19 @@ shell_global_get_screen (ShellGlobal *global)
}
/**
+ * 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:
*
* Gets the list of MutterWindows for the plugin's screen
@@ -441,9 +449,10 @@ shell_global_get_windows (ShellGlobal *global)
}
static gboolean
-update_screen_size (ShellGlobal *global)
+update_screen_size (gpointer data)
{
int width, height;
+ ShellGlobal *global = SHELL_GLOBAL (data);
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),
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;
}
@@ -482,7 +480,7 @@ global_stage_notify_width (GObject *gobject,
g_object_notify (G_OBJECT (global), "screen-width");
meta_later_add (META_LATER_BEFORE_REDRAW,
- on_screen_size_changed_cb,
+ update_screen_size,
global,
NULL);
}
@@ -497,7 +495,7 @@ global_stage_notify_height (GObject *gobject,
g_object_notify (G_OBJECT (global), "screen-height");
meta_later_add (META_LATER_BEFORE_REDRAW,
- on_screen_size_changed_cb,
+ update_screen_size,
global,
NULL);
}
@@ -1167,7 +1165,7 @@ shell_global_get_monitors (ShellGlobal *global)
GdkRectangle *
shell_global_get_primary_monitor (ShellGlobal *global)
{
- GdkScreen *screen = gdk_screen_get_default ();
+ GdkScreen *screen = shell_global_get_gdk_screen (global);
GdkRectangle rect;
gint primary = 0;
diff --git a/src/shell-global.h b/src/shell-global.h
index e46bea1..81df16d 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -25,8 +25,6 @@ typedef struct _ShellGlobalClass ShellGlobalClass;
struct _ShellGlobalClass
{
GObjectClass parent_class;
-
- void (*screen_size_changed) (ShellGlobal *global);
};
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);
+GdkScreen *shell_global_get_gdk_screen (ShellGlobal *global);
+
gboolean shell_global_add_extension_importer (ShellGlobal *global,
const char *target_object_script,
const char *target_property,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]