Commit Graph

75765 Commits

Author SHA1 Message Date
Benjamin Otte
a147da1120 testsuite: Run json parser as a single test
Much faster.
2023-04-15 06:11:54 +02:00
Benjamin Otte
f953673edb testsuite: Add a testsuite for the json parser
Add a simple test runner and the testsuite from https://github.com/nst/JSONTestSuite
2023-04-15 06:11:54 +02:00
Benjamin Otte
670286eb9e jsonparser: Don't treat \0 as eof
Instead, treat it as regular part of the data and emit errors when we
encounter it.
2023-04-15 06:11:54 +02:00
Benjamin Otte
a7a3ec8a16 jsonparser: Don't stack overflow
Handle skipping deep nested object/array trees when skipping them
without causing stack overflow.

The code is somewhat brittle, but it seems to work.
2023-04-15 06:11:54 +02:00
Benjamin Otte
506b009925 jsonparser: Accept UTF-8 BOM at start of document 2023-04-15 06:11:54 +02:00
Benjamin Otte
1459810b43 jsonparser: Improve error handling
* Add a custom GError domain with our own error values
 * Add API so external code can emit errors
 * Add location information to errors
 * Allow API to query errors
2023-04-15 06:11:54 +02:00
Benjamin Otte
798c35f506 jsonparser: Make select_member() fast
Introduce a JsonStringIterator that allows iterating over a json encoded
string without memory allocation - use that code to do strcmp()-like
matching as well as strdup()-like copying.

Much fancy now.
2023-04-15 06:11:54 +02:00
Benjamin Otte
424e5eaf4e json: Add gtk_json_parser_select_member()
This is modeled after JsonReader.selectName() from the Java Moshi
package, see https://square.github.io/moshi/1.x/moshi/com/squareup/moshi/JsonReader.html#selectName-com.squareup.moshi.JsonReader.Options-

It returns the ID of the current member name in the passed i char array
or -1 if it is not found.

