window: use input event helper functions on notify_focus()

This commit is contained in:
Carlos Garnacho 2011-06-09 17:47:45 +02:00
parent 66e9720cb7
commit 01e77bae9d

View File

@ -6658,6 +6658,9 @@ gboolean
meta_window_notify_focus (MetaWindow *window,
XEvent *event)
{
guint evtype, mode, detail;
Window xwindow;
/* note the event can be on either the window or the frame,
* we focus the frame for shaded windows
*/
@ -6676,23 +6679,36 @@ meta_window_notify_focus (MetaWindow *window,
* the MRU list gets confused from what the user expects once a
* keybinding is used.
*/
if (meta_input_event_get_type (window->display, event, &evtype))
{
meta_input_event_get_crossing_details (window->display, event,
&mode, &detail);
xwindow = meta_input_event_get_window (window->display, event);
}
else
{
xwindow = event->xany.window;
evtype = event->type;
mode = detail = 0;
}
meta_topic (META_DEBUG_FOCUS,
"Focus %s event received on %s 0x%lx (%s) "
"mode %s detail %s\n",
event->type == FocusIn ? "in" :
event->type == FocusOut ? "out" :
event->type == UnmapNotify ? "unmap" :
evtype == FocusIn ? "in" :
evtype == FocusOut ? "out" :
evtype == UnmapNotify ? "unmap" :
"???",
window->desc, event->xany.window,
event->xany.window == window->xwindow ?
window->desc, xwindow,
xwindow == window->xwindow ?
"client window" :
(window->frame && event->xany.window == window->frame->xwindow) ?
"frame window" :
"unknown window",
event->type != UnmapNotify ?
meta_event_mode_to_string (event->xfocus.mode) : "n/a",
event->type != UnmapNotify ?
meta_event_detail_to_string (event->xfocus.detail) : "n/a");
evtype != UnmapNotify ?
meta_event_mode_to_string (mode) : "n/a",
evtype != UnmapNotify ?
meta_event_detail_to_string (detail) : "n/a");
/* FIXME our pointer tracking is broken; see how
* gtk+/gdk/x11/gdkevents-x11.c or XFree86/xc/programs/xterm/misc.c
@ -6713,19 +6729,19 @@ meta_window_notify_focus (MetaWindow *window,
* http://bugzilla.gnome.org/show_bug.cgi?id=90382
*/
if ((event->type == FocusIn ||
event->type == FocusOut) &&
(event->xfocus.mode == NotifyGrab ||
event->xfocus.mode == NotifyUngrab ||
if ((evtype == FocusIn ||
evtype == FocusOut) &&
(mode == NotifyGrab ||
mode == NotifyUngrab ||
/* From WindowMaker, ignore all funky pointer root events */
event->xfocus.detail > NotifyNonlinearVirtual))
detail > NotifyNonlinearVirtual))
{
meta_topic (META_DEBUG_FOCUS,
"Ignoring focus event generated by a grab or other weirdness\n");
return TRUE;
}
if (event->type == FocusIn)
if (evtype == FocusIn)
{
if (window->override_redirect)
{
@ -6808,11 +6824,11 @@ meta_window_notify_focus (MetaWindow *window,
meta_window_propagate_focus_appearance (window, TRUE);
}
}
else if (event->type == FocusOut ||
event->type == UnmapNotify)
else if (evtype == FocusOut ||
evtype == UnmapNotify)
{
if (event->type == FocusOut &&
event->xfocus.detail == NotifyInferior)
if (evtype == FocusOut &&
detail == NotifyInferior)
{
/* This event means the client moved focus to a subwindow */
meta_topic (META_DEBUG_FOCUS,