mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
x11/events: Clean up event name getting
Preparation for adding a generic "get event name" getter. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
This commit is contained in:
parent
8bd75747b1
commit
72704f787c
199
src/x11/events.c
199
src/x11/events.c
@ -359,6 +359,28 @@ alarm_state_to_string (XSyncAlarmState state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
get_xi2_event_name (XIEvent *input_event)
|
||||||
|
{
|
||||||
|
switch (input_event->evtype)
|
||||||
|
{
|
||||||
|
case XI_FocusIn:
|
||||||
|
return "XI_FocusIn";
|
||||||
|
case XI_FocusOut:
|
||||||
|
return "XI_FocusOut";
|
||||||
|
case XI_Enter:
|
||||||
|
return "XI_Enter";
|
||||||
|
case XI_Leave:
|
||||||
|
return "XI_Leave";
|
||||||
|
case XI_BarrierHit:
|
||||||
|
return "XI_BarrierHit";
|
||||||
|
case XI_BarrierLeave:
|
||||||
|
return "XI_BarrierLeave";
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_spew_xi2_event (MetaX11Display *x11_display,
|
meta_spew_xi2_event (MetaX11Display *x11_display,
|
||||||
XIEvent *input_event,
|
XIEvent *input_event,
|
||||||
@ -370,27 +392,7 @@ meta_spew_xi2_event (MetaX11Display *x11_display,
|
|||||||
|
|
||||||
XIEnterEvent *enter_event = (XIEnterEvent *) input_event;
|
XIEnterEvent *enter_event = (XIEnterEvent *) input_event;
|
||||||
|
|
||||||
switch (input_event->evtype)
|
name = get_xi2_event_name (input_event);
|
||||||
{
|
|
||||||
case XI_FocusIn:
|
|
||||||
name = "XI_FocusIn";
|
|
||||||
break;
|
|
||||||
case XI_FocusOut:
|
|
||||||
name = "XI_FocusOut";
|
|
||||||
break;
|
|
||||||
case XI_Enter:
|
|
||||||
name = "XI_Enter";
|
|
||||||
break;
|
|
||||||
case XI_Leave:
|
|
||||||
name = "XI_Leave";
|
|
||||||
break;
|
|
||||||
case XI_BarrierHit:
|
|
||||||
name = "XI_BarrierHit";
|
|
||||||
break;
|
|
||||||
case XI_BarrierLeave:
|
|
||||||
name = "XI_BarrierLeave";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (input_event->evtype)
|
switch (input_event->evtype)
|
||||||
{
|
{
|
||||||
@ -417,6 +419,105 @@ meta_spew_xi2_event (MetaX11Display *x11_display,
|
|||||||
*extra_p = extra;
|
*extra_p = extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
get_core_event_name (XEvent *event)
|
||||||
|
{
|
||||||
|
/* GenericEvent is omitted here, as it's handled separately. */
|
||||||
|
switch (event->type)
|
||||||
|
{
|
||||||
|
case KeyPress:
|
||||||
|
return "KeyPress";
|
||||||
|
case KeyRelease:
|
||||||
|
return "KeyRelease";
|
||||||
|
case ButtonPress:
|
||||||
|
return "ButtonPress";
|
||||||
|
case ButtonRelease:
|
||||||
|
return "ButtonRelease";
|
||||||
|
case MotionNotify:
|
||||||
|
return "MotionNotify";
|
||||||
|
case EnterNotify:
|
||||||
|
return "EnterNotify";
|
||||||
|
case LeaveNotify:
|
||||||
|
return "LeaveNotify";
|
||||||
|
case FocusIn:
|
||||||
|
return "FocusIn";
|
||||||
|
case FocusOut:
|
||||||
|
return "FocusOut";
|
||||||
|
case KeymapNotify:
|
||||||
|
return "KeymapNotify";
|
||||||
|
case Expose:
|
||||||
|
return "Expose";
|
||||||
|
case GraphicsExpose:
|
||||||
|
return "GraphicsExpose";
|
||||||
|
case NoExpose:
|
||||||
|
return "NoExpose";
|
||||||
|
case VisibilityNotify:
|
||||||
|
return "VisibilityNotify";
|
||||||
|
case CreateNotify:
|
||||||
|
return "CreateNotify";
|
||||||
|
case DestroyNotify:
|
||||||
|
return "DestroyNotify";
|
||||||
|
case UnmapNotify:
|
||||||
|
return "UnmapNotify";
|
||||||
|
case MapNotify:
|
||||||
|
return "MapNotify";
|
||||||
|
case MapRequest:
|
||||||
|
return "MapRequest";
|
||||||
|
case ReparentNotify:
|
||||||
|
return "ReparentNotify";
|
||||||
|
case ConfigureNotify:
|
||||||
|
return "ConfigureNotify";
|
||||||
|
case ConfigureRequest:
|
||||||
|
return "ConfigureRequest";
|
||||||
|
case GravityNotify:
|
||||||
|
return "GravityNotify";
|
||||||
|
case ResizeRequest:
|
||||||
|
return "ResizeRequest";
|
||||||
|
case CirculateNotify:
|
||||||
|
return "CirculateNotify";
|
||||||
|
case CirculateRequest:
|
||||||
|
return "CirculateRequest";
|
||||||
|
case PropertyNotify:
|
||||||
|
return "PropertyNotify";
|
||||||
|
case SelectionClear:
|
||||||
|
return "SelectionClear";
|
||||||
|
case SelectionRequest:
|
||||||
|
return "SelectionRequest";
|
||||||
|
case SelectionNotify:
|
||||||
|
return "SelectionNotify";
|
||||||
|
case ColormapNotify:
|
||||||
|
return "ColormapNotify";
|
||||||
|
case ClientMessage:
|
||||||
|
return "ClientMessage";
|
||||||
|
case MappingNotify:
|
||||||
|
return "MappingNotify";
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
get_extension_event_name (MetaX11Display *x11_display,
|
||||||
|
XEvent *event)
|
||||||
|
{
|
||||||
|
if (META_X11_DISPLAY_HAS_XSYNC (x11_display) &&
|
||||||
|
event->type == (x11_display->xsync_event_base + XSyncAlarmNotify))
|
||||||
|
return "XSyncAlarmNotify";
|
||||||
|
|
||||||
|
if (META_X11_DISPLAY_HAS_SHAPE (x11_display) &&
|
||||||
|
event->type == (x11_display->shape_event_base + ShapeNotify))
|
||||||
|
return "ShapeNotify";
|
||||||
|
|
||||||
|
if (META_X11_DISPLAY_HAS_DAMAGE (x11_display) &&
|
||||||
|
event->type == (x11_display->damage_event_base + XDamageNotify))
|
||||||
|
return "XDamageNotify";
|
||||||
|
|
||||||
|
if (event->type == (x11_display->xfixes_event_base + XFixesSelectionNotify))
|
||||||
|
return "XFixesSelectionNotify";
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_spew_core_event (MetaX11Display *x11_display,
|
meta_spew_core_event (MetaX11Display *x11_display,
|
||||||
XEvent *event,
|
XEvent *event,
|
||||||
@ -426,64 +527,60 @@ meta_spew_core_event (MetaX11Display *x11_display,
|
|||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
char *extra = NULL;
|
char *extra = NULL;
|
||||||
|
|
||||||
|
name = get_core_event_name (event);
|
||||||
|
|
||||||
|
if (!name)
|
||||||
|
name = get_extension_event_name (x11_display, event);
|
||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
case KeymapNotify:
|
case KeymapNotify:
|
||||||
name = "KeymapNotify";
|
|
||||||
break;
|
|
||||||
case Expose:
|
case Expose:
|
||||||
name = "Expose";
|
|
||||||
break;
|
|
||||||
case GraphicsExpose:
|
case GraphicsExpose:
|
||||||
name = "GraphicsExpose";
|
|
||||||
break;
|
|
||||||
case NoExpose:
|
case NoExpose:
|
||||||
name = "NoExpose";
|
|
||||||
break;
|
|
||||||
case VisibilityNotify:
|
case VisibilityNotify:
|
||||||
name = "VisibilityNotify";
|
case GravityNotify:
|
||||||
|
case CirculateNotify:
|
||||||
|
case CirculateRequest:
|
||||||
|
case SelectionClear:
|
||||||
|
case SelectionRequest:
|
||||||
|
case SelectionNotify:
|
||||||
|
case ColormapNotify:
|
||||||
break;
|
break;
|
||||||
case CreateNotify:
|
case CreateNotify:
|
||||||
name = "CreateNotify";
|
|
||||||
extra = g_strdup_printf ("parent: 0x%lx window: 0x%lx",
|
extra = g_strdup_printf ("parent: 0x%lx window: 0x%lx",
|
||||||
event->xcreatewindow.parent,
|
event->xcreatewindow.parent,
|
||||||
event->xcreatewindow.window);
|
event->xcreatewindow.window);
|
||||||
break;
|
break;
|
||||||
case DestroyNotify:
|
case DestroyNotify:
|
||||||
name = "DestroyNotify";
|
|
||||||
extra = g_strdup_printf ("event: 0x%lx window: 0x%lx",
|
extra = g_strdup_printf ("event: 0x%lx window: 0x%lx",
|
||||||
event->xdestroywindow.event,
|
event->xdestroywindow.event,
|
||||||
event->xdestroywindow.window);
|
event->xdestroywindow.window);
|
||||||
break;
|
break;
|
||||||
case UnmapNotify:
|
case UnmapNotify:
|
||||||
name = "UnmapNotify";
|
|
||||||
extra = g_strdup_printf ("event: 0x%lx window: 0x%lx from_configure: %d",
|
extra = g_strdup_printf ("event: 0x%lx window: 0x%lx from_configure: %d",
|
||||||
event->xunmap.event,
|
event->xunmap.event,
|
||||||
event->xunmap.window,
|
event->xunmap.window,
|
||||||
event->xunmap.from_configure);
|
event->xunmap.from_configure);
|
||||||
break;
|
break;
|
||||||
case MapNotify:
|
case MapNotify:
|
||||||
name = "MapNotify";
|
|
||||||
extra = g_strdup_printf ("event: 0x%lx window: 0x%lx override_redirect: %d",
|
extra = g_strdup_printf ("event: 0x%lx window: 0x%lx override_redirect: %d",
|
||||||
event->xmap.event,
|
event->xmap.event,
|
||||||
event->xmap.window,
|
event->xmap.window,
|
||||||
event->xmap.override_redirect);
|
event->xmap.override_redirect);
|
||||||
break;
|
break;
|
||||||
case MapRequest:
|
case MapRequest:
|
||||||
name = "MapRequest";
|
|
||||||
extra = g_strdup_printf ("window: 0x%lx parent: 0x%lx\n",
|
extra = g_strdup_printf ("window: 0x%lx parent: 0x%lx\n",
|
||||||
event->xmaprequest.window,
|
event->xmaprequest.window,
|
||||||
event->xmaprequest.parent);
|
event->xmaprequest.parent);
|
||||||
break;
|
break;
|
||||||
case ReparentNotify:
|
case ReparentNotify:
|
||||||
name = "ReparentNotify";
|
|
||||||
extra = g_strdup_printf ("window: 0x%lx parent: 0x%lx event: 0x%lx\n",
|
extra = g_strdup_printf ("window: 0x%lx parent: 0x%lx event: 0x%lx\n",
|
||||||
event->xreparent.window,
|
event->xreparent.window,
|
||||||
event->xreparent.parent,
|
event->xreparent.parent,
|
||||||
event->xreparent.event);
|
event->xreparent.event);
|
||||||
break;
|
break;
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
name = "ConfigureNotify";
|
|
||||||
extra = g_strdup_printf ("x: %d y: %d w: %d h: %d above: 0x%lx override_redirect: %d",
|
extra = g_strdup_printf ("x: %d y: %d w: %d h: %d above: 0x%lx override_redirect: %d",
|
||||||
event->xconfigure.x,
|
event->xconfigure.x,
|
||||||
event->xconfigure.y,
|
event->xconfigure.y,
|
||||||
@ -493,7 +590,6 @@ meta_spew_core_event (MetaX11Display *x11_display,
|
|||||||
event->xconfigure.override_redirect);
|
event->xconfigure.override_redirect);
|
||||||
break;
|
break;
|
||||||
case ConfigureRequest:
|
case ConfigureRequest:
|
||||||
name = "ConfigureRequest";
|
|
||||||
extra = g_strdup_printf ("parent: 0x%lx window: 0x%lx x: %d %sy: %d %sw: %d %sh: %d %sborder: %d %sabove: %lx %sstackmode: %s %s",
|
extra = g_strdup_printf ("parent: 0x%lx window: 0x%lx x: %d %sy: %d %sw: %d %sh: %d %sborder: %d %sabove: %lx %sstackmode: %s %s",
|
||||||
event->xconfigurerequest.parent,
|
event->xconfigurerequest.parent,
|
||||||
event->xconfigurerequest.window,
|
event->xconfigurerequest.window,
|
||||||
@ -519,28 +615,16 @@ meta_spew_core_event (MetaX11Display *x11_display,
|
|||||||
event->xconfigurerequest.value_mask &
|
event->xconfigurerequest.value_mask &
|
||||||
CWStackMode ? "" : "(unset)");
|
CWStackMode ? "" : "(unset)");
|
||||||
break;
|
break;
|
||||||
case GravityNotify:
|
|
||||||
name = "GravityNotify";
|
|
||||||
break;
|
|
||||||
case ResizeRequest:
|
case ResizeRequest:
|
||||||
name = "ResizeRequest";
|
|
||||||
extra = g_strdup_printf ("width = %d height = %d",
|
extra = g_strdup_printf ("width = %d height = %d",
|
||||||
event->xresizerequest.width,
|
event->xresizerequest.width,
|
||||||
event->xresizerequest.height);
|
event->xresizerequest.height);
|
||||||
break;
|
break;
|
||||||
case CirculateNotify:
|
|
||||||
name = "CirculateNotify";
|
|
||||||
break;
|
|
||||||
case CirculateRequest:
|
|
||||||
name = "CirculateRequest";
|
|
||||||
break;
|
|
||||||
case PropertyNotify:
|
case PropertyNotify:
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
const char *state;
|
const char *state;
|
||||||
|
|
||||||
name = "PropertyNotify";
|
|
||||||
|
|
||||||
meta_x11_error_trap_push (x11_display);
|
meta_x11_error_trap_push (x11_display);
|
||||||
str = XGetAtomName (x11_display->xdisplay,
|
str = XGetAtomName (x11_display->xdisplay,
|
||||||
event->xproperty.atom);
|
event->xproperty.atom);
|
||||||
@ -559,22 +643,9 @@ meta_spew_core_event (MetaX11Display *x11_display,
|
|||||||
meta_XFree (str);
|
meta_XFree (str);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SelectionClear:
|
|
||||||
name = "SelectionClear";
|
|
||||||
break;
|
|
||||||
case SelectionRequest:
|
|
||||||
name = "SelectionRequest";
|
|
||||||
break;
|
|
||||||
case SelectionNotify:
|
|
||||||
name = "SelectionNotify";
|
|
||||||
break;
|
|
||||||
case ColormapNotify:
|
|
||||||
name = "ColormapNotify";
|
|
||||||
break;
|
|
||||||
case ClientMessage:
|
case ClientMessage:
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
name = "ClientMessage";
|
|
||||||
meta_x11_error_trap_push (x11_display);
|
meta_x11_error_trap_push (x11_display);
|
||||||
str = XGetAtomName (x11_display->xdisplay,
|
str = XGetAtomName (x11_display->xdisplay,
|
||||||
event->xclient.message_type);
|
event->xclient.message_type);
|
||||||
@ -586,7 +657,6 @@ meta_spew_core_event (MetaX11Display *x11_display,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MappingNotify:
|
case MappingNotify:
|
||||||
name = "MappingNotify";
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (META_X11_DISPLAY_HAS_XSYNC (x11_display) &&
|
if (META_X11_DISPLAY_HAS_XSYNC (x11_display) &&
|
||||||
@ -594,7 +664,6 @@ meta_spew_core_event (MetaX11Display *x11_display,
|
|||||||
{
|
{
|
||||||
XSyncAlarmNotifyEvent *aevent = (XSyncAlarmNotifyEvent*) event;
|
XSyncAlarmNotifyEvent *aevent = (XSyncAlarmNotifyEvent*) event;
|
||||||
|
|
||||||
name = "XSyncAlarmNotify";
|
|
||||||
extra =
|
extra =
|
||||||
g_strdup_printf ("alarm: 0x%lx"
|
g_strdup_printf ("alarm: 0x%lx"
|
||||||
" counter_value: %" G_GINT64_FORMAT
|
" counter_value: %" G_GINT64_FORMAT
|
||||||
|
Loading…
Reference in New Issue
Block a user