Skip to content

window-x11: Do not try to compare a wayland active window with X11

Marco Trevisan requested to merge 3v1n0/mutter:fix-x11-window-group-check into main

If a window sends a configure stacking request, we were comparing the active window with the event window even though they were different client types (e.g. wayland and x11).

This was leading to a critical error, so let's handle this by ensuring that the active window is of the same kind of the event window before doing x11-specific checks. Behaving as different applications in case.

Before of this we were getting this stacktrace:

#0  g_logv (log_domain=0x7ffff7f9ff93 "GLib-GObject", log_level=G_LOG_LEVEL_CRITICAL, 
    format=<optimized out>, args=args@entry=0x7fffffffb1e0) at ../../glib/glib/gmessages.c:1277
#1  0x00007ffff792d1f3 in g_log (log_domain=log_domain@entry=0x7ffff7f9ff93 "GLib-GObject", 
    log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, 
    format=format@entry=0x7ffff7fa6b00 "invalid cast from '%s' to '%s'")
    at ../../glib/glib/gmessages.c:1315
#2  0x00007ffff7f955d0 in g_type_check_instance_cast (type_instance=0x555558f17610, 
    iface_type=<optimized out>) at ../../glib/gobject/gtype.c:4193
#3  0x00007ffff71b58e5 in META_WINDOW_X11 (ptr=0x555558f17610)
    at ../../mutter/src/x11/window-x11.h:36
#4  0x00007ffff71c092c in meta_window_x11_get_group (window=0x555558f17610)
    at ../../mutter/src/x11/window-x11.c:4542
#5  0x00007ffff71c08cd in meta_window_x11_same_application (window=0x555556cb0420, 
    other_window=0x555558f17610) at ../../mutter/src/x11/window-x11.c:4520
#6  0x00007ffff71bc394 in meta_window_x11_configure_request (window=0x555556cb0420, 
    event=0x7fffffffb700) at ../../mutter/src/x11/window-x11.c:2865
#7  0x00007ffff71997da in handle_other_xevent (x11_display=0x555556de47c0, 
    event=0x7fffffffb700) at ../../mutter/src/x11/events.c:1570
#8  0x00007ffff719a6e6 in meta_x11_display_handle_xevent (x11_display=0x555556de47c0, 
    event=0x7fffffffb700) at ../../mutter/src/x11/events.c:1930
#9  0x00007ffff719a84f in xevent_func (xevent=0x7fffffffb700, data=0x555556de47c0)
    at ../../mutter/src/x11/events.c:1969
#10 0x00007ffff71a5e39 in meta_x11_event_source_dispatch (source=0x555558ef0160, 
    callback=0x7ffff719a820 <xevent_func>, user_data=0x555556de47c0)
    at ../../mutter/src/x11/meta-x11-event-source.c:62
#11 0x00007ffff79213a9 in g_main_dispatch (context=context@entry=0x55555558cd80)
    at ../../glib/glib/gmain.c:3344
#12 0x00007ffff7924607 in g_main_context_dispatch_unlocked (context=0x55555558cd80)
    at ../../glib/glib/gmain.c:4152
#13 g_main_context_iterate_unlocked (context=0x55555558cd80, block=block@entry=1, 
    dispatch=dispatch@entry=1, self=<optimized out>) at ../../glib/glib/gmain.c:4217
#14 0x00007ffff7924f0f in g_main_loop_run (loop=0x555555a56cb0) at ../../glib/glib/gmain.c:4419
#15 0x00007ffff7143378 in meta_context_run_main_loop (context=0x555555584460, 
    error=0x7fffffffbd30) at ../../mutter/src/core/meta-context.c:523
#16 0x00007ffff737f8b6 in ?? () from /lib/x86_64-linux-gnu/libffi.so.8
#17 0x00007ffff737c34d in ?? () from /lib/x86_64-linux-gnu/libffi.so.8
#18 0x00007ffff737ef33 in ffi_call () from /lib/x86_64-linux-gnu/libffi.so.8
#19 0x00007ffff769ad07 in Gjs::Function::invoke (this=0x555555acef00, context=0x5555555a9310, 
    args=..., this_obj=..., r_value=0x0) at ../../gjs/gi/function.cpp:1054
#20 0x00007ffff769b836 in Gjs::Function::call (context=0x5555555a9310, js_argc=0, 
    vp=0x555555676808) at ../../gjs/gi/function.cpp:1236
#21 0x00007ffff4763970 in ?? () from /lib/x86_64-linux-gnu/libmozjs-115.so.0
#22 0x00007ffff4757cdf in ?? () from /lib/x86_64-linux-gnu/libmozjs-115.so.0
#23 0x00007ffff47634db in ?? () from /lib/x86_64-linux-gnu/libmozjs-115.so.0
#24 0x00007ffff4763847 in ?? () from /lib/x86_64-linux-gnu/libmozjs-115.so.0
#25 0x00007ffff4763db9 in ?? () from /lib/x86_64-linux-gnu/libmozjs-115.so.0

/cc @bilelmoussaoui

Merge request reports