Compare commits

...

7 Commits

Author SHA1 Message Date
Matthias Clasen
c71757dd70 gdk: Drop GdkEventConfigure
This is no longer used.
2018-07-15 08:13:12 -04:00
Matthias Clasen
8aeef172e8 xim: Stop listening for configure events
Instead, we need to listen for position changes.
That won't work in general. For now, do nothing.
2018-07-15 08:12:57 -04:00
Matthias Clasen
edccd76fbb tests: Stop using configure events 2018-07-15 08:12:57 -04:00
Matthias Clasen
d0e28abbd4 x11: Stop sending configure events
No longer needed.
2018-07-15 07:42:09 -04:00
Matthias Clasen
343e3f3982 wayland: Stop sending configure events
These are no longer needed.
2018-07-15 07:42:08 -04:00
Matthias Clasen
028c5dcf98 Stop using configure events
Listen to changes of ::width and ::height properties instead.
2018-07-15 00:53:37 -04:00
Matthias Clasen
286b27e55f gdk: Make surface width and height properties
This is the first step to removing configure events.
2018-07-15 00:04:51 -04:00
14 changed files with 119 additions and 105 deletions

View File

@@ -397,8 +397,8 @@ gdk_surface_broadway_move_resize (GdkSurface *surface,
impl->dirty = TRUE;
impl->last_synced = FALSE;
surface->width = width;
surface->height = height;
g_object_freeze_notify (G_OBJECT (surface));
gdk_surface_set_size (surface, width, height);
}
}
@@ -412,6 +412,7 @@ gdk_surface_broadway_move_resize (GdkSurface *surface,
{
surface->resize_count++;
_gdk_surface_update_size (surface);
g_object_thaw_notify (G_OBJECT (surface));
}
}

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

@@ -292,6 +292,10 @@ void gdk_surface_get_unscaled_size (GdkSurface *surface,
int *unscaled_width,
int *unscaled_height);
void gdk_surface_set_size (GdkSurface *surface,
int width,
int height);
/*****************************************
* Interfaces provided by windowing code *
*****************************************/

View File

@@ -105,6 +105,8 @@ enum {
PROP_CURSOR,
PROP_DISPLAY,
PROP_STATE,
PROP_WIDTH,
PROP_HEIGHT,
LAST_PROP
};
@@ -271,6 +273,21 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
GDK_TYPE_SURFACE_STATE, GDK_SURFACE_STATE_WITHDRAWN,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
properties[PROP_WIDTH] =
g_param_spec_int ("width",
P_("Width"),
P_("Width"),
1, G_MAXINT, 1,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
properties[PROP_HEIGHT] =
g_param_spec_int ("height",
P_("Width"),
P_("Width"),
1, G_MAXINT, 1,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, LAST_PROP, properties);
/**
@@ -416,6 +433,14 @@ gdk_surface_get_property (GObject *object,
g_value_set_flags (value, surface->state);
break;
case PROP_WIDTH:
g_value_set_int (value, surface->width);
break;
case PROP_HEIGHT:
g_value_set_int (value, surface->height);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -2652,6 +2677,26 @@ gdk_surface_move_resize_toplevel (GdkSurface *surface,
recompute_visible_regions (surface, FALSE);
}
void
gdk_surface_set_size (GdkSurface *surface,
int width,
int height)
{
g_object_freeze_notify (G_OBJECT (surface));
if (surface->width != width)
{
surface->width = width;
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_WIDTH]);
}
if (surface->height != height)
{
surface->height = height;
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_HEIGHT]);
}
g_object_thaw_notify (G_OBJECT (surface));
}
static void
gdk_surface_move_resize_internal (GdkSurface *surface,
@@ -2690,6 +2735,8 @@ gdk_surface_move_resize_internal (GdkSurface *surface,
/* Handle child surfaces */
g_object_freeze_notify (G_OBJECT (surface));
expose = FALSE;
old_region = NULL;
@@ -2715,10 +2762,7 @@ gdk_surface_move_resize_internal (GdkSurface *surface,
surface->y = y;
}
if (!(width < 0 && height < 0))
{
surface->width = width;
surface->height = height;
}
gdk_surface_set_size (surface, width, height);
recompute_visible_regions (surface, FALSE);
@@ -2740,6 +2784,8 @@ gdk_surface_move_resize_internal (GdkSurface *surface,
cairo_region_destroy (old_region);
cairo_region_destroy (new_region);
}
g_object_thaw_notify (G_OBJECT (surface));
}
@@ -3908,7 +3954,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

@@ -306,8 +306,9 @@ gdk_wayland_surface_update_size (GdkSurface *surface,
(impl->scale == scale))
return;
surface->width = width;
surface->height = height;
g_object_freeze_notify (G_OBJECT (surface));
gdk_surface_set_size (surface, width, height);
impl->scale = scale;
if (impl->display_server.egl_window)
@@ -316,6 +317,9 @@ gdk_wayland_surface_update_size (GdkSurface *surface,
wl_surface_set_buffer_scale (impl->display_server.wl_surface, scale);
gdk_surface_invalidate_rect (surface, NULL);
_gdk_surface_update_size (surface);
g_object_thaw_notify (G_OBJECT (surface));
}
static const gchar *
@@ -698,20 +702,7 @@ 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);
}
static gboolean

