diff options
author | Jonas Ådahl <jadahl@gmail.com> | 2023-03-24 11:26:05 +0100 |
---|---|---|
committer | Jonas Ådahl <jadahl@gmail.com> | 2023-04-20 14:52:01 +0200 |
commit | 1da8df81c52a0fd9f694e2ca55442231f868fc1c (patch) | |
tree | 0291ad38e85ee4a40ceb1d19076be29421eb4214 | |
parent | d272b16e5066464f90273e95d3ce4c1f725a2880 (diff) | |
download | gnome-shell-1da8df81c52a0fd9f694e2ca55442231f868fc1c.tar.gz |
perf-helper: Allow creating window with text input
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2722>
-rw-r--r-- | data/dbus-interfaces/org.gnome.Shell.PerfHelper.xml | 1 | ||||
-rw-r--r-- | js/ui/scripting.js | 4 | ||||
-rw-r--r-- | 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 @@ <arg type="b" direction="in"/> <arg type="b" direction="in"/> <arg type="b" direction="in"/> + <arg type="b" direction="in"/> </method> <method name="WaitWindows"/> <method name="DestroyWindows"/> 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[] = " <arg type='b' name='alpha' direction='in'/>" " <arg type='b' name='maximized' direction='in'/>" " <arg type='b' name='redraws' direction='in'/>" + " <arg type='b' name='text_input' direction='in'/>" " </method>" " <method name='WaitWindows'/>" " <method name='DestroyWindows'/>" @@ -112,6 +113,22 @@ on_window_map_event (GtkWidget *window, } 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, WindowInfo *info) @@ -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) |