This allows writing code like:
  do {
    switch (gtk_json_parser_select_member (parser, { "foo", "bar", NULL })
    {
    case 0:
      /* handle the "foo" member */
      break;
    case 1:
      /* handle the "bar" member */
      break;
    default:
      /* do nothing or complain or whatever */
      break;
    }
  } while (gtk_json_parser_next (parser));

The impementation so far is the simplest one possible, but could be
significantly improved.
2023-04-15 06:11:54 +02:00
Benjamin Otte
9bc458fa8b jsonparser: Store the node in the character table
That turns the get_node() function into a simple character lookup.
2023-04-15 06:11:54 +02:00
Benjamin Otte
353a841ec7 tools: Add gtk-json-validate
It's a trivial port of json-glib-validate.
2023-04-15 06:11:54 +02:00
Benjamin Otte
0c3e5fdcfb jsonparser: Remove the reader object
Put the members directly into the JsonParser object.
2023-04-15 06:11:54 +02:00
Benjamin Otte
eb84b58ee9 jsonparser: Prevalidate numbers and strings
Validation and parsing are 2 separate steps anyway.
2023-04-15 06:11:54 +02:00
Benjamin Otte
37ccc972bf jsonparser: Split parsing strings from unescaping them 2023-04-15 06:11:54 +02:00
Benjamin Otte
0265714708 jsonparser: Build a character table and use it
Instead of using strchr() and friends, build a table with character
flags, so that we can implement various functions with it.
2023-04-15 06:11:54 +02:00
Benjamin Otte
04348ebf87 jsonparser: Remove line number tracking
We can parse the document manually if we're interested.
2023-04-15 06:11:54 +02:00
Benjamin Otte
489d9398df tools: Add gtk-json-format
The tool is modeled after json-glib-format and supports all the same
arguments.
2023-04-15 06:11:54 +02:00
Benjamin Otte
901a9edeb8 Add GtkJsonPrinter 2023-04-15 06:11:54 +02:00
Benjamin Otte
7ce2d70e0e Add GtkJsonParser 2023-04-15 06:11:54 +02:00
Benjamin Otte
8d0e09c086 testutils: Rewrite to use GSubprocess
That way, we also properly catch all errors and don't let tests pass
when diff(1) fails.

Oops.
2023-04-15 06:11:54 +02:00
Benjamin Otte
60f3cc398a Merge branch 'wip/otte/for-main' into 'main'
inspector: Don't randomly emit application signals

See merge request GNOME/gtk!5834
2023-04-15 03:40:00 +00:00
Benjamin Otte
e010cd242c listlistmodel: Add a cache
Cache the last looked up item and use it for looking up the next item if
it's closest. This massively speeds up iteration over the model, because
each call to get_item() will be adjacent to the previous one.

Improves performance of the inspector quite a bit.
2023-04-15 05:27:47 +02:00
Benjamin Otte
41454b63b4 testsuite: Add some more exhaustive testing to listlistmodel 2023-04-15 05:27:47 +02:00
Benjamin Otte
f458951745 inspector: Don't randomly emit application signals
When the variant-editor emits a callback, it might not actually have
edited the value in question. Try to detect that by only emitting
signals if the value changed.
2023-04-15 05:27:47 +02:00
Benjamin Otte
ef3793ec37 Merge branch 'gbsneto/vulkan-buffer-release' into 'main'
gsk/vulkan/render: Download image before reset

See merge request GNOME/gtk!5832
2023-04-14 23:28:55 +00:00
Georges Basile Stavracas Neto
94b1a78378 gsk/vulkan/render: Download image before reset
gsk_vulkan_render_download_target() currently resets the uploader
objects before downloading the image that it produces. This is
problematic because there might be unreleased buffers and images
in the command queue.

In particular, this can make validation layers complain about the
glyph atlas - of all things! - upload buffer being released while
still being used by the command queue.

Fix that by resetting the uploader after downloading the image.
2023-04-14 16:43:04 -03:00
Matthias Clasen
64a1969293 Merge branch 'fix_scalebutton_orientation' into 'main'
ScaleButton: fix CSS name in documentation, fix orientation doing nothing

See merge request GNOME/gtk!5819
2023-04-13 20:44:23 +00:00
Matthias Clasen
2baab9732c Merge branch 'check-openuri-portal-version' into 'main'
openuriportal: Detect if the interface isn't there

Closes #5733

See merge request GNOME/gtk!5826
2023-04-13 20:44:03 +00:00
Georges Basile Stavracas Neto
8134daf843 Merge branch 'gbsneto/vulkan-mailbox' into 'main'
gdk/vulkancontext: Use more appropriate present mode

See merge request GNOME/gtk!5828
2023-04-13 17:07:59 +00:00
Georges Basile Stavracas Neto
9c013d40c1 gdk/vulkancontext: Use more appropriate present mode
Check if the driver supports MAILBOX and prefer using it; in its
absense, checkif the driver supports IMMEDIATE and prefer using
it; finally, if neither of them are supported, use the guaranteed
to be supported FIFO mode.
2023-04-13 13:54:45 -03:00
Benjamin Otte
d798372a53 Merge branch 'wip/otte/for-main' into 'main'
x11: Remove commented outdated code

See merge request GNOME/gtk!5827
2023-04-13 15:34:48 +00:00
Benjamin Otte
cfaf1b3e71 x11: Remove commented outdated code
... and it's copy/paste into the win32 backend
2023-04-13 17:15:35 +02:00
Benjamin Otte
9763d83a9d gdk: Remove unused vfunc 2023-04-13 17:15:35 +02:00
Benjamin Otte
5f82a496cb Merge branch 'wip/otte/wl-gloria-gaynor' into 'main'
wayland: Make wl_surface survive until surface is desstroyed

See merge request GNOME/gtk!5825
2023-04-13 15:12:07 +00:00
Matthias Clasen
0c35015c44 Merge branch 'wip/exalm/print-dialog' into 'main'
printunixdialog: Remove a redundant style class

See merge request GNOME/gtk!5823
2023-04-13 05:39:08 +00:00
Matthias Clasen
3da0572078 openuriportal: Detect if the interface isn't there
Check the portal version number before trying to use
it. Most importantly, this will detect the case where
the interface isn't supported at all, since the proxy
will report a version of 0 in that case.

Fixes: #5733
2023-04-13 07:24:38 +02:00
Matthias Clasen
c649d8a4ec Merge branch 'bilelmoussaoui/g-i' into 'main'
g-i: Fix GtkGLArea type name

See merge request GNOME/gtk!5824
2023-04-13 04:37:45 +00:00
Benjamin Otte
75bea01a86 wayland: Keep EGL window around when hidden
See previous commit:

We want to keep resources around as long as the surface exists.
2023-04-13 05:19:18 +02:00
Benjamin Otte
5d3cec5441 wayland: Don't destroy the wl_surface on hide()
We want to keep the wl_surface around, because surfaces create their
resources on construct and keep them until destroyed. See the HWND ond
Windows and the XWindow on X11.

This is relevant for graphics resources, where we want to have access
to the VkSurface and eglSurface while the GdkSurface is hidden.
We also want these surfaces to be permanent and not change during the
lifetime of the GdkSurface.

What we can - and must - destroy however are the xdg surfaces, because
those handle visibility on screen.
And we also need to ensure no buffer is attached, so that during the
next creation of the xdg surface we don't get a protocol error.
2023-04-13 04:23:35 +02:00
Benjamin Otte
891242920e wayland: Split out a function
We have a create_wl_surface(), create a matching destroy_wl_surface().
2023-04-13 02:56:12 +02:00
Benjamin Otte
b375f17f09 wayland: Remove useless function
gdk_wayland_surface_maybe_resize() just calls
gdk_wayland_surface_update_size(), so make all callers call that one
instead.

The check that it does is done by the other function again.
2023-04-13 02:48:47 +02:00
Benjamin Otte
ec69990126 wayland: Remove an old workaround
This workaround - were it ever to trigger - is broken today. It destroys
the wl_surface and all associated structs but does not recreate the
xdg_popup or xdg_toplevel struct, so it would cause a hidden window.

The workaround looked a lot different when it was introduced in commit
83b54bab57, too - both in what it did and
in what the vfuncs did that it called.
2023-04-13 02:44:05 +02:00
Bilal Elmoussaoui
aec5a5739e g-i: Fix GtkGLArea type name 2023-04-12 18:12:40 +00:00
Alexander Mikhaylenko
ac9e0039b8 printunixdialog: Remove a redundant style class
.view does absolutely nothing in Default style since the whole box is
covered with a GtkNotebook which has its own background, and adds an
unwanted background onto the tab strip in Adwaita.
2023-04-12 21:09:25 +04:00
Matthias Clasen
4574b21fd6 Merge branch 'dialogs-force-window-destruction' into 'main'
gtk/dialogs: Destroy the window promptly on finish async function

Closes #5741

See merge request GNOME/gtk!5820
2023-04-12 13:54:13 +00:00
Marco Trevisan (Treviño)
31c5961c4f gtk/dialogs: Destroy the window promptly on finish async function
Some bindings (GJS!) could add temporary references to the GAsyncResult
argument that we return, and thus to the GTask, which may cause the
dialog not to close when the finish function is called (but at garbage
collection instead!).

To prevent this, just manually destroy the window (by removing the task
data), so that we are not bound to the GTask lifetime anymore.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5741
2023-04-12 15:39:39 +02:00
Matthias Clasen
8fc3f06155 Merge branch 'filechooserentry-fixes' into 'main'
filechooserentry: Make filtering work again

Closes #5743

See merge request GNOME/gtk!5822
2023-04-12 10:38:04 +00:00
Matthias Clasen
5327203201 Merge branch 'wip/carlosg/multi-click-text-view' into 'main'
textview: Reset press counter if double/triple clicking on a different line

See merge request GNOME/gtk!5821
2023-04-12 10:11:16 +00:00
Matthias Clasen
8442fce962 Merge branch 'touch-no-double-click-threshold' into 'main'
gestureclick: Don't use threshold for touch

Closes #5580

See merge request GNOME/gtk!5798
2023-04-12 10:10:31 +00:00
Matthias Clasen
d8b46c16cc Merge branch 'stylus-fixes' into 'main'
gtk-demo: Test stylus-only mode

See merge request GNOME/gtk!5804
2023-04-12 10:10:11 +00:00
Matthias Clasen
4df7273266 filechooserentry: Plug a memory leak 2023-04-12 12:09:02 +02:00