mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 14:20:21 +00:00
Stop using foreign windows for xsettings
Stop wrapping the xsettings manager window in a foreign window. This means that we cannot use the gdk window filter APIs anymore, so just do the filtering in a non-generic way.
This commit is contained in:
parent
5bd8884bf8
commit
9f6b556dc2
@ -22,6 +22,7 @@
|
|||||||
#include "gdkinternals.h"
|
#include "gdkinternals.h"
|
||||||
#include "gdkwindow-x11.h"
|
#include "gdkwindow-x11.h"
|
||||||
#include "gdkprivate-x11.h"
|
#include "gdkprivate-x11.h"
|
||||||
|
#include "xsettings-client.h"
|
||||||
|
|
||||||
|
|
||||||
static gboolean gdk_event_source_prepare (GSource *source,
|
static gboolean gdk_event_source_prepare (GSource *source,
|
||||||
@ -271,6 +272,9 @@ gdk_event_source_translate_event (GdkEventSource *event_source,
|
|||||||
GdkEventTranslator *event_translator;
|
GdkEventTranslator *event_translator;
|
||||||
GdkWindow *filter_window;
|
GdkWindow *filter_window;
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
|
GdkX11Screen *x11_screen;
|
||||||
|
|
||||||
|
x11_screen = (GdkX11Screen*)gdk_display_get_default_screen (event_source->display);
|
||||||
|
|
||||||
dpy = GDK_DISPLAY_XDISPLAY (event_source->display);
|
dpy = GDK_DISPLAY_XDISPLAY (event_source->display);
|
||||||
|
|
||||||
@ -287,8 +291,17 @@ gdk_event_source_translate_event (GdkEventSource *event_source,
|
|||||||
if (filter_window)
|
if (filter_window)
|
||||||
event->any.window = g_object_ref (filter_window);
|
event->any.window = g_object_ref (filter_window);
|
||||||
|
|
||||||
|
/* apply XSettings filters */
|
||||||
|
if (xevent->xany.window == XRootWindow (dpy, 0))
|
||||||
|
result = gdk_xsettings_root_window_filter (xevent, event, x11_screen);
|
||||||
|
|
||||||
|
if (result == GDK_FILTER_CONTINUE &&
|
||||||
|
xevent->xany.window == x11_screen->xsettings_manager_window)
|
||||||
|
result = gdk_xsettings_manager_window_filter (xevent, event, x11_screen);
|
||||||
|
|
||||||
/* Run default filters */
|
/* Run default filters */
|
||||||
if (_gdk_default_filters)
|
if (result == GDK_FILTER_CONTINUE &&
|
||||||
|
_gdk_default_filters)
|
||||||
{
|
{
|
||||||
/* Apply global filters */
|
/* Apply global filters */
|
||||||
result = gdk_event_apply_filters (xevent, event, NULL);
|
result = gdk_event_apply_filters (xevent, event, NULL);
|
||||||
|
@ -59,7 +59,7 @@ struct _GdkX11Screen
|
|||||||
char *window_manager_name;
|
char *window_manager_name;
|
||||||
|
|
||||||
/* X Settings */
|
/* X Settings */
|
||||||
GdkWindow *xsettings_manager_window;
|
Window xsettings_manager_window;
|
||||||
Atom xsettings_selection_atom;
|
Atom xsettings_selection_atom;
|
||||||
GHashTable *xsettings; /* string of GDK settings name => GValue */
|
GHashTable *xsettings; /* string of GDK settings name => GValue */
|
||||||
|
|
||||||
|
@ -413,13 +413,13 @@ read_settings (GdkX11Screen *x11_screen,
|
|||||||
|
|
||||||
x11_screen->xsettings = NULL;
|
x11_screen->xsettings = NULL;
|
||||||
|
|
||||||
if (x11_screen->xsettings_manager_window)
|
if (x11_screen->xsettings_manager_window != 0)
|
||||||
{
|
{
|
||||||
Atom xsettings_atom = gdk_x11_get_xatom_by_name_for_display (display, "_XSETTINGS_SETTINGS");
|
Atom xsettings_atom = gdk_x11_get_xatom_by_name_for_display (display, "_XSETTINGS_SETTINGS");
|
||||||
|
|
||||||
gdk_x11_display_error_trap_push (display);
|
gdk_x11_display_error_trap_push (display);
|
||||||
result = XGetWindowProperty (gdk_x11_display_get_xdisplay (display),
|
result = XGetWindowProperty (gdk_x11_display_get_xdisplay (display),
|
||||||
gdk_x11_window_get_xid (x11_screen->xsettings_manager_window),
|
x11_screen->xsettings_manager_window,
|
||||||
xsettings_atom, 0, LONG_MAX,
|
xsettings_atom, 0, LONG_MAX,
|
||||||
False, xsettings_atom,
|
False, xsettings_atom,
|
||||||
&type, &format, &n_items, &bytes_after, &data);
|
&type, &format, &n_items, &bytes_after, &data);
|
||||||
@ -475,53 +475,33 @@ get_selection_atom (GdkX11Screen *x11_screen)
|
|||||||
return _gdk_x11_get_xatom_for_display_printf (x11_screen->display, "_XSETTINGS_S%d", x11_screen->screen_num);
|
return _gdk_x11_get_xatom_for_display_printf (x11_screen->display, "_XSETTINGS_S%d", x11_screen->screen_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkFilterReturn
|
|
||||||
gdk_xsettings_manager_window_filter (GdkXEvent *xevent,
|
|
||||||
GdkEvent *event,
|
|
||||||
gpointer data);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_manager_window (GdkX11Screen *x11_screen,
|
check_manager_window (GdkX11Screen *x11_screen,
|
||||||
gboolean notify_changes)
|
gboolean notify_changes)
|
||||||
{
|
{
|
||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
Window manager_window_xid;
|
|
||||||
|
|
||||||
display = x11_screen->display;
|
display = x11_screen->display;
|
||||||
xdisplay = gdk_x11_display_get_xdisplay (display);
|
xdisplay = gdk_x11_display_get_xdisplay (display);
|
||||||
|
|
||||||
if (x11_screen->xsettings_manager_window)
|
|
||||||
{
|
|
||||||
gdk_window_remove_filter (x11_screen->xsettings_manager_window, gdk_xsettings_manager_window_filter, x11_screen);
|
|
||||||
g_object_unref (x11_screen->xsettings_manager_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
gdk_x11_display_grab (display);
|
gdk_x11_display_grab (display);
|
||||||
|
|
||||||
manager_window_xid = XGetSelectionOwner (xdisplay, get_selection_atom (x11_screen));
|
x11_screen->xsettings_manager_window = XGetSelectionOwner (xdisplay, get_selection_atom (x11_screen));
|
||||||
x11_screen->xsettings_manager_window = gdk_x11_window_foreign_new_for_display (display,
|
|
||||||
manager_window_xid);
|
if (x11_screen->xsettings_manager_window != 0)
|
||||||
/* XXX: Can't use gdk_window_set_events() here because the first call to this
|
|
||||||
* function happens too early in gdk_init() */
|
|
||||||
if (x11_screen->xsettings_manager_window)
|
|
||||||
XSelectInput (xdisplay,
|
XSelectInput (xdisplay,
|
||||||
gdk_x11_window_get_xid (x11_screen->xsettings_manager_window),
|
x11_screen->xsettings_manager_window,
|
||||||
PropertyChangeMask | StructureNotifyMask);
|
PropertyChangeMask | StructureNotifyMask);
|
||||||
|
|
||||||
gdk_x11_display_ungrab (display);
|
gdk_x11_display_ungrab (display);
|
||||||
|
|
||||||
gdk_display_flush (display);
|
gdk_display_flush (display);
|
||||||
|
|
||||||
if (x11_screen->xsettings_manager_window)
|
|
||||||
{
|
|
||||||
gdk_window_add_filter (x11_screen->xsettings_manager_window, gdk_xsettings_manager_window_filter, x11_screen);
|
|
||||||
}
|
|
||||||
|
|
||||||
read_settings (x11_screen, notify_changes);
|
read_settings (x11_screen, notify_changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkFilterReturn
|
GdkFilterReturn
|
||||||
gdk_xsettings_root_window_filter (GdkXEvent *xevent,
|
gdk_xsettings_root_window_filter (GdkXEvent *xevent,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
@ -542,11 +522,11 @@ gdk_xsettings_root_window_filter (GdkXEvent *xevent,
|
|||||||
check_manager_window (x11_screen, TRUE);
|
check_manager_window (x11_screen, TRUE);
|
||||||
return GDK_FILTER_REMOVE;
|
return GDK_FILTER_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GDK_FILTER_CONTINUE;
|
return GDK_FILTER_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkFilterReturn
|
GdkFilterReturn
|
||||||
gdk_xsettings_manager_window_filter (GdkXEvent *xevent,
|
gdk_xsettings_manager_window_filter (GdkXEvent *xevent,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
@ -558,22 +538,20 @@ gdk_xsettings_manager_window_filter (GdkXEvent *xevent,
|
|||||||
{
|
{
|
||||||
check_manager_window (x11_screen, TRUE);
|
check_manager_window (x11_screen, TRUE);
|
||||||
/* let GDK do its cleanup */
|
/* let GDK do its cleanup */
|
||||||
return GDK_FILTER_CONTINUE;
|
return GDK_FILTER_CONTINUE;
|
||||||
}
|
}
|
||||||
else if (xev->xany.type == PropertyNotify)
|
else if (xev->xany.type == PropertyNotify)
|
||||||
{
|
{
|
||||||
read_settings (x11_screen, TRUE);
|
read_settings (x11_screen, TRUE);
|
||||||
return GDK_FILTER_REMOVE;
|
return GDK_FILTER_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GDK_FILTER_CONTINUE;;
|
return GDK_FILTER_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_gdk_x11_xsettings_init (GdkX11Screen *x11_screen)
|
_gdk_x11_xsettings_init (GdkX11Screen *x11_screen)
|
||||||
{
|
{
|
||||||
gdk_window_add_filter (gdk_display_get_root_window (x11_screen->display), gdk_xsettings_root_window_filter, x11_screen);
|
|
||||||
|
|
||||||
check_manager_window (x11_screen, FALSE);
|
check_manager_window (x11_screen, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,18 +564,12 @@ _gdk_x11_settings_force_reread (GdkX11Screen *x11_screen)
|
|||||||
void
|
void
|
||||||
_gdk_x11_xsettings_finish (GdkX11Screen *x11_screen)
|
_gdk_x11_xsettings_finish (GdkX11Screen *x11_screen)
|
||||||
{
|
{
|
||||||
gdk_window_remove_filter (gdk_display_get_root_window (x11_screen->display), gdk_xsettings_root_window_filter, x11_screen);
|
|
||||||
if (x11_screen->xsettings_manager_window)
|
if (x11_screen->xsettings_manager_window)
|
||||||
{
|
x11_screen->xsettings_manager_window = 0;
|
||||||
gdk_window_remove_filter (x11_screen->xsettings_manager_window, gdk_xsettings_manager_window_filter, x11_screen);
|
|
||||||
g_object_unref (x11_screen->xsettings_manager_window);
|
|
||||||
x11_screen->xsettings_manager_window = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x11_screen->xsettings)
|
if (x11_screen->xsettings)
|
||||||
{
|
{
|
||||||
g_hash_table_unref (x11_screen->xsettings);
|
g_hash_table_unref (x11_screen->xsettings);
|
||||||
x11_screen->xsettings = NULL;
|
x11_screen->xsettings = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,4 +29,12 @@ void _gdk_x11_xsettings_init (GdkX11Screen *x11_screen);
|
|||||||
void _gdk_x11_xsettings_finish (GdkX11Screen *x11_screen);
|
void _gdk_x11_xsettings_finish (GdkX11Screen *x11_screen);
|
||||||
void _gdk_x11_settings_force_reread (GdkX11Screen *x11_screen);
|
void _gdk_x11_settings_force_reread (GdkX11Screen *x11_screen);
|
||||||
|
|
||||||
|
GdkFilterReturn gdk_xsettings_root_window_filter (GdkXEvent *xevent,
|
||||||
|
GdkEvent *event,
|
||||||
|
gpointer data);
|
||||||
|
GdkFilterReturn gdk_xsettings_manager_window_filter (GdkXEvent *xevent,
|
||||||
|
GdkEvent *event,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
|
|
||||||
#endif /* XSETTINGS_CLIENT_H */
|
#endif /* XSETTINGS_CLIENT_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user