X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a200c35efa060107d8243458fca160eb237b9c23..f427e0d63499522aeeb8360e6a5c748de0a87d92:/src/gtk1/window.cpp diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 866d2b4f8b..ca9543b11e 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1735,6 +1735,8 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, // "focus_out_event" //----------------------------------------------------------------------------- +static GtkWidget *gs_widgetLastFocus = NULL; + static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1745,6 +1747,18 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; + // VZ: this is really weird but GTK+ seems to call us from inside + // gtk_widget_grab_focus(), i.e. it first sends "focus_out" signal to + // this widget and then "focus_in". This is totally unexpected and + // completely breaks wxUniv code so ignore this dummy event (we can't + // be losing focus if we're about to acquire it!) + if ( widget == gs_widgetLastFocus ) + { + gs_widgetLastFocus = NULL; + + return; + } + // if the focus goes out of our app alltogether, OnIdle() will send // wxActivateEvent, otherwise gtk_window_focus_in_callback() will reset // g_sendActivateEvent to -1 @@ -2690,10 +2704,12 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags if (m_resizing) return; /* I don't like recursions */ m_resizing = TRUE; - if (x == -1) - x = m_x; + int currentX, currentY; + GetPosition(¤tX, ¤tY); + if (x == -1) + x = currentX; if (y == -1) - y = m_y; + y = currentY; AdjustForParentClientOrigin(x, y, sizeFlags); if (m_parent->m_wxwindow == NULL) /* i.e. wxNotebook */ @@ -2986,9 +3002,21 @@ void wxWindowGTK::DoGetPosition( int *x, int *y ) const dx = pizza->xoffset; dy = pizza->yoffset; } + + int nx = m_x - dx; + int ny = m_y - dy; + + if ( !IsTopLevel() && m_parent ) + { + // We may be faking the client origin. So a window that's really at (0, + // 30) may appear (to wxWin apps) to be at (0, 0). + wxPoint pt(m_parent->GetClientAreaOrigin()); + nx -= pt.x; + ny -= pt.y; + } - if (x) (*x) = m_x - dx; - if (y) (*y) = m_y - dy; + if (x) (*x) = nx; + if (y) (*y) = ny; } void wxWindowGTK::DoClientToScreen( int *x, int *y ) const @@ -3151,11 +3179,13 @@ void wxWindowGTK::SetFocus() if (m_wxwindow) { if (!GTK_WIDGET_HAS_FOCUS (m_wxwindow)) + { + // see comment in gtk_window_focus_out_callback() + gs_widgetLastFocus = m_wxwindow; gtk_widget_grab_focus (m_wxwindow); - return; + } } - - if (m_widget) + else if (m_widget) { if (GTK_WIDGET_CAN_FOCUS(m_widget) && !GTK_WIDGET_HAS_FOCUS (m_widget) ) {