gtk: Remove 2BUTTON and 3BUTTON events and event types

Those should be interpreted by widget-local gestures, not guessed at a
high level with no notions of the specific context. Users will want
GtkGestureMultiPress to replace these events.
This commit is contained in:
Carlos Garnacho 2017-09-15 17:34:06 +02:00
parent 403a724164
commit a9988e18b0
15 changed files with 5 additions and 245 deletions

View File

@ -101,8 +101,7 @@
* By default, GDK will automatically listen for events coming from all
* master devices, setting the #GdkDevice for all events coming from input
* devices. Events containing device information are #GDK_MOTION_NOTIFY,
* #GDK_BUTTON_PRESS, #GDK_2BUTTON_PRESS, #GDK_3BUTTON_PRESS,
* #GDK_BUTTON_RELEASE, #GDK_SCROLL, #GDK_KEY_PRESS, #GDK_KEY_RELEASE,
* #GDK_BUTTON_PRESS, #GDK_BUTTON_RELEASE, #GDK_SCROLL, #GDK_KEY_PRESS, #GDK_KEY_RELEASE,
* #GDK_ENTER_NOTIFY, #GDK_LEAVE_NOTIFY, #GDK_FOCUS_CHANGE,
* #GDK_PROXIMITY_IN, #GDK_PROXIMITY_OUT, #GDK_DRAG_ENTER, #GDK_DRAG_LEAVE,
* #GDK_DRAG_MOTION, #GDK_DRAG_STATUS, #GDK_DROP_START, #GDK_DROP_FINISHED

View File

@ -132,7 +132,6 @@ device_removed_cb (GdkDeviceManager *device_manager,
GdkDevice *device,
GdkDisplay *display)
{
g_hash_table_remove (display->multiple_click_info, device);
g_hash_table_remove (display->device_grabs, device);
g_hash_table_remove (display->pointers_info, device);
@ -386,9 +385,6 @@ gdk_display_init (GdkDisplay *display)
display->pointers_info = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) free_pointer_info);
display->multiple_click_info = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) g_free);
display->rendering_mode = _gdk_rendering_mode;
display->composited = TRUE;
@ -439,7 +435,6 @@ gdk_display_finalize (GObject *object)
g_hash_table_destroy (display->motion_hint_info);
g_hash_table_destroy (display->pointers_info);
g_hash_table_destroy (display->multiple_click_info);
g_list_free_full (display->input_devices, g_object_unref);
g_list_free_full (display->seats, g_object_unref);

View File

