+ // Use composited window if background is transparent, if supported.
+ if (m_backgroundStyle == wxBG_STYLE_TRANSPARENT)
+ {
+#if wxGTK_HAS_COMPOSITING_SUPPORT
+ if (IsTransparentBackgroundSupported())
+ {
+ if (window)
+ gdk_window_set_composited(window, true);
+ }
+ else
+#endif // wxGTK_HAS_COMPOSITING_SUPPORT
+ {
+ // We revert to erase mode if transparency is not supported
+ m_backgroundStyle = wxBG_STYLE_ERASE;
+ }
+ }
+
+#ifndef __WXGTK3__
+ if (window && (
+ m_backgroundStyle == wxBG_STYLE_PAINT ||
+ m_backgroundStyle == wxBG_STYLE_TRANSPARENT))
+ {
+ gdk_window_set_back_pixmap(window, NULL, false);
+ }
+#endif
+
+ wxWindowCreateEvent event(static_cast<wxWindow*>(this));
+ event.SetEventObject( this );
+ GTKProcessEvent( event );
+
+ GTKUpdateCursor(true, false);
+
+ if (m_wxwindow && IsTopLevel())
+ {
+ // 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);
+ }
+}
+
+void wxWindowGTK::GTKHandleUnrealize()
+{
+ // unrealizing a frozen window seems to have some lingering effect
+ // preventing updates to the affected area
+ if (IsFrozen())
+ DoThaw();
+
+ if (m_wxwindow)
+ {
+ if (m_imContext)
+ gtk_im_context_set_client_window(m_imContext, NULL);
+
+ if (IsTopLevel())
+ {
+ g_signal_handlers_disconnect_by_func(
+ m_wxwindow, (void*)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()
+{
+#if wxUSE_MENUS
+ // 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();
+#endif // wxUSE_MENUS
+
+ 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 GdkDisplay* GetDisplay()
+{
+ 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();
+ return display;
+}
+
+wxMouseState wxGetMouseState()
+{
+ wxMouseState ms;
+
+ gint x;
+ gint y;
+ GdkModifierType mask;
+
+ GdkDisplay* display = GetDisplay();
+#ifdef __WXGTK3__
+ GdkDeviceManager* manager = gdk_display_get_device_manager(display);
+ GdkDevice* device = gdk_device_manager_get_client_pointer(manager);
+ GdkScreen* screen;
+ gdk_device_get_position(device, &screen, &x, &y);
+ GdkWindow* window = gdk_screen_get_root_window(screen);
+ gdk_device_get_state(device, window, NULL, &mask);
+#else
+ gdk_display_get_pointer(display, NULL, &x, &y, &mask);
+#endif
+
+ ms.SetX(x);
+ ms.SetY(y);
+ ms.SetLeftDown((mask & GDK_BUTTON1_MASK) != 0);
+ ms.SetMiddleDown((mask & GDK_BUTTON2_MASK) != 0);
+ ms.SetRightDown((mask & GDK_BUTTON3_MASK) != 0);
+ // see the comment in InitMouseEvent()
+ ms.SetAux1Down((mask & GDK_BUTTON4_MASK) != 0);
+ ms.SetAux2Down((mask & GDK_BUTTON5_MASK) != 0);
+
+ ms.SetControlDown((mask & GDK_CONTROL_MASK) != 0);
+ ms.SetShiftDown((mask & GDK_SHIFT_MASK) != 0);
+ ms.SetAltDown((mask & GDK_MOD1_MASK) != 0);
+ ms.SetMetaDown((mask & GDK_META_MASK) != 0);