From 1da8df81c52a0fd9f694e2ca55442231f868fc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 24 Mar 2023 11:26:05 +0100 Subject: [PATCH] perf-helper: Allow creating window with text input Part-of: --- .../org.gnome.Shell.PerfHelper.xml | 1 + js/ui/scripting.js | 4 +- src/shell-perf-helper.c | 55 +++++++++++++------ 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/data/dbus-interfaces/org.gnome.Shell.PerfHelper.xml b/data/dbus-interfaces/org.gnome.Shell.PerfHelper.xml index 140bbcc34..739237d74 100644 --- a/data/dbus-interfaces/org.gnome.Shell.PerfHelper.xml +++ b/data/dbus-interfaces/org.gnome.Shell.PerfHelper.xml @@ -7,6 +7,7 @@ + diff --git a/js/ui/scripting.js b/js/ui/scripting.js index f988d53f9..51639b91d 100644 --- a/js/ui/scripting.js +++ b/js/ui/scripting.js @@ -107,12 +107,14 @@ function createTestWindow(params) { alpha: false, maximized: false, redraws: false, + textInput: false, }); let perfHelper = _getPerfHelper(); perfHelper.CreateWindowAsync( params.width, params.height, - params.alpha, params.maximized, params.redraws).catch(logError); + params.alpha, params.maximized, + params.redraws, params.textInput).catch(logError); } /** diff --git a/src/shell-perf-helper.c b/src/shell-perf-helper.c index a50376e2e..16cbb748d 100644 --- a/src/shell-perf-helper.c +++ b/src/shell-perf-helper.c @@ -29,6 +29,7 @@ static const gchar introspection_xml[] = " " " " " " + " " " " " " " " @@ -111,6 +112,22 @@ on_window_map_event (GtkWidget *window, return FALSE; } +static gboolean +on_window_draw (GtkWidget *window, + cairo_t *cr, + WindowInfo *info) +{ + info->exposed = TRUE; + + if (info->exposed && info->mapped && info->pending) + { + info->pending = FALSE; + check_finish_wait_windows (); + } + + return FALSE; +} + static gboolean on_child_draw (GtkWidget *window, cairo_t *cr, @@ -160,14 +177,6 @@ on_child_draw (GtkWidget *window, cairo_line_to (cr, allocation.width - 40 + x_offset, allocation.height); cairo_stroke (cr); - info->exposed = TRUE; - - if (info->exposed && info->mapped && info->pending) - { - info->pending = FALSE; - check_finish_wait_windows (); - } - return FALSE; } @@ -193,7 +202,8 @@ create_window (int width, int height, gboolean alpha, gboolean maximized, - gboolean redraws) + gboolean redraws, + gboolean text_input) { WindowInfo *info; GtkWidget *child; @@ -212,13 +222,24 @@ create_window (int width, info->pending = TRUE; info->start_time = -1; - child = g_object_new (GTK_TYPE_BOX, "visible", TRUE, "app-paintable", TRUE, NULL); + if (text_input) + { + child = gtk_entry_new (); + gtk_widget_show (child); + } + else + { + child = g_object_new (GTK_TYPE_BOX, "visible", TRUE, "app-paintable", TRUE, NULL); + gtk_widget_set_app_paintable (info->window, TRUE); + g_signal_connect (child, "draw", G_CALLBACK (on_child_draw), info); + } + gtk_container_add (GTK_CONTAINER (info->window), child); - gtk_widget_set_size_request (info->window, width, height); - gtk_widget_set_app_paintable (info->window, TRUE); + g_signal_connect (info->window, "draw", G_CALLBACK (on_window_draw), info); g_signal_connect (info->window, "map-event", G_CALLBACK (on_window_map_event), info); - g_signal_connect (child, "draw", G_CALLBACK (on_child_draw), info); + + gtk_widget_set_size_request (info->window, width, height); gtk_widget_show (info->window); if (info->redraws) @@ -282,11 +303,13 @@ handle_method_call (GDBusConnection *connection, else if (g_strcmp0 (method_name, "CreateWindow") == 0) { int width, height; - gboolean alpha, maximized, redraws; + gboolean alpha, maximized, redraws, text_input; - g_variant_get (parameters, "(iibbb)", &width, &height, &alpha, &maximized, &redraws); + g_variant_get (parameters, "(iibbbb)", + &width, &height, + &alpha, &maximized, &redraws, &text_input); - create_window (width, height, alpha, maximized, redraws); + create_window (width, height, alpha, maximized, redraws, text_input); g_dbus_method_invocation_return_value (invocation, NULL); } else if (g_strcmp0 (method_name, "WaitWindows") == 0)