diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-09-06 13:25:43 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-09-06 13:25:43 +0000 |
commit | bd7aa1782cc2d10ba1cf44db6df277c3bfee04dc (patch) | |
tree | 402dc59bc7d5de80f43b31e4a931a83409f03d8b | |
parent | 007c9c62186eb24166781a8222431193b7707d0e (diff) | |
parent | 8c8baa9aa66b45b61f7e86368b5ede7588862380 (diff) | |
download | gtk+-bd7aa1782cc2d10ba1cf44db6df277c3bfee04dc.tar.gz |
Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master
See merge request GNOME/gtk!2535
-rw-r--r-- | demos/gtk-demo/constraints.c | 12 | ||||
-rw-r--r-- | demos/gtk-demo/constraints2.c | 12 | ||||
-rw-r--r-- | demos/gtk-demo/constraints3.c | 12 | ||||
-rw-r--r-- | demos/gtk-demo/four_point_transform.c | 6 | ||||
-rw-r--r-- | demos/gtk-demo/singular_value_decomposition.c | 55 | ||||
-rw-r--r-- | gtk/inspector/general.c | 37 |
6 files changed, 98 insertions, 36 deletions
diff --git a/demos/gtk-demo/constraints.c b/demos/gtk-demo/constraints.c index fc6eb5d72b..6f842008fb 100644 --- a/demos/gtk-demo/constraints.c +++ b/demos/gtk-demo/constraints.c @@ -254,15 +254,11 @@ do_constraints (GtkWidget *do_widget) if (!window) { - GtkWidget *header, *box, *grid, *button; + GtkWidget *box, *grid; window = gtk_window_new (); gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget)); gtk_window_set_title (GTK_WINDOW (window), "Constraints"); - - header = gtk_header_bar_new (); - gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE); - gtk_window_set_titlebar (GTK_WINDOW (window), header); g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window); box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); @@ -272,12 +268,6 @@ do_constraints (GtkWidget *do_widget) gtk_widget_set_hexpand (grid, TRUE); gtk_widget_set_vexpand (grid, TRUE); gtk_box_append (GTK_BOX (box), grid); - - button = gtk_button_new_with_label ("Close"); - gtk_box_append (GTK_BOX (box), button); - gtk_widget_set_hexpand (grid, TRUE); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_window_destroy), window); } if (!gtk_widget_get_visible (window)) diff --git a/demos/gtk-demo/constraints2.c b/demos/gtk-demo/constraints2.c index 01c898f24b..8e804592ed 100644 --- a/demos/gtk-demo/constraints2.c +++ b/demos/gtk-demo/constraints2.c @@ -210,15 +210,11 @@ do_constraints2 (GtkWidget *do_widget) if (!window) { - GtkWidget *header, *box, *grid, *button; + GtkWidget *box, *grid; window = gtk_window_new (); gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget)); gtk_window_set_title (GTK_WINDOW (window), "Constraints"); - - header = gtk_header_bar_new (); - gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE); - gtk_window_set_titlebar (GTK_WINDOW (window), header); g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window); box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); @@ -228,12 +224,6 @@ do_constraints2 (GtkWidget *do_widget) gtk_widget_set_hexpand (grid, TRUE); gtk_widget_set_vexpand (grid, TRUE); gtk_box_append (GTK_BOX (box), grid); - - button = gtk_button_new_with_label ("Close"); - gtk_box_append (GTK_BOX (box), button); - gtk_widget_set_hexpand (grid, TRUE); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_window_destroy), window); } if (!gtk_widget_get_visible (window)) diff --git a/demos/gtk-demo/constraints3.c b/demos/gtk-demo/constraints3.c index 64d484abb6..0cb9b97702 100644 --- a/demos/gtk-demo/constraints3.c +++ b/demos/gtk-demo/constraints3.c @@ -130,15 +130,11 @@ do_constraints3 (GtkWidget *do_widget) if (!window) { - GtkWidget *header, *box, *grid, *button; + GtkWidget *box, *grid; window = gtk_window_new (); gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget)); gtk_window_set_title (GTK_WINDOW (window), "Constraints"); - - header = gtk_header_bar_new (); - gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE); - gtk_window_set_titlebar (GTK_WINDOW (window), header); g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window); box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); @@ -148,12 +144,6 @@ do_constraints3 (GtkWidget *do_widget) gtk_widget_set_hexpand (grid, TRUE); gtk_widget_set_vexpand (grid, TRUE); gtk_box_append (GTK_BOX (box), grid); - - button = gtk_button_new_with_label ("Close"); - gtk_box_append (GTK_BOX (box), button); - gtk_widget_set_hexpand (grid, TRUE); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_window_destroy), window); } if (!gtk_widget_get_visible (window)) diff --git a/demos/gtk-demo/four_point_transform.c b/demos/gtk-demo/four_point_transform.c index 9df10ef163..beffc174ae 100644 --- a/demos/gtk-demo/four_point_transform.c +++ b/demos/gtk-demo/four_point_transform.c @@ -63,11 +63,15 @@ unit_to (graphene_point3d_t *p1, graphene_matrix_multiply (&s, &u, m); } -/* Make a 4x4 matrix that maps +/* Compute a 4x4 matrix m that maps * p1 -> q1 * p2 -> q2 * p3 -> q3 * p4 -> q4 + * + * This is not in general possible, because projective + * transforms preserve coplanarity. But in the cases we + * care about here, both sets of points are always coplanar. */ void perspective_3d (graphene_point3d_t *p1, diff --git a/demos/gtk-demo/singular_value_decomposition.c b/demos/gtk-demo/singular_value_decomposition.c index 05d04d0667..e6d063ab4b 100644 --- a/demos/gtk-demo/singular_value_decomposition.c +++ b/demos/gtk-demo/singular_value_decomposition.c @@ -11,6 +11,20 @@ #define MAX_ITERATION_COUNT 30 +/* Perform Householder reduction to bidiagonal form + * + * Input: Matrix A of size nrows x ncols + * + * Output: Matrices and vectors such that + * A = U*Bidiag(diagonal, superdiagonal)*Vt + * + * All matrices are allocated by the caller + * + * Sizes: + * A, U: nrows x ncols + * diagonal, superdiagonal: ncols + * V: ncols x ncols + */ static void householder_reduction (double *A, int nrows, @@ -160,6 +174,20 @@ householder_reduction (double *A, } } +/* Perform Givens reduction + * + * Input: Matrices such that + * A = U*Bidiag(diagonal,superdiagonal)*Vt + * + * Output: The same, with superdiagonal = 0 + * + * All matrices are allocated by the caller + * + * Sizes: + * U: nrows x ncols + * diagonal, superdiagonal: ncols + * V: ncols x ncols + */ static int givens_reduction (int nrows, int ncols, @@ -298,6 +326,11 @@ givens_reduction (int nrows, return 0; } +/* Given a singular value decomposition + * of an nrows x ncols matrix A = U*Diag(S)*Vt, + * sort the values of S by decreasing value, + * permuting V to match. + */ static void sort_singular_values (int nrows, int ncols, @@ -339,6 +372,16 @@ sort_singular_values (int nrows, } } +/* Compute a singular value decomposition of A, + * A = U*Diag(S)*Vt + * + * All matrices are allocated by the caller + * + * Sizes: + * A, U: nrows x ncols + * S: ncols + * V: ncols x ncols + */ int singular_value_decomposition (double *A, int nrows, @@ -364,6 +407,18 @@ singular_value_decomposition (double *A, return 0; } +/* + * Given a singular value decomposition of A = U*Diag(S)*Vt, + * compute the best approximation x to A*x = B. + * + * All matrices are allocated by the caller + * + * Sizes: + * U: nrows x ncols + * S: ncols + * V: ncols x ncols + * B, x: ncols + */ void singular_value_decomposition_solve (double *U, double *S, diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c index 76bd0011e2..ab368e2f8d 100644 --- a/gtk/inspector/general.c +++ b/gtk/inspector/general.c @@ -818,6 +818,13 @@ add_seat (GtkInspectorGeneral *gen, } static void +disconnect_seat (GtkInspectorGeneral *gen, + GdkSeat *seat) +{ + g_signal_handlers_disconnect_by_func (seat, G_CALLBACK (populate_seats), gen); +} + +static void populate_seats (GtkInspectorGeneral *gen) { GtkWidget *child; @@ -836,10 +843,27 @@ populate_seats (GtkInspectorGeneral *gen) } static void +seat_added (GdkDisplay *display, + GdkSeat *seat, + GtkInspectorGeneral *gen) +{ + populate_seats (gen); +} + +static void +seat_removed (GdkDisplay *display, + GdkSeat *seat, + GtkInspectorGeneral *gen) +{ + disconnect_seat (gen, seat); + populate_seats (gen); +} + +static void init_device (GtkInspectorGeneral *gen) { - g_signal_connect_swapped (gen->display, "seat-added", G_CALLBACK (populate_seats), gen); - g_signal_connect_swapped (gen->display, "seat-removed", G_CALLBACK (populate_seats), gen); + g_signal_connect (gen->display, "seat-added", G_CALLBACK (seat_added), gen); + g_signal_connect (gen->display, "seat-removed", G_CALLBACK (seat_removed), gen); populate_seats (gen); } @@ -911,9 +935,18 @@ static void gtk_inspector_general_dispose (GObject *object) { GtkInspectorGeneral *gen = GTK_INSPECTOR_GENERAL (object); + GList *list, *l; g_clear_pointer (&gen->swin, gtk_widget_unparent); + g_signal_handlers_disconnect_by_func (gen->display, G_CALLBACK (seat_added), gen); + g_signal_handlers_disconnect_by_func (gen->display, G_CALLBACK (seat_removed), gen); + + list = gdk_display_list_seats (gen->display); + for (l = list; l; l = l->next) + disconnect_seat (gen, GDK_SEAT (l->data)); + g_list_free (list); + G_OBJECT_CLASS (gtk_inspector_general_parent_class)->dispose (object); } |