forked from AuroraMiddleware/gtk
widget: Port emulation code to constructors
Use the new event constructors when generating events for emulating presses.
This commit is contained in:
parent
374c9dd880
commit
080e5de786
@ -2085,47 +2085,60 @@ _gtk_widget_emulate_press (GtkWidget *widget,
|
|||||||
event->any.type == GDK_TOUCH_UPDATE ||
|
event->any.type == GDK_TOUCH_UPDATE ||
|
||||||
event->any.type == GDK_TOUCH_END)
|
event->any.type == GDK_TOUCH_END)
|
||||||
{
|
{
|
||||||
press = gdk_event_copy (event);
|
press = gdk_event_touch_new (GDK_TOUCH_BEGIN,
|
||||||
press->any.type = GDK_TOUCH_BEGIN;
|
event->touch.sequence,
|
||||||
|
event->any.surface,
|
||||||
|
event->any.device,
|
||||||
|
event->any.source_device,
|
||||||
|
event->touch.time,
|
||||||
|
event->touch.state,
|
||||||
|
p.x, p.y,
|
||||||
|
NULL,
|
||||||
|
event->touch.emulating_pointer);
|
||||||
}
|
}
|
||||||
else if (event->any.type == GDK_BUTTON_PRESS ||
|
else if (event->any.type == GDK_BUTTON_PRESS ||
|
||||||
event->any.type == GDK_BUTTON_RELEASE)
|
event->any.type == GDK_BUTTON_RELEASE)
|
||||||
{
|
{
|
||||||
press = gdk_event_copy (event);
|
press = gdk_event_button_new (GDK_BUTTON_PRESS,
|
||||||
press->any.type = GDK_BUTTON_PRESS;
|
event->any.surface,
|
||||||
|
event->any.device,
|
||||||
|
event->any.source_device,
|
||||||
|
event->button.tool,
|
||||||
|
event->button.time,
|
||||||
|
event->button.state,
|
||||||
|
event->button.button,
|
||||||
|
p.x, p.y,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
else if (event->any.type == GDK_MOTION_NOTIFY)
|
else if (event->any.type == GDK_MOTION_NOTIFY)
|
||||||
{
|
{
|
||||||
press = gdk_event_new (GDK_BUTTON_PRESS);
|
int button;
|
||||||
press->any.surface = g_object_ref (event->any.surface);
|
|
||||||
press->button.time = event->motion.time;
|
|
||||||
press->button.state = event->motion.state;
|
|
||||||
|
|
||||||
press->button.axes = g_memdup (event->motion.axes,
|
|
||||||
sizeof (gdouble) *
|
|
||||||
gdk_device_get_n_axes (event->any.device));
|
|
||||||
|
|
||||||
if (event->motion.state & GDK_BUTTON3_MASK)
|
if (event->motion.state & GDK_BUTTON3_MASK)
|
||||||
press->button.button = 3;
|
button = 3;
|
||||||
else if (event->motion.state & GDK_BUTTON2_MASK)
|
else if (event->motion.state & GDK_BUTTON2_MASK)
|
||||||
press->button.button = 2;
|
button = 2;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((event->motion.state & GDK_BUTTON1_MASK) == 0)
|
if ((event->motion.state & GDK_BUTTON1_MASK) == 0)
|
||||||
g_critical ("Guessing button number 1 on generated button press event");
|
g_critical ("Guessing button number 1 on generated button press event");
|
||||||
|
|
||||||
press->button.button = 1;
|
button = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_event_set_device (press, gdk_event_get_device (event));
|
press = gdk_event_button_new (GDK_BUTTON_PRESS,
|
||||||
gdk_event_set_source_device (press, gdk_event_get_source_device (event));
|
event->any.surface,
|
||||||
|
event->any.device,
|
||||||
|
event->any.source_device,
|
||||||
|
NULL,
|
||||||
|
event->motion.time,
|
||||||
|
event->motion.state,
|
||||||
|
button,
|
||||||
|
p.x, p.y,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gdk_event_set_coords (press, p.x, p.y);
|
|
||||||
|
|
||||||
press->any.send_event = TRUE;
|
|
||||||
next_child = event_widget;
|
next_child = event_widget;
|
||||||
parent = _gtk_widget_get_parent (next_child);
|
parent = _gtk_widget_get_parent (next_child);
|
||||||
|
|
||||||
@ -7948,23 +7961,19 @@ synth_crossing (GtkWidget *widget,
|
|||||||
GdkNotifyType detail)
|
GdkNotifyType detail)
|
||||||
{
|
{
|
||||||
GdkEvent *event;
|
GdkEvent *event;
|
||||||
|
double x, y;
|
||||||
|
GdkModifierType state;
|
||||||
|
|
||||||
event = gdk_event_new (type);
|
gdk_surface_get_device_position (surface, device, &x, &y, &state);
|
||||||
|
event = gdk_event_crossing_new (type,
|
||||||
event->any.surface = g_object_ref (surface);
|
surface,
|
||||||
event->any.send_event = TRUE;
|
|
||||||
event->crossing.child_surface = g_object_ref (surface);
|
|
||||||
event->crossing.time = GDK_CURRENT_TIME;
|
|
||||||
gdk_surface_get_device_position (surface,
|
|
||||||
device,
|
device,
|
||||||
&event->crossing.x,
|
device,
|
||||||
&event->crossing.y,
|
GDK_CURRENT_TIME,
|
||||||
NULL);
|
state,
|
||||||
event->crossing.mode = mode;
|
x, y,
|
||||||
event->crossing.detail = detail;
|
mode,
|
||||||
event->crossing.focus = FALSE;
|
detail);
|
||||||
event->crossing.state = 0;
|
|
||||||
gdk_event_set_device (event, device);
|
|
||||||
|
|
||||||
if (!widget)
|
if (!widget)
|
||||||
widget = gtk_get_event_widget (event);
|
widget = gtk_get_event_widget (event);
|
||||||
|
Loading…
Reference in New Issue
Block a user