← Back to Pull requests

mate-screenshot: Prefer X11 backend in X11 sessions #405

Open
unknown opened this pull request with 217 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 21, 2026 14:48 UTC
Author

Summary

Fix a segmentation fault in mate-screenshot when a nested Wayland compositor (such as Cage) is running inside an X11 desktop session.

Problem

When Cage runs as a nested Wayland compositor under MATE/X11, GTK may select the Wayland backend instead of the host X11 backend.

mate-screenshot subsequently calls X11-specific functions, including gdk_x11_display_grab(), which leads to a segmentation fault inside XGrabServer().

This occurs even when the Cage window is not focused and prevents the Print Screen shortcut from working.

Solution

When the session type is X11 and DISPLAY is available, explicitly restrict GTK to the X11 backend using gdk_set_allowed_backends("x11").

The change:

  • Applies only to X11 sessions.

  • Preserves native Wayland behavior.

  • Respects an explicitly configured GDK_BACKEND.

  • Selects the backend before GTK initialization.
  • Steps to reproduce

    1. Log into a MATE/X11 session.
    2. Start Cage as a nested compositor:

       cage -- sh -c 'sleep 120'
       

    3. Run mate-screenshot from another terminal.

    Before: Segmentation fault in XGrabServer().

    After: Screenshot capture works normally.

    Testing

    Tested on Linux Mint with MATE/X11.

  • Confirmed the crash occurs with Cage running, even without Waydroid.

  • Confirmed GDK_BACKEND=x11 mate-screenshot avoids the crash.

  • Built the patched application from source.

  • Verified the patched executable captures screenshots successfully with Cage running, without setting GDK_BACKEND.

  • git diff --check passed.
  • The local build used MATE Desktop 1.26.2 compatibility overrides and the source tree's GSettings schema. Testing against the upstream-supported MATE Desktop version remains to be done.

    Diff: 217 lines (+162 / -55) across 2 files Reviewer: lukefromdc Review duration: 13009m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 217 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.322
    Real PR Conversation Timeline
    1 comments
    "Review active on #405"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.7% (MEDIUM) · Higher = larger blast radius
    36.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.6% · Safe to merge
    19.6%