Add "window-created" signal to MetaDisplay, "unmanaged" signal for MetaWindow

For some consumers it's significantly more convenient to be able
to directly connect to a signal on the Window to know when
Mutter is done with it, rather than having to connect to each
Workspace object (and handle workspace additions, etc.).

Similarly, add window-created which acts globally.

https://bugzilla.gnome.org/show_bug.cgi?id=598289
This commit is contained in:
Colin Walters 2009-10-13 10:34:34 -04:00
parent 3c76478510
commit 9311addca3
4 changed files with 36 additions and 0 deletions

View File

@ -358,6 +358,9 @@ void meta_display_register_x_window (MetaDisplay *display,
void meta_display_unregister_x_window (MetaDisplay *display, void meta_display_unregister_x_window (MetaDisplay *display,
Window xwindow); Window xwindow);
void meta_display_notify_window_created (MetaDisplay *display,
MetaWindow *window);
GSList* meta_display_list_windows (MetaDisplay *display, GSList* meta_display_list_windows (MetaDisplay *display,
MetaListWindowsFlags flags); MetaListWindowsFlags flags);

View File

@ -129,6 +129,7 @@ enum
{ {
OVERLAY_KEY, OVERLAY_KEY,
FOCUS_WINDOW, FOCUS_WINDOW,
WINDOW_CREATED,
LAST_SIGNAL LAST_SIGNAL
}; };
@ -226,6 +227,16 @@ meta_display_class_init (MetaDisplayClass *klass)
g_cclosure_marshal_VOID__VOID, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
display_signals[WINDOW_CREATED] =
g_signal_new ("window-created",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, META_TYPE_WINDOW);
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_FOCUS_WINDOW, PROP_FOCUS_WINDOW,
g_param_spec_object ("focus-window", g_param_spec_object ("focus-window",
@ -3210,6 +3221,13 @@ meta_display_unregister_x_window (MetaDisplay *display,
remove_pending_pings_for_window (display, xwindow); remove_pending_pings_for_window (display, xwindow);
} }
void
meta_display_notify_window_created (MetaDisplay *display,
MetaWindow *window)
{
g_signal_emit (display, display_signals[WINDOW_CREATED], 0, window);
}
/** /**
* meta_display_xwindow_is_a_no_focus_window: * meta_display_xwindow_is_a_no_focus_window:
* @display: A #MetaDisplay * @display: A #MetaDisplay

View File

@ -380,6 +380,7 @@ struct _MetaWindowClass
void (*workspace_changed) (MetaWindow *window, int old_workspace); void (*workspace_changed) (MetaWindow *window, int old_workspace);
void (*focus) (MetaWindow *window); void (*focus) (MetaWindow *window);
void (*raised) (MetaWindow *window); void (*raised) (MetaWindow *window);
void (*unmanaged) (MetaWindow *window);
}; };
/* These differ from window->has_foo_func in that they consider /* These differ from window->has_foo_func in that they consider

View File

@ -146,6 +146,7 @@ enum
WORKSPACE_CHANGED, WORKSPACE_CHANGED,
FOCUS, FOCUS,
RAISED, RAISED,
UNMANAGED,
LAST_SIGNAL LAST_SIGNAL
}; };
@ -322,6 +323,15 @@ meta_window_class_init (MetaWindowClass *klass)
NULL, NULL, NULL, NULL,
g_cclosure_marshal_VOID__VOID, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
window_signals[UNMANAGED] =
g_signal_new ("unmanaged",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (MetaWindowClass, unmanaged),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
} }
static void static void
@ -1081,6 +1091,8 @@ meta_window_new_with_attrs (MetaDisplay *display,
window->constructing = FALSE; window->constructing = FALSE;
meta_display_notify_window_created (display, window);
return window; return window;
} }
@ -1453,6 +1465,8 @@ meta_window_unmanage (MetaWindow *window,
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display, FALSE);
g_signal_emit (window, window_signals[UNMANAGED], 0);
g_object_unref (window); g_object_unref (window);
} }