[mutter] Add signals for when windows change monitors
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] Add signals for when windows change monitors
- Date: Thu, 17 Mar 2011 12:55:05 +0000 (UTC)
commit 74b97dcd141c0c5a8c722369c9875d2880f144c6
Author: Alexander Larsson <alexl redhat com>
Date: Mon Feb 28 21:26:11 2011 +0100
Add signals for when windows change monitors
This is useful in order to track e.g. which windows are on the primary
monitor.
https://bugzilla.gnome.org/show_bug.cgi?id=609258
src/core/screen.c | 39 +++++++++++++++++++++++++++++++++++++++
src/core/window.c | 13 +++++++++++++
src/mutter-marshal.list | 1 +
3 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/src/core/screen.c b/src/core/screen.c
index 8affdd0..59dd254 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -84,6 +84,8 @@ enum
WORKSPACE_ADDED,
WORKSPACE_REMOVED,
WORKSPACE_SWITCHED,
+ WINDOW_ENTERED_MONITOR,
+ WINDOW_LEFT_MONITOR,
STARTUP_SEQUENCE_CHANGED,
WORKAREAS_CHANGED,
MONITORS_CHANGED,
@@ -201,6 +203,28 @@ meta_screen_class_init (MetaScreenClass *klass)
G_TYPE_INT,
MUTTER_TYPE_MOTION_DIRECTION);
+ screen_signals[WINDOW_ENTERED_MONITOR] =
+ g_signal_new ("window-entered-monitor",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ _mutter_marshal_VOID__INT_OBJECT,
+ G_TYPE_NONE, 2,
+ G_TYPE_INT,
+ META_TYPE_WINDOW);
+
+ screen_signals[WINDOW_LEFT_MONITOR] =
+ g_signal_new ("window-left-monitor",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ _mutter_marshal_VOID__INT_OBJECT,
+ G_TYPE_NONE, 2,
+ G_TYPE_INT,
+ META_TYPE_WINDOW);
+
screen_signals[STARTUP_SEQUENCE_CHANGED] =
g_signal_new ("startup-sequence-changed",
G_TYPE_FROM_CLASS (klass),
@@ -2822,6 +2846,21 @@ meta_screen_resize (MetaScreen *screen,
screen->rect.width = width;
screen->rect.height = height;
+ /* Clear monitor for all windows on this screen, as it will become
+ * invalid. */
+ windows = meta_display_list_windows (screen->display,
+ META_LIST_INCLUDE_OVERRIDE_REDIRECT);
+ for (tmp = windows; tmp != NULL; tmp = tmp->next)
+ {
+ MetaWindow *window = tmp->data;
+
+ if (window->screen == screen)
+ {
+ g_signal_emit_by_name (screen, "window-left-monitor", window->monitor->number, window);
+ window->monitor = NULL;
+ }
+ }
+
reload_monitor_infos (screen);
set_desktop_geometry_hint (screen);
diff --git a/src/core/window.c b/src/core/window.c
index ca5aeb6..f61b97d 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -1085,6 +1085,8 @@ meta_window_new_with_attrs (MetaDisplay *display,
meta_window_update_struts (window);
}
+ g_signal_emit_by_name (window->screen, "window-entered-monitor", window->monitor->number, window);
+
/* Must add window to stack before doing move/resize, since the
* window might have fullscreen size (i.e. should have been
* fullscreen'd; acrobat is one such braindead case; it withdraws
@@ -1465,6 +1467,13 @@ meta_window_unmanage (MetaWindow *window,
}
#endif
+ if (window->monitor)
+ {
+ g_signal_emit_by_name (window->screen, "window-left-monitor",
+ window->monitor->number, window);
+ window->monitor = NULL;
+ }
+
if (!window->override_redirect)
meta_stack_remove (window->screen->stack, window);
@@ -4104,6 +4113,10 @@ meta_window_update_monitor (MetaWindow *window)
meta_window_is_on_primary_monitor (window) &&
window->screen->active_workspace != window->workspace)
meta_window_change_workspace (window, window->screen->active_workspace);
+
+ if (old)
+ g_signal_emit_by_name (window->screen, "window-left-monitor", old->number, window);
+ g_signal_emit_by_name (window->screen, "window-entered-monitor", window->monitor->number, window);
}
}
diff --git a/src/mutter-marshal.list b/src/mutter-marshal.list
index 34c75c7..becfcf6 100644
--- a/src/mutter-marshal.list
+++ b/src/mutter-marshal.list
@@ -1 +1,2 @@
VOID:INT,INT,ENUM
+VOID:INT,OBJECT
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]