Add wxSYS_CARET_{ON,OFF,TIMEOUT}_MSEC system settings

Provide a way to retrieve the caret blink times from wxSystemSe and implement
it for wxOSX and wxGTK.

Closes #17629.
This commit is contained in:
brawer
2016-08-19 22:55:20 +02:00
committed by Vadim Zeitlin
parent 75e254fce7
commit 7f10d1fa8a
5 changed files with 138 additions and 2 deletions

View File

@@ -19,6 +19,8 @@
#include "wx/fontutil.h"
#include "wx/fontenum.h"
#include <stdint.h>
#include <gtk/gtk.h>
#include "wx/gtk/private/win_gtk.h"
#include "wx/gtk/private/gtk2-compat.h"
@@ -574,6 +576,56 @@ int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
"gtk-double-click-time", &dclick, NULL);
return dclick;
case wxSYS_CARET_ON_MSEC:
{
gint blink_time = -1;
g_object_get(GetSettingsForWindowScreen(window),
"gtk-cursor-blink-time", &blink_time, NULL);
if (blink_time > 0)
return blink_time / 2;
return -1;
}
case wxSYS_CARET_OFF_MSEC:
{
gboolean should_blink = true;
gint blink_time = -1;
g_object_get(GetSettingsForWindowScreen(window),
"gtk-cursor-blink", &should_blink,
"gtk-cursor-blink-time", &blink_time,
NULL);
if (!should_blink)
return 0;
if (blink_time > 0)
return blink_time / 2;
return -1;
}
case wxSYS_CARET_TIMEOUT_MSEC:
{
gboolean should_blink = true;
gint timeout = 0;
g_object_get(GetSettingsForWindowScreen(window),
"gtk-cursor-blink", &should_blink,
"gtk-cursor-blink-timeout", &timeout,
NULL);
if (!should_blink)
return 0;
// GTK+ returns this value in seconds, not milliseconds,
// Special value of 2147483647 means that the cursor never
// blinks and we handle any value that would overflow int after
// multiplication in the same manner as it looks quite
// unnecessary to support cursor blinking once a month.
if (timeout > 0 && timeout < INT32_MAX / 1000)
return timeout * 1000;
return -1; // no timeout, blink forever
}
case wxSYS_DRAG_X:
case wxSYS_DRAG_Y:
gint drag_threshold;