gdk: Drop configure events

Replace configure events with a GdkSurface::size-changed signal.
This is part of the move to use events only for input.
This commit is contained in:
Matthias Clasen 2018-07-15 10:45:57 -04:00
parent 443f8ddf6b
commit a8926c9d87
11 changed files with 63 additions and 91 deletions

View File

@ -827,7 +827,6 @@ gdk_event_get_time (const GdkEvent *event)
return event->pad_axis.time;
case GDK_PAD_GROUP_MODE:
return event->pad_group_mode.time;
case GDK_CONFIGURE:
case GDK_FOCUS_CHANGE:
case GDK_NOTHING:
case GDK_DELETE:
@ -897,7 +896,6 @@ gdk_event_get_state (const GdkEvent *event,
case GDK_LEAVE_NOTIFY:
*state = event->crossing.state;
return TRUE;
case GDK_CONFIGURE:
case GDK_FOCUS_CHANGE:
case GDK_PROXIMITY_IN:
case GDK_PROXIMITY_OUT:
@ -949,10 +947,6 @@ gdk_event_get_coords (const GdkEvent *event,
switch ((guint) event->any.type)
{
case GDK_CONFIGURE:
x = event->configure.x;
y = event->configure.y;
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
x = event->crossing.x;
@ -1083,10 +1077,6 @@ gdk_event_set_coords (GdkEvent *event,
switch ((guint) event->any.type)
{
case GDK_CONFIGURE:
event->configure.x = x;
event->configure.y = y;
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
event->crossing.x = x;

View File

@ -112,7 +112,6 @@ 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;
@ -155,8 +154,6 @@ typedef void (*GdkEventFunc) (GdkEvent *event,
* @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.
* Note that GTK+ discards these events for %GDK_SURFACE_CHILD surfaces.
* @GDK_MAP: the surface has been mapped.
* @GDK_UNMAP: the surface has been unmapped.
* @GDK_PROXIMITY_IN: an input device has moved into contact with a sensing
@ -215,7 +212,6 @@ typedef enum
GDK_ENTER_NOTIFY,
GDK_LEAVE_NOTIFY,
GDK_FOCUS_CHANGE,
GDK_CONFIGURE,
GDK_MAP,
GDK_UNMAP,
GDK_PROXIMITY_IN,

View File

@ -351,26 +351,6 @@ struct _GdkEventFocus
gint16 in;
};
/*
* GdkEventConfigure:
* @type: the type of the event (%GDK_CONFIGURE).
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @x: the new x coordinate of the surface, relative to its parent.
* @y: the new y coordinate of the surface, relative to its parent.
* @width: the new width of the surface.
* @height: the new height of the surface.
*
* Generated when a surface size or position has changed.
*/
struct _GdkEventConfigure
{
GdkEventAny any;
gint x, y;
gint width;
gint height;
};
/*
* GdkEventProximity:
* @type: the type of the event (%GDK_PROXIMITY_IN or %GDK_PROXIMITY_OUT).
@ -601,7 +581,6 @@ struct _GdkEventPadGroupMode {
* @key: a #GdkEventKey
* @crossing: a #GdkEventCrossing
* @focus_change: a #GdkEventFocus
* @configure: a #GdkEventConfigure
* @proximity: a #GdkEventProximity
* @dnd: a #GdkEventDND
* @grab_broken: a #GdkEventGrabBroken
@ -653,7 +632,6 @@ union _GdkEvent
GdkEventKey key;
GdkEventCrossing crossing;
GdkEventFocus focus_change;
GdkEventConfigure configure;
GdkEventProximity proximity;
GdkEventDND dnd;
GdkEventGrabBroken grab_broken;

View File

@ -97,6 +97,7 @@
enum {
MOVED_TO_RECT,
SIZE_CHANGED,
LAST_SIGNAL
};
@ -310,6 +311,19 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
G_TYPE_POINTER,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN);
signals[SIZE_CHANGED] =
g_signal_new (g_intern_static_string ("size-changed"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL,
NULL,
NULL,
G_TYPE_NONE,
2,
G_TYPE_INT,
G_TYPE_INT);
}
static void
@ -2663,6 +2677,7 @@ gdk_surface_move_resize_internal (GdkSurface *surface,
{
cairo_region_t *old_region, *new_region;
gboolean expose;
gboolean size_changed;
g_return_if_fail (GDK_IS_SURFACE (surface));
@ -2691,6 +2706,7 @@ gdk_surface_move_resize_internal (GdkSurface *surface,
/* Handle child surfaces */
expose = FALSE;
size_changed = FALSE;
old_region = NULL;
if (gdk_surface_is_viewable (surface) &&
@ -2716,8 +2732,16 @@ gdk_surface_move_resize_internal (GdkSurface *surface,
}
if (!(width < 0 && height < 0))
{
surface->width = width;
surface->height = height;
if (surface->width != width)
{
surface->width = width;
size_changed = TRUE;
}
if (surface->height != height)
{
surface->height = height;
size_changed = TRUE;
}
}
recompute_visible_regions (surface, FALSE);
@ -2740,10 +2764,11 @@ gdk_surface_move_resize_internal (GdkSurface *surface,
cairo_region_destroy (old_region);
cairo_region_destroy (new_region);
}
if (size_changed)
g_signal_emit (surface, signals[SIZE_CHANGED], 0, width, height);
}
/**
* gdk_surface_move:
* @surface: a #GdkSurface
@ -3908,7 +3933,6 @@ _gdk_make_event (GdkSurface *surface,
break;
case GDK_FOCUS_CHANGE:
case GDK_CONFIGURE:
case GDK_MAP:
case GDK_UNMAP:
case GDK_DELETE:

View File

@ -698,20 +698,9 @@ gdk_wayland_surface_configure (GdkSurface *surface,
int height,
int scale)
{
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;
gdk_wayland_surface_update_size (surface, width, height, scale);
_gdk_surface_update_size (surface);
display = gdk_surface_get_display (surface);
_gdk_wayland_display_deliver_event (display, event);
g_signal_emit_by_name (surface, "size-changed", width, height);
}
static gboolean

View File

@ -960,11 +960,12 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
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;
int x, y, width, height;
x = 0;
y = 0;
width = (xevent->xconfigure.width + surface_impl->surface_scale - 1) / surface_impl->surface_scale;
height = (xevent->xconfigure.height + surface_impl->surface_scale - 1) / surface_impl->surface_scale;
if (!xevent->xconfigure.send_event &&
!xevent->xconfigure.override_redirect &&
!GDK_SURFACE_DESTROYED (surface))
@ -981,31 +982,34 @@ 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)
{
surface->x = event->configure.x;
surface->y = event->configure.y;
surface->x = x;
surface->y = y;
if (surface_impl->unscaled_width != xevent->xconfigure.width ||
surface_impl->unscaled_height != xevent->xconfigure.height)
{
surface_impl->unscaled_width = xevent->xconfigure.width;
surface_impl->unscaled_height = xevent->xconfigure.height;
surface->width = event->configure.width;
surface->height = event->configure.height;
surface->width = width;
surface->height = height;
_gdk_surface_update_size (surface);
_gdk_x11_surface_update_size (surface_impl);
g_signal_emit_by_name (surface, "size-changed", width, height);
}
if (surface->resize_count >= 1)
@ -1014,8 +1018,10 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
if (surface->resize_count == 0)
_gdk_x11_moveresize_configure_done (display, surface);
}
}
}
return_val = FALSE;
}
break;

View File

@ -1603,6 +1603,7 @@ on_status_toplevel_configure (GtkWidget *toplevel,
GdkEvent *event,
StatusWindow *status_window)
{
#if 0
if (gdk_event_get_event_type (event) == GDK_CONFIGURE)
{
GdkRectangle rect;
@ -1625,6 +1626,7 @@ on_status_toplevel_configure (GtkWidget *toplevel,
gtk_window_move (GTK_WINDOW (status_window->window), rect.x, y);
}
}
#endif
return GDK_EVENT_PROPAGATE;
}

View File

@ -1846,16 +1846,6 @@ gtk_main_do_event (GdkEvent *event)
}
break;
case GDK_CONFIGURE:
if (GTK_IS_WINDOW (event_widget) &&
_gtk_widget_get_surface (event_widget) == event->any.surface)
{
gtk_window_configure (GTK_WINDOW (event_widget),
event->configure.width,
event->configure.height);
}
break;
case GDK_FOCUS_CHANGE:
case GDK_UNMAP:
case GDK_GRAB_BROKEN:

View File

@ -5288,7 +5288,6 @@ gtk_widget_event_internal (GtkWidget *widget,
case GDK_NOTHING:
case GDK_DELETE:
case GDK_DESTROY:
case GDK_CONFIGURE:
case GDK_MAP:
case GDK_UNMAP:
return gtk_widget_emit_event_signals (widget, event);

View File

@ -6869,6 +6869,7 @@ gtk_window_realize (GtkWidget *widget)
gtk_widget_set_surface (widget, surface);
g_signal_connect_swapped (surface, "notify::state", G_CALLBACK (surface_state_changed), widget);
g_signal_connect_swapped (surface, "size-changed", G_CALLBACK (gtk_window_configure), widget);
gtk_widget_register_surface (widget, surface);
GTK_WIDGET_CLASS (gtk_window_parent_class)->realize (widget);
@ -7007,6 +7008,9 @@ gtk_window_unrealize (GtkWidget *widget)
g_signal_handlers_disconnect_by_func (_gtk_widget_get_surface (widget),
G_CALLBACK (surface_state_changed),
widget);
g_signal_handlers_disconnect_by_func (_gtk_widget_get_surface (widget),
G_CALLBACK (gtk_window_configure),
widget);
GTK_WIDGET_CLASS (gtk_window_parent_class)->unrealize (widget);

View File

@ -8,21 +8,14 @@ static GtkWidget *default_width_spin;
static GtkWidget *default_height_spin;
static GtkWidget *resizable_check;
static gboolean
configure_event_cb (GtkWidget *window, GdkEvent *event, GtkLabel *label)
static void
configure_event_cb (GtkWidget *window, int width, int height, GtkLabel *label)
{
if (gdk_event_get_event_type (event) == GDK_CONFIGURE)
{
gchar *str;
gint width, height;
gchar *str;
gtk_window_get_size (GTK_WINDOW (window), &width, &height);
str = g_strdup_printf ("%d x %d", width, height);
gtk_label_set_label (label, str);
g_free (str);
}
return GDK_EVENT_PROPAGATE;
str = g_strdup_printf ("%d x %d", width, height);
gtk_label_set_label (label, str);
g_free (str);
}
static void
@ -71,7 +64,8 @@ show_dialog (void)
//gtk_widget_show (label);
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), label, GTK_RESPONSE_HELP);
g_signal_connect (dialog, "event",
gtk_widget_realize (dialog);
g_signal_connect (gtk_widget_get_surface (dialog), "size-changed",
G_CALLBACK (configure_event_cb), label);
gtk_dialog_run (GTK_DIALOG (dialog));