gdk: Drop expose events

Replace expose events with a GdkSurface::expose signal.
This is part of the move to use events only for input.
This commit is contained in:
Matthias Clasen 2018-07-15 08:48:46 -04:00
parent a8926c9d87
commit da3aaf39b9
6 changed files with 29 additions and 68 deletions

View File

@ -646,11 +646,6 @@ gdk_event_copy (const GdkEvent *event)
g_object_ref (event->dnd.drop);
break;
case GDK_EXPOSE:
if (event->expose.region)
new_event->expose.region = cairo_region_copy (event->expose.region);
break;
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
if (event->button.axes)
@ -730,11 +725,6 @@ gdk_event_finalize (GObject *object)
g_free (event->touch.axes);
break;
case GDK_EXPOSE:
if (event->expose.region)
cairo_region_destroy (event->expose.region);
break;
case GDK_MOTION_NOTIFY:
g_clear_object (&event->motion.tool);
g_free (event->motion.axes);
@ -831,7 +821,6 @@ gdk_event_get_time (const GdkEvent *event)
case GDK_NOTHING:
case GDK_DELETE:
case GDK_DESTROY:
case GDK_EXPOSE:
case GDK_MAP:
case GDK_UNMAP:
case GDK_GRAB_BROKEN:
@ -906,7 +895,6 @@ gdk_event_get_state (const GdkEvent *event,
case GDK_NOTHING:
case GDK_DELETE:
case GDK_DESTROY:
case GDK_EXPOSE:
case GDK_MAP:
case GDK_UNMAP:
case GDK_GRAB_BROKEN:

View File

@ -104,7 +104,6 @@ G_BEGIN_DECLS
typedef struct _GdkEventAny GdkEventAny;
typedef struct _GdkEventExpose GdkEventExpose;
typedef struct _GdkEventMotion GdkEventMotion;
typedef struct _GdkEventButton GdkEventButton;
typedef struct _GdkEventTouch GdkEventTouch;
@ -144,8 +143,6 @@ typedef void (*GdkEventFunc) (GdkEvent *event,
* hidden or destroyed, usually when the user clicks on a special icon in the
* title bar.
* @GDK_DESTROY: the surface has been destroyed.
* @GDK_EXPOSE: all or part of the surface has become visible and needs to be
* redrawn.
* @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.
@ -203,7 +200,6 @@ typedef enum
GDK_NOTHING,
GDK_DELETE,
GDK_DESTROY,
GDK_EXPOSE,
GDK_MOTION_NOTIFY,
GDK_BUTTON_PRESS,
GDK_BUTTON_RELEASE,

View File

@ -63,23 +63,6 @@ struct _GdkEventAny
GdkDisplay *display;
};
/*
* GdkEventExpose:
* @type: the type of the event (%GDK_EXPOSE)
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @area: bounding box of @region.
* @region: the region that needs to be redrawn.
*
* Generated when all or part of a surface becomes visible and needs to be
* redrawn.
*/
struct _GdkEventExpose
{
GdkEventAny any;
cairo_region_t *region;
};
/*
* GdkEventMotion:
* @type: the type of the event.
@ -573,7 +556,6 @@ struct _GdkEventPadGroupMode {
* GdkEvent:
* @type: the #GdkEventType
* @any: a #GdkEventAny
* @expose: a #GdkEventExpose
* @motion: a #GdkEventMotion
* @button: a #GdkEventButton
* @touch: a #GdkEventTouch
@ -624,7 +606,6 @@ struct _GdkEventPadGroupMode {
union _GdkEvent
{
GdkEventAny any;
GdkEventExpose expose;
GdkEventMotion motion;
GdkEventButton button;
GdkEventTouch touch;

View File

@ -98,6 +98,7 @@
enum {
MOVED_TO_RECT,
SIZE_CHANGED,
RENDER,
LAST_SIGNAL
};
@ -324,6 +325,18 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
2,
G_TYPE_INT,
G_TYPE_INT);
signals[RENDER] =
g_signal_new (g_intern_static_string ("render"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
NULL,
G_TYPE_BOOLEAN,
1,
CAIRO_GOBJECT_TYPE_REGION);
}
static void
@ -1631,20 +1644,13 @@ static void
gdk_surface_process_updates_recurse (GdkSurface *surface,
cairo_region_t *expose_region)
{
GdkEvent *event;
gboolean handled;
if (surface->destroyed)
return;
/* Paint the surface before the children, clipped to the surface region */
event = gdk_event_new (GDK_EXPOSE);
event->any.surface = g_object_ref (surface);
event->any.send_event = FALSE;
event->expose.region = cairo_region_reference (expose_region);
_gdk_event_emit (event);
g_object_unref (event);
g_signal_emit (surface, signals[RENDER], 0, expose_region, &handled);
}
/* Process and remove any invalid area on the native surface by creating
@ -3937,7 +3943,6 @@ _gdk_make_event (GdkSurface *surface,
case GDK_UNMAP:
case GDK_DELETE:
case GDK_DESTROY:
case GDK_EXPOSE:
default:
break;
}

View File

@ -1827,11 +1827,6 @@ gtk_main_do_event (GdkEvent *event)
}
break;
case GDK_EXPOSE:
if (event->any.surface)
gtk_widget_render (event_widget, event->any.surface, event->expose.region);
break;
case GDK_MAP:
if (GTK_IS_WINDOW (event_widget) && !_gtk_widget_get_mapped (event_widget))
{

View File

@ -5091,14 +5091,6 @@ gtk_widget_event (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
g_return_val_if_fail (WIDGET_REALIZED_FOR_EVENT (widget, event), TRUE);
if (event->any.type == GDK_EXPOSE)
{
g_warning ("Events of type GDK_EXPOSE cannot be synthesized. To get "
"the same effect, call gdk_surface_invalidate_rect/region(), "
"followed by gdk_surface_process_updates().");
return TRUE;
}
return gtk_widget_event_internal (widget, event);
}
@ -5174,14 +5166,6 @@ _gtk_widget_captured_event (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
g_return_val_if_fail (WIDGET_REALIZED_FOR_EVENT (widget, event), TRUE);
if (event->any.type == GDK_EXPOSE)
{
g_warning ("Events of type GDK_EXPOSE cannot be synthesized. To get "
"the same effect, call gdk_surface_invalidate_rect/region(), "
"followed by gdk_surface_process_updates().");
return TRUE;
}
if (!event_surface_is_still_viewable (event))
return TRUE;
@ -5217,7 +5201,6 @@ event_surface_is_still_viewable (const GdkEvent *event)
*/
switch ((guint) event->any.type)
{
case GDK_EXPOSE:
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_KEY_PRESS:
@ -5284,7 +5267,6 @@ gtk_widget_event_internal (GtkWidget *widget,
/* Non input events get handled right away */
switch ((guint) event->any.type)
{
case GDK_EXPOSE:
case GDK_NOTHING:
case GDK_DELETE:
case GDK_DESTROY:
@ -11512,6 +11494,16 @@ gtk_widget_set_surface (GtkWidget *widget,
}
}
static gboolean
surface_expose (GdkSurface *surface,
cairo_region_t *region,
GtkWidget *widget)
{
gtk_widget_render (widget, surface, region);
return TRUE;
}
/**
* gtk_widget_register_surface:
* @widget: a #GtkWidget
@ -11539,6 +11531,8 @@ gtk_widget_register_surface (GtkWidget *widget,
g_assert (user_data == NULL);
gdk_surface_set_user_data (surface, widget);
g_signal_connect (surface, "render", G_CALLBACK (surface_expose), widget);
}
/**
@ -11562,6 +11556,8 @@ gtk_widget_unregister_surface (GtkWidget *widget,
gdk_surface_get_user_data (surface, &user_data);
g_assert (user_data == widget);
gdk_surface_set_user_data (surface, NULL);
g_signal_handlers_disconnect_by_func (surface, surface_expose, widget);
}
/**