]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/window.cpp
remove unnecessary include of wx/cairo.h
[wxWidgets.git] / src / gtk / window.cpp
index ea80fb319d8f4846bb3bdb9b5d6f5718af9de9ac..2fe5fc38baf823f56d220f522f213a85624da271 100644 (file)
@@ -2270,14 +2270,20 @@ void wxWindowGTK::GTKCreateScrolledWindowWith(GtkWidget* view)
         }
     }
 
-    if (HasFlag(wxALWAYS_SHOW_SB))
-    {
-        gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS );
-    }
-    else
-    {
-        gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
-    }
+    // If wx[HV]SCROLL is not given, the corresponding scrollbar is not shown
+    // at all. Otherwise it may be shown only on demand (default) or always, if
+    // the wxALWAYS_SHOW_SB is specified.
+    GtkPolicyType horzPolicy = HasFlag(wxHSCROLL)
+                                ? HasFlag(wxALWAYS_SHOW_SB)
+                                    ? GTK_POLICY_ALWAYS
+                                    : GTK_POLICY_AUTOMATIC
+                                : GTK_POLICY_NEVER;
+    GtkPolicyType vertPolicy = HasFlag(wxVSCROLL)
+                                ? HasFlag(wxALWAYS_SHOW_SB)
+                                    ? GTK_POLICY_ALWAYS
+                                    : GTK_POLICY_AUTOMATIC
+                                : GTK_POLICY_NEVER;
+    gtk_scrolled_window_set_policy( scrolledWindow, horzPolicy, vertPolicy );
 
     m_scrollBar[ScrollDir_Horz] = GTK_RANGE(gtk_scrolled_window_get_hscrollbar(scrolledWindow));
     m_scrollBar[ScrollDir_Vert] = GTK_RANGE(gtk_scrolled_window_get_vscrollbar(scrolledWindow));
@@ -2380,10 +2386,25 @@ wxWindowGTK::~wxWindowGTK()
     if ( gs_deferredFocusOut == this )
         gs_deferredFocusOut = NULL;
 
-    if (m_widget)
-        GTKDisconnect(m_widget);
-    if (m_wxwindow && m_wxwindow != m_widget)
+    // Unlike the above cases, which can happen in normal circumstances, a
+    // window shouldn't be destroyed while it still has capture, so even though
+    // we still reset the global pointer to avoid leaving it dangling and
+    // crashing afterwards, also complain about it.
+    if ( g_captureWindow == this )
+    {
+        wxFAIL_MSG( wxS("Destroying window with mouse capture") );
+        g_captureWindow = NULL;
+    }
+
+    if (m_wxwindow)
+    {
         GTKDisconnect(m_wxwindow);
+        GtkWidget* parent = gtk_widget_get_parent(m_wxwindow);
+        if (parent)
+            GTKDisconnect(parent);
+    }
+    if (m_widget && m_widget != m_wxwindow)
+        GTKDisconnect(m_widget);
 
     // destroy children before destroying this window itself
     DestroyChildren();
@@ -4686,18 +4707,23 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt)
 }
 
 // Get the current mouse position.
-wxPoint wxGetMousePosition()
+void wxGetMousePosition(int* x, int* y)
 {
-    int x, y;
     GdkDisplay* display = GetDisplay();
 #ifdef __WXGTK3__
     GdkDeviceManager* manager = gdk_display_get_device_manager(display);
     GdkDevice* device = gdk_device_manager_get_client_pointer(manager);
-    gdk_device_get_position(device, NULL, &x, &y);
+    gdk_device_get_position(device, NULL, x, y);
 #else
-    gdk_display_get_pointer(display, NULL, &x, &y, NULL);
+    gdk_display_get_pointer(display, NULL, x, y, NULL);
 #endif
-    return wxPoint(x, y);
+}
+
+wxPoint wxGetMousePosition()
+{
+    wxPoint pt;
+    wxGetMousePosition(&pt.x, &pt.y);
+    return pt;
 }
 
 GdkWindow* wxWindowGTK::GTKGetDrawingWindow() const