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.
+
* gtk/gtkmenu.c (gtk_menu_grab_notify): Cancel menus when
they are grab-shadowed by something thats not a
submenu. (#145416, Euan MacGregor)
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.
+
* gtk/gtkmenu.c (gtk_menu_grab_notify): Cancel menus when
they are grab-shadowed by something thats not a
submenu. (#145416, Euan MacGregor)
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.
+
* gtk/gtkmenu.c (gtk_menu_grab_notify): Cancel menus when
they are grab-shadowed by something thats not a
submenu. (#145416, Euan MacGregor)
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.
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;
}
/**
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;
}
/**
GdkWindowObject *pointer_xgrab_window;
gulong pointer_xgrab_serial;
gboolean pointer_xgrab_owner_events;
+ guint32 pointer_xgrab_time;
GdkWindowObject *keyboard_xgrab_window;
gulong keyboard_xgrab_serial;
gboolean keyboard_xgrab_owner_events;
+ guint32 keyboard_xgrab_time;
/* drag and drop information */
GdkDragContext *current_dest_drag;
if (return_val == GrabSuccess)
{
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (window));
-#if 0
if (display_x11->pointer_xgrab_window != NULL)
{
+ g_print ("overgrab pointer\n");
+#if 0
generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_xgrab_window),
FALSE);
- }
#endif
+ }
display_x11->pointer_xgrab_window = (GdkWindowObject *)window;
display_x11->pointer_xgrab_serial = serial;
display_x11->pointer_xgrab_owner_events = owner_events;
+ display_x11->pointer_xgrab_time = time;
}
return gdk_x11_convert_grab_status (return_val);
if (return_val == GrabSuccess)
{
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (gdk_drawable_get_display (window));
-#if 0
if (display_x11->keyboard_xgrab_window != NULL)
{
+ g_print ("overgrab keyboard\n");
+#if 0
generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
TRUE);
- }
#endif
+ }
display_x11->keyboard_xgrab_window = (GdkWindowObject *)window;
display_x11->keyboard_xgrab_serial = serial;
display_x11->keyboard_xgrab_owner_events = owner_events;
+ display_x11->keyboard_xgrab_time = time;
}
return gdk_x11_convert_grab_status (return_val);
if (tmp)
{
+ g_print ("pointer grab broken from check unmap\n");
generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_xgrab_window),
FALSE);
display_x11->pointer_xgrab_window = NULL;
if (tmp)
{
+ g_print ("keyboard grab broken from check unmap\n");
generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
TRUE);
display_x11->keyboard_xgrab_window = NULL;
if ((GdkWindowObject *)window == display_x11->pointer_xgrab_window)
{
+ g_print ("pointer grab broken from check destroy\n");
generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_xgrab_window),
FALSE);
display_x11->pointer_xgrab_window = NULL;
if ((GdkWindowObject *)window == display_x11->keyboard_xgrab_window)
{
+ g_print ("keyboard grab broken from check destroy\n");
generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
TRUE);
display_x11->keyboard_xgrab_window = NULL;
if (context_xim->im_info)
{
- GdkDisplay *display;
- XIMCallback im_destroy_callback;
-
- display = gdk_screen_get_display (context_xim->im_info->screen);
- XUnregisterIMInstantiateCallback (GDK_DISPLAY_XDISPLAY (display),
- NULL, NULL, NULL,
- xim_instantiate_callback,
- (XPointer)context_xim->im_info);
-
- im_destroy_callback.client_data = NULL;
- im_destroy_callback.callback = NULL;
- XSetIMValues (context_xim->im_info->im,
- XNDestroyCallback, &im_destroy_callback,
- NULL);
+ if (context_xim->im_info->reconnecting)
+ {
+ GdkDisplay *display;
+
+ display = gdk_screen_get_display (context_xim->im_info->screen);
+ XUnregisterIMInstantiateCallback (GDK_DISPLAY_XDISPLAY (display),
+ NULL, NULL, NULL,
+ xim_instantiate_callback,
+ (XPointer)context_xim->im_info);
+ }
+ else
+ {
+ XIMCallback im_destroy_callback;
+
+ im_destroy_callback.client_data = NULL;
+ im_destroy_callback.callback = NULL;
+ XSetIMValues (context_xim->im_info->im,
+ XNDestroyCallback, &im_destroy_callback,
+ NULL);
+ }
}
set_ic_client_window (context_xim, NULL);