forked from AuroraMiddleware/gtk
surface: Remove gdk_surface_scroll()
It's yet another fancy way to call gdk_surface_invalidate_region(). Also remove the one testgtk test that was still using it.
This commit is contained in:
parent
d6ba10bacf
commit
a1898d678b
@ -216,7 +216,6 @@ gdk_surface_get_pass_through
|
||||
gdk_surface_move
|
||||
gdk_surface_resize
|
||||
gdk_surface_move_resize
|
||||
gdk_surface_scroll
|
||||
gdk_surface_has_native
|
||||
gdk_surface_raise
|
||||
gdk_surface_lower
|
||||
|
@ -3932,58 +3932,6 @@ gdk_surface_move_to_rect (GdkSurface *surface,
|
||||
rect_anchor_dy);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_surface_scroll:
|
||||
* @surface: a #GdkSurface
|
||||
* @dx: Amount to scroll in the X direction
|
||||
* @dy: Amount to scroll in the Y direction
|
||||
*
|
||||
* Scroll the contents of @surface, both pixels and children, by the
|
||||
* given amount. @surface itself does not move. Portions of the surface
|
||||
* that the scroll operation brings in from offscreen areas are
|
||||
* invalidated. The invalidated region may be bigger than what would
|
||||
* strictly be necessary.
|
||||
*
|
||||
* For X11, a minimum area will be invalidated if the surface has no
|
||||
* subsurfaces, or if the edges of the surface’s parent do not extend
|
||||
* beyond the edges of the surface. In other cases, a multi-step process
|
||||
* is used to scroll the surface which may produce temporary visual
|
||||
* artifacts and unnecessary invalidations.
|
||||
**/
|
||||
void
|
||||
gdk_surface_scroll (GdkSurface *surface,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
GList *tmp_list;
|
||||
|
||||
g_return_if_fail (GDK_IS_SURFACE (surface));
|
||||
|
||||
if (dx == 0 && dy == 0)
|
||||
return;
|
||||
|
||||
if (surface->destroyed)
|
||||
return;
|
||||
|
||||
/* First move all child surfaces, without causing invalidation */
|
||||
|
||||
tmp_list = surface->children;
|
||||
while (tmp_list)
|
||||
{
|
||||
GdkSurface *child = GDK_SURFACE (tmp_list->data);
|
||||
|
||||
/* Just update the positions, the bits will move with the copy */
|
||||
child->x += dx;
|
||||
child->y += dy;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
recompute_visible_regions (surface, TRUE);
|
||||
|
||||
gdk_surface_invalidate_rect_full (surface, NULL, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_surface_set_cursor_internal (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
|
@ -513,10 +513,6 @@ gboolean gdk_surface_get_focus_on_map (GdkSurface *surface);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_set_focus_on_map (GdkSurface *surface,
|
||||
gboolean focus_on_map);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_scroll (GdkSurface *surface,
|
||||
gint dx,
|
||||
gint dy);
|
||||
|
||||
/*
|
||||
* This allows for making shaped (partially transparent) surfaces
|
||||
|
155
tests/testgtk.c
155
tests/testgtk.c
@ -6909,160 +6909,6 @@ create_snapshot (GtkWidget *widget)
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Test scrolling
|
||||
*/
|
||||
|
||||
static int scroll_test_pos = 0.0;
|
||||
|
||||
static void
|
||||
scroll_test_draw (GtkDrawingArea *darea,
|
||||
cairo_t *cr,
|
||||
int width,
|
||||
int height,
|
||||
gpointer adjustment)
|
||||
{
|
||||
gint i,j;
|
||||
gint imin, imax, jmin, jmax;
|
||||
GdkRectangle clip;
|
||||
|
||||
gdk_cairo_get_clip_rectangle (cr, &clip);
|
||||
|
||||
imin = (clip.x) / 10;
|
||||
imax = (clip.x + clip.width + 9) / 10;
|
||||
|
||||
jmin = ((int)gtk_adjustment_get_value (adjustment) + clip.y) / 10;
|
||||
jmax = ((int)gtk_adjustment_get_value (adjustment) + clip.y + clip.height + 9) / 10;
|
||||
|
||||
for (i=imin; i<imax; i++)
|
||||
for (j=jmin; j<jmax; j++)
|
||||
if ((i+j) % 2)
|
||||
cairo_rectangle (cr, 10*i, 10*j - (int)gtk_adjustment_get_value (adjustment), 1+i%10, 1+j%10);
|
||||
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
scroll_test_scroll (GtkEventControllerScroll *scroll,
|
||||
double dx,
|
||||
double dy,
|
||||
GtkAdjustment *adjustment)
|
||||
{
|
||||
gdouble new_value;
|
||||
|
||||
new_value = gtk_adjustment_get_value (adjustment) + dy * gtk_adjustment_get_page_increment (adjustment) / 2;
|
||||
new_value = CLAMP (new_value, gtk_adjustment_get_lower (adjustment), gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_page_size (adjustment));
|
||||
gtk_adjustment_set_value (adjustment, new_value);
|
||||
}
|
||||
|
||||
static void
|
||||
scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event,
|
||||
GtkAdjustment *adjustment)
|
||||
{
|
||||
GtkAllocation allocation;
|
||||
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
gtk_adjustment_configure (adjustment,
|
||||
gtk_adjustment_get_value (adjustment),
|
||||
gtk_adjustment_get_lower (adjustment),
|
||||
gtk_adjustment_get_upper (adjustment),
|
||||
0.1 * allocation.height,
|
||||
0.9 * allocation.height,
|
||||
allocation.height);
|
||||
}
|
||||
|
||||
static void
|
||||
scroll_test_adjustment_changed (GtkAdjustment *adjustment, GtkWidget *widget)
|
||||
{
|
||||
GdkSurface *window;
|
||||
gint dy;
|
||||
|
||||
dy = scroll_test_pos - (int)gtk_adjustment_get_value (adjustment);
|
||||
scroll_test_pos = gtk_adjustment_get_value (adjustment);
|
||||
|
||||
if (!gtk_widget_is_drawable (widget))
|
||||
return;
|
||||
|
||||
window = gtk_widget_get_surface (widget);
|
||||
gdk_surface_scroll (window, 0, dy);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
create_scroll_test (GtkWidget *widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *content_area;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *drawing_area;
|
||||
GtkWidget *scrollbar;
|
||||
GtkAdjustment *adjustment;
|
||||
GtkEventController *controller;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_dialog_new ();
|
||||
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (widget));
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&window);
|
||||
|
||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Scroll Test");
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_pack_start (GTK_BOX (content_area), hbox);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
adjustment = gtk_adjustment_new (0.0, 0.0, 1000.0, 1.0, 180.0, 200.0);
|
||||
scroll_test_pos = 0.0;
|
||||
|
||||
drawing_area = gtk_drawing_area_new ();
|
||||
gtk_widget_set_hexpand (drawing_area, TRUE);
|
||||
gtk_widget_set_vexpand (drawing_area, TRUE);
|
||||
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (drawing_area), 200);
|
||||
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (drawing_area), 200);
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area),
|
||||
scroll_test_draw,
|
||||
adjustment,
|
||||
g_object_unref);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), drawing_area);
|
||||
gtk_widget_show (drawing_area);
|
||||
|
||||
scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjustment);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), scrollbar);
|
||||
gtk_widget_show (scrollbar);
|
||||
|
||||
g_signal_connect (drawing_area, "configure_event",
|
||||
G_CALLBACK (scroll_test_configure), adjustment);
|
||||
controller = gtk_event_controller_scroll_new (drawing_area, GTK_EVENT_CONTROLLER_SCROLL_VERTICAL);
|
||||
g_object_set_data_full (G_OBJECT (drawing_area), "scroll", controller, g_object_unref);
|
||||
g_signal_connect (controller, "scroll", G_CALLBACK (scroll_test_scroll), adjustment);
|
||||
|
||||
g_signal_connect (adjustment, "value_changed",
|
||||
G_CALLBACK (scroll_test_adjustment_changed),
|
||||
drawing_area);
|
||||
|
||||
/* .. And create some buttons */
|
||||
|
||||
gtk_dialog_add_button (GTK_DIALOG (window),
|
||||
"Quit",
|
||||
GTK_RESPONSE_CLOSE);
|
||||
g_signal_connect_swapped (window, "response",
|
||||
G_CALLBACK (gtk_widget_destroy),
|
||||
window);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
/*
|
||||
* Timeout Test
|
||||
*/
|
||||
@ -7774,7 +7620,6 @@ struct {
|
||||
{ "spinbutton", create_spins },
|
||||
{ "statusbar", create_statusbar },
|
||||
{ "test mainloop", create_mainloop, TRUE },
|
||||
{ "test scrolling", create_scroll_test },
|
||||
{ "test timeout", create_timeout_test },
|
||||
{ "toggle buttons", create_toggle_buttons },
|
||||
{ "tooltips", create_tooltips },
|
||||
|
Loading…
Reference in New Issue
Block a user