Commit fbb0ba1a authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Do not interpret distant clicks as double-clicks (#116541, Bernhard

Tue Dec 16 01:46:46 2003  Matthias Clasen  <maclas@gmx.de>

	Do not interpret distant clicks as double-clicks  (#116541,
	Bernhard Walle):

	* gdk/gdkdisplay.h (struct GdkDisplay): Add new fields
	double_click_distance, button_x and button_y.
	* gdk/gdkdisplay.c (gdk_display_init): Initialize the new fields.

	* gdk/gdkdisplay.h:
	* gdk/gdkevents.c (gdk_display_set_double_click_distance):
	New function to set the double click distance on a display.

	* gdk/gdkevents.c: Take double click distance into account
	when generating single, double or triple clicks.

	* gtk/gtksettings.c: Add new setting "gtk-double-click-distance".

	* gdk/x11/gdkevents-x11.c: Add the XSetting
	"Net/DoubleClickDistance" and map it to "gtk-double-click-distance".
parent 69c2585f
Tue Dec 16 01:46:46 2003 Matthias Clasen <maclas@gmx.de>
Do not interpret distant clicks as double-clicks (#116541,
Bernhard Walle):
* gdk/gdkdisplay.h (struct GdkDisplay): Add new fields
double_click_distance, button_x and button_y.
* gdk/gdkdisplay.c (gdk_display_init): Initialize the new fields.
* gdk/gdkdisplay.h:
* gdk/gdkevents.c (gdk_display_set_double_click_distance):
New function to set the double click distance on a display.
* gdk/gdkevents.c: Take double click distance into account
when generating single, double or triple clicks.
* gtk/gtksettings.c: Add new setting "gtk-double-click-distance".
* gdk/x11/gdkevents-x11.c: Add the XSetting
"Net/DoubleClickDistance" and map it to "gtk-double-click-distance".
2003-12-15 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkdialog.c: Sigh, revert the change.
......
Tue Dec 16 01:46:46 2003 Matthias Clasen <maclas@gmx.de>
Do not interpret distant clicks as double-clicks (#116541,
Bernhard Walle):
* gdk/gdkdisplay.h (struct GdkDisplay): Add new fields
double_click_distance, button_x and button_y.
* gdk/gdkdisplay.c (gdk_display_init): Initialize the new fields.
* gdk/gdkdisplay.h:
* gdk/gdkevents.c (gdk_display_set_double_click_distance):
New function to set the double click distance on a display.
* gdk/gdkevents.c: Take double click distance into account
when generating single, double or triple clicks.
* gtk/gtksettings.c: Add new setting "gtk-double-click-distance".
* gdk/x11/gdkevents-x11.c: Add the XSetting
"Net/DoubleClickDistance" and map it to "gtk-double-click-distance".
2003-12-15 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkdialog.c: Sigh, revert the change.
......
Tue Dec 16 01:46:46 2003 Matthias Clasen <maclas@gmx.de>
Do not interpret distant clicks as double-clicks (#116541,
Bernhard Walle):
* gdk/gdkdisplay.h (struct GdkDisplay): Add new fields
double_click_distance, button_x and button_y.
* gdk/gdkdisplay.c (gdk_display_init): Initialize the new fields.
* gdk/gdkdisplay.h:
* gdk/gdkevents.c (gdk_display_set_double_click_distance):
New function to set the double click distance on a display.
* gdk/gdkevents.c: Take double click distance into account
when generating single, double or triple clicks.
* gtk/gtksettings.c: Add new setting "gtk-double-click-distance".
* gdk/x11/gdkevents-x11.c: Add the XSetting
"Net/DoubleClickDistance" and map it to "gtk-double-click-distance".
2003-12-15 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkdialog.c: Sigh, revert the change.
......
Tue Dec 16 01:46:46 2003 Matthias Clasen <maclas@gmx.de>
Do not interpret distant clicks as double-clicks (#116541,
Bernhard Walle):
* gdk/gdkdisplay.h (struct GdkDisplay): Add new fields
double_click_distance, button_x and button_y.
* gdk/gdkdisplay.c (gdk_display_init): Initialize the new fields.
* gdk/gdkdisplay.h:
* gdk/gdkevents.c (gdk_display_set_double_click_distance):
New function to set the double click distance on a display.
* gdk/gdkevents.c: Take double click distance into account
when generating single, double or triple clicks.
* gtk/gtksettings.c: Add new setting "gtk-double-click-distance".
* gdk/x11/gdkevents-x11.c: Add the XSetting
"Net/DoubleClickDistance" and map it to "gtk-double-click-distance".
2003-12-15 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkdialog.c: Sigh, revert the change.
......
Tue Dec 16 01:46:46 2003 Matthias Clasen <maclas@gmx.de>
Do not interpret distant clicks as double-clicks (#116541,
Bernhard Walle):
* gdk/gdkdisplay.h (struct GdkDisplay): Add new fields
double_click_distance, button_x and button_y.
* gdk/gdkdisplay.c (gdk_display_init): Initialize the new fields.
* gdk/gdkdisplay.h:
* gdk/gdkevents.c (gdk_display_set_double_click_distance):
New function to set the double click distance on a display.
* gdk/gdkevents.c: Take double click distance into account
when generating single, double or triple clicks.
* gtk/gtksettings.c: Add new setting "gtk-double-click-distance".
* gdk/x11/gdkevents-x11.c: Add the XSetting
"Net/DoubleClickDistance" and map it to "gtk-double-click-distance".
2003-12-15 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkdialog.c: Sigh, revert the change.
......
Tue Dec 16 01:57:13 2003 Matthias Clasen <maclas@gmx.de>
* gdk/gdk-sections.txt: Add gdk_display_set_double_click_distance.
Mon Dec 15 01:03:08 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtk-sections.txt: Add gtk_button_[sg]et_alignment.
......
......@@ -135,6 +135,7 @@ gdk_display_peek_event
gdk_display_put_event
gdk_display_add_client_message_filter
gdk_display_set_double_click_time
gdk_display_set_double_click_distance
gdk_display_get_pointer
gdk_display_get_window_at_pointer
GdkDisplayPointerHooks
......
......@@ -151,8 +151,11 @@ gdk_display_init (GdkDisplay *display)
display->button_click_time[0] = display->button_click_time[1] = 0;
display->button_window[0] = display->button_window[1] = NULL;
display->button_number[0] = display->button_number[1] = -1;
display->button_x[0] = display->button_x[1] = 0;
display->button_y[0] = display->button_y[1] = 0;
display->double_click_time = 250;
display->double_click_distance = 5;
display->pointer_hooks = &default_pointer_hooks;
}
......
......@@ -40,7 +40,6 @@ typedef struct _GdkDisplayPointerHooks GdkDisplayPointerHooks;
#define GDK_IS_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY))
#define GDK_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY, GdkDisplayClass))
struct _GdkDisplay
{
GObject parent_instance;
......@@ -62,6 +61,10 @@ struct _GdkDisplay
const GdkDisplayPointerHooks *pointer_hooks; /* Current hooks for querying pointer */
guint closed : 1; /* Whether this display has been closed */
guint double_click_distance; /* Maximum distance between clicks in pixels */
gint button_x[2]; /* The last 2 button click positions. */
gint button_y[2];
};
struct _GdkDisplayClass
......@@ -129,8 +132,10 @@ void gdk_display_add_client_message_filter (GdkDisplay *display,
GdkFilterFunc func,
gpointer data);
void gdk_display_set_double_click_time (GdkDisplay *display,
guint msec);
void gdk_display_set_double_click_time (GdkDisplay *display,
guint msec);
void gdk_display_set_double_click_distance (GdkDisplay *display,
guint distance);
GdkDisplay *gdk_display_get_default (void);
......
......@@ -46,10 +46,6 @@ GdkEventFunc _gdk_event_func = NULL; /* Callback for events */
gpointer _gdk_event_data = NULL;
GDestroyNotify _gdk_event_notify = NULL;
#define TRIPLE_CLICK_TIME(display) (2*display->double_click_time)
#define DOUBLE_CLICK_DIST 5
#define TRIPLE_CLICK_DIST 5
/*********************************************
* Functions for maintaining the event queue *
*********************************************/
......@@ -1031,22 +1027,28 @@ void
_gdk_event_button_generate (GdkDisplay *display,
GdkEvent *event)
{
if ((event->button.time < (display->button_click_time[1] + TRIPLE_CLICK_TIME (display))) &&
if ((event->button.time < (display->button_click_time[1] + 2*display->double_click_time)) &&
(event->button.window == display->button_window[1]) &&
(event->button.button == display->button_number[1]))
{
(event->button.button == display->button_number[1]) &&
(ABS (event->button.x - display->button_x[1]) <= display->double_click_distance) &&
(ABS (event->button.y - display->button_y[1]) <= display->double_click_distance))
{
gdk_synthesize_click (display, event, 3);
display->button_click_time[1] = 0;
display->button_click_time[0] = 0;
display->button_window[1] = NULL;
display->button_window[0] = 0;
display->button_number[1] = -1;
display->button_number[0] = -1;
display->button_x[0] = display->button_x[1] = 0;
display->button_y[0] = display->button_y[1] = 0;
}
else if ((event->button.time < (display->button_click_time[0] + display->double_click_time)) &&
(event->button.window == display->button_window[0]) &&
(event->button.button == display->button_number[0]))
(event->button.button == display->button_number[0]) &&
(ABS (event->button.x - display->button_x[0]) <= display->double_click_distance) &&
(ABS (event->button.y - display->button_y[0]) <= display->double_click_distance))
{
gdk_synthesize_click (display, event, 2);
......@@ -1056,6 +1058,10 @@ _gdk_event_button_generate (GdkDisplay *display,
display->button_window[0] = event->button.window;
display->button_number[1] = display->button_number[0];
display->button_number[0] = event->button.button;
display->button_x[1] = display->button_x[0];
display->button_x[0] = event->button.x;
display->button_y[1] = display->button_y[0];
display->button_y[0] = event->button.y;
}
else
{
......@@ -1065,6 +1071,10 @@ _gdk_event_button_generate (GdkDisplay *display,
display->button_window[0] = event->button.window;
display->button_number[1] = -1;
display->button_number[0] = event->button.button;
display->button_x[1] = 0;
display->button_x[0] = event->button.x;
display->button_y[1] = 0;
display->button_y[0] = event->button.y;
}
}
......@@ -1126,7 +1136,8 @@ gdk_synthesize_window_state (GdkWindow *window,
*
* Sets the double click time (two clicks within this time interval
* count as a double click and result in a #GDK_2BUTTON_PRESS event).
* Applications should NOT set this, it is a global user-configured setting.
* Applications should <emphasis>not</emphasis> set this, it is a global
* user-configured setting.
*
* Since: 2.2
**/
......@@ -1142,8 +1153,10 @@ gdk_display_set_double_click_time (GdkDisplay *display,
* @msec: double click time in milliseconds (thousandths of a second)
*
* Set the double click time for the default display. See
* gdk_display_set_double_click_time(). Applications should NOT
* set this, it is a global user-configured setting.
* gdk_display_set_double_click_time().
* See also gdk_display_set_double_click_distance().
* Applications should <emphasis>not</emphasis> set this, it is a
* global user-configured setting.
**/
void
gdk_set_double_click_time (guint msec)
......@@ -1151,6 +1164,26 @@ gdk_set_double_click_time (guint msec)
gdk_display_set_double_click_time (gdk_display_get_default (), msec);
}
/**
* gdk_display_set_double_click_distance:
* @display: a #GdkDisplay
* @distance: distance in pixels
*
* Sets the double click distance (two clicks within this distance
* count as a double click and result in a #GDK_2BUTTON_PRESS event).
* See also gdk_display_set_double_click_time().
* Applications should <emphasis>not</emphasis> set this, it is a global
* user-configured setting.
*
* Since: 2.4
**/
void
gdk_display_set_double_click_distance (GdkDisplay *display,
guint distance)
{
display->double_click_distance = distance;
}
GType
gdk_event_get_type (void)
{
......
......@@ -55,11 +55,6 @@ typedef struct _GdkIOClosure GdkIOClosure;
typedef struct _GdkDisplaySource GdkDisplaySource;
typedef struct _GdkEventTypeX11 GdkEventTypeX11;
#define DOUBLE_CLICK_TIME 250
#define TRIPLE_CLICK_TIME 500
#define DOUBLE_CLICK_DIST 5
#define TRIPLE_CLICK_DIST 5
struct _GdkIOClosure
{
GdkInputFunction function;
......@@ -2591,6 +2586,7 @@ static struct
const char *gdk_name;
} settings_map[] = {
{ "Net/DoubleClickTime", "gtk-double-click-time" },
{ "Net/DoubleClickDistance", "gtk-double-click-distance" },
{ "Net/DndDragThreshold", "gtk-dnd-drag-threshold" },
{ "Gtk/CanChangeAccels", "gtk-can-change-accels" },
{ "Gtk/ColorPalette", "gtk-color-palette" },
......
......@@ -45,6 +45,7 @@ struct _GtkSettingsPropertyValue
enum {
PROP_0,
PROP_DOUBLE_CLICK_TIME,
PROP_DOUBLE_CLICK_DISTANCE,
PROP_CURSOR_BLINK,
PROP_CURSOR_BLINK_TIME,
PROP_SPLIT_CURSOR,
......@@ -75,7 +76,7 @@ static void gtk_settings_notify (GObject *object,
static guint settings_install_property_parser (GtkSettingsClass *class,
GParamSpec *pspec,
GtkRcPropertyParser parser);
static void settings_update_double_click_time (GtkSettings *settings);
static void settings_update_double_click (GtkSettings *settings);
/* --- variables --- */
......@@ -172,6 +173,14 @@ gtk_settings_class_init (GtkSettingsClass *class)
G_PARAM_READWRITE),
NULL);
g_assert (result == PROP_DOUBLE_CLICK_TIME);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-double-click-distance",
_("Double Click Distance"),
_("Maximum distance allowed between two clicks for them to be considered a double click (in pixels)"),
0, G_MAXINT, 5,
G_PARAM_READWRITE),
NULL);
g_assert (result == PROP_DOUBLE_CLICK_DISTANCE);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-cursor-blink",
_("Cursor Blink"),
......@@ -299,7 +308,7 @@ gtk_settings_get_for_screen (GdkScreen *screen)
settings->screen = screen;
g_object_set_data (G_OBJECT (screen), "gtk-settings", settings);
gtk_rc_reparse_all_for_settings (settings, TRUE);
settings_update_double_click_time (settings);
settings_update_double_click (settings);
}
return settings;
......@@ -420,7 +429,8 @@ gtk_settings_notify (GObject *object,
switch (property_id)
{
case PROP_DOUBLE_CLICK_TIME:
settings_update_double_click_time (settings);
case PROP_DOUBLE_CLICK_DISTANCE:
settings_update_double_click (settings);
break;
}
}
......@@ -1162,16 +1172,20 @@ _gtk_settings_reset_rc_values (GtkSettings *settings)
}
static void
settings_update_double_click_time (GtkSettings *settings)
settings_update_double_click (GtkSettings *settings)
{
if (gdk_screen_get_number (settings->screen) == 0)
{
GdkDisplay *display = gdk_screen_get_display (settings->screen);
gint double_click_time;
gint double_click_distance;
g_object_get (settings, "gtk-double-click-time",
&double_click_time, NULL);
g_object_get (settings,
"gtk-double-click-time", &double_click_time,
"gtk-double-click-distance", &double_click_distance,
NULL);
gdk_display_set_double_click_time (display, double_click_time);
gdk_display_set_double_click_distance (display, double_click_distance);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment