wxGLCanvas inside wxPopupWindow gets positioned incorrectly on EGL+Wayland. (Issue #26250)

56 views
Skip to first unread message

dsa-t

unread,
Feb 25, 2026, 9:12:57 PMFeb 25
to wx-...@googlegroups.com, Subscribed
dsa-t created an issue (wxWidgets/wxWidgets#26250)

In KiCad we have a wxGLCanvas inside a sizer in a wxPopupWindow.

On Wayland+EGL the canvas gets positioned incorrectly:

image.png (view on web)

Also messages like this appear:

Trace: (glegl) Window 0x55555a048df0 is not not ready to draw yet
Trace: (glegl) In frame callback handler for 0x55555a048df0

This worked fine at some point. Also works fine with GDK_BACKEND=x11.

Single display, no scaling.

Platform and version information

  • wxWidgets version you use: master (3.3)
  • wxWidgets port you use: wxGTK
  • OS and its version: Manjaro
    • Which GDK backend is used: Wayland
    • Desktop environment : KDE


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250@github.com>

VZ

unread,
Feb 26, 2026, 8:55:32 AMFeb 26
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26250)

I think the messages are fine/expected and not related to the wrong origin problem.

I'll try to look at this, starting by making a reproducer for it, but I suspect this might be another instance when we do something in wxTLW in wxGTK that ought to be done in wxNonOwnedWindow.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/3966795987@github.com>

Jiří Pinkava

unread,
Mar 16, 2026, 8:20:03 PMMar 16
to wx-...@googlegroups.com, Subscribed
pinkavaj left a comment (wxWidgets/wxWidgets#26250)

FYI: https://gitlab.com/kicad/code/kicad/-/work_items/23460


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4071479103@github.com>

dsa-t

unread,
Apr 4, 2026, 12:30:26 PMApr 4
to wx-...@googlegroups.com, Subscribed
dsa-t left a comment (wxWidgets/wxWidgets#26250)

Here's a basic repro case:

cube.cpp.txt
cube.h.txt

The menu doesn't open on Wayland either with message Tried to map a popup with a non-top most parent


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4187360754@github.com>

VZ

unread,
Apr 12, 2026, 3:39:55 PM (12 days ago) Apr 12
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26250)

Thanks for the reproducer, the fix is actually embarrassingly simple:

diff --git a/src/unix/glegl.cpp b/src/unix/glegl.cpp
index 02e3374143..daf5eb4a4c 100644
--- a/src/unix/glegl.cpp
+++ b/src/unix/glegl.cpp
@@ -449,7 +449,7 @@ void wxGLCanvasEGL::UpdateSubsurfacePosition()
     }
 
     int x, y;
-    gdk_window_get_origin(m_canvas->GTKGetDrawingWindow(), &x, &y);
+    gdk_window_get_position(m_canvas->GTKGetDrawingWindow(), &x, &y);
     wl_subsurface_set_position(m_wlSubsurface, x, y);
 }
 

Apparently this only worked before because for normal TLWs (0,0) of the root coordinate system is the top left corner of the window under Wayland — but for popups this is not the case. Using position instead of origin works fine in both cases however, so I'm going to push it, please retest with KiCad when you can.

Note that I'm still not sure what's going on with hiding/showing: I was wondering why did you do it like this and tried without these calls, but then the popup was never shown at all. I didn't try to debug this further, as I guess this is not a problem in real use, but please open another issue if it is. Thanks!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4232594323@github.com>

VZ

unread,
Apr 12, 2026, 3:44:39 PM (12 days ago) Apr 12
to wx-...@googlegroups.com, Subscribed

Closed #26250 as completed via 5a42ec7.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/26250/issue_event/24425275109@github.com>

dsa-t

