forked from AuroraMiddleware/gtk
Merge branch 'readonly-events-1' into 'master'
Redo events See merge request GNOME/gtk!1443
This commit is contained in:
commit
77e1fd01c3
@ -99,14 +99,16 @@ day_selected_cb (GtkCalendar *calendar,
|
||||
GtkWidget *popover;
|
||||
GdkEvent *event;
|
||||
gdouble x, y;
|
||||
GtkWidget *widget;
|
||||
|
||||
event = gtk_get_current_event ();
|
||||
|
||||
if (gdk_event_get_event_type (event) != GDK_BUTTON_PRESS)
|
||||
return;
|
||||
|
||||
gdk_event_get_coords (event, &x, &y);
|
||||
gtk_widget_translate_coordinates (gtk_get_event_widget (event),
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
widget = gtk_native_get_for_surface (gdk_event_get_surface (event));
|
||||
gtk_widget_translate_coordinates (widget,
|
||||
GTK_WIDGET (calendar),
|
||||
x, y,
|
||||
&rect.x, &rect.y);
|
||||
@ -119,7 +121,7 @@ day_selected_cb (GtkCalendar *calendar,
|
||||
|
||||
gtk_widget_show (popover);
|
||||
|
||||
g_object_unref (event);
|
||||
gdk_event_unref (event);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@ -135,13 +135,13 @@ clicked (GtkGestureClick *gesture,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *window;
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
GdkModifierType state;
|
||||
|
||||
window = gtk_widget_get_ancestor (gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)), GTK_TYPE_WINDOW);
|
||||
|
||||
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), NULL);
|
||||
gdk_event_get_state (event, &state);
|
||||
state = gdk_event_get_modifier_state (event);
|
||||
|
||||
if (state & GDK_CONTROL_MASK)
|
||||
{
|
||||
|
@ -578,61 +578,54 @@ GDK_BUTTON_MIDDLE
|
||||
GDK_BUTTON_SECONDARY
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_event_new
|
||||
gdk_event_copy
|
||||
gdk_event_get_axes
|
||||
gdk_event_get_axis
|
||||
gdk_event_get_button
|
||||
gdk_event_get_click_count
|
||||
gdk_event_get_coords
|
||||
gdk_event_get_keycode
|
||||
gdk_event_get_keyval
|
||||
gdk_event_get_scroll_direction
|
||||
gdk_event_get_scroll_deltas
|
||||
gdk_event_is_scroll_stop_event
|
||||
gdk_event_get_state
|
||||
gdk_event_get_time
|
||||
gdk_event_get_surface
|
||||
gdk_event_ref
|
||||
gdk_event_unref
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_event_get_event_type
|
||||
gdk_event_get_surface
|
||||
gdk_event_get_device
|
||||
gdk_event_get_source_device
|
||||
gdk_event_get_device_tool
|
||||
gdk_event_get_time
|
||||
gdk_event_get_display
|
||||
GdkEventSequence
|
||||
gdk_event_get_event_sequence
|
||||
gdk_event_get_modifier_state
|
||||
gdk_event_get_position
|
||||
gdk_event_get_axes
|
||||
gdk_event_get_axis
|
||||
gdk_event_get_pointer_emulated
|
||||
gdk_button_event_get_button
|
||||
gdk_scroll_event_get_direction
|
||||
gdk_scroll_event_get_deltas
|
||||
gdk_scroll_event_is_stop
|
||||
gdk_key_event_get_keyval
|
||||
gdk_key_event_get_keycode
|
||||
gdk_key_event_get_scancode
|
||||
gdk_key_event_get_group
|
||||
gdk_key_event_is_modifier
|
||||
gdk_focus_event_get_in
|
||||
gdk_touch_event_get_emulating_pointer
|
||||
gdk_crossing_event_get_mode
|
||||
gdk_crossing_event_get_detail
|
||||
gdk_configure_event_get_size
|
||||
gdk_touchpad_event_get_gesture_phase
|
||||
gdk_touchpad_event_get_n_fingers
|
||||
gdk_touchpad_event_get_deltas
|
||||
gdk_touchpad_pinch_event_get_angle_delta
|
||||
gdk_touchpad_pinch_event_get_scale
|
||||
gdk_pad_button_event_get_button
|
||||
gdk_pad_axis_event_get_value
|
||||
gdk_pad_event_get_group_mode
|
||||
gdk_drag_event_get_drop
|
||||
gdk_grab_broken_event_get_grab_surface
|
||||
gdk_event_get_motion_history
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_events_get_angle
|
||||
gdk_events_get_center
|
||||
gdk_events_get_distance
|
||||
gdk_event_triggers_context_menu
|
||||
gdk_event_get_seat
|
||||
gdk_event_get_scancode
|
||||
gdk_event_get_pointer_emulated
|
||||
gdk_event_get_crossing_detail
|
||||
gdk_event_get_crossing_mode
|
||||
gdk_event_get_drop
|
||||
gdk_event_get_focus_in
|
||||
gdk_event_get_grab_surface
|
||||
gdk_event_get_motion_history
|
||||
gdk_event_get_key_group
|
||||
gdk_event_get_key_is_modifier
|
||||
gdk_event_get_pad_axis_value
|
||||
gdk_event_get_pad_button
|
||||
gdk_event_get_pad_group_mode
|
||||
gdk_event_get_touch_emulating_pointer
|
||||
gdk_event_get_touchpad_angle_delta
|
||||
gdk_event_get_touchpad_deltas
|
||||
gdk_event_get_touchpad_gesture_n_fingers
|
||||
gdk_event_get_touchpad_gesture_phase
|
||||
gdk_event_get_touchpad_scale
|
||||
gdk_event_is_sent
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_get_show_events
|
||||
gdk_set_show_events
|
||||
gdk_event_set_display
|
||||
gdk_event_get_display
|
||||
gdk_event_get_device
|
||||
gdk_event_set_device
|
||||
gdk_event_get_source_device
|
||||
gdk_event_set_source_device
|
||||
gdk_event_get_device_tool
|
||||
gdk_event_set_device_tool
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_TYPE_EVENT
|
||||
|
@ -321,6 +321,7 @@
|
||||
<title>Gestures and event handling</title>
|
||||
<xi:include href="xml/gtkeventcontroller.xml" />
|
||||
<xi:include href="xml/gtkeventcontrollerkey.xml" />
|
||||
<xi:include href="xml/gtkeventcontrollerfocus.xml" />
|
||||
<xi:include href="xml/gtkeventcontrollerlegacy.xml" />
|
||||
<xi:include href="xml/gtkeventcontrollerscroll.xml" />
|
||||
<xi:include href="xml/gtkeventcontrollermotion.xml" />
|
||||
|
@ -4435,9 +4435,6 @@ gtk_get_current_event
|
||||
gtk_get_current_event_time
|
||||
gtk_get_current_event_state
|
||||
gtk_get_current_event_device
|
||||
gtk_get_event_widget
|
||||
gtk_get_event_target
|
||||
gtk_get_event_target_with_type
|
||||
|
||||
<SUBSECTION Private>
|
||||
gtk_init_abi_check
|
||||
@ -6144,8 +6141,6 @@ gtk_event_controller_scroll_get_type
|
||||
<TITLE>GtkEventControllerMotion</TITLE>
|
||||
GtkEventControllerMotion
|
||||
gtk_event_controller_motion_new
|
||||
gtk_event_controller_motion_get_pointer_origin
|
||||
gtk_event_controller_motion_get_pointer_target
|
||||
gtk_event_controller_motion_contains_pointer
|
||||
gtk_event_controller_motion_is_pointer
|
||||
|
||||
@ -6170,10 +6165,6 @@ gtk_event_controller_key_set_im_context
|
||||
gtk_event_controller_key_get_im_context
|
||||
gtk_event_controller_key_forward
|
||||
gtk_event_controller_key_get_group
|
||||
gtk_event_controller_key_get_focus_origin
|
||||
gtk_event_controller_key_get_focus_target
|
||||
gtk_event_controller_key_contains_focus
|
||||
gtk_event_controller_key_is_focus
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_EVENT_CONTROLLER_KEY
|
||||
@ -6187,6 +6178,28 @@ GTK_EVENT_CONTROLLER_KEY_GET_CLASS
|
||||
gtk_event_controller_key_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkeventcontrollerfocus</FILE>
|
||||
<TITLE>GtkEventControllerFocus</TITLE>
|
||||
GtkEventControllerFocus
|
||||
gtk_event_controller_focus_new
|
||||
gtk_event_controller_focus_get_focus_origin
|
||||
gtk_event_controller_focus_get_focus_target
|
||||
gtk_event_controller_focus_contains_focus
|
||||
gtk_event_controller_focus_is_focus
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_EVENT_CONTROLLER_FOCUS
|
||||
GTK_EVENT_CONTROLLER_FOCUS
|
||||
GTK_EVENT_CONTROLLER_FOCUS_CLASS
|
||||
GTK_IS_EVENT_CONTROLL_FOCUS
|
||||
GTK_IS_EVENT_CONTROLLER_FOCUS_CLASS
|
||||
GTK_EVENT_CONTROLLER_FOCUS_GET_CLASS
|
||||
|
||||
<SUBSECTION Private>
|
||||
gtk_event_controller_focus_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkgesturedrag</FILE>
|
||||
<TITLE>GtkGestureDrag</TITLE>
|
||||
|
@ -68,6 +68,7 @@ gtk_entry_completion_get_type
|
||||
gtk_entry_get_type
|
||||
gtk_event_controller_get_type
|
||||
gtk_event_controller_key_get_type
|
||||
gtk_event_controller_focus_get_type
|
||||
gtk_event_controller_legacy_get_type
|
||||
gtk_event_controller_motion_get_type
|
||||
gtk_event_controller_scroll_get_type
|
||||
|
@ -100,17 +100,16 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
|
||||
if (surface)
|
||||
{
|
||||
event = gdk_event_new (GDK_ENTER_NOTIFY);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->crossing.time = message->base.time;
|
||||
event->crossing.x = message->pointer.win_x;
|
||||
event->crossing.y = message->pointer.win_y;
|
||||
event->crossing.x_root = message->pointer.root_x;
|
||||
event->crossing.y_root = message->pointer.root_y;
|
||||
event->crossing.state = message->pointer.state;
|
||||
event->crossing.mode = message->crossing.mode;
|
||||
event->crossing.detail = GDK_NOTIFY_ANCESTOR;
|
||||
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
||||
event = gdk_event_crossing_new (GDK_ENTER_NOTIFY,
|
||||
surface,
|
||||
gdk_seat_get_pointer (seat),
|
||||
gdk_seat_get_pointer (seat),
|
||||
message->base.time,
|
||||
message->pointer.state,
|
||||
message->pointer.win_x,
|
||||
message->pointer.win_y,
|
||||
message->crossing.mode,
|
||||
GDK_NOTIFY_ANCESTOR);
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
||||
@ -120,17 +119,16 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
|
||||
if (surface)
|
||||
{
|
||||
event = gdk_event_new (GDK_LEAVE_NOTIFY);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->crossing.time = message->base.time;
|
||||
event->crossing.x = message->pointer.win_x;
|
||||
event->crossing.y = message->pointer.win_y;
|
||||
event->crossing.x_root = message->pointer.root_x;
|
||||
event->crossing.y_root = message->pointer.root_y;
|
||||
event->crossing.state = message->pointer.state;
|
||||
event->crossing.mode = message->crossing.mode;
|
||||
event->crossing.detail = GDK_NOTIFY_ANCESTOR;
|
||||
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
||||
event = gdk_event_crossing_new (GDK_LEAVE_NOTIFY,
|
||||
surface,
|
||||
gdk_seat_get_pointer (seat),
|
||||
gdk_seat_get_pointer (seat),
|
||||
message->base.time,
|
||||
message->pointer.state,
|
||||
message->pointer.win_x,
|
||||
message->pointer.win_y,
|
||||
message->crossing.mode,
|
||||
GDK_NOTIFY_ANCESTOR);
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
||||
@ -143,15 +141,15 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
|
||||
if (surface)
|
||||
{
|
||||
event = gdk_event_new (GDK_MOTION_NOTIFY);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->motion.time = message->base.time;
|
||||
event->motion.x = message->pointer.win_x;
|
||||
event->motion.y = message->pointer.win_y;
|
||||
event->motion.x_root = message->pointer.root_x;
|
||||
event->motion.y_root = message->pointer.root_y;
|
||||
event->motion.state = message->pointer.state;
|
||||
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
||||
event = gdk_event_motion_new (surface,
|
||||
gdk_seat_get_pointer (seat),
|
||||
gdk_seat_get_pointer (seat),
|
||||
NULL,
|
||||
message->base.time,
|
||||
message->pointer.state,
|
||||
message->pointer.win_x,
|
||||
message->pointer.win_y,
|
||||
NULL);
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
||||
@ -167,16 +165,19 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
|
||||
if (surface)
|
||||
{
|
||||
event = gdk_event_new (message->base.type == BROADWAY_EVENT_BUTTON_PRESS ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->button.time = message->base.time;
|
||||
event->button.x = message->pointer.win_x;
|
||||
event->button.y = message->pointer.win_y;
|
||||
event->button.x_root = message->pointer.root_x;
|
||||
event->button.y_root = message->pointer.root_y;
|
||||
event->button.button = message->button.button;
|
||||
event->button.state = message->pointer.state;
|
||||
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
||||
event = gdk_event_button_new (message->base.type == BROADWAY_EVENT_BUTTON_PRESS
|
||||
? GDK_BUTTON_PRESS
|
||||
: GDK_BUTTON_RELEASE,
|
||||
surface,
|
||||
gdk_seat_get_pointer (seat),
|
||||
gdk_seat_get_pointer (seat),
|
||||
NULL,
|
||||
message->base.time,
|
||||
message->pointer.state,
|
||||
message->button.button,
|
||||
message->pointer.win_x,
|
||||
message->pointer.win_y,
|
||||
NULL);
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
||||
@ -187,16 +188,17 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
|
||||
if (surface)
|
||||
{
|
||||
event = gdk_event_new (GDK_SCROLL);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->scroll.time = message->base.time;
|
||||
event->scroll.x = message->pointer.win_x;
|
||||
event->scroll.y = message->pointer.win_y;
|
||||
event->scroll.x_root = message->pointer.root_x;
|
||||
event->scroll.y_root = message->pointer.root_y;
|
||||
event->scroll.direction = message->scroll.dir == 0 ? GDK_SCROLL_UP : GDK_SCROLL_DOWN;
|
||||
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
||||
|
||||
event = gdk_event_discrete_scroll_new (surface,
|
||||
gdk_seat_get_pointer (seat),
|
||||
gdk_seat_get_pointer (seat),
|
||||
NULL,
|
||||
message->base.time,
|
||||
0,
|
||||
message->scroll.dir == 0
|
||||
? GDK_SCROLL_UP
|
||||
: GDK_SCROLL_DOWN,
|
||||
FALSE);
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
||||
}
|
||||
@ -207,6 +209,8 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
if (surface)
|
||||
{
|
||||
GdkEventType event_type = 0;
|
||||
GdkModifierType state;
|
||||
GdkDevice *source_device;
|
||||
|
||||
switch (message->touch.touch_type) {
|
||||
case 0:
|
||||
@ -226,30 +230,30 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
message->touch.is_emulated && _gdk_broadway_moveresize_handle_event (display, message))
|
||||
break;
|
||||
|
||||
event = gdk_event_new (event_type);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->touch.sequence = GUINT_TO_POINTER(message->touch.sequence_id);
|
||||
event->touch.emulating_pointer = message->touch.is_emulated;
|
||||
event->touch.time = message->base.time;
|
||||
event->touch.x = message->touch.win_x;
|
||||
event->touch.y = message->touch.win_y;
|
||||
event->touch.x_root = message->touch.root_x;
|
||||
event->touch.y_root = message->touch.root_y;
|
||||
event->touch.state = message->touch.state;
|
||||
|
||||
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
||||
source_device = gdk_seat_get_pointer (seat);
|
||||
{
|
||||
GList *devices;
|
||||
devices = gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_TOUCH);
|
||||
if (devices)
|
||||
gdk_event_set_source_device (event, GDK_DEVICE (devices->data));
|
||||
source_device = GDK_DEVICE (devices->data);
|
||||
g_list_free (devices);
|
||||
}
|
||||
if (message->touch.is_emulated)
|
||||
gdk_event_set_pointer_emulated (event, TRUE);
|
||||
|
||||
state = message->touch.state;
|
||||
if (event_type == GDK_TOUCH_BEGIN || event_type == GDK_TOUCH_UPDATE)
|
||||
event->touch.state |= GDK_BUTTON1_MASK;
|
||||
state |= GDK_BUTTON1_MASK;
|
||||
|
||||
event = gdk_event_touch_new (event_type,
|
||||
GUINT_TO_POINTER (message->touch.sequence_id),
|
||||
surface,
|
||||
gdk_seat_get_pointer (seat),
|
||||
source_device,
|
||||
message->base.time,
|
||||
state,
|
||||
message->touch.win_x,
|
||||
message->touch.win_y,
|
||||
NULL,
|
||||
message->touch.is_emulated);
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
||||
@ -262,14 +266,19 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
GINT_TO_POINTER (message->key.surface_id));
|
||||
if (surface)
|
||||
{
|
||||
event = gdk_event_new (message->base.type == BROADWAY_EVENT_KEY_PRESS ? GDK_KEY_PRESS : GDK_KEY_RELEASE);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->key.time = message->base.time;
|
||||
event->key.keyval = message->key.key;
|
||||
event->key.state = message->key.state;
|
||||
event->key.hardware_keycode = message->key.key;
|
||||
gdk_event_set_scancode (event, message->key.key);
|
||||
gdk_event_set_device (event, gdk_seat_get_keyboard (seat));
|
||||
event = gdk_event_key_new (message->base.type == BROADWAY_EVENT_KEY_PRESS
|
||||
? GDK_KEY_PRESS
|
||||
: GDK_KEY_RELEASE,
|
||||
surface,
|
||||
gdk_seat_get_keyboard (seat),
|
||||
gdk_seat_get_keyboard (seat),
|
||||
message->base.time,
|
||||
message->key.state,
|
||||
message->key.key,
|
||||
message->key.key,
|
||||
message->key.key,
|
||||
0,
|
||||
FALSE);
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
||||
@ -290,12 +299,9 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
|
||||
gdk_broadway_surface_update_popups (surface);
|
||||
|
||||
event = gdk_event_new (GDK_CONFIGURE);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->configure.x = message->configure_notify.x;
|
||||
event->configure.y = message->configure_notify.y;
|
||||
event->configure.width = message->configure_notify.width;
|
||||
event->configure.height = message->configure_notify.height;
|
||||
event = gdk_event_configure_new (surface,
|
||||
message->configure_notify.width,
|
||||
message->configure_notify.height);
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
||||
@ -324,20 +330,22 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->focus.old_id));
|
||||
if (surface)
|
||||
{
|
||||
event = gdk_event_new (GDK_FOCUS_CHANGE);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->focus_change.in = FALSE;
|
||||
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
||||
event = gdk_event_focus_new (surface,
|
||||
gdk_seat_get_keyboard (seat),
|
||||
gdk_seat_get_keyboard (seat),
|
||||
FALSE);
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
||||
}
|
||||
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->focus.new_id));
|
||||
if (surface)
|
||||
{
|
||||
event = gdk_event_new (GDK_FOCUS_CHANGE);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->focus_change.in = TRUE;
|
||||
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
|
||||
event = gdk_event_focus_new (surface,
|
||||
gdk_seat_get_keyboard (seat),
|
||||
gdk_seat_get_keyboard (seat),
|
||||
TRUE);
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
||||
}
|
||||
@ -368,7 +376,7 @@ gdk_event_source_dispatch (GSource *source,
|
||||
{
|
||||
_gdk_event_emit (event);
|
||||
|
||||
g_object_unref (event);
|
||||
gdk_event_unref (event);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -43,7 +43,7 @@
|
||||
* context = gdk_display_get_app_launch_context (display);
|
||||
*
|
||||
* gdk_app_launch_context_set_display (display);
|
||||
* gdk_app_launch_context_set_timestamp (event->time);
|
||||
* gdk_app_launch_context_set_timestamp (gdk_event_get_time (event));
|
||||
*
|
||||
* if (!g_app_info_launch_default_for_uri ("http://www.gtk.org", context, &error))
|
||||
* g_warning ("Launching failed: %s\n", error->message);
|
||||
|
@ -89,8 +89,6 @@ enum {
|
||||
|
||||
static void gdk_display_dispose (GObject *object);
|
||||
static void gdk_display_finalize (GObject *object);
|
||||
static void gdk_display_put_event_nocopy (GdkDisplay *display,
|
||||
GdkEvent *event);
|
||||
|
||||
|
||||
static GdkAppLaunchContext *gdk_display_real_get_app_launch_context (GdkDisplay *display);
|
||||
@ -135,7 +133,7 @@ gdk_display_real_opened (GdkDisplay *display)
|
||||
|
||||
static void
|
||||
gdk_display_real_event_data_copy (GdkDisplay *display,
|
||||
const GdkEvent *src,
|
||||
GdkEvent *src,
|
||||
GdkEvent *dst)
|
||||
{
|
||||
}
|
||||
@ -471,34 +469,27 @@ gdk_display_peek_event (GdkDisplay *display)
|
||||
tmp_list = _gdk_event_queue_find_first (display);
|
||||
|
||||
if (tmp_list != NULL)
|
||||
return g_object_ref (tmp_list->data);
|
||||
return gdk_event_ref (tmp_list->data);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_display_put_event_nocopy (GdkDisplay *display,
|
||||
GdkEvent *event)
|
||||
{
|
||||
_gdk_event_queue_append (display, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_display_put_event:
|
||||
* @display: a #GdkDisplay
|
||||
* @event: a #GdkEvent.
|
||||
* @event (transfer none): a #GdkEvent.
|
||||
*
|
||||
* Appends a copy of the given event onto the front of the event
|
||||
* Appends the given event onto the front of the event
|
||||
* queue for @display.
|
||||
**/
|
||||
void
|
||||
gdk_display_put_event (GdkDisplay *display,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
g_return_if_fail (event != NULL);
|
||||
|
||||
gdk_display_put_event_nocopy (display, gdk_event_copy (event));
|
||||
_gdk_event_queue_append (display, gdk_event_ref ((GdkEvent *)event));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -514,15 +505,13 @@ generate_grab_broken_event (GdkDisplay *display,
|
||||
{
|
||||
GdkEvent *event;
|
||||
|
||||
event = gdk_event_new (GDK_GRAB_BROKEN);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->any.send_event = FALSE;
|
||||
event->grab_broken.implicit = implicit;
|
||||
event->grab_broken.grab_surface = grab_surface;
|
||||
gdk_event_set_device (event, device);
|
||||
event->grab_broken.keyboard = (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD) ? TRUE : FALSE;
|
||||
event = gdk_event_grab_broken_new (surface,
|
||||
device,
|
||||
device,
|
||||
grab_surface,
|
||||
implicit);
|
||||
|
||||
gdk_display_put_event_nocopy (display, event);
|
||||
_gdk_event_queue_append (display, event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -699,7 +688,7 @@ switch_to_pointer_grab (GdkDisplay *display,
|
||||
|
||||
void
|
||||
_gdk_display_update_last_event (GdkDisplay *display,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
if (gdk_event_get_time (event) != GDK_CURRENT_TIME)
|
||||
display->last_event_time = gdk_event_get_time (event);
|
||||
@ -1301,7 +1290,7 @@ _gdk_display_unpause_events (GdkDisplay *display)
|
||||
|
||||
void
|
||||
_gdk_display_event_data_copy (GdkDisplay *display,
|
||||
const GdkEvent *event,
|
||||
GdkEvent *event,
|
||||
GdkEvent *new_event)
|
||||
{
|
||||
GDK_DISPLAY_GET_CLASS (display)->event_data_copy (display, event, new_event);
|
||||
|
@ -72,7 +72,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
GdkEvent* gdk_display_peek_event (GdkDisplay *display);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_display_put_event (GdkDisplay *display,
|
||||
const GdkEvent *event);
|
||||
GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_display_has_pending (GdkDisplay *display);
|
||||
|
||||
|
@ -136,7 +136,7 @@ struct _GdkDisplayClass
|
||||
const gchar * (*get_startup_notification_id) (GdkDisplay *display);
|
||||
|
||||
void (*event_data_copy) (GdkDisplay *display,
|
||||
const GdkEvent *event,
|
||||
GdkEvent *event,
|
||||
GdkEvent *new_event);
|
||||
void (*event_data_free) (GdkDisplay *display,
|
||||
GdkEvent *event);
|
||||
@ -191,7 +191,7 @@ typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay *display,
|
||||
gpointer user_data);
|
||||
|
||||
void _gdk_display_update_last_event (GdkDisplay *display,
|
||||
const GdkEvent *event);
|
||||
GdkEvent *event);
|
||||
void _gdk_display_device_grab_update (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
@ -227,7 +227,7 @@ gulong _gdk_display_get_next_serial (GdkDisplay *display
|
||||
void _gdk_display_pause_events (GdkDisplay *display);
|
||||
void _gdk_display_unpause_events (GdkDisplay *display);
|
||||
void _gdk_display_event_data_copy (GdkDisplay *display,
|
||||
const GdkEvent *event,
|
||||
GdkEvent *event,
|
||||
GdkEvent *new_event);
|
||||
void _gdk_display_event_data_free (GdkDisplay *display,
|
||||
GdkEvent *event);
|
||||
|
@ -49,7 +49,7 @@ struct _GdkDragClass {
|
||||
void (*dnd_finished) (GdkDrag *drag);
|
||||
|
||||
gboolean (*handle_event) (GdkDrag *drag,
|
||||
const GdkEvent *event);
|
||||
GdkEvent *event);
|
||||
};
|
||||
|
||||
struct _GdkDrag {
|
||||
|
@ -952,7 +952,7 @@ gdk_drop_do_emit_event (GdkEvent *event,
|
||||
if (dont_queue)
|
||||
{
|
||||
_gdk_event_emit (event);
|
||||
g_object_unref (event);
|
||||
gdk_event_unref (event);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -969,11 +969,12 @@ gdk_drop_emit_enter_event (GdkDrop *self,
|
||||
|
||||
g_warn_if_fail (!priv->entered);
|
||||
|
||||
event = gdk_event_new (GDK_DRAG_ENTER);
|
||||
event->any.surface = g_object_ref (priv->surface);
|
||||
event->dnd.drop = g_object_ref (self);
|
||||
event->dnd.time = time;
|
||||
gdk_event_set_device (event, priv->device);
|
||||
event = gdk_event_drag_new (GDK_DRAG_ENTER,
|
||||
priv->surface,
|
||||
priv->device,
|
||||
self,
|
||||
time,
|
||||
0, 0);
|
||||
|
||||
priv->entered = TRUE;
|
||||
|
||||
@ -983,27 +984,21 @@ gdk_drop_emit_enter_event (GdkDrop *self,
|
||||
void
|
||||
gdk_drop_emit_motion_event (GdkDrop *self,
|
||||
gboolean dont_queue,
|
||||
double x_root,
|
||||
double y_root,
|
||||
double x,
|
||||
double y,
|
||||
guint32 time)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
GdkEvent *event;
|
||||
int x, y;
|
||||
|
||||
g_warn_if_fail (priv->entered);
|
||||
|
||||
gdk_surface_get_origin (priv->surface, &x, &y);
|
||||
|
||||
event = gdk_event_new (GDK_DRAG_MOTION);
|
||||
event->any.surface = g_object_ref (priv->surface);
|
||||
event->dnd.drop = g_object_ref (self);
|
||||
event->dnd.time = time;
|
||||
event->dnd.x_root = x_root;
|
||||
event->dnd.y_root = y_root;
|
||||
event->dnd.x = x_root - x;
|
||||
event->dnd.y = y_root - y;
|
||||
gdk_event_set_device (event, priv->device);
|
||||
event = gdk_event_drag_new (GDK_DRAG_MOTION,
|
||||
priv->surface,
|
||||
priv->device,
|
||||
self,
|
||||
time,
|
||||
x, y);
|
||||
|
||||
gdk_drop_do_emit_event (event, dont_queue);
|
||||
}
|
||||
@ -1018,11 +1013,12 @@ gdk_drop_emit_leave_event (GdkDrop *self,
|
||||
|
||||
g_warn_if_fail (priv->entered);
|
||||
|
||||
event = gdk_event_new (GDK_DRAG_LEAVE);
|
||||
event->any.surface = g_object_ref (priv->surface);
|
||||
event->dnd.drop = g_object_ref (self);
|
||||
event->dnd.time = time;
|
||||
gdk_event_set_device (event, priv->device);
|
||||
event = gdk_event_drag_new (GDK_DRAG_LEAVE,
|
||||
priv->surface,
|
||||
priv->device,
|
||||
self,
|
||||
time,
|
||||
0, 0);
|
||||
|
||||
priv->entered = FALSE;
|
||||
|
||||
@ -1032,28 +1028,22 @@ gdk_drop_emit_leave_event (GdkDrop *self,
|
||||
void
|
||||
gdk_drop_emit_drop_event (GdkDrop *self,
|
||||
gboolean dont_queue,
|
||||
double x_root,
|
||||
double y_root,
|
||||
double x,
|
||||
double y,
|
||||
guint32 time)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
GdkEvent *event;
|
||||
int x, y;
|
||||
|
||||
g_warn_if_fail (priv->entered);
|
||||
g_warn_if_fail (priv->state == GDK_DROP_STATE_NONE);
|
||||
|
||||
gdk_surface_get_origin (priv->surface, &x, &y);
|
||||
|
||||
event = gdk_event_new (GDK_DROP_START);
|
||||
event->any.surface = g_object_ref (priv->surface);
|
||||
event->dnd.drop = g_object_ref (self);
|
||||
event->dnd.time = time;
|
||||
event->dnd.x_root = x_root;
|
||||
event->dnd.y_root = y_root;
|
||||
event->dnd.x = x_root - x;
|
||||
event->dnd.y = y_root - y;
|
||||
gdk_event_set_device (event, priv->device);
|
||||
event = gdk_event_drag_new (GDK_DROP_START,
|
||||
priv->surface,
|
||||
priv->device,
|
||||
self,
|
||||
time,
|
||||
x, y);
|
||||
|
||||
priv->state = GDK_DROP_STATE_DROPPING;
|
||||
|
||||
|
@ -64,16 +64,16 @@ void gdk_drop_emit_enter_event (GdkDrop
|
||||
guint32 time);
|
||||
void gdk_drop_emit_motion_event (GdkDrop *self,
|
||||
gboolean dont_queue,
|
||||
double x_root,
|
||||
double y_root,
|
||||
double x,
|
||||
double y,
|
||||
guint32 time);
|
||||
void gdk_drop_emit_leave_event (GdkDrop *self,
|
||||
gboolean dont_queue,
|
||||
guint32 time);
|
||||
void gdk_drop_emit_drop_event (GdkDrop *self,
|
||||
gboolean dont_queue,
|
||||
double x_root,
|
||||
double y_root,
|
||||
double x,
|
||||
double y,
|
||||
guint32 time);
|
||||
|
||||
G_END_DECLS
|
||||
|
3040
gdk/gdkevents.c
3040
gdk/gdkevents.c
File diff suppressed because it is too large
Load Diff
310
gdk/gdkevents.h
310
gdk/gdkevents.h
@ -41,9 +41,6 @@ G_BEGIN_DECLS
|
||||
#define GDK_TYPE_EVENT (gdk_event_get_type ())
|
||||
#define GDK_TYPE_EVENT_SEQUENCE (gdk_event_sequence_get_type ())
|
||||
|
||||
#define GDK_EVENT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_EVENT, GdkEvent))
|
||||
#define GDK_IS_EVENT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_EVENT))
|
||||
|
||||
|
||||
/**
|
||||
* GDK_PRIORITY_EVENTS:
|
||||
@ -102,36 +99,14 @@ G_BEGIN_DECLS
|
||||
#define GDK_BUTTON_SECONDARY (3)
|
||||
|
||||
|
||||
|
||||
typedef struct _GdkEventAny GdkEventAny;
|
||||
typedef struct _GdkEventMotion GdkEventMotion;
|
||||
typedef struct _GdkEventButton GdkEventButton;
|
||||
typedef struct _GdkEventTouch GdkEventTouch;
|
||||
typedef struct _GdkEventScroll GdkEventScroll;
|
||||
typedef struct _GdkEventKey GdkEventKey;
|
||||
typedef struct _GdkEventFocus GdkEventFocus;
|
||||
typedef struct _GdkEventCrossing GdkEventCrossing;
|
||||
typedef struct _GdkEventConfigure GdkEventConfigure;
|
||||
typedef struct _GdkEventProximity GdkEventProximity;
|
||||
typedef struct _GdkEventDND GdkEventDND;
|
||||
typedef struct _GdkEventSetting GdkEventSetting;
|
||||
typedef struct _GdkEventGrabBroken GdkEventGrabBroken;
|
||||
typedef struct _GdkEventTouchpadSwipe GdkEventTouchpadSwipe;
|
||||
typedef struct _GdkEventTouchpadPinch GdkEventTouchpadPinch;
|
||||
typedef struct _GdkEventPadButton GdkEventPadButton;
|
||||
typedef struct _GdkEventPadAxis GdkEventPadAxis;
|
||||
typedef struct _GdkEventPadGroupMode GdkEventPadGroupMode;
|
||||
|
||||
typedef struct _GdkEventSequence GdkEventSequence;
|
||||
typedef union _GdkEvent GdkEvent;
|
||||
|
||||
/**
|
||||
* GdkEventType:
|
||||
* @GDK_NOTHING: a special code to indicate a null event.
|
||||
* @GDK_DELETE: the window manager has requested that the toplevel surface be
|
||||
* hidden or destroyed, usually when the user clicks on a special icon in the
|
||||
* title bar.
|
||||
* @GDK_DESTROY: the surface has been destroyed.
|
||||
* @GDK_MOTION_NOTIFY: the pointer (usually a mouse) has moved.
|
||||
* @GDK_BUTTON_PRESS: a mouse button has been pressed.
|
||||
* @GDK_BUTTON_RELEASE: a mouse button has been released.
|
||||
@ -140,7 +115,7 @@ typedef union _GdkEvent GdkEvent;
|
||||
* @GDK_ENTER_NOTIFY: the pointer has entered the surface.
|
||||
* @GDK_LEAVE_NOTIFY: the pointer has left the surface.
|
||||
* @GDK_FOCUS_CHANGE: the keyboard focus has entered or left the surface.
|
||||
* @GDK_CONFIGURE: the size, position or stacking order of the surface has changed.
|
||||
* @GDK_CONFIGURE: the size of the surface has changed.
|
||||
* @GDK_PROXIMITY_IN: an input device has moved into contact with a sensing
|
||||
* surface (e.g. a touchscreen or graphics tablet).
|
||||
* @GDK_PROXIMITY_OUT: an input device has moved out of contact with a sensing
|
||||
@ -151,43 +126,27 @@ typedef union _GdkEvent GdkEvent;
|
||||
* progress.
|
||||
* @GDK_DROP_START: a drop operation onto the surface has started.
|
||||
* @GDK_SCROLL: the scroll wheel was turned
|
||||
* @GDK_GRAB_BROKEN: a pointer or keyboard grab was broken. This event type
|
||||
* was added in 2.8.
|
||||
* @GDK_TOUCH_BEGIN: A new touch event sequence has just started. This event
|
||||
* type was added in 3.4.
|
||||
* @GDK_TOUCH_UPDATE: A touch event sequence has been updated. This event type
|
||||
* was added in 3.4.
|
||||
* @GDK_TOUCH_END: A touch event sequence has finished. This event type
|
||||
* was added in 3.4.
|
||||
* @GDK_TOUCH_CANCEL: A touch event sequence has been canceled. This event type
|
||||
* was added in 3.4.
|
||||
* @GDK_GRAB_BROKEN: a pointer or keyboard grab was broken.
|
||||
* @GDK_TOUCH_BEGIN: A new touch event sequence has just started.
|
||||
* @GDK_TOUCH_UPDATE: A touch event sequence has been updated.
|
||||
* @GDK_TOUCH_END: A touch event sequence has finished.
|
||||
* @GDK_TOUCH_CANCEL: A touch event sequence has been canceled.
|
||||
* @GDK_TOUCHPAD_SWIPE: A touchpad swipe gesture event, the current state
|
||||
* is determined by its phase field. This event type was added in 3.18.
|
||||
* is determined by its phase field.
|
||||
* @GDK_TOUCHPAD_PINCH: A touchpad pinch gesture event, the current state
|
||||
* is determined by its phase field. This event type was added in 3.18.
|
||||
* @GDK_PAD_BUTTON_PRESS: A tablet pad button press event. This event type
|
||||
* was added in 3.22.
|
||||
* @GDK_PAD_BUTTON_RELEASE: A tablet pad button release event. This event type
|
||||
* was added in 3.22.
|
||||
* @GDK_PAD_RING: A tablet pad axis event from a "ring". This event type was
|
||||
* added in 3.22.
|
||||
* @GDK_PAD_STRIP: A tablet pad axis event from a "strip". This event type was
|
||||
* added in 3.22.
|
||||
* @GDK_PAD_GROUP_MODE: A tablet pad group mode change. This event type was
|
||||
* added in 3.22.
|
||||
* @GDK_EVENT_LAST: marks the end of the GdkEventType enumeration. Added in 2.18
|
||||
* is determined by its phase field.
|
||||
* @GDK_PAD_BUTTON_PRESS: A tablet pad button press event.
|
||||
* @GDK_PAD_BUTTON_RELEASE: A tablet pad button release event.
|
||||
* @GDK_PAD_RING: A tablet pad axis event from a "ring".
|
||||
* @GDK_PAD_STRIP: A tablet pad axis event from a "strip".
|
||||
* @GDK_PAD_GROUP_MODE: A tablet pad group mode change.
|
||||
* @GDK_EVENT_LAST: marks the end of the GdkEventType enumeration.
|
||||
*
|
||||
* Specifies the type of the event.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_NOTHING,
|
||||
GDK_DELETE,
|
||||
GDK_DESTROY,
|
||||
GDK_MOTION_NOTIFY,
|
||||
GDK_BUTTON_PRESS,
|
||||
GDK_BUTTON_RELEASE,
|
||||
@ -337,186 +296,137 @@ typedef enum
|
||||
} GdkCrossingMode;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_event_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_event_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_event_sequence_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_event_sequence_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkEvent* gdk_event_new (GdkEventType type);
|
||||
GdkEvent * gdk_event_ref (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkEvent* gdk_event_copy (const GdkEvent *event);
|
||||
void gdk_event_unref (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface *gdk_event_get_surface (const GdkEvent *event);
|
||||
GdkEventType gdk_event_get_event_type (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint32 gdk_event_get_time (const GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_state (const GdkEvent *event,
|
||||
GdkModifierType *state);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_coords (const GdkEvent *event,
|
||||
gdouble *x_win,
|
||||
gdouble *y_win);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_event_set_coords (GdkEvent *event,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_button (const GdkEvent *event,
|
||||
guint *button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_click_count (const GdkEvent *event,
|
||||
guint *click_count);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_keyval (const GdkEvent *event,
|
||||
guint *keyval);
|
||||
GdkSurface * gdk_event_get_surface (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_event_set_keyval (GdkEvent *event,
|
||||
guint keyval);
|
||||
GdkDevice * gdk_event_get_device (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_keycode (const GdkEvent *event,
|
||||
guint16 *keycode);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_key_is_modifier (const GdkEvent *event,
|
||||
gboolean *is_modifier);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_key_group (const GdkEvent *event,
|
||||
guint *group);
|
||||
GdkDevice * gdk_event_get_source_device (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_scroll_direction (const GdkEvent *event,
|
||||
GdkScrollDirection *direction);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_scroll_deltas (const GdkEvent *event,
|
||||
gdouble *delta_x,
|
||||
gdouble *delta_y);
|
||||
GdkDeviceTool * gdk_event_get_device_tool (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_is_scroll_stop_event (const GdkEvent *event);
|
||||
guint32 gdk_event_get_time (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_axis (const GdkEvent *event,
|
||||
GdkAxisUse axis_use,
|
||||
gdouble *value);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_event_set_device (GdkEvent *event,
|
||||
GdkDevice *device);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDevice* gdk_event_get_device (const GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_event_set_source_device (GdkEvent *event,
|
||||
GdkDevice *device);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDevice* gdk_event_get_source_device (const GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_triggers_context_menu (const GdkEvent *event);
|
||||
GdkDisplay * gdk_event_get_display (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_events_get_distance (GdkEvent *event1,
|
||||
GdkEvent *event2,
|
||||
gdouble *distance);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_events_get_angle (GdkEvent *event1,
|
||||
GdkEvent *event2,
|
||||
gdouble *angle);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_events_get_center (GdkEvent *event1,
|
||||
GdkEvent *event2,
|
||||
gdouble *x,
|
||||
gdouble *y);
|
||||
GdkEventSequence * gdk_event_get_event_sequence (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_event_set_display (GdkEvent *event,
|
||||
GdkDisplay *display);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDisplay *gdk_event_get_display (const GdkEvent *event);
|
||||
GdkModifierType gdk_event_get_modifier_state (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkEventSequence *gdk_event_get_event_sequence (const GdkEvent *event);
|
||||
gboolean gdk_event_get_position (GdkEvent *event,
|
||||
double *x,
|
||||
double *y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_axes (GdkEvent *event,
|
||||
double **axes,
|
||||
guint *n_axes);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_axis (GdkEvent *event,
|
||||
GdkAxisUse axis_use,
|
||||
double *value);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_pointer_emulated (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkEventType gdk_event_get_event_type (const GdkEvent *event);
|
||||
guint gdk_button_event_get_button (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkScrollDirection gdk_scroll_event_get_direction (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_scroll_event_get_deltas (GdkEvent *event,
|
||||
double *delta_x,
|
||||
double *delta_y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_scroll_event_is_stop (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gdk_key_event_get_keyval (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gdk_key_event_get_keycode (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gdk_key_event_get_scancode (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gdk_key_event_get_group (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_key_event_is_modifier (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_focus_event_get_in (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_touch_event_get_emulating_pointer (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkCrossingMode gdk_crossing_event_get_mode (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkNotifyType gdk_crossing_event_get_detail (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_configure_event_get_size (GdkEvent *event,
|
||||
int *width,
|
||||
int *height);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkTouchpadGesturePhase
|
||||
gdk_touchpad_event_get_gesture_phase (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gdk_touchpad_event_get_n_fingers (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_touchpad_event_get_deltas (GdkEvent *event,
|
||||
double *dx,
|
||||
double *dy);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
double gdk_touchpad_pinch_event_get_angle_delta (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
double gdk_touchpad_pinch_event_get_scale (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gdk_pad_button_event_get_button (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_pad_axis_event_get_value (GdkEvent *event,
|
||||
guint *index,
|
||||
double *value);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_pad_event_get_group_mode (GdkEvent *event,
|
||||
guint *group,
|
||||
guint *mode);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDrop * gdk_drag_event_get_drop (GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface * gdk_grab_broken_event_get_grab_surface (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSeat *gdk_event_get_seat (const GdkEvent *event);
|
||||
GList * gdk_event_get_motion_history (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_set_show_events (gboolean show_events);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_get_show_events (void);
|
||||
gboolean gdk_event_triggers_context_menu (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDeviceTool *gdk_event_get_device_tool (const GdkEvent *event);
|
||||
|
||||
gboolean gdk_events_get_distance (GdkEvent *event1,
|
||||
GdkEvent *event2,
|
||||
double *distance);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_event_set_device_tool (GdkEvent *event,
|
||||
GdkDeviceTool *tool);
|
||||
|
||||
gboolean gdk_events_get_angle (GdkEvent *event1,
|
||||
GdkEvent *event2,
|
||||
double *angle);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
int gdk_event_get_scancode (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_pointer_emulated (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_is_sent (const GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDrop * gdk_event_get_drop (const GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_crossing_mode (const GdkEvent *event,
|
||||
GdkCrossingMode *mode);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_crossing_detail (const GdkEvent *event,
|
||||
GdkNotifyType *detail);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_touchpad_gesture_phase (const GdkEvent *event,
|
||||
GdkTouchpadGesturePhase *phase);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_touchpad_gesture_n_fingers (const GdkEvent *event,
|
||||
guint *n_fingers);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_touchpad_deltas (const GdkEvent *event,
|
||||
double *dx,
|
||||
double *dy);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_touchpad_angle_delta (const GdkEvent *event,
|
||||
double *delta);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_touchpad_scale (const GdkEvent *event,
|
||||
double *scale);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_touch_emulating_pointer (const GdkEvent *event,
|
||||
gboolean *emulating);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_grab_surface (const GdkEvent *event,
|
||||
GdkSurface **surface);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_focus_in (const GdkEvent *event,
|
||||
gboolean *focus_in);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_pad_group_mode (const GdkEvent *event,
|
||||
guint *group,
|
||||
guint *mode);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_pad_button (const GdkEvent *event,
|
||||
guint *button);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_pad_axis_value (const GdkEvent *event,
|
||||
guint *index,
|
||||
gdouble *value);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_axes (GdkEvent *event,
|
||||
gdouble **axes,
|
||||
guint *n_axes);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GList * gdk_event_get_motion_history (const GdkEvent *event);
|
||||
gboolean gdk_events_get_center (GdkEvent *event1,
|
||||
GdkEvent *event2,
|
||||
double *x,
|
||||
double *y);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -30,16 +30,25 @@
|
||||
#include <gdk/gdkdevice.h>
|
||||
#include <gdk/gdkdevicetool.h>
|
||||
|
||||
#define GDK_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_EVENT, GdkEventClass))
|
||||
#define GDK_IS_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_EVENT))
|
||||
#define GDK_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_EVENT, GdkEventClass))
|
||||
|
||||
typedef struct _GdkEventClass GdkEventClass;
|
||||
|
||||
struct _GdkEventClass
|
||||
{
|
||||
GObjectClass object_class;
|
||||
};
|
||||
typedef struct _GdkEventAny GdkEventAny;
|
||||
typedef struct _GdkEventMotion GdkEventMotion;
|
||||
typedef struct _GdkEventButton GdkEventButton;
|
||||
typedef struct _GdkEventTouch GdkEventTouch;
|
||||
typedef struct _GdkEventScroll GdkEventScroll;
|
||||
typedef struct _GdkEventKey GdkEventKey;
|
||||
typedef struct _GdkEventFocus GdkEventFocus;
|
||||
typedef struct _GdkEventCrossing GdkEventCrossing;
|
||||
typedef struct _GdkEventConfigure GdkEventConfigure;
|
||||
typedef struct _GdkEventProximity GdkEventProximity;
|
||||
typedef struct _GdkEventDND GdkEventDND;
|
||||
typedef struct _GdkEventSetting GdkEventSetting;
|
||||
typedef struct _GdkEventGrabBroken GdkEventGrabBroken;
|
||||
typedef struct _GdkEventTouchpadSwipe GdkEventTouchpadSwipe;
|
||||
typedef struct _GdkEventTouchpadPinch GdkEventTouchpadPinch;
|
||||
typedef struct _GdkEventPadButton GdkEventPadButton;
|
||||
typedef struct _GdkEventPadAxis GdkEventPadAxis;
|
||||
typedef struct _GdkEventPadGroupMode GdkEventPadGroupMode;
|
||||
|
||||
/*
|
||||
* GdkEventAny:
|
||||
@ -53,15 +62,18 @@ struct _GdkEventClass
|
||||
*/
|
||||
struct _GdkEventAny
|
||||
{
|
||||
GObject parent_instance;
|
||||
int ref_count;
|
||||
GdkEventType type;
|
||||
GdkSurface *surface;
|
||||
guint32 time;
|
||||
guint16 flags;
|
||||
gint8 send_event;
|
||||
guint pointer_emulated : 1;
|
||||
guint touch_emulating : 1;
|
||||
guint scroll_is_stop : 1;
|
||||
guint key_is_modifier : 1;
|
||||
guint focus_in : 1;
|
||||
GdkDevice *device;
|
||||
GdkDevice *source_device;
|
||||
GdkDisplay *display;
|
||||
GObject *target;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -79,9 +91,6 @@ struct _GdkEventAny
|
||||
* buttons. See #GdkModifierType.
|
||||
* @device: the master device that the event originated from. Use
|
||||
* gdk_event_get_source_device() to get the slave device.
|
||||
* @x_root: the x coordinate of the pointer relative to the root of the
|
||||
* screen.
|
||||
* @y_root: the y coordinate of the pointer relative to the root of the
|
||||
* screen.
|
||||
*
|
||||
* Generated when the pointer moves.
|
||||
@ -89,13 +98,11 @@ struct _GdkEventAny
|
||||
struct _GdkEventMotion
|
||||
{
|
||||
GdkEventAny any;
|
||||
guint32 time;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
gdouble *axes;
|
||||
guint state;
|
||||
GdkModifierType state;
|
||||
double x;
|
||||
double y;
|
||||
double *axes;
|
||||
GdkDeviceTool *tool;
|
||||
gdouble x_root, y_root;
|
||||
GList *history;
|
||||
};
|
||||
|
||||
@ -118,9 +125,6 @@ struct _GdkEventMotion
|
||||
* often be simulated by pressing both mouse buttons together.
|
||||
* @device: the master device that the event originated from. Use
|
||||
* gdk_event_get_source_device() to get the slave device.
|
||||
* @x_root: the x coordinate of the pointer relative to the root of the
|
||||
* screen.
|
||||
* @y_root: the y coordinate of the pointer relative to the root of the
|
||||
* screen.
|
||||
*
|
||||
* Used for button press and button release events. The
|
||||
@ -129,14 +133,12 @@ struct _GdkEventMotion
|
||||
struct _GdkEventButton
|
||||
{
|
||||
GdkEventAny any;
|
||||
guint32 time;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
gdouble *axes;
|
||||
guint state;
|
||||
GdkModifierType state;
|
||||
guint button;
|
||||
double x;
|
||||
double y;
|
||||
double *axes;
|
||||
GdkDeviceTool *tool;
|
||||
gdouble x_root, y_root;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -158,9 +160,6 @@ struct _GdkEventButton
|
||||
* pointer event
|
||||
* @device: the master device that the event originated from. Use
|
||||
* gdk_event_get_source_device() to get the slave device.
|
||||
* @x_root: the x coordinate of the pointer relative to the root of the
|
||||
* screen
|
||||
* @y_root: the y coordinate of the pointer relative to the root of the
|
||||
* screen
|
||||
*
|
||||
* Used for touch events.
|
||||
@ -177,14 +176,11 @@ struct _GdkEventButton
|
||||
struct _GdkEventTouch
|
||||
{
|
||||
GdkEventAny any;
|
||||
guint32 time;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
gdouble *axes;
|
||||
guint state;
|
||||
GdkModifierType state;
|
||||
double x;
|
||||
double y;
|
||||
double *axes;
|
||||
GdkEventSequence *sequence;
|
||||
gboolean emulating_pointer;
|
||||
gdouble x_root, y_root;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -203,10 +199,6 @@ struct _GdkEventTouch
|
||||
* %GDK_SCROLL_SMOOTH).
|
||||
* @device: the master device that the event originated from. Use
|
||||
* gdk_event_get_source_device() to get the slave device.
|
||||
* @x_root: the x coordinate of the pointer relative to the root of the
|
||||
* screen.
|
||||
* @y_root: the y coordinate of the pointer relative to the root of the
|
||||
* screen.
|
||||
* @delta_x: the x coordinate of the scroll delta
|
||||
* @delta_y: the y coordinate of the scroll delta
|
||||
*
|
||||
@ -222,15 +214,12 @@ struct _GdkEventTouch
|
||||
struct _GdkEventScroll
|
||||
{
|
||||
GdkEventAny any;
|
||||
guint32 time;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
guint state;
|
||||
double x;
|
||||
double y;
|
||||
GdkModifierType state;
|
||||
GdkScrollDirection direction;
|
||||
gdouble x_root, y_root;
|
||||
gdouble delta_x;
|
||||
gdouble delta_y;
|
||||
guint is_stop : 1;
|
||||
double delta_x;
|
||||
double delta_y;
|
||||
GdkDeviceTool *tool;
|
||||
};
|
||||
|
||||
@ -256,13 +245,11 @@ struct _GdkEventScroll
|
||||
struct _GdkEventKey
|
||||
{
|
||||
GdkEventAny any;
|
||||
guint32 time;
|
||||
guint state;
|
||||
GdkModifierType state;
|
||||
guint keyval;
|
||||
guint16 hardware_keycode;
|
||||
guint16 key_scancode;
|
||||
guint8 group;
|
||||
guint is_modifier : 1;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -274,8 +261,6 @@ struct _GdkEventKey
|
||||
* @time: the time of the event in milliseconds.
|
||||
* @x: the x coordinate of the pointer relative to the surface.
|
||||
* @y: the y coordinate of the pointer relative to the surface.
|
||||
* @x_root: the x coordinate of the pointer relative to the root of the screen.
|
||||
* @y_root: the y coordinate of the pointer relative to the root of the screen.
|
||||
* @mode: the crossing mode (%GDK_CROSSING_NORMAL, %GDK_CROSSING_GRAB,
|
||||
* %GDK_CROSSING_UNGRAB, %GDK_CROSSING_GTK_GRAB, %GDK_CROSSING_GTK_UNGRAB or
|
||||
* %GDK_CROSSING_STATE_CHANGED). %GDK_CROSSING_GTK_GRAB, %GDK_CROSSING_GTK_UNGRAB,
|
||||
@ -294,17 +279,13 @@ struct _GdkEventKey
|
||||
struct _GdkEventCrossing
|
||||
{
|
||||
GdkEventAny any;
|
||||
GdkSurface *child_surface;
|
||||
guint32 time;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
gdouble x_root;
|
||||
gdouble y_root;
|
||||
GdkModifierType state;
|
||||
GdkCrossingMode mode;
|
||||
double x;
|
||||
double y;
|
||||
GdkNotifyType detail;
|
||||
gboolean focus;
|
||||
guint state;
|
||||
GObject *related_target;
|
||||
GdkSurface *child_surface;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -325,7 +306,6 @@ struct _GdkEventFocus
|
||||
gint16 in;
|
||||
GdkCrossingMode mode;
|
||||
GdkNotifyType detail;
|
||||
GObject *related_target;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -343,9 +323,10 @@ struct _GdkEventFocus
|
||||
struct _GdkEventConfigure
|
||||
{
|
||||
GdkEventAny any;
|
||||
gint x, y;
|
||||
gint width;
|
||||
gint height;
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -370,7 +351,6 @@ struct _GdkEventConfigure
|
||||
struct _GdkEventProximity
|
||||
{
|
||||
GdkEventAny any;
|
||||
guint32 time;
|
||||
GdkDeviceTool *tool;
|
||||
};
|
||||
|
||||
@ -408,19 +388,12 @@ struct _GdkEventGrabBroken {
|
||||
* @send_event: %TRUE if the event was sent explicitly.
|
||||
* @drop: the #GdkDrop for the current DND operation.
|
||||
* @time: the time of the event in milliseconds.
|
||||
* @x_root: the x coordinate of the pointer relative to the root of the
|
||||
* screen, only set for %GDK_DRAG_MOTION and %GDK_DROP_START.
|
||||
* @y_root: the y coordinate of the pointer relative to the root of the
|
||||
* screen, only set for %GDK_DRAG_MOTION and %GDK_DROP_START.
|
||||
*
|
||||
* Generated during DND operations.
|
||||
*/
|
||||
struct _GdkEventDND {
|
||||
GdkEventAny any;
|
||||
GdkDrop *drop;
|
||||
|
||||
guint32 time;
|
||||
double x_root, y_root;
|
||||
double x;
|
||||
double y;
|
||||
};
|
||||
@ -437,10 +410,6 @@ struct _GdkEventDND {
|
||||
* @y: The Y coordinate of the pointer
|
||||
* @dx: Movement delta in the X axis of the swipe focal point
|
||||
* @dy: Movement delta in the Y axis of the swipe focal point
|
||||
* @x_root: The X coordinate of the pointer, relative to the
|
||||
* root of the screen.
|
||||
* @y_root: The Y coordinate of the pointer, relative to the
|
||||
* root of the screen.
|
||||
* @state: (type GdkModifierType): a bit-mask representing the state of
|
||||
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
|
||||
* buttons. See #GdkModifierType.
|
||||
@ -449,15 +418,13 @@ struct _GdkEventDND {
|
||||
*/
|
||||
struct _GdkEventTouchpadSwipe {
|
||||
GdkEventAny any;
|
||||
GdkModifierType state;
|
||||
gint8 phase;
|
||||
gint8 n_fingers;
|
||||
guint32 time;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
gdouble dx;
|
||||
gdouble dy;
|
||||
gdouble x_root, y_root;
|
||||
guint state;
|
||||
double x;
|
||||
double y;
|
||||
double dx;
|
||||
double dy;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -476,10 +443,6 @@ struct _GdkEventTouchpadSwipe {
|
||||
* denote counter-clockwise movements
|
||||
* @scale: The current scale, relative to that at the time of
|
||||
* the corresponding %GDK_TOUCHPAD_GESTURE_PHASE_BEGIN event
|
||||
* @x_root: The X coordinate of the pointer, relative to the
|
||||
* root of the screen.
|
||||
* @y_root: The Y coordinate of the pointer, relative to the
|
||||
* root of the screen.
|
||||
* @state: (type GdkModifierType): a bit-mask representing the state of
|
||||
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
|
||||
* buttons. See #GdkModifierType.
|
||||
@ -488,17 +451,15 @@ struct _GdkEventTouchpadSwipe {
|
||||
*/
|
||||
struct _GdkEventTouchpadPinch {
|
||||
GdkEventAny any;
|
||||
GdkModifierType state;
|
||||
gint8 phase;
|
||||
gint8 n_fingers;
|
||||
guint32 time;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
gdouble dx;
|
||||
gdouble dy;
|
||||
gdouble angle_delta;
|
||||
gdouble scale;
|
||||
gdouble x_root, y_root;
|
||||
guint state;
|
||||
double x;
|
||||
double y;
|
||||
double dx;
|
||||
double dy;
|
||||
double angle_delta;
|
||||
double scale;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -517,7 +478,6 @@ struct _GdkEventTouchpadPinch {
|
||||
*/
|
||||
struct _GdkEventPadButton {
|
||||
GdkEventAny any;
|
||||
guint32 time;
|
||||
guint group;
|
||||
guint button;
|
||||
guint mode;
|
||||
@ -541,11 +501,10 @@ struct _GdkEventPadButton {
|
||||
*/
|
||||
struct _GdkEventPadAxis {
|
||||
GdkEventAny any;
|
||||
guint32 time;
|
||||
guint group;
|
||||
guint index;
|
||||
guint mode;
|
||||
gdouble value;
|
||||
double value;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -564,62 +523,15 @@ struct _GdkEventPadAxis {
|
||||
*/
|
||||
struct _GdkEventPadGroupMode {
|
||||
GdkEventAny any;
|
||||
guint32 time;
|
||||
guint group;
|
||||
guint mode;
|
||||
};
|
||||
|
||||
/*
|
||||
* GdkEvent:
|
||||
* @type: the #GdkEventType
|
||||
* @any: a #GdkEventAny
|
||||
* @motion: a #GdkEventMotion
|
||||
* @button: a #GdkEventButton
|
||||
* @touch: a #GdkEventTouch
|
||||
* @scroll: a #GdkEventScroll
|
||||
* @key: a #GdkEventKey
|
||||
* @crossing: a #GdkEventCrossing
|
||||
* @focus_change: a #GdkEventFocus
|
||||
* @configure: a #GdkEventConfigure
|
||||
* @proximity: a #GdkEventProximity
|
||||
* @dnd: a #GdkEventDND
|
||||
* @grab_broken: a #GdkEventGrabBroken
|
||||
* @touchpad_swipe: a #GdkEventTouchpadSwipe
|
||||
* @touchpad_pinch: a #GdkEventTouchpadPinch
|
||||
* @pad_button: a #GdkEventPadButton
|
||||
* @pad_axis: a #GdkEventPadAxis
|
||||
* @pad_group_mode: a #GdkEventPadGroupMode
|
||||
*
|
||||
* A #GdkEvent contains a union of all of the event types,
|
||||
* and allows access to the data fields in a number of ways.
|
||||
*
|
||||
* The event type is always the first field in all of the event types, and
|
||||
* can always be accessed with the following code, no matter what type of
|
||||
* event it is:
|
||||
* |[<!-- language="C" -->
|
||||
* GdkEvent *event;
|
||||
* GdkEventType type;
|
||||
*
|
||||
* type = event->type;
|
||||
* ]|
|
||||
*
|
||||
* To access other fields of the event, the pointer to the event
|
||||
* can be cast to the appropriate event type, or the union member
|
||||
* name can be used. For example if the event type is %GDK_BUTTON_PRESS
|
||||
* then the x coordinate of the button press can be accessed with:
|
||||
* |[<!-- language="C" -->
|
||||
* GdkEvent *event;
|
||||
* gdouble x;
|
||||
*
|
||||
* x = ((GdkEventButton*)event)->x;
|
||||
* ]|
|
||||
* or:
|
||||
* |[<!-- language="C" -->
|
||||
* GdkEvent *event;
|
||||
* gdouble x;
|
||||
*
|
||||
* x = event->button.x;
|
||||
* ]|
|
||||
* The GdkEvent struct is private and should only be accessed
|
||||
* using the accessor functions.
|
||||
*/
|
||||
union _GdkEvent
|
||||
{
|
||||
@ -642,14 +554,174 @@ union _GdkEvent
|
||||
GdkEventPadGroupMode pad_group_mode;
|
||||
};
|
||||
|
||||
void gdk_event_set_target (GdkEvent *event,
|
||||
GObject *user_data);
|
||||
GObject * gdk_event_get_target (const GdkEvent *event);
|
||||
void gdk_event_set_related_target (GdkEvent *event,
|
||||
GObject *user_data);
|
||||
GObject * gdk_event_get_related_target (const GdkEvent *event);
|
||||
GdkEvent * gdk_event_button_new (GdkEventType type,
|
||||
GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
GdkDeviceTool *tool,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
guint button,
|
||||
double x,
|
||||
double y,
|
||||
double *axes);
|
||||
|
||||
GdkEvent * gdk_event_motion_new (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
GdkDeviceTool *tool,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
double x,
|
||||
double y,
|
||||
double *axes);
|
||||
|
||||
gboolean check_event_sanity (GdkEvent *event);
|
||||
GdkEvent * gdk_event_crossing_new (GdkEventType type,
|
||||
GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
double x,
|
||||
double y,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType notify);
|
||||
|
||||
GdkEvent * gdk_event_proximity_new (GdkEventType type,
|
||||
GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
GdkDeviceTool *tool,
|
||||
guint32 time);
|
||||
|
||||
GdkEvent * gdk_event_key_new (GdkEventType type,
|
||||
GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
guint keyval,
|
||||
guint16 keycode,
|
||||
guint16 scancode,
|
||||
guint8 group,
|
||||
gboolean is_modifier);
|
||||
|
||||
GdkEvent * gdk_event_focus_new (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
gboolean focus_in);
|
||||
|
||||
GdkEvent * gdk_event_configure_new (GdkSurface *surface,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
GdkEvent * gdk_event_delete_new (GdkSurface *surface);
|
||||
|
||||
GdkEvent * gdk_event_scroll_new (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
GdkDeviceTool *tool,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
double delta_x,
|
||||
double delta_y,
|
||||
gboolean is_stop);
|
||||
|
||||
GdkEvent * gdk_event_discrete_scroll_new (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
GdkDeviceTool *tool,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GdkScrollDirection direction,
|
||||
gboolean emulated);
|
||||
|
||||
GdkEvent * gdk_event_touch_new (GdkEventType type,
|
||||
GdkEventSequence *sequence,
|
||||
GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
double x,
|
||||
double y,
|
||||
double *axes,
|
||||
gboolean emulating);
|
||||
|
||||
GdkEvent * gdk_event_touchpad_swipe_new (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GdkTouchpadGesturePhase phase,
|
||||
double x,
|
||||
double y,
|
||||
int n_fingers,
|
||||
double dx,
|
||||
double dy);
|
||||
|
||||
GdkEvent * gdk_event_touchpad_pinch_new (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GdkTouchpadGesturePhase phase,
|
||||
double x,
|
||||
double y,
|
||||
int n_fingers,
|
||||
double dx,
|
||||
double dy,
|
||||
double scale,
|
||||
double angle_delta);
|
||||
|
||||
GdkEvent * gdk_event_pad_ring_new (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
guint32 time,
|
||||
guint group,
|
||||
guint index,
|
||||
guint mode,
|
||||
double value);
|
||||
|
||||
GdkEvent * gdk_event_pad_strip_new (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
guint32 time,
|
||||
guint group,
|
||||
guint index,
|
||||
guint mode,
|
||||
double value);
|
||||
|
||||
GdkEvent * gdk_event_pad_button_new (GdkEventType type,
|
||||
GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
guint32 time,
|
||||
guint group,
|
||||
guint button,
|
||||
guint mode);
|
||||
|
||||
GdkEvent * gdk_event_pad_group_mode_new (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
guint32 time,
|
||||
guint group,
|
||||
guint mode);
|
||||
|
||||
GdkEvent * gdk_event_drag_new (GdkEventType type,
|
||||
GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDrop *drop,
|
||||
guint32 time,
|
||||
double x,
|
||||
double y);
|
||||
|
||||
GdkEvent * gdk_event_grab_broken_new (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkDevice *source_device,
|
||||
GdkSurface *grab_surface,
|
||||
gboolean implicit);
|
||||
|
||||
|
||||
#endif /* __GDK_EVENTS_PRIVATE_H__ */
|
||||
|
||||
|
@ -102,12 +102,6 @@ typedef enum
|
||||
*/
|
||||
GDK_EVENT_PENDING = 1 << 0,
|
||||
|
||||
/* The following flag is set for:
|
||||
* 1) touch events emulating pointer events
|
||||
* 2) pointer events being emulated by a touch sequence.
|
||||
*/
|
||||
GDK_EVENT_POINTER_EMULATED = 1 << 1,
|
||||
|
||||
/* When we are ready to draw a frame, we pause event delivery,
|
||||
* mark all events in the queue with this flag, and deliver
|
||||
* only those events until we finish the frame.
|
||||
@ -124,12 +118,6 @@ extern gint _gdk_screen_number;
|
||||
|
||||
GdkEvent* _gdk_event_unqueue (GdkDisplay *display);
|
||||
|
||||
void gdk_event_set_pointer_emulated (GdkEvent *event,
|
||||
gboolean emulated);
|
||||
|
||||
void gdk_event_set_scancode (GdkEvent *event,
|
||||
guint16 scancode);
|
||||
|
||||
void _gdk_event_emit (GdkEvent *event);
|
||||
GList* _gdk_event_queue_find_first (GdkDisplay *display);
|
||||
void _gdk_event_queue_remove_link (GdkDisplay *display,
|
||||
@ -149,7 +137,7 @@ void _gdk_event_queue_flush (GdkDisplay *display);
|
||||
void _gdk_event_button_generate (GdkDisplay *display,
|
||||
GdkEvent *event);
|
||||
|
||||
void _gdk_windowing_event_data_copy (const GdkEvent *src,
|
||||
void _gdk_windowing_event_data_copy (GdkEvent *src,
|
||||
GdkEvent *dst);
|
||||
void _gdk_windowing_event_data_free (GdkEvent *event);
|
||||
|
||||
@ -272,7 +260,7 @@ GdkGrabStatus gdk_seat_grab (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities,
|
||||
gboolean owner_events,
|
||||
GdkCursor *cursor,
|
||||
const GdkEvent *event,
|
||||
GdkEvent *event,
|
||||
GdkSeatGrabPrepareFunc prepare_func,
|
||||
gpointer prepare_func_data);
|
||||
void gdk_seat_ungrab (GdkSeat *seat);
|
||||
|
@ -559,11 +559,14 @@ gdk_keymap_lookup_key (GdkKeymap *keymap,
|
||||
* |[<!-- language="C" -->
|
||||
* // We want to ignore irrelevant modifiers like ScrollLock
|
||||
* #define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)
|
||||
* gdk_keymap_translate_keyboard_state (keymap, event->hardware_keycode,
|
||||
* event->state, event->group,
|
||||
* state = gdk_event_get_modifier_state (event);
|
||||
* gdk_keymap_translate_keyboard_state (keymap,
|
||||
* gdk_key_event_get_keycode (event),
|
||||
* state,
|
||||
* gdk_key_event_get_group (event),
|
||||
* &keyval, NULL, NULL, &consumed);
|
||||
* if (keyval == GDK_PLUS &&
|
||||
* (event->state & ~consumed & ALL_ACCELS_MASK) == GDK_CONTROL_MASK)
|
||||
* (state & ~consumed & ALL_ACCELS_MASK) == GDK_CONTROL_MASK)
|
||||
* // Control was pressed
|
||||
* ]|
|
||||
*
|
||||
@ -574,7 +577,7 @@ gdk_keymap_lookup_key (GdkKeymap *keymap,
|
||||
* |[<!-- language="C" -->
|
||||
* // XXX Don’t do this XXX
|
||||
* if (keyval == accel_keyval &&
|
||||
* (event->state & ~consumed & ALL_ACCELS_MASK) == (accel_mods & ~consumed))
|
||||
* (state & ~consumed & ALL_ACCELS_MASK) == (accel_mods & ~consumed))
|
||||
* // Accelerator was pressed
|
||||
* ]|
|
||||
*
|
||||
|
@ -286,7 +286,7 @@ gdk_seat_grab (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities,
|
||||
gboolean owner_events,
|
||||
GdkCursor *cursor,
|
||||
const GdkEvent *event,
|
||||
GdkEvent *event,
|
||||
GdkSeatGrabPrepareFunc prepare_func,
|
||||
gpointer prepare_func_data)
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ gdk_seat_default_grab (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities,
|
||||
gboolean owner_events,
|
||||
GdkCursor *cursor,
|
||||
const GdkEvent *event,
|
||||
GdkEvent *event,
|
||||
GdkSeatGrabPrepareFunc prepare_func,
|
||||
gpointer prepare_func_data)
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ struct _GdkSeatClass
|
||||
GdkSeatCapabilities capabilities,
|
||||
gboolean owner_events,
|
||||
GdkCursor *cursor,
|
||||
const GdkEvent *event,
|
||||
GdkEvent *event,
|
||||
GdkSeatGrabPrepareFunc prepare_func,
|
||||
gpointer prepare_func_data);
|
||||
void (* ungrab) (GdkSeat *seat);
|
||||
|
106
gdk/gdksurface.c
106
gdk/gdksurface.c
@ -558,13 +558,13 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
|
||||
0,
|
||||
g_signal_accumulator_true_handled,
|
||||
NULL,
|
||||
_gdk_marshal_BOOLEAN__OBJECT,
|
||||
_gdk_marshal_BOOLEAN__BOXED,
|
||||
G_TYPE_BOOLEAN,
|
||||
1,
|
||||
GDK_TYPE_EVENT);
|
||||
g_signal_set_va_marshaller (signals[EVENT],
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
_gdk_marshal_BOOLEAN__OBJECTv);
|
||||
_gdk_marshal_BOOLEAN__BOXEDv);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2675,6 +2675,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
|
||||
GdkDeviceGrabInfo *button_release_grab;
|
||||
GdkPointerSurfaceInfo *pointer_info = NULL;
|
||||
GdkDevice *device, *source_device;
|
||||
GdkEventType type;
|
||||
|
||||
_gdk_display_update_last_event (display, event);
|
||||
|
||||
@ -2708,21 +2709,21 @@ _gdk_windowing_got_event (GdkDisplay *display,
|
||||
}
|
||||
}
|
||||
|
||||
event_surface = event->any.surface;
|
||||
event_surface = gdk_event_get_surface (event);
|
||||
if (!event_surface)
|
||||
goto out;
|
||||
|
||||
if (event->any.type == GDK_ENTER_NOTIFY)
|
||||
type = gdk_event_get_event_type (event);
|
||||
if (type == GDK_ENTER_NOTIFY)
|
||||
_gdk_display_set_surface_under_pointer (display, device, event_surface);
|
||||
else if (event->any.type == GDK_LEAVE_NOTIFY)
|
||||
else if (type == GDK_LEAVE_NOTIFY)
|
||||
_gdk_display_set_surface_under_pointer (display, device, NULL);
|
||||
|
||||
if ((event->any.type == GDK_BUTTON_RELEASE ||
|
||||
event->any.type == GDK_TOUCH_CANCEL ||
|
||||
event->any.type == GDK_TOUCH_END) &&
|
||||
!event->any.send_event)
|
||||
if (type == GDK_BUTTON_RELEASE ||
|
||||
type == GDK_TOUCH_CANCEL ||
|
||||
type == GDK_TOUCH_END)
|
||||
{
|
||||
if (event->any.type == GDK_BUTTON_RELEASE ||
|
||||
if (type == GDK_BUTTON_RELEASE ||
|
||||
gdk_event_get_pointer_emulated (event))
|
||||
{
|
||||
button_release_grab =
|
||||
@ -2730,7 +2731,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
|
||||
|
||||
if (button_release_grab &&
|
||||
button_release_grab->implicit &&
|
||||
(event->button.state & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK << (event->button.button - 1))) == 0)
|
||||
(gdk_event_get_modifier_state (event) & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK << (gdk_button_event_get_button (event) - 1))) == 0)
|
||||
{
|
||||
button_release_grab->serial_end = serial;
|
||||
button_release_grab->implicit_ungrab = FALSE;
|
||||
@ -2744,7 +2745,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
|
||||
{
|
||||
_gdk_event_queue_remove_link (display, event_link);
|
||||
g_list_free_1 (event_link);
|
||||
g_object_unref (event);
|
||||
gdk_event_unref (event);
|
||||
}
|
||||
|
||||
/* This does two things - first it sees if there are motions at the
|
||||
@ -3982,12 +3983,13 @@ check_autohide (GdkEvent *event)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_key_event (GdkEvent *event)
|
||||
is_keyboard_event (GdkEvent *event)
|
||||
{
|
||||
switch ((guint) gdk_event_get_event_type (event))
|
||||
{
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
case GDK_FOCUS_CHANGE:
|
||||
return TRUE;
|
||||
default:;
|
||||
}
|
||||
@ -3995,16 +3997,35 @@ is_key_event (GdkEvent *event)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
static GdkEvent *
|
||||
rewrite_event_for_toplevel (GdkEvent *event)
|
||||
{
|
||||
GdkSurface *surface;
|
||||
|
||||
surface = gdk_event_get_surface (event);
|
||||
if (!surface->parent)
|
||||
return gdk_event_ref (event);
|
||||
|
||||
while (surface->parent)
|
||||
surface = surface->parent;
|
||||
|
||||
g_set_object (&event->any.surface, surface);
|
||||
if (gdk_event_get_event_type (event) == GDK_FOCUS_CHANGE)
|
||||
return gdk_event_focus_new (surface,
|
||||
gdk_event_get_device (event),
|
||||
gdk_event_get_source_device (event),
|
||||
gdk_focus_event_get_in (event));
|
||||
else
|
||||
return gdk_event_key_new (gdk_event_get_event_type (event),
|
||||
surface,
|
||||
gdk_event_get_device (event),
|
||||
gdk_event_get_source_device (event),
|
||||
gdk_event_get_time (event),
|
||||
gdk_event_get_modifier_state (event),
|
||||
gdk_key_event_get_keyval (event),
|
||||
gdk_key_event_get_keycode (event),
|
||||
gdk_key_event_get_scancode (event),
|
||||
gdk_key_event_get_group (event),
|
||||
gdk_key_event_is_modifier (event));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -4025,49 +4046,44 @@ add_event_mark (GdkEvent *event,
|
||||
{
|
||||
case GDK_MOTION_NOTIFY:
|
||||
{
|
||||
GdkEventMotion *motion = (GdkEventMotion *)event;
|
||||
double x, y;
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
message = g_strdup_printf ("{x=%lf, y=%lf, state=0x%x}",
|
||||
motion->x, motion->y, motion->state);
|
||||
x, y,
|
||||
gdk_event_get_modifier_state (event));
|
||||
break;
|
||||
}
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
{
|
||||
GdkEventButton *button = (GdkEventButton *)event;
|
||||
message = g_strdup_printf ("{button=%u, x=%lf, y=%lf, state=0x%x}",
|
||||
button->button, button->x, button->y, button->state);
|
||||
break;
|
||||
}
|
||||
|
||||
case GDK_BUTTON_RELEASE:
|
||||
{
|
||||
GdkEventButton *button = (GdkEventButton *)event;
|
||||
double x, y;
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
message = g_strdup_printf ("{button=%u, x=%lf, y=%lf, state=0x%x}",
|
||||
button->button, button->x, button->y, button->state);
|
||||
gdk_button_event_get_button (event),
|
||||
x, y,
|
||||
gdk_event_get_modifier_state (event));
|
||||
break;
|
||||
}
|
||||
|
||||
case GDK_KEY_PRESS:
|
||||
{
|
||||
GdkEventKey *key = (GdkEventKey *)event;
|
||||
message = g_strdup_printf ("{keyval=%u, state=0x%x, hardware_keycode=%u key_scancode=%u group=%u is_modifier=%u}",
|
||||
key->keyval, key->state, key->hardware_keycode, key->key_scancode, key->group, key->is_modifier);
|
||||
break;
|
||||
}
|
||||
|
||||
case GDK_KEY_RELEASE:
|
||||
{
|
||||
GdkEventKey *key = (GdkEventKey *)event;
|
||||
message = g_strdup_printf ("{keyval=%u, state=0x%x, hardware_keycode=%u key_scancode=%u group=%u is_modifier=%u}",
|
||||
key->keyval, key->state, key->hardware_keycode, key->key_scancode, key->group, key->is_modifier);
|
||||
gdk_key_event_get_keyval (event),
|
||||
gdk_event_get_modifier_state (event),
|
||||
gdk_key_event_get_keycode (event),
|
||||
gdk_key_event_get_scancode (event),
|
||||
gdk_key_event_get_group (event),
|
||||
gdk_key_event_is_modifier (event));
|
||||
break;
|
||||
}
|
||||
|
||||
case GDK_CONFIGURE:
|
||||
{
|
||||
GdkEventConfigure *config = (GdkEventConfigure *)event;
|
||||
message = g_strdup_printf ("{x=%d, y=%d, width=%d, height=%d}",
|
||||
config->x, config->y, config->width, config->height);
|
||||
int width, height;
|
||||
gdk_configure_event_get_size (event, &width, &height);
|
||||
message = g_strdup_printf ("{width=%d, height=%d}", width, height);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -4094,11 +4110,9 @@ add_event_mark (GdkEvent *event,
|
||||
case GDK_PAD_GROUP_MODE:
|
||||
case GDK_GRAB_BROKEN:
|
||||
case GDK_DELETE:
|
||||
case GDK_DESTROY:
|
||||
case GDK_FOCUS_CHANGE:
|
||||
case GDK_PROXIMITY_IN:
|
||||
case GDK_PROXIMITY_OUT:
|
||||
case GDK_NOTHING:
|
||||
case GDK_EVENT_LAST:
|
||||
default:
|
||||
break;
|
||||
@ -4129,9 +4143,15 @@ gdk_surface_handle_event (GdkEvent *event)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_key_event (event))
|
||||
rewrite_event_for_toplevel (event);
|
||||
g_signal_emit (gdk_event_get_surface (event), signals[EVENT], 0, event, &handled);
|
||||
GdkEvent *emitted;
|
||||
|
||||
if (is_keyboard_event (event))
|
||||
emitted = rewrite_event_for_toplevel (event);
|
||||
else
|
||||
emitted = gdk_event_ref (event);
|
||||
|
||||
g_signal_emit (gdk_event_get_surface (emitted), signals[EVENT], 0, emitted, &handled);
|
||||
gdk_event_unref (emitted);
|
||||
}
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -140,7 +140,7 @@ gdk_event_source_dispatch (GSource *base,
|
||||
{
|
||||
_gdk_event_emit (event);
|
||||
|
||||
g_object_unref (event);
|
||||
gdk_event_unref (event);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -170,9 +170,6 @@ _gdk_wayland_display_deliver_event (GdkDisplay *display,
|
||||
{
|
||||
GList *node;
|
||||
|
||||
if (!check_event_sanity (event))
|
||||
g_warning ("Snap! delivering insane events\n");
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
_gdk_windowing_got_event (display, node, event,
|
||||
_gdk_display_get_next_serial (display));
|
||||
|
@ -145,7 +145,7 @@ void _gdk_wayland_display_remove_seat (GdkWaylandDisplay *displa
|
||||
|
||||
GdkKeymap *_gdk_wayland_device_get_keymap (GdkDevice *device);
|
||||
uint32_t _gdk_wayland_device_get_implicit_grab_serial(GdkWaylandDevice *device,
|
||||
const GdkEvent *event);
|
||||
GdkEvent *event);
|
||||
uint32_t _gdk_wayland_seat_get_last_implicit_grab_serial (GdkWaylandSeat *seat,
|
||||
GdkEventSequence **seqence);
|
||||
struct wl_data_device * gdk_wayland_device_get_data_device (GdkDevice *gdk_device);
|
||||
|
@ -802,11 +802,7 @@ gdk_wayland_surface_resize (GdkSurface *surface,
|
||||
GdkDisplay *display;
|
||||
GdkEvent *event;
|
||||
|
||||
event = gdk_event_new (GDK_CONFIGURE);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->any.send_event = FALSE;
|
||||
event->configure.width = width;
|
||||
event->configure.height = height;
|
||||
event = gdk_event_configure_new (surface, width, height);
|
||||
|
||||
gdk_wayland_surface_update_size (surface, width, height, scale);
|
||||
_gdk_surface_update_size (surface);
|
||||
@ -1380,9 +1376,7 @@ gdk_wayland_surface_handle_close (GdkSurface *surface)
|
||||
|
||||
GDK_DISPLAY_NOTE (display, EVENTS, g_message ("close %p", surface));
|
||||
|
||||
event = gdk_event_new (GDK_DELETE);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->any.send_event = TRUE;
|
||||
event = gdk_event_delete_new (surface);
|
||||
|
||||
_gdk_wayland_display_deliver_event (display, event);
|
||||
}
|
||||
@ -3847,7 +3841,7 @@ gdk_wayland_surface_show_window_menu (GdkSurface *surface,
|
||||
|
||||
device = GDK_WAYLAND_DEVICE (gdk_event_get_device (event));
|
||||
seat = gdk_wayland_device_get_wl_seat (GDK_DEVICE (device));
|
||||
gdk_event_get_coords (event, &x, &y);
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
|
||||
serial = _gdk_wayland_device_get_implicit_grab_serial (device, event);
|
||||
|
||||
|
@ -874,9 +874,8 @@ gdk_device_manager_find_wintab_device (GdkDeviceManagerWin32 *device_manager,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
GdkEvent *
|
||||
gdk_input_other_event (GdkDisplay *display,
|
||||
GdkEvent *event,
|
||||
MSG *msg,
|
||||
GdkSurface *window)
|
||||
{
|
||||
@ -884,21 +883,28 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
GdkDeviceWintab *source_device = NULL;
|
||||
GdkDeviceGrabInfo *last_grab;
|
||||
guint key_state;
|
||||
GdkEvent *event;
|
||||
|
||||
PACKET packet;
|
||||
gint root_x, root_y;
|
||||
gint num_axes;
|
||||
double x, y;
|
||||
guint translated_buttons, button_diff, button_mask;
|
||||
|
||||
GdkEventType event_type;
|
||||
int event_button;
|
||||
GdkModifierType event_state;
|
||||
double event_x, event_y;
|
||||
double *axes;
|
||||
|
||||
/* Translation from tablet button state to GDK button state for
|
||||
* buttons 1-3 - swap button 2 and 3.
|
||||
*/
|
||||
static guint button_map[8] = {0, 1, 4, 5, 2, 3, 6, 7};
|
||||
|
||||
if (event->any.surface != wintab_window)
|
||||
if (window != wintab_window)
|
||||
{
|
||||
g_warning ("gdk_input_other_event: not wintab_window?");
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
device_manager = GDK_DEVICE_MANAGER_WIN32 (_gdk_device_manager);
|
||||
@ -914,7 +920,7 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
if (msg->message == WT_PACKET || msg->message == WT_CSRCHANGE)
|
||||
{
|
||||
if (!(*p_WTPacket) ((HCTX) msg->lParam, msg->wParam, &packet))
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (msg->message)
|
||||
@ -966,7 +972,7 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
|
||||
if (source_device == NULL ||
|
||||
gdk_device_get_mode (GDK_DEVICE (source_device)) == GDK_MODE_DISABLED)
|
||||
return FALSE;
|
||||
return NULL;
|
||||
|
||||
/* Don't produce any button or motion events while a window is being
|
||||
* moved or resized, see bug #151090.
|
||||
@ -974,7 +980,7 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
if (_modal_operation_in_progress & GDK_WIN32_MODAL_OP_SIZEMOVE_MASK)
|
||||
{
|
||||
GDK_NOTE (EVENTS_OR_INPUT, g_print ("... ignored when moving/sizing\n"));
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
last_grab = _gdk_display_get_last_device_grab (display, GDK_DEVICE (source_device));
|
||||
@ -989,7 +995,7 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
if (window == NULL)
|
||||
{
|
||||
GDK_NOTE (EVENTS_OR_INPUT, g_print ("... is root\n"));
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
num_axes = 0;
|
||||
@ -1018,10 +1024,10 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
button_diff = translated_buttons ^ source_device->button_state;
|
||||
|
||||
/* Gdk buttons are numbered 1.. */
|
||||
event->button.button = 1;
|
||||
event_button = 1;
|
||||
|
||||
for (button_mask = 1; button_mask != 0x80000000;
|
||||
button_mask <<= 1, event->button.button++)
|
||||
button_mask <<= 1, event_button++)
|
||||
{
|
||||
if (button_diff & button_mask)
|
||||
{
|
||||
@ -1032,47 +1038,49 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
|
||||
if (!(translated_buttons & button_mask))
|
||||
{
|
||||
event->any.type = GDK_BUTTON_RELEASE;
|
||||
event_type = GDK_BUTTON_RELEASE;
|
||||
}
|
||||
else
|
||||
{
|
||||
event->any.type = GDK_BUTTON_PRESS;
|
||||
event_type = GDK_BUTTON_PRESS;
|
||||
}
|
||||
source_device->button_state ^= button_mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
event->any.type = GDK_MOTION_NOTIFY;
|
||||
event_type = GDK_MOTION_NOTIFY;
|
||||
}
|
||||
|
||||
event->any.surface = window;
|
||||
key_state = get_modifier_key_state ();
|
||||
if (event->any.type == GDK_BUTTON_PRESS ||
|
||||
event->any.type == GDK_BUTTON_RELEASE)
|
||||
if (event_type == GDK_BUTTON_PRESS ||
|
||||
event_type == GDK_BUTTON_RELEASE)
|
||||
{
|
||||
event->button.time = _gdk_win32_get_next_tick (msg->time);
|
||||
if (source_device->sends_core)
|
||||
gdk_event_set_device (event, device_manager->core_pointer);
|
||||
gdk_event_set_source_device (event, GDK_DEVICE (source_device));
|
||||
|
||||
event->button.axes = g_new (gdouble, num_axes);
|
||||
gdk_surface_get_origin (window, &root_x, &root_y);
|
||||
axes = g_new (gdouble, num_axes);
|
||||
|
||||
_gdk_device_wintab_translate_axes (source_device,
|
||||
window,
|
||||
event->button.axes,
|
||||
&event->button.x,
|
||||
&event->button.y);
|
||||
axes,
|
||||
&event_x,
|
||||
&event_y);
|
||||
|
||||
event->button.x_root = event->button.x + root_x;
|
||||
event->button.y_root = event->button.y + root_y;
|
||||
|
||||
event->button.state =
|
||||
event_state =
|
||||
key_state | ((source_device->button_state << 8)
|
||||
& (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK
|
||||
| GDK_BUTTON3_MASK | GDK_BUTTON4_MASK
|
||||
| GDK_BUTTON5_MASK));
|
||||
|
||||
event = gdk_event_button_new (event_type,
|
||||
window,
|
||||
device_manager->core_pointer,
|
||||
GDK_DEVICE (source_device),
|
||||
NULL,
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
event_state,
|
||||
event_button,
|
||||
event_x,
|
||||
event_y,
|
||||
axes);
|
||||
|
||||
GDK_NOTE (EVENTS_OR_INPUT,
|
||||
g_print ("WINTAB button %s:%d %g,%g\n",
|
||||
(event->any.type == GDK_BUTTON_PRESS ?
|
||||
@ -1082,33 +1090,33 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
}
|
||||
else
|
||||
{
|
||||
event->motion.time = _gdk_win32_get_next_tick (msg->time);
|
||||
gdk_event_set_device (event, device_manager->core_pointer);
|
||||
gdk_event_set_source_device (event, GDK_DEVICE (source_device));
|
||||
|
||||
event->motion.axes = g_new (gdouble, num_axes);
|
||||
gdk_surface_get_origin (window, &root_x, &root_y);
|
||||
|
||||
axes = g_new (gdouble, num_axes);
|
||||
_gdk_device_wintab_translate_axes (source_device,
|
||||
window,
|
||||
event->motion.axes,
|
||||
&event->motion.x,
|
||||
&event->motion.y);
|
||||
axes,
|
||||
&event_x,
|
||||
&event_y);
|
||||
|
||||
event->motion.x_root = event->motion.x + root_x;
|
||||
event->motion.y_root = event->motion.y + root_y;
|
||||
|
||||
event->motion.state =
|
||||
event_state =
|
||||
key_state | ((source_device->button_state << 8)
|
||||
& (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK
|
||||
| GDK_BUTTON3_MASK | GDK_BUTTON4_MASK
|
||||
| GDK_BUTTON5_MASK));
|
||||
|
||||
event = gdk_event_motion_new (window,
|
||||
device_manager->core_pointer,
|
||||
GDK_DEVICE (source_device),
|
||||
NULL,
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
event_state,
|
||||
event_x,
|
||||
event_y,
|
||||
axes);
|
||||
GDK_NOTE (EVENTS_OR_INPUT,
|
||||
g_print ("WINTAB motion: %g,%g\n",
|
||||
event->motion.x, event->motion.y));
|
||||
}
|
||||
return TRUE;
|
||||
return event;
|
||||
|
||||
case WT_CSRCHANGE:
|
||||
if (device_manager->dev_entered_proximity > 0)
|
||||
@ -1117,7 +1125,7 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
if ((source_device = gdk_device_manager_find_wintab_device (device_manager,
|
||||
(HCTX) msg->lParam,
|
||||
packet.pkCursor)) == NULL)
|
||||
return FALSE;
|
||||
return NULL;
|
||||
|
||||
if (source_device->sends_core &&
|
||||
gdk_device_get_mode (GDK_DEVICE (source_device)) != GDK_MODE_DISABLED)
|
||||
@ -1127,7 +1135,7 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
_gdk_input_ignore_core += 1;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return NULL;
|
||||
|
||||
case WT_PROXIMITY:
|
||||
if (LOWORD (msg->lParam) == 0)
|
||||
@ -1146,8 +1154,8 @@ gdk_input_other_event (GdkDisplay *display,
|
||||
device_manager->dev_entered_proximity += 1;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -57,8 +57,7 @@ struct _GdkDeviceManagerWin32Class
|
||||
GType gdk_device_manager_win32_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void _gdk_input_set_tablet_active (void);
|
||||
gboolean gdk_input_other_event (GdkDisplay *display,
|
||||
GdkEvent *event,
|
||||
GdkEvent * gdk_input_other_event (GdkDisplay *display,
|
||||
MSG *msg,
|
||||
GdkSurface *window);
|
||||
|
||||
|
@ -2331,28 +2331,32 @@ gdk_local_drag_update (GdkDrag *drag,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_motion_event (GdkDrag *drag,
|
||||
const GdkEventMotion *event)
|
||||
gdk_dnd_handle_motion_event (GdkDrag *drag,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GdkModifierType state;
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
DWORD key_state;
|
||||
double x, y;
|
||||
double x_root, y_root;
|
||||
|
||||
if (!gdk_event_get_state ((GdkEvent *) event, &state))
|
||||
return FALSE;
|
||||
GDK_NOTE (DND, g_print ("gdk_dnd_handle_motion_event: 0x%p\n", drag));
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_dnd_handle_motion_event: 0x%p\n",
|
||||
drag));
|
||||
state = gdk_event_get_modifier_state (event);
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
|
||||
x_root = x + _gdk_offset_x;
|
||||
y_root = y + _gdk_offset_y;
|
||||
|
||||
if (drag_win32->drag_surface)
|
||||
move_drag_surface (drag, event->x_root, event->y_root);
|
||||
move_drag_surface (drag, x_root, y_root);
|
||||
|
||||
key_state = manufacture_keystate_from_GMT (state);
|
||||
|
||||
if (drag_win32->protocol == GDK_DRAG_PROTO_LOCAL)
|
||||
{
|
||||
gdk_local_drag_update (drag, event->x_root, event->y_root, key_state,
|
||||
gdk_event_get_time ((GdkEvent *) event));
|
||||
gdk_local_drag_update (drag, x_root, y_root, key_state,
|
||||
gdk_event_get_time (event));
|
||||
}
|
||||
else if (drag_win32->protocol == GDK_DRAG_PROTO_OLE2)
|
||||
{
|
||||
@ -2360,40 +2364,38 @@ gdk_dnd_handle_motion_event (GdkDrag *drag,
|
||||
|
||||
GDK_NOTE (DND, g_print ("Post WM_MOUSEMOVE keystate=%lu\n", key_state));
|
||||
|
||||
drag_win32->util_data.last_x = event->x_root;
|
||||
drag_win32->util_data.last_y = event->y_root;
|
||||
drag_win32->util_data.last_x = x_root;
|
||||
drag_win32->util_data.last_y = y_root;
|
||||
|
||||
API_CALL (PostThreadMessage, (clipdrop->dnd_thread_id,
|
||||
WM_MOUSEMOVE,
|
||||
key_state,
|
||||
MAKELPARAM ((event->x_root - _gdk_offset_x) * drag_win32->scale,
|
||||
(event->y_root - _gdk_offset_y) * drag_win32->scale)));
|
||||
MAKELPARAM (x * drag_win32->scale,
|
||||
y * drag_win32->scale)));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_key_event (GdkDrag *drag,
|
||||
const GdkEventKey *event)
|
||||
gdk_dnd_handle_key_event (GdkDrag *drag,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
GdkModifierType state;
|
||||
GdkDevice *pointer;
|
||||
gint dx, dy;
|
||||
|
||||
if (!gdk_event_get_state ((GdkEvent *) event, &state))
|
||||
return FALSE;
|
||||
GDK_NOTE (DND, g_print ("gdk_dnd_handle_key_event: 0x%p\n", drag));
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_dnd_handle_key_event: 0x%p\n",
|
||||
drag));
|
||||
state = gdk_event_get_modifier_state (event);
|
||||
|
||||
dx = dy = 0;
|
||||
pointer = gdk_device_get_associated_device (gdk_event_get_device ((GdkEvent *) event));
|
||||
pointer = gdk_device_get_associated_device (gdk_event_get_device (event));
|
||||
|
||||
if (event->any.type == GDK_KEY_PRESS)
|
||||
if (gdk_event_get_event_type (event) == GDK_KEY_PRESS)
|
||||
{
|
||||
switch (event->keyval)
|
||||
switch (gdk_key_event_get_keyval (event))
|
||||
{
|
||||
case GDK_KEY_Escape:
|
||||
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
|
||||
@ -2453,31 +2455,29 @@ gdk_dnd_handle_key_event (GdkDrag *drag,
|
||||
if (drag_win32->protocol == GDK_DRAG_PROTO_LOCAL)
|
||||
gdk_local_drag_update (drag, drag_win32->util_data.last_x, drag_win32->util_data.last_y,
|
||||
manufacture_keystate_from_GMT (state),
|
||||
gdk_event_get_time ((GdkEvent *) event));
|
||||
gdk_event_get_time (event));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
|
||||
const GdkEventGrabBroken *event)
|
||||
gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_dnd_handle_grab_broken_event: 0x%p\n",
|
||||
drag));
|
||||
GDK_NOTE (DND, g_print ("gdk_dnd_handle_grab_broken_event: 0x%p\n", drag));
|
||||
|
||||
/* Don't cancel if we break the implicit grab from the initial button_press.
|
||||
* Also, don't cancel if we re-grab on the widget or on our grab window, for
|
||||
* example, when changing the drag cursor.
|
||||
*/
|
||||
if (event->implicit ||
|
||||
event->grab_surface == drag_win32->drag_surface ||
|
||||
event->grab_surface == drag_win32->grab_surface)
|
||||
if (/* FIXME: event->implicit || */
|
||||
gdk_grab_broken_event_get_grab_surface (event) == drag_win32->drag_surface ||
|
||||
gdk_grab_broken_event_get_grab_surface (event) == drag_win32->grab_surface)
|
||||
return FALSE;
|
||||
|
||||
if (gdk_event_get_device ((GdkEvent *) event) !=
|
||||
gdk_drag_get_device (drag))
|
||||
if (gdk_event_get_device (event) != gdk_drag_get_device (drag))
|
||||
return FALSE;
|
||||
|
||||
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_ERROR);
|
||||
@ -2485,11 +2485,10 @@ gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_button_event (GdkDrag *drag,
|
||||
const GdkEventButton *event)
|
||||
gdk_dnd_handle_button_event (GdkDrag *drag,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GDK_NOTE (DND, g_print ("gdk_dnd_handle_button_event: 0x%p\n",
|
||||
drag));
|
||||
GDK_NOTE (DND, g_print ("gdk_dnd_handle_button_event: 0x%p\n", drag));
|
||||
|
||||
#if 0
|
||||
/* FIXME: Check the button matches */
|
||||
@ -2509,8 +2508,8 @@ gdk_dnd_handle_button_event (GdkDrag *drag,
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_win32_drag_handle_event (GdkDrag *drag,
|
||||
const GdkEvent *event)
|
||||
gdk_win32_drag_handle_event (GdkDrag *drag,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
@ -2523,17 +2522,17 @@ gdk_win32_drag_handle_event (GdkDrag *drag,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (event->any.type)
|
||||
switch (gdk_event_get_event_type (event))
|
||||
{
|
||||
case GDK_MOTION_NOTIFY:
|
||||
return gdk_dnd_handle_motion_event (drag, &event->motion);
|
||||
return gdk_dnd_handle_motion_event (drag, event);
|
||||
case GDK_BUTTON_RELEASE:
|
||||
return gdk_dnd_handle_button_event (drag, &event->button);
|
||||
return gdk_dnd_handle_button_event (drag, event);
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
return gdk_dnd_handle_key_event (drag, &event->key);
|
||||
return gdk_dnd_handle_key_event (drag, event);
|
||||
case GDK_GRAB_BROKEN:
|
||||
return gdk_dnd_handle_grab_broken_event (drag, &event->grab_broken);
|
||||
return gdk_dnd_handle_grab_broken_event (drag, event);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -205,11 +205,7 @@ generate_focus_event (GdkDeviceManagerWin32 *device_manager,
|
||||
device = GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard;
|
||||
source_device = GDK_DEVICE_MANAGER_WIN32 (device_manager)->system_keyboard;
|
||||
|
||||
event = gdk_event_new (GDK_FOCUS_CHANGE);
|
||||
event->any.surface = window;
|
||||
event->focus_change.in = in;
|
||||
gdk_event_set_device (event, device);
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
event = gdk_event_focus_new (window, device, source_device, in);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
}
|
||||
@ -220,28 +216,26 @@ generate_grab_broken_event (GdkDeviceManagerWin32 *device_manager,
|
||||
gboolean keyboard,
|
||||
GdkSurface *grab_window)
|
||||
{
|
||||
GdkEvent *event = gdk_event_new (GDK_GRAB_BROKEN);
|
||||
GdkEvent *event;
|
||||
GdkDevice *device;
|
||||
GdkDevice *source_device;
|
||||
|
||||
if (keyboard)
|
||||
{
|
||||
device = GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard;
|
||||
source_device = GDK_DEVICE_MANAGER_WIN32 (device_manager)->system_keyboard;
|
||||
device = device_manager->core_keyboard;
|
||||
source_device = device_manager->system_keyboard;
|
||||
}
|
||||
else
|
||||
{
|
||||
device = GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_pointer;
|
||||
source_device = GDK_DEVICE_MANAGER_WIN32 (device_manager)->system_pointer;
|
||||
device = device_manager->core_pointer;
|
||||
source_device = device_manager->system_pointer;
|
||||
}
|
||||
|
||||
event->any.surface = window;
|
||||
event->any.send_event = 0;
|
||||
event->grab_broken.keyboard = keyboard;
|
||||
event->grab_broken.implicit = FALSE;
|
||||
event->grab_broken.grab_surface = grab_window;
|
||||
gdk_event_set_device (event, device);
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
event = gdk_event_grab_broken_new (window,
|
||||
device,
|
||||
source_device,
|
||||
grab_window,
|
||||
FALSE);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
}
|
||||
@ -633,51 +627,62 @@ find_window_for_mouse_event (GdkSurface* reported_window,
|
||||
return event_surface;
|
||||
}
|
||||
|
||||
static void
|
||||
build_key_event_state (GdkEvent *event,
|
||||
BYTE *key_state)
|
||||
static GdkModifierType
|
||||
build_key_event_state (BYTE *key_state)
|
||||
{
|
||||
GdkModifierType state;
|
||||
GdkWin32Keymap *keymap;
|
||||
|
||||
event->key.state = 0;
|
||||
state = 0;
|
||||
|
||||
if (key_state[VK_SHIFT] & 0x80)
|
||||
event->key.state |= GDK_SHIFT_MASK;
|
||||
state |= GDK_SHIFT_MASK;
|
||||
|
||||
if (key_state[VK_CAPITAL] & 0x01)
|
||||
event->key.state |= GDK_LOCK_MASK;
|
||||
state |= GDK_LOCK_MASK;
|
||||
|
||||
if (key_state[VK_LBUTTON] & 0x80)
|
||||
event->key.state |= GDK_BUTTON1_MASK;
|
||||
state |= GDK_BUTTON1_MASK;
|
||||
if (key_state[VK_MBUTTON] & 0x80)
|
||||
event->key.state |= GDK_BUTTON2_MASK;
|
||||
state |= GDK_BUTTON2_MASK;
|
||||
if (key_state[VK_RBUTTON] & 0x80)
|
||||
event->key.state |= GDK_BUTTON3_MASK;
|
||||
state |= GDK_BUTTON3_MASK;
|
||||
if (key_state[VK_XBUTTON1] & 0x80)
|
||||
event->key.state |= GDK_BUTTON4_MASK;
|
||||
state |= GDK_BUTTON4_MASK;
|
||||
if (key_state[VK_XBUTTON2] & 0x80)
|
||||
event->key.state |= GDK_BUTTON5_MASK;
|
||||
state |= GDK_BUTTON5_MASK;
|
||||
|
||||
keymap = GDK_WIN32_KEYMAP (_gdk_win32_display_get_keymap (_gdk_display));
|
||||
event->key.group = _gdk_win32_keymap_get_active_group (keymap);
|
||||
|
||||
if (_gdk_win32_keymap_has_altgr (keymap) &&
|
||||
(key_state[VK_LCONTROL] & 0x80) &&
|
||||
(key_state[VK_RMENU] & 0x80))
|
||||
{
|
||||
event->key.state |= GDK_MOD2_MASK;
|
||||
state |= GDK_MOD2_MASK;
|
||||
if (key_state[VK_RCONTROL] & 0x80)
|
||||
event->key.state |= GDK_CONTROL_MASK;
|
||||
state |= GDK_CONTROL_MASK;
|
||||
if (key_state[VK_LMENU] & 0x80)
|
||||
event->key.state |= GDK_MOD1_MASK;
|
||||
state |= GDK_MOD1_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key_state[VK_CONTROL] & 0x80)
|
||||
event->key.state |= GDK_CONTROL_MASK;
|
||||
state |= GDK_CONTROL_MASK;
|
||||
if (key_state[VK_MENU] & 0x80)
|
||||
event->key.state |= GDK_MOD1_MASK;
|
||||
state |= GDK_MOD1_MASK;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
static guint8
|
||||
get_active_group (void)
|
||||
{
|
||||
GdkWin32Keymap *keymap;
|
||||
|
||||
keymap = GDK_WIN32_KEYMAP (_gdk_win32_display_get_keymap (_gdk_display));
|
||||
|
||||
return _gdk_win32_keymap_get_active_group (keymap);
|
||||
}
|
||||
|
||||
static gint
|
||||
@ -727,20 +732,6 @@ build_pointer_event_state (MSG *msg)
|
||||
return state;
|
||||
}
|
||||
|
||||
static void
|
||||
build_wm_ime_composition_event (GdkEvent *event,
|
||||
MSG *msg,
|
||||
wchar_t wc,
|
||||
BYTE *key_state)
|
||||
{
|
||||
event->key.time = _gdk_win32_get_next_tick (msg->time);
|
||||
|
||||
build_key_event_state (event, key_state);
|
||||
|
||||
event->key.hardware_keycode = 0; /* FIXME: What should it be? */
|
||||
event->key.keyval = gdk_unicode_to_keyval (wc);
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
static void
|
||||
@ -764,17 +755,19 @@ print_event_state (guint state)
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_print_event (const GdkEvent *event)
|
||||
_gdk_win32_print_event (GdkEvent *event)
|
||||
{
|
||||
const char *kvname;
|
||||
double x, y;
|
||||
GdkCrossingMode mode;
|
||||
GdkNotifyType detail;
|
||||
GdkScrollDirection direction;
|
||||
|
||||
g_print ("%s%*s===> ", (debug_indent > 0 ? "\n" : ""), debug_indent, "");
|
||||
switch (event->any.type)
|
||||
switch (gdk_event_get_event_type (event))
|
||||
{
|
||||
#define CASE(x) case x: g_print (#x); break;
|
||||
CASE (GDK_NOTHING);
|
||||
CASE (GDK_DELETE);
|
||||
CASE (GDK_DESTROY);
|
||||
CASE (GDK_MOTION_NOTIFY);
|
||||
CASE (GDK_BUTTON_PRESS);
|
||||
CASE (GDK_BUTTON_RELEASE);
|
||||
@ -796,81 +789,72 @@ _gdk_win32_print_event (const GdkEvent *event)
|
||||
}
|
||||
|
||||
g_print (" %p @ %ums ",
|
||||
event->any.surface ? GDK_SURFACE_HWND (event->any.surface) : NULL,
|
||||
GDK_SURFACE_HWND (gdk_event_get_surface (event)),
|
||||
gdk_event_get_time (event));
|
||||
|
||||
switch (event->any.type)
|
||||
switch (gdk_event_get_event_type (event))
|
||||
{
|
||||
case GDK_MOTION_NOTIFY:
|
||||
g_print ("(%.4g,%.4g) (%.4g,%.4g)",
|
||||
event->motion.x, event->motion.y,
|
||||
event->motion.x_root, event->motion.y_root);
|
||||
print_event_state (event->motion.state);
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
g_print ("(%.4g,%.4g) ", x, y);
|
||||
print_event_state (gdk_event_get_modifier_state (event));
|
||||
break;
|
||||
case GDK_BUTTON_PRESS:
|
||||
case GDK_BUTTON_RELEASE:
|
||||
g_print ("%d (%.4g,%.4g) (%.4g,%.4g) ",
|
||||
event->button.button,
|
||||
event->button.x, event->button.y,
|
||||
event->button.x_root, event->button.y_root);
|
||||
print_event_state (event->button.state);
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
g_print ("%d (%.4g,%.4g) ", gdk_button_event_get_button (event), x, y);
|
||||
print_event_state (gdk_event_get_modifier_state (event));
|
||||
break;
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
kvname = gdk_keyval_name (event->key.keyval);
|
||||
kvname = gdk_keyval_name (gdk_key_event_get_keyval (event));
|
||||
g_print ("%#.02x group:%d %s",
|
||||
event->key.hardware_keycode, event->key.group,
|
||||
gdk_key_event_get_keycode (event),
|
||||
gdk_key_event_get_group (event),
|
||||
(kvname ? kvname : "??"));
|
||||
print_event_state (event->key.state);
|
||||
print_event_state (gdk_event_get_modifier_state (event));
|
||||
break;
|
||||
case GDK_ENTER_NOTIFY:
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
g_print ("%p (%.4g,%.4g) (%.4g,%.4g) %s %s%s",
|
||||
event->crossing.child_surface == NULL ? NULL : GDK_SURFACE_HWND (event->crossing.child_surface),
|
||||
event->crossing.x, event->crossing.y,
|
||||
event->crossing.x_root, event->crossing.y_root,
|
||||
(event->crossing.mode == GDK_CROSSING_NORMAL ? "NORMAL" :
|
||||
(event->crossing.mode == GDK_CROSSING_GRAB ? "GRAB" :
|
||||
(event->crossing.mode == GDK_CROSSING_UNGRAB ? "UNGRAB" :
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
mode = gdk_crossing_event_get_mode (event);
|
||||
detail = gdk_crossing_event_get_detail (event);
|
||||
g_print ("(%.4g,%.4g) %s %s",
|
||||
x, y,
|
||||
(mode == GDK_CROSSING_NORMAL ? "NORMAL" :
|
||||
(mode == GDK_CROSSING_GRAB ? "GRAB" :
|
||||
(mode == GDK_CROSSING_UNGRAB ? "UNGRAB" :
|
||||
"???"))),
|
||||
(event->crossing.detail == GDK_NOTIFY_ANCESTOR ? "ANCESTOR" :
|
||||
(event->crossing.detail == GDK_NOTIFY_VIRTUAL ? "VIRTUAL" :
|
||||
(event->crossing.detail == GDK_NOTIFY_INFERIOR ? "INFERIOR" :
|
||||
(event->crossing.detail == GDK_NOTIFY_NONLINEAR ? "NONLINEAR" :
|
||||
(event->crossing.detail == GDK_NOTIFY_NONLINEAR_VIRTUAL ? "NONLINEAR_VIRTUAL" :
|
||||
(event->crossing.detail == GDK_NOTIFY_UNKNOWN ? "UNKNOWN" :
|
||||
"???")))))),
|
||||
event->crossing.focus ? " FOCUS" : "");
|
||||
print_event_state (event->crossing.state);
|
||||
(detail == GDK_NOTIFY_ANCESTOR ? "ANCESTOR" :
|
||||
(detail == GDK_NOTIFY_VIRTUAL ? "VIRTUAL" :
|
||||
(detail == GDK_NOTIFY_INFERIOR ? "INFERIOR" :
|
||||
(detail == GDK_NOTIFY_NONLINEAR ? "NONLINEAR" :
|
||||
(detail == GDK_NOTIFY_NONLINEAR_VIRTUAL ? "NONLINEAR_VIRTUAL" :
|
||||
(detail == GDK_NOTIFY_UNKNOWN ? "UNKNOWN" :
|
||||
"???")))))));
|
||||
print_event_state (gdk_event_get_modifier_state (event));
|
||||
break;
|
||||
case GDK_FOCUS_CHANGE:
|
||||
g_print ("%s", (event->focus_change.in ? "IN" : "OUT"));
|
||||
g_print ("%s", (gdk_focus_event_get_in (event) ? "IN" : "OUT"));
|
||||
break;
|
||||
case GDK_DRAG_ENTER:
|
||||
case GDK_DRAG_LEAVE:
|
||||
case GDK_DRAG_MOTION:
|
||||
case GDK_DROP_START:
|
||||
if (event->dnd.drop != NULL)
|
||||
g_print ("ctx:%p: %s",
|
||||
event->dnd.drop,
|
||||
_gdk_win32_drag_protocol_to_string (GDK_WIN32_DRAG (event->dnd.drop)->protocol));
|
||||
g_print ("DND");
|
||||
break;
|
||||
case GDK_SCROLL:
|
||||
g_print ("(%.4g,%.4g) (%.4g,%.4g) %s ",
|
||||
event->scroll.x, event->scroll.y,
|
||||
event->scroll.x_root, event->scroll.y_root,
|
||||
(event->scroll.direction == GDK_SCROLL_UP ? "UP" :
|
||||
(event->scroll.direction == GDK_SCROLL_DOWN ? "DOWN" :
|
||||
(event->scroll.direction == GDK_SCROLL_LEFT ? "LEFT" :
|
||||
(event->scroll.direction == GDK_SCROLL_RIGHT ? "RIGHT" :
|
||||
direction = gdk_scroll_event_get_direction (event);
|
||||
g_print (" %s ",
|
||||
(direction == GDK_SCROLL_UP ? "UP" :
|
||||
(direction == GDK_SCROLL_DOWN ? "DOWN" :
|
||||
(direction == GDK_SCROLL_LEFT ? "LEFT" :
|
||||
(direction == GDK_SCROLL_RIGHT ? "RIGHT" :
|
||||
"???")))));
|
||||
print_event_state (event->scroll.state);
|
||||
print_event_state (gdk_event_get_modifier_state (event));
|
||||
break;
|
||||
case GDK_GRAB_BROKEN:
|
||||
g_print ("%s %s %p",
|
||||
(event->grab_broken.keyboard ? "KEYBOARD" : "POINTER"),
|
||||
(event->grab_broken.implicit ? "IMPLICIT" : "EXPLICIT"),
|
||||
(event->grab_broken.grab_surface ? GDK_SURFACE_HWND (event->grab_broken.grab_surface) : 0));
|
||||
g_print ("Grab broken");
|
||||
default:
|
||||
/* Nothing */
|
||||
break;
|
||||
@ -908,7 +892,6 @@ fixup_event (GdkEvent *event)
|
||||
(event->any.type == GDK_LEAVE_NOTIFY)) &&
|
||||
(event->crossing.child_surface != NULL))
|
||||
g_object_ref (event->crossing.child_surface);
|
||||
event->any.send_event = InSendMessage ();
|
||||
}
|
||||
|
||||
void
|
||||
@ -1098,23 +1081,17 @@ send_crossing_event (GdkDisplay *display,
|
||||
pt = *screen_pt;
|
||||
ScreenToClient (GDK_SURFACE_HWND (window), &pt);
|
||||
|
||||
event = gdk_event_new (type);
|
||||
event->any.surface = window;
|
||||
event->crossing.child_surface = subwindow;
|
||||
event->crossing.time = _gdk_win32_get_next_tick (time_);
|
||||
event->crossing.x = pt.x / impl->surface_scale;
|
||||
event->crossing.y = pt.y / impl->surface_scale;
|
||||
event->crossing.x_root = (screen_pt->x + _gdk_offset_x) / impl->surface_scale;
|
||||
event->crossing.y_root = (screen_pt->y + _gdk_offset_y) / impl->surface_scale;
|
||||
event->crossing.mode = mode;
|
||||
event->crossing.detail = notify_type;
|
||||
event->crossing.mode = mode;
|
||||
event->crossing.detail = notify_type;
|
||||
event->crossing.focus = FALSE;
|
||||
event->crossing.state = mask;
|
||||
gdk_event_set_device (event, device_manager->core_pointer);
|
||||
gdk_event_set_source_device (event, device_manager->system_pointer);
|
||||
|
||||
event = gdk_event_crossing_new (type,
|
||||
window,
|
||||
device_manager->core_pointer,
|
||||
device_manager->system_pointer,
|
||||
_gdk_win32_get_next_tick (time_),
|
||||
mask,
|
||||
pt.x / impl->surface_scale,
|
||||
pt.y / impl->surface_scale,
|
||||
mode,
|
||||
notify_type);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
}
|
||||
|
||||
@ -1601,7 +1578,7 @@ generate_button_event (GdkEventType type,
|
||||
GdkSurface *window,
|
||||
MSG *msg)
|
||||
{
|
||||
GdkEvent *event = gdk_event_new (type);
|
||||
GdkEvent *event;
|
||||
GdkDeviceManagerWin32 *device_manager;
|
||||
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
||||
|
||||
@ -1610,18 +1587,21 @@ generate_button_event (GdkEventType type,
|
||||
|
||||
device_manager = GDK_DEVICE_MANAGER_WIN32 (_gdk_device_manager);
|
||||
|
||||
event->any.surface = window;
|
||||
event->button.time = _gdk_win32_get_next_tick (msg->time);
|
||||
event->button.x = current_x = (gint16) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
event->button.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
event->button.x_root = (msg->pt.x + _gdk_offset_x) / impl->surface_scale;
|
||||
event->button.y_root = (msg->pt.y + _gdk_offset_y) / impl->surface_scale;
|
||||
event->button.axes = NULL;
|
||||
event->button.state = build_pointer_event_state (msg);
|
||||
event->button.button = button;
|
||||
gdk_event_set_device (event, device_manager->core_pointer);
|
||||
gdk_event_set_source_device (event, device_manager->system_pointer);
|
||||
current_x = (gint16) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
current_y = (gint16) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
|
||||
event = gdk_event_button_new (type,
|
||||
window,
|
||||
device_manager->core_pointer,
|
||||
device_manager->system_pointer,
|
||||
NULL,
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
build_pointer_event_state (msg),
|
||||
button,
|
||||
current_x,
|
||||
current_y,
|
||||
NULL);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
}
|
||||
|
||||
@ -2078,6 +2058,16 @@ gdk_event_translate (MSG *msg,
|
||||
|
||||
int i;
|
||||
|
||||
GdkModifierType state;
|
||||
guint keyval;
|
||||
guint16 keycode;
|
||||
guint16 scancode;
|
||||
guint8 group;
|
||||
gboolean is_modifier;
|
||||
|
||||
double delta_x, delta_y;
|
||||
GdkScrollDirection direction;
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
win32_display = GDK_WIN32_DISPLAY (display);
|
||||
|
||||
@ -2150,17 +2140,17 @@ gdk_event_translate (MSG *msg,
|
||||
gdk_display_setting_changed (display, "gtk-im-module");
|
||||
|
||||
/* Generate a dummy key event to "nudge" IMContext */
|
||||
event = gdk_event_new (GDK_KEY_PRESS);
|
||||
event->any.surface = window;
|
||||
event->key.time = _gdk_win32_get_next_tick (msg->time);
|
||||
event->key.keyval = GDK_KEY_VoidSymbol;
|
||||
event->key.hardware_keycode = 0;
|
||||
event->key.group = 0;
|
||||
gdk_event_set_scancode (event, 0);
|
||||
gdk_event_set_device (event, device_manager_win32->core_keyboard);
|
||||
gdk_event_set_source_device (event, device_manager_win32->system_keyboard);
|
||||
event->key.is_modifier = FALSE;
|
||||
event->key.state = 0;
|
||||
event = gdk_event_key_new (GDK_KEY_PRESS,
|
||||
window,
|
||||
device_manager_win32->core_keyboard,
|
||||
device_manager_win32->system_keyboard,
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
0,
|
||||
GDK_KEY_VoidSymbol,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
FALSE);
|
||||
_gdk_win32_append_event (event);
|
||||
break;
|
||||
|
||||
@ -2244,44 +2234,38 @@ gdk_event_translate (MSG *msg,
|
||||
}
|
||||
}
|
||||
|
||||
event = gdk_event_new ((msg->message == WM_KEYDOWN ||
|
||||
msg->message == WM_SYSKEYDOWN) ?
|
||||
GDK_KEY_PRESS : GDK_KEY_RELEASE);
|
||||
event->any.surface = window;
|
||||
event->key.time = _gdk_win32_get_next_tick (msg->time);
|
||||
event->key.keyval = GDK_KEY_VoidSymbol;
|
||||
event->key.hardware_keycode = msg->wParam;
|
||||
/* save original scancode */
|
||||
gdk_event_set_scancode (event, msg->lParam >> 16);
|
||||
gdk_event_set_device (event, device_manager_win32->core_keyboard);
|
||||
gdk_event_set_source_device (event, device_manager_win32->system_keyboard);
|
||||
keyval = GDK_KEY_VoidSymbol;
|
||||
keycode = msg->wParam;
|
||||
scancode = msg->lParam >> 16;
|
||||
|
||||
if (HIWORD (msg->lParam) & KF_EXTENDED)
|
||||
{
|
||||
switch (msg->wParam)
|
||||
{
|
||||
case VK_CONTROL:
|
||||
event->key.hardware_keycode = VK_RCONTROL;
|
||||
keycode = VK_RCONTROL;
|
||||
break;
|
||||
case VK_SHIFT: /* Actually, KF_EXTENDED is not set
|
||||
* for the right shift key.
|
||||
*/
|
||||
event->key.hardware_keycode = VK_RSHIFT;
|
||||
keycode = VK_RSHIFT;
|
||||
break;
|
||||
case VK_MENU:
|
||||
event->key.hardware_keycode = VK_RMENU;
|
||||
keycode = VK_RMENU;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (msg->wParam == VK_SHIFT &&
|
||||
LOBYTE (HIWORD (msg->lParam)) == _gdk_win32_keymap_get_rshift_scancode (GDK_WIN32_KEYMAP (_gdk_win32_display_get_keymap (_gdk_display))))
|
||||
event->key.hardware_keycode = VK_RSHIFT;
|
||||
keycode = VK_RSHIFT;
|
||||
|
||||
event->key.is_modifier = (msg->wParam == VK_CONTROL ||
|
||||
msg->wParam == VK_SHIFT ||
|
||||
msg->wParam == VK_MENU);
|
||||
is_modifier = (msg->wParam == VK_CONTROL ||
|
||||
msg->wParam == VK_SHIFT ||
|
||||
msg->wParam == VK_MENU);
|
||||
/* g_print ("ctrl:%02x lctrl:%02x rctrl:%02x alt:%02x lalt:%02x ralt:%02x\n", key_state[VK_CONTROL], key_state[VK_LCONTROL], key_state[VK_RCONTROL], key_state[VK_MENU], key_state[VK_LMENU], key_state[VK_RMENU]); */
|
||||
|
||||
build_key_event_state (event, key_state);
|
||||
state = build_key_event_state (key_state);
|
||||
group = get_active_group ();
|
||||
|
||||
if (msg->wParam == VK_PACKET && ccount == 1)
|
||||
{
|
||||
@ -2298,20 +2282,20 @@ gdk_event_translate (MSG *msg,
|
||||
else
|
||||
leading = impl->leading_surrogate_keyup;
|
||||
|
||||
event->key.keyval = gdk_unicode_to_keyval ((leading - 0xD800) * 0x400 + wbuf[0] - 0xDC00 + 0x10000);
|
||||
keyval = gdk_unicode_to_keyval ((leading - 0xD800) * 0x400 + wbuf[0] - 0xDC00 + 0x10000);
|
||||
}
|
||||
else
|
||||
{
|
||||
event->key.keyval = gdk_unicode_to_keyval (wbuf[0]);
|
||||
keyval = gdk_unicode_to_keyval (wbuf[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_keymap_translate_keyboard_state (_gdk_win32_display_get_keymap (display),
|
||||
event->key.hardware_keycode,
|
||||
event->key.state,
|
||||
event->key.group,
|
||||
&event->key.keyval,
|
||||
keycode,
|
||||
state,
|
||||
group,
|
||||
&keyval,
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
@ -2354,7 +2338,21 @@ gdk_event_translate (MSG *msg,
|
||||
|
||||
/* Reset MOD1_MASK if it is the Alt key itself */
|
||||
if (msg->wParam == VK_MENU)
|
||||
event->key.state &= ~GDK_MOD1_MASK;
|
||||
state &= ~GDK_MOD1_MASK;
|
||||
|
||||
event = gdk_event_key_new ((msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN)
|
||||
? GDK_KEY_PRESS
|
||||
: GDK_KEY_RELEASE,
|
||||
window,
|
||||
device_manager_win32->core_keyboard,
|
||||
device_manager_win32->system_keyboard,
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
state,
|
||||
keyval,
|
||||
keycode,
|
||||
scancode,
|
||||
group,
|
||||
is_modifier);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
|
||||
@ -2416,20 +2414,32 @@ gdk_event_translate (MSG *msg,
|
||||
for (i = 0; i < ccount; i++)
|
||||
{
|
||||
/* Build a key press event */
|
||||
event = gdk_event_new (GDK_KEY_PRESS);
|
||||
event->any.surface = window;
|
||||
gdk_event_set_device (event, device_manager_win32->core_keyboard);
|
||||
gdk_event_set_source_device (event, device_manager_win32->system_keyboard);
|
||||
build_wm_ime_composition_event (event, msg, wbuf[i], key_state);
|
||||
event = gdk_event_key_new (GDK_KEY_PRESS,
|
||||
window,
|
||||
device_manager_win32->core_keyboard,
|
||||
device_manager_win32->system_keyboard,
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
build_key_event_state (key_state),
|
||||
gdk_unicode_to_keyval (wbuf[i]),
|
||||
0,
|
||||
0,
|
||||
get_active_group (),
|
||||
FALSE);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
|
||||
/* Build a key release event. */
|
||||
event = gdk_event_new (GDK_KEY_RELEASE);
|
||||
event->any.surface = window;
|
||||
gdk_event_set_device (event, device_manager_win32->core_keyboard);
|
||||
gdk_event_set_source_device (event, device_manager_win32->system_keyboard);
|
||||
build_wm_ime_composition_event (event, msg, wbuf[i], key_state);
|
||||
event = gdk_event_key_new (GDK_KEY_RELEASE,
|
||||
window,
|
||||
device_manager_win32->core_keyboard,
|
||||
device_manager_win32->system_keyboard,
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
build_key_event_state (key_state),
|
||||
gdk_unicode_to_keyval (wbuf[i]),
|
||||
0,
|
||||
0,
|
||||
get_active_group (),
|
||||
FALSE);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
}
|
||||
@ -2631,17 +2641,18 @@ gdk_event_translate (MSG *msg,
|
||||
}
|
||||
else if (_gdk_input_ignore_core == 0)
|
||||
{
|
||||
event = gdk_event_new (GDK_MOTION_NOTIFY);
|
||||
event->any.surface = window;
|
||||
event->motion.time = _gdk_win32_get_next_tick (msg->time);
|
||||
event->motion.x = current_x = (gint16) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
event->motion.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
event->motion.x_root = current_root_x;
|
||||
event->motion.y_root = current_root_y;
|
||||
event->motion.axes = NULL;
|
||||
event->motion.state = build_pointer_event_state (msg);
|
||||
gdk_event_set_device (event, device_manager_win32->core_pointer);
|
||||
gdk_event_set_source_device (event, device_manager_win32->system_pointer);
|
||||
current_x = (gint16) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
current_y = (gint16) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
|
||||
event = gdk_event_motion_new (window,
|
||||
device_manager_win32->core_pointer,
|
||||
device_manager_win32->system_pointer,
|
||||
NULL,
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
build_pointer_event_state (msg),
|
||||
current_x,
|
||||
current_y,
|
||||
NULL);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
}
|
||||
@ -2748,44 +2759,48 @@ gdk_event_translate (MSG *msg,
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
ScreenToClient (msg->hwnd, &point);
|
||||
|
||||
event = gdk_event_new (GDK_SCROLL);
|
||||
event->any.surface = window;
|
||||
event->scroll.direction = GDK_SCROLL_SMOOTH;
|
||||
delta_x = delta_y = 0.0;
|
||||
|
||||
if (msg->message == WM_MOUSEWHEEL)
|
||||
{
|
||||
event->scroll.delta_y = (gdouble) GET_WHEEL_DELTA_WPARAM (msg->wParam) / (gdouble) WHEEL_DELTA;
|
||||
}
|
||||
delta_y = (double) GET_WHEEL_DELTA_WPARAM (msg->wParam) / (gdouble) WHEEL_DELTA;
|
||||
else if (msg->message == WM_MOUSEHWHEEL)
|
||||
{
|
||||
event->scroll.delta_x = (gdouble) GET_WHEEL_DELTA_WPARAM (msg->wParam) / (gdouble) WHEEL_DELTA;
|
||||
}
|
||||
delta_x = (double) GET_WHEEL_DELTA_WPARAM (msg->wParam) / (gdouble) WHEEL_DELTA;
|
||||
/* Positive delta scrolls up, not down,
|
||||
see API documentation for WM_MOUSEWHEEL message.
|
||||
*/
|
||||
event->scroll.delta_y *= -1.0;
|
||||
event->scroll.time = _gdk_win32_get_next_tick (msg->time);
|
||||
event->scroll.x = (gint16) point.x / impl->surface_scale;
|
||||
event->scroll.y = (gint16) point.y / impl->surface_scale;
|
||||
event->scroll.x_root = ((gint16) GET_X_LPARAM (msg->lParam) + _gdk_offset_x) / impl->surface_scale;
|
||||
event->scroll.y_root = ((gint16) GET_Y_LPARAM (msg->lParam) + _gdk_offset_y) / impl->surface_scale;
|
||||
event->scroll.state = build_pointer_event_state (msg);
|
||||
gdk_event_set_device (event, device_manager_win32->core_pointer);
|
||||
gdk_event_set_source_device (event, device_manager_win32->system_pointer);
|
||||
gdk_event_set_pointer_emulated (event, FALSE);
|
||||
delta_y *= -1.0;
|
||||
|
||||
_gdk_win32_append_event (gdk_event_copy (event));
|
||||
event = gdk_event_scroll_new (window,
|
||||
device_manager_win32->core_pointer,
|
||||
device_manager_win32->system_pointer,
|
||||
NULL,
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
build_pointer_event_state (msg),
|
||||
delta_x,
|
||||
delta_y,
|
||||
FALSE);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
|
||||
/* Append the discrete version too */
|
||||
direction = 0;
|
||||
if (msg->message == WM_MOUSEWHEEL)
|
||||
event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ?
|
||||
GDK_SCROLL_UP : GDK_SCROLL_DOWN;
|
||||
direction = (((short) HIWORD (msg->wParam)) > 0)
|
||||
? GDK_SCROLL_UP
|
||||
: GDK_SCROLL_DOWN;
|
||||
else if (msg->message == WM_MOUSEHWHEEL)
|
||||
event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ?
|
||||
GDK_SCROLL_RIGHT : GDK_SCROLL_LEFT;
|
||||
event->scroll.delta_x = 0;
|
||||
event->scroll.delta_y = 0;
|
||||
gdk_event_set_pointer_emulated (event, TRUE);
|
||||
direction = (((short) HIWORD (msg->wParam)) > 0)
|
||||
? GDK_SCROLL_RIGHT
|
||||
: GDK_SCROLL_LEFT;
|
||||
|
||||
event = gdk_event_discrete_scroll_new (window,
|
||||
device_manager_win32->core_pointer,
|
||||
device_manager_win32->system_pointer,
|
||||
NULL,
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
build_pointer_event_state (msg),
|
||||
direction,
|
||||
TRUE);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
|
||||
@ -3414,8 +3429,7 @@ gdk_event_translate (MSG *msg,
|
||||
if (GDK_SURFACE_DESTROYED (window))
|
||||
break;
|
||||
|
||||
event = gdk_event_new (GDK_DELETE);
|
||||
event->any.surface = window;
|
||||
event = gdk_event_delete_new (window);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
|
||||
@ -3449,8 +3463,7 @@ gdk_event_translate (MSG *msg,
|
||||
if (window == NULL || GDK_SURFACE_DESTROYED (window))
|
||||
break;
|
||||
|
||||
event = gdk_event_new (GDK_DESTROY);
|
||||
event->any.surface = window;
|
||||
event = gdk_event_delete_new (window);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
|
||||
@ -3563,14 +3576,12 @@ gdk_event_translate (MSG *msg,
|
||||
/* Fall through */
|
||||
wintab:
|
||||
|
||||
event = gdk_event_new (GDK_NOTHING);
|
||||
event->any.surface = window;
|
||||
g_object_ref (window);
|
||||
|
||||
if (gdk_input_other_event (display, event, msg, window))
|
||||
_gdk_win32_append_event (event);
|
||||
else
|
||||
g_object_unref (event);
|
||||
event = gdk_input_other_event (display, msg, window);
|
||||
if (event)
|
||||
{
|
||||
_gdk_win32_append_event (event);
|
||||
gdk_event_unref (event);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@ -3651,7 +3662,7 @@ gdk_event_dispatch (GSource *source,
|
||||
{
|
||||
_gdk_event_emit (event);
|
||||
|
||||
g_object_unref (event);
|
||||
gdk_event_unref (event);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -236,7 +236,7 @@ gchar *_gdk_win32_rect_to_string (const RECT *rect);
|
||||
gchar *_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect);
|
||||
gchar *_gdk_win32_cairo_region_to_string (const cairo_region_t *box);
|
||||
|
||||
void _gdk_win32_print_event (const GdkEvent *event);
|
||||
void _gdk_win32_print_event (GdkEvent *event);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -4969,7 +4969,7 @@ gdk_win32_surface_show_window_menu (GdkSurface *window,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gdk_event_get_coords (event, &event_x, &event_y);
|
||||
gdk_event_get_position (event, &event_x, &event_y);
|
||||
x = round (event_x);
|
||||
y = round (event_y);
|
||||
|
||||
|
@ -114,10 +114,9 @@ static void gdk_x11_device_manager_xi2_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static gboolean gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
GdkDisplay *display,
|
||||
GdkEvent *event,
|
||||
const XEvent *xevent);
|
||||
static GdkEvent * gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
GdkDisplay *display,
|
||||
const XEvent *xevent);
|
||||
static GdkEventMask gdk_x11_device_manager_xi2_get_handled_events (GdkEventTranslator *translator);
|
||||
static void gdk_x11_device_manager_xi2_select_surface_events (GdkEventTranslator *translator,
|
||||
Window window,
|
||||
@ -1184,7 +1183,7 @@ set_user_time (GdkEvent *event)
|
||||
GdkSurface *surface;
|
||||
guint32 time;
|
||||
|
||||
surface = event->any.surface;
|
||||
surface = gdk_event_get_surface (event);
|
||||
g_return_if_fail (GDK_IS_SURFACE (surface));
|
||||
|
||||
time = gdk_event_get_time (event);
|
||||
@ -1457,51 +1456,45 @@ _gdk_device_manager_xi2_handle_focus (GdkSurface *surface,
|
||||
{
|
||||
GdkEvent *event;
|
||||
|
||||
event = gdk_event_new (GDK_FOCUS_CHANGE);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->any.send_event = FALSE;
|
||||
event->focus_change.in = focus_in;
|
||||
gdk_event_set_device (event, device);
|
||||
if (source_device)
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
|
||||
event = gdk_event_focus_new (surface, device, source_device, focus_in);
|
||||
gdk_display_put_event (gdk_surface_get_display (surface), event);
|
||||
g_object_unref (event);
|
||||
gdk_event_unref (event);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static GdkEvent *
|
||||
gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
GdkDisplay *display,
|
||||
GdkEvent *event,
|
||||
const XEvent *xevent)
|
||||
{
|
||||
GdkX11DeviceManagerXI2 *device_manager;
|
||||
const XGenericEventCookie *cookie;
|
||||
GdkDevice *device, *source_device;
|
||||
gboolean return_val = TRUE;
|
||||
GdkSurface *surface;
|
||||
GdkX11Surface *impl;
|
||||
int scale;
|
||||
XIEvent *ev;
|
||||
GdkEvent *event;
|
||||
|
||||
event = NULL;
|
||||
|
||||
device_manager = (GdkX11DeviceManagerXI2 *) translator;
|
||||
cookie = &xevent->xcookie;
|
||||
|
||||
if (xevent->type != GenericEvent ||
|
||||
cookie->extension != device_manager->opcode)
|
||||
return FALSE;
|
||||
return event;
|
||||
|
||||
ev = (XIEvent *) cookie->data;
|
||||
|
||||
if (!ev)
|
||||
return FALSE;
|
||||
return NULL;
|
||||
|
||||
if (!get_event_surface (translator, ev, &surface))
|
||||
return FALSE;
|
||||
return NULL;
|
||||
|
||||
if (surface && GDK_SURFACE_DESTROYED (surface))
|
||||
return FALSE;
|
||||
return NULL;
|
||||
|
||||
scale = 1;
|
||||
if (surface)
|
||||
@ -1514,7 +1507,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
ev->evtype == XI_ButtonRelease)
|
||||
{
|
||||
if (_gdk_x11_moveresize_handle_event (xevent))
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (ev->evtype)
|
||||
@ -1522,17 +1515,14 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
case XI_HierarchyChanged:
|
||||
handle_hierarchy_changed (device_manager,
|
||||
(XIHierarchyEvent *) ev);
|
||||
return_val = FALSE;
|
||||
break;
|
||||
case XI_DeviceChanged:
|
||||
handle_device_changed (device_manager,
|
||||
(XIDeviceChangedEvent *) ev);
|
||||
return_val = FALSE;
|
||||
break;
|
||||
case XI_PropertyEvent:
|
||||
handle_property_change (device_manager,
|
||||
(XIPropertyEvent *) ev);
|
||||
return_val = FALSE;
|
||||
break;
|
||||
case XI_KeyPress:
|
||||
case XI_KeyRelease:
|
||||
@ -1540,6 +1530,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
XIDeviceEvent *xev = (XIDeviceEvent *) ev;
|
||||
GdkKeymap *keymap = gdk_display_get_keymap (display);
|
||||
GdkModifierType consumed, state;
|
||||
guint keyval;
|
||||
|
||||
GDK_DISPLAY_NOTE (display, EVENTS,
|
||||
g_message ("key %s:\twindow %ld\n"
|
||||
@ -1552,38 +1543,39 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
xev->sourceid,
|
||||
xev->detail));
|
||||
|
||||
event->any.type = xev->evtype == XI_KeyPress ? GDK_KEY_PRESS : GDK_KEY_RELEASE;
|
||||
|
||||
event->any.surface = surface;
|
||||
|
||||
event->key.time = xev->time;
|
||||
event->key.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
event->key.group = xev->group.effective;
|
||||
|
||||
event->key.hardware_keycode = xev->detail;
|
||||
gdk_event_set_scancode (event, xev->detail);
|
||||
event->key.is_modifier = gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
|
||||
state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
|
||||
device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->deviceid));
|
||||
gdk_event_set_device (event, device);
|
||||
|
||||
source_device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->sourceid));
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
|
||||
event->key.keyval = GDK_KEY_VoidSymbol;
|
||||
keyval = GDK_KEY_VoidSymbol;
|
||||
|
||||
gdk_keymap_translate_keyboard_state (keymap,
|
||||
event->key.hardware_keycode,
|
||||
event->key.state,
|
||||
event->key.group,
|
||||
&event->key.keyval,
|
||||
xev->detail,
|
||||
state,
|
||||
xev->group.effective,
|
||||
&keyval,
|
||||
NULL, NULL, &consumed);
|
||||
|
||||
state = event->key.state & ~consumed;
|
||||
state &= ~consumed;
|
||||
_gdk_x11_keymap_add_virt_mods (keymap, &state);
|
||||
event->key.state |= state;
|
||||
|
||||
event = gdk_event_key_new (xev->evtype == XI_KeyPress
|
||||
? GDK_KEY_PRESS
|
||||
: GDK_KEY_RELEASE,
|
||||
surface,
|
||||
device,
|
||||
source_device,
|
||||
xev->time,
|
||||
state,
|
||||
keyval,
|
||||
xev->detail,
|
||||
xev->detail,
|
||||
xev->group.effective,
|
||||
gdk_x11_keymap_key_is_modifier (keymap, xev->detail));
|
||||
|
||||
if (ev->evtype == XI_KeyPress)
|
||||
set_user_time (event);
|
||||
@ -1623,80 +1615,78 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
else if (ev->evtype == XI_ButtonPress &&
|
||||
(xev->detail >= 4 && xev->detail <= 7))
|
||||
{
|
||||
GdkScrollDirection direction;
|
||||
|
||||
/* Button presses of button 4-7 are scroll events */
|
||||
event->any.type = GDK_SCROLL;
|
||||
|
||||
if (xev->detail == 4)
|
||||
event->scroll.direction = GDK_SCROLL_UP;
|
||||
direction = GDK_SCROLL_UP;
|
||||
else if (xev->detail == 5)
|
||||
event->scroll.direction = GDK_SCROLL_DOWN;
|
||||
direction = GDK_SCROLL_DOWN;
|
||||
else if (xev->detail == 6)
|
||||
event->scroll.direction = GDK_SCROLL_LEFT;
|
||||
direction = GDK_SCROLL_LEFT;
|
||||
else
|
||||
event->scroll.direction = GDK_SCROLL_RIGHT;
|
||||
|
||||
event->any.surface = surface;
|
||||
event->scroll.time = xev->time;
|
||||
event->scroll.x = (gdouble) xev->event_x / scale;
|
||||
event->scroll.y = (gdouble) xev->event_y / scale;
|
||||
event->scroll.x_root = (gdouble) xev->root_x / scale;
|
||||
event->scroll.y_root = (gdouble) xev->root_y / scale;
|
||||
event->scroll.delta_x = 0;
|
||||
event->scroll.delta_y = 0;
|
||||
direction = GDK_SCROLL_RIGHT;
|
||||
|
||||
device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->deviceid));
|
||||
gdk_event_set_device (event, device);
|
||||
|
||||
source_device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->sourceid));
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
|
||||
event->scroll.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
event = gdk_event_discrete_scroll_new (surface,
|
||||
device,
|
||||
source_device,
|
||||
NULL,
|
||||
xev->time,
|
||||
_gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group),
|
||||
direction,
|
||||
FALSE);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
event->any.type = (ev->evtype == XI_ButtonPress) ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE;
|
||||
|
||||
event->any.surface = surface;
|
||||
event->button.time = xev->time;
|
||||
event->button.x = (gdouble) xev->event_x / scale;
|
||||
event->button.y = (gdouble) xev->event_y / scale;
|
||||
event->button.x_root = (gdouble) xev->root_x / scale;
|
||||
event->button.y_root = (gdouble) xev->root_y / scale;
|
||||
double x, y;
|
||||
double *axes;
|
||||
|
||||
device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->deviceid));
|
||||
gdk_event_set_device (event, device);
|
||||
|
||||
source_device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->sourceid));
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
gdk_event_set_device_tool (event, source_device->last_tool);
|
||||
|
||||
event->button.axes = translate_axes (device,
|
||||
event->button.x,
|
||||
event->button.y,
|
||||
event->any.surface,
|
||||
&xev->valuators);
|
||||
axes = translate_axes (device,
|
||||
(double) xev->event_x / scale,
|
||||
(double) xev->event_y / scale,
|
||||
surface,
|
||||
&xev->valuators);
|
||||
|
||||
if (gdk_device_get_mode (device) == GDK_MODE_SURFACE)
|
||||
{
|
||||
/* Update event coordinates from axes */
|
||||
gdk_device_get_axis (device, event->button.axes, GDK_AXIS_X, &event->button.x);
|
||||
gdk_device_get_axis (device, event->button.axes, GDK_AXIS_Y, &event->button.y);
|
||||
gdk_device_get_axis (device, axes, GDK_AXIS_X, &x);
|
||||
gdk_device_get_axis (device, axes, GDK_AXIS_Y, &y);
|
||||
}
|
||||
else
|
||||
{
|
||||
x = (double) xev->event_x / scale;
|
||||
y = (double) xev->event_y / scale;
|
||||
}
|
||||
|
||||
event->button.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
|
||||
event->button.button = xev->detail;
|
||||
event = gdk_event_button_new (ev->evtype == XI_ButtonPress
|
||||
? GDK_BUTTON_PRESS
|
||||
: GDK_BUTTON_RELEASE,
|
||||
surface,
|
||||
device,
|
||||
source_device,
|
||||
source_device->last_tool,
|
||||
xev->time,
|
||||
_gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group),
|
||||
xev->detail,
|
||||
x, y,
|
||||
axes);
|
||||
}
|
||||
|
||||
if (return_val == FALSE)
|
||||
break;
|
||||
|
||||
gdk_event_set_display (event, display);
|
||||
|
||||
if (ev->evtype == XI_ButtonPress)
|
||||
set_user_time (event);
|
||||
|
||||
@ -1708,6 +1698,9 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
XIDeviceEvent *xev = (XIDeviceEvent *) ev;
|
||||
gdouble delta_x, delta_y;
|
||||
|
||||
double x, y;
|
||||
double *axes;
|
||||
|
||||
#ifdef XINPUT_2_2
|
||||
if (xev->flags & XIPointerEmulated)
|
||||
return FALSE;
|
||||
@ -1730,60 +1723,50 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
scroll_valuators_changed (GDK_X11_DEVICE_XI2 (source_device),
|
||||
&xev->valuators, &delta_x, &delta_y))
|
||||
{
|
||||
event->any.type = GDK_SCROLL;
|
||||
event->scroll.direction = GDK_SCROLL_SMOOTH;
|
||||
|
||||
if (delta_x == 0.0 && delta_y == 0.0)
|
||||
event->scroll.is_stop = TRUE;
|
||||
|
||||
GDK_DISPLAY_NOTE (display, EVENTS,
|
||||
g_message ("smooth scroll: \n\tdevice: %u\n\tsource device: %u\n\twindow %ld\n\tdeltas: %f %f",
|
||||
xev->deviceid, xev->sourceid,
|
||||
xev->event, delta_x, delta_y));
|
||||
|
||||
|
||||
event->any.surface = surface;
|
||||
event->scroll.time = xev->time;
|
||||
event->scroll.x = (gdouble) xev->event_x / scale;
|
||||
event->scroll.y = (gdouble) xev->event_y / scale;
|
||||
event->scroll.x_root = (gdouble) xev->root_x / scale;
|
||||
event->scroll.y_root = (gdouble) xev->root_y / scale;
|
||||
event->scroll.delta_x = delta_x;
|
||||
event->scroll.delta_y = delta_y;
|
||||
|
||||
gdk_event_set_device (event, device);
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
|
||||
event->scroll.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
event = gdk_event_scroll_new (surface,
|
||||
device,
|
||||
source_device,
|
||||
NULL,
|
||||
xev->time,
|
||||
_gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group),
|
||||
delta_x,
|
||||
delta_y,
|
||||
delta_x == 0.0 && delta_y == 0.0);
|
||||
break;
|
||||
}
|
||||
|
||||
event->any.type = GDK_MOTION_NOTIFY;
|
||||
event->any.surface = surface;
|
||||
event->motion.time = xev->time;
|
||||
event->motion.x = (gdouble) xev->event_x / scale;
|
||||
event->motion.y = (gdouble) xev->event_y / scale;
|
||||
event->motion.x_root = (gdouble) xev->root_x / scale;
|
||||
event->motion.y_root = (gdouble) xev->root_y / scale;
|
||||
|
||||
gdk_event_set_device (event, device);
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
gdk_event_set_device_tool (event, source_device->last_tool);
|
||||
|
||||
event->motion.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
|
||||
event->motion.axes = translate_axes (device,
|
||||
event->motion.x,
|
||||
event->motion.y,
|
||||
event->any.surface,
|
||||
&xev->valuators);
|
||||
axes = translate_axes (device,
|
||||
(double) xev->event_x / scale,
|
||||
(double) xev->event_y / scale,
|
||||
surface,
|
||||
&xev->valuators);
|
||||
|
||||
if (gdk_device_get_mode (device) == GDK_MODE_SURFACE)
|
||||
{
|
||||
/* Update event coordinates from axes */
|
||||
gdk_device_get_axis (device, event->motion.axes, GDK_AXIS_X, &event->motion.x);
|
||||
gdk_device_get_axis (device, event->motion.axes, GDK_AXIS_Y, &event->motion.y);
|
||||
gdk_device_get_axis (device, axes, GDK_AXIS_X, &x);
|
||||
gdk_device_get_axis (device, axes, GDK_AXIS_Y, &y);
|
||||
}
|
||||
else
|
||||
{
|
||||
x = (double) xev->event_x / scale;
|
||||
y = (double) xev->event_y / scale;
|
||||
}
|
||||
|
||||
event = gdk_event_motion_new (surface,
|
||||
device,
|
||||
source_device,
|
||||
source_device->last_tool,
|
||||
xev->time,
|
||||
_gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group),
|
||||
x, y,
|
||||
axes);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1792,6 +1775,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
case XI_TouchEnd:
|
||||
{
|
||||
XIDeviceEvent *xev = (XIDeviceEvent *) ev;
|
||||
GdkModifierType state;
|
||||
|
||||
double x, y;
|
||||
double *axes;
|
||||
|
||||
GDK_DISPLAY_NOTE (display, EVENTS,
|
||||
g_message ("touch %s:\twindow %ld\n\ttouch id: %u\n\tpointer emulating: %s",
|
||||
@ -1800,56 +1787,45 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
xev->detail,
|
||||
xev->flags & XITouchEmulatingPointer ? "true" : "false"));
|
||||
|
||||
if (ev->evtype == XI_TouchBegin)
|
||||
event->any.type = GDK_TOUCH_BEGIN;
|
||||
else if (ev->evtype == XI_TouchEnd)
|
||||
event->any.type = GDK_TOUCH_END;
|
||||
|
||||
event->any.surface = surface;
|
||||
event->touch.time = xev->time;
|
||||
event->touch.x = (gdouble) xev->event_x / scale;
|
||||
event->touch.y = (gdouble) xev->event_y / scale;
|
||||
event->touch.x_root = (gdouble) xev->root_x / scale;
|
||||
event->touch.y_root = (gdouble) xev->root_y / scale;
|
||||
|
||||
device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->deviceid));
|
||||
gdk_event_set_device (event, device);
|
||||
|
||||
source_device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->sourceid));
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
|
||||
event->touch.axes = translate_axes (device,
|
||||
event->touch.x,
|
||||
event->touch.y,
|
||||
event->any.surface,
|
||||
&xev->valuators);
|
||||
state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
if (ev->evtype == XI_TouchBegin)
|
||||
state |= GDK_BUTTON1_MASK;
|
||||
|
||||
axes = translate_axes (device,
|
||||
(double) xev->event_x / scale,
|
||||
(double) xev->event_y / scale,
|
||||
surface,
|
||||
&xev->valuators);
|
||||
|
||||
if (gdk_device_get_mode (device) == GDK_MODE_SURFACE)
|
||||
{
|
||||
/* Update event coordinates from axes */
|
||||
gdk_device_get_axis (device, event->touch.axes, GDK_AXIS_X, &event->touch.x);
|
||||
gdk_device_get_axis (device, event->touch.axes, GDK_AXIS_Y, &event->touch.y);
|
||||
gdk_device_get_axis (device, axes, GDK_AXIS_X, &x);
|
||||
gdk_device_get_axis (device, axes, GDK_AXIS_Y, &y);
|
||||
}
|
||||
|
||||
event->touch.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
|
||||
if (ev->evtype == XI_TouchBegin)
|
||||
event->touch.state |= GDK_BUTTON1_MASK;
|
||||
|
||||
event->touch.sequence = GUINT_TO_POINTER (xev->detail);
|
||||
|
||||
if (xev->flags & XITouchEmulatingPointer)
|
||||
else
|
||||
{
|
||||
event->touch.emulating_pointer = TRUE;
|
||||
gdk_event_set_pointer_emulated (event, TRUE);
|
||||
x = (double) xev->event_x / scale;
|
||||
y = (double) xev->event_y / scale;
|
||||
}
|
||||
|
||||
if (return_val == FALSE)
|
||||
break;
|
||||
|
||||
gdk_event_set_display (event, display);
|
||||
event = gdk_event_touch_new (ev->evtype == XI_TouchBegin
|
||||
? GDK_TOUCH_BEGIN
|
||||
: GDK_TOUCH_END,
|
||||
GUINT_TO_POINTER (xev->detail),
|
||||
surface,
|
||||
device,
|
||||
source_device,
|
||||
xev->time,
|
||||
state,
|
||||
x, y,
|
||||
axes,
|
||||
xev->flags & XITouchEmulatingPointer);
|
||||
|
||||
if (ev->evtype == XI_TouchBegin)
|
||||
set_user_time (event);
|
||||
@ -1859,6 +1835,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
case XI_TouchUpdate:
|
||||
{
|
||||
XIDeviceEvent *xev = (XIDeviceEvent *) ev;
|
||||
GdkModifierType state;
|
||||
|
||||
double x, y;
|
||||
double *axes;
|
||||
|
||||
GDK_DISPLAY_NOTE (display, EVENTS,
|
||||
g_message ("touch update:\twindow %ld\n\ttouch id: %u\n\tpointer emulating: %s",
|
||||
@ -1866,45 +1846,43 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
xev->detail,
|
||||
xev->flags & XITouchEmulatingPointer ? "true" : "false"));
|
||||
|
||||
event->any.surface = surface;
|
||||
event->touch.sequence = GUINT_TO_POINTER (xev->detail);
|
||||
event->any.type = GDK_TOUCH_UPDATE;
|
||||
event->touch.time = xev->time;
|
||||
event->touch.x = (gdouble) xev->event_x / scale;
|
||||
event->touch.y = (gdouble) xev->event_y / scale;
|
||||
event->touch.x_root = (gdouble) xev->root_x / scale;
|
||||
event->touch.y_root = (gdouble) xev->root_y / scale;
|
||||
|
||||
device = g_hash_table_lookup (device_manager->id_table,
|
||||
GINT_TO_POINTER (xev->deviceid));
|
||||
gdk_event_set_device (event, device);
|
||||
|
||||
source_device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->sourceid));
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
|
||||
event->touch.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
state |= GDK_BUTTON1_MASK;
|
||||
|
||||
event->touch.state |= GDK_BUTTON1_MASK;
|
||||
|
||||
if (xev->flags & XITouchEmulatingPointer)
|
||||
{
|
||||
event->touch.emulating_pointer = TRUE;
|
||||
gdk_event_set_pointer_emulated (event, TRUE);
|
||||
}
|
||||
|
||||
event->touch.axes = translate_axes (device,
|
||||
event->touch.x,
|
||||
event->touch.y,
|
||||
event->any.surface,
|
||||
&xev->valuators);
|
||||
axes = translate_axes (device,
|
||||
(double) xev->event_x / scale,
|
||||
(double) xev->event_y / scale,
|
||||
surface,
|
||||
&xev->valuators);
|
||||
|
||||
if (gdk_device_get_mode (device) == GDK_MODE_SURFACE)
|
||||
{
|
||||
/* Update event coordinates from axes */
|
||||
gdk_device_get_axis (device, event->touch.axes, GDK_AXIS_X, &event->touch.x);
|
||||
gdk_device_get_axis (device, event->touch.axes, GDK_AXIS_Y, &event->touch.y);
|
||||
gdk_device_get_axis (device, axes, GDK_AXIS_X, &x);
|
||||
gdk_device_get_axis (device, axes, GDK_AXIS_Y, &y);
|
||||
}
|
||||
else
|
||||
{
|
||||
x = (double) xev->event_x / scale;
|
||||
y = (double) xev->event_y / scale;
|
||||
}
|
||||
|
||||
event = gdk_event_touch_new (GDK_TOUCH_UPDATE,
|
||||
GUINT_TO_POINTER (xev->detail),
|
||||
surface,
|
||||
device,
|
||||
source_device,
|
||||
xev->time,
|
||||
state,
|
||||
x, y,
|
||||
axes,
|
||||
xev->flags & XITouchEmulatingPointer);
|
||||
}
|
||||
break;
|
||||
#endif /* XINPUT_2_2 */
|
||||
@ -1923,25 +1901,11 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
xev->deviceid, xev->sourceid,
|
||||
xev->detail, xev->mode));
|
||||
|
||||
event->any.type = (ev->evtype == XI_Enter) ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY;
|
||||
|
||||
event->crossing.x = (gdouble) xev->event_x / scale;
|
||||
event->crossing.y = (gdouble) xev->event_y / scale;
|
||||
event->crossing.x_root = (gdouble) xev->root_x / scale;
|
||||
event->crossing.y_root = (gdouble) xev->root_y / scale;
|
||||
event->crossing.time = xev->time;
|
||||
event->crossing.focus = xev->focus;
|
||||
|
||||
event->any.surface = surface;
|
||||
event->crossing.child_surface = gdk_x11_surface_lookup_for_display (display, xev->child);
|
||||
|
||||
device = g_hash_table_lookup (device_manager->id_table,
|
||||
GINT_TO_POINTER (xev->deviceid));
|
||||
gdk_event_set_device (event, device);
|
||||
|
||||
source_device = g_hash_table_lookup (device_manager->id_table,
|
||||
GUINT_TO_POINTER (xev->sourceid));
|
||||
gdk_event_set_source_device (event, source_device);
|
||||
|
||||
if (ev->evtype == XI_Enter &&
|
||||
xev->detail != XINotifyInferior && xev->mode != XINotifyPassiveUngrab &&
|
||||
@ -1962,9 +1926,19 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
}
|
||||
}
|
||||
|
||||
event->crossing.mode = translate_crossing_mode (xev->mode);
|
||||
event->crossing.detail = translate_notify_type (xev->detail);
|
||||
event->crossing.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
|
||||
event = gdk_event_crossing_new (ev->evtype == XI_Enter
|
||||
? GDK_ENTER_NOTIFY
|
||||
: GDK_LEAVE_NOTIFY,
|
||||
surface,
|
||||
device,
|
||||
source_device,
|
||||
xev->time,
|
||||
_gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group),
|
||||
(double) xev->event_x / scale,
|
||||
(double) xev->event_y / scale,
|
||||
translate_crossing_mode (xev->mode),
|
||||
translate_notify_type (xev->detail));
|
||||
|
||||
}
|
||||
break;
|
||||
case XI_FocusIn:
|
||||
@ -1988,35 +1962,13 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
xev->detail,
|
||||
xev->mode);
|
||||
}
|
||||
|
||||
return_val = FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return_val = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
event->any.send_event = cookie->send_event;
|
||||
|
||||
if (return_val)
|
||||
{
|
||||
if (event->any.surface)
|
||||
g_object_ref (event->any.surface);
|
||||
|
||||
if (((event->any.type == GDK_ENTER_NOTIFY) ||
|
||||
(event->any.type == GDK_LEAVE_NOTIFY)) &&
|
||||
(event->crossing.child_surface != NULL))
|
||||
g_object_ref (event->crossing.child_surface);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Mark this event as having no resources to be freed */
|
||||
event->any.surface = NULL;
|
||||
event->any.type = GDK_NOTHING;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
return event;
|
||||
}
|
||||
|
||||
static GdkEventMask
|
||||
|
@ -106,10 +106,9 @@ static void gdk_x11_display_finalize (GObject *object);
|
||||
|
||||
static void gdk_x11_display_event_translator_init (GdkEventTranslatorIface *iface);
|
||||
|
||||
static gboolean gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
GdkDisplay *display,
|
||||
GdkEvent *event,
|
||||
const XEvent *xevent);
|
||||
static GdkEvent * gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
GdkDisplay *display,
|
||||
const XEvent *xevent);
|
||||
|
||||
static void gdk_internal_connection_watch (Display *display,
|
||||
XPointer arg,
|
||||
@ -630,10 +629,9 @@ get_event_xwindow (const XEvent *xevent)
|
||||
return xwindow;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static GdkEvent *
|
||||
gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
GdkDisplay *display,
|
||||
GdkEvent *event,
|
||||
const XEvent *xevent)
|
||||
{
|
||||
Window xwindow;
|
||||
@ -643,7 +641,9 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
GdkX11Screen *x11_screen = NULL;
|
||||
GdkToplevelX11 *toplevel = NULL;
|
||||
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
|
||||
gboolean return_val;
|
||||
GdkEvent *event;
|
||||
|
||||
event = NULL;
|
||||
|
||||
/* Find the GdkSurface that this event relates to. If that's
|
||||
* not the same as the surface that the event was sent to,
|
||||
@ -665,7 +665,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
* and ShmCompletion for pixmaps
|
||||
*/
|
||||
if (!GDK_IS_SURFACE (surface))
|
||||
return FALSE;
|
||||
return NULL;
|
||||
|
||||
x11_screen = GDK_SURFACE_SCREEN (surface);
|
||||
toplevel = _gdk_x11_surface_get_toplevel (surface);
|
||||
@ -674,16 +674,10 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
g_object_ref (surface);
|
||||
}
|
||||
|
||||
event->any.surface = surface;
|
||||
event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
|
||||
|
||||
if (surface && GDK_SURFACE_DESTROYED (surface))
|
||||
{
|
||||
if (xevent->type != DestroyNotify)
|
||||
{
|
||||
return_val = FALSE;
|
||||
goto done;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (xevent->type == DestroyNotify && !is_substructure)
|
||||
@ -700,7 +694,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
/* careful, reentrancy */
|
||||
_gdk_x11_screen_window_manager_changed (x11_screen);
|
||||
|
||||
return_val = FALSE;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@ -712,30 +705,23 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
* received.
|
||||
*/
|
||||
|
||||
return_val = TRUE;
|
||||
|
||||
switch (xevent->type)
|
||||
{
|
||||
case KeymapNotify:
|
||||
GDK_DISPLAY_NOTE (display, EVENTS, g_message ("keymap notify"));
|
||||
|
||||
/* Not currently handled */
|
||||
return_val = FALSE;
|
||||
break;
|
||||
|
||||
case Expose:
|
||||
GDK_DISPLAY_NOTE (display, EVENTS,
|
||||
g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d%s",
|
||||
g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d",
|
||||
xevent->xexpose.window, xevent->xexpose.count,
|
||||
xevent->xexpose.x, xevent->xexpose.y,
|
||||
xevent->xexpose.width, xevent->xexpose.height,
|
||||
event->any.send_event ? " (send)" : ""));
|
||||
xevent->xexpose.width, xevent->xexpose.height));
|
||||
|
||||
if (surface == NULL)
|
||||
{
|
||||
return_val = FALSE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
{
|
||||
GdkRectangle expose_rect;
|
||||
@ -751,7 +737,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
expose_rect.height = y2 - expose_rect.y;
|
||||
|
||||
gdk_surface_invalidate_rect (surface, &expose_rect);
|
||||
return_val = FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -766,10 +751,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
xevent->xgraphicsexpose.drawable));
|
||||
|
||||
if (surface == NULL)
|
||||
{
|
||||
return_val = FALSE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
expose_rect.x = xevent->xgraphicsexpose.x / surface_impl->surface_scale;
|
||||
expose_rect.y = xevent->xgraphicsexpose.y / surface_impl->surface_scale;
|
||||
@ -781,7 +763,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
expose_rect.height = y2 - expose_rect.y;
|
||||
|
||||
gdk_surface_invalidate_rect (surface, &expose_rect);
|
||||
return_val = FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -807,7 +788,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
}
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
/* not handled */
|
||||
return_val = FALSE;
|
||||
break;
|
||||
|
||||
case CreateNotify:
|
||||
@ -831,16 +811,11 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
|
||||
if (!is_substructure)
|
||||
{
|
||||
event->any.type = GDK_DESTROY;
|
||||
event->any.surface = surface;
|
||||
|
||||
return_val = surface && !GDK_SURFACE_DESTROYED (surface);
|
||||
event = gdk_event_delete_new (surface);
|
||||
|
||||
if (surface && GDK_SURFACE_XID (surface) != x11_screen->xroot_window)
|
||||
gdk_surface_destroy_notify (surface);
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
|
||||
break;
|
||||
|
||||
@ -886,8 +861,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
gdk_profiler_add_markf (g_get_monotonic_time (), 0, "unmapped window", "0x%lx", GDK_SURFACE_XID (surface));
|
||||
}
|
||||
|
||||
return_val = FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case MapNotify:
|
||||
@ -913,8 +886,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
}
|
||||
}
|
||||
|
||||
return_val = FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case ReparentNotify:
|
||||
@ -927,7 +898,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
xevent->xreparent.override_redirect));
|
||||
|
||||
/* Not currently handled */
|
||||
return_val = FALSE;
|
||||
break;
|
||||
|
||||
case ConfigureNotify:
|
||||
@ -956,15 +926,14 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!surface ||
|
||||
xevent->xconfigure.event != xevent->xconfigure.window)
|
||||
return_val = FALSE;
|
||||
else
|
||||
{
|
||||
event->any.type = GDK_CONFIGURE;
|
||||
event->any.surface = surface;
|
||||
event->configure.width = (xevent->xconfigure.width + surface_impl->surface_scale - 1) / surface_impl->surface_scale;
|
||||
event->configure.height = (xevent->xconfigure.height + surface_impl->surface_scale - 1) / surface_impl->surface_scale;
|
||||
if (surface &&
|
||||
xevent->xconfigure.event == xevent->xconfigure.window)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
event = gdk_event_configure_new (surface,
|
||||
(xevent->xconfigure.width + surface_impl->surface_scale - 1) / surface_impl->surface_scale,
|
||||
(xevent->xconfigure.height + surface_impl->surface_scale - 1) / surface_impl->surface_scale);
|
||||
|
||||
if (!xevent->xconfigure.send_event &&
|
||||
!xevent->xconfigure.override_redirect &&
|
||||
@ -974,6 +943,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
gint ty = 0;
|
||||
Window child_window = 0;
|
||||
|
||||
x = y = 0;
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
if (XTranslateCoordinates (GDK_SURFACE_XDISPLAY (surface),
|
||||
GDK_SURFACE_XID (surface),
|
||||
@ -982,22 +952,22 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
&tx, &ty,
|
||||
&child_window))
|
||||
{
|
||||
event->configure.x = tx / surface_impl->surface_scale;
|
||||
event->configure.y = ty / surface_impl->surface_scale;
|
||||
x = tx / surface_impl->surface_scale;
|
||||
y = ty / surface_impl->surface_scale;
|
||||
}
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
}
|
||||
else
|
||||
{
|
||||
event->configure.x = xevent->xconfigure.x / surface_impl->surface_scale;
|
||||
event->configure.y = xevent->xconfigure.y / surface_impl->surface_scale;
|
||||
x = xevent->xconfigure.x / surface_impl->surface_scale;
|
||||
y = xevent->xconfigure.y / surface_impl->surface_scale;
|
||||
}
|
||||
if (!is_substructure)
|
||||
{
|
||||
int new_abs_x, new_abs_y;
|
||||
|
||||
new_abs_x = event->configure.x;
|
||||
new_abs_y = event->configure.y;
|
||||
new_abs_x = x;
|
||||
new_abs_y = y;
|
||||
|
||||
surface_impl->abs_x = new_abs_x;
|
||||
surface_impl->abs_y = new_abs_y;
|
||||
@ -1046,10 +1016,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
"\""));
|
||||
|
||||
if (surface == NULL)
|
||||
{
|
||||
return_val = FALSE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
/* We compare with the serial of the last time we mapped the
|
||||
* window to avoid refetching properties that we set ourselves
|
||||
@ -1066,8 +1033,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_GTK_EDGE_CONSTRAINTS"))
|
||||
gdk_check_edge_constraints_changed (surface);
|
||||
}
|
||||
|
||||
return_val = FALSE;
|
||||
break;
|
||||
|
||||
case ColormapNotify:
|
||||
@ -1076,7 +1041,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
xevent->xcolormap.window));
|
||||
|
||||
/* Not currently handled */
|
||||
return_val = FALSE;
|
||||
break;
|
||||
|
||||
case ClientMessage:
|
||||
@ -1085,7 +1049,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
xevent->xclient.window));
|
||||
|
||||
/* Not currently handled */
|
||||
return_val = FALSE;
|
||||
break;
|
||||
|
||||
case MappingNotify:
|
||||
@ -1096,7 +1059,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
*/
|
||||
XRefreshKeyboardMapping ((XMappingEvent *) xevent);
|
||||
_gdk_x11_keymap_keys_changed (display);
|
||||
return_val = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1119,8 +1081,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
case XkbNewKeyboardNotify:
|
||||
case XkbMapNotify:
|
||||
_gdk_x11_keymap_keys_changed (display);
|
||||
|
||||
return_val = FALSE;
|
||||
break;
|
||||
|
||||
case XkbStateNotify:
|
||||
@ -1130,28 +1090,14 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return_val = FALSE;
|
||||
}
|
||||
|
||||
done:
|
||||
if (return_val)
|
||||
{
|
||||
if (event->any.surface)
|
||||
g_object_ref (event->any.surface);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Mark this event as having no resources to be freed */
|
||||
event->any.surface = NULL;
|
||||
event->any.type = GDK_NOTHING;
|
||||
}
|
||||
|
||||
if (surface)
|
||||
g_object_unref (surface);
|
||||
|
||||
return return_val;
|
||||
return event;
|
||||
}
|
||||
|
||||
static GdkFrameTimings *
|
||||
@ -1215,11 +1161,11 @@ server_time_to_monotonic_time (GdkX11Display *display_x11,
|
||||
}
|
||||
|
||||
GdkFilterReturn
|
||||
_gdk_wm_protocols_filter (const XEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
_gdk_wm_protocols_filter (const XEvent *xevent,
|
||||
GdkSurface *win,
|
||||
GdkEvent **event,
|
||||
gpointer data)
|
||||
{
|
||||
GdkSurface *win = event->any.surface;
|
||||
GdkDisplay *display;
|
||||
Atom atom;
|
||||
|
||||
@ -1257,7 +1203,7 @@ _gdk_wm_protocols_filter (const XEvent *xevent,
|
||||
if (surface_impl->toplevel->frame_pending)
|
||||
{
|
||||
surface_impl->toplevel->frame_pending = FALSE;
|
||||
gdk_surface_thaw_updates (event->any.surface);
|
||||
gdk_surface_thaw_updates (win);
|
||||
}
|
||||
|
||||
gdk_frame_clock_get_refresh_info (clock,
|
||||
@ -1329,7 +1275,7 @@ _gdk_wm_protocols_filter (const XEvent *xevent,
|
||||
g_message ("delete window:\t\twindow: %ld",
|
||||
xevent->xclient.window));
|
||||
|
||||
event->any.type = GDK_DELETE;
|
||||
*event = gdk_event_delete_new (win);
|
||||
|
||||
gdk_x11_surface_set_user_time (win, xevent->xclient.data.l[1]);
|
||||
|
||||
|
@ -179,7 +179,8 @@ gboolean gdk_x11_display_request_selection_notification (GdkDisplay
|
||||
const char *selection);
|
||||
|
||||
GdkFilterReturn _gdk_wm_protocols_filter (const XEvent *xevent,
|
||||
GdkEvent *event,
|
||||
GdkSurface *win,
|
||||
GdkEvent **event,
|
||||
gpointer data);
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -171,7 +171,7 @@ static GdkSurfaceCache *gdk_surface_cache_ref (GdkSurfaceCache *cache);
|
||||
static void gdk_surface_cache_unref (GdkSurfaceCache *cache);
|
||||
|
||||
gboolean gdk_x11_drag_handle_event (GdkDrag *drag,
|
||||
const GdkEvent *event);
|
||||
GdkEvent *event);
|
||||
|
||||
static GList *drags;
|
||||
static GSList *window_caches;
|
||||
@ -354,7 +354,6 @@ gdk_surface_cache_add (GdkSurfaceCache *cache,
|
||||
|
||||
GdkFilterReturn
|
||||
gdk_surface_cache_shape_filter (const XEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
GdkSurfaceCache *cache = data;
|
||||
@ -388,7 +387,6 @@ gdk_surface_cache_shape_filter (const XEvent *xevent,
|
||||
|
||||
GdkFilterReturn
|
||||
gdk_surface_cache_filter (const XEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
GdkSurfaceCache *cache = data;
|
||||
@ -2243,22 +2241,24 @@ gdk_drag_update (GdkDrag *drag,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_motion_event (GdkDrag *drag,
|
||||
const GdkEventMotion *event)
|
||||
gdk_dnd_handle_motion_event (GdkDrag *drag,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GdkModifierType state;
|
||||
double x, y;
|
||||
int x_root, y_root;
|
||||
|
||||
if (!gdk_event_get_state ((GdkEvent *) event, &state))
|
||||
return FALSE;
|
||||
|
||||
gdk_drag_update (drag, event->x_root, event->y_root, state,
|
||||
gdk_event_get_time ((GdkEvent *) event));
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
x_root = event->any.surface->x + x;
|
||||
y_root = event->any.surface->y + y;
|
||||
gdk_drag_update (drag, x_root, y_root,
|
||||
gdk_event_get_modifier_state (event),
|
||||
gdk_event_get_time (event));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_key_event (GdkDrag *drag,
|
||||
const GdkEventKey *event)
|
||||
GdkEventKey *event)
|
||||
{
|
||||
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
|
||||
GdkModifierType state;
|
||||
@ -2351,7 +2351,7 @@ gdk_dnd_handle_key_event (GdkDrag *drag,
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
|
||||
const GdkEventGrabBroken *event)
|
||||
GdkEventGrabBroken *event)
|
||||
{
|
||||
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
|
||||
|
||||
@ -2374,7 +2374,7 @@ gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_button_event (GdkDrag *drag,
|
||||
const GdkEventButton *event)
|
||||
GdkEventButton *event)
|
||||
{
|
||||
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
|
||||
|
||||
@ -2397,7 +2397,7 @@ gdk_dnd_handle_button_event (GdkDrag *drag,
|
||||
|
||||
gboolean
|
||||
gdk_x11_drag_handle_event (GdkDrag *drag,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
|
||||
|
||||
@ -2407,7 +2407,7 @@ gdk_x11_drag_handle_event (GdkDrag *drag,
|
||||
switch ((guint) event->any.type)
|
||||
{
|
||||
case GDK_MOTION_NOTIFY:
|
||||
return gdk_dnd_handle_motion_event (drag, &event->motion);
|
||||
return gdk_dnd_handle_motion_event (drag, event);
|
||||
case GDK_BUTTON_RELEASE:
|
||||
return gdk_dnd_handle_button_event (drag, &event->button);
|
||||
case GDK_KEY_PRESS:
|
||||
|
@ -647,7 +647,8 @@ xdnd_position_filter (GdkSurface *surface,
|
||||
if ((drop != NULL) &&
|
||||
(drop_x11->source_window == source_window))
|
||||
{
|
||||
impl = GDK_X11_SURFACE (gdk_drop_get_surface (drop));
|
||||
surface = gdk_drop_get_surface (drop);
|
||||
impl = GDK_X11_SURFACE (surface);
|
||||
|
||||
drop_x11->suggested_action = xdnd_action_from_atom (display, action);
|
||||
gdk_x11_drop_update_actions (drop_x11);
|
||||
@ -655,7 +656,7 @@ xdnd_position_filter (GdkSurface *surface,
|
||||
drop_x11->last_x = x_root / impl->surface_scale;
|
||||
drop_x11->last_y = y_root / impl->surface_scale;
|
||||
|
||||
gdk_drop_emit_motion_event (drop, FALSE, drop_x11->last_x, drop_x11->last_y, time);
|
||||
gdk_drop_emit_motion_event (drop, FALSE, drop_x11->last_x - surface->x, drop_x11->last_y - surface->y, time);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -687,9 +688,10 @@ xdnd_drop_filter (GdkSurface *surface,
|
||||
if ((drop != NULL) &&
|
||||
(drop_x11->source_window == source_window))
|
||||
{
|
||||
gdk_x11_surface_set_user_time (gdk_drop_get_surface (drop), time);
|
||||
GdkSurface *s = gdk_drop_get_surface (drop);
|
||||
gdk_x11_surface_set_user_time (s, time);
|
||||
|
||||
gdk_drop_emit_drop_event (drop, FALSE, drop_x11->last_x, drop_x11->last_y, time);
|
||||
gdk_drop_emit_drop_event (drop, FALSE, drop_x11->last_x - s->x, drop_x11->last_y - s->y, time);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -87,25 +87,25 @@ gdk_event_source_get_filter_surface (GdkEventSource *event_source,
|
||||
}
|
||||
|
||||
static void
|
||||
handle_focus_change (GdkEventCrossing *event)
|
||||
handle_focus_change (GdkEvent *event)
|
||||
{
|
||||
GdkToplevelX11 *toplevel;
|
||||
GdkX11Screen *x11_screen;
|
||||
gboolean focus_in, had_focus;
|
||||
|
||||
toplevel = _gdk_x11_surface_get_toplevel (event->any.surface);
|
||||
x11_screen = GDK_X11_SCREEN (GDK_SURFACE_SCREEN (event->any.surface));
|
||||
focus_in = (event->any.type == GDK_ENTER_NOTIFY);
|
||||
toplevel = _gdk_x11_surface_get_toplevel (gdk_event_get_surface (event));
|
||||
x11_screen = GDK_X11_SCREEN (GDK_SURFACE_SCREEN (gdk_event_get_surface (event)));
|
||||
focus_in = (gdk_event_get_event_type (event) == GDK_ENTER_NOTIFY);
|
||||
|
||||
if (x11_screen->wmspec_check_window)
|
||||
return;
|
||||
|
||||
if (!toplevel || event->detail == GDK_NOTIFY_INFERIOR)
|
||||
if (!toplevel || gdk_crossing_event_get_detail (event) == GDK_NOTIFY_INFERIOR)
|
||||
return;
|
||||
|
||||
toplevel->has_pointer = focus_in;
|
||||
|
||||
if (!event->focus || toplevel->has_focus_window)
|
||||
if (!event->crossing.focus || toplevel->has_focus_window)
|
||||
return;
|
||||
|
||||
had_focus = HAS_FOCUS (toplevel);
|
||||
@ -115,13 +115,11 @@ handle_focus_change (GdkEventCrossing *event)
|
||||
{
|
||||
GdkEvent *focus_event;
|
||||
|
||||
focus_event = gdk_event_new (GDK_FOCUS_CHANGE);
|
||||
focus_event->any.surface = g_object_ref (event->any.surface);
|
||||
focus_event->any.send_event = FALSE;
|
||||
focus_event->focus_change.in = focus_in;
|
||||
gdk_event_set_device (focus_event, gdk_event_get_device ((GdkEvent *) event));
|
||||
|
||||
gdk_display_put_event (gdk_surface_get_display (event->any.surface), focus_event);
|
||||
focus_event = gdk_event_focus_new (gdk_event_get_surface (event),
|
||||
gdk_event_get_device (event),
|
||||
gdk_event_get_source_device (event),
|
||||
focus_in);
|
||||
gdk_display_put_event (gdk_event_get_display (event), focus_event);
|
||||
g_object_unref (focus_event);
|
||||
}
|
||||
}
|
||||
@ -129,28 +127,23 @@ handle_focus_change (GdkEventCrossing *event)
|
||||
static GdkEvent *
|
||||
create_synth_crossing_event (GdkEventType evtype,
|
||||
GdkCrossingMode mode,
|
||||
const GdkEvent *real_event)
|
||||
GdkEvent *real_event)
|
||||
{
|
||||
GdkEvent *event;
|
||||
gdouble x, y;
|
||||
GdkModifierType state;
|
||||
|
||||
g_assert (evtype == GDK_ENTER_NOTIFY || evtype == GDK_LEAVE_NOTIFY);
|
||||
|
||||
event = gdk_event_new (evtype);
|
||||
event->any.send_event = TRUE;
|
||||
event->any.surface = g_object_ref (real_event->any.surface);
|
||||
event->crossing.detail = GDK_NOTIFY_ANCESTOR;
|
||||
event->crossing.mode = mode;
|
||||
event->crossing.time = gdk_event_get_time (real_event);
|
||||
gdk_event_set_device (event, gdk_event_get_device (real_event));
|
||||
gdk_event_set_source_device (event, gdk_event_get_device (real_event));
|
||||
|
||||
if (gdk_event_get_state (real_event, &state))
|
||||
event->crossing.state = state;
|
||||
|
||||
if (gdk_event_get_coords (real_event, &x, &y))
|
||||
gdk_event_set_coords (event, x, y);
|
||||
gdk_event_get_position (real_event, &x, &y);
|
||||
event = gdk_event_crossing_new (evtype,
|
||||
gdk_event_get_surface (real_event),
|
||||
gdk_event_get_device (real_event),
|
||||
gdk_event_get_source_device (real_event),
|
||||
gdk_event_get_time (real_event),
|
||||
gdk_event_get_modifier_state (real_event),
|
||||
x, y,
|
||||
mode,
|
||||
GDK_NOTIFY_ANCESTOR);
|
||||
|
||||
return event;
|
||||
}
|
||||
@ -237,52 +230,44 @@ gdk_event_source_translate_event (GdkX11Display *x11_display,
|
||||
x11_screen = GDK_X11_DISPLAY (display)->screen;
|
||||
dpy = GDK_DISPLAY_XDISPLAY (display);
|
||||
|
||||
event = gdk_event_new (GDK_NOTHING);
|
||||
event = NULL;
|
||||
filter_surface = gdk_event_source_get_filter_surface (event_source, xevent,
|
||||
&event_translator);
|
||||
if (filter_surface)
|
||||
event->any.surface = g_object_ref (filter_surface);
|
||||
|
||||
/* apply XSettings filters */
|
||||
if (xevent->xany.window == XRootWindow (dpy, 0))
|
||||
result = gdk_xsettings_root_window_filter (xevent, event, x11_screen);
|
||||
result = gdk_xsettings_root_window_filter (xevent, x11_screen);
|
||||
|
||||
if (result == GDK_FILTER_CONTINUE &&
|
||||
xevent->xany.window == x11_screen->xsettings_manager_window)
|
||||
result = gdk_xsettings_manager_window_filter (xevent, event, x11_screen);
|
||||
result = gdk_xsettings_manager_window_filter (xevent, x11_screen);
|
||||
|
||||
cache = gdk_surface_cache_get (display);
|
||||
if (cache)
|
||||
{
|
||||
if (result == GDK_FILTER_CONTINUE)
|
||||
result = gdk_surface_cache_shape_filter (xevent, event, cache);
|
||||
result = gdk_surface_cache_shape_filter (xevent, cache);
|
||||
|
||||
if (result == GDK_FILTER_CONTINUE &&
|
||||
xevent->xany.window == XRootWindow (dpy, 0))
|
||||
result = gdk_surface_cache_filter (xevent, event, cache);
|
||||
result = gdk_surface_cache_filter (xevent, cache);
|
||||
}
|
||||
|
||||
if (result == GDK_FILTER_CONTINUE)
|
||||
result = _gdk_wm_protocols_filter (xevent, event, NULL);
|
||||
result = _gdk_wm_protocols_filter (xevent, filter_surface, &event, NULL);
|
||||
|
||||
if (result == GDK_FILTER_CONTINUE &&
|
||||
gdk_x11_drop_filter (event->any.surface, xevent))
|
||||
gdk_x11_drop_filter (filter_surface, xevent))
|
||||
result = GDK_FILTER_REMOVE;
|
||||
|
||||
if (result != GDK_FILTER_CONTINUE)
|
||||
{
|
||||
if (result == GDK_FILTER_REMOVE)
|
||||
{
|
||||
g_object_unref (event);
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
else /* GDK_FILTER_TRANSLATE */
|
||||
return event;
|
||||
}
|
||||
|
||||
g_object_unref (event);
|
||||
event = NULL;
|
||||
|
||||
if (event_translator)
|
||||
{
|
||||
/* Event translator was gotten before in get_filter_window() */
|
||||
@ -305,29 +290,26 @@ gdk_event_source_translate_event (GdkX11Display *x11_display,
|
||||
}
|
||||
}
|
||||
|
||||
if (event &&
|
||||
event->any.type == GDK_NOTHING)
|
||||
if (event)
|
||||
{
|
||||
g_clear_object (&event);
|
||||
}
|
||||
GdkEventType evtype = gdk_event_get_event_type (event);
|
||||
|
||||
if ((evtype == GDK_ENTER_NOTIFY ||
|
||||
evtype == GDK_LEAVE_NOTIFY) &&
|
||||
gdk_event_get_surface (event) != NULL)
|
||||
{
|
||||
/* Handle focusing (in the case where no window manager is running */
|
||||
handle_focus_change (event);
|
||||
}
|
||||
|
||||
if (event &&
|
||||
(event->any.type == GDK_ENTER_NOTIFY ||
|
||||
event->any.type == GDK_LEAVE_NOTIFY) &&
|
||||
event->any.surface != NULL)
|
||||
{
|
||||
/* Handle focusing (in the case where no window manager is running */
|
||||
handle_focus_change (&event->crossing);
|
||||
}
|
||||
|
||||
if (event &&
|
||||
(event->any.type == GDK_TOUCH_BEGIN ||
|
||||
event->any.type == GDK_TOUCH_END ||
|
||||
event->any.type == GDK_MOTION_NOTIFY ||
|
||||
event->any.type == GDK_ENTER_NOTIFY ||
|
||||
event->any.type == GDK_LEAVE_NOTIFY))
|
||||
{
|
||||
handle_touch_synthetic_crossing (event);
|
||||
if (evtype == GDK_TOUCH_BEGIN ||
|
||||
evtype == GDK_TOUCH_END ||
|
||||
evtype == GDK_MOTION_NOTIFY ||
|
||||
evtype == GDK_ENTER_NOTIFY ||
|
||||
evtype == GDK_LEAVE_NOTIFY)
|
||||
{
|
||||
handle_touch_synthetic_crossing (event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
@ -444,7 +426,7 @@ gdk_event_source_dispatch (GSource *source,
|
||||
{
|
||||
_gdk_event_emit (event);
|
||||
|
||||
g_object_unref (event);
|
||||
gdk_event_unref (event);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -36,7 +36,6 @@ _gdk_x11_event_translator_translate (GdkEventTranslator *translator,
|
||||
const XEvent *xevent)
|
||||
{
|
||||
GdkEventTranslatorIface *iface;
|
||||
GdkEvent *event;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_EVENT_TRANSLATOR (translator), NULL);
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||
@ -46,14 +45,7 @@ _gdk_x11_event_translator_translate (GdkEventTranslator *translator,
|
||||
if (!iface->translate_event)
|
||||
return NULL;
|
||||
|
||||
event = gdk_event_new (GDK_NOTHING);
|
||||
|
||||
if ((iface->translate_event) (translator, display, event, xevent))
|
||||
return event;
|
||||
|
||||
g_object_unref (event);
|
||||
|
||||
return NULL;
|
||||
return (iface->translate_event) (translator, display, xevent);
|
||||
}
|
||||
|
||||
GdkEventMask
|
||||
|
@ -38,10 +38,9 @@ struct _GdkEventTranslatorIface
|
||||
GTypeInterface iface;
|
||||
|
||||
/* VMethods */
|
||||
gboolean (* translate_event) (GdkEventTranslator *translator,
|
||||
GdkDisplay *display,
|
||||
GdkEvent *event,
|
||||
const XEvent *xevent);
|
||||
GdkEvent * (* translate_event) (GdkEventTranslator *translator,
|
||||
GdkDisplay *display,
|
||||
const XEvent *xevent);
|
||||
|
||||
GdkEventMask (* get_handled_events) (GdkEventTranslator *translator);
|
||||
void (* select_surface_events) (GdkEventTranslator *translator,
|
||||
|
@ -212,11 +212,9 @@ gdk_surface_cache_get (GdkDisplay *display);
|
||||
|
||||
GdkFilterReturn
|
||||
gdk_surface_cache_filter (const XEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
GdkFilterReturn
|
||||
gdk_surface_cache_shape_filter (const XEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
|
||||
void _gdk_x11_cursor_display_finalize (GdkDisplay *display);
|
||||
|
@ -4651,7 +4651,7 @@ gdk_x11_surface_show_window_menu (GdkSurface *surface,
|
||||
g_intern_static_string ("_GTK_SHOW_WINDOW_MENU")))
|
||||
return FALSE;
|
||||
|
||||
gdk_event_get_coords (event, &x, &y);
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
gdk_x11_surface_get_root_coords (surface, x, y, &x_root, &y_root);
|
||||
device = gdk_event_get_device (event);
|
||||
g_object_get (G_OBJECT (device),
|
||||
|
@ -506,7 +506,6 @@ check_manager_window (GdkX11Screen *x11_screen,
|
||||
|
||||
GdkFilterReturn
|
||||
gdk_xsettings_root_window_filter (const XEvent *xev,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
GdkX11Screen *x11_screen = data;
|
||||
@ -530,7 +529,6 @@ gdk_xsettings_root_window_filter (const XEvent *xev,
|
||||
|
||||
GdkFilterReturn
|
||||
gdk_xsettings_manager_window_filter (const XEvent *xev,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
GdkX11Screen *x11_screen = data;
|
||||
|
@ -31,10 +31,8 @@ void _gdk_x11_xsettings_finish (GdkX11Screen *x11_screen);
|
||||
void _gdk_x11_settings_force_reread (GdkX11Screen *x11_screen);
|
||||
|
||||
GdkFilterReturn gdk_xsettings_root_window_filter (const XEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
GdkFilterReturn gdk_xsettings_manager_window_filter (const XEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
|
||||
|
||||
|
@ -25,9 +25,6 @@ G_BEGIN_DECLS
|
||||
|
||||
void _gtk_accessibility_init (void);
|
||||
|
||||
gboolean _gtk_accessibility_key_snooper (GtkWidget *widget,
|
||||
GdkEventKey *event);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ACCESSIBILITY_H__ */
|
||||
|
@ -107,54 +107,3 @@ _gtk_accessibility_override_atk_util (void)
|
||||
atk_class->get_toolkit_name = get_toolkit_name;
|
||||
atk_class->get_toolkit_version = get_toolkit_version;
|
||||
}
|
||||
|
||||
static void
|
||||
atk_key_event_from_gdk_event_key (GdkEventKey *key,
|
||||
AtkKeyEventStruct *event)
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkModifierType state;
|
||||
guint keyval;
|
||||
guint16 keycode;
|
||||
|
||||
type = gdk_event_get_event_type ((GdkEvent *)key);
|
||||
gdk_event_get_state ((GdkEvent *)key, &state);
|
||||
gdk_event_get_keyval ((GdkEvent *)key, &keyval);
|
||||
gdk_event_get_keycode ((GdkEvent *)key, &keycode);
|
||||
|
||||
if (type == GDK_KEY_PRESS)
|
||||
event->type = ATK_KEY_EVENT_PRESS;
|
||||
else if (type == GDK_KEY_RELEASE)
|
||||
event->type = ATK_KEY_EVENT_RELEASE;
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
|
||||
event->state = state;
|
||||
event->keyval = keyval;
|
||||
event->string = (char *) gdk_keyval_name (keyval);
|
||||
event->length = strlen (event->string);
|
||||
event->keycode = keycode;
|
||||
event->timestamp = gdk_event_get_time ((GdkEvent *)key);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_accessibility_key_snooper (GtkWidget *widget,
|
||||
GdkEventKey *event)
|
||||
{
|
||||
GSList *l;
|
||||
AtkKeyEventStruct atk_event;
|
||||
gboolean result;
|
||||
|
||||
result = FALSE;
|
||||
|
||||
atk_key_event_from_gdk_event_key (event, &atk_event);
|
||||
|
||||
for (l = key_listener_list; l; l = l->next)
|
||||
{
|
||||
KeyEventListener *listener = l->data;
|
||||
|
||||
result |= listener->func (&atk_event, listener->data);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -101,6 +101,7 @@
|
||||
#include <gtk/gtkentrycompletion.h>
|
||||
#include <gtk/gtkenums.h>
|
||||
#include <gtk/gtkeventcontroller.h>
|
||||
#include <gtk/gtkeventcontrollerfocus.h>
|
||||
#include <gtk/gtkeventcontrollerkey.h>
|
||||
#include <gtk/gtkeventcontrollerlegacy.h>
|
||||
#include <gtk/gtkeventcontrollermotion.h>
|
||||
|
@ -1756,7 +1756,7 @@ gtk_bindings_activate (GObject *object,
|
||||
/**
|
||||
* gtk_bindings_activate_event:
|
||||
* @object: a #GObject (generally must be a widget)
|
||||
* @event: a #GdkEventKey
|
||||
* @event: a key event
|
||||
*
|
||||
* Looks up key bindings for @object to find one matching
|
||||
* @event, and if one was found, activate it.
|
||||
@ -1764,16 +1764,13 @@ gtk_bindings_activate (GObject *object,
|
||||
* Returns: %TRUE if a matching key binding was found
|
||||
*/
|
||||
gboolean
|
||||
gtk_bindings_activate_event (GObject *object,
|
||||
GdkEventKey *event)
|
||||
gtk_bindings_activate_event (GObject *object,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GSList *entries = NULL;
|
||||
GdkDisplay *display;
|
||||
GtkKeyHash *key_hash;
|
||||
gboolean handled = FALSE;
|
||||
guint16 keycode;
|
||||
GdkModifierType state;
|
||||
guint group;
|
||||
|
||||
if (!GTK_IS_WIDGET (object))
|
||||
return FALSE;
|
||||
@ -1781,18 +1778,14 @@ gtk_bindings_activate_event (GObject *object,
|
||||
display = gtk_widget_get_display (GTK_WIDGET (object));
|
||||
key_hash = binding_key_hash_for_keymap (gdk_display_get_keymap (display));
|
||||
|
||||
gdk_event_get_keycode ((GdkEvent *)event, &keycode);
|
||||
gdk_event_get_state ((GdkEvent *)event, &state);
|
||||
gdk_event_get_key_group ((GdkEvent *)event, &group);
|
||||
|
||||
entries = _gtk_key_hash_lookup (key_hash,
|
||||
keycode,
|
||||
state,
|
||||
gdk_key_event_get_keycode (event),
|
||||
gdk_event_get_modifier_state (event),
|
||||
BINDING_MOD_MASK () & ~GDK_RELEASE_MASK,
|
||||
group);
|
||||
gdk_key_event_get_group(event));
|
||||
|
||||
handled = gtk_bindings_activate_list (object, entries,
|
||||
gdk_event_get_event_type ((GdkEvent *) event) == GDK_KEY_RELEASE);
|
||||
gdk_event_get_event_type (event) == GDK_KEY_RELEASE);
|
||||
|
||||
g_slist_free (entries);
|
||||
|
||||
|
@ -67,7 +67,7 @@ gboolean gtk_bindings_activate (GObject *object,
|
||||
GdkModifierType modifiers);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_bindings_activate_event (GObject *object,
|
||||
GdkEventKey *event);
|
||||
GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_binding_set_activate (GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
|
@ -318,13 +318,13 @@ touch_release_in_button (GtkButton *button)
|
||||
|
||||
if (gdk_event_get_event_type (event) != GDK_TOUCH_END)
|
||||
{
|
||||
g_object_unref (event);
|
||||
gdk_event_unref (event);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gdk_event_get_coords (event, &x, &y);
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
|
||||
g_object_unref (event);
|
||||
gdk_event_unref (event);
|
||||
|
||||
if (gtk_widget_contains (GTK_WIDGET (button), x, y))
|
||||
return TRUE;
|
||||
|
@ -109,6 +109,7 @@
|
||||
#include "gtkgesturedrag.h"
|
||||
#include "gtkeventcontrollerscroll.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkeventcontrollerfocus.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkicontheme.h"
|
||||
@ -280,9 +281,7 @@ static gboolean gtk_calendar_key_controller_key_pressed (GtkEventControllerKey *
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
GtkWidget *widget);
|
||||
static void gtk_calendar_key_controller_focus (GtkEventControllerKey *controller,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
static void gtk_calendar_focus_controller_focus (GtkEventController *controller,
|
||||
GtkWidget *widget);
|
||||
static void gtk_calendar_state_flags_changed (GtkWidget *widget,
|
||||
GtkStateFlags previous_state);
|
||||
@ -593,11 +592,13 @@ gtk_calendar_init (GtkCalendar *calendar)
|
||||
g_signal_connect (controller, "key-pressed",
|
||||
G_CALLBACK (gtk_calendar_key_controller_key_pressed),
|
||||
calendar);
|
||||
g_signal_connect (controller, "focus-in",
|
||||
G_CALLBACK (gtk_calendar_key_controller_focus),
|
||||
gtk_widget_add_controller (GTK_WIDGET (calendar), controller);
|
||||
controller = gtk_event_controller_focus_new ();
|
||||
g_signal_connect (controller, "enter",
|
||||
G_CALLBACK (gtk_calendar_focus_controller_focus),
|
||||
calendar);
|
||||
g_signal_connect (controller, "focus-out",
|
||||
G_CALLBACK (gtk_calendar_key_controller_focus),
|
||||
g_signal_connect (controller, "leave",
|
||||
G_CALLBACK (gtk_calendar_focus_controller_focus),
|
||||
calendar);
|
||||
gtk_widget_add_controller (GTK_WIDGET (calendar), controller);
|
||||
|
||||
@ -1393,10 +1394,8 @@ gtk_calendar_key_controller_key_pressed (GtkEventControllerKey *controller,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_calendar_key_controller_focus (GtkEventControllerKey *key,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
GtkWidget *widget)
|
||||
gtk_calendar_focus_controller_focus (GtkEventController *controller,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkCalendar *calendar = GTK_CALENDAR (widget);
|
||||
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
|
||||
|
@ -1024,12 +1024,9 @@ gtk_cell_area_real_event (GtkCellArea *area,
|
||||
|
||||
if (event_type == GDK_KEY_PRESS && (flags & GTK_CELL_RENDERER_FOCUSED) != 0)
|
||||
{
|
||||
guint keyval;
|
||||
|
||||
/* Cancel any edits in progress */
|
||||
if (priv->edited_cell &&
|
||||
gdk_event_get_keyval (event, &keyval) &&
|
||||
keyval == GDK_KEY_Escape)
|
||||
gdk_key_event_get_keyval (event) == GDK_KEY_Escape)
|
||||
{
|
||||
gtk_cell_area_stop_editing (area, TRUE);
|
||||
retval = TRUE;
|
||||
@ -1039,7 +1036,8 @@ gtk_cell_area_real_event (GtkCellArea *area,
|
||||
{
|
||||
guint button;
|
||||
|
||||
if (gdk_event_get_button (event, &button) && button == GDK_BUTTON_PRIMARY)
|
||||
button = gdk_button_event_get_button (event);
|
||||
if (button == GDK_BUTTON_PRIMARY)
|
||||
{
|
||||
GtkCellRenderer *renderer = NULL;
|
||||
GtkCellRenderer *focus_renderer;
|
||||
@ -1048,7 +1046,7 @@ gtk_cell_area_real_event (GtkCellArea *area,
|
||||
|
||||
/* We may need some semantics to tell us the offset of the event
|
||||
* window we are handling events for (i.e. GtkTreeView has a bin_window) */
|
||||
gdk_event_get_coords (event, &event_x, &event_y);
|
||||
gdk_event_get_position (event, &event_x, &event_y);
|
||||
|
||||
/* Dont try to search for an event coordinate that is not in the area, that will
|
||||
* trigger a runtime warning.
|
||||
|
@ -1795,12 +1795,12 @@ gtk_combo_box_menu_key (GtkEventControllerKey *key,
|
||||
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (key));
|
||||
event = gtk_get_current_event ();
|
||||
|
||||
if (!gtk_bindings_activate_event (G_OBJECT (widget), (GdkEventKey *)event))
|
||||
if (!gtk_bindings_activate_event (G_OBJECT (widget), event))
|
||||
{
|
||||
gtk_event_controller_key_forward (key, GTK_WIDGET (combo_box));
|
||||
}
|
||||
|
||||
g_object_unref (event);
|
||||
gdk_event_unref (event);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -117,9 +117,11 @@ static gboolean gtk_drop_target_accept (GtkDropTarget *dest,
|
||||
GdkDrop *drop);
|
||||
|
||||
static gboolean gtk_drop_target_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event);
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y);
|
||||
static gboolean gtk_drop_target_filter_event (GtkEventController *controller,
|
||||
const GdkEvent *event);
|
||||
GdkEvent *event);
|
||||
static void gtk_drop_target_set_widget (GtkEventController *controller,
|
||||
GtkWidget *widget);
|
||||
static void gtk_drop_target_unset_widget (GtkEventController *controller);
|
||||
@ -673,7 +675,7 @@ gtk_drop_target_get_contains (GtkDropTarget *dest)
|
||||
|
||||
static gboolean
|
||||
gtk_drop_target_filter_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
switch ((int)gdk_event_get_event_type (event))
|
||||
{
|
||||
@ -755,22 +757,21 @@ gtk_drop_set_current_dest (GdkDrop *drop,
|
||||
|
||||
static gboolean
|
||||
gtk_drop_target_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkDropTarget *dest = GTK_DROP_TARGET (controller);
|
||||
GdkDrop *drop;
|
||||
double x, y;
|
||||
GtkDropStatus status;
|
||||
gboolean found = FALSE;
|
||||
|
||||
drop = gdk_event_get_drop (event);
|
||||
drop = gdk_drag_event_get_drop (event);
|
||||
|
||||
status = gtk_drop_target_get_drop_status (dest, drop);
|
||||
if (status == GTK_DROP_STATUS_DENIED)
|
||||
return FALSE;
|
||||
|
||||
gdk_event_get_coords (event, &x, &y);
|
||||
|
||||
switch ((int)gdk_event_get_event_type (event))
|
||||
{
|
||||
case GDK_DRAG_MOTION:
|
||||
@ -817,7 +818,7 @@ gtk_drag_dest_handle_event (GtkWidget *toplevel,
|
||||
g_return_if_fail (event != NULL);
|
||||
|
||||
event_type = gdk_event_get_event_type (event);
|
||||
drop = gdk_event_get_drop (event);
|
||||
drop = gdk_drag_event_get_drop (event);
|
||||
|
||||
switch ((guint) event_type)
|
||||
{
|
||||
|
@ -198,7 +198,7 @@ gtk_drag_source_get_property (GObject *object,
|
||||
|
||||
static gboolean
|
||||
gtk_drag_source_filter_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
/* Let touchpad swipe events go through, only if they match n-points */
|
||||
if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_SWIPE)
|
||||
@ -207,7 +207,7 @@ gtk_drag_source_filter_event (GtkEventController *controller,
|
||||
guint n_fingers;
|
||||
|
||||
g_object_get (G_OBJECT (controller), "n-points", &n_points, NULL);
|
||||
gdk_event_get_touchpad_gesture_n_fingers (event, &n_fingers);
|
||||
n_fingers = gdk_touchpad_event_get_n_fingers (event);
|
||||
|
||||
if (n_fingers == n_points)
|
||||
return FALSE;
|
||||
|
@ -83,6 +83,7 @@
|
||||
#include "gtkentry.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkeventcontrollerfocus.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkgestureclick.h"
|
||||
|
||||
@ -2307,13 +2308,11 @@ accept_completion_callback (GtkEntryCompletion *completion)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
text_focus_out (GtkEntryCompletion *completion)
|
||||
{
|
||||
if (gtk_widget_get_mapped (completion->priv->popup_window))
|
||||
return FALSE;
|
||||
|
||||
return accept_completion_callback (completion);
|
||||
if (!gtk_widget_get_mapped (completion->priv->popup_window))
|
||||
accept_completion_callback (completion);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2349,7 +2348,9 @@ connect_completion_signals (GtkEntryCompletion *completion)
|
||||
controller = priv->entry_key_controller = gtk_event_controller_key_new ();
|
||||
g_signal_connect (controller, "key-pressed",
|
||||
G_CALLBACK (gtk_entry_completion_key_pressed), completion);
|
||||
g_signal_connect_swapped (controller, "focus-out", G_CALLBACK (text_focus_out), completion);
|
||||
gtk_widget_add_controller (GTK_WIDGET (text), controller);
|
||||
controller = priv->entry_focus_controller = gtk_event_controller_focus_new ();
|
||||
g_signal_connect_swapped (controller, "leave", G_CALLBACK (text_focus_out), completion);
|
||||
gtk_widget_add_controller (GTK_WIDGET (text), controller);
|
||||
|
||||
completion->priv->changed_id =
|
||||
@ -2397,6 +2398,7 @@ disconnect_completion_signals (GtkEntryCompletion *completion)
|
||||
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->priv->entry));
|
||||
|
||||
gtk_widget_remove_controller (GTK_WIDGET (text), completion->priv->entry_key_controller);
|
||||
gtk_widget_remove_controller (GTK_WIDGET (text), completion->priv->entry_focus_controller);
|
||||
|
||||
if (completion->priv->changed_id > 0 &&
|
||||
g_signal_handler_is_connected (text, completion->priv->changed_id))
|
||||
|
@ -78,6 +78,7 @@ struct _GtkEntryCompletionPrivate
|
||||
gchar *case_normalized_key;
|
||||
|
||||
GtkEventController *entry_key_controller;
|
||||
GtkEventController *entry_focus_controller;
|
||||
|
||||
/* only used by GtkEntry when attached: */
|
||||
GtkWidget *popup_window;
|
||||
|
@ -58,6 +58,7 @@ struct _GtkEventControllerPrivate
|
||||
GtkPropagationPhase phase;
|
||||
GtkPropagationLimit limit;
|
||||
char *name;
|
||||
GtkWidget *target;
|
||||
};
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkEventController, gtk_event_controller, G_TYPE_OBJECT)
|
||||
@ -81,50 +82,28 @@ gtk_event_controller_unset_widget (GtkEventController *self)
|
||||
|
||||
static gboolean
|
||||
gtk_event_controller_filter_event_default (GtkEventController *self,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (self);
|
||||
|
||||
if (priv->widget && !gtk_widget_is_sensitive (priv->widget))
|
||||
return TRUE;
|
||||
|
||||
if (priv->limit == GTK_LIMIT_SAME_NATIVE)
|
||||
{
|
||||
GtkWidget *native;
|
||||
GtkWidget *native2;
|
||||
GtkWidget *target;
|
||||
|
||||
native = GTK_WIDGET (gtk_widget_get_native (priv->widget));
|
||||
|
||||
target = GTK_WIDGET (gdk_event_get_target (event));
|
||||
if (target)
|
||||
{
|
||||
native2 = GTK_WIDGET (gtk_widget_get_native (target));
|
||||
if (native == native2)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
target = GTK_WIDGET (gdk_event_get_related_target (event));
|
||||
if (target)
|
||||
{
|
||||
native2 = GTK_WIDGET (gtk_widget_get_native (target));
|
||||
if (native == native2)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_event_controller_handle_event_default (GtkEventController *self,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_event_controller_handle_crossing_default (GtkEventController *self,
|
||||
const GtkCrossingData *crossing,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_event_controller_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@ -202,6 +181,7 @@ gtk_event_controller_class_init (GtkEventControllerClass *klass)
|
||||
klass->unset_widget = gtk_event_controller_unset_widget;
|
||||
klass->filter_event = gtk_event_controller_filter_event_default;
|
||||
klass->handle_event = gtk_event_controller_handle_event_default;
|
||||
klass->handle_crossing = gtk_event_controller_handle_crossing_default;
|
||||
|
||||
object_class->finalize = gtk_event_controller_finalize;
|
||||
object_class->set_property = gtk_event_controller_set_property;
|
||||
@ -265,10 +245,70 @@ gtk_event_controller_init (GtkEventController *controller)
|
||||
priv->limit = GTK_LIMIT_SAME_NATIVE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
same_native (GtkWidget *widget,
|
||||
GtkWidget *target)
|
||||
{
|
||||
GtkWidget *native;
|
||||
GtkWidget *native2;
|
||||
|
||||
if (!widget || !target)
|
||||
return TRUE;
|
||||
|
||||
native = GTK_WIDGET (gtk_widget_get_native (widget));
|
||||
native2 = GTK_WIDGET (gtk_widget_get_native (widget));
|
||||
|
||||
return native == native2;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_event_controller_filter_event (GtkEventController *controller,
|
||||
GdkEvent *event,
|
||||
GtkWidget *target)
|
||||
{
|
||||
GtkEventControllerPrivate *priv;
|
||||
GtkEventControllerClass *controller_class;
|
||||
|
||||
priv = gtk_event_controller_get_instance_private (controller);
|
||||
|
||||
if (priv->widget && !gtk_widget_is_sensitive (priv->widget))
|
||||
return TRUE;
|
||||
|
||||
if (priv->limit == GTK_LIMIT_SAME_NATIVE &&
|
||||
!same_native (priv->widget, target))
|
||||
return TRUE;
|
||||
|
||||
controller_class = GTK_EVENT_CONTROLLER_GET_CLASS (controller);
|
||||
|
||||
return controller_class->filter_event (controller, event);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_event_controller_filter_crossing (GtkEventController *controller,
|
||||
const GtkCrossingData *data)
|
||||
{
|
||||
GtkEventControllerPrivate *priv;
|
||||
|
||||
priv = gtk_event_controller_get_instance_private (controller);
|
||||
|
||||
if (priv->widget && !gtk_widget_is_sensitive (priv->widget))
|
||||
return TRUE;
|
||||
|
||||
if (priv->limit == GTK_LIMIT_SAME_NATIVE &&
|
||||
(!same_native (priv->widget, data->old_target) ||
|
||||
!same_native (priv->widget, data->new_target)))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_handle_event:
|
||||
* @controller: a #GtkEventController
|
||||
* @event: a #GdkEvent
|
||||
* @target: the target widget
|
||||
* @x: event position in widget coordinates, or 0 if not a pointer event
|
||||
* @y: event position in widget coordinates, or 0 if not a pointer event
|
||||
*
|
||||
* Feeds an event into @controller, so it can be interpreted
|
||||
* and the controller actions triggered.
|
||||
@ -278,29 +318,67 @@ gtk_event_controller_init (GtkEventController *controller)
|
||||
**/
|
||||
gboolean
|
||||
gtk_event_controller_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event,
|
||||
GtkWidget *target,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkEventControllerClass *controller_class;
|
||||
GtkEventControllerPrivate *priv;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
priv = gtk_event_controller_get_instance_private (controller);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER (controller), FALSE);
|
||||
g_return_val_if_fail (event != NULL, FALSE);
|
||||
|
||||
controller_class = GTK_EVENT_CONTROLLER_GET_CLASS (controller);
|
||||
|
||||
if (controller_class->filter_event (controller, event))
|
||||
if (gtk_event_controller_filter_event (controller, event, target))
|
||||
return retval;
|
||||
|
||||
if (controller_class->handle_event)
|
||||
{
|
||||
g_object_ref (controller);
|
||||
retval = controller_class->handle_event (controller, event);
|
||||
g_object_unref (controller);
|
||||
}
|
||||
controller_class = GTK_EVENT_CONTROLLER_GET_CLASS (controller);
|
||||
|
||||
priv->target = target;
|
||||
|
||||
g_object_ref (controller);
|
||||
retval = controller_class->handle_event (controller, event, x, y);
|
||||
g_object_unref (controller);
|
||||
|
||||
priv->target = NULL;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_handle_crossing:
|
||||
* @controller: a #GtkEventController
|
||||
* @crossing: a #GtkCrossingData
|
||||
* @x: translated event coordinates
|
||||
* @y: translated event coordinates
|
||||
*
|
||||
* Feeds a crossing event into @controller, so it can be interpreted
|
||||
* and the controller actions triggered.
|
||||
**/
|
||||
void
|
||||
gtk_event_controller_handle_crossing (GtkEventController *controller,
|
||||
const GtkCrossingData *crossing,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkEventControllerClass *controller_class;
|
||||
|
||||
g_return_if_fail (GTK_IS_EVENT_CONTROLLER (controller));
|
||||
g_return_if_fail (crossing != NULL);
|
||||
|
||||
if (gtk_event_controller_filter_crossing (controller, crossing))
|
||||
return;
|
||||
|
||||
controller_class = GTK_EVENT_CONTROLLER_GET_CLASS (controller);
|
||||
|
||||
g_object_ref (controller);
|
||||
controller_class->handle_crossing (controller, crossing, x, y);
|
||||
g_object_unref (controller);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_get_widget:
|
||||
* @controller: a #GtkEventController
|
||||
@ -445,3 +523,41 @@ gtk_event_controller_set_name (GtkEventController *controller,
|
||||
g_free (priv->name);
|
||||
priv->name = g_strdup (name);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_event_controller_get_target (GtkEventController *controller)
|
||||
{
|
||||
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (controller);
|
||||
|
||||
return priv->target;
|
||||
}
|
||||
|
||||
static GtkCrossingData *
|
||||
gtk_crossing_data_copy (GtkCrossingData *crossing)
|
||||
{
|
||||
GtkCrossingData *copy;
|
||||
|
||||
copy = g_new (GtkCrossingData, 1);
|
||||
|
||||
copy->type = crossing->type;
|
||||
copy->direction = crossing->direction;
|
||||
|
||||
if (crossing->old_target)
|
||||
copy->old_target = g_object_ref (crossing->old_target);
|
||||
if (crossing->new_target)
|
||||
copy->new_target = g_object_ref (crossing->new_target);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_crossing_data_free (GtkCrossingData *crossing)
|
||||
{
|
||||
g_clear_object (&crossing->old_target);
|
||||
g_clear_object (&crossing->new_target);
|
||||
|
||||
g_free (crossing);
|
||||
}
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GtkCrossingData, gtk_crossing_data,
|
||||
gtk_crossing_data_copy, gtk_crossing_data_free)
|
||||
|
@ -40,15 +40,16 @@ G_BEGIN_DECLS
|
||||
#define GTK_EVENT_CONTROLLER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_EVENT_CONTROLLER, GtkEventControllerClass))
|
||||
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_crossing_data_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_event_controller_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_event_controller_get_widget (GtkEventController *controller);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_event_controller_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_event_controller_reset (GtkEventController *controller);
|
||||
|
||||
|
318
gtk/gtkeventcontrollerfocus.c
Normal file
318
gtk/gtkeventcontrollerfocus.c
Normal file
@ -0,0 +1,318 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2020, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author(s): Matthias Clasen <mclasen@redhat.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:gtkeventcontrollerfocus
|
||||
* @Short_description: Event controller for focus
|
||||
* @Title: GtkEventControllerFocus
|
||||
* @See_also: #GtkEventController
|
||||
*
|
||||
* #GtkEventControllerFocus is an event controller meant for situations
|
||||
* where you need to know where the focus is.
|
||||
**/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkeventcontrollerprivate.h"
|
||||
#include "gtkeventcontrollerfocus.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkenums.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
struct _GtkEventControllerFocus
|
||||
{
|
||||
GtkEventController parent_instance;
|
||||
|
||||
guint is_focus : 1;
|
||||
guint contains_focus : 1;
|
||||
};
|
||||
|
||||
struct _GtkEventControllerFocusClass
|
||||
{
|
||||
GtkEventControllerClass parent_class;
|
||||
};
|
||||
|
||||
enum {
|
||||
ENTER,
|
||||
LEAVE,
|
||||
N_SIGNALS
|
||||
};
|
||||
|
||||
static guint signals[N_SIGNALS] = { 0 };
|
||||
|
||||
enum {
|
||||
PROP_IS_FOCUS = 1,
|
||||
PROP_CONTAINS_FOCUS,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *props[NUM_PROPERTIES] = { NULL, };
|
||||
|
||||
G_DEFINE_TYPE (GtkEventControllerFocus, gtk_event_controller_focus,
|
||||
GTK_TYPE_EVENT_CONTROLLER)
|
||||
|
||||
static void
|
||||
gtk_event_controller_focus_finalize (GObject *object)
|
||||
{
|
||||
//GtkEventControllerFocus *focus = GTK_EVENT_CONTROLLER_FOCUS (object);
|
||||
|
||||
G_OBJECT_CLASS (gtk_event_controller_focus_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
update_focus (GtkEventController *controller,
|
||||
const GtkCrossingData *crossing)
|
||||
{
|
||||
GtkEventControllerFocus *focus = GTK_EVENT_CONTROLLER_FOCUS (controller);
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (controller);
|
||||
gboolean is_focus = FALSE;
|
||||
gboolean contains_focus = FALSE;
|
||||
gboolean enter = FALSE;
|
||||
gboolean leave = FALSE;
|
||||
|
||||
if (crossing->direction == GTK_CROSSING_IN)
|
||||
{
|
||||
if (crossing->new_descendent != NULL)
|
||||
{
|
||||
contains_focus = TRUE;
|
||||
}
|
||||
if (crossing->new_target == widget)
|
||||
{
|
||||
contains_focus = TRUE;
|
||||
is_focus = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (crossing->new_descendent != NULL ||
|
||||
crossing->new_target == widget)
|
||||
contains_focus = TRUE;
|
||||
is_focus = FALSE;
|
||||
}
|
||||
|
||||
if (focus->contains_focus != contains_focus)
|
||||
{
|
||||
enter = contains_focus;
|
||||
leave = !contains_focus;
|
||||
}
|
||||
|
||||
if (leave)
|
||||
g_signal_emit (controller, signals[LEAVE], 0);
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (focus));
|
||||
if (focus->is_focus != is_focus)
|
||||
{
|
||||
focus->is_focus = is_focus;
|
||||
g_object_notify (G_OBJECT (focus), "is-focus");
|
||||
}
|
||||
|
||||
if (focus->contains_focus != contains_focus)
|
||||
{
|
||||
focus->contains_focus = contains_focus;
|
||||
g_object_notify (G_OBJECT (focus), "contains-focus");
|
||||
}
|
||||
g_object_thaw_notify (G_OBJECT (focus));
|
||||
|
||||
if (enter)
|
||||
g_signal_emit (controller, signals[ENTER], 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_event_controller_focus_handle_crossing (GtkEventController *controller,
|
||||
const GtkCrossingData *crossing,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
if (crossing->type == GTK_CROSSING_FOCUS)
|
||||
update_focus (controller, crossing);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_event_controller_focus_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkEventControllerFocus *controller = GTK_EVENT_CONTROLLER_FOCUS (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_IS_FOCUS:
|
||||
g_value_set_boolean (value, controller->is_focus);
|
||||
break;
|
||||
|
||||
case PROP_CONTAINS_FOCUS:
|
||||
g_value_set_boolean (value, controller->contains_focus);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_event_controller_focus_class_init (GtkEventControllerFocusClass *klass)
|
||||
{
|
||||
GtkEventControllerClass *controller_class = GTK_EVENT_CONTROLLER_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_event_controller_focus_finalize;
|
||||
object_class->get_property = gtk_event_controller_focus_get_property;
|
||||
controller_class->handle_crossing = gtk_event_controller_focus_handle_crossing;
|
||||
|
||||
/**
|
||||
* GtkEventControllerFocus:is-focus:
|
||||
*
|
||||
* Whether focus is in the controllers widget itself,
|
||||
* opposed to in a descendent widget. See also
|
||||
* #GtkEventControllerFocus:contains-focus.
|
||||
*
|
||||
* When handling focus events, this property is updated
|
||||
* before #GtkEventControllerFocus::focus-in or
|
||||
* #GtkEventControllerFocus::focus-out are emitted.
|
||||
*/
|
||||
props[PROP_IS_FOCUS] =
|
||||
g_param_spec_boolean ("is-focus",
|
||||
P_("Is Focus"),
|
||||
P_("Whether the focus is in the controllers widget"),
|
||||
FALSE,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
/**
|
||||
* GtkEventControllerFocus:contains-focus:
|
||||
*
|
||||
* Whether focus is contain in the controllers widget. See
|
||||
* See #GtkEventControllerFocus:is-focus for whether the focus is in the widget itself
|
||||
* or inside a descendent.
|
||||
*
|
||||
* When handling focus events, this property is updated
|
||||
* before #GtkEventControllerFocus::focus-in or
|
||||
* #GtkEventControllerFocus::focus-out are emitted.
|
||||
*/
|
||||
props[PROP_CONTAINS_FOCUS] =
|
||||
g_param_spec_boolean ("contains-focus",
|
||||
P_("Contains Focus"),
|
||||
P_("Whether the focus is in a descendant of the controllers widget"),
|
||||
FALSE,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
g_object_class_install_properties (object_class, NUM_PROPERTIES, props);
|
||||
|
||||
/**
|
||||
* GtkEventControllerFocus::enter:
|
||||
* @controller: the object which received the signal
|
||||
*
|
||||
* This signal is emitted whenever the focus enters into the
|
||||
* widget or one of its descendents.
|
||||
*
|
||||
* Note that this means you may not get an ::enter signal
|
||||
* even though the widget becomes the focus location, in
|
||||
* certain cases (such as when the focus moves from a descendent
|
||||
* of the widget to the widget itself). If you are interested
|
||||
* in these cases, you can monitor the #GtkEventControllerFocus:is-focus
|
||||
* property for changes.
|
||||
*/
|
||||
signals[ENTER] =
|
||||
g_signal_new (I_("enter"),
|
||||
GTK_TYPE_EVENT_CONTROLLER_FOCUS,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0, NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/**
|
||||
* GtkEventControllerFocus::leave:
|
||||
* @controller: the object which received the signal
|
||||
*
|
||||
* This signal is emitted whenever the focus leaves the
|
||||
* widget hierarchy that is rooted at the widget that the
|
||||
* controller is attached to.
|
||||
*
|
||||
* Note that this means you may not get a ::leave signal
|
||||
* even though the focus moves away from the widget, in
|
||||
* certain cases (such as when the focus moves from the widget
|
||||
* to a descendent). If you are interested in these cases, you
|
||||
* can monitor the #GtkEventControllerFocus:is-focus property
|
||||
* for changes.
|
||||
*/
|
||||
signals[LEAVE] =
|
||||
g_signal_new (I_("leave"),
|
||||
GTK_TYPE_EVENT_CONTROLLER_FOCUS,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0, NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_event_controller_focus_init (GtkEventControllerFocus *controller)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_focus_new:
|
||||
*
|
||||
* Creates a new event controller that will handle focus events.
|
||||
*
|
||||
* Returns: a new #GtkEventControllerFocus
|
||||
**/
|
||||
GtkEventController *
|
||||
gtk_event_controller_focus_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_EVENT_CONTROLLER_FOCUS, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_focus_contains_focus:
|
||||
* @self: a #GtkEventControllerFocus
|
||||
*
|
||||
* Returns the value of the GtkEventControllerFocus:contains-focus property.
|
||||
*
|
||||
* Returns: %TRUE if focus is within @self or one of its children
|
||||
*/
|
||||
gboolean
|
||||
gtk_event_controller_focus_contains_focus (GtkEventControllerFocus *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_FOCUS (self), FALSE);
|
||||
|
||||
return self->contains_focus;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_focus_is_focus:
|
||||
* @self: a #GtkEventControllerFocus
|
||||
*
|
||||
* Returns the value of the GtkEventControllerFocus:is-focus property.
|
||||
*
|
||||
* Returns: %TRUE if focus is within @self but not one of its children
|
||||
*/
|
||||
gboolean
|
||||
gtk_event_controller_focus_is_focus (GtkEventControllerFocus *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_FOCUS (self), FALSE);
|
||||
|
||||
return self->is_focus;
|
||||
}
|
57
gtk/gtkeventcontrollerfocus.h
Normal file
57
gtk/gtkeventcontrollerfocus.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2020, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author(s): Matthias Clasen <mclasen@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_EVENT_CONTROLLER_FOCUS_H__
|
||||
#define __GTK_EVENT_CONTROLLER_FOCUS_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkeventcontroller.h>
|
||||
#include <gtk/gtkimcontext.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_EVENT_CONTROLLER_FOCUS (gtk_event_controller_focus_get_type ())
|
||||
#define GTK_EVENT_CONTROLLER_FOCUS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_EVENT_CONTROLLER_FOCUS, GtkEventControllerFocus))
|
||||
#define GTK_EVENT_CONTROLLER_FOCUS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_EVENT_CONTROLLER_FOCUS, GtkEventControllerFocusClass))
|
||||
#define GTK_IS_EVENT_CONTROLLER_FOCUS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_EVENT_CONTROLLER_FOCUS))
|
||||
#define GTK_IS_EVENT_CONTROLLER_FOCUS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_EVENT_CONTROLLER_FOCUS))
|
||||
#define GTK_EVENT_CONTROLLER_FOCUS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_EVENT_CONTROLLER_FOCUS, GtkEventControllerFocusClass))
|
||||
|
||||
typedef struct _GtkEventControllerFocus GtkEventControllerFocus;
|
||||
typedef struct _GtkEventControllerFocusClass GtkEventControllerFocusClass;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_event_controller_focus_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkEventController *gtk_event_controller_focus_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_event_controller_focus_contains_focus (GtkEventControllerFocus *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_event_controller_focus_is_focus (GtkEventControllerFocus *self);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_EVENT_CONTROLLER_FOCUS_H__ */
|
@ -38,6 +38,7 @@
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkenums.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
@ -49,10 +50,9 @@ struct _GtkEventControllerKey
|
||||
|
||||
GdkModifierType state;
|
||||
|
||||
const GdkEvent *current_event;
|
||||
GdkEvent *current_event;
|
||||
|
||||
guint is_focus : 1;
|
||||
guint contains_focus : 1;
|
||||
gboolean is_focus;
|
||||
};
|
||||
|
||||
struct _GtkEventControllerKeyClass
|
||||
@ -65,21 +65,11 @@ enum {
|
||||
KEY_RELEASED,
|
||||
MODIFIERS,
|
||||
IM_UPDATE,
|
||||
FOCUS_IN,
|
||||
FOCUS_OUT,
|
||||
N_SIGNALS
|
||||
};
|
||||
|
||||
static guint signals[N_SIGNALS] = { 0 };
|
||||
|
||||
enum {
|
||||
PROP_IS_FOCUS = 1,
|
||||
PROP_CONTAINS_FOCUS,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *props[NUM_PROPERTIES] = { NULL, };
|
||||
|
||||
G_DEFINE_TYPE (GtkEventControllerKey, gtk_event_controller_key,
|
||||
GTK_TYPE_EVENT_CONTROLLER)
|
||||
|
||||
@ -94,60 +84,11 @@ gtk_event_controller_key_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (gtk_event_controller_key_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
update_focus (GtkEventControllerKey *key,
|
||||
gboolean focus_in,
|
||||
GdkNotifyType detail)
|
||||
{
|
||||
gboolean is_focus;
|
||||
gboolean contains_focus;
|
||||
|
||||
switch (detail)
|
||||
{
|
||||
case GDK_NOTIFY_VIRTUAL:
|
||||
case GDK_NOTIFY_NONLINEAR_VIRTUAL:
|
||||
is_focus = FALSE;
|
||||
contains_focus = focus_in;
|
||||
break;
|
||||
case GDK_NOTIFY_ANCESTOR:
|
||||
case GDK_NOTIFY_NONLINEAR:
|
||||
is_focus = focus_in;
|
||||
contains_focus = is_focus;
|
||||
break;
|
||||
case GDK_NOTIFY_INFERIOR:
|
||||
is_focus = focus_in;
|
||||
contains_focus = TRUE;
|
||||
break;
|
||||
case GDK_NOTIFY_UNKNOWN:
|
||||
default:
|
||||
g_warning ("Unknown focus change detail");
|
||||
return;
|
||||
}
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (key));
|
||||
if (key->is_focus != is_focus)
|
||||
{
|
||||
key->is_focus = is_focus;
|
||||
g_object_notify (G_OBJECT (key), "is-focus");
|
||||
if (key->im_context)
|
||||
{
|
||||
if (focus_in)
|
||||
gtk_im_context_focus_in (key->im_context);
|
||||
else
|
||||
gtk_im_context_focus_out (key->im_context);
|
||||
}
|
||||
}
|
||||
if (key->contains_focus != contains_focus)
|
||||
{
|
||||
key->contains_focus = contains_focus;
|
||||
g_object_notify (G_OBJECT (key), "contains-focus");
|
||||
}
|
||||
g_object_thaw_notify (G_OBJECT (key));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_event_controller_key_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkEventControllerKey *key = GTK_EVENT_CONTROLLER_KEY (controller);
|
||||
GdkEventType event_type = gdk_event_get_event_type (event);
|
||||
@ -156,35 +97,11 @@ gtk_event_controller_key_handle_event (GtkEventController *controller,
|
||||
guint keyval;
|
||||
gboolean handled = FALSE;
|
||||
|
||||
if (event_type == GDK_FOCUS_CHANGE)
|
||||
{
|
||||
gboolean focus_in;
|
||||
GdkCrossingMode mode;
|
||||
GdkNotifyType detail;
|
||||
|
||||
gdk_event_get_focus_in (event, &focus_in);
|
||||
gdk_event_get_crossing_mode (event, &mode);
|
||||
gdk_event_get_crossing_detail (event, &detail);
|
||||
|
||||
update_focus (key, focus_in, detail);
|
||||
|
||||
key->current_event = event;
|
||||
|
||||
if (focus_in)
|
||||
g_signal_emit (controller, signals[FOCUS_IN], 0, mode, detail);
|
||||
else
|
||||
g_signal_emit (controller, signals[FOCUS_OUT], 0, mode, detail);
|
||||
|
||||
key->current_event = NULL;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (event_type != GDK_KEY_PRESS && event_type != GDK_KEY_RELEASE)
|
||||
return FALSE;
|
||||
|
||||
if (key->im_context &&
|
||||
gtk_im_context_filter_keypress (key->im_context, (GdkEventKey *) event))
|
||||
gtk_im_context_filter_keypress (key->im_context, event))
|
||||
{
|
||||
g_signal_emit (controller, signals[IM_UPDATE], 0);
|
||||
return TRUE;
|
||||
@ -192,7 +109,7 @@ gtk_event_controller_key_handle_event (GtkEventController *controller,
|
||||
|
||||
key->current_event = event;
|
||||
|
||||
gdk_event_get_state (event, &state);
|
||||
state = gdk_event_get_modifier_state (event);
|
||||
if (key->state != state)
|
||||
{
|
||||
gboolean unused;
|
||||
@ -201,8 +118,8 @@ gtk_event_controller_key_handle_event (GtkEventController *controller,
|
||||
g_signal_emit (controller, signals[MODIFIERS], 0, state, &unused);
|
||||
}
|
||||
|
||||
gdk_event_get_keycode (event, &keycode);
|
||||
gdk_event_get_keyval (event, &keyval);
|
||||
keycode = gdk_key_event_get_keycode (event);
|
||||
keyval = gdk_key_event_get_keyval (event);
|
||||
|
||||
if (event_type == GDK_KEY_PRESS)
|
||||
{
|
||||
@ -228,25 +145,40 @@ gtk_event_controller_key_handle_event (GtkEventController *controller,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_event_controller_key_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gtk_event_controller_key_handle_crossing (GtkEventController *controller,
|
||||
const GtkCrossingData *crossing,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkEventControllerKey *controller = GTK_EVENT_CONTROLLER_KEY (object);
|
||||
GtkEventControllerKey *key = GTK_EVENT_CONTROLLER_KEY (controller);
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (controller);
|
||||
gboolean start_crossing, end_crossing;
|
||||
gboolean is_focus;
|
||||
|
||||
switch (prop_id)
|
||||
if (crossing->type != GTK_CROSSING_FOCUS)
|
||||
return;
|
||||
|
||||
start_crossing = crossing->direction == GTK_CROSSING_OUT &&
|
||||
widget == crossing->old_target;
|
||||
end_crossing = crossing->direction == GTK_CROSSING_IN &&
|
||||
widget == crossing->new_target;
|
||||
|
||||
if (!start_crossing && !end_crossing)
|
||||
return;
|
||||
|
||||
is_focus = end_crossing;
|
||||
|
||||
if (key->is_focus != is_focus)
|
||||
{
|
||||
case PROP_IS_FOCUS:
|
||||
g_value_set_boolean (value, controller->is_focus);
|
||||
break;
|
||||
key->is_focus = is_focus;
|
||||
|
||||
case PROP_CONTAINS_FOCUS:
|
||||
g_value_set_boolean (value, controller->contains_focus);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
if (key->im_context)
|
||||
{
|
||||
if (is_focus)
|
||||
gtk_im_context_focus_in (key->im_context);
|
||||
else
|
||||
gtk_im_context_focus_out (key->im_context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,46 +189,8 @@ gtk_event_controller_key_class_init (GtkEventControllerKeyClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_event_controller_key_finalize;
|
||||
object_class->get_property = gtk_event_controller_key_get_property;
|
||||
controller_class->handle_event = gtk_event_controller_key_handle_event;
|
||||
|
||||
/**
|
||||
* GtkEventControllerKey:is-focus:
|
||||
*
|
||||
* Whether focus is in the controllers widget itself,
|
||||
* opposed to in a descendent widget. See also
|
||||
* #GtkEventControllerKey:contains-focus.
|
||||
*
|
||||
* When handling focus events, this property is updated
|
||||
* before #GtkEventControllerKey::focus-in or
|
||||
* #GtkEventControllerKey::focus-out are emitted.
|
||||
*/
|
||||
props[PROP_IS_FOCUS] =
|
||||
g_param_spec_boolean ("is-focus",
|
||||
P_("Is Focus"),
|
||||
P_("Whether the focus is in the controllers widget"),
|
||||
FALSE,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
/**
|
||||
* GtkEventControllerKey:contains-focus:
|
||||
*
|
||||
* Whether focus is contain in the controllers widget. See
|
||||
* See #GtkEventControllerKey:is-focus for whether the focus is in the widget itself
|
||||
* or inside a descendent.
|
||||
*
|
||||
* When handling focus events, this property is updated
|
||||
* before #GtkEventControllerKey::focus-in or
|
||||
* #GtkEventControllerKey::focus-out are emitted.
|
||||
*/
|
||||
props[PROP_CONTAINS_FOCUS] =
|
||||
g_param_spec_boolean ("contains-focus",
|
||||
P_("Contains Focus"),
|
||||
P_("Whether the focus is in a descendant of the controllers widget"),
|
||||
FALSE,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
g_object_class_install_properties (object_class, NUM_PROPERTIES, props);
|
||||
controller_class->handle_crossing = gtk_event_controller_key_handle_crossing;
|
||||
|
||||
/**
|
||||
* GtkEventControllerKey::key-pressed:
|
||||
@ -364,7 +258,7 @@ gtk_event_controller_key_class_init (GtkEventControllerKeyClass *klass)
|
||||
|
||||
/**
|
||||
* GtkEventControllerKey::im-update:
|
||||
* @controller: the object which received the signal.
|
||||
* @controller: the object which received the signal
|
||||
*
|
||||
* This signal is emitted whenever the input method context filters away a
|
||||
* keypress and prevents the @controller receiving it. See
|
||||
@ -378,48 +272,6 @@ gtk_event_controller_key_class_init (GtkEventControllerKeyClass *klass)
|
||||
0, NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/**
|
||||
* GtkEventControllerKey::focus-in:
|
||||
* @controller: the object which received the signal.
|
||||
* @mode: crossing mode indicating what caused this change
|
||||
* @detail: detail indication where the focus is coming from
|
||||
*
|
||||
* This signal is emitted whenever the widget controlled
|
||||
* by the @controller or one of its descendants) is given
|
||||
* the keyboard focus.
|
||||
*/
|
||||
signals[FOCUS_IN] =
|
||||
g_signal_new (I_("focus-in"),
|
||||
GTK_TYPE_EVENT_CONTROLLER_KEY,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0, NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE,
|
||||
2,
|
||||
GDK_TYPE_CROSSING_MODE,
|
||||
GDK_TYPE_NOTIFY_TYPE);
|
||||
|
||||
/**
|
||||
* GtkEventControllerKey::focus-out:
|
||||
* @controller: the object which received the signal.
|
||||
* @mode: crossing mode indicating what caused this change
|
||||
* @detail: detail indication where the focus is going
|
||||
*
|
||||
* This signal is emitted whenever the widget controlled
|
||||
* by the @controller (or one of its descendants) loses
|
||||
* the keyboard focus.
|
||||
*/
|
||||
signals[FOCUS_OUT] =
|
||||
g_signal_new (I_("focus-out"),
|
||||
GTK_TYPE_EVENT_CONTROLLER_KEY,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0, NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE,
|
||||
2,
|
||||
GDK_TYPE_CROSSING_MODE,
|
||||
GDK_TYPE_NOTIFY_TYPE);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -506,17 +358,17 @@ gtk_event_controller_key_forward (GtkEventControllerKey *controller,
|
||||
if (!gtk_widget_get_realized (widget))
|
||||
gtk_widget_realize (widget);
|
||||
|
||||
if (gtk_widget_run_controllers (widget, controller->current_event,
|
||||
GTK_PHASE_CAPTURE))
|
||||
if (gtk_widget_run_controllers (widget, controller->current_event, widget, 0, 0,
|
||||
GTK_PHASE_CAPTURE))
|
||||
return TRUE;
|
||||
if (gtk_widget_run_controllers (widget, controller->current_event,
|
||||
GTK_PHASE_TARGET))
|
||||
if (gtk_widget_run_controllers (widget, controller->current_event, widget, 0, 0,
|
||||
GTK_PHASE_TARGET))
|
||||
return TRUE;
|
||||
if (gtk_widget_run_controllers (widget, controller->current_event,
|
||||
GTK_PHASE_BUBBLE))
|
||||
if (gtk_widget_run_controllers (widget, controller->current_event, widget, 0, 0,
|
||||
GTK_PHASE_BUBBLE))
|
||||
return TRUE;
|
||||
|
||||
if (gtk_bindings_activate_event (G_OBJECT (widget), (GdkEventKey *)controller->current_event))
|
||||
if (gtk_bindings_activate_event (G_OBJECT (widget), controller->current_event))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
@ -527,112 +379,15 @@ gtk_event_controller_key_forward (GtkEventControllerKey *controller,
|
||||
* @controller: a #GtkEventControllerKey
|
||||
*
|
||||
* Gets the key group of the current event of this @controller.
|
||||
* See gdk_event_get_key_group().
|
||||
* See gdk_key_event_get_group().
|
||||
*
|
||||
* Returns: the key group
|
||||
**/
|
||||
guint
|
||||
gtk_event_controller_key_get_group (GtkEventControllerKey *controller)
|
||||
{
|
||||
guint group;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_KEY (controller), FALSE);
|
||||
g_return_val_if_fail (controller->current_event != NULL, FALSE);
|
||||
|
||||
gdk_event_get_key_group (controller->current_event, &group);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_key_get_focus_origin:
|
||||
* @controller: a #GtkEventControllerKey
|
||||
*
|
||||
* Returns the widget that was holding focus before.
|
||||
*
|
||||
* This function can only be used in handlers for the
|
||||
* #GtkEventControllerKey::focus-in and
|
||||
* #GtkEventControllerKey::focus-out signals.
|
||||
*
|
||||
* Returns: (transfer none): the previous focus
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_event_controller_key_get_focus_origin (GtkEventControllerKey *controller)
|
||||
{
|
||||
gboolean focus_in;
|
||||
GtkWidget *origin;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_KEY (controller), NULL);
|
||||
g_return_val_if_fail (controller->current_event != NULL, NULL);
|
||||
g_return_val_if_fail (gdk_event_get_event_type (controller->current_event) == GDK_FOCUS_CHANGE, NULL);
|
||||
|
||||
gdk_event_get_focus_in (controller->current_event, &focus_in);
|
||||
|
||||
if (focus_in)
|
||||
origin = (GtkWidget *)gdk_event_get_related_target (controller->current_event);
|
||||
else
|
||||
origin = (GtkWidget *)gdk_event_get_target (controller->current_event);
|
||||
|
||||
return origin;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_key_get_focus_target:
|
||||
* @controller: a #GtkEventControllerKey
|
||||
*
|
||||
* Returns the widget that will be holding focus afterwards.
|
||||
*
|
||||
* This function can only be used in handlers for the
|
||||
* #GtkEventControllerKey::focus-in and
|
||||
* #GtkEventControllerKey::focus-out signals.
|
||||
*
|
||||
* Returns: (transfer none): the next focus
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_event_controller_key_get_focus_target (GtkEventControllerKey *controller)
|
||||
{
|
||||
gboolean focus_in;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_KEY (controller), NULL);
|
||||
g_return_val_if_fail (controller->current_event != NULL, NULL);
|
||||
g_return_val_if_fail (gdk_event_get_event_type (controller->current_event) == GDK_FOCUS_CHANGE, NULL);
|
||||
|
||||
gdk_event_get_focus_in (controller->current_event, &focus_in);
|
||||
|
||||
if (focus_in)
|
||||
return (GtkWidget *)gdk_event_get_target (controller->current_event);
|
||||
else
|
||||
return (GtkWidget *)gdk_event_get_related_target (controller->current_event);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_key_contains_focus:
|
||||
* @self: a #GtkEventControllerKey
|
||||
*
|
||||
* Returns the value of the GtkEventControllerKey:contains-focus property.
|
||||
*
|
||||
* Returns: %TRUE if focus is within @self or one of its children
|
||||
*/
|
||||
gboolean
|
||||
gtk_event_controller_key_contains_focus (GtkEventControllerKey *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_KEY (self), FALSE);
|
||||
|
||||
return self->contains_focus;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_key_is_focus:
|
||||
* @self: a #GtkEventControllerKey
|
||||
*
|
||||
* Returns the value of the GtkEventControllerKey:is-focus property.
|
||||
*
|
||||
* Returns: %TRUE if focus is within @self but not one of its children
|
||||
*/
|
||||
gboolean
|
||||
gtk_event_controller_key_is_focus (GtkEventControllerKey *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_KEY (self), FALSE);
|
||||
|
||||
return self->is_focus;
|
||||
return gdk_key_event_get_group (controller->current_event);
|
||||
}
|
||||
|
@ -58,16 +58,6 @@ gboolean gtk_event_controller_key_forward (GtkEventControllerK
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gtk_event_controller_key_get_group (GtkEventControllerKey *controller);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_event_controller_key_get_focus_origin (GtkEventControllerKey *controller);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_event_controller_key_get_focus_target (GtkEventControllerKey *controller);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_event_controller_key_contains_focus (GtkEventControllerKey *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_event_controller_key_is_focus (GtkEventControllerKey *self);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -59,7 +59,9 @@ G_DEFINE_TYPE (GtkEventControllerLegacy, gtk_event_controller_legacy,
|
||||
|
||||
static gboolean
|
||||
gtk_event_controller_legacy_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
gboolean handled;
|
||||
|
||||
|
@ -41,8 +41,6 @@ struct _GtkEventControllerMotion
|
||||
{
|
||||
GtkEventController parent_instance;
|
||||
|
||||
const GdkEvent *current_event;
|
||||
|
||||
guint is_pointer : 1;
|
||||
guint contains_pointer : 1;
|
||||
};
|
||||
@ -71,35 +69,65 @@ static guint signals[N_SIGNALS] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE (GtkEventControllerMotion, gtk_event_controller_motion, GTK_TYPE_EVENT_CONTROLLER)
|
||||
|
||||
static void
|
||||
update_pointer_focus (GtkEventControllerMotion *motion,
|
||||
gboolean enter,
|
||||
GdkNotifyType detail)
|
||||
static gboolean
|
||||
gtk_event_controller_motion_handle_event (GtkEventController *controller,
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
gboolean is_pointer;
|
||||
gboolean contains_pointer;
|
||||
GtkEventControllerClass *parent_class;
|
||||
GdkEventType type;
|
||||
|
||||
switch (detail)
|
||||
type = gdk_event_get_event_type (event);
|
||||
if (type == GDK_MOTION_NOTIFY)
|
||||
g_signal_emit (controller, signals[MOTION], 0, x, y);
|
||||
|
||||
parent_class = GTK_EVENT_CONTROLLER_CLASS (gtk_event_controller_motion_parent_class);
|
||||
|
||||
return parent_class->handle_event (controller, event, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
update_pointer_focus (GtkEventController *controller,
|
||||
const GtkCrossingData *crossing,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkEventControllerMotion *motion = GTK_EVENT_CONTROLLER_MOTION (controller);
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (controller);
|
||||
gboolean is_pointer = FALSE;
|
||||
gboolean contains_pointer = FALSE;
|
||||
gboolean enter = FALSE;
|
||||
gboolean leave = FALSE;
|
||||
|
||||
if (crossing->direction == GTK_CROSSING_IN)
|
||||
{
|
||||
case GDK_NOTIFY_VIRTUAL:
|
||||
case GDK_NOTIFY_NONLINEAR_VIRTUAL:
|
||||
is_pointer = FALSE;
|
||||
contains_pointer = enter;
|
||||
break;
|
||||
case GDK_NOTIFY_ANCESTOR:
|
||||
case GDK_NOTIFY_NONLINEAR:
|
||||
is_pointer = enter;
|
||||
contains_pointer = enter;
|
||||
break;
|
||||
case GDK_NOTIFY_INFERIOR:
|
||||
is_pointer = enter;
|
||||
contains_pointer = TRUE;
|
||||
break;
|
||||
case GDK_NOTIFY_UNKNOWN:
|
||||
default:
|
||||
g_warning ("Unknown crossing detail");
|
||||
return;
|
||||
if (crossing->new_descendent != NULL)
|
||||
{
|
||||
contains_pointer = TRUE;
|
||||
}
|
||||
if (crossing->new_target == widget)
|
||||
{
|
||||
contains_pointer = TRUE;
|
||||
is_pointer = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (crossing->new_descendent != NULL ||
|
||||
crossing->new_target == widget)
|
||||
contains_pointer = TRUE;
|
||||
is_pointer = FALSE;
|
||||
}
|
||||
|
||||
if (motion->contains_pointer != contains_pointer)
|
||||
{
|
||||
enter = contains_pointer;
|
||||
leave = !contains_pointer;
|
||||
}
|
||||
|
||||
if (leave)
|
||||
g_signal_emit (controller, signals[LEAVE], 0, crossing->mode);
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (motion));
|
||||
if (motion->is_pointer != is_pointer)
|
||||
@ -113,63 +141,19 @@ update_pointer_focus (GtkEventControllerMotion *motion,
|
||||
g_object_notify (G_OBJECT (motion), "contains-pointer");
|
||||
}
|
||||
g_object_thaw_notify (G_OBJECT (motion));
|
||||
|
||||
if (enter)
|
||||
g_signal_emit (controller, signals[ENTER], 0, x, y, crossing->mode);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_event_controller_motion_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
static void
|
||||
gtk_event_controller_motion_handle_crossing (GtkEventController *controller,
|
||||
const GtkCrossingData *crossing,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkEventControllerMotion *motion = GTK_EVENT_CONTROLLER_MOTION (controller);
|
||||
GtkEventControllerClass *parent_class;
|
||||
GdkEventType type;
|
||||
|
||||
type = gdk_event_get_event_type (event);
|
||||
if (type == GDK_ENTER_NOTIFY)
|
||||
{
|
||||
double x, y;
|
||||
GdkCrossingMode mode;
|
||||
GdkNotifyType detail;
|
||||
|
||||
gdk_event_get_coords (event, &x, &y);
|
||||
gdk_event_get_crossing_mode (event, &mode);
|
||||
gdk_event_get_crossing_detail (event, &detail);
|
||||
|
||||
update_pointer_focus (motion, TRUE, detail);
|
||||
|
||||
motion->current_event = event;
|
||||
|
||||
g_signal_emit (controller, signals[ENTER], 0, x, y, mode, detail);
|
||||
|
||||
motion->current_event = NULL;
|
||||
}
|
||||
else if (type == GDK_LEAVE_NOTIFY)
|
||||
{
|
||||
GdkCrossingMode mode;
|
||||
GdkNotifyType detail;
|
||||
|
||||
gdk_event_get_crossing_mode (event, &mode);
|
||||
gdk_event_get_crossing_detail (event, &detail);
|
||||
|
||||
update_pointer_focus (motion, FALSE, detail);
|
||||
|
||||
motion->current_event = event;
|
||||
|
||||
g_signal_emit (controller, signals[LEAVE], 0, mode, detail);
|
||||
|
||||
motion->current_event = NULL;
|
||||
}
|
||||
else if (type == GDK_MOTION_NOTIFY)
|
||||
{
|
||||
double x, y;
|
||||
|
||||
gdk_event_get_coords (event, &x, &y);
|
||||
|
||||
g_signal_emit (controller, signals[MOTION], 0, x, y);
|
||||
}
|
||||
|
||||
parent_class = GTK_EVENT_CONTROLLER_CLASS (gtk_event_controller_motion_parent_class);
|
||||
|
||||
return parent_class->handle_event (controller, event);
|
||||
if (crossing->type == GTK_CROSSING_POINTER)
|
||||
update_pointer_focus (controller, crossing, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -204,6 +188,7 @@ gtk_event_controller_motion_class_init (GtkEventControllerMotionClass *klass)
|
||||
object_class->get_property = gtk_event_controller_motion_get_property;
|
||||
|
||||
controller_class->handle_event = gtk_event_controller_motion_handle_event;
|
||||
controller_class->handle_crossing = gtk_event_controller_motion_handle_crossing;
|
||||
|
||||
/**
|
||||
* GtkEventControllerMotion:is-pointer:
|
||||
@ -244,51 +229,39 @@ gtk_event_controller_motion_class_init (GtkEventControllerMotionClass *klass)
|
||||
|
||||
/**
|
||||
* GtkEventControllerMotion::enter:
|
||||
* @controller: The object that received the signal
|
||||
* @x: the x coordinate
|
||||
* @y: the y coordinate
|
||||
* @crossing_mode: the crossing mode of this event
|
||||
* @notify_type: the kind of crossing event
|
||||
* @controller: the object which received the signal
|
||||
* @x: coordinates of pointer location
|
||||
* @y: coordinates of pointer location
|
||||
* @mode: crossing mode
|
||||
*
|
||||
* Signals that the pointer has entered the widget.
|
||||
*/
|
||||
signals[ENTER] =
|
||||
g_signal_new (I_("enter"),
|
||||
GTK_TYPE_EVENT_CONTROLLER_MOTION,
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0, NULL, NULL,
|
||||
_gtk_marshal_VOID__DOUBLE_DOUBLE_ENUM_ENUM,
|
||||
G_TYPE_NONE,
|
||||
4,
|
||||
NULL,
|
||||
G_TYPE_NONE, 3,
|
||||
G_TYPE_DOUBLE,
|
||||
G_TYPE_DOUBLE,
|
||||
GDK_TYPE_CROSSING_MODE,
|
||||
GDK_TYPE_NOTIFY_TYPE);
|
||||
g_signal_set_va_marshaller (signals[ENTER],
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
_gtk_marshal_VOID__DOUBLE_DOUBLE_ENUM_ENUMv);
|
||||
GDK_TYPE_CROSSING_MODE);
|
||||
|
||||
/**
|
||||
* GtkEventControllerMotion::leave:
|
||||
* @controller: The object that received the signal
|
||||
* @crossing_mode: the crossing mode of this event
|
||||
* @notify_type: the kind of crossing event
|
||||
* @controller: the object which received the signal
|
||||
* @mode: crossing mode
|
||||
*
|
||||
* Signals that pointer has left the widget.
|
||||
* Signals that the pointer has left the widget.
|
||||
*/
|
||||
signals[LEAVE] =
|
||||
g_signal_new (I_("leave"),
|
||||
GTK_TYPE_EVENT_CONTROLLER_MOTION,
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0, NULL, NULL,
|
||||
_gtk_marshal_VOID__ENUM_ENUM,
|
||||
G_TYPE_NONE,
|
||||
2,
|
||||
GDK_TYPE_CROSSING_MODE,
|
||||
GDK_TYPE_NOTIFY_TYPE);
|
||||
g_signal_set_va_marshaller (signals[LEAVE],
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
_gtk_marshal_VOID__ENUM_ENUMv);
|
||||
NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
GDK_TYPE_CROSSING_MODE);
|
||||
|
||||
/**
|
||||
* GtkEventControllerMotion::motion:
|
||||
@ -329,58 +302,6 @@ gtk_event_controller_motion_new (void)
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_motion_get_pointer_origin:
|
||||
* @controller: a #GtkEventControllerMotion
|
||||
*
|
||||
* Returns the widget that contained the pointer before.
|
||||
*
|
||||
* This function can only be used in handlers for the
|
||||
* #GtkEventControllerMotion::enter and
|
||||
* #GtkEventControllerMotion::leave signals.
|
||||
*
|
||||
* Returns: (transfer none): the previous pointer focus
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_event_controller_motion_get_pointer_origin (GtkEventControllerMotion *controller)
|
||||
{
|
||||
GtkWidget *origin;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_MOTION (controller), NULL);
|
||||
g_return_val_if_fail (controller->current_event != NULL, NULL);
|
||||
|
||||
if (gdk_event_get_event_type (controller->current_event) == GDK_ENTER_NOTIFY)
|
||||
origin = (GtkWidget *)gdk_event_get_related_target (controller->current_event);
|
||||
else
|
||||
origin = (GtkWidget *)gdk_event_get_target (controller->current_event);
|
||||
|
||||
return origin;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_motion_get_pointer_target:
|
||||
* @controller: a #GtkEventControllerMotion
|
||||
*
|
||||
* Returns the widget that will contain the pointer afterwards.
|
||||
*
|
||||
* This function can only be used in handlers for the
|
||||
* #GtkEventControllerMotion::enter and
|
||||
* #GtkEventControllerMotion::leave signals.
|
||||
*
|
||||
* Returns: (transfer none): the next pointer focus
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_event_controller_motion_get_pointer_target (GtkEventControllerMotion *controller)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_MOTION (controller), NULL);
|
||||
g_return_val_if_fail (controller->current_event != NULL, NULL);
|
||||
|
||||
if (gdk_event_get_event_type (controller->current_event) == GDK_ENTER_NOTIFY)
|
||||
return (GtkWidget *)gdk_event_get_target (controller->current_event);
|
||||
else
|
||||
return (GtkWidget *)gdk_event_get_related_target (controller->current_event);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_motion_contains_pointer:
|
||||
* @self: a #GtkEventControllerMotion
|
||||
|
@ -45,11 +45,6 @@ GType gtk_event_controller_motion_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkEventController *gtk_event_controller_motion_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_event_controller_motion_get_pointer_origin (GtkEventControllerMotion *controller);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_event_controller_motion_get_pointer_target (GtkEventControllerMotion *controller);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_event_controller_motion_contains_pointer (GtkEventControllerMotion *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -22,6 +22,47 @@
|
||||
|
||||
#include "gtkeventcontroller.h"
|
||||
|
||||
typedef enum {
|
||||
GTK_CROSSING_FOCUS,
|
||||
GTK_CROSSING_POINTER
|
||||
} GtkCrossingType;
|
||||
|
||||
typedef enum {
|
||||
GTK_CROSSING_IN,
|
||||
GTK_CROSSING_OUT
|
||||
} GtkCrossingDirection;
|
||||
|
||||
typedef struct _GtkCrossingData GtkCrossingData;
|
||||
|
||||
/**
|
||||
* GtkCrossingData:
|
||||
* @type: the type of crossing event
|
||||
* @direction: whether this is a focus-in or focus-out event
|
||||
* @mode: the crossing mode
|
||||
* @old_target: the old target
|
||||
* @old_descendent: the direct child of the receiving widget that
|
||||
* is an ancestor of @old_target, or %NULL if @old_target is not
|
||||
* a descendent of the receiving widget
|
||||
* @new_target: the new target
|
||||
* @new_descendent: the direct child of the receiving widget that
|
||||
* is an ancestor of @new_target, or %NULL if @new_target is not
|
||||
* a descendent of the receiving widget
|
||||
*
|
||||
* The struct that is passed to gtk_event_controller_handle_crossing().
|
||||
*
|
||||
* The @old_target and @new_target fields are set to the old or new
|
||||
* focus or hover location.
|
||||
*/
|
||||
struct _GtkCrossingData {
|
||||
GtkCrossingType type;
|
||||
GtkCrossingDirection direction;
|
||||
GdkCrossingMode mode;
|
||||
GtkWidget *old_target;
|
||||
GtkWidget *old_descendent;
|
||||
GtkWidget *new_target;
|
||||
GtkWidget *new_descendent;
|
||||
};
|
||||
|
||||
struct _GtkEventController
|
||||
{
|
||||
GObject parent_instance;
|
||||
@ -35,17 +76,37 @@ struct _GtkEventControllerClass
|
||||
GtkWidget *widget);
|
||||
void (* unset_widget) (GtkEventController *controller);
|
||||
gboolean (* handle_event) (GtkEventController *controller,
|
||||
const GdkEvent *event);
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y);
|
||||
void (* reset) (GtkEventController *controller);
|
||||
|
||||
void (* handle_crossing) (GtkEventController *controller,
|
||||
const GtkCrossingData *crossing,
|
||||
double x,
|
||||
double y);
|
||||
|
||||
/*<private>*/
|
||||
|
||||
/* Tells whether the event is filtered out, %TRUE makes
|
||||
* the event unseen by the handle_event vfunc.
|
||||
*/
|
||||
gboolean (* filter_event) (GtkEventController *controller,
|
||||
const GdkEvent *event);
|
||||
GdkEvent *event);
|
||||
|
||||
gpointer padding[10];
|
||||
};
|
||||
|
||||
GtkWidget *gtk_event_controller_get_target (GtkEventController *controller);
|
||||
|
||||
gboolean gtk_event_controller_handle_event (GtkEventController *controller,
|
||||
GdkEvent *event,
|
||||
GtkWidget *target,
|
||||
double x,
|
||||
double y);
|
||||
void gtk_event_controller_handle_crossing (GtkEventController *controller,
|
||||
const GtkCrossingData *crossing,
|
||||
double x,
|
||||
double y);
|
||||
|
||||
#endif /* __GTK_EVENT_CONTROLLER_PRIVATE_H__ */
|
||||
|
@ -238,7 +238,9 @@ gtk_event_controller_scroll_get_property (GObject *object,
|
||||
|
||||
static gboolean
|
||||
gtk_event_controller_scroll_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkEventControllerScroll *scroll = GTK_EVENT_CONTROLLER_SCROLL (controller);
|
||||
GdkScrollDirection direction = GDK_SCROLL_SMOOTH;
|
||||
@ -247,17 +249,20 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
|
||||
|
||||
if (gdk_event_get_event_type (event) != GDK_SCROLL)
|
||||
return FALSE;
|
||||
|
||||
if ((scroll->flags & (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL |
|
||||
GTK_EVENT_CONTROLLER_SCROLL_HORIZONTAL)) == 0)
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: Handle device changes */
|
||||
|
||||
if (gdk_event_get_scroll_deltas (event, &dx, &dy))
|
||||
direction = gdk_scroll_event_get_direction (event);
|
||||
if (direction == GDK_SCROLL_SMOOTH)
|
||||
{
|
||||
GdkDevice *device = gdk_event_get_source_device (event);
|
||||
GdkInputSource input_source = gdk_device_get_source (device);
|
||||
|
||||
gdk_scroll_event_get_deltas (event, &dx, &dy);
|
||||
|
||||
if (!scroll->active &&
|
||||
(input_source == GDK_SOURCE_TRACKPOINT ||
|
||||
input_source == GDK_SOURCE_TOUCHPAD))
|
||||
@ -295,7 +300,7 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (gdk_event_get_scroll_direction (event, &direction))
|
||||
else
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
@ -331,7 +336,7 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
|
||||
scroll_history_push (scroll, dx, dy, gdk_event_get_time (event));
|
||||
}
|
||||
|
||||
if (scroll->active && gdk_event_is_scroll_stop_event (event))
|
||||
if (scroll->active && gdk_scroll_event_is_stop (event))
|
||||
{
|
||||
g_signal_emit (controller, signals[SCROLL_END], 0);
|
||||
scroll->active = FALSE;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkfilefilterprivate.h"
|
||||
#include "gtkeventcontrollerfocus.h"
|
||||
|
||||
typedef struct _GtkFileChooserEntryClass GtkFileChooserEntryClass;
|
||||
|
||||
@ -259,10 +260,8 @@ match_func (GtkEntryCompletion *compl,
|
||||
}
|
||||
|
||||
static void
|
||||
chooser_entry_focus_out (GtkEventControllerKey *key_controller,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
GtkFileChooserEntry *chooser_entry)
|
||||
chooser_entry_focus_out (GtkEventController *controller,
|
||||
GtkFileChooserEntry *chooser_entry)
|
||||
{
|
||||
set_complete_on_load (chooser_entry, FALSE);
|
||||
}
|
||||
@ -311,8 +310,10 @@ _gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry)
|
||||
"key-pressed",
|
||||
G_CALLBACK (gtk_file_chooser_entry_tab_handler),
|
||||
chooser_entry);
|
||||
gtk_widget_add_controller (GTK_WIDGET (chooser_entry), controller);
|
||||
controller = gtk_event_controller_focus_new ();
|
||||
g_signal_connect (controller,
|
||||
"focus-out", G_CALLBACK (chooser_entry_focus_out),
|
||||
"leave", G_CALLBACK (chooser_entry_focus_out),
|
||||
chooser_entry);
|
||||
gtk_widget_add_controller (GTK_WIDGET (chooser_entry), controller);
|
||||
|
||||
|
@ -2708,7 +2708,7 @@ gtk_flow_box_click_gesture_released (GtkGestureClick *gesture,
|
||||
{
|
||||
GdkEventSequence *sequence;
|
||||
GdkInputSource source;
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
gboolean modify;
|
||||
gboolean extend;
|
||||
|
||||
|
138
gtk/gtkgesture.c
138
gtk/gtkgesture.c
@ -145,6 +145,7 @@ enum {
|
||||
struct _PointData
|
||||
{
|
||||
GdkEvent *event;
|
||||
GtkWidget *target;
|
||||
gdouble widget_x;
|
||||
gdouble widget_y;
|
||||
|
||||
@ -235,7 +236,7 @@ _gtk_gesture_get_n_touchpad_points (GtkGesture *gesture,
|
||||
GtkGesturePrivate *priv;
|
||||
PointData *data;
|
||||
GdkEventType event_type;
|
||||
GdkTouchpadGesturePhase phase;
|
||||
GdkTouchpadGesturePhase phase = 0;
|
||||
guint n_fingers = 0;
|
||||
|
||||
priv = gtk_gesture_get_instance_private (gesture);
|
||||
@ -250,7 +251,11 @@ _gtk_gesture_get_n_touchpad_points (GtkGesture *gesture,
|
||||
|
||||
event_type = gdk_event_get_event_type (data->event);
|
||||
|
||||
gdk_event_get_touchpad_gesture_phase (data->event, &phase);
|
||||
if (EVENT_IS_TOUCHPAD_GESTURE (data->event))
|
||||
{
|
||||
phase = gdk_touchpad_event_get_gesture_phase (data->event);
|
||||
n_fingers = gdk_touchpad_event_get_n_fingers (data->event);
|
||||
}
|
||||
|
||||
if (only_active &&
|
||||
(data->state == GTK_EVENT_SEQUENCE_DENIED ||
|
||||
@ -258,9 +263,6 @@ _gtk_gesture_get_n_touchpad_points (GtkGesture *gesture,
|
||||
(event_type == GDK_TOUCHPAD_PINCH && phase == GDK_TOUCHPAD_GESTURE_PHASE_END)))
|
||||
return 0;
|
||||
|
||||
if (!gdk_event_get_touchpad_gesture_n_fingers (data->event, &n_fingers))
|
||||
return 0;
|
||||
|
||||
return n_fingers;
|
||||
}
|
||||
|
||||
@ -389,7 +391,6 @@ static void
|
||||
_update_touchpad_deltas (PointData *data)
|
||||
{
|
||||
GdkEvent *event = data->event;
|
||||
GdkEventType event_type;
|
||||
GdkTouchpadGesturePhase phase;
|
||||
double dx;
|
||||
double dy;
|
||||
@ -397,13 +398,10 @@ _update_touchpad_deltas (PointData *data)
|
||||
if (!event)
|
||||
return;
|
||||
|
||||
event_type = gdk_event_get_event_type (event);
|
||||
gdk_event_get_touchpad_gesture_phase (event, &phase);
|
||||
gdk_event_get_touchpad_deltas (event, &dx, &dy);
|
||||
|
||||
if (event_type == GDK_TOUCHPAD_SWIPE ||
|
||||
event_type == GDK_TOUCHPAD_PINCH)
|
||||
if (EVENT_IS_TOUCHPAD_GESTURE (event))
|
||||
{
|
||||
phase = gdk_touchpad_event_get_gesture_phase (event);
|
||||
gdk_touchpad_event_get_deltas (event, &dx, &dy);
|
||||
if (phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN)
|
||||
data->accum_dx = data->accum_dy = 0;
|
||||
else if (phase == GDK_TOUCHPAD_GESTURE_PHASE_UPDATE)
|
||||
@ -414,36 +412,6 @@ _update_touchpad_deltas (PointData *data)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_get_event_coordinates (PointData *data,
|
||||
gdouble *x,
|
||||
gdouble *y)
|
||||
{
|
||||
gdouble event_x, event_y;
|
||||
|
||||
g_assert (data->event != NULL);
|
||||
|
||||
gdk_event_get_coords (data->event, &event_x, &event_y);
|
||||
event_x += data->accum_dx;
|
||||
event_y += data->accum_dy;
|
||||
|
||||
if (x)
|
||||
*x = event_x;
|
||||
if (y)
|
||||
*y = event_y;
|
||||
}
|
||||
|
||||
static void
|
||||
_update_widget_coordinates (GtkGesture *gesture,
|
||||
PointData *data)
|
||||
{
|
||||
gdouble event_x, event_y;
|
||||
|
||||
_get_event_coordinates (data, &event_x, &event_y);
|
||||
data->widget_x = event_x;
|
||||
data->widget_y = event_y;
|
||||
}
|
||||
|
||||
static GtkEventSequenceState
|
||||
gtk_gesture_get_group_state (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence)
|
||||
@ -469,7 +437,10 @@ gtk_gesture_get_group_state (GtkGesture *gesture,
|
||||
|
||||
static gboolean
|
||||
_gtk_gesture_update_point (GtkGesture *gesture,
|
||||
const GdkEvent *event,
|
||||
GdkEvent *event,
|
||||
GtkWidget *target,
|
||||
double x,
|
||||
double y,
|
||||
gboolean add)
|
||||
{
|
||||
GdkEventSequence *sequence;
|
||||
@ -478,9 +449,6 @@ _gtk_gesture_update_point (GtkGesture *gesture,
|
||||
gboolean existed, touchpad;
|
||||
PointData *data;
|
||||
|
||||
if (!gdk_event_get_coords (event, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
device = gdk_event_get_device (event);
|
||||
|
||||
if (!device)
|
||||
@ -530,11 +498,12 @@ _gtk_gesture_update_point (GtkGesture *gesture,
|
||||
}
|
||||
|
||||
if (data->event)
|
||||
g_object_unref (data->event);
|
||||
gdk_event_unref (data->event);
|
||||
|
||||
data->event = g_object_ref ((gpointer) event);
|
||||
data->event = gdk_event_ref ((GdkEvent *)event);
|
||||
_update_touchpad_deltas (data);
|
||||
_update_widget_coordinates (gesture, data);
|
||||
data->widget_x = x + data->accum_dx;
|
||||
data->widget_y = y + data->accum_dy;
|
||||
|
||||
/* Deny the sequence right away if the expected
|
||||
* number of points is exceeded, so this sequence
|
||||
@ -563,7 +532,7 @@ _gtk_gesture_check_empty (GtkGesture *gesture)
|
||||
|
||||
static void
|
||||
_gtk_gesture_remove_point (GtkGesture *gesture,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
GdkEventSequence *sequence;
|
||||
GtkGesturePrivate *priv;
|
||||
@ -612,7 +581,7 @@ gesture_within_surface (GtkGesture *gesture,
|
||||
|
||||
static gboolean
|
||||
gtk_gesture_filter_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
/* Even though GtkGesture handles these events, we want
|
||||
* touchpad gestures disabled by default, it will be
|
||||
@ -627,7 +596,9 @@ gtk_gesture_filter_event (GtkEventController *controller,
|
||||
|
||||
static gboolean
|
||||
gtk_gesture_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkGesture *gesture = GTK_GESTURE (controller);
|
||||
GdkEventSequence *sequence;
|
||||
@ -635,8 +606,9 @@ gtk_gesture_handle_event (GtkEventController *controller,
|
||||
GdkDevice *source_device;
|
||||
gboolean was_recognized;
|
||||
GdkEventType event_type;
|
||||
GdkTouchpadGesturePhase phase;
|
||||
GdkTouchpadGesturePhase phase = 0;
|
||||
GdkModifierType state;
|
||||
GtkWidget *target;
|
||||
|
||||
source_device = gdk_event_get_source_device (event);
|
||||
|
||||
@ -647,8 +619,11 @@ gtk_gesture_handle_event (GtkEventController *controller,
|
||||
sequence = gdk_event_get_event_sequence (event);
|
||||
was_recognized = gtk_gesture_is_recognized (gesture);
|
||||
event_type = gdk_event_get_event_type (event);
|
||||
gdk_event_get_state (event, &state);
|
||||
gdk_event_get_touchpad_gesture_phase (event, &phase);
|
||||
state = gdk_event_get_modifier_state (event);
|
||||
if (EVENT_IS_TOUCHPAD_GESTURE (event))
|
||||
phase = gdk_touchpad_event_get_gesture_phase (event);
|
||||
|
||||
target = gtk_event_controller_get_target (controller);
|
||||
|
||||
if (gtk_gesture_get_sequence_state (gesture, sequence) != GTK_EVENT_SEQUENCE_DENIED)
|
||||
priv->last_sequence = sequence;
|
||||
@ -658,7 +633,7 @@ gtk_gesture_handle_event (GtkEventController *controller,
|
||||
(event_type == GDK_TOUCHPAD_SWIPE && phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN) ||
|
||||
(event_type == GDK_TOUCHPAD_PINCH && phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN))
|
||||
{
|
||||
if (_gtk_gesture_update_point (gesture, event, TRUE))
|
||||
if (_gtk_gesture_update_point (gesture, event, target, x, y, TRUE))
|
||||
{
|
||||
gboolean triggered_recognition;
|
||||
|
||||
@ -692,7 +667,7 @@ gtk_gesture_handle_event (GtkEventController *controller,
|
||||
{
|
||||
gboolean was_claimed;
|
||||
|
||||
if (_gtk_gesture_update_point (gesture, event, FALSE))
|
||||
if (_gtk_gesture_update_point (gesture, event, target, x, y, FALSE))
|
||||
{
|
||||
if (was_recognized &&
|
||||
_gtk_gesture_check_recognized (gesture, sequence))
|
||||
@ -717,7 +692,7 @@ gtk_gesture_handle_event (GtkEventController *controller,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (_gtk_gesture_update_point (gesture, event, FALSE) &&
|
||||
if (_gtk_gesture_update_point (gesture, event, target, x, y, FALSE) &&
|
||||
_gtk_gesture_check_recognized (gesture, sequence))
|
||||
g_signal_emit (gesture, signals[UPDATE], 0, sequence);
|
||||
}
|
||||
@ -734,9 +709,9 @@ gtk_gesture_handle_event (GtkEventController *controller,
|
||||
}
|
||||
else if (event_type == GDK_GRAB_BROKEN)
|
||||
{
|
||||
GdkSurface *surface = NULL;
|
||||
GdkSurface *surface;
|
||||
|
||||
gdk_event_get_grab_surface (event, &surface);
|
||||
surface = gdk_grab_broken_event_get_grab_surface (event);
|
||||
if (!surface || !gesture_within_surface (gesture, surface))
|
||||
_gtk_gesture_cancel_all (gesture);
|
||||
|
||||
@ -896,7 +871,10 @@ free_point_data (gpointer data)
|
||||
PointData *point = data;
|
||||
|
||||
if (point->event)
|
||||
g_object_unref (point->event);
|
||||
gdk_event_unref (point->event);
|
||||
|
||||
if (point->target)
|
||||
g_object_unref (point->target);
|
||||
|
||||
g_free (point);
|
||||
}
|
||||
@ -1167,7 +1145,7 @@ gtk_gesture_get_last_updated_sequence (GtkGesture *gesture)
|
||||
*
|
||||
* Returns: (transfer none) (nullable): The last event from @sequence
|
||||
**/
|
||||
const GdkEvent *
|
||||
GdkEvent *
|
||||
gtk_gesture_get_last_event (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence)
|
||||
{
|
||||
@ -1185,6 +1163,34 @@ gtk_gesture_get_last_event (GtkGesture *gesture,
|
||||
return data->event;
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_gesture_get_last_target:
|
||||
* @gesture: a #GtkGesture
|
||||
* @sequence: event sequence
|
||||
*
|
||||
* Returns the widget that the last event was targeted at.
|
||||
* See gtk_gesture_get_last_event().
|
||||
*
|
||||
* Returns: (transfer none) (nullable): The target of the last event
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_gesture_get_last_target (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence)
|
||||
{
|
||||
GtkGesturePrivate *priv;
|
||||
PointData *data;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_GESTURE (gesture), NULL);
|
||||
|
||||
priv = gtk_gesture_get_instance_private (gesture);
|
||||
data = g_hash_table_lookup (priv->points, sequence);
|
||||
|
||||
if (!data)
|
||||
return NULL;
|
||||
|
||||
return data->target;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_gesture_get_point:
|
||||
* @gesture: a #GtkGesture
|
||||
@ -1297,7 +1303,7 @@ gtk_gesture_get_bounding_box (GtkGesture *gesture,
|
||||
event_type == GDK_BUTTON_RELEASE)
|
||||
continue;
|
||||
|
||||
gdk_event_get_coords (data->event, &x, &y);
|
||||
gdk_event_get_position (data->event, &x, &y);
|
||||
n_points++;
|
||||
x1 = MIN (x1, x);
|
||||
y1 = MIN (y1, y);
|
||||
@ -1335,7 +1341,7 @@ gtk_gesture_get_bounding_box_center (GtkGesture *gesture,
|
||||
gdouble *x,
|
||||
gdouble *y)
|
||||
{
|
||||
const GdkEvent *last_event;
|
||||
GdkEvent *last_event;
|
||||
GdkRectangle rect;
|
||||
GdkEventSequence *sequence;
|
||||
|
||||
@ -1619,7 +1625,6 @@ _gtk_gesture_get_pointer_emulating_sequence (GtkGesture *gesture,
|
||||
GdkEventSequence *seq;
|
||||
GHashTableIter iter;
|
||||
PointData *data;
|
||||
gboolean emulating;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_GESTURE (gesture), FALSE);
|
||||
|
||||
@ -1633,8 +1638,7 @@ _gtk_gesture_get_pointer_emulating_sequence (GtkGesture *gesture,
|
||||
case GDK_TOUCH_BEGIN:
|
||||
case GDK_TOUCH_UPDATE:
|
||||
case GDK_TOUCH_END:
|
||||
gdk_event_get_touch_emulating_pointer (data->event, &emulating);
|
||||
if (!emulating)
|
||||
if (!gdk_touch_event_get_emulating_pointer (data->event))
|
||||
continue;
|
||||
/* Fall through */
|
||||
case GDK_BUTTON_PRESS:
|
||||
|
@ -66,9 +66,10 @@ GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_gesture_handles_sequence (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GdkEvent *
|
||||
GdkEvent *
|
||||
gtk_gesture_get_last_event (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_gesture_get_point (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence,
|
||||
|
@ -197,7 +197,7 @@ gtk_gesture_click_begin (GtkGesture *gesture,
|
||||
GtkGestureClickPrivate *priv;
|
||||
guint n_presses, button = 1;
|
||||
GdkEventSequence *current;
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
GdkEventType event_type;
|
||||
GdkDevice *device;
|
||||
gdouble x, y;
|
||||
@ -213,7 +213,7 @@ gtk_gesture_click_begin (GtkGesture *gesture,
|
||||
event_type = gdk_event_get_event_type (event);
|
||||
|
||||
if (event_type == GDK_BUTTON_PRESS)
|
||||
gdk_event_get_button (event, &button);
|
||||
button = gdk_button_event_get_button (event);
|
||||
else if (event_type == GDK_TOUCH_BEGIN)
|
||||
button = 1;
|
||||
else
|
||||
@ -307,13 +307,14 @@ gtk_gesture_click_reset (GtkEventController *controller)
|
||||
|
||||
static gboolean
|
||||
gtk_gesture_click_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkEventControllerClass *parent_controller;
|
||||
GtkGestureClickPrivate *priv;
|
||||
GdkEventSequence *sequence;
|
||||
guint button;
|
||||
gdouble x, y;
|
||||
|
||||
priv = gtk_gesture_click_get_instance_private (GTK_GESTURE_CLICK (controller));
|
||||
parent_controller = GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_click_parent_class);
|
||||
@ -324,14 +325,15 @@ gtk_gesture_click_handle_event (GtkEventController *controller,
|
||||
(gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE ||
|
||||
gdk_event_get_event_type (event) == GDK_TOUCH_END))
|
||||
{
|
||||
if (!gdk_event_get_button (event, &button))
|
||||
if (gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE)
|
||||
button = gdk_button_event_get_button (event);
|
||||
else
|
||||
button = 0;
|
||||
gdk_event_get_coords (event, &x, &y);
|
||||
g_signal_emit (controller, signals[UNPAIRED_RELEASE], 0,
|
||||
x, y, button, sequence);
|
||||
}
|
||||
|
||||
return parent_controller->handle_event (controller, event);
|
||||
return parent_controller->handle_event (controller, event, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -60,7 +60,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkGestureDrag, gtk_gesture_drag, GTK_TYPE_GESTURE_S
|
||||
|
||||
static gboolean
|
||||
gtk_gesture_drag_filter_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
/* Let touchpad swipe events go through, only if they match n-points */
|
||||
if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_SWIPE)
|
||||
@ -69,7 +69,7 @@ gtk_gesture_drag_filter_event (GtkEventController *controller,
|
||||
guint n_fingers;
|
||||
|
||||
g_object_get (G_OBJECT (controller), "n-points", &n_points, NULL);
|
||||
gdk_event_get_touchpad_gesture_n_fingers (event, &n_fingers);
|
||||
n_fingers = gdk_touchpad_event_get_n_fingers (event);
|
||||
|
||||
if (n_fingers == n_points)
|
||||
return FALSE;
|
||||
|
@ -116,7 +116,7 @@ gtk_gesture_long_press_begin (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence)
|
||||
{
|
||||
GtkGestureLongPressPrivate *priv;
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
GdkEventType event_type;
|
||||
GtkWidget *widget;
|
||||
gint delay;
|
||||
|
@ -70,6 +70,10 @@ gboolean _gtk_gesture_get_last_update_time (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence,
|
||||
guint32 *evtime);
|
||||
|
||||
GtkWidget *gtk_gesture_get_last_target (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_GESTURE_PRIVATE_H__ */
|
||||
|
@ -78,7 +78,7 @@ _gtk_gesture_rotate_get_angle (GtkGestureRotate *rotate,
|
||||
gdouble *angle)
|
||||
{
|
||||
GtkGestureRotatePrivate *priv;
|
||||
const GdkEvent *last_event;
|
||||
GdkEvent *last_event;
|
||||
gdouble x1, y1, x2, y2;
|
||||
GtkGesture *gesture;
|
||||
gdouble dx, dy;
|
||||
@ -97,7 +97,7 @@ _gtk_gesture_rotate_get_angle (GtkGestureRotate *rotate,
|
||||
goto out;
|
||||
|
||||
last_event = gtk_gesture_get_last_event (gesture, sequences->data);
|
||||
gdk_event_get_touchpad_gesture_phase (last_event, &phase);
|
||||
phase = gdk_touchpad_event_get_gesture_phase (last_event);
|
||||
|
||||
if (gdk_event_get_event_type (last_event) == GDK_TOUCHPAD_PINCH &&
|
||||
(phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN ||
|
||||
@ -172,14 +172,14 @@ gtk_gesture_rotate_update (GtkGesture *gesture,
|
||||
|
||||
static gboolean
|
||||
gtk_gesture_rotate_filter_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
/* Let 2-finger touchpad pinch events go through */
|
||||
if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_PINCH)
|
||||
{
|
||||
guint n_fingers;
|
||||
|
||||
gdk_event_get_touchpad_gesture_n_fingers (event, &n_fingers);
|
||||
n_fingers = gdk_touchpad_event_get_n_fingers (event);
|
||||
|
||||
if (n_fingers == 2)
|
||||
return FALSE;
|
||||
@ -192,7 +192,9 @@ gtk_gesture_rotate_filter_event (GtkEventController *controller,
|
||||
|
||||
static gboolean
|
||||
gtk_gesture_rotate_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkGestureRotate *rotate = GTK_GESTURE_ROTATE (controller);
|
||||
GtkGestureRotatePrivate *priv;
|
||||
@ -201,11 +203,10 @@ gtk_gesture_rotate_handle_event (GtkEventController *controller,
|
||||
|
||||
priv = gtk_gesture_rotate_get_instance_private (rotate);
|
||||
|
||||
gdk_event_get_touchpad_gesture_phase (event, &phase);
|
||||
gdk_event_get_touchpad_angle_delta (event, &delta);
|
||||
|
||||
if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_PINCH)
|
||||
{
|
||||
phase = gdk_touchpad_event_get_gesture_phase (event);
|
||||
delta = gdk_touchpad_pinch_event_get_angle_delta (event);
|
||||
if (phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN ||
|
||||
phase == GDK_TOUCHPAD_GESTURE_PHASE_END)
|
||||
priv->accum_touchpad_angle = 0;
|
||||
@ -213,7 +214,7 @@ gtk_gesture_rotate_handle_event (GtkEventController *controller,
|
||||
priv->accum_touchpad_angle += delta;
|
||||
}
|
||||
|
||||
return GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_rotate_parent_class)->handle_event (controller, event);
|
||||
return GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_rotate_parent_class)->handle_event (controller, event, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -131,7 +131,9 @@ gtk_gesture_single_cancel (GtkGesture *gesture,
|
||||
|
||||
static gboolean
|
||||
gtk_gesture_single_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GdkEventSequence *sequence = NULL;
|
||||
GtkGestureSinglePrivate *priv;
|
||||
@ -140,7 +142,6 @@ gtk_gesture_single_handle_event (GtkEventController *controller,
|
||||
guint button = 0, state, i;
|
||||
gboolean retval, test_touchscreen = FALSE;
|
||||
GdkEventType event_type;
|
||||
gboolean emulating;
|
||||
|
||||
source_device = gdk_event_get_source_device (event);
|
||||
|
||||
@ -160,8 +161,7 @@ gtk_gesture_single_handle_event (GtkEventController *controller,
|
||||
case GDK_TOUCH_BEGIN:
|
||||
case GDK_TOUCH_END:
|
||||
case GDK_TOUCH_UPDATE:
|
||||
gdk_event_get_touch_emulating_pointer (event, &emulating);
|
||||
if (priv->exclusive && !emulating)
|
||||
if (priv->exclusive && !gdk_touch_event_get_emulating_pointer (event))
|
||||
return FALSE;
|
||||
|
||||
sequence = gdk_event_get_event_sequence (event);
|
||||
@ -172,15 +172,14 @@ gtk_gesture_single_handle_event (GtkEventController *controller,
|
||||
if (priv->touch_only && !test_touchscreen && source != GDK_SOURCE_TOUCHSCREEN)
|
||||
return FALSE;
|
||||
|
||||
gdk_event_get_button (event, &button);
|
||||
button = gdk_button_event_get_button (event);
|
||||
break;
|
||||
case GDK_MOTION_NOTIFY:
|
||||
if (!gtk_gesture_handles_sequence (GTK_GESTURE (controller), sequence))
|
||||
return FALSE;
|
||||
if (priv->touch_only && !test_touchscreen && source != GDK_SOURCE_TOUCHSCREEN)
|
||||
return FALSE;
|
||||
if (!gdk_event_get_state (event, &state))
|
||||
return FALSE;
|
||||
state = gdk_event_get_modifier_state (event);
|
||||
|
||||
if (priv->current_button > 0 && priv->current_button <= 5 &&
|
||||
(state & (GDK_BUTTON1_MASK << (priv->current_button - 1))))
|
||||
@ -201,8 +200,7 @@ gtk_gesture_single_handle_event (GtkEventController *controller,
|
||||
case GDK_TOUCH_CANCEL:
|
||||
case GDK_GRAB_BROKEN:
|
||||
case GDK_TOUCHPAD_SWIPE:
|
||||
return GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_single_parent_class)->handle_event (controller,
|
||||
event);
|
||||
return GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_single_parent_class)->handle_event (controller, event, x, y);
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
@ -226,7 +224,7 @@ gtk_gesture_single_handle_event (GtkEventController *controller,
|
||||
priv->current_button = button;
|
||||
}
|
||||
|
||||
retval = GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_single_parent_class)->handle_event (controller, event);
|
||||
retval = GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_single_parent_class)->handle_event (controller, event, x, y);
|
||||
|
||||
if (sequence == priv->current_sequence &&
|
||||
(event_type == GDK_BUTTON_RELEASE || event_type == GDK_TOUCH_END))
|
||||
|
@ -49,18 +49,17 @@ static guint signals[N_SIGNALS] = { 0, };
|
||||
|
||||
static gboolean
|
||||
gtk_gesture_stylus_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GdkModifierType modifiers;
|
||||
guint n_signal;
|
||||
gdouble x, y;
|
||||
|
||||
GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_stylus_parent_class)->handle_event (controller, event);
|
||||
GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_stylus_parent_class)->handle_event (controller, event, x, y);
|
||||
|
||||
if (!gdk_event_get_device_tool (event))
|
||||
return FALSE;
|
||||
if (!gdk_event_get_coords (event, &x, &y))
|
||||
return FALSE;
|
||||
|
||||
switch ((guint) gdk_event_get_event_type (event))
|
||||
{
|
||||
@ -71,7 +70,7 @@ gtk_gesture_stylus_handle_event (GtkEventController *controller,
|
||||
n_signal = UP;
|
||||
break;
|
||||
case GDK_MOTION_NOTIFY:
|
||||
gdk_event_get_state (event, &modifiers);
|
||||
modifiers = gdk_event_get_modifier_state (event);
|
||||
|
||||
if (modifiers & GDK_BUTTON1_MASK)
|
||||
n_signal = MOTION;
|
||||
@ -163,7 +162,7 @@ gtk_gesture_stylus_new (void)
|
||||
NULL);
|
||||
}
|
||||
|
||||
static const GdkEvent *
|
||||
static GdkEvent *
|
||||
gesture_get_current_event (GtkGestureStylus *gesture)
|
||||
{
|
||||
GdkEventSequence *sequence;
|
||||
@ -191,7 +190,7 @@ gtk_gesture_stylus_get_axis (GtkGestureStylus *gesture,
|
||||
GdkAxisUse axis,
|
||||
gdouble *value)
|
||||
{
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_GESTURE_STYLUS (gesture), FALSE);
|
||||
g_return_val_if_fail (axis < GDK_AXIS_LAST, FALSE);
|
||||
@ -222,7 +221,7 @@ gtk_gesture_stylus_get_axes (GtkGestureStylus *gesture,
|
||||
GdkAxisUse axes[],
|
||||
gdouble **values)
|
||||
{
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
GArray *array;
|
||||
gint i = 0;
|
||||
|
||||
@ -282,7 +281,7 @@ gtk_gesture_stylus_get_backlog (GtkGestureStylus *gesture,
|
||||
GdkTimeCoord **backlog,
|
||||
guint *n_elems)
|
||||
{
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
GArray *backlog_array;
|
||||
GList *history = NULL, *l;
|
||||
|
||||
@ -340,7 +339,7 @@ gtk_gesture_stylus_get_backlog (GtkGestureStylus *gesture,
|
||||
GdkDeviceTool *
|
||||
gtk_gesture_stylus_get_device_tool (GtkGestureStylus *gesture)
|
||||
{
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_GESTURE_STYLUS (gesture), FALSE);
|
||||
|
||||
|
@ -82,7 +82,7 @@ gtk_gesture_swipe_finalize (GObject *object)
|
||||
|
||||
static gboolean
|
||||
gtk_gesture_swipe_filter_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
/* Let touchpad swipe events go through, only if they match n-points */
|
||||
if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_SWIPE)
|
||||
@ -92,7 +92,7 @@ gtk_gesture_swipe_filter_event (GtkEventController *controller,
|
||||
|
||||
g_object_get (G_OBJECT (controller), "n-points", &n_points, NULL);
|
||||
|
||||
gdk_event_get_touchpad_gesture_n_fingers (event, &n_fingers);
|
||||
n_fingers = gdk_touchpad_event_get_n_fingers (event);
|
||||
|
||||
if (n_fingers == n_points)
|
||||
return FALSE;
|
||||
|
@ -76,7 +76,7 @@ static gboolean
|
||||
_gtk_gesture_zoom_get_distance (GtkGestureZoom *zoom,
|
||||
gdouble *distance)
|
||||
{
|
||||
const GdkEvent *last_event;
|
||||
GdkEvent *last_event;
|
||||
gdouble x1, y1, x2, y2;
|
||||
GtkGesture *gesture;
|
||||
GList *sequences = NULL;
|
||||
@ -94,7 +94,7 @@ _gtk_gesture_zoom_get_distance (GtkGestureZoom *zoom,
|
||||
goto out;
|
||||
|
||||
last_event = gtk_gesture_get_last_event (gesture, sequences->data);
|
||||
gdk_event_get_touchpad_gesture_phase (last_event, &phase);
|
||||
phase = gdk_touchpad_event_get_gesture_phase (last_event);
|
||||
|
||||
if (gdk_event_get_event_type (last_event) == GDK_TOUCHPAD_PINCH &&
|
||||
(phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN ||
|
||||
@ -104,7 +104,7 @@ _gtk_gesture_zoom_get_distance (GtkGestureZoom *zoom,
|
||||
double scale;
|
||||
/* Touchpad pinch */
|
||||
|
||||
gdk_event_get_touchpad_scale (last_event, &scale);
|
||||
scale = gdk_touchpad_pinch_event_get_scale (last_event);
|
||||
*distance = scale;
|
||||
}
|
||||
else
|
||||
@ -149,14 +149,14 @@ _gtk_gesture_zoom_check_emit (GtkGestureZoom *gesture)
|
||||
|
||||
static gboolean
|
||||
gtk_gesture_zoom_filter_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
/* Let 2-finger touchpad pinch events go through */
|
||||
if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_PINCH)
|
||||
{
|
||||
guint n_fingers;
|
||||
|
||||
gdk_event_get_touchpad_gesture_n_fingers (event, &n_fingers);
|
||||
n_fingers = gdk_touchpad_event_get_n_fingers (event);
|
||||
|
||||
if (n_fingers == 2)
|
||||
return FALSE;
|
||||
|
@ -166,10 +166,9 @@ static void gtk_icon_view_motion (GtkEventControl
|
||||
double x,
|
||||
double y,
|
||||
gpointer user_data);
|
||||
static void gtk_icon_view_leave (GtkEventController *controller,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
gpointer user_data);
|
||||
static void gtk_icon_view_leave (GtkEventController *controller,
|
||||
GdkCrossingMode mode,
|
||||
gpointer user_data);
|
||||
static void gtk_icon_view_button_press (GtkGestureClick *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
@ -965,10 +964,8 @@ gtk_icon_view_init (GtkIconView *icon_view)
|
||||
gtk_widget_add_controller (GTK_WIDGET (icon_view), GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (gtk_icon_view_leave),
|
||||
icon_view);
|
||||
g_signal_connect (controller, "motion", G_CALLBACK (gtk_icon_view_motion),
|
||||
icon_view);
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (gtk_icon_view_leave), icon_view);
|
||||
g_signal_connect (controller, "motion", G_CALLBACK (gtk_icon_view_motion), icon_view);
|
||||
gtk_widget_add_controller (GTK_WIDGET (icon_view), controller);
|
||||
|
||||
controller = gtk_event_controller_key_new ();
|
||||
@ -1881,10 +1878,9 @@ gtk_icon_view_motion (GtkEventController *controller,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_leave (GtkEventController *controller,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
gpointer user_data)
|
||||
gtk_icon_view_leave(GtkEventController *controller,
|
||||
GdkCrossingMode mode,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkIconView *icon_view;
|
||||
GtkIconViewPrivate *priv;
|
||||
@ -2120,18 +2116,18 @@ gtk_icon_view_button_press (GtkGestureClick *gesture,
|
||||
GtkCellRenderer *cell = NULL, *cursor_cell = NULL;
|
||||
int button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
|
||||
GdkEventSequence *sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
||||
const GdkEventButton *event = (const GdkEventButton *)gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
||||
GdkEventButton *event = (GdkEventButton *)gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
||||
GdkModifierType state;
|
||||
|
||||
if (!gtk_widget_has_focus (widget))
|
||||
gtk_widget_grab_focus (widget);
|
||||
|
||||
if (button == GDK_BUTTON_PRIMARY &&
|
||||
gdk_event_get_state ((GdkEvent *) event, &state))
|
||||
if (button == GDK_BUTTON_PRIMARY)
|
||||
{
|
||||
GdkModifierType extend_mod_mask;
|
||||
GdkModifierType modify_mod_mask;
|
||||
|
||||
state = gdk_event_get_modifier_state ((GdkEvent *)event);
|
||||
extend_mod_mask =
|
||||
gtk_widget_get_modifier_mask (widget, GDK_MODIFIER_INTENT_EXTEND_SELECTION);
|
||||
|
||||
@ -2268,11 +2264,11 @@ gtk_icon_view_button_press (GtkGestureClick *gesture,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
button_event_modifies_selection (const GdkEventButton *event)
|
||||
button_event_modifies_selection (GdkEventButton *event)
|
||||
{
|
||||
guint state;
|
||||
|
||||
gdk_event_get_state ((GdkEvent *) event, &state);
|
||||
state = gdk_event_get_modifier_state ((GdkEvent *) event);
|
||||
return (state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
|
||||
}
|
||||
|
||||
@ -2286,7 +2282,7 @@ gtk_icon_view_button_release (GtkGestureClick *gesture,
|
||||
GtkIconView *icon_view = user_data;
|
||||
int button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
|
||||
GdkEventSequence *sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
||||
const GdkEventButton *event = (const GdkEventButton *)gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
||||
GdkEventButton *event = (GdkEventButton *)gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
||||
|
||||
if (icon_view->priv->pressed_button == button)
|
||||
icon_view->priv->pressed_button = -1;
|
||||
|
@ -127,7 +127,7 @@ static void gtk_im_context_real_get_preedit_string (GtkIMContext *context,
|
||||
PangoAttrList **attrs,
|
||||
gint *cursor_pos);
|
||||
static gboolean gtk_im_context_real_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *event);
|
||||
GdkEvent *event);
|
||||
static gboolean gtk_im_context_real_get_surrounding (GtkIMContext *context,
|
||||
gchar **text,
|
||||
gint *cursor_index);
|
||||
@ -371,8 +371,8 @@ gtk_im_context_real_get_preedit_string (GtkIMContext *context,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_im_context_real_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *event)
|
||||
gtk_im_context_real_filter_keypress (GtkIMContext *context,
|
||||
GdkEvent *event)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -511,7 +511,7 @@ gtk_im_context_get_preedit_string (GtkIMContext *context,
|
||||
**/
|
||||
gboolean
|
||||
gtk_im_context_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *key)
|
||||
GdkEvent *key)
|
||||
{
|
||||
GtkIMContextClass *klass;
|
||||
|
||||
|
@ -68,7 +68,7 @@ struct _GtkIMContextClass
|
||||
PangoAttrList **attrs,
|
||||
gint *cursor_pos);
|
||||
gboolean (*filter_keypress) (GtkIMContext *context,
|
||||
GdkEventKey *event);
|
||||
GdkEvent *event);
|
||||
void (*focus_in) (GtkIMContext *context);
|
||||
void (*focus_out) (GtkIMContext *context);
|
||||
void (*reset) (GtkIMContext *context);
|
||||
@ -106,7 +106,7 @@ void gtk_im_context_get_preedit_string (GtkIMContext *context,
|
||||
gint *cursor_pos);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_im_context_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *event);
|
||||
GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_im_context_focus_in (GtkIMContext *context);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -98,7 +98,7 @@ static void gtk_im_context_ime_get_property (GObject *object,
|
||||
static void gtk_im_context_ime_set_client_widget (GtkIMContext *context,
|
||||
GtkWidget *widget);
|
||||
static gboolean gtk_im_context_ime_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *event);
|
||||
GdkEvent *event);
|
||||
static void gtk_im_context_ime_reset (GtkIMContext *context);
|
||||
static void gtk_im_context_ime_get_preedit_string (GtkIMContext *context,
|
||||
gchar **str,
|
||||
@ -345,7 +345,7 @@ _gtk_im_context_ime_commit_unichar (GtkIMContextIME *context_ime,
|
||||
|
||||
static gboolean
|
||||
gtk_im_context_ime_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkIMContextIME *context_ime;
|
||||
gboolean retval = FALSE;
|
||||
@ -359,7 +359,7 @@ gtk_im_context_ime_filter_keypress (GtkIMContext *context,
|
||||
if (gdk_event_get_event_type ((GdkEvent *) event) == GDK_KEY_RELEASE)
|
||||
return FALSE;
|
||||
|
||||
gdk_event_get_state ((GdkEvent *) event, &state);
|
||||
state = gdk_event_get_modifier_state ((GdkEvent *) event);
|
||||
|
||||
if (state & GDK_CONTROL_MASK)
|
||||
return FALSE;
|
||||
@ -372,7 +372,7 @@ gtk_im_context_ime_filter_keypress (GtkIMContext *context,
|
||||
if (!GDK_IS_SURFACE (context_ime->client_surface))
|
||||
return FALSE;
|
||||
|
||||
gdk_event_get_keyval ((GdkEvent *) event, &keyval);
|
||||
keyval = gdk_key_event_get_keyval ((GdkEvent *) event);
|
||||
|
||||
if (keyval == GDK_KEY_space &&
|
||||
context_ime->priv->dead_key_keyval != 0)
|
||||
|
@ -163,7 +163,7 @@ output_result (GtkIMContext *context,
|
||||
|
||||
static gboolean
|
||||
quartz_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
gboolean retval;
|
||||
|
@ -114,7 +114,7 @@ static const guint16 gtk_compose_ignore[] = {
|
||||
|
||||
static void gtk_im_context_simple_finalize (GObject *obj);
|
||||
static gboolean gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *key);
|
||||
GdkEvent *key);
|
||||
static void gtk_im_context_simple_reset (GtkIMContext *context);
|
||||
static void gtk_im_context_simple_get_preedit_string (GtkIMContext *context,
|
||||
gchar **str,
|
||||
@ -893,7 +893,7 @@ beep_surface (GdkSurface *surface)
|
||||
static gboolean
|
||||
no_sequence_matches (GtkIMContextSimple *context_simple,
|
||||
gint n_compose,
|
||||
GdkEventKey *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkIMContextSimplePrivate *priv = context_simple->priv;
|
||||
GtkIMContext *context;
|
||||
@ -913,23 +913,35 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
|
||||
gtk_im_context_simple_commit_char (context, priv->tentative_match);
|
||||
priv->compose_buffer[0] = 0;
|
||||
|
||||
for (i=0; i < n_compose - len - 1; i++)
|
||||
for (i = 0; i < n_compose - len - 1; i++)
|
||||
{
|
||||
GdkEvent *tmp_event = gdk_event_copy ((GdkEvent *)event);
|
||||
gdk_event_set_keyval (tmp_event, priv->compose_buffer[len + i]);
|
||||
guint tmp_keyval = priv->compose_buffer[len + i];
|
||||
GdkEvent *tmp_event = gdk_event_key_new (GDK_KEY_PRESS,
|
||||
gdk_event_get_surface (event),
|
||||
gdk_event_get_device (event),
|
||||
gdk_event_get_source_device (event),
|
||||
gdk_event_get_time (event),
|
||||
gdk_event_get_modifier_state (event),
|
||||
tmp_keyval,
|
||||
tmp_keyval,
|
||||
tmp_keyval,
|
||||
0,
|
||||
0);
|
||||
|
||||
gtk_im_context_filter_keypress (context, (GdkEventKey *)tmp_event);
|
||||
gtk_im_context_filter_keypress (context, tmp_event);
|
||||
g_object_unref (tmp_event);
|
||||
}
|
||||
|
||||
return gtk_im_context_filter_keypress (context, event);
|
||||
}
|
||||
else if (gdk_event_get_keyval ((GdkEvent *) event, &keyval))
|
||||
else
|
||||
{
|
||||
keyval = gdk_key_event_get_keyval (event);
|
||||
|
||||
priv->compose_buffer[0] = 0;
|
||||
if (n_compose > 1) /* Invalid sequence */
|
||||
{
|
||||
beep_surface (gdk_event_get_surface ((GdkEvent *) event));
|
||||
beep_surface (gdk_event_get_surface (event));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -942,8 +954,7 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -955,7 +966,7 @@ is_hex_keyval (guint keyval)
|
||||
}
|
||||
|
||||
static guint
|
||||
canonical_hex_keyval (GdkEventKey *event)
|
||||
canonical_hex_keyval (GdkEvent *event)
|
||||
{
|
||||
GdkSurface *surface = gdk_event_get_surface ((GdkEvent *) event);
|
||||
GdkKeymap *keymap = gdk_display_get_keymap (gdk_surface_get_display (surface));
|
||||
@ -964,8 +975,7 @@ canonical_hex_keyval (GdkEventKey *event)
|
||||
gint n_vals = 0;
|
||||
gint i;
|
||||
|
||||
if (!gdk_event_get_keyval ((GdkEvent *) event, &event_keyval))
|
||||
return 0;
|
||||
event_keyval = gdk_key_event_get_keyval ((GdkEvent *)event);
|
||||
|
||||
/* See if the keyval is already a hex digit */
|
||||
if (is_hex_keyval (event_keyval))
|
||||
@ -975,7 +985,7 @@ canonical_hex_keyval (GdkEventKey *event)
|
||||
* any other state, and return that hex keyval if so
|
||||
*/
|
||||
gdk_keymap_get_entries_for_keycode (keymap,
|
||||
gdk_event_get_scancode ((GdkEvent *) event),
|
||||
gdk_key_event_get_scancode ((GdkEvent *) event),
|
||||
NULL,
|
||||
&keyvals, &n_vals);
|
||||
|
||||
@ -1004,7 +1014,7 @@ canonical_hex_keyval (GdkEventKey *event)
|
||||
|
||||
static gboolean
|
||||
gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
|
||||
GtkIMContextSimplePrivate *priv = context_simple->priv;
|
||||
@ -1029,9 +1039,8 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
while (priv->compose_buffer[n_compose] != 0)
|
||||
n_compose++;
|
||||
|
||||
if (!gdk_event_get_keyval ((GdkEvent *) event, &keyval) ||
|
||||
!gdk_event_get_state ((GdkEvent *) event, &state))
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
keyval = gdk_key_event_get_keyval ((GdkEvent *)event);
|
||||
state = gdk_event_get_modifier_state ((GdkEvent *)event);
|
||||
|
||||
if (gdk_event_get_event_type ((GdkEvent *) event) == GDK_KEY_RELEASE)
|
||||
{
|
||||
@ -1345,7 +1354,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
}
|
||||
|
||||
/* The current compose_buffer doesn't match anything */
|
||||
return no_sequence_matches (context_simple, n_compose, event);
|
||||
return no_sequence_matches (context_simple, n_compose, (GdkEvent *)event);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -615,7 +615,7 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext *context,
|
||||
|
||||
static gboolean
|
||||
gtk_im_context_wayland_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *key)
|
||||
GdkEvent *key)
|
||||
{
|
||||
/* This is done by the compositor */
|
||||
return GTK_IM_CONTEXT_CLASS (gtk_im_context_wayland_parent_class)->filter_keypress (context, key);
|
||||
|
@ -66,7 +66,7 @@ static void gtk_im_multicontext_get_preedit_string (GtkIMContext
|
||||
PangoAttrList **attrs,
|
||||
gint *cursor_pos);
|
||||
static gboolean gtk_im_multicontext_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *event);
|
||||
GdkEvent *event);
|
||||
static void gtk_im_multicontext_focus_in (GtkIMContext *context);
|
||||
static void gtk_im_multicontext_focus_out (GtkIMContext *context);
|
||||
static void gtk_im_multicontext_reset (GtkIMContext *context);
|
||||
@ -343,7 +343,7 @@ gtk_im_multicontext_get_preedit_string (GtkIMContext *context,
|
||||
|
||||
static gboolean
|
||||
gtk_im_multicontext_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (context);
|
||||
GtkIMContext *slave = gtk_im_multicontext_get_slave (multicontext);
|
||||
@ -353,19 +353,20 @@ gtk_im_multicontext_filter_keypress (GtkIMContext *context,
|
||||
{
|
||||
return gtk_im_context_filter_keypress (slave, event);
|
||||
}
|
||||
else if (gdk_event_get_keyval ((GdkEvent *) event, &keyval) &&
|
||||
gdk_event_get_state ((GdkEvent *) event, &state))
|
||||
else
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkModifierType no_text_input_mask;
|
||||
|
||||
display = gdk_surface_get_display (gdk_event_get_surface ((GdkEvent *) event));
|
||||
keyval = gdk_key_event_get_keyval (event);
|
||||
state = gdk_event_get_modifier_state (event);
|
||||
display = gdk_event_get_display (event);
|
||||
|
||||
no_text_input_mask =
|
||||
gdk_keymap_get_modifier_mask (gdk_display_get_keymap (display),
|
||||
GDK_MODIFIER_INTENT_NO_TEXT_INPUT);
|
||||
|
||||
if (gdk_event_get_event_type ((GdkEvent *) event) == GDK_KEY_PRESS &&
|
||||
if (gdk_event_get_event_type (event) == GDK_KEY_PRESS &&
|
||||
(state & no_text_input_mask) == 0)
|
||||
{
|
||||
gunichar ch;
|
||||
|
@ -355,11 +355,11 @@ keyval_in_group (GdkKeymap *keymap,
|
||||
/**
|
||||
* _gtk_key_hash_lookup:
|
||||
* @key_hash: a #GtkKeyHash
|
||||
* @hardware_keycode: hardware keycode field from a #GdkEventKey
|
||||
* @state: state field from a #GdkEventKey
|
||||
* @hardware_keycode: hardware keycode field from a #GdkEvent
|
||||
* @state: state field from a #GdkEvent
|
||||
* @mask: mask of modifiers to consider when matching against the
|
||||
* modifiers in entries.
|
||||
* @group: group field from a #GdkEventKey
|
||||
* @group: group field from a #GdkEvent
|
||||
*
|
||||
* Looks up the best matching entry or entries in the hash table for
|
||||
* a given event. The results are sorted so that entries with less
|
||||
@ -530,7 +530,7 @@ _gtk_key_hash_lookup (GtkKeyHash *key_hash,
|
||||
*
|
||||
* Looks up the best matching entry or entries in the hash table for a
|
||||
* given keyval/modifiers pair. It’s better to use
|
||||
* _gtk_key_hash_lookup() if you have the original #GdkEventKey
|
||||
* _gtk_key_hash_lookup() if you have the original #GdkEvent
|
||||
* available. The results are sorted so that entries with less
|
||||
* modifiers come before entries with more modifiers.
|
||||
*
|
||||
|
@ -450,7 +450,6 @@ static void gtk_label_motion (GtkEventControllerMotion *controller,
|
||||
gpointer data);
|
||||
static void gtk_label_leave (GtkEventControllerMotion *controller,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
gpointer data);
|
||||
|
||||
static gboolean gtk_label_grab_focus (GtkWidget *widget);
|
||||
@ -4454,7 +4453,7 @@ gtk_label_click_gesture_pressed (GtkGestureClick *gesture,
|
||||
GtkLabelSelectionInfo *info = priv->select_info;
|
||||
GtkWidget *widget = GTK_WIDGET (label);
|
||||
GdkEventSequence *sequence;
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
guint button;
|
||||
|
||||
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
|
||||
@ -4631,7 +4630,7 @@ gtk_label_drag_gesture_begin (GtkGestureDrag *gesture,
|
||||
GtkLabelSelectionInfo *info = priv->select_info;
|
||||
GdkModifierType state_mask;
|
||||
GdkEventSequence *sequence;
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
gint min, max, index;
|
||||
|
||||
if (!info || !info->selectable)
|
||||
@ -4646,7 +4645,7 @@ gtk_label_drag_gesture_begin (GtkGestureDrag *gesture,
|
||||
|
||||
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
||||
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
||||
gdk_event_get_state (event, &state_mask);
|
||||
state_mask = gdk_event_get_modifier_state (event);
|
||||
|
||||
if ((info->selection_anchor != info->selection_end) &&
|
||||
(state_mask & GDK_SHIFT_MASK))
|
||||
@ -4859,7 +4858,6 @@ gtk_label_motion (GtkEventControllerMotion *controller,
|
||||
static void
|
||||
gtk_label_leave (GtkEventControllerMotion *controller,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
gpointer data)
|
||||
{
|
||||
GtkLabel *label = GTK_LABEL (data);
|
||||
|
@ -451,7 +451,7 @@ gtk_link_button_pressed_cb (GtkGestureClick *gesture,
|
||||
GtkLinkButton *link_button = user_data;
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
GdkEventSequence *sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
||||
const GdkEvent *event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
||||
GdkEvent *event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
||||
|
||||
if (!gtk_widget_has_focus (GTK_WIDGET (link_button)))
|
||||
gtk_widget_grab_focus (GTK_WIDGET (link_button));
|
||||
|
@ -1867,7 +1867,7 @@ gtk_list_box_click_gesture_released (GtkGestureClick *gesture,
|
||||
{
|
||||
GdkEventSequence *sequence;
|
||||
GdkInputSource source;
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
gboolean modify;
|
||||
gboolean extend;
|
||||
|
||||
|
557
gtk/gtkmain.c
557
gtk/gtkmain.c
@ -1077,77 +1077,101 @@ gtk_main_sync (void)
|
||||
_gtk_recent_manager_sync ();
|
||||
}
|
||||
|
||||
static void
|
||||
rewrite_events_translate (GdkSurface *old_surface,
|
||||
GdkSurface *new_surface,
|
||||
gdouble *x,
|
||||
gdouble *y)
|
||||
{
|
||||
if (!gdk_surface_translate_coordinates (old_surface, new_surface, x, y))
|
||||
{
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static GdkEvent *
|
||||
rewrite_event_for_surface (GdkEvent *event,
|
||||
GdkSurface *new_surface)
|
||||
{
|
||||
event = gdk_event_copy (event);
|
||||
GdkEventType type;
|
||||
double x, y;
|
||||
double dx, dy;
|
||||
|
||||
switch ((guint) event->any.type)
|
||||
type = gdk_event_get_event_type (event);
|
||||
|
||||
switch ((guint) type)
|
||||
{
|
||||
case GDK_SCROLL:
|
||||
rewrite_events_translate (event->any.surface,
|
||||
new_surface,
|
||||
&event->scroll.x, &event->scroll.y);
|
||||
break;
|
||||
case GDK_BUTTON_PRESS:
|
||||
case GDK_BUTTON_RELEASE:
|
||||
rewrite_events_translate (event->any.surface,
|
||||
new_surface,
|
||||
&event->button.x, &event->button.y);
|
||||
break;
|
||||
case GDK_MOTION_NOTIFY:
|
||||
rewrite_events_translate (event->any.surface,
|
||||
new_surface,
|
||||
&event->motion.x, &event->motion.y);
|
||||
break;
|
||||
case GDK_TOUCH_BEGIN:
|
||||
case GDK_TOUCH_UPDATE:
|
||||
case GDK_TOUCH_END:
|
||||
case GDK_TOUCH_CANCEL:
|
||||
rewrite_events_translate (event->any.surface,
|
||||
new_surface,
|
||||
&event->touch.x, &event->touch.y);
|
||||
break;
|
||||
case GDK_TOUCHPAD_SWIPE:
|
||||
rewrite_events_translate (event->any.surface,
|
||||
new_surface,
|
||||
&event->touchpad_swipe.x,
|
||||
&event->touchpad_swipe.y);
|
||||
break;
|
||||
case GDK_TOUCHPAD_PINCH:
|
||||
rewrite_events_translate (event->any.surface,
|
||||
new_surface,
|
||||
&event->touchpad_pinch.x,
|
||||
&event->touchpad_pinch.y);
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
gdk_surface_translate_coordinates (gdk_event_get_surface (event), new_surface, &x, &y);
|
||||
break;
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
case GDK_PROXIMITY_IN:
|
||||
case GDK_PROXIMITY_OUT:
|
||||
break;
|
||||
|
||||
default:
|
||||
return event;
|
||||
x = y = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
g_object_unref (event->any.surface);
|
||||
event->any.surface = g_object_ref (new_surface);
|
||||
switch ((guint) type)
|
||||
{
|
||||
case GDK_BUTTON_PRESS:
|
||||
case GDK_BUTTON_RELEASE:
|
||||
return gdk_event_button_new (type,
|
||||
new_surface,
|
||||
gdk_event_get_device (event),
|
||||
gdk_event_get_source_device (event),
|
||||
gdk_event_get_device_tool (event),
|
||||
gdk_event_get_time (event),
|
||||
gdk_event_get_modifier_state (event),
|
||||
gdk_button_event_get_button (event),
|
||||
x, y,
|
||||
NULL); // FIXME copy axes
|
||||
case GDK_MOTION_NOTIFY:
|
||||
return gdk_event_motion_new (new_surface,
|
||||
gdk_event_get_device (event),
|
||||
gdk_event_get_source_device (event),
|
||||
gdk_event_get_device_tool (event),
|
||||
gdk_event_get_time (event),
|
||||
gdk_event_get_modifier_state (event),
|
||||
x, y,
|
||||
NULL); // FIXME copy axes
|
||||
case GDK_TOUCH_BEGIN:
|
||||
case GDK_TOUCH_UPDATE:
|
||||
case GDK_TOUCH_END:
|
||||
case GDK_TOUCH_CANCEL:
|
||||
return gdk_event_touch_new (type,
|
||||
gdk_event_get_event_sequence (event),
|
||||
new_surface,
|
||||
gdk_event_get_device (event),
|
||||
gdk_event_get_source_device (event),
|
||||
gdk_event_get_time (event),
|
||||
gdk_event_get_modifier_state (event),
|
||||
x, y,
|
||||
NULL, // FIXME copy axes
|
||||
gdk_touch_event_get_emulating_pointer (event));
|
||||
case GDK_TOUCHPAD_SWIPE:
|
||||
gdk_touchpad_event_get_deltas (event, &dx, &dy);
|
||||
return gdk_event_touchpad_swipe_new (new_surface,
|
||||
gdk_event_get_device (event),
|
||||
gdk_event_get_source_device (event),
|
||||
gdk_event_get_time (event),
|
||||
gdk_event_get_modifier_state (event),
|
||||
gdk_touchpad_event_get_gesture_phase (event),
|
||||
x, y,
|
||||
gdk_touchpad_event_get_n_fingers (event),
|
||||
dx, dy);
|
||||
case GDK_TOUCHPAD_PINCH:
|
||||
gdk_touchpad_event_get_deltas (event, &dx, &dy);
|
||||
return gdk_event_touchpad_pinch_new (new_surface,
|
||||
gdk_event_get_device (event),
|
||||
gdk_event_get_source_device (event),
|
||||
gdk_event_get_time (event),
|
||||
gdk_event_get_modifier_state (event),
|
||||
gdk_touchpad_event_get_gesture_phase (event),
|
||||
x, y,
|
||||
gdk_touchpad_event_get_n_fingers (event),
|
||||
dx, dy,
|
||||
gdk_touchpad_pinch_event_get_scale (event),
|
||||
gdk_touchpad_pinch_event_get_angle_delta (event));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return event;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* If there is a pointer or keyboard grab in effect with owner_events = TRUE,
|
||||
@ -1166,7 +1190,7 @@ rewrite_event_for_grabs (GdkEvent *event)
|
||||
GdkDisplay *display;
|
||||
GdkDevice *device;
|
||||
|
||||
switch ((guint) event->any.type)
|
||||
switch ((guint) gdk_event_get_event_type (event))
|
||||
{
|
||||
case GDK_SCROLL:
|
||||
case GDK_BUTTON_PRESS:
|
||||
@ -1182,7 +1206,7 @@ rewrite_event_for_grabs (GdkEvent *event)
|
||||
case GDK_TOUCH_CANCEL:
|
||||
case GDK_TOUCHPAD_SWIPE:
|
||||
case GDK_TOUCHPAD_PINCH:
|
||||
display = gdk_surface_get_display (event->any.surface);
|
||||
display = gdk_event_get_display (event);
|
||||
device = gdk_event_get_device (event);
|
||||
|
||||
if (!gdk_device_grab_info (display, device, &grab_surface, &owner_events) ||
|
||||
@ -1251,144 +1275,33 @@ check_event_in_child_popover (GtkWidget *event_widget,
|
||||
return (popover_parent == grab_widget || gtk_widget_is_ancestor (popover_parent, grab_widget));
|
||||
}
|
||||
|
||||
static GdkNotifyType
|
||||
get_virtual_notify_type (GdkNotifyType notify_type)
|
||||
{
|
||||
switch (notify_type)
|
||||
{
|
||||
case GDK_NOTIFY_ANCESTOR:
|
||||
case GDK_NOTIFY_INFERIOR:
|
||||
return GDK_NOTIFY_VIRTUAL;
|
||||
case GDK_NOTIFY_NONLINEAR:
|
||||
return GDK_NOTIFY_NONLINEAR_VIRTUAL;
|
||||
case GDK_NOTIFY_VIRTUAL:
|
||||
case GDK_NOTIFY_NONLINEAR_VIRTUAL:
|
||||
case GDK_NOTIFY_UNKNOWN:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return GDK_NOTIFY_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine from crossing mode details whether the ultimate
|
||||
* target is us or a descendant. Keep this code in sync with
|
||||
* gtkeventcontrollerkey.c:update_focus
|
||||
*/
|
||||
static gboolean
|
||||
is_or_contains (gboolean enter,
|
||||
GdkNotifyType detail)
|
||||
translate_event_coordinates (GdkEvent *event,
|
||||
double *x,
|
||||
double *y,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
gboolean is = FALSE;
|
||||
gboolean contains = FALSE;
|
||||
GtkWidget *event_widget;
|
||||
graphene_point_t p;
|
||||
double event_x, event_y;
|
||||
|
||||
switch (detail)
|
||||
{
|
||||
case GDK_NOTIFY_VIRTUAL:
|
||||
case GDK_NOTIFY_NONLINEAR_VIRTUAL:
|
||||
is = FALSE;
|
||||
contains = enter;
|
||||
break;
|
||||
case GDK_NOTIFY_ANCESTOR:
|
||||
case GDK_NOTIFY_NONLINEAR:
|
||||
is = enter;
|
||||
contains = FALSE;
|
||||
break;
|
||||
case GDK_NOTIFY_INFERIOR:
|
||||
is = enter;
|
||||
contains = !enter;
|
||||
break;
|
||||
case GDK_NOTIFY_UNKNOWN:
|
||||
default:
|
||||
g_warning ("Unknown focus change detail");
|
||||
break;
|
||||
}
|
||||
*x = *y = 0;
|
||||
|
||||
return is || contains;
|
||||
}
|
||||
if (!gdk_event_get_position (event, &event_x, &event_y))
|
||||
return FALSE;
|
||||
|
||||
static void
|
||||
synth_crossing (GtkWidget *widget,
|
||||
GtkWidget *toplevel,
|
||||
gboolean enter,
|
||||
GtkWidget *target,
|
||||
GtkWidget *related_target,
|
||||
GdkEvent *source,
|
||||
GdkNotifyType notify_type,
|
||||
GdkCrossingMode crossing_mode)
|
||||
{
|
||||
GdkEvent *event;
|
||||
GtkStateFlags flags;
|
||||
event_widget = gtk_get_event_widget (event);
|
||||
|
||||
if (gdk_event_get_event_type (source) == GDK_FOCUS_CHANGE)
|
||||
{
|
||||
event = gdk_event_new (GDK_FOCUS_CHANGE);
|
||||
event->focus_change.in = enter;
|
||||
event->focus_change.mode = crossing_mode;
|
||||
event->focus_change.detail = notify_type;
|
||||
if (!gtk_widget_compute_point (event_widget,
|
||||
widget,
|
||||
&GRAPHENE_POINT_INIT (event_x, event_y),
|
||||
&p))
|
||||
return FALSE;
|
||||
|
||||
flags = GTK_STATE_FLAG_FOCUSED;
|
||||
if (!GTK_IS_WINDOW (toplevel) || gtk_window_get_focus_visible (GTK_WINDOW (toplevel)))
|
||||
flags |= GTK_STATE_FLAG_FOCUS_VISIBLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gdouble x, y;
|
||||
event = gdk_event_new (enter ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY);
|
||||
if (related_target)
|
||||
{
|
||||
GdkSurface *surface;
|
||||
*x = p.x;
|
||||
*y = p.y;
|
||||
|
||||
surface = gtk_native_get_surface (gtk_widget_get_native (related_target));
|
||||
event->crossing.child_surface = g_object_ref (surface);
|
||||
}
|
||||
gdk_event_get_coords (source, &x, &y);
|
||||
event->crossing.x = x;
|
||||
event->crossing.y = y;
|
||||
event->crossing.mode = crossing_mode;
|
||||
event->crossing.detail = notify_type;
|
||||
|
||||
flags = GTK_STATE_FLAG_PRELIGHT;
|
||||
}
|
||||
|
||||
gdk_event_set_target (event, G_OBJECT (target));
|
||||
gdk_event_set_related_target (event, G_OBJECT (related_target));
|
||||
gdk_event_set_device (event, gdk_event_get_device (source));
|
||||
gdk_event_set_source_device (event, gdk_event_get_source_device (source));
|
||||
|
||||
event->any.surface = gtk_native_get_surface (gtk_widget_get_native (toplevel));
|
||||
if (event->any.surface)
|
||||
g_object_ref (event->any.surface);
|
||||
|
||||
if (is_or_contains (enter, notify_type))
|
||||
gtk_widget_set_state_flags (widget, flags, FALSE);
|
||||
else
|
||||
gtk_widget_unset_state_flags (widget, flags);
|
||||
|
||||
if (gdk_event_get_event_type (source) == GDK_FOCUS_CHANGE)
|
||||
{
|
||||
/* maintain focus chain */
|
||||
if (enter || notify_type == GDK_NOTIFY_INFERIOR)
|
||||
{
|
||||
GtkWidget *parent = gtk_widget_get_parent (widget);
|
||||
if (parent)
|
||||
gtk_widget_set_focus_child (parent, widget);
|
||||
}
|
||||
else if (!enter && notify_type != GDK_NOTIFY_INFERIOR)
|
||||
{
|
||||
GtkWidget *parent = gtk_widget_get_parent (widget);
|
||||
if (parent)
|
||||
gtk_widget_set_focus_child (parent, NULL);
|
||||
}
|
||||
|
||||
/* maintain widget state */
|
||||
if (notify_type == GDK_NOTIFY_ANCESTOR ||
|
||||
notify_type == GDK_NOTIFY_INFERIOR ||
|
||||
notify_type == GDK_NOTIFY_NONLINEAR)
|
||||
gtk_widget_set_has_focus (widget, enter);
|
||||
}
|
||||
|
||||
gtk_widget_event (widget, event);
|
||||
g_object_unref (event);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -1398,72 +1311,100 @@ gtk_synthesize_crossing_events (GtkRoot *toplevel,
|
||||
GdkEvent *event,
|
||||
GdkCrossingMode mode)
|
||||
{
|
||||
GtkWidget *ancestor = NULL, *widget;
|
||||
GdkNotifyType enter_type, leave_type, notify_type;
|
||||
GtkCrossingData crossing;
|
||||
GtkWidget *ancestor;
|
||||
GtkWidget *widget;
|
||||
GList *list, *l;
|
||||
double x, y;
|
||||
GtkWidget *prev;
|
||||
gboolean seen_ancestor;
|
||||
|
||||
if (old_target && new_target)
|
||||
ancestor = gtk_widget_common_ancestor (old_target, new_target);
|
||||
|
||||
if (ancestor == old_target)
|
||||
{
|
||||
leave_type = GDK_NOTIFY_INFERIOR;
|
||||
enter_type = GDK_NOTIFY_ANCESTOR;
|
||||
}
|
||||
else if (ancestor == new_target)
|
||||
{
|
||||
leave_type = GDK_NOTIFY_ANCESTOR;
|
||||
enter_type = GDK_NOTIFY_INFERIOR;
|
||||
}
|
||||
else
|
||||
enter_type = leave_type = GDK_NOTIFY_NONLINEAR;
|
||||
ancestor = NULL;
|
||||
|
||||
if (old_target)
|
||||
crossing.type = GTK_CROSSING_POINTER;
|
||||
crossing.mode = mode;
|
||||
crossing.old_target = old_target;
|
||||
crossing.old_descendent = NULL;
|
||||
crossing.new_target = new_target;
|
||||
crossing.new_descendent = NULL;
|
||||
|
||||
crossing.direction = GTK_CROSSING_OUT;
|
||||
|
||||
prev = NULL;
|
||||
seen_ancestor = FALSE;
|
||||
widget = old_target;
|
||||
while (widget)
|
||||
{
|
||||
widget = old_target;
|
||||
|
||||
while (widget)
|
||||
crossing.old_descendent = prev;
|
||||
if (seen_ancestor)
|
||||
{
|
||||
notify_type = (widget == old_target) ?
|
||||
leave_type : get_virtual_notify_type (leave_type);
|
||||
|
||||
if (widget != ancestor || widget == old_target)
|
||||
synth_crossing (widget, GTK_WIDGET (toplevel), FALSE,
|
||||
old_target, new_target, event, notify_type, mode);
|
||||
if (widget == ancestor || widget == GTK_WIDGET (toplevel))
|
||||
break;
|
||||
widget = gtk_widget_get_parent (widget);
|
||||
crossing.new_descendent = new_target ? prev : NULL;
|
||||
}
|
||||
else if (widget == ancestor)
|
||||
{
|
||||
GtkWidget *w;
|
||||
|
||||
crossing.new_descendent = NULL;
|
||||
for (w = new_target; w != ancestor; w = gtk_widget_get_parent (w))
|
||||
crossing.new_descendent = w;
|
||||
|
||||
seen_ancestor = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
crossing.new_descendent = NULL;
|
||||
}
|
||||
check_crossing_invariants (widget, &crossing);
|
||||
translate_event_coordinates (event, &x, &y, widget);
|
||||
gtk_widget_handle_crossing (widget, &crossing, x, y);
|
||||
gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_PRELIGHT);
|
||||
widget = gtk_widget_get_parent (widget);
|
||||
}
|
||||
|
||||
if (new_target)
|
||||
list = NULL;
|
||||
for (widget = new_target; widget; widget = gtk_widget_get_parent (widget))
|
||||
list = g_list_prepend (list, widget);
|
||||
|
||||
crossing.direction = GTK_CROSSING_IN;
|
||||
|
||||
seen_ancestor = FALSE;
|
||||
for (l = list; l; l = l->next)
|
||||
{
|
||||
GSList *widgets = NULL;
|
||||
|
||||
widget = new_target;
|
||||
|
||||
while (widget)
|
||||
widget = l->data;
|
||||
if (l->next)
|
||||
crossing.new_descendent = l->next->data;
|
||||
else
|
||||
crossing.new_descendent = NULL;
|
||||
if (seen_ancestor)
|
||||
{
|
||||
widgets = g_slist_prepend (widgets, widget);
|
||||
if (widget == ancestor || widget == GTK_WIDGET (toplevel))
|
||||
break;
|
||||
widget = gtk_widget_get_parent (widget);
|
||||
crossing.old_descendent = NULL;
|
||||
}
|
||||
else if (widget == ancestor)
|
||||
{
|
||||
GtkWidget *w;
|
||||
|
||||
crossing.old_descendent = NULL;
|
||||
for (w = old_target; w != ancestor; w = gtk_widget_get_parent (w))
|
||||
crossing.old_descendent = w;
|
||||
|
||||
seen_ancestor = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
crossing.old_descendent = old_target ? crossing.new_descendent : NULL;
|
||||
}
|
||||
|
||||
while (widgets)
|
||||
{
|
||||
widget = widgets->data;
|
||||
widgets = g_slist_delete_link (widgets, widgets);
|
||||
notify_type = (widget == new_target) ?
|
||||
enter_type : get_virtual_notify_type (enter_type);
|
||||
|
||||
if (widget != ancestor || widget == new_target)
|
||||
synth_crossing (widget, GTK_WIDGET (toplevel), TRUE,
|
||||
new_target, old_target, event, notify_type, mode);
|
||||
}
|
||||
translate_event_coordinates (event, &x, &y, widget);
|
||||
gtk_widget_handle_crossing (widget, &crossing, x, y);
|
||||
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_PRELIGHT, FALSE);
|
||||
}
|
||||
|
||||
g_list_free (list);
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
update_pointer_focus_state (GtkWindow *toplevel,
|
||||
GdkEvent *event,
|
||||
@ -1480,7 +1421,7 @@ update_pointer_focus_state (GtkWindow *toplevel,
|
||||
if (old_target == new_target)
|
||||
return old_target;
|
||||
|
||||
gdk_event_get_coords (event, &x, &y);
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
gtk_window_update_pointer_focus (toplevel, device, sequence,
|
||||
new_target, x, y);
|
||||
|
||||
@ -1490,7 +1431,7 @@ update_pointer_focus_state (GtkWindow *toplevel,
|
||||
static gboolean
|
||||
is_pointing_event (GdkEvent *event)
|
||||
{
|
||||
switch ((guint) event->any.type)
|
||||
switch ((guint) gdk_event_get_event_type (event))
|
||||
{
|
||||
case GDK_MOTION_NOTIFY:
|
||||
case GDK_ENTER_NOTIFY:
|
||||
@ -1514,7 +1455,7 @@ is_pointing_event (GdkEvent *event)
|
||||
static gboolean
|
||||
is_key_event (GdkEvent *event)
|
||||
{
|
||||
switch ((guint) event->any.type)
|
||||
switch ((guint) gdk_event_get_event_type (event))
|
||||
{
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
@ -1528,7 +1469,7 @@ is_key_event (GdkEvent *event)
|
||||
static gboolean
|
||||
is_focus_event (GdkEvent *event)
|
||||
{
|
||||
switch ((guint) event->any.type)
|
||||
switch ((guint) gdk_event_get_event_type (event))
|
||||
{
|
||||
case GDK_FOCUS_CHANGE:
|
||||
return TRUE;
|
||||
@ -1541,7 +1482,7 @@ is_focus_event (GdkEvent *event)
|
||||
static gboolean
|
||||
is_dnd_event (GdkEvent *event)
|
||||
{
|
||||
switch ((guint) event->any.type)
|
||||
switch ((guint) gdk_event_get_event_type (event))
|
||||
{
|
||||
case GDK_DRAG_ENTER:
|
||||
case GDK_DRAG_LEAVE:
|
||||
@ -1580,21 +1521,22 @@ handle_pointing_event (GdkEvent *event)
|
||||
GdkDevice *device;
|
||||
gdouble x, y;
|
||||
GtkWidget *native;
|
||||
GdkEventType type;
|
||||
|
||||
event_widget = gtk_get_event_widget (event);
|
||||
device = gdk_event_get_device (event);
|
||||
if (!device || !gdk_event_get_coords (event, &x, &y))
|
||||
return event_widget;
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
|
||||
toplevel = GTK_WINDOW (gtk_widget_get_root (event_widget));
|
||||
native = GTK_WIDGET (gtk_widget_get_native (event_widget));
|
||||
|
||||
type = gdk_event_get_event_type (event);
|
||||
sequence = gdk_event_get_event_sequence (event);
|
||||
|
||||
switch ((guint) event->any.type)
|
||||
switch ((guint) type)
|
||||
{
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
if (event->crossing.mode == GDK_CROSSING_NORMAL &&
|
||||
if (gdk_crossing_event_get_mode (event) == GDK_CROSSING_NORMAL &&
|
||||
gtk_window_lookup_pointer_focus_implicit_grab (toplevel, device, NULL))
|
||||
{
|
||||
/* We have an implicit grab, wait for the corresponding
|
||||
@ -1606,14 +1548,13 @@ handle_pointing_event (GdkEvent *event)
|
||||
case GDK_TOUCH_END:
|
||||
case GDK_TOUCH_CANCEL:
|
||||
old_target = update_pointer_focus_state (toplevel, event, NULL);
|
||||
|
||||
if (event->any.type == GDK_LEAVE_NOTIFY)
|
||||
if (type == GDK_LEAVE_NOTIFY)
|
||||
gtk_synthesize_crossing_events (GTK_ROOT (toplevel), old_target, NULL,
|
||||
event, event->crossing.mode);
|
||||
event, gdk_crossing_event_get_mode (event));
|
||||
break;
|
||||
case GDK_ENTER_NOTIFY:
|
||||
if (event->crossing.mode == GDK_CROSSING_GRAB ||
|
||||
event->crossing.mode == GDK_CROSSING_UNGRAB)
|
||||
if (gdk_crossing_event_get_mode (event) == GDK_CROSSING_GRAB ||
|
||||
gdk_crossing_event_get_mode (event) == GDK_CROSSING_UNGRAB)
|
||||
break;
|
||||
G_GNUC_FALLTHROUGH;
|
||||
case GDK_TOUCH_BEGIN:
|
||||
@ -1629,7 +1570,7 @@ handle_pointing_event (GdkEvent *event)
|
||||
|
||||
old_target = update_pointer_focus_state (toplevel, event, target);
|
||||
|
||||
if (event->any.type == GDK_MOTION_NOTIFY || event->any.type == GDK_ENTER_NOTIFY)
|
||||
if (type == GDK_MOTION_NOTIFY || type == GDK_ENTER_NOTIFY)
|
||||
{
|
||||
if (!gtk_window_lookup_pointer_focus_implicit_grab (toplevel, device,
|
||||
sequence))
|
||||
@ -1641,7 +1582,7 @@ handle_pointing_event (GdkEvent *event)
|
||||
gtk_window_maybe_update_cursor (toplevel, NULL, device);
|
||||
}
|
||||
|
||||
if (event->any.type == GDK_TOUCH_BEGIN)
|
||||
if (type == GDK_TOUCH_BEGIN)
|
||||
gtk_window_set_pointer_focus_grab (toplevel, device, sequence, target);
|
||||
|
||||
/* Let it take the effective pointer focus anyway, as it may change due
|
||||
@ -1655,21 +1596,21 @@ handle_pointing_event (GdkEvent *event)
|
||||
device,
|
||||
sequence);
|
||||
gtk_window_set_pointer_focus_grab (toplevel, device, sequence,
|
||||
event->any.type == GDK_BUTTON_PRESS ?
|
||||
type == GDK_BUTTON_PRESS ?
|
||||
target : NULL);
|
||||
|
||||
if (event->any.type == GDK_BUTTON_RELEASE)
|
||||
if (type == GDK_BUTTON_RELEASE)
|
||||
{
|
||||
GtkWidget *new_target;
|
||||
new_target = gtk_widget_pick (GTK_WIDGET (native), x, y, GTK_PICK_DEFAULT);
|
||||
if (new_target == NULL)
|
||||
new_target = GTK_WIDGET (toplevel);
|
||||
gtk_synthesize_crossing_events (GTK_ROOT (toplevel), target, new_target, event,
|
||||
GDK_CROSSING_UNGRAB);
|
||||
gtk_synthesize_crossing_events (GTK_ROOT (toplevel), target, new_target,
|
||||
event, GDK_CROSSING_UNGRAB);
|
||||
gtk_window_maybe_update_cursor (toplevel, NULL, device);
|
||||
}
|
||||
|
||||
set_widget_active_state (target, event->any.type == GDK_BUTTON_RELEASE);
|
||||
set_widget_active_state (target, type == GDK_BUTTON_RELEASE);
|
||||
|
||||
break;
|
||||
case GDK_SCROLL:
|
||||
@ -1709,9 +1650,7 @@ handle_dnd_event (GdkEvent *event)
|
||||
|
||||
event_widget = gtk_get_event_widget (event);
|
||||
|
||||
if (!gdk_event_get_coords (event, &x, &y))
|
||||
return event_widget;
|
||||
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
native = GTK_WIDGET (gtk_widget_get_native (event_widget));
|
||||
target = gtk_widget_pick (native, x, y, GTK_PICK_DEFAULT);
|
||||
|
||||
@ -1761,9 +1700,9 @@ gtk_main_do_event (GdkEvent *event)
|
||||
target_widget = handle_pointing_event (event);
|
||||
else if (is_key_event (event))
|
||||
{
|
||||
if (event->any.type == GDK_KEY_PRESS &&
|
||||
if (gdk_event_get_event_type (event) == GDK_KEY_PRESS &&
|
||||
GTK_IS_WINDOW (target_widget) &&
|
||||
gtk_window_activate_key (GTK_WINDOW (target_widget), (GdkEventKey *) event))
|
||||
gtk_window_activate_key (GTK_WINDOW (target_widget), event))
|
||||
goto cleanup;
|
||||
|
||||
target_widget = handle_key_event (event);
|
||||
@ -1782,8 +1721,6 @@ gtk_main_do_event (GdkEvent *event)
|
||||
if (!target_widget)
|
||||
goto cleanup;
|
||||
|
||||
gdk_event_set_target (event, G_OBJECT (target_widget));
|
||||
|
||||
window_group = gtk_main_get_window_group (target_widget);
|
||||
device = gdk_event_get_device (event);
|
||||
|
||||
@ -1799,7 +1736,7 @@ gtk_main_do_event (GdkEvent *event)
|
||||
* This is the key to implementing modality.
|
||||
*/
|
||||
if (!grab_widget ||
|
||||
((gtk_widget_is_sensitive (target_widget) || event->any.type == GDK_SCROLL) &&
|
||||
((gtk_widget_is_sensitive (target_widget) || gdk_event_get_event_type (event) == GDK_SCROLL) &&
|
||||
gtk_widget_is_ancestor (target_widget, grab_widget)))
|
||||
grab_widget = target_widget;
|
||||
|
||||
@ -1828,11 +1765,8 @@ gtk_main_do_event (GdkEvent *event)
|
||||
* Drag events are also not redirected, since it isn't
|
||||
* clear what the semantics of that would be.
|
||||
*/
|
||||
switch ((guint)event->any.type)
|
||||
switch ((guint)gdk_event_get_event_type (event))
|
||||
{
|
||||
case GDK_NOTHING:
|
||||
break;
|
||||
|
||||
case GDK_DELETE:
|
||||
g_object_ref (target_widget);
|
||||
if (!gtk_window_group_get_current_grab (window_group) ||
|
||||
@ -1845,24 +1779,10 @@ gtk_main_do_event (GdkEvent *event)
|
||||
g_object_unref (target_widget);
|
||||
break;
|
||||
|
||||
case GDK_DESTROY:
|
||||
/* Unexpected GDK_DESTROY from the outside, ignore for
|
||||
* child windows, handle like a GDK_DELETE for toplevels
|
||||
*/
|
||||
if (!gtk_widget_get_parent (target_widget))
|
||||
{
|
||||
g_object_ref (target_widget);
|
||||
if (!gtk_widget_event (target_widget, event) &&
|
||||
gtk_widget_get_realized (target_widget))
|
||||
gtk_widget_destroy (target_widget);
|
||||
g_object_unref (target_widget);
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_FOCUS_CHANGE:
|
||||
case GDK_GRAB_BROKEN:
|
||||
if (!_gtk_widget_captured_event (target_widget, event))
|
||||
gtk_widget_event (target_widget, event);
|
||||
if (!_gtk_widget_captured_event (target_widget, event, target_widget))
|
||||
gtk_widget_event (target_widget, event, target_widget);
|
||||
break;
|
||||
|
||||
case GDK_KEY_PRESS:
|
||||
@ -1909,7 +1829,7 @@ gtk_main_do_event (GdkEvent *event)
|
||||
break;
|
||||
}
|
||||
|
||||
_gtk_tooltip_handle_event (event);
|
||||
_gtk_tooltip_handle_event (target_widget, event);
|
||||
|
||||
cleanup:
|
||||
tmp_list = current_events;
|
||||
@ -1917,7 +1837,7 @@ gtk_main_do_event (GdkEvent *event)
|
||||
g_list_free_1 (tmp_list);
|
||||
|
||||
if (rewritten_event)
|
||||
g_object_unref (rewritten_event);
|
||||
gdk_event_unref (rewritten_event);
|
||||
}
|
||||
|
||||
static GtkWindowGroup *
|
||||
@ -2272,7 +2192,7 @@ GdkEvent*
|
||||
gtk_get_current_event (void)
|
||||
{
|
||||
if (current_events)
|
||||
return g_object_ref (current_events->data);
|
||||
return gdk_event_ref (current_events->data);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
@ -2312,7 +2232,10 @@ gtk_get_current_event_state (GdkModifierType *state)
|
||||
g_return_val_if_fail (state != NULL, FALSE);
|
||||
|
||||
if (current_events)
|
||||
return gdk_event_get_state (current_events->data, state);
|
||||
{
|
||||
*state = gdk_event_get_modifier_state (current_events->data);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*state = 0;
|
||||
@ -2348,58 +2271,16 @@ gtk_get_current_event_device (void)
|
||||
* Returns: (transfer none) (nullable): the widget that originally
|
||||
* received @event, or %NULL
|
||||
*/
|
||||
GtkWidget*
|
||||
gtk_get_event_widget (const GdkEvent *event)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = NULL;
|
||||
if (event && event->any.surface &&
|
||||
(event->any.type == GDK_DESTROY || !gdk_surface_is_destroyed (event->any.surface)))
|
||||
widget = gtk_native_get_for_surface (event->any.surface);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_get_event_target:
|
||||
* @event: a #GdkEvent
|
||||
*
|
||||
* If @event is %NULL or the event was not associated with any widget,
|
||||
* returns %NULL, otherwise returns the widget that is the deepmost
|
||||
* receiver of the event.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the target widget, or %NULL
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_get_event_target (const GdkEvent *event)
|
||||
gtk_get_event_widget (GdkEvent *event)
|
||||
{
|
||||
return GTK_WIDGET (gdk_event_get_target (event));
|
||||
}
|
||||
GdkSurface *surface;
|
||||
|
||||
/**
|
||||
* gtk_get_event_target_with_type:
|
||||
* @event: a #GdkEvent
|
||||
* @type: the type to look for
|
||||
*
|
||||
* If @event is %NULL or the event was not associated with any widget,
|
||||
* returns %NULL, otherwise returns first widget found from the event
|
||||
* target to the toplevel that matches @type.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the widget in the target stack
|
||||
* with the given type, or %NULL
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_get_event_target_with_type (GdkEvent *event,
|
||||
GType type)
|
||||
{
|
||||
GtkWidget *target;
|
||||
surface = gdk_event_get_surface (event);
|
||||
if (surface && !gdk_surface_is_destroyed (surface))
|
||||
return gtk_native_get_for_surface (surface);
|
||||
|
||||
target = gtk_get_event_target (event);
|
||||
while (target && !g_type_is_a (G_OBJECT_TYPE (target), type))
|
||||
target = gtk_widget_get_parent (target);
|
||||
|
||||
return target;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -2408,6 +2289,7 @@ propagate_event_up (GtkWidget *widget,
|
||||
GtkWidget *topmost)
|
||||
{
|
||||
gboolean handled_event = FALSE;
|
||||
GtkWidget *target = widget;
|
||||
|
||||
/* Propagate event up the widget tree so that
|
||||
* parents can see the button and motion
|
||||
@ -2425,9 +2307,9 @@ propagate_event_up (GtkWidget *widget,
|
||||
* event
|
||||
*/
|
||||
if (!gtk_widget_is_sensitive (widget))
|
||||
handled_event = event->any.type != GDK_SCROLL;
|
||||
handled_event = gdk_event_get_event_type (event) != GDK_SCROLL;
|
||||
else if (gtk_widget_get_realized (widget))
|
||||
handled_event = gtk_widget_event (widget, event);
|
||||
handled_event = gtk_widget_event (widget, event, target);
|
||||
|
||||
handled_event |= !gtk_widget_get_realized (widget);
|
||||
|
||||
@ -2454,6 +2336,7 @@ propagate_event_down (GtkWidget *widget,
|
||||
gint handled_event = FALSE;
|
||||
GList *widgets = NULL;
|
||||
GList *l;
|
||||
GtkWidget *target = widget;
|
||||
|
||||
widgets = g_list_prepend (widgets, g_object_ref (widget));
|
||||
while (widget && widget != topmost)
|
||||
@ -2477,13 +2360,13 @@ propagate_event_down (GtkWidget *widget,
|
||||
/* stop propagating on SCROLL, but don't handle the event, so it
|
||||
* can propagate up again and reach its handling widget
|
||||
*/
|
||||
if (event->any.type == GDK_SCROLL)
|
||||
if (gdk_event_get_event_type (event) == GDK_SCROLL)
|
||||
break;
|
||||
else
|
||||
handled_event = TRUE;
|
||||
}
|
||||
else if (gtk_widget_get_realized (widget))
|
||||
handled_event = _gtk_widget_captured_event (widget, event);
|
||||
handled_event = _gtk_widget_captured_event (widget, event, target);
|
||||
|
||||
handled_event |= !gtk_widget_get_realized (widget);
|
||||
}
|
||||
|
@ -131,16 +131,6 @@ gboolean gtk_get_current_event_state (GdkModifierType *state);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDevice *gtk_get_current_event_device (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget *gtk_get_event_widget (const GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget *gtk_get_event_target (const GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget *gtk_get_event_target_with_type (GdkEvent *event,
|
||||
GType type);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "gtkactionable.h"
|
||||
#include "gtkeventcontrollermotion.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkeventcontrollerfocus.h"
|
||||
#include "gtknative.h"
|
||||
|
||||
/**
|
||||
@ -1311,25 +1312,35 @@ stop_open (GtkModelButton *button)
|
||||
}
|
||||
|
||||
static void
|
||||
enter_cb (GtkEventController *controller,
|
||||
double x,
|
||||
double y,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType type,
|
||||
gpointer data)
|
||||
pointer_cb (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *target;
|
||||
GtkWidget *popover;
|
||||
gboolean contains;
|
||||
|
||||
target = gtk_event_controller_get_widget (controller);
|
||||
popover = gtk_widget_get_ancestor (target, GTK_TYPE_POPOVER_MENU);
|
||||
contains = gtk_event_controller_motion_contains_pointer (GTK_EVENT_CONTROLLER_MOTION (object));
|
||||
|
||||
if (popover && gtk_event_controller_motion_contains_pointer (GTK_EVENT_CONTROLLER_MOTION (controller)))
|
||||
if (contains)
|
||||
{
|
||||
if (gtk_popover_menu_get_open_submenu (GTK_POPOVER_MENU (popover)) != NULL)
|
||||
start_open (GTK_MODEL_BUTTON (target));
|
||||
else
|
||||
open_submenu (target);
|
||||
GtkWidget *target;
|
||||
GtkWidget *popover;
|
||||
|
||||
target = GTK_WIDGET (data);
|
||||
popover = gtk_widget_get_ancestor (target, GTK_TYPE_POPOVER_MENU);
|
||||
|
||||
if (popover)
|
||||
{
|
||||
if (gtk_popover_menu_get_open_submenu (GTK_POPOVER_MENU (popover)) != NULL)
|
||||
start_open (GTK_MODEL_BUTTON (target));
|
||||
else
|
||||
open_submenu (target);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkModelButton *button = data;
|
||||
|
||||
stop_open (button);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1343,26 +1354,8 @@ motion_cb (GtkEventController *controller,
|
||||
}
|
||||
|
||||
static void
|
||||
leave_cb (GtkEventController *controller,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType type,
|
||||
gpointer data)
|
||||
{
|
||||
GtkPopoverMenu *popover;
|
||||
|
||||
popover = (GtkPopoverMenu*)gtk_widget_get_ancestor (GTK_WIDGET (data), GTK_TYPE_POPOVER_MENU);
|
||||
|
||||
stop_open (GTK_MODEL_BUTTON (data));
|
||||
|
||||
if (popover)
|
||||
gtk_popover_menu_set_active_item (popover, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
focus_in_cb (GtkEventController *controller,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType type,
|
||||
gpointer data)
|
||||
focus_in_cb (GtkEventController *controller,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *target;
|
||||
GtkWidget *popover;
|
||||
@ -1394,13 +1387,12 @@ gtk_model_button_init (GtkModelButton *self)
|
||||
gtk_widget_add_css_class (GTK_WIDGET (self), "flat");
|
||||
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "enter", G_CALLBACK (enter_cb), self);
|
||||
g_signal_connect (controller, "notify::contains-pointer", G_CALLBACK (pointer_cb), self);
|
||||
g_signal_connect (controller, "motion", G_CALLBACK (motion_cb), self);
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (leave_cb), self);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||
|
||||
controller = gtk_event_controller_key_new ();
|
||||
g_signal_connect (controller, "focus-in", G_CALLBACK (focus_in_cb), NULL);
|
||||
controller = gtk_event_controller_focus_new ();
|
||||
g_signal_connect (controller, "enter", G_CALLBACK (focus_in_cb), NULL);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||
|
||||
gesture = gtk_gesture_click_new ();
|
||||
|
@ -1406,7 +1406,7 @@ on_end_process_activated (GtkModelButton *button,
|
||||
|
||||
static gboolean
|
||||
do_popup_menu_for_process_tree_view (GtkWidget *widget,
|
||||
const GdkEvent *event,
|
||||
GdkEvent *event,
|
||||
GtkMountOperation *op)
|
||||
{
|
||||
GtkWidget *menu;
|
||||
@ -1424,12 +1424,12 @@ do_popup_menu_for_process_tree_view (GtkWidget *widget,
|
||||
op);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
|
||||
if (event && gdk_event_triggers_context_menu (event) &&
|
||||
gdk_event_get_coords (event, &x, &y))
|
||||
if (event && gdk_event_triggers_context_menu (event))
|
||||
{
|
||||
GtkTreePath *path;
|
||||
GtkTreeSelection *selection;
|
||||
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (op->priv->process_tree_view),
|
||||
(gint) x,
|
||||
(gint) y,
|
||||
@ -1471,7 +1471,7 @@ click_cb (GtkGesture *gesture,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkMountOperation *op = GTK_MOUNT_OPERATION (user_data);
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
GdkEventSequence *sequence;
|
||||
GtkWidget *widget;
|
||||
|
||||
|
@ -2541,7 +2541,7 @@ gtk_notebook_gesture_pressed (GtkGestureClick *gesture,
|
||||
GdkEventSequence *sequence;
|
||||
GtkNotebookArrow arrow;
|
||||
GtkNotebookPage *page;
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
guint button;
|
||||
GList *tab;
|
||||
|
||||
@ -2800,7 +2800,7 @@ gtk_notebook_gesture_released (GtkGestureClick *gesture,
|
||||
GtkNotebook *notebook = user_data;
|
||||
GtkNotebookPrivate *priv = notebook->priv;
|
||||
GdkEventSequence *sequence;
|
||||
const GdkEvent *event;
|
||||
GdkEvent *event;
|
||||
guint button;
|
||||
|
||||
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
||||
|
@ -208,7 +208,7 @@ gtk_pad_controller_handle_mode_switch (GtkPadController *controller,
|
||||
|
||||
static gboolean
|
||||
gtk_pad_controller_filter_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkPadController *pad_controller = GTK_PAD_CONTROLLER (controller);
|
||||
GdkEventType event_type = gdk_event_get_event_type (event);
|
||||
@ -229,7 +229,9 @@ gtk_pad_controller_filter_event (GtkEventController *controller,
|
||||
|
||||
static gboolean
|
||||
gtk_pad_controller_handle_event (GtkEventController *controller,
|
||||
const GdkEvent *event)
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkPadController *pad_controller = GTK_PAD_CONTROLLER (controller);
|
||||
GdkEventType event_type = gdk_event_get_event_type (event);
|
||||
@ -238,7 +240,7 @@ gtk_pad_controller_handle_event (GtkEventController *controller,
|
||||
guint index, mode, group;
|
||||
gdouble value = 0;
|
||||
|
||||
gdk_event_get_pad_group_mode (event, &group, &mode);
|
||||
gdk_pad_event_get_group_mode (event, &group, &mode);
|
||||
if (event_type == GDK_PAD_GROUP_MODE)
|
||||
{
|
||||
gtk_pad_controller_handle_mode_switch (pad_controller,
|
||||
@ -252,13 +254,13 @@ gtk_pad_controller_handle_event (GtkEventController *controller,
|
||||
{
|
||||
case GDK_PAD_BUTTON_PRESS:
|
||||
type = GTK_PAD_ACTION_BUTTON;
|
||||
gdk_event_get_pad_button (event, &index);
|
||||
index = gdk_pad_button_event_get_button (event);
|
||||
break;
|
||||
case GDK_PAD_RING:
|
||||
case GDK_PAD_STRIP:
|
||||
type = event_type == GDK_PAD_RING ?
|
||||
GTK_PAD_ACTION_RING : GTK_PAD_ACTION_STRIP;
|
||||
gdk_event_get_pad_axis_value (event, &index, &value);
|
||||
gdk_pad_axis_event_get_value (event, &index, &value);
|
||||
break;
|
||||
default:
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user