Linux: wxPreferencesEditor: Window height is mis-calculated under Wayland (Issue #22155)

76 views
Skip to first unread message

Will Cosgrove

unread,
Feb 23, 2022, 1:56:42 PM2/23/22
to wx-...@googlegroups.com, Subscribed

Describe the bug
When using wxPreferencesEditor under Wayland, the height of the window is mis-calculated causing it to be too short. It appears to be too short by the height of the title bar + the bottom space which includes the Close button. I'm a 4k monitor which may be influencing the bug.

Expected vs observed behaviour
The window to be sized correctly on Wayland. Observed, the heigh is only calculated correctly on X.

Patch or snippet allowing to reproduce the problem

I believe just running the Preferences Sample application will show the issue.

Platform and version information

  • wxWidgets version you use: 3.1.5
  • wxWidgets port you use: wxGTK
  • OS and its version: Fedora 35
  • For wxGTK only:
    • GTK version: 3.24.31
    • Which GDK backend is used: Wayland


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22155@github.com>

Will Cosgrove

unread,
Feb 23, 2022, 3:10:30 PM2/23/22
to wx-...@googlegroups.com, Subscribed

Doing some more testing, it works on Wayland under Ubuntu 21.10, but not on Fedora 35, so there may be a bit more to this.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Scott Talbert

unread,
Feb 23, 2022, 3:19:42 PM2/23/22
to wx-...@googlegroups.com, Subscribed

Doing some more testing, it works on Wayland under Ubuntu 21.10, but not on Fedora 35, so there may be a bit more to this.

Client-side decorations vs not?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Will Cosgrove

unread,
Feb 23, 2022, 8:02:56 PM2/23/22
to wx-...@googlegroups.com, Subscribed

So I'm doing some more debugging and here's what I found; if I launch my program from within VSCode (as a child process using gdb) the prefs window lays out as expected. If I launch it standalone it doesn't layout correctly. Furthermore, if I run the sample prefs app standalone, it works just fine. The only thing I can come up with is for my program we're using the vcpkg version of wxWidgets while for the sample app I built wx directly. Do you know of any build flags that may cause this behavior?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Will Cosgrove

unread,
Feb 23, 2022, 8:12:56 PM2/23/22
to wx-...@googlegroups.com, Subscribed

The other option is the bug was fixed post 3.1.5.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Will Cosgrove

unread,
Feb 25, 2022, 10:13:04 PM2/25/22
to wx-...@googlegroups.com, Subscribed

OK, I have found a reproducible case. If replace the MyFrame() code in the Preferences example with the sizer example code (https://docs.wxwidgets.org/3.0/overview_sizer.html), then show the Preferences window, the preferences window will be crushed. As crazy as it sounds, it seems like sizers inside of sizers in another frame is triggering the issue.

MyFrame() : wxFrame(NULL, wxID_ANY, "Preferences sample")
    {
        wxMenu *fileMenu = new wxMenu;
        fileMenu->Append(wxID_PREFERENCES);
        fileMenu->Append(wxID_EXIT);

        wxMenuBar *menuBar = new wxMenuBar();
        menuBar->Append(fileMenu, "&File");
        SetMenuBar(menuBar);

        Bind(wxEVT_MENU, &MyFrame::OnPref, this, wxID_PREFERENCES);
        Bind(wxEVT_MENU, &MyFrame::OnExit, this, wxID_EXIT);
        Bind(wxEVT_CLOSE_WINDOW, &MyFrame::OnClose, this);

            wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
    // create text ctrl with minimal size 100x60
    topsizer->Add(
        new wxTextCtrl(this, -1, "My text.", wxDefaultPosition, wxSize(100,60), wxTE_MULTILINE),
        1,            // make vertically stretchable
        wxEXPAND |    // make horizontally stretchable
        wxALL,        //   and make border all around
        10 );         // set border width to 10
    wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
    button_sizer->Add(
        new wxButton(this, wxID_OK, "OK" ),
        0,           // make horizontally unstretchable
        wxALL,       // make border all around (implicit top alignment)
        10 );        // set border width to 10
    button_sizer->Add(
        new wxButton(this, wxID_CANCEL, "Cancel" ),
        0,           // make horizontally unstretchable
        wxALL,       // make border all around (implicit top alignment)
        10 );        // set border width to 10
    topsizer->Add(
        button_sizer,
        0,                // make vertically unstretchable
        wxALIGN_CENTER ); // no border and centre horizontally

    SetSizerAndFit(topsizer); // use the sizer for layout and size window
                              // accordingly and prevent it from being resized
                              // to smaller size

        // Show the initial values.
       // UpdateSettings();
    }


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Will Cosgrove

unread,
Feb 25, 2022, 10:26:03 PM2/25/22
to wx-...@googlegroups.com, Subscribed

The end result looks like this:

Screenshot from 2022-02-25 19-25-08


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Will Cosgrove

unread,
Feb 25, 2022, 10:34:15 PM2/25/22
to wx-...@googlegroups.com, Subscribed

I should note, I also removed the second page in the preferences example for testing.

//m_prefEditor->AddPage(new PrefsPageTopics());


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

paulcor

unread,
Mar 17, 2022, 12:37:39 AM3/17/22
to wx-...@googlegroups.com, Subscribed

Test case as a diff against the preferences sample.

diff --git a/samples/preferences/preferences.cpp b/samples/preferences/preferences.cpp
index 4b231fd5d2..a1b05ebdb7 100644
--- a/samples/preferences/preferences.cpp
+++ b/samples/preferences/preferences.cpp
@@ -24,6 +24,8 @@
 #include "wx/sizer.h"
 #include "wx/artprov.h"
 #include "wx/frame.h"
+#include "wx/textctrl.h"
+#include "wx/button.h"
 
 // This struct combines the settings edited in the preferences dialog.
 struct MySettings
@@ -81,6 +83,7 @@ public:
         Bind(wxEVT_MENU, &MyFrame::OnExit, this, wxID_EXIT);
         Bind(wxEVT_CLOSE_WINDOW, &MyFrame::OnClose, this);
 
+#if 0
         wxPanel* const panel = new wxPanel(this);
         m_textMarkdownSyntax = new wxStaticText(panel, wxID_ANY, "");
         m_textSpellcheck = new wxStaticText(panel, wxID_ANY, "");
@@ -95,6 +98,17 @@ public:
         sizer->Add(m_textSpellcheck,
                    wxSizerFlags().Center());
         panel->SetSizer(sizer);
+#endif
+        wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
+        topsizer->Add(
+            new wxTextCtrl(this, -1, "My text.", wxDefaultPosition, wxSize(100,60), wxTE_MULTILINE),
+            1, wxEXPAND | wxALL, 10);
+        wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
+        button_sizer->Add(new wxButton(this, wxID_OK, "OK"), 0, wxALL, 10);
+        button_sizer->Add(new wxButton(this, wxID_CANCEL, "Cancel"), 0, wxALL, 10);
+        topsizer->Add(button_sizer, 0, wxALIGN_CENTER);
+
+        SetSizerAndFit(topsizer);
 
         // Show the initial values.
         UpdateSettings();
@@ -102,6 +116,7 @@ public:
 
     void UpdateSettings()
     {
+        return;
         // Here we should update the settings we use. As we don't actually do
         // anything in this sample, just update their values shown on screen.
         const MySettings& settings = wxGetApp().GetSettings();
@@ -298,7 +313,6 @@ void MyApp::ShowPreferencesEditor(wxWindow* parent)
     {
         m_prefEditor.reset(new wxPreferencesEditor);
         m_prefEditor->AddPage(new PrefsPageGeneral());
-        m_prefEditor->AddPage(new PrefsPageTopics());
     }
 
     m_prefEditor->Show(parent);


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

paulcor

unread,
Mar 29, 2022, 12:23:55 PM3/29/22
to wx-...@googlegroups.com, Subscribed

Should be fixed by 1b129ef and 8f47d9a


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/22155/1082091648@github.com>

paulcor

unread,
Mar 29, 2022, 12:23:56 PM3/29/22
to wx-...@googlegroups.com, Subscribed

Closed #22155.


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/22155/issue_event/6328139759@github.com>

Reply all
Reply to author
Forward
0 new messages