View File

@@ -960,10 +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 &&
@@ -981,31 +983,31 @@ 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;
g_object_freeze_notify (G_OBJECT (surface));
gdk_surface_set_size (surface, width, height);
_gdk_surface_update_size (surface);
_gdk_x11_surface_update_size (surface_impl);
g_object_thaw_notify (G_OBJECT (surface));
}
if (surface->resize_count >= 1)
@@ -1016,6 +1018,8 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
_gdk_x11_moveresize_configure_done (display, surface);
}
}
return_val = FALSE;
}
break;

View File

@@ -923,11 +923,9 @@ _gdk_x11_display_create_surface_impl (GdkDisplay *display,
surface->height * impl->surface_scale > 32767)
{
g_warning ("Native Windows wider or taller than 32767 pixels are not supported");
if (surface->width * impl->surface_scale > 32767)
surface->width = 32767 / impl->surface_scale;
if (surface->height * impl->surface_scale > 32767)
surface->height = 32767 / impl->surface_scale;
gdk_surface_set_size (surface,
MIN (surface->width, 32767 / impl->surface_scale),
MIN (surface->height, 32767 / impl->surface_scale));
}
impl->unscaled_width = surface->width * impl->surface_scale;
@@ -1371,9 +1369,10 @@ surface_x11_resize (GdkSurface *surface,
{
impl->unscaled_width = width * impl->surface_scale;
impl->unscaled_height = height * impl->surface_scale;
surface->width = width;
surface->height = height;
g_object_freeze_notify (G_OBJECT (surface));
gdk_surface_set_size (surface, width, height);
_gdk_x11_surface_update_size (GDK_SURFACE_IMPL_X11 (surface->impl));
g_object_thaw_notify (G_OBJECT (surface));
}
else
{
@@ -1411,10 +1410,10 @@ surface_x11_move_resize (GdkSurface *surface,
impl->unscaled_width = width * impl->surface_scale;
impl->unscaled_height = height * impl->surface_scale;
surface->width = width;
surface->height = height;
g_object_freeze_notify (G_OBJECT (surface));
gdk_surface_set_size (surface, width, height);
_gdk_x11_surface_update_size (GDK_SURFACE_IMPL_X11 (surface->impl));
g_object_thaw_notify (G_OBJECT (surface));
}
else
{

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

@@ -432,6 +432,7 @@ static gboolean gtk_window_close_request (GtkWindow *window);
static void gtk_window_focus_in (GtkWidget *widget);
static void gtk_window_focus_out (GtkWidget *widget);
static void surface_state_changed (GtkWidget *widget);
static void surface_size_changed (GtkWidget *widget);
static void gtk_window_remove (GtkContainer *container,
GtkWidget *widget);
static void gtk_window_check_resize (GtkContainer *container);
@@ -6869,6 +6870,8 @@ 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, "notify::width", G_CALLBACK (surface_size_changed), widget);
g_signal_connect_swapped (surface, "notify::height", G_CALLBACK (surface_size_changed), widget);
gtk_widget_register_surface (widget, surface);
GTK_WIDGET_CLASS (gtk_window_parent_class)->realize (widget);
@@ -7007,6 +7010,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 (surface_size_changed),
widget);
GTK_WIDGET_CLASS (gtk_window_parent_class)->unrealize (widget);
@@ -7320,6 +7326,16 @@ surface_state_changed (GtkWidget *widget)
}
}
static void
surface_size_changed (GtkWidget *widget)
{
GdkSurface *surface = _gtk_widget_get_surface (widget);
gtk_window_configure (GTK_WINDOW (widget),
gdk_surface_get_width (surface),
gdk_surface_get_height (surface));
}
/* the accel_key and accel_mods fields of the key have to be setup
* upon calling this function. itll then return whether that key
* is at all used as accelerator, and if so will OR in the

View File

@@ -9,20 +9,16 @@ static GtkWidget *default_height_spin;
static GtkWidget *resizable_check;
static gboolean
configure_event_cb (GtkWidget *window, GdkEvent *event, GtkLabel *label)
configure_event_cb (GdkSurface *surface, GParamSpec *pspec, GtkLabel *label)
{
if (gdk_event_get_event_type (event) == GDK_CONFIGURE)
{
gchar *str;
gint width, height;
int width, height;
char *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;
width = gdk_surface_get_width (surface);
height = gdk_surface_get_height (surface);
str = g_strdup_printf ("%d x %d", width, height);
gtk_label_set_label (label, str);
g_free (str);
}
static void
@@ -71,7 +67,10 @@ 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), "notify::width",
G_CALLBACK (configure_event_cb), label);
g_signal_connect (gtk_widget_get_surface (dialog), "notify::height",
G_CALLBACK (configure_event_cb), label);
gtk_dialog_run (GTK_DIALOG (dialog));