gdkevents-x11: Do not break strict-aliasing rules

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=619385
This commit is contained in:
Javier Jardón 2010-05-22 22:42:00 +02:00
parent 7f89bf262b
commit 5917eba911

View File

@ -68,6 +68,8 @@ typedef struct _GdkIOClosure GdkIOClosure;
typedef struct _GdkDisplaySource GdkDisplaySource; typedef struct _GdkDisplaySource GdkDisplaySource;
typedef struct _GdkEventTypeX11 GdkEventTypeX11; typedef struct _GdkEventTypeX11 GdkEventTypeX11;
typedef union _GdkNotifyEvent GdkNotifyEvent;
struct _GdkIOClosure struct _GdkIOClosure
{ {
GdkInputFunction function; GdkInputFunction function;
@ -90,6 +92,13 @@ struct _GdkEventTypeX11
gint n_events; gint n_events;
}; };
union _GdkNotifyEvent
{
XEvent xevent;
XFixesSelectionNotifyEvent selection_notify;
XDamageNotifyEvent damage_event;
};
/* /*
* Private function declarations * Private function declarations
*/ */
@ -845,7 +854,7 @@ gdk_event_translate (GdkDisplay *display,
XEvent *xevent, XEvent *xevent,
gboolean return_exposes) gboolean return_exposes)
{ {
GdkNotifyEvent *notify_event;
GdkWindow *window; GdkWindow *window;
GdkWindowObject *window_private; GdkWindowObject *window_private;
GdkWindow *filter_window; GdkWindow *filter_window;
@ -2020,6 +2029,13 @@ gdk_event_translate (GdkDisplay *display,
break; break;
default: default:
notify_event = (GdkNotifyEvent *) xevent;
#ifdef HAVE_XFIXES
XFixesSelectionNotifyEvent *selection_notify = &(notify_event->selection_notify);
#endif
#ifdef HAVE_XDAMAGE
XDamageNotifyEvent *damage_event = &(notify_event->damage_event);
#endif
#ifdef HAVE_XKB #ifdef HAVE_XKB
if (xevent->type == display_x11->xkb_event_type) if (xevent->type == display_x11->xkb_event_type)
{ {
@ -2044,8 +2060,6 @@ gdk_event_translate (GdkDisplay *display,
#ifdef HAVE_XFIXES #ifdef HAVE_XFIXES
if (xevent->type - display_x11->xfixes_event_base == XFixesSelectionNotify) if (xevent->type - display_x11->xfixes_event_base == XFixesSelectionNotify)
{ {
XFixesSelectionNotifyEvent *selection_notify = (XFixesSelectionNotifyEvent *)xevent;
_gdk_x11_screen_process_owner_change (screen, xevent); _gdk_x11_screen_process_owner_change (screen, xevent);
event->owner_change.type = GDK_OWNER_CHANGE; event->owner_change.type = GDK_OWNER_CHANGE;
@ -2074,9 +2088,8 @@ gdk_event_translate (GdkDisplay *display,
#if defined(HAVE_XCOMPOSITE) && defined (HAVE_XDAMAGE) && defined (HAVE_XFIXES) #if defined(HAVE_XCOMPOSITE) && defined (HAVE_XDAMAGE) && defined (HAVE_XFIXES)
if (display_x11->have_xdamage && window_private && window_private->composited && if (display_x11->have_xdamage && window_private && window_private->composited &&
xevent->type == display_x11->xdamage_event_base + XDamageNotify && xevent->type == display_x11->xdamage_event_base + XDamageNotify &&
((XDamageNotifyEvent *) xevent)->damage == window_impl->damage) damage_event->damage == window_impl->damage)
{ {
XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) xevent;
XserverRegion repair; XserverRegion repair;
GdkRectangle rect; GdkRectangle rect;