// "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
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
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 */
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
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) )
{