mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
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:
parent
ddd27f21a6
commit
c719b4bf3d
13
ChangeLog
13
ChangeLog
@ -1,5 +1,18 @@
|
|||||||
2005-06-27 Matthias Clasen <mclasen@redhat.com>
|
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
|
* gtk/gtkmenu.c (gtk_menu_grab_notify): Cancel menus when
|
||||||
they are grab-shadowed by something thats not a
|
they are grab-shadowed by something thats not a
|
||||||
submenu. (#145416, Euan MacGregor)
|
submenu. (#145416, Euan MacGregor)
|
||||||
|
@ -1,5 +1,18 @@
|
|||||||
2005-06-27 Matthias Clasen <mclasen@redhat.com>
|
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
|
* gtk/gtkmenu.c (gtk_menu_grab_notify): Cancel menus when
|
||||||
they are grab-shadowed by something thats not a
|
they are grab-shadowed by something thats not a
|
||||||
submenu. (#145416, Euan MacGregor)
|
submenu. (#145416, Euan MacGregor)
|
||||||
|
@ -1,5 +1,18 @@
|
|||||||
2005-06-27 Matthias Clasen <mclasen@redhat.com>
|
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
|
* gtk/gtkmenu.c (gtk_menu_grab_notify): Cancel menus when
|
||||||
they are grab-shadowed by something thats not a
|
they are grab-shadowed by something thats not a
|
||||||
submenu. (#145416, Euan MacGregor)
|
submenu. (#145416, Euan MacGregor)
|
||||||
|
@ -488,6 +488,11 @@ _gdk_x11_display_is_root_window (GdkDisplay *display,
|
|||||||
return FALSE;
|
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:
|
* gdk_display_pointer_ungrab:
|
||||||
* @display: a #GdkDisplay.
|
* @display: a #GdkDisplay.
|
||||||
@ -502,16 +507,21 @@ gdk_display_pointer_ungrab (GdkDisplay *display,
|
|||||||
guint32 time)
|
guint32 time)
|
||||||
{
|
{
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
|
GdkDisplayX11 *display_x11;
|
||||||
|
|
||||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||||
|
|
||||||
|
display_x11 = GDK_DISPLAY_X11 (display);
|
||||||
xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
||||||
|
|
||||||
_gdk_input_ungrab_pointer (display, time);
|
_gdk_input_ungrab_pointer (display, time);
|
||||||
XUngrabPointer (xdisplay, time);
|
XUngrabPointer (xdisplay, time);
|
||||||
XFlush (xdisplay);
|
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)
|
guint32 time)
|
||||||
{
|
{
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
|
GdkDisplayX11 *display_x11;
|
||||||
|
|
||||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||||
|
|
||||||
|
display_x11 = GDK_DISPLAY_X11 (display);
|
||||||
xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
||||||
|
|
||||||
XUngrabKeyboard (xdisplay, time);
|
XUngrabKeyboard (xdisplay, time);
|
||||||
XFlush (xdisplay);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,10 +88,12 @@ struct _GdkDisplayX11
|
|||||||
GdkWindowObject *pointer_xgrab_window;
|
GdkWindowObject *pointer_xgrab_window;
|
||||||
gulong pointer_xgrab_serial;
|
gulong pointer_xgrab_serial;
|
||||||
gboolean pointer_xgrab_owner_events;
|
gboolean pointer_xgrab_owner_events;
|
||||||
|
guint32 pointer_xgrab_time;
|
||||||
|
|
||||||
GdkWindowObject *keyboard_xgrab_window;
|
GdkWindowObject *keyboard_xgrab_window;
|
||||||
gulong keyboard_xgrab_serial;
|
gulong keyboard_xgrab_serial;
|
||||||
gboolean keyboard_xgrab_owner_events;
|
gboolean keyboard_xgrab_owner_events;
|
||||||
|
guint32 keyboard_xgrab_time;
|
||||||
|
|
||||||
/* drag and drop information */
|
/* drag and drop information */
|
||||||
GdkDragContext *current_dest_drag;
|
GdkDragContext *current_dest_drag;
|
||||||
|
@ -251,17 +251,19 @@ gdk_pointer_grab (GdkWindow * window,
|
|||||||
if (return_val == GrabSuccess)
|
if (return_val == GrabSuccess)
|
||||||
{
|
{
|
||||||
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (window));
|
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (window));
|
||||||
#if 0
|
|
||||||
if (display_x11->pointer_xgrab_window != NULL)
|
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),
|
generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_xgrab_window),
|
||||||
FALSE);
|
FALSE);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
display_x11->pointer_xgrab_window = (GdkWindowObject *)window;
|
display_x11->pointer_xgrab_window = (GdkWindowObject *)window;
|
||||||
display_x11->pointer_xgrab_serial = serial;
|
display_x11->pointer_xgrab_serial = serial;
|
||||||
display_x11->pointer_xgrab_owner_events = owner_events;
|
display_x11->pointer_xgrab_owner_events = owner_events;
|
||||||
|
display_x11->pointer_xgrab_time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gdk_x11_convert_grab_status (return_val);
|
return gdk_x11_convert_grab_status (return_val);
|
||||||
@ -356,16 +358,18 @@ gdk_keyboard_grab (GdkWindow * window,
|
|||||||
if (return_val == GrabSuccess)
|
if (return_val == GrabSuccess)
|
||||||
{
|
{
|
||||||
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (gdk_drawable_get_display (window));
|
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (gdk_drawable_get_display (window));
|
||||||
#if 0
|
|
||||||
if (display_x11->keyboard_xgrab_window != NULL)
|
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),
|
generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
|
||||||
TRUE);
|
TRUE);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
display_x11->keyboard_xgrab_window = (GdkWindowObject *)window;
|
display_x11->keyboard_xgrab_window = (GdkWindowObject *)window;
|
||||||
display_x11->keyboard_xgrab_serial = serial;
|
display_x11->keyboard_xgrab_serial = serial;
|
||||||
display_x11->keyboard_xgrab_owner_events = owner_events;
|
display_x11->keyboard_xgrab_owner_events = owner_events;
|
||||||
|
display_x11->keyboard_xgrab_time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gdk_x11_convert_grab_status (return_val);
|
return gdk_x11_convert_grab_status (return_val);
|
||||||
@ -435,6 +439,7 @@ _gdk_xgrab_check_unmap (GdkWindow *window,
|
|||||||
|
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
|
g_print ("pointer grab broken from check unmap\n");
|
||||||
generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_xgrab_window),
|
generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_xgrab_window),
|
||||||
FALSE);
|
FALSE);
|
||||||
display_x11->pointer_xgrab_window = NULL;
|
display_x11->pointer_xgrab_window = NULL;
|
||||||
@ -453,6 +458,7 @@ _gdk_xgrab_check_unmap (GdkWindow *window,
|
|||||||
|
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
|
g_print ("keyboard grab broken from check unmap\n");
|
||||||
generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
|
generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
|
||||||
TRUE);
|
TRUE);
|
||||||
display_x11->keyboard_xgrab_window = NULL;
|
display_x11->keyboard_xgrab_window = NULL;
|
||||||
@ -474,6 +480,7 @@ _gdk_xgrab_check_destroy (GdkWindow *window)
|
|||||||
|
|
||||||
if ((GdkWindowObject *)window == display_x11->pointer_xgrab_window)
|
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),
|
generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_xgrab_window),
|
||||||
FALSE);
|
FALSE);
|
||||||
display_x11->pointer_xgrab_window = NULL;
|
display_x11->pointer_xgrab_window = NULL;
|
||||||
@ -481,6 +488,7 @@ _gdk_xgrab_check_destroy (GdkWindow *window)
|
|||||||
|
|
||||||
if ((GdkWindowObject *)window == display_x11->keyboard_xgrab_window)
|
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),
|
generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
|
||||||
TRUE);
|
TRUE);
|
||||||
display_x11->keyboard_xgrab_window = NULL;
|
display_x11->keyboard_xgrab_window = NULL;
|
||||||
|
@ -567,20 +567,26 @@ gtk_im_context_xim_finalize (GObject *obj)
|
|||||||
|
|
||||||
if (context_xim->im_info)
|
if (context_xim->im_info)
|
||||||
{
|
{
|
||||||
GdkDisplay *display;
|
if (context_xim->im_info->reconnecting)
|
||||||
XIMCallback im_destroy_callback;
|
{
|
||||||
|
GdkDisplay *display;
|
||||||
|
|
||||||
display = gdk_screen_get_display (context_xim->im_info->screen);
|
display = gdk_screen_get_display (context_xim->im_info->screen);
|
||||||
XUnregisterIMInstantiateCallback (GDK_DISPLAY_XDISPLAY (display),
|
XUnregisterIMInstantiateCallback (GDK_DISPLAY_XDISPLAY (display),
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
xim_instantiate_callback,
|
xim_instantiate_callback,
|
||||||
(XPointer)context_xim->im_info);
|
(XPointer)context_xim->im_info);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XIMCallback im_destroy_callback;
|
||||||
|
|
||||||
im_destroy_callback.client_data = NULL;
|
im_destroy_callback.client_data = NULL;
|
||||||
im_destroy_callback.callback = NULL;
|
im_destroy_callback.callback = NULL;
|
||||||
XSetIMValues (context_xim->im_info->im,
|
XSetIMValues (context_xim->im_info->im,
|
||||||
XNDestroyCallback, &im_destroy_callback,
|
XNDestroyCallback, &im_destroy_callback,
|
||||||
NULL);
|
NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_ic_client_window (context_xim, NULL);
|
set_ic_client_window (context_xim, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user