window: add _NET_WM_STATE_FOCUSED hint to _NET_WM_STATE

This hint reflects whether a window appears focused.

https://bugzilla.gnome.org/show_bug.cgi?id=661427
This commit is contained in:
Rui Matos 2011-10-26 19:00:18 +01:00
parent 4fb2fab7f7
commit 6e47f0e846
2 changed files with 22 additions and 14 deletions

View File

@ -1897,7 +1897,7 @@ static void
set_net_wm_state (MetaWindow *window) set_net_wm_state (MetaWindow *window)
{ {
int i; int i;
unsigned long data[12]; unsigned long data[13];
i = 0; i = 0;
if (window->shaded) if (window->shaded)
@ -1960,6 +1960,11 @@ set_net_wm_state (MetaWindow *window)
data[i] = window->display->atom__NET_WM_STATE_STICKY; data[i] = window->display->atom__NET_WM_STATE_STICKY;
++i; ++i;
} }
if (meta_window_appears_focused (window))
{
data[i] = window->display->atom__NET_WM_STATE_FOCUSED;
++i;
}
meta_verbose ("Setting _NET_WM_STATE with %d atoms\n", i); meta_verbose ("Setting _NET_WM_STATE with %d atoms\n", i);
@ -6629,6 +6634,17 @@ meta_window_client_message (MetaWindow *window,
return FALSE; return FALSE;
} }
static void
meta_window_appears_focused_changed (MetaWindow *window)
{
set_net_wm_state (window);
g_object_notify (G_OBJECT (window), "appears-focused");
if (window->frame)
meta_frame_queue_draw (window->frame);
}
/** /**
* meta_window_propagate_focus_appearance: * meta_window_propagate_focus_appearance:
* @window: the window to start propagating from * @window: the window to start propagating from
@ -6674,9 +6690,7 @@ meta_window_propagate_focus_appearance (MetaWindow *window,
if (child_focus_state_changed && !parent->has_focus && if (child_focus_state_changed && !parent->has_focus &&
parent != window->display->expected_focus_window) parent != window->display->expected_focus_window)
{ {
g_object_notify (G_OBJECT (parent), "appears-focused"); meta_window_appears_focused_changed (parent);
if (parent->frame)
meta_frame_queue_draw (parent->frame);
} }
child = parent; child = parent;
@ -6830,11 +6844,8 @@ meta_window_notify_focus (MetaWindow *window,
g_object_notify (G_OBJECT (window->display), "focus-window"); g_object_notify (G_OBJECT (window->display), "focus-window");
if (!window->attached_focus_window) if (!window->attached_focus_window)
{ meta_window_appears_focused_changed (window);
g_object_notify (G_OBJECT (window), "appears-focused");
if (window->frame)
meta_frame_queue_draw (window->frame);
}
meta_window_propagate_focus_appearance (window, TRUE); meta_window_propagate_focus_appearance (window, TRUE);
} }
} }
@ -6867,11 +6878,7 @@ meta_window_notify_focus (MetaWindow *window,
window->has_focus = FALSE; window->has_focus = FALSE;
if (!window->attached_focus_window) if (!window->attached_focus_window)
{ meta_window_appears_focused_changed (window);
g_object_notify (G_OBJECT (window), "appears-focused");
if (window->frame)
meta_frame_queue_draw (window->frame);
}
meta_error_trap_push (window->display); meta_error_trap_push (window->display);
XUninstallColormap (window->display->xdisplay, XUninstallColormap (window->display->xdisplay,

View File

@ -164,6 +164,7 @@ item(_NET_WM_ACTION_ABOVE)
item(_NET_WM_ACTION_BELOW) item(_NET_WM_ACTION_BELOW)
item(_NET_WM_STATE_STICKY) item(_NET_WM_STATE_STICKY)
item(_NET_WM_FULLSCREEN_MONITORS) item(_NET_WM_FULLSCREEN_MONITORS)
item(_NET_WM_STATE_FOCUSED)
#if 0 #if 0
/* We apparently never use: */ /* We apparently never use: */