Add focus-window property to MetaDisplay
Useful mainly for notify::focus-window.
This commit is contained in:
parent
c9e0613b53
commit
df90187e06
2 changed files with 61 additions and 3 deletions
|
@ -128,9 +128,16 @@ G_DEFINE_TYPE(MetaDisplay, meta_display, G_TYPE_OBJECT);
|
|||
enum
|
||||
{
|
||||
OVERLAY_KEY,
|
||||
FOCUS_WINDOW,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
|
||||
PROP_FOCUS_WINDOW
|
||||
};
|
||||
|
||||
static guint display_signals [LAST_SIGNAL] = { 0 };
|
||||
|
||||
/**
|
||||
|
@ -169,9 +176,47 @@ static void sanity_check_timestamps (MetaDisplay *display,
|
|||
|
||||
MetaGroup* get_focussed_group (MetaDisplay *display);
|
||||
|
||||
static void
|
||||
meta_display_get_property(GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaDisplay *display = META_DISPLAY (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_FOCUS_WINDOW:
|
||||
g_value_set_object (value, display->focus_window);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_display_set_property(GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_display_class_init (MetaDisplayClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->get_property = meta_display_get_property;
|
||||
object_class->set_property = meta_display_set_property;
|
||||
|
||||
display_signals[OVERLAY_KEY] =
|
||||
g_signal_new ("overlay-key",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -179,9 +224,18 @@ meta_display_class_init (MetaDisplayClass *klass)
|
|||
0,
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_FOCUS_WINDOW,
|
||||
g_param_spec_object ("focus-window",
|
||||
"Focus window",
|
||||
"Currently focused window",
|
||||
META_TYPE_WINDOW,
|
||||
G_PARAM_READABLE));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destructor for MetaPingData structs. Will destroy the
|
||||
* event source for the struct as well.
|
||||
|
|
|
@ -1289,7 +1289,10 @@ meta_window_unmanage (MetaWindow *window,
|
|||
g_assert (window->display->grab_window != window);
|
||||
|
||||
if (window->display->focus_window == window)
|
||||
window->display->focus_window = NULL;
|
||||
{
|
||||
window->display->focus_window = NULL;
|
||||
g_object_notify (window->display, "focus-window");
|
||||
}
|
||||
|
||||
if (window->maximized_horizontally || window->maximized_vertically)
|
||||
unmaximize_window_before_freeing (window);
|
||||
|
@ -5747,7 +5750,7 @@ meta_window_notify_focus (MetaWindow *window,
|
|||
meta_display_ungrab_focus_window_button (window->display, window);
|
||||
|
||||
g_signal_emit (window, window_signals[FOCUS], 0);
|
||||
|
||||
g_object_notify (window->display, "focus-window");
|
||||
}
|
||||
}
|
||||
else if (event->type == FocusOut ||
|
||||
|
@ -5773,6 +5776,7 @@ meta_window_notify_focus (MetaWindow *window,
|
|||
"* Focus --> NULL (was %s)\n", window->desc);
|
||||
|
||||
window->display->focus_window = NULL;
|
||||
g_object_notify (window->display, "focus-window");
|
||||
window->has_focus = FALSE;
|
||||
if (window->frame)
|
||||
meta_frame_queue_draw (window->frame);
|
||||
|
|
Loading…
Reference in a new issue