mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 18:30:08 +00:00
parent
e2fd33f78a
commit
7a1073c3ae
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -334,6 +334,26 @@ 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).
|
||||
@ -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;
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
if (gdk_event_get_event_type (event) == GDK_CONFIGURE)
|
||||
{
|
||||
gchar *str;
|
||||
gint width, height;
|
||||
|
||||
str = g_strdup_printf ("%d x %d", width, height);
|
||||
gtk_label_set_label (label, str);
|
||||
g_free (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;
|
||||
}
|
||||
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user