Avoid a segfault. (#309054)
2005-06-27 Matthias Clasen <mclasen@redhat.com> * modules/input/gtkimcontextxim.c (gtk_im_context_xim_finalize): Avoid a segfault. (#309054) * gdk/x11/gdkdisplay-x11.h (struct _GdkDisplayX11): Add fields for grab timestamps. * gdk/x11/gdkmain-x11.c (gdk_pointer_grab, gdk_keyboard_grab): Store grab timestamps when grabbing. * gdk/x11/gdkdisplay-x11.c (gdk_display_keyboard_ungrab) (gdk_display_pointer_ungrab): Don't unset the grab_window if the timestamps indicate that the ungrab will fails.
This commit is contained in:
committed by
Matthias Clasen
parent
ddd27f21a6
commit
c719b4bf3d
@ -488,6 +488,11 @@ _gdk_x11_display_is_root_window (GdkDisplay *display,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define XSERVER_TIME_IS_LATER(time1, time2) \
|
||||
( (( time1 > time2 ) && ( time1 - time2 < ((guint32)-1)/2 )) || \
|
||||
(( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 )) \
|
||||
)
|
||||
|
||||
/**
|
||||
* gdk_display_pointer_ungrab:
|
||||
* @display: a #GdkDisplay.
|
||||
@ -502,16 +507,21 @@ gdk_display_pointer_ungrab (GdkDisplay *display,
|
||||
guint32 time)
|
||||
{
|
||||
Display *xdisplay;
|
||||
|
||||
GdkDisplayX11 *display_x11;
|
||||
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
|
||||
display_x11 = GDK_DISPLAY_X11 (display);
|
||||
xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
||||
|
||||
_gdk_input_ungrab_pointer (display, time);
|
||||
XUngrabPointer (xdisplay, time);
|
||||
XFlush (xdisplay);
|
||||
|
||||
GDK_DISPLAY_X11 (display)->pointer_xgrab_window = NULL;
|
||||
|
||||
if (time == GDK_CURRENT_TIME ||
|
||||
display_x11->pointer_xgrab_time == GDK_CURRENT_TIME ||
|
||||
!XSERVER_TIME_IS_LATER (display_x11->pointer_xgrab_time, time))
|
||||
display_x11->pointer_xgrab_window = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -546,15 +556,20 @@ gdk_display_keyboard_ungrab (GdkDisplay *display,
|
||||
guint32 time)
|
||||
{
|
||||
Display *xdisplay;
|
||||
GdkDisplayX11 *display_x11;
|
||||
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
|
||||
display_x11 = GDK_DISPLAY_X11 (display);
|
||||
xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
||||
|
||||
XUngrabKeyboard (xdisplay, time);
|
||||
XFlush (xdisplay);
|
||||
|
||||
GDK_DISPLAY_X11 (display)->keyboard_xgrab_window = NULL;
|
||||
if (time == GDK_CURRENT_TIME ||
|
||||
display_x11->keyboard_xgrab_time == GDK_CURRENT_TIME ||
|
||||
!XSERVER_TIME_IS_LATER (display_x11->keyboard_xgrab_time, time))
|
||||
display_x11->keyboard_xgrab_window = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user