Compare commits

...

3 Commits

Author SHA1 Message Date
Matthias Clasen
8df53a48cd scrolledwindow: Create a synthetic motion during scrolling
We are not doing any layout here, so this is needed to fix
the listbox demo in gtk4-demo.
2020-02-21 16:40:10 -05:00
Matthias Clasen
af8e8d9a9c container: Create a synthetic motion during layout 2020-02-21 16:39:40 -05:00
Matthias Clasen
166c7f8a03 Add a function to synthesize motion events
We want to ensure that the pointer position is reflected
when widget geometry changes, so add a function that tells
GDK "please create a motion event at the current position
on this surface".
2020-02-21 16:38:36 -05:00
4 changed files with 69 additions and 1 deletions

View File

@@ -515,6 +515,54 @@ generate_grab_broken_event (GdkDisplay *display,
}
}
void
gdk_surface_ensure_motion (GdkSurface *surface)
{
GList *list, *l;
GdkDisplay *display;
GdkSeat *seat;
GdkDevice *device;
GdkEvent *event;
GdkFrameClock *frame_clock;
display = gdk_surface_get_display (surface);
for (l = g_queue_peek_head_link (&display->queued_events); l; l = l->next)
{
event = l->data;
if (event->any.type == GDK_MOTION_NOTIFY)
return;
}
seat = gdk_display_get_default_seat (display);
device = gdk_seat_get_pointer (seat);
list = gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_POINTER);
for (l = list; l; l = l->next)
{
GdkDevice *source_device = l->data;
double x, y;
GdkModifierType state;
gdk_surface_get_device_position (surface, device, &x, &y, &state);
event = gdk_event_motion_new (surface,
device,
source_device,
NULL,
GDK_CURRENT_TIME,
state,
x, y,
NULL);
_gdk_event_queue_append (display, event);
}
g_list_free (list);
frame_clock = gdk_surface_get_frame_clock (surface);
if (frame_clock)
gdk_frame_clock_request_phase (frame_clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
}
GdkDeviceGrabInfo *
_gdk_display_get_last_device_grab (GdkDisplay *display,
GdkDevice *device)

View File

@@ -614,6 +614,9 @@ GdkVulkanContext *
gdk_surface_create_vulkan_context(GdkSurface *surface,
GError **error);
GDK_AVAILABLE_IN_ALL
void gdk_surface_ensure_motion (GdkSurface *surface);
G_END_DECLS
#endif /* __GDK_SURFACE_H__ */

View File

@@ -372,7 +372,10 @@ gtk_container_idle_sizer (GdkFrameClock *clock,
if (gtk_widget_needs_allocate (GTK_WIDGET (container)))
{
if (GTK_IS_ROOT (container))
gtk_native_check_resize (GTK_NATIVE (container));
{
gtk_native_check_resize (GTK_NATIVE (container));
gdk_surface_ensure_motion (gtk_native_get_surface (GTK_NATIVE (container)));
}
else
g_warning ("gtk_container_idle_sizer() called on a non-native non-window");
}

View File

@@ -51,6 +51,7 @@
#include "gtktypebuiltins.h"
#include "gtkviewport.h"
#include "gtkwidgetprivate.h"
#include "gtknative.h"
#include "a11y/gtkscrolledwindowaccessible.h"
@@ -3470,9 +3471,22 @@ gtk_scrolled_window_adjustment_value_changed (GtkAdjustment *adjustment,
{
GtkScrolledWindow *scrolled_window = user_data;
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GtkNative *native;
GdkSurface *surface;
maybe_emit_edge_reached (scrolled_window, adjustment);
native = gtk_widget_get_native (GTK_WIDGET (scrolled_window));
if (native)
{
surface = gtk_native_get_surface (native);
if (surface)
{
g_print ("adjustment value changed\n");
//gdk_surface_ensure_motion (surface);
}
}
/* Allow overshooting for kinetic scrolling operations */
if (priv->deceleration_id)
return;