tray: Adapt to meta_x11_error_* removal

By switching to use the mtk helpers instead

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3087>
This commit is contained in:
Bilal Elmoussaoui 2024-01-03 16:13:41 +01:00 committed by Marge Bot
parent 71befc5ff7
commit 00813828f3
4 changed files with 48 additions and 47 deletions

View File

@ -22,6 +22,7 @@
#include "na-tray-child.h" #include "na-tray-child.h"
#include <mtk/mtk-x11.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@ -61,10 +62,10 @@ na_tray_child_new (MetaX11Display *x11_display,
* the socket in the same visual. * the socket in the same visual.
*/ */
meta_x11_error_trap_push (x11_display); mtk_x11_error_trap_push (xdisplay);
result = XGetWindowAttributes (xdisplay, icon_window, result = XGetWindowAttributes (xdisplay, icon_window,
&window_attributes); &window_attributes);
meta_x11_error_trap_pop (x11_display); mtk_x11_error_trap_pop (xdisplay);
if (!result) /* Window already gone */ if (!result) /* Window already gone */
return NULL; return NULL;
@ -97,7 +98,7 @@ na_tray_child_get_title (NaTrayChild *child)
utf8_string = XInternAtom (xdisplay, "UTF8_STRING", False); utf8_string = XInternAtom (xdisplay, "UTF8_STRING", False);
atom = XInternAtom (xdisplay, "_NET_WM_NAME", False); atom = XInternAtom (xdisplay, "_NET_WM_NAME", False);
meta_x11_error_trap_push (x11_display); mtk_x11_error_trap_push (xdisplay);
result = XGetWindowProperty (xdisplay, result = XGetWindowProperty (xdisplay,
na_xembed_get_plug_window (NA_XEMBED (child)), na_xembed_get_plug_window (NA_XEMBED (child)),
@ -107,7 +108,7 @@ na_tray_child_get_title (NaTrayChild *child)
&type, &format, &nitems, &type, &format, &nitems,
&bytes_after, (guchar **)&val); &bytes_after, (guchar **)&val);
if (meta_x11_error_trap_pop_with_return (x11_display) || result != Success) if (mtk_x11_error_trap_pop_with_return (xdisplay) || result != Success)
return NULL; return NULL;
if (type != utf8_string || if (type != utf8_string ||
@ -166,9 +167,9 @@ _get_wmclass (MetaX11Display *x11_display,
xdisplay = meta_x11_display_get_xdisplay (x11_display); xdisplay = meta_x11_display_get_xdisplay (x11_display);
meta_x11_error_trap_push (x11_display); mtk_x11_error_trap_push (xdisplay);
XGetClassHint (xdisplay, xwindow, &ch); XGetClassHint (xdisplay, xwindow, &ch);
meta_x11_error_trap_pop (x11_display); mtk_x11_error_trap_pop (xdisplay);
if (res_class) if (res_class)
*res_class = NULL; *res_class = NULL;
@ -234,7 +235,7 @@ na_tray_child_get_pid (NaTrayChild *child)
xdisplay = meta_x11_display_get_xdisplay (x11_display); xdisplay = meta_x11_display_get_xdisplay (x11_display);
xdisplay = meta_x11_display_get_xdisplay (x11_display); xdisplay = meta_x11_display_get_xdisplay (x11_display);
meta_x11_error_trap_push (x11_display); mtk_x11_error_trap_push (xdisplay);
result = XGetWindowProperty (xdisplay, result = XGetWindowProperty (xdisplay,
na_xembed_get_plug_window (NA_XEMBED (child)), na_xembed_get_plug_window (NA_XEMBED (child)),
XInternAtom (xdisplay, "_NET_WM_PID", False), XInternAtom (xdisplay, "_NET_WM_PID", False),
@ -242,7 +243,7 @@ na_tray_child_get_pid (NaTrayChild *child)
&type, &format, &nitems, &type, &format, &nitems,
&bytes_after, (guchar **)&val); &bytes_after, (guchar **)&val);
if (!meta_x11_error_trap_pop_with_return (x11_display) && if (!mtk_x11_error_trap_pop_with_return (xdisplay) &&
result == Success && result == Success &&
type == XA_CARDINAL && type == XA_CARDINAL &&
nitems == 1) nitems == 1)
@ -272,6 +273,7 @@ na_tray_child_emulate_event (NaTrayChild *tray_child,
event_type == CLUTTER_KEY_RELEASE); event_type == CLUTTER_KEY_RELEASE);
x11_display = na_xembed_get_x11_display (NA_XEMBED (tray_child)); x11_display = na_xembed_get_x11_display (NA_XEMBED (tray_child));
xdisplay = meta_x11_display_get_xdisplay (x11_display);
xwindow = na_xembed_get_plug_window (NA_XEMBED (tray_child)); xwindow = na_xembed_get_plug_window (NA_XEMBED (tray_child));
if (xwindow == None) if (xwindow == None)
@ -282,9 +284,7 @@ na_tray_child_emulate_event (NaTrayChild *tray_child,
na_xembed_get_size (NA_XEMBED (tray_child), &width, &height); na_xembed_get_size (NA_XEMBED (tray_child), &width, &height);
meta_x11_error_trap_push (x11_display); mtk_x11_error_trap_push (xdisplay);
xdisplay = meta_x11_display_get_xdisplay (x11_display);
xrootwindow = XDefaultRootWindow (xdisplay); xrootwindow = XDefaultRootWindow (xdisplay);
/* First make the icon believe the pointer is inside it */ /* First make the icon believe the pointer is inside it */
@ -358,5 +358,5 @@ na_tray_child_emulate_event (NaTrayChild *tray_child,
xcevent.type = LeaveNotify; xcevent.type = LeaveNotify;
XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xcevent); XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xcevent);
meta_x11_error_trap_pop (x11_display); mtk_x11_error_trap_pop (xdisplay);
} }

