gdk: event filter, X11 and quartz fixes from GTK 3
Backported from GTK 3: - an event filter removed and re-added while running runs again - an untrusted X client no longer dies on a beep - no pid in a Flatpak sandbox that the window manager could kill - quartz drops the pointers of a destroyed window - win32 centers on a fully set rectangle Upstream commits: - 5ac848d229 (Руслан Ижбулатов) - a73fa04e92 (Matthias Clasen) - 9c84f7645e (Matthias Clasen) - 749c863073 (John Ralls)
This commit is contained in:
parent
8b50a92bbd
commit
bb636048f2
6 changed files with 53 additions and 12 deletions
|
|
@ -2731,6 +2731,9 @@ gdk_window_add_filter (GdkWindow *window,
|
|||
if ((filter->function == function) && (filter->data == data))
|
||||
{
|
||||
filter->ref_count++;
|
||||
/* The filter may have been removed while it is being run (and
|
||||
* is only kept by that); added again, it has to run again. */
|
||||
filter->flags = 0;
|
||||
return;
|
||||
}
|
||||
tmp_list = tmp_list->next;
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ gdk_window_impl_quartz_finalize (GObject *object)
|
|||
|
||||
if (impl->transient_for)
|
||||
g_object_unref (impl->transient_for);
|
||||
impl->transient_for = NULL;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -1202,6 +1203,12 @@ _gdk_quartz_window_destroy (GdkWindow *window,
|
|||
else if (impl->view)
|
||||
[impl->view removeFromSuperview];
|
||||
|
||||
/* The window is released when closed (and with it its view), a
|
||||
* view removed from its superview is released; don't keep
|
||||
* dangling pointers to them. */
|
||||
impl->view = NULL;
|
||||
impl->toplevel = NULL;
|
||||
|
||||
GDK_QUARTZ_RELEASE_POOL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1153,7 +1153,7 @@ show_window_internal (GdkWindow *window,
|
|||
else
|
||||
{
|
||||
center_on_rect.left = 0;
|
||||
center_on_rect.right = 0;
|
||||
center_on_rect.top = 0;
|
||||
center_on_rect.right = GetSystemMetrics (SM_CXSCREEN);
|
||||
center_on_rect.bottom = GetSystemMetrics (SM_CYSCREEN);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,6 +136,18 @@ _gdk_display_x11_init (GdkDisplayX11 *display)
|
|||
{
|
||||
}
|
||||
|
||||
/* Whether we run in a Flatpak sandbox */
|
||||
gboolean
|
||||
_gdk_x11_running_in_sandbox (void)
|
||||
{
|
||||
static gint in_sandbox = -1;
|
||||
|
||||
if (in_sandbox < 0)
|
||||
in_sandbox = g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS);
|
||||
|
||||
return in_sandbox;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_display_open:
|
||||
* @display_name: the name of the display to open
|
||||
|
|
@ -339,11 +351,16 @@ gdk_display_open (const gchar *display_name)
|
|||
if (sm_client_id)
|
||||
_gdk_windowing_display_set_sm_client_id (display, sm_client_id);
|
||||
|
||||
pid = getpid ();
|
||||
XChangeProperty (display_x11->xdisplay,
|
||||
display_x11->leader_window,
|
||||
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PID"),
|
||||
XA_CARDINAL, 32, PropModeReplace, (guchar *) & pid, 1);
|
||||
/* Sandboxed, we are likely in a pid namespace, and our pid would
|
||||
* only confuse the window manager (or make it kill another process) */
|
||||
if (!_gdk_x11_running_in_sandbox ())
|
||||
{
|
||||
pid = getpid ();
|
||||
XChangeProperty (display_x11->xdisplay,
|
||||
display_x11->leader_window,
|
||||
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PID"),
|
||||
XA_CARDINAL, 32, PropModeReplace, (guchar *) & pid, 1);
|
||||
}
|
||||
|
||||
/* We don't yet know a valid time. */
|
||||
display_x11->user_time = 0;
|
||||
|
|
@ -694,6 +711,10 @@ gdk_display_beep (GdkDisplay *display)
|
|||
{
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
|
||||
/* An untrusted client gets BadAccess for the bell */
|
||||
if (!GDK_DISPLAY_X11 (display)->trusted_client)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_XKB
|
||||
XkbBell (GDK_DISPLAY_XDISPLAY (display), None, 0, None);
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ gint _gdk_send_xevent (GdkDisplay *display,
|
|||
GType _gdk_gc_x11_get_type (void);
|
||||
|
||||
gboolean _gdk_x11_have_render (GdkDisplay *display);
|
||||
gboolean _gdk_x11_running_in_sandbox (void);
|
||||
|
||||
GdkGC *_gdk_x11_gc_new (GdkDrawable *drawable,
|
||||
GdkGCValues *values,
|
||||
|
|
|
|||
|
|
@ -617,12 +617,17 @@ setup_toplevel_window (GdkWindow *window,
|
|||
/* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME */
|
||||
XSetWMProperties (xdisplay, xid, NULL, NULL, NULL, 0, NULL, NULL, NULL);
|
||||
|
||||
pid = getpid ();
|
||||
XChangeProperty (xdisplay, xid,
|
||||
gdk_x11_get_xatom_by_name_for_display (screen_x11->display, "_NET_WM_PID"),
|
||||
XA_CARDINAL, 32,
|
||||
PropModeReplace,
|
||||
(guchar *)&pid, 1);
|
||||
/* Sandboxed, we are likely in a pid namespace, and our pid would
|
||||
* only confuse the window manager (or make it kill another process) */
|
||||
if (!_gdk_x11_running_in_sandbox ())
|
||||
{
|
||||
pid = getpid ();
|
||||
XChangeProperty (xdisplay, xid,
|
||||
gdk_x11_get_xatom_by_name_for_display (screen_x11->display, "_NET_WM_PID"),
|
||||
XA_CARDINAL, 32,
|
||||
PropModeReplace,
|
||||
(guchar *)&pid, 1);
|
||||
}
|
||||
|
||||
leader_window = GDK_DISPLAY_X11 (screen_x11->display)->leader_window;
|
||||
if (!leader_window)
|
||||
|
|
@ -6052,6 +6057,10 @@ _gdk_windowing_window_beep (GdkWindow *window)
|
|||
|
||||
display = GDK_WINDOW_DISPLAY (window);
|
||||
|
||||
/* An untrusted client gets BadAccess for the bell */
|
||||
if (!GDK_DISPLAY_X11 (display)->trusted_client)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_XKB
|
||||
if (GDK_DISPLAY_X11 (display)->use_xkb)
|
||||
XkbBell (GDK_DISPLAY_XDISPLAY (display),
|
||||
|
|
|
|||
Loading…
Reference in a new issue