display: separate input/non-input events handling in the event callback

In order to make the XI2 handling easier on us in the future, we now
split input events from non-input events. This will allow one code path
to use XIEvent, and the other to use XEvent in the future. This commit
has involved plenty of indenting changes, so it's better seen with
git diff -b or &ignorews=1

https://bugzilla.gnome.org/show_bug.cgi?id=688779
This commit is contained in:
Carlos Garnacho 2011-06-08 10:27:27 +02:00 committed by Jasper St. Pierre
parent 8bf8f3ea55
commit 129c729c50

View File

@ -1796,6 +1796,27 @@ handle_net_restack_window (MetaDisplay* display,
}
#endif
static XEvent *
get_input_event (MetaDisplay *display,
XEvent *event)
{
switch (event->type) {
case MotionNotify:
case ButtonPress:
case ButtonRelease:
case KeyPress:
case KeyRelease:
case FocusIn:
case FocusOut:
case EnterNotify:
case LeaveNotify:
return event;
break;
}
return NULL;
}
/**
* event_callback:
* @event: The event that just happened
@ -1821,6 +1842,7 @@ event_callback (XEvent *event,
gboolean frame_was_receiver;
gboolean bypass_compositor;
gboolean filter_out_event;
XEvent *input_event;
display = data;
@ -1840,6 +1862,8 @@ event_callback (XEvent *event,
modified = event_get_modified_window (display, event);
input_event = get_input_event (display, event);
if (event->type == UnmapNotify)
{
if (meta_ui_window_should_not_cause_focus (display->xdisplay,
@ -1851,8 +1875,9 @@ event_callback (XEvent *event,
event->xany.serial);
}
}
else if (event->type == LeaveNotify &&
event->xcrossing.mode == NotifyUngrab &&
else if (input_event &&
input_event->type == LeaveNotify &&
input_event->xcrossing.mode == NotifyUngrab &&
modified == display->ungrab_should_not_cause_focus_window)
{
meta_display_add_ignored_crossing_serial (display, event->xany.serial);
@ -1954,8 +1979,10 @@ event_callback (XEvent *event,
}
#endif /* HAVE_SHAPE */
if (input_event != NULL)
{
if (window && !window->override_redirect &&
((event->type == KeyPress) || (event->type == ButtonPress)))
((input_event->type == KeyPress) || (input_event->type == ButtonPress)))
{
if (CurrentTime == display->current_time)
{
@ -1974,10 +2001,11 @@ event_callback (XEvent *event,
}
}
switch (event->type)
switch (input_event->type)
{
case KeyPress:
case KeyRelease:
/* For key events, it's important to enforce single-handling, or
* we can get into a confused state. So if a keybinding is
* handled (because it's one of our hot-keys, or because we are
@ -2301,8 +2329,8 @@ event_callback (XEvent *event,
meta_topic (META_DEBUG_FOCUS,
"Focus %s event received on no_focus_window 0x%lx "
"mode %s detail %s\n",
event->type == FocusIn ? "in" :
event->type == FocusOut ? "out" :
input_event->type == FocusIn ? "in" :
input_event->type == FocusOut ? "out" :
"???",
event->xany.window,
meta_event_mode_to_string (event->xfocus.mode),
@ -2319,14 +2347,14 @@ event_callback (XEvent *event,
meta_topic (META_DEBUG_FOCUS,
"Focus %s event received on root window 0x%lx "
"mode %s detail %s\n",
event->type == FocusIn ? "in" :
event->type == FocusOut ? "out" :
input_event->type == FocusIn ? "in" :
input_event->type == FocusOut ? "out" :
"???",
event->xany.window,
meta_event_mode_to_string (event->xfocus.mode),
meta_event_detail_to_string (event->xfocus.detail));
if (event->type == FocusIn &&
if (input_event->type == FocusIn &&
event->xfocus.detail == NotifyDetailNone)
{
meta_topic (META_DEBUG_FOCUS,
@ -2337,7 +2365,7 @@ event_callback (XEvent *event,
NULL,
meta_display_get_current_time_roundtrip (display));
}
else if (event->type == FocusIn &&
else if (input_event->type == FocusIn &&
event->xfocus.mode == NotifyNormal &&
event->xfocus.detail == NotifyInferior)
{
@ -2352,6 +2380,12 @@ event_callback (XEvent *event,
}
break;
}
}
else
{
switch (event->type)
{
case KeymapNotify:
break;
case Expose:
@ -2838,6 +2872,7 @@ event_callback (XEvent *event,
#endif
break;
}
}
if (display->compositor && !bypass_compositor)
{