+ return success;
+}
+
+// helper: return the GtkSettings either for the screen the current window is
+// on or for the default screen if window is NULL
+static GtkSettings *GetSettingsForWindowScreen(GdkWindow *window)
+{
+ return window ? gtk_settings_get_for_screen(gdk_drawable_get_screen(window))
+ : gtk_settings_get_default();
+}
+
+int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
+{
+ GdkWindow *window = NULL;
+ if(win && GTK_WIDGET_REALIZED(win->GetHandle()))
+ window = win->GetHandle()->window;
+
+ switch (index)
+ {
+ case wxSYS_BORDER_X:
+ case wxSYS_BORDER_Y:
+ case wxSYS_EDGE_X:
+ case wxSYS_EDGE_Y:
+ case wxSYS_FRAMESIZE_X:
+ case wxSYS_FRAMESIZE_Y:
+ // If a window is specified/realized, and it is a toplevel window, we can query from wm.
+ // The returned border thickness is outside the client area in that case.
+ if (window)
+ {
+ wxTopLevelWindow *tlw = wxDynamicCast(win, wxTopLevelWindow);
+ if (!tlw)
+ return -1; // not a tlw, not sure how to approach
+ else
+ {
+ // Get the frame extents from the windowmanager.
+ // In most cases the top extent is the titlebar, so we use the bottom extent
+ // for the heights.
+ int right, bottom;
+ if (GetFrameExtents(window, NULL, &right, NULL, &bottom))
+ {
+ switch (index)
+ {
+ case wxSYS_BORDER_X:
+ case wxSYS_EDGE_X:
+ case wxSYS_FRAMESIZE_X:
+ return right; // width of right extent
+ default:
+ return bottom; // height of bottom extent
+ }
+ }
+ }
+ }
+
+ return -1; // no window specified
+
+ case wxSYS_CURSOR_X:
+ case wxSYS_CURSOR_Y:
+ return gdk_display_get_default_cursor_size(
+ window ? gdk_drawable_get_display(window)
+ : gdk_display_get_default());
+
+ case wxSYS_DCLICK_X:
+ case wxSYS_DCLICK_Y:
+ gint dclick_distance;
+ g_object_get(GetSettingsForWindowScreen(window),
+ "gtk-double-click-distance", &dclick_distance, NULL);
+
+ return dclick_distance * 2;
+
+ case wxSYS_DCLICK_MSEC:
+ gint dclick;
+ g_object_get(GetSettingsForWindowScreen(window),
+ "gtk-double-click-time", &dclick, NULL);
+ return dclick;
+
+ case wxSYS_DRAG_X:
+ case wxSYS_DRAG_Y:
+ gint drag_threshold;
+ g_object_get(GetSettingsForWindowScreen(window),
+ "gtk-dnd-drag-threshold", &drag_threshold, NULL);