unread,
Apr 12, 2026, 5:17:17 PM (11 days ago) Apr 12
to wx-...@googlegroups.com, Subscribed
dsa-t left a comment (wxWidgets/wxWidgets#26250)

Note that I'm still not sure what's going on with hiding/showing: I was wondering why did you do it like this

Wayland doesn't allow moving shown windows, so we hide them before moving.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4232763893@github.com>

dsa-t

unread,
Apr 17, 2026, 12:36:14 PM (7 days ago) Apr 17
to wx-...@googlegroups.com, Subscribed
dsa-t left a comment (wxWidgets/wxWidgets#26250)

That's how KiCad PCB editor looks now:

image.png (view on web)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4269714650@github.com>

VZ

unread,
Apr 17, 2026, 12:37:28 PM (7 days ago) Apr 17
to wx-...@googlegroups.com, Subscribed

Reopened #26250.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/26250/issue_event/24615958806@github.com>

VZ

unread,
Apr 17, 2026, 12:38:15 PM (7 days ago) Apr 17
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26250)

Is this also with Wayland or with X11?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4269724616@github.com>

dsa-t

unread,
Apr 17, 2026, 12:38:56 PM (7 days ago) Apr 17
to wx-...@googlegroups.com, Subscribed
dsa-t left a comment (wxWidgets/wxWidgets#26250)

logging origin/position:

origin=(0,0) position=(0,0)

origin=(237,285) position=(-1,-1)
origin=(241,310) position=(0,0)
origin=(241,307) position=(0,0)
origin=(241,253) position=(0,0)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4269728423@github.com>

dsa-t

unread,
Apr 17, 2026, 12:40:40 PM (7 days ago) Apr 17
to wx-...@googlegroups.com, Subscribed
dsa-t left a comment (wxWidgets/wxWidgets#26250)

It is all fine when using GDK_BACKEND=x11


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4269736540@github.com>

VZ

unread,
Apr 17, 2026, 12:43:57 PM (7 days ago) Apr 17
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26250)

But does the sample with your patch work for you? I.e. is it the difference between the compositors (the patched sample works fine for me under Sway, I didn't test with anything else yet) or between the sample and the actual KiCad code?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4269754040@github.com>

VZ

unread,
Apr 17, 2026, 12:46:15 PM (7 days ago) Apr 17
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26250)

FWIW I've put the following in MyFrame::UpdatePopupPosition() (after Move() and Show()):

    int x0, y0;
    gdk_window_get_origin(m_canvas->GTKGetDrawingWindow(), &x0, &y0);
    int x, y;
    gdk_window_get_position(m_canvas->GTKGetDrawingWindow(), &x, &y);
    wxLogDebug("Popup position=%d,%d, origin=%d,%d, pos=%d,%d", popupPos.x, popupPos.y, x0, y0, x, y);

and I get this kind of output with Wayland/Sway:

18:41:57: Debug: Popup position=149,103, origin=157,219, pos=8,116
18:41:57: Debug: Popup position=148,102, origin=156,218, pos=8,116
18:41:57: Debug: Popup position=147,101, origin=155,217, pos=8,116

In comparison, with X11 it's something like this:

18:43:51: Debug: Popup position=2835,475, origin=2843,591, pos=8,116
18:43:51: Debug: Popup position=2835,476, origin=2843,592, pos=8,116
18:43:51: Debug: Popup position=2835,478, origin=2843,594, pos=8,116


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4269766596@github.com>

dsa-t

unread,
Apr 17, 2026, 12:53:12 PM (7 days ago) Apr 17
to wx-...@googlegroups.com, Subscribed
dsa-t left a comment (wxWidgets/wxWidgets#26250)

I get similar values. It fixes the sample, but not kicad.

As seen here, the "Text before preview" is not visible:
image.png (view on web)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4269806048@github.com>

dsa-t

unread,
Apr 17, 2026, 1:13:27 PM (7 days ago) Apr 17
to wx-...@googlegroups.com, Subscribed
dsa-t left a comment (wxWidgets/wxWidgets#26250)

Wrapping the canvas in a panel breaks the sample:

    CubePopupWindow(wxWindow* parent, bool stereoWindow, wxGLCanvas** canvasOut)
        : wxPopupWindow(parent, wxBORDER_SIMPLE)
    {
        auto* topLabel = new wxStaticText(this, wxID_ANY, "Before GL canvas");
        auto* canvasPanel = new wxPanel(this, wxID_ANY);
        auto* canvas = new TestGLCanvas(canvasPanel, stereoWindow);
        canvas->SetMinSize(wxSize(320, 320));
        auto* canvasSizer = new wxBoxSizer(wxVERTICAL);
        canvasSizer->Add(canvas, 1, wxEXPAND);
        canvasPanel->SetSizer(canvasSizer);
        auto* bottomLabel = new wxStaticText(this, wxID_ANY, "After GL canvas");

        auto* sizer = new wxBoxSizer(wxVERTICAL);
        sizer->Add(topLabel, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 8);
        sizer->Add(canvasPanel, 1, wxLEFT | wxRIGHT | wxEXPAND, 8);
        sizer->Add(bottomLabel, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 8);

        SetSizerAndFit(sizer);

        if ( canvasOut )
            *canvasOut = canvas;
    }
image.png (view on web)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4269922458@github.com>

dsa-t

unread,
Apr 17, 2026, 1:30:34 PM (7 days ago) Apr 17
to wx-...@googlegroups.com, Subscribed
dsa-t left a comment (wxWidgets/wxWidgets#26250)

Something like this seems to do the trick:

void wxGLCanvasEGL::UpdateSubsurfacePosition()
{
    if ( !m_wlSubsurface )
    {
        // In some circumstances such as when reparenting a canvas between two hidden
        // toplevel windows, GTK will call size-allocate before mapping the canvas
        // Ignore the call, the position will be fixed when it is mapped
        return;
    }

    GtkWidget* toplevel = gtk_widget_get_toplevel(m_canvas->m_widget);
    GdkWindow* toplevelWindow = gtk_widget_get_window(toplevel);

    int tlwx, tlwy, ox, oy;
    gdk_window_get_origin(toplevelWindow, &tlwx, &tlwy);
    gdk_window_get_origin(m_canvas->GTKGetDrawingWindow(), &ox, &oy);

    wl_subsurface_set_position(m_wlSubsurface, ox - tlwx, oy - tlwy);

    std::cout << "origin=(" << ox << "," << oy
              << ") toplevel origin=(" << tlwx << "," << tlwy << ")" << std::endl;
}


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4270026695@github.com>

VZ

unread,
Apr 17, 2026, 1:37:37 PM (7 days ago) Apr 17
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26250)

Yes, this makes sense, thanks. The funny (sad?) thing is that I had started with something very similar, if not identical, but then simplified it to the fix which I pushed because I couldn't see any difference.

I'll test this a bit more and push later, thanks!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4270063124@github.com>

VZ

unread,
Apr 17, 2026, 1:50:39 PM (7 days ago) Apr 17
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26250)

There is also gtk_widget_translate_coordinates() which could be used for this, but I'm not sure if there is really any difference between what it does and your patch in this case.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26250/4270139112@github.com>

VZ

unread,
Apr 18, 2026, 6:28:05 PM (5 days ago) Apr 18
to wx-...@googlegroups.com, Subscribed

Closed #26250 as completed via f8cef12.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/26250/issue_event/24643258197@github.com>

Reply all
Reply to author
Forward
0 new messages