diff --git a/src/core/screen.c b/src/core/screen.c index 8affdd041..59dd254a1 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 ca5aeb6e0..f61b97d5b 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 34c75c720..becfcf63f 100644 --- a/src/mutter-marshal.list +++ b/src/mutter-marshal.list @@ -1 +1,2 @@ VOID:INT,INT,ENUM +VOID:INT,OBJECT