@ -86,16 +86,6 @@ typedef struct
guint need_touch_press_enter : 1;
} GdkPointerWindowInfo;
typedef struct
{
guint32 button_click_time[2]; /* last 2 button click times */
GdkWindow *button_window[2]; /* last 2 windows to receive button presses */
gint button_number[2]; /* last 2 buttons to be pressed */
gint button_x[2]; /* last 2 button click positions */
gint button_y[2];
GdkDevice *last_slave;
} GdkMultipleClickInfo;
struct _GdkDisplay
{
GObject parent_instance;
@ -103,11 +93,6 @@ struct _GdkDisplay
GList *queued_events;
GList *queued_tail;
/* Information for determining if the latest button click
* is part of a double-click or triple-click
*/
GHashTable *multiple_click_info;
guint event_pause_count; /* How many times events are blocked */
guint closed : 1; /* Whether this display has been closed */

View File

@ -529,8 +529,6 @@ gdk_event_new (GdkEventType type)
new_event->motion.y_root = 0.;
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
new_event->button.x = 0.;
new_event->button.y = 0.;
@ -701,8 +699,6 @@ gdk_event_copy (const GdkEvent *event)
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
if (event->button.axes)
new_event->button.axes = g_memdup (event->button.axes,
@ -796,8 +792,6 @@ gdk_event_free (GdkEvent *event)
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
g_free (event->button.axes);
break;
@ -886,8 +880,6 @@ gdk_event_get_time (const GdkEvent *event)
case GDK_MOTION_NOTIFY:
return event->motion.time;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
return event->button.time;
case GDK_TOUCH_BEGIN:
@ -979,8 +971,6 @@ gdk_event_get_state (const GdkEvent *event,
*state = event->motion.state;
return TRUE;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
*state = event->button.state;
return TRUE;
@ -1084,8 +1074,6 @@ gdk_event_get_coords (const GdkEvent *event,
y = event->scroll.y;
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
x = event->button.x;
y = event->button.y;
@ -1153,8 +1141,6 @@ gdk_event_get_root_coords (const GdkEvent *event,
y = event->scroll.y_root;
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
x = event->button.x_root;
y = event->button.y_root;
@ -1224,8 +1210,6 @@ gdk_event_set_coords (GdkEvent *event,
event->scroll.y = y;
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
event->button.x = x;
event->button.y = y;
@ -1277,8 +1261,6 @@ gdk_event_get_button (const GdkEvent *event,
switch (event->type)
{
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
number = event->button.button;
break;
@ -1323,12 +1305,6 @@ gdk_event_get_click_count (const GdkEvent *event,
case GDK_BUTTON_RELEASE:
number = 1;
break;
case GDK_2BUTTON_PRESS:
number = 2;
break;
case GDK_3BUTTON_PRESS:
number = 3;
break;
default:
fetched = FALSE;
break;
@ -1707,8 +1683,6 @@ gdk_event_set_device (GdkEvent *event,
event->motion.device = device;
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
event->button.device = device;
break;
@ -1759,8 +1733,6 @@ gdk_event_get_device (const GdkEvent *event)
case GDK_MOTION_NOTIFY:
return event->motion.device;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
return event->button.device;
case GDK_TOUCH_BEGIN:
@ -1782,8 +1754,6 @@ gdk_event_get_device (const GdkEvent *event)
{
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
case GDK_TOUCH_BEGIN:
case GDK_TOUCH_UPDATE:
@ -2226,96 +2196,6 @@ gdk_get_show_events (void)
return (_gdk_debug_flags & GDK_DEBUG_EVENTS) != 0;
}
static void
gdk_synthesize_click (GdkDisplay *display,
GdkEvent *event,
gint nclicks)
{
GdkEvent *event_copy;
event_copy = gdk_event_copy (event);
event_copy->type = (nclicks == 2) ? GDK_2BUTTON_PRESS : GDK_3BUTTON_PRESS;
_gdk_event_queue_append (display, event_copy);
}
void
_gdk_event_button_generate (GdkDisplay *display,
GdkEvent *event)
{
GdkMultipleClickInfo *info;
GdkDevice *source_device;
g_return_if_fail (event->type == GDK_BUTTON_PRESS);
source_device = gdk_event_get_source_device (event);
info = g_hash_table_lookup (display->multiple_click_info, event->button.device);
if (G_UNLIKELY (!info))
{
info = g_new0 (GdkMultipleClickInfo, 1);
info->button_number[0] = info->button_number[1] = -1;
g_hash_table_insert (display->multiple_click_info,
event->button.device, info);
}
if ((event->button.time < (info->button_click_time[1] + 2 * display->double_click_time)) &&
(event->button.window == info->button_window[1]) &&
(event->button.button == info->button_number[1]) &&
(source_device == info->last_slave) &&
(ABS (event->button.x - info->button_x[1]) <= display->double_click_distance) &&
(ABS (event->button.y - info->button_y[1]) <= display->double_click_distance))
{
gdk_synthesize_click (display, event, 3);
info->button_click_time[1] = 0;
info->button_click_time[0] = 0;
info->button_window[1] = NULL;
info->button_window[0] = NULL;
info->button_number[1] = -1;
info->button_number[0] = -1;
info->button_x[0] = info->button_x[1] = 0;
info->button_y[0] = info->button_y[1] = 0;
info->last_slave = NULL;
}
else if ((event->button.time < (info->button_click_time[0] + display->double_click_time)) &&
(event->button.window == info->button_window[0]) &&
(event->button.button == info->button_number[0]) &&
(source_device == info->last_slave) &&
(ABS (event->button.x - info->button_x[0]) <= display->double_click_distance) &&
(ABS (event->button.y - info->button_y[0]) <= display->double_click_distance))
{
gdk_synthesize_click (display, event, 2);
info->button_click_time[1] = info->button_click_time[0];
info->button_click_time[0] = event->button.time;
info->button_window[1] = info->button_window[0];
info->button_window[0] = event->button.window;
info->button_number[1] = info->button_number[0];
info->button_number[0] = event->button.button;
info->button_x[1] = info->button_x[0];
info->button_x[0] = event->button.x;
info->button_y[1] = info->button_y[0];
info->button_y[0] = event->button.y;
info->last_slave = source_device;
}
else
{
info->button_click_time[1] = 0;
info->button_click_time[0] = event->button.time;
info->button_window[1] = NULL;
info->button_window[0] = event->button.window;
info->button_number[1] = -1;
info->button_number[0] = event->button.button;
info->button_x[1] = 0;
info->button_x[0] = event->button.x;
info->button_y[1] = 0;
info->button_y[0] = event->button.y;
info->last_slave = source_device;
}
}
static GList *
gdk_get_pending_window_state_event_link (GdkWindow *window)
{
@ -2413,8 +2293,7 @@ gdk_synthesize_window_state (GdkWindow *window,
* @msec: double click time in milliseconds (thousandths of a second)
*
* 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
* count as a double click). Applications should not set this, it is a global
* user-configured setting.
*
* Since: 2.2
@ -2448,8 +2327,7 @@ gdk_set_double_click_time (guint msec)
* @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().
* count as a double click). See also gdk_display_set_double_click_time().
* Applications should not set this, it is a global
* user-configured setting.
*

View File

@ -223,13 +223,6 @@ typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
* redrawn.
* @GDK_MOTION_NOTIFY: the pointer (usually a mouse) has moved.
* @GDK_BUTTON_PRESS: a mouse button has been pressed.
* @GDK_2BUTTON_PRESS: a mouse button has been double-clicked (clicked twice
* within a short period of time). Note that each click also generates a
* %GDK_BUTTON_PRESS event.
* @GDK_DOUBLE_BUTTON_PRESS: alias for %GDK_2BUTTON_PRESS, added in 3.6.
* @GDK_3BUTTON_PRESS: a mouse button has been clicked 3 times in a short period
* of time. Note that each click also generates a %GDK_BUTTON_PRESS event.
* @GDK_TRIPLE_BUTTON_PRESS: alias for %GDK_3BUTTON_PRESS, added in 3.6.
* @GDK_BUTTON_RELEASE: a mouse button has been released.
* @GDK_KEY_PRESS: a key has been pressed.
* @GDK_KEY_RELEASE: a key has been released.
@ -297,13 +290,6 @@ typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
* Do not confuse these events with the signals that GTK+ widgets emit.
* Although many of these events result in corresponding signals being emitted,
* the events are often transformed or filtered along the way.
*
* In some language bindings, the values %GDK_2BUTTON_PRESS and
* %GDK_3BUTTON_PRESS would translate into something syntactically
* invalid (eg `Gdk.EventType.2ButtonPress`, where a
* symbol is not allowed to start with a number). In that case, the
* aliases %GDK_DOUBLE_BUTTON_PRESS and %GDK_TRIPLE_BUTTON_PRESS can
* be used instead.
*/
typedef enum
{
@ -313,10 +299,6 @@ typedef enum
GDK_EXPOSE = 2,
GDK_MOTION_NOTIFY = 3,
GDK_BUTTON_PRESS = 4,
GDK_2BUTTON_PRESS = 5,
GDK_DOUBLE_BUTTON_PRESS = GDK_2BUTTON_PRESS,
GDK_3BUTTON_PRESS = 6,
GDK_TRIPLE_BUTTON_PRESS = GDK_3BUTTON_PRESS,
GDK_BUTTON_RELEASE = 7,
GDK_KEY_PRESS = 8,
GDK_KEY_RELEASE = 9,

View File

@ -136,8 +136,7 @@ struct _GdkEventMotion
/**
* GdkEventButton:
* @type: the type of the event (%GDK_BUTTON_PRESS, %GDK_2BUTTON_PRESS,
* %GDK_3BUTTON_PRESS or %GDK_BUTTON_RELEASE).
* @type: the type of the event (%GDK_BUTTON_PRESS or %GDK_BUTTON_RELEASE).
* @window: the window which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @time: the time of the event in milliseconds.
@ -160,38 +159,7 @@ struct _GdkEventMotion
* screen.
*
* Used for button press and button release events. The
* @type field will be one of %GDK_BUTTON_PRESS,
* %GDK_2BUTTON_PRESS, %GDK_3BUTTON_PRESS or %GDK_BUTTON_RELEASE,
*
* Double and triple-clicks result in a sequence of events being received.
* For double-clicks the order of events will be:
*
* - %GDK_BUTTON_PRESS
* - %GDK_BUTTON_RELEASE
* - %GDK_BUTTON_PRESS
* - %GDK_2BUTTON_PRESS
* - %GDK_BUTTON_RELEASE
*
* Note that the first click is received just like a normal
* button press, while the second click results in a %GDK_2BUTTON_PRESS
* being received just after the %GDK_BUTTON_PRESS.
*
* Triple-clicks are very similar to double-clicks, except that
* %GDK_3BUTTON_PRESS is inserted after the third click. The order of the
* events is:
*
* - %GDK_BUTTON_PRESS
* - %GDK_BUTTON_RELEASE
* - %GDK_BUTTON_PRESS
* - %GDK_2BUTTON_PRESS
* - %GDK_BUTTON_RELEASE
* - %GDK_BUTTON_PRESS
* - %GDK_3BUTTON_PRESS
* - %GDK_BUTTON_RELEASE
*
* For a double click to occur, the second button press must occur within
* 1/4 of a second of the first. For a triple click to occur, the third
* button press must also occur within 1/2 second of the first button press.
* @type field will be one of %GDK_BUTTON_PRESS or %GDK_BUTTON_RELEASE,
*/
struct _GdkEventButton
{

View File

@ -5734,8 +5734,6 @@ _gdk_make_event (GdkWindow *window,
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
event->button.time = the_time;
event->button.axes = NULL;

View File

@ -651,8 +651,6 @@ _gdk_win32_print_event (const GdkEvent *event)
CASE (GDK_EXPOSE);
CASE (GDK_MOTION_NOTIFY);
CASE (GDK_BUTTON_PRESS);
CASE (GDK_2BUTTON_PRESS);
CASE (GDK_3BUTTON_PRESS);
CASE (GDK_BUTTON_RELEASE);
CASE (GDK_KEY_PRESS);
CASE (GDK_KEY_RELEASE);
@ -704,8 +702,6 @@ _gdk_win32_print_event (const GdkEvent *event)
print_event_state (event->motion.state);
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
g_print ("%d (%.4g,%.4g) (%.4g,%.4g) ",
event->button.button,

View File

@ -303,23 +303,6 @@ gtk_cell_renderer_spin_key_press_event (GtkWidget *widget,
return FALSE;
}
static gboolean
gtk_cell_renderer_spin_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
{
GdkEventType event_type = gdk_event_get_event_type ((GdkEvent *) event);
/* Block 2BUTTON and 3BUTTON here, so that they won't be eaten
* by tree view.
*/
if (event_type == GDK_2BUTTON_PRESS
|| event_type == GDK_3BUTTON_PRESS)
return TRUE;
return FALSE;
}
static GtkCellEditable *
gtk_cell_renderer_spin_start_editing (GtkCellRenderer *cell,
GdkEvent *event,
@ -348,10 +331,6 @@ gtk_cell_renderer_spin_start_editing (GtkCellRenderer *cell,
spin = gtk_spin_button_new (priv->adjustment,
priv->climb_rate, priv->digits);
g_signal_connect (spin, "button-press-event",
G_CALLBACK (gtk_cell_renderer_spin_button_press_event),
NULL);
g_object_get (cell_text, "text", &text, NULL);
if (text)
{

View File

@ -3545,8 +3545,6 @@ gtk_entry_event (GtkWidget *widget,
icon_info->current_sequence = sequence;
/* Fall through */
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
priv->start_x = x;
priv->start_y = y;
icon_info->pressed = TRUE;

View File

@ -1148,8 +1148,6 @@ rewrite_event_for_window (GdkEvent *event,
&event->scroll.x, &event->scroll.y);
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
rewrite_events_translate (event->any.window,
new_window,
@ -1217,8 +1215,6 @@ rewrite_event_for_grabs (GdkEvent *event)
{
case GDK_SCROLL:
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
case GDK_MOTION_NOTIFY:
case GDK_PROXIMITY_IN:
@ -1809,8 +1805,6 @@ gtk_main_do_event (GdkEvent *event)
/* else fall through */
case GDK_SCROLL:
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_TOUCH_BEGIN:
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_RELEASE:
@ -1852,8 +1846,6 @@ gtk_main_do_event (GdkEvent *event)
if (event->type == GDK_ENTER_NOTIFY
|| event->type == GDK_LEAVE_NOTIFY
|| event->type == GDK_BUTTON_PRESS
|| event->type == GDK_2BUTTON_PRESS
|| event->type == GDK_3BUTTON_PRESS
|| event->type == GDK_KEY_PRESS
|| event->type == GDK_DRAG_ENTER
|| event->type == GDK_GRAB_BROKEN

View File

@ -4943,8 +4943,6 @@ get_event_coordinates (GdkEvent *event, gint *x, gint *y)
{
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
gdk_event_get_coords (event, &event_x, &event_y);
*x = event_x;

View File

@ -1449,8 +1449,6 @@ gtk_tooltip_handle_event_internal (GdkEventType event_type,
switch (event_type)
{
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_KEY_PRESS:
case GDK_DRAG_ENTER:
case GDK_GRAB_BROKEN:

View File

@ -1056,8 +1056,6 @@ gtk_tree_view_column_button_event (GtkWidget *widget,
switch (event_type)
{
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_RELEASE:
case GDK_ENTER_NOTIFY:

View File

@ -6707,8 +6707,6 @@ event_window_is_still_viewable (const GdkEvent *event)
case GDK_EXPOSE:
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_KEY_PRESS:
case GDK_ENTER_NOTIFY:
case GDK_PROXIMITY_IN:
@ -6842,8 +6840,6 @@ gtk_widget_emit_event_signals (GtkWidget *widget,
signal_num = -1;
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
signal_num = BUTTON_PRESS_EVENT;
break;
case GDK_TOUCH_BEGIN: