Fix ClientToScreen()/ScreenToClient() when used immediately after window creation.
And whenever window does not have an up-to-date GTK size allocation. Closes #16061 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@78033 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3091,7 +3091,37 @@ void wxWindowGTK::DoClientToScreen( int *x, int *y ) const
|
||||
{
|
||||
wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
|
||||
|
||||
if (gtk_widget_get_window(m_widget) == NULL) return;
|
||||
if (!m_useCachedClientSize && !IsTopLevel() && m_parent)
|
||||
{
|
||||
m_parent->DoClientToScreen(x, y);
|
||||
int xx, yy;
|
||||
DoGetPosition(&xx, &yy);
|
||||
if (m_wxwindow)
|
||||
{
|
||||
GtkBorder border;
|
||||
WX_PIZZA(m_wxwindow)->get_border(border);
|
||||
xx += border.left;
|
||||
yy += border.top;
|
||||
}
|
||||
if (y) *y += yy;
|
||||
if (x)
|
||||
{
|
||||
if (GetLayoutDirection() != wxLayout_RightToLeft)
|
||||
*x += xx;
|
||||
else
|
||||
{
|
||||
int w;
|
||||
// undo RTL conversion done by parent
|
||||
m_parent->DoGetClientSize(&w, NULL);
|
||||
*x = w - *x;
|
||||
|
||||
DoGetClientSize(&w, NULL);
|
||||
*x += xx;
|
||||
*x = w - *x;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
GdkWindow *source = NULL;
|
||||
if (m_wxwindow)
|
||||
@@ -3099,6 +3129,8 @@ void wxWindowGTK::DoClientToScreen( int *x, int *y ) const
|
||||
else
|
||||
source = gtk_widget_get_window(m_widget);
|
||||
|
||||
wxCHECK_RET(source, "ClientToScreen failed on unrealized window");
|
||||
|
||||
int org_x = 0;
|
||||
int org_y = 0;
|
||||
gdk_window_get_origin( source, &org_x, &org_y );
|
||||
@@ -3130,7 +3162,37 @@ void wxWindowGTK::DoScreenToClient( int *x, int *y ) const
|
||||
{
|
||||
wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
|
||||
|
||||
if (!gtk_widget_get_realized(m_widget)) return;
|
||||
if (!m_useCachedClientSize && !IsTopLevel() && m_parent)
|
||||
{
|
||||
m_parent->DoScreenToClient(x, y);
|
||||
int xx, yy;
|
||||
DoGetPosition(&xx, &yy);
|
||||
if (m_wxwindow)
|
||||
{
|
||||
GtkBorder border;
|
||||
WX_PIZZA(m_wxwindow)->get_border(border);
|
||||
xx += border.left;
|
||||
yy += border.top;
|
||||
}
|
||||
if (y) *y -= yy;
|
||||
if (x)
|
||||
{
|
||||
if (GetLayoutDirection() != wxLayout_RightToLeft)
|
||||
*x -= xx;
|
||||
else
|
||||
{
|
||||
int w;
|
||||
// undo RTL conversion done by parent
|
||||
m_parent->DoGetClientSize(&w, NULL);
|
||||
*x = w - *x;
|
||||
|
||||
DoGetClientSize(&w, NULL);
|
||||
*x -= xx;
|
||||
*x = w - *x;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
GdkWindow *source = NULL;
|
||||
if (m_wxwindow)
|
||||
@@ -3138,6 +3200,8 @@ void wxWindowGTK::DoScreenToClient( int *x, int *y ) const
|
||||
else
|
||||
source = gtk_widget_get_window(m_widget);
|
||||
|
||||
wxCHECK_RET(source, "ScreenToClient failed on unrealized window");
|
||||
|
||||
int org_x = 0;
|
||||
int org_y = 0;
|
||||
gdk_window_get_origin( source, &org_x, &org_y );
|
||||
|
Reference in New Issue
Block a user