View File

@ -23,8 +23,6 @@
#include "na-xembed.h" #include "na-xembed.h"
#include <meta/meta-x11-errors.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define NA_TYPE_TRAY_CHILD (na_tray_child_get_type ()) #define NA_TYPE_TRAY_CHILD (na_tray_child_get_type ())

View File

@ -24,6 +24,7 @@
#include "na-tray-manager.h" #include "na-tray-manager.h"
#include <mtk/mtk-x11.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@ -603,7 +604,7 @@ na_tray_manager_manage (NaTrayManager *manager)
xdisplay = meta_x11_display_get_xdisplay (manager->x11_display); xdisplay = meta_x11_display_get_xdisplay (manager->x11_display);
meta_x11_error_trap_push (manager->x11_display); mtk_x11_error_trap_push (xdisplay);
manager->window = XCreateSimpleWindow (xdisplay, manager->window = XCreateSimpleWindow (xdisplay,
XDefaultRootWindow (xdisplay), XDefaultRootWindow (xdisplay),
0, 0, 1, 1, 0, 0, 1, 1,
@ -611,7 +612,7 @@ na_tray_manager_manage (NaTrayManager *manager)
XSelectInput (xdisplay, manager->window, XSelectInput (xdisplay, manager->window,
StructureNotifyMask | PropertyChangeMask); StructureNotifyMask | PropertyChangeMask);
if (meta_x11_error_trap_pop_with_return (manager->x11_display) || if (mtk_x11_error_trap_pop_with_return (xdisplay) ||
!manager->window) !manager->window)
return FALSE; return FALSE;
@ -620,13 +621,13 @@ na_tray_manager_manage (NaTrayManager *manager)
na_tray_manager_set_visual_property (manager); na_tray_manager_set_visual_property (manager);
na_tray_manager_set_colors_property (manager); na_tray_manager_set_colors_property (manager);
meta_x11_error_trap_push (manager->x11_display); mtk_x11_error_trap_push (xdisplay);
XSetSelectionOwner (xdisplay, manager->selection_atom, XSetSelectionOwner (xdisplay, manager->selection_atom,
manager->window, CurrentTime); manager->window, CurrentTime);
/* Check if we could set the selection owner successfully */ /* Check if we could set the selection owner successfully */
if (!meta_x11_error_trap_pop_with_return (manager->x11_display)) if (!mtk_x11_error_trap_pop_with_return (xdisplay))
{ {
XClientMessageEvent xev; XClientMessageEvent xev;

View File

@ -23,7 +23,7 @@
#include "na-xembed.h" #include "na-xembed.h"
#include <meta/meta-x11-errors.h> #include <mtk/mtk-x11.h>
#include <X11/extensions/Xfixes.h> #include <X11/extensions/Xfixes.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@ -110,6 +110,7 @@ xembed_send_message (NaXembed *xembed,
glong data2) glong data2)
{ {
NaXembedPrivate *priv = na_xembed_get_instance_private (xembed); NaXembedPrivate *priv = na_xembed_get_instance_private (xembed);
Display *xdisplay = meta_x11_display_get_xdisplay (priv->x11_display);
XClientMessageEvent xclient; XClientMessageEvent xclient;
memset (&xclient, 0, sizeof (xclient)); memset (&xclient, 0, sizeof (xclient));
@ -123,11 +124,11 @@ xembed_send_message (NaXembed *xembed,
xclient.data.l[3] = data1; xclient.data.l[3] = data1;
xclient.data.l[4] = data2; xclient.data.l[4] = data2;
meta_x11_error_trap_push (priv->x11_display); mtk_x11_error_trap_push (xdisplay);
XSendEvent (meta_x11_display_get_xdisplay (priv->x11_display), XSendEvent (xdisplay,
recipient, recipient,
False, NoEventMask, (XEvent*) &xclient); False, NoEventMask, (XEvent*) &xclient);
meta_x11_error_trap_pop (priv->x11_display); mtk_x11_error_trap_pop (xdisplay);
} }
static void static void
@ -147,6 +148,7 @@ na_xembed_send_configure_event (NaXembed *xembed)
{ {
NaXembedPrivate *priv = na_xembed_get_instance_private (xembed); NaXembedPrivate *priv = na_xembed_get_instance_private (xembed);
XConfigureEvent xconfigure; XConfigureEvent xconfigure;
Display *xdisplay = meta_x11_display_get_xdisplay (priv->x11_display);
memset (&xconfigure, 0, sizeof (xconfigure)); memset (&xconfigure, 0, sizeof (xconfigure));
xconfigure.type = ConfigureNotify; xconfigure.type = ConfigureNotify;
@ -163,12 +165,12 @@ na_xembed_send_configure_event (NaXembed *xembed)
xconfigure.above = None; xconfigure.above = None;
xconfigure.override_redirect = False; xconfigure.override_redirect = False;
meta_x11_error_trap_push (priv->x11_display); mtk_x11_error_trap_push (xdisplay);
XSendEvent (meta_x11_display_get_xdisplay (priv->x11_display), XSendEvent (xdisplay,
priv->plug_window, priv->plug_window,
False, NoEventMask, False, NoEventMask,
(XEvent*) &xconfigure); (XEvent*) &xconfigure);
meta_x11_error_trap_pop (priv->x11_display); mtk_x11_error_trap_pop (xdisplay);
} }
static void static void
@ -190,7 +192,7 @@ na_xembed_synchronize_size (NaXembed *xembed)
if (priv->plug_window) if (priv->plug_window)
{ {
meta_x11_error_trap_push (priv->x11_display); mtk_x11_error_trap_push (xdisplay);
if (width != priv->current_width || if (width != priv->current_width ||
height != priv->current_height) height != priv->current_height)
@ -218,7 +220,7 @@ na_xembed_synchronize_size (NaXembed *xembed)
priv->resize_count--; priv->resize_count--;
} }
meta_x11_error_trap_pop (priv->x11_display); mtk_x11_error_trap_pop (xdisplay);
} }
} }
@ -238,17 +240,18 @@ static void
na_xembed_resize (NaXembed *xembed) na_xembed_resize (NaXembed *xembed)
{ {
NaXembedPrivate *priv = na_xembed_get_instance_private (xembed); NaXembedPrivate *priv = na_xembed_get_instance_private (xembed);
Display *xdisplay = meta_x11_display_get_xdisplay (priv->x11_display);
XSizeHints hints; XSizeHints hints;
long supplied; long supplied;
g_clear_handle_id (&priv->resize_id, g_source_remove); g_clear_handle_id (&priv->resize_id, g_source_remove);
meta_x11_error_trap_push (priv->x11_display); mtk_x11_error_trap_push (xdisplay);
priv->request_width = 1; priv->request_width = 1;
priv->request_height = 1; priv->request_height = 1;
if (XGetWMNormalHints (meta_x11_display_get_xdisplay (priv->x11_display), if (XGetWMNormalHints (xdisplay,
priv->plug_window, priv->plug_window,
&hints, &supplied)) &hints, &supplied))
{ {
@ -265,7 +268,7 @@ na_xembed_resize (NaXembed *xembed)
} }
priv->have_size = TRUE; priv->have_size = TRUE;
meta_x11_error_trap_pop (priv->x11_display); mtk_x11_error_trap_pop (xdisplay);
priv->resize_id = g_idle_add (synchronize_size_cb, xembed); priv->resize_id = g_idle_add (synchronize_size_cb, xembed);
} }
@ -286,7 +289,7 @@ na_xembed_get_info (NaXembed *xembed,
unsigned long *data_long; unsigned long *data_long;
int status; int status;
meta_x11_error_trap_push (x11_display); mtk_x11_error_trap_push (xdisplay);
status = XGetWindowProperty (xdisplay, status = XGetWindowProperty (xdisplay,
xwindow, xwindow,
priv->atom__XEMBED_INFO, priv->atom__XEMBED_INFO,
@ -294,7 +297,7 @@ na_xembed_get_info (NaXembed *xembed,
priv->atom__XEMBED_INFO, priv->atom__XEMBED_INFO,
&type, &format, &type, &format,
&nitems, &bytes_after, &data); &nitems, &bytes_after, &data);
meta_x11_error_trap_pop (x11_display); mtk_x11_error_trap_pop (xdisplay);
if (status != Success) if (status != Success)
return FALSE; return FALSE;
@ -339,13 +342,13 @@ na_xembed_add_window (NaXembed *xembed,
priv->plug_window = xid; priv->plug_window = xid;
meta_x11_error_trap_push (priv->x11_display); mtk_x11_error_trap_push (xdisplay);
XSelectInput (xdisplay, XSelectInput (xdisplay,
priv->plug_window, priv->plug_window,
StructureNotifyMask | PropertyChangeMask); StructureNotifyMask | PropertyChangeMask);
if (meta_x11_error_trap_pop_with_return (priv->x11_display)) if (mtk_x11_error_trap_pop_with_return (xdisplay))
{ {
priv->plug_window = None; priv->plug_window = None;
return; return;
@ -353,7 +356,7 @@ na_xembed_add_window (NaXembed *xembed,
/* OK, we now will reliably get destroy notification on socket->plug_window */ /* OK, we now will reliably get destroy notification on socket->plug_window */
meta_x11_error_trap_push (priv->x11_display); mtk_x11_error_trap_push (xdisplay);
if (need_reparent) if (need_reparent)
{ {
@ -364,21 +367,20 @@ na_xembed_add_window (NaXembed *xembed,
result = XGetWindowAttributes (xdisplay, priv->plug_window, &plug_attrs); result = XGetWindowAttributes (xdisplay, priv->plug_window, &plug_attrs);
if (result == 0) if (result == 0)
{ {
meta_x11_error_trap_pop (priv->x11_display); mtk_x11_error_trap_pop (xdisplay);
priv->plug_window = None; priv->plug_window = None;
return; return;
} }
template.visualid = plug_attrs.visual->visualid; template.visualid = plug_attrs.visual->visualid;
priv->xvisual_info = priv->xvisual_info = XGetVisualInfo (xdisplay,
XGetVisualInfo (meta_x11_display_get_xdisplay (priv->x11_display),
VisualIDMask, VisualIDMask,
&template, &template,
&n_xvisuals); &n_xvisuals);
if (!priv->xvisual_info) if (!priv->xvisual_info)
{ {
meta_x11_error_trap_pop (priv->x11_display); mtk_x11_error_trap_pop (xdisplay);
priv->plug_window = None; priv->plug_window = None;
return; return;
} }
@ -423,12 +425,12 @@ na_xembed_add_window (NaXembed *xembed,
priv->need_map = priv->is_mapped; priv->need_map = priv->is_mapped;
meta_x11_error_trap_pop (priv->x11_display); mtk_x11_error_trap_pop (xdisplay);
meta_x11_error_trap_push (priv->x11_display); mtk_x11_error_trap_push (xdisplay);
XFixesChangeSaveSet (xdisplay, priv->plug_window, XFixesChangeSaveSet (xdisplay, priv->plug_window,
SetModeInsert, SaveSetRoot, SaveSetUnmap); SetModeInsert, SaveSetRoot, SaveSetUnmap);
meta_x11_error_trap_pop (priv->x11_display); mtk_x11_error_trap_pop (xdisplay);
xembed_send_message (xembed, xembed_send_message (xembed,
priv->plug_window, priv->plug_window,
@ -571,9 +573,9 @@ xembed_filter_func (MetaX11Display *x11_display,
} }
else else
{ {
meta_x11_error_trap_push (priv->x11_display); mtk_x11_error_trap_push (xdisplay);
XMapWindow (xdisplay, priv->plug_window); XMapWindow (xdisplay, priv->plug_window);
meta_x11_error_trap_pop (priv->x11_display); mtk_x11_error_trap_pop (xdisplay);
na_xembed_handle_unmap_notify (xembed); na_xembed_handle_unmap_notify (xembed);
} }