summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2018-07-15 19:52:28 -0400
committerMatthias Clasen <mclasen@redhat.com>2018-07-15 20:23:45 -0400
commit7a1073c3ae89e4cdf35d95afec564d48f776774f (patch)
tree2c3c4eb8f3d942362297923c48e80807211e5e5a
parente2fd33f78a5bcd461139a32957abfeaa45fa3d2e (diff)
downloadgtk+-7a1073c3ae89e4cdf35d95afec564d48f776774f.tar.gz
Revert "gdk: Drop configure events"
This reverts commit a8926c9d873ce968353a2eb1d3930c4f1ac79c94.
-rw-r--r--gdk/gdkevents.c10
-rw-r--r--gdk/gdkevents.h4
-rw-r--r--gdk/gdkeventsprivate.h22
-rw-r--r--gdk/gdksurface.c20
-rw-r--r--gdk/wayland/gdksurface-wayland.c13
-rw-r--r--gdk/x11/gdkdisplay-x11.c32
-rw-r--r--gtk/gtkimcontextxim.c2
-rw-r--r--gtk/gtkmain.c11
-rw-r--r--gtk/gtkwidget.c1
-rw-r--r--gtk/gtkwindow.c4
-rw-r--r--tests/testwindowsize.c24
11 files changed, 93 insertions, 50 deletions
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index b53c146943..02c61f389a 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -817,6 +817,7 @@ 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:
@@ -883,6 +884,7 @@ 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:
@@ -931,6 +933,10 @@ 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;
@@ -1061,6 +1067,10 @@ 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;
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index d725abf28c..291b6d34f8 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -111,6 +111,7 @@ 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;
@@ -151,6 +152,8 @@ 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_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
@@ -206,6 +209,7 @@ typedef enum
GDK_ENTER_NOTIFY,
GDK_LEAVE_NOTIFY,
GDK_FOCUS_CHANGE,
+ GDK_CONFIGURE,
GDK_PROXIMITY_IN,
GDK_PROXIMITY_OUT,
GDK_DRAG_ENTER,
diff --git a/gdk/gdkeventsprivate.h b/gdk/gdkeventsprivate.h
index 21f3518fbd..f4d15507e7 100644
--- a/gdk/gdkeventsprivate.h
+++ b/gdk/gdkeventsprivate.h
@@ -335,6 +335,26 @@ struct _GdkEventFocus
};
/*
+ * 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).
* @surface: the surface which received the event.
@@ -563,6 +583,7 @@ 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
@@ -613,6 +634,7 @@ union _GdkEvent
GdkEventKey key;
GdkEventCrossing crossing;
GdkEventFocus focus_change;
+ GdkEventConfigure configure;
GdkEventProximity proximity;
GdkEventDND dnd;
GdkEventGrabBroken grab_broken;
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index da5d0c65f3..7140f9c251 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2639,7 +2639,6 @@ 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));
@@ -2668,7 +2667,6 @@ gdk_surface_move_resize_internal (GdkSurface *surface,
/* Handle child surfaces */
expose = FALSE;
- size_changed = FALSE;
old_region = NULL;
if (gdk_surface_is_viewable (surface) &&
@@ -2694,16 +2692,8 @@ gdk_surface_move_resize_internal (GdkSurface *surface,
}
if (!(width < 0 && height < 0))
{
- if (surface->width != width)
- {
- surface->width = width;
- size_changed = TRUE;
- }
- if (surface->height != height)
- {
- surface->height = height;
- size_changed = TRUE;
- }
+ surface->width = width;
+ surface->height = height;
}
recompute_visible_regions (surface, FALSE);
@@ -2726,11 +2716,10 @@ 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
@@ -3895,6 +3884,7 @@ _gdk_make_event (GdkSurface *surface,
break;
case GDK_FOCUS_CHANGE:
+ case GDK_CONFIGURE:
case GDK_DELETE:
case GDK_DESTROY:
default:
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index ce0b5d773d..51eca561df 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -698,9 +698,20 @@ 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);
- g_signal_emit_by_name (surface, "size-changed", width, height);
+
+ display = gdk_surface_get_display (surface);
+ _gdk_wayland_display_deliver_event (display, event);
}
static gboolean
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 72ead44bbb..3dc613fc82 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -958,12 +958,11 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
return_val = FALSE;
else
{
- int x, y, width, height;
+ 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;
- 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))
@@ -980,34 +979,31 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
&tx, &ty,
&child_window))
{
- x = tx / surface_impl->surface_scale;
- y = ty / surface_impl->surface_scale;
+ event->configure.x = tx / surface_impl->surface_scale;
+ event->configure.y = ty / surface_impl->surface_scale;
}
gdk_x11_display_error_trap_pop_ignored (display);
}
else
{
- x = xevent->xconfigure.x / surface_impl->surface_scale;
- y = xevent->xconfigure.y / surface_impl->surface_scale;
+ event->configure.x = xevent->xconfigure.x / surface_impl->surface_scale;
+ event->configure.y = xevent->xconfigure.y / surface_impl->surface_scale;
}
-
if (!is_substructure)
{
- surface->x = x;
- surface->y = y;
+ surface->x = event->configure.x;
+ surface->y = event->configure.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 = width;
- surface->height = height;
+ surface->width = event->configure.width;
+ surface->height = event->configure.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)
@@ -1016,10 +1012,8 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
if (surface->resize_count == 0)
_gdk_x11_moveresize_configure_done (display, surface);
- }
+ }
}
-
- return_val = FALSE;
}
break;
diff --git a/gtk/gtkimcontextxim.c b/gtk/gtkimcontextxim.c
index 7cdb3c75b7..01629ab054 100644
--- a/gtk/gtkimcontextxim.c
+++ b/gtk/gtkimcontextxim.c
@@ -1603,7 +1603,6 @@ on_status_toplevel_configure (GtkWidget *toplevel,
GdkEvent *event,
StatusWindow *status_window)
{
-#if 0
if (gdk_event_get_event_type (event) == GDK_CONFIGURE)
{
GdkRectangle rect;
@@ -1626,7 +1625,6 @@ on_status_toplevel_configure (GtkWidget *toplevel,
gtk_window_move (GTK_WINDOW (status_window->window), rect.x, y);
}
}
-#endif
return GDK_EVENT_PROPAGATE;
}
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index d92523a90d..5d4b71935e 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1827,6 +1827,17 @@ 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_GRAB_BROKEN:
if (!_gtk_widget_captured_event (event_widget, event))
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 514bc0ac4b..a491d5b3e3 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5270,6 +5270,7 @@ gtk_widget_event_internal (GtkWidget *widget,
case GDK_NOTHING:
case GDK_DELETE:
case GDK_DESTROY:
+ case GDK_CONFIGURE:
return gtk_widget_emit_event_signals (widget, event);
default:
break;
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 295fbacee1..392d4ab268 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -6869,7 +6869,6 @@ 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);
@@ -7008,9 +7007,6 @@ 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);
diff --git a/tests/testwindowsize.c b/tests/testwindowsize.c
index 0f55a45092..6e62dd0a60 100644
--- a/tests/testwindowsize.c
+++ b/tests/testwindowsize.c
@@ -8,14 +8,21 @@ static GtkWidget *default_width_spin;
static GtkWidget *default_height_spin;
static GtkWidget *resizable_check;
-static void
-configure_event_cb (GtkWidget *window, int width, int height, GtkLabel *label)
+static gboolean
+configure_event_cb (GtkWidget *window, GdkEvent *event, GtkLabel *label)
{
- gchar *str;
-
- str = g_strdup_printf ("%d x %d", width, height);
- gtk_label_set_label (label, str);
- g_free (str);
+ if (gdk_event_get_event_type (event) == GDK_CONFIGURE)
+ {
+ gchar *str;
+ gint width, height;
+
+ 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;
}
static void
@@ -64,8 +71,7 @@ show_dialog (void)
//gtk_widget_show (label);
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), label, GTK_RESPONSE_HELP);
- gtk_widget_realize (dialog);
- g_signal_connect (gtk_widget_get_surface (dialog), "size-changed",
+ g_signal_connect (dialog, "event",
G_CALLBACK (configure_event_cb), label);
gtk_dialog_run (GTK_DIALOG (dialog));