There is a logic problem in the TLW code, but I'm not sure how much it matters. For me the dialog is centered with GTK2 as well. And still centered with GTK3 even with these changes:
diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 3ebd0cd052..f1c38e6b64 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -701,8 +701,6 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, // on parent by default (this is what GtkDialog ctor does): gtk_window_set_type_hint(GTK_WINDOW(m_widget), GDK_WINDOW_TYPE_HINT_DIALOG); - gtk_window_set_position(GTK_WINDOW(m_widget), - GTK_WIN_POS_CENTER_ON_PARENT); } else { @@ -792,9 +790,6 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, if (pos.IsFullySpecified()) { #ifdef __WXGTK3__ - GtkWindowPosition windowPos; - g_object_get(m_widget, "window-position", &windowPos, nullptr); - if (windowPos == GTK_WIN_POS_NONE) gtk_window_move(GTK_WINDOW(m_widget), m_x, m_y); #else gtk_widget_set_uposition( m_widget, m_x, m_y );
In general, the Window Manager is free to ignore any request to position a TLW. And of course with Wayland, it's guaranteed to be ignored.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
If a wxDialog
is created with a specified position, it will not be displayed at that position, but centered (on the parent window) instead.
This is a GTK3 specific issue as with GTK2 the dialog is correctly displayed at the specified position.
The cause of this issue seems to be that the dialog is first centered during creation (with both GTK2 and GTK3).
And later it is moved to the specified position. What is always done with GTK2, but with GTK3 only under a condition that is not met due to the previous centering.
The issue can be reproduced in the minimal sample, with the following changes.
diff --git "a/samples/minimal/minimal.cpp" "b/samples/minimal/minimal.cpp" index 5f32257c6b..5f31b66df3 100644 --- "a/samples/minimal/minimal.cpp" +++ "b/samples/minimal/minimal.cpp" @@ -188,6 +188,10 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { + wxDialog dlg( this, wxID_ANY, "Test", wxPoint(0, 0), wxSize(200, 150) ); + dlg.ShowModal(); + return; + wxMessageBox(wxString::Format ( "Welcome to %s!\n"
F1
key to show a dialog at the top left of the screen.—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
With these changes
diff --git "a/src/gtk/toplevel.cpp" "b/src/gtk/toplevel.cpp" index 3ebd0cd052..22b0d126f6 100644 --- "a/src/gtk/toplevel.cpp" +++ "b/src/gtk/toplevel.cpp" @@ -792,9 +792,6 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, if (pos.IsFullySpecified()) { #ifdef __WXGTK3__
- GtkWindowPosition windowPos; - g_object_get(m_widget, "window-position", &windowPos, nullptr); - if (windowPos == GTK_WIN_POS_NONE) gtk_window_move(GTK_WINDOW(m_widget), m_x, m_y); #else gtk_widget_set_uposition( m_widget, m_x, m_y );
it works on:
Surely it doesn't work with Wayland. But that is another, more fundamental problem. And should not be a reason for not making it work with X11.
So please apply a fix and also backport it to 3.2. Thanks in advance!
P.S.: I don't know what system you are using, but it might not work for you because you may have "Attached Modal Dialogs" enabled. See: How to detach modal dialogs from main window
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
I think we could apply this, i.e. I don't think this would things worse. @paulcor Please let me know if you have any objections or prefer a different fix.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
Closed #24552 as completed.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
Closing as fix was applied to master and I've added it to 3.2 backports branch too. Thanks!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.