+
+ // We cannot set colours and fonts before the widget
+ // been realized, so we do this directly after realization
+ // or otherwise in idle time
+
+ if (m_needsStyleChange)
+ {
+ SetBackgroundStyle(GetBackgroundStyle());
+ m_needsStyleChange = false;
+ }
+
+ wxWindowCreateEvent event(static_cast<wxWindow*>(this));
+ event.SetEventObject( this );
+ GTKProcessEvent( event );
+
+ GTKUpdateCursor(true, false);
+
+ if (m_wxwindow &&
+ (IsTopLevel() || HasFlag(wxBORDER_RAISED | wxBORDER_SUNKEN | wxBORDER_THEME)))
+ {
+ // attaching to style changed signal after realization avoids initial
+ // changes we don't care about
+ const gchar *detailed_signal =
+#ifdef __WXGTK3__
+ "style_updated";
+#else
+ "style_set";
+#endif
+ g_signal_connect(m_wxwindow,
+ detailed_signal,
+ G_CALLBACK(style_updated), this);
+ }
+}
+
+// ----------------------------------------------------------------------------
+// this wxWindowBase function is implemented here (in platform-specific file)
+// because it is static and so couldn't be made virtual
+// ----------------------------------------------------------------------------
+
+wxWindow *wxWindowBase::DoFindFocus()
+{
+ // For compatibility with wxMSW, pretend that showing a popup menu doesn't
+ // change the focus and that it remains on the window showing it, even
+ // though the real focus does change in GTK.
+ extern wxMenu *wxCurrentPopupMenu;
+ if ( wxCurrentPopupMenu )
+ return wxCurrentPopupMenu->GetInvokingWindow();
+
+ wxWindowGTK *focus = gs_pendingFocus ? gs_pendingFocus : gs_currentFocus;
+ // the cast is necessary when we compile in wxUniversal mode
+ return static_cast<wxWindow*>(focus);
+}
+
+void wxWindowGTK::AddChildGTK(wxWindowGTK* child)
+{
+ wxASSERT_MSG(m_wxwindow, "Cannot add a child to a window without a client area");
+
+ // the window might have been scrolled already, we
+ // have to adapt the position
+ wxPizza* pizza = WX_PIZZA(m_wxwindow);
+ child->m_x += pizza->m_scroll_x;
+ child->m_y += pizza->m_scroll_y;
+
+ pizza->put(child->m_widget,
+ child->m_x, child->m_y, child->m_width, child->m_height);
+}
+
+//-----------------------------------------------------------------------------
+// global functions
+//-----------------------------------------------------------------------------
+
+wxWindow *wxGetActiveWindow()
+{
+ return wxWindow::FindFocus();
+}
+
+
+// Under Unix this is implemented using X11 functions in utilsx11.cpp but we
+// need to have this function under Windows too, so provide at least a stub.
+#ifndef GDK_WINDOWING_X11
+bool wxGetKeyState(wxKeyCode WXUNUSED(key))
+{
+ wxFAIL_MSG(wxS("Not implemented under Windows"));
+ return false;
+}
+#endif // __WINDOWS__
+
+static void GetMouseState(int& x, int& y, GdkModifierType& mask)
+{
+ wxWindow* tlw = NULL;
+ if (!wxTopLevelWindows.empty())
+ tlw = wxTopLevelWindows.front();
+ GdkDisplay* display;
+ if (tlw && tlw->m_widget)
+ display = gtk_widget_get_display(tlw->m_widget);
+ else
+ display = gdk_display_get_default();
+ gdk_display_get_pointer(display, NULL, &x, &y, &mask);
+}
+
+wxMouseState wxGetMouseState()
+{
+ wxMouseState ms;
+
+ gint x;
+ gint y;
+ GdkModifierType mask;
+
+ GetMouseState(x, y, mask);