Compare commits

...

1553 Commits

Author SHA1 Message Date
Matthias Clasen
ec271b47fb wip 2024-08-07 19:18:35 -04:00
Matthias Clasen
80bee35ab7 download op: wip 2024-08-07 18:13:34 -04:00
Matthias Clasen
4be4e53bdd memory convert: debug spew 2024-08-07 18:13:34 -04:00
Matthias Clasen
d10c55c748 node processor: spew 2024-08-07 18:13:34 -04:00
Matthias Clasen
60d9d79bcc renderer: debug spew 2024-08-07 18:13:33 -04:00
Matthias Clasen
d0fbe1db5a download op: debug spew 2024-08-07 18:13:33 -04:00
Matthias Clasen
44aca0cecf Add a test for render_texture 2024-08-07 18:13:33 -04:00
Matthias Clasen
f8afc60c9b Some more color tests 2024-08-07 18:11:35 -04:00
Matthias Clasen
2f26bd9842 colorstate: Change the rendering color state api
Pass an extra boolean that tells whether the target image is GL_SRGB,
in which case, the rendering color state must be srgb-linear.

Update all callers to pass FALSE, except for the one call in
the node processor, where we want to take GL_LINEAR into account.
2024-08-07 18:11:35 -04:00
Matthias Clasen
449fc749e6 Add a compare test for handling of pq colors
The node file here has a pq color that is far out of range for
sRGB, and will produce widely different result if we don't clamp
things properly.
2024-08-07 13:34:45 -04:00
Matthias Clasen
56ea1754bf gsk: Pass color state to download op
This lets us create a texture in the desired color state.
2024-08-07 13:34:45 -04:00
Matthias Clasen
cd18bb9fd1 renderer: Make hdr textures if necessary
Take the preferred color state of the content into account
when deciding what color state to use for the texture we
generate.
2024-08-07 13:34:45 -04:00
Matthias Clasen
9f3927e7a7 gsk: Adapt to new rendering colorstate api
Since we now handle the GL_SRGB case when the  node processor calls
get_rendering_color_state, we can just pass SRGB as input here.
2024-08-07 13:34:45 -04:00
Matthias Clasen
df18749d6d colorstate: Change the rendering color state api
Pass an extra boolean that tells whether the target image is GL_SRGB,
in which case, the rendering color state must be srgb-linear.

Update all callers to pass FALSE, except for the one call in
the node processor, where we want to take GL_LINEAR into account.
2024-08-07 13:34:45 -04:00
Matthias Clasen
50c19a6534 Merge branch 'hdr-content' into 'main'
gsk: Track whether nodes require wide gamut

See merge request GNOME/gtk!7575
2024-08-07 17:34:02 +00:00
Matthias Clasen
6edb526561 Merge branch 'plug-gtask-leaks' into 'main'
Plug GTask leaks

See merge request GNOME/gtk!7551
2024-08-07 16:26:52 +00:00
Matthias Clasen
ee18156675 gsk: Add gsk_render_node_is_hdr
Add a function that tracks whether a render node's content is
in a wide gamut color state (in practice, that means non-sRGB).

This will be used in render_texture to determine the color
state to use when creating a texture.
2024-08-07 11:14:21 -04:00
Matthias Clasen
e70a961ac1 Merge branch 'matthiasc/for-main' into 'main'
memoryformat: Add a debug helper

See merge request GNOME/gtk!7571
2024-08-07 14:51:05 +00:00
Matthias Clasen
ffdc8c8f60 gsk: Drop some unused code
Nobody is using gsk_gpu_download_png_op, and we are going to
refactor the download op code.
2024-08-07 08:39:53 -04:00
Matthias Clasen
fd78bd3eaf memoryformat: Add a debug helper
I need this often enough that I'll just put it here.
2024-08-07 08:22:05 -04:00
Matthias Clasen
f2ccba0988 Merge branch 'wip/test-parser-data-additions' into 'main'
testsuite: add more files to test_data

See merge request GNOME/gtk!7569
2024-08-07 03:30:20 +00:00
Jeremy Bícha
8ee465c630 testsuite: add more files to test_data 2024-08-06 20:28:58 -04:00
Matthias Clasen
31b655c9eb Merge branch 'wip/dont-leak-egl-surface' into 'main'
gdk/surface: Don't leak the EGLSurface

See merge request GNOME/gtk!7568
2024-08-06 22:54:31 +00:00
Jonas Ådahl
7fd65cc3c1 gdk/surface: Don't leak the EGLSurface
Each time we create a new window, we create a new EGLSurface. Each time
we destroy a window, we failed to destroy the EGLSurface, due to passing
a GdkDisplay instead of a EGLDisplay to eglDestroySurface().

This effectively leaked not only the EGL surface metadata, but also the
associated DMA buffers. For applications where one opens and closes many
windows over the lifetime of the application, and where the application
runs for a long time; for example a terminal emulator server, this
causes a significant memory leak, as the memory will only ever be freed
once once the application process itself exits, if ever.

Fix this passing an actual EGLDisplay instead of an GdkDisplay, to
eglDestroySurface().
2024-08-06 23:42:11 +02:00
Jonas Ådahl
8089222fc3 gsk/gpu/downloadop: Include glib-unix.h
It's needed by g_close().
2024-08-06 23:41:46 +02:00
Benjamin Otte
0667bd39fb Merge branch 'wip/otte/for-main' into 'main'
gpu: Consult target colorstate for depth

See merge request GNOME/gtk!7567
2024-08-06 21:07:44 +00:00
Benjamin Otte
a4854dfa9e memoryformat: Use "(p)" as premultiplied indicator in names
This matches what the gpu renderer does when printing
colorstates.

It also avoids it printing "S*RGBA8" for the format and instead prints
"SRGBA8(p)" now.
2024-08-06 22:15:17 +02:00
Benjamin Otte
6c54d0a7e2 gpu: Consult target colorstate for depth
When creating images for use with different colorstates, ensure that
they have the depth of that colorstate. Otherwise we might lose accuracy
due to quantization.

Fixes mipmaps in rec2100 being rendered as RGBA8.
2024-08-06 22:15:17 +02:00
Matthias Clasen
341860eb4d Merge branch 'small-fixes' into 'main'
colorstate: Drop xyz for now

See merge request GNOME/gtk!7565
2024-08-06 20:06:38 +00:00
Matthias Clasen
876445f080 inspector: Show color states of textures 2024-08-06 15:38:31 -04:00
Matthias Clasen
03ef6a7719 colorstate: Drop xyz for now
Converting to and from xyz turns out to be more difficult than
expected, depending on what whitepoint you choose, And different
specs choose different whitepoints, so we can't directly map
css xyz to cicp xyz anyway.
2024-08-06 15:38:31 -04:00
Benjamin Otte
fde8c6df79 Merge branch 'wip/otte/for-main' into 'main'
rendrenodeparser: Use simpler function

See merge request GNOME/gtk!7564
2024-08-06 16:18:13 +00:00
Benjamin Otte
6c06e1855e roaring: Fix a compiler warning
This is a simple fix, I did not investigate if NULL is actually possible
here.

In function ‘bitset_container_empty’,
    inlined from ‘bitset_container_const_nonzero_cardinality’ at ../gtk/roaring/roaring.h:1942:13,
    inlined from ‘container_nonzero_cardinality’ at ../gtk/roaring/roaring.h:4055:20,
    inlined from ‘roaring_bitmap_lazy_xor’ at ../gtk/roaring/roaring.c:9727:17:
../gtk/roaring/roaring.h:1928:13: error: potential null pointer dereference [-Werror=null-dereference]
 1928 |   if (bitset->cardinality == BITSET_UNKNOWN_CARDINALITY) {
      |       ~~~~~~^~~~~~~~~~~~~
2024-08-06 17:53:41 +02:00
Benjamin Otte
c60ae0b575 textview: Fix compiler warning
../gtk/gtktextview.c: In function ‘gtk_text_view_add_default_attributes’:
../gtk/gtktextview.c:10681:8: error: potential null pointer dereference [-Werror=null-dereference]
2024-08-06 17:50:57 +02:00
Benjamin Otte
e58f9ea1b4 rendrenodeparser: Use simpler function
We don't need to peek tokens.
2024-08-06 17:50:43 +02:00
Matthias Clasen
3d55d733dc Merge branch 'fix-premul-for-colorize' into 'main'
Colors are always unpremultiplied

See merge request GNOME/gtk!7563
2024-08-06 11:33:38 +00:00
Matthias Clasen
582dba54b1 Try to fix win32 build of compare-render 2024-08-06 07:10:04 -04:00
Matthias Clasen
0775432ed9 Add a compare test for premultiplied colors
This test checks a that a specific combination of mask with alpha
inside opacity works as expected. We were treating the mask color
as premultiplied here, although it isn't.
2024-08-06 00:59:23 -04:00
Matthias Clasen
d9e15ff6e9 Colors are always unpremultiplied
We can't use gsk_gpu_node_processor_color_states_self() for ops which
apply alt to colors that don't come from textures, since those are
always unpremultiplied.

This fixes the + and - in disabled spin buttons appearing completely
white.
2024-08-06 00:59:23 -04:00
Matthias Clasen
c04edfc76e Merge branch 'matthiasc/for-main' into 'main'
rewrite color parsing in the node parser

See merge request GNOME/gtk!7560
2024-08-06 04:54:04 +00:00
Matthias Clasen
71d6392572 nodeparser: Rewrite the color parsing
Use gtk_css_parser_consume_function, for better error handling.
We are now getting the expected error for

  color(srgb 1 2 3 4 5 6)

Test included.
2024-08-06 00:23:07 -04:00
Matthias Clasen
dbd16cd9da Rename GDK_COLOR_INIT_SRGB
Rename the macro to GDK_COLOR_SRGB, and make it usable as
a compound literal as well.

Update all users.
2024-08-06 00:06:41 -04:00
Matthias Clasen
950d266894 Merge branch 'wip/chergert/fix-6133-commit-funcs' into 'main'
textbuffer: Add GtkTextBufferCommitNotify

Closes #6133

See merge request GNOME/gtk!7524
2024-08-06 01:41:23 +00:00
Matthias Clasen
884974eeaa Merge branch 'matthiasc/for-main' into 'main'
gsk: Improve handling of fill and stroke nodes

See merge request GNOME/gtk!7559
2024-08-05 21:01:54 +00:00
Christian Hergert
e836166664 textbuffer: Add GtkTextBufferCommitNotify
Add a new function callback called GtkTetBufferCommitNotify to be notified
of changes to a GtkTextBuffer without being involved in a signal chain.

This is necessary for some situations because signal handlers may modify
the parameters as they proceed down to default handler. As such, the signal
is unsuitable for applications heavily utilizing plug-ins such as Builder
due to non-deterministic signal connection ordering.

This technique has been used in Builder for the better part of a decade
and now would also vastly help in situations like libspelling where you
also want to know about changes to the buffer right before they are
committed to the b-tree.

Fixes: #6133
2024-08-05 13:28:59 -07:00
Matthias Clasen
c1a99bf901 tests: Link compare-render statically
This is a temporary change, only needed until we make the new
snapshot and rendernode apis public.
2024-08-05 16:09:42 -04:00
Matthias Clasen
f9c9a03404 gsk: Improve handling of fill and stroke nodes
Use GdkColor here. We still convert to sRGB as the last step, though.
2024-08-05 15:59:28 -04:00
Matthias Clasen
3a337824e6 Merge branch 'css-color-hookup-1' into 'main'
Add GdkColor, make non-srgb css colors work for color nodes

See merge request GNOME/gtk!7546
2024-08-05 16:11:39 +00:00
Matthias Clasen
7dab23e38a gl: Handle color nodes with color states
Since we don't have proper color management here, just convert
any color we meet to sRGB and hope for the best.
2024-08-05 11:11:15 -04:00
Matthias Clasen
78935ec83c Make node-format.md part of the docs
This makes useful information more easily available, and it also
serves to validate the markdown.
2024-08-05 11:11:15 -04:00
Matthias Clasen
b8989b7ff6 Add a compare test for color states
This checks that the red values in all 4 default color states
come out identical to a plain old red png.
2024-08-05 11:11:15 -04:00
Matthias Clasen
96cd47d0a0 inspector: Show more color node details
Show the color state, and create textures with the full color
information.
2024-08-05 11:11:15 -04:00
Matthias Clasen
d6a6cfe6c5 gtk: Fix gtk_snapshot_collect_repeat
This creates a new color node that is meant to be identical to
an existing one, so we need to use gsk_color_node_new2 to preserve
the color state information.

Test included.
2024-08-05 11:11:15 -04:00
Matthias Clasen
501356116d gtk: Preserve css background color spaces
When rendering css backgrounds, use the new gtk_css_color_get_color
and gtk_snapshot_append_color2 apis to preserve color spaces as
far as possible.
2024-08-05 11:11:15 -04:00
Matthias Clasen
e11e5525db gtk: Add gtk_snapshot_append_color2
This is a private snapshot function that uses the new color
node constructor to create a color node with a given color state.
2024-08-05 11:11:15 -04:00
Matthias Clasen
16431da3f2 nodeparser: Add support for cicp color states
Allow defining cicp color states with an @-rule:

    @cicp "jpeg" {
      primaries: 1;
      transfer: 13;
      matrix: 6;
      range: full;
    }

And allow using them in color() like this:

    color("jpeg" 50% 0.5 1 / 75%)

Note that custom color states use a string, unlike default color
states which use an ident.

Test included.
2024-08-05 11:11:15 -04:00
Matthias Clasen
842949fcf3 nodeparser: Support color states
And allow using color states for colors with a syntax similar
to modern css color syntax.

color(srgb 50% 0.5 1 / 75%)

Both floating point numbers and percentages can be used.

Currently, this is only supported for color nodes.

Test included.
2024-08-05 11:11:15 -04:00
Matthias Clasen
3d3e935c91 offload: Use gsk_color_node_get_color2
We want the blackest black.
2024-08-05 11:11:15 -04:00
Matthias Clasen
d5ae94ca5d testsuite: Update replay nodes
We can't currently recreate color nodes with public api, so cheat
and reuse the node we got.
2024-08-05 11:11:15 -04:00
Matthias Clasen
87e9c940a4 gsk: Use the private color node api
Use the color state returned by this function instead of assuming
the color of a color node is always sRGB.

Node colors are converted to the css on the cpu. That is necessary
since we don't know if they are in one of the default color states,
and our shaders can't deal with non-default color states.
2024-08-05 11:11:14 -04:00
Matthias Clasen
6a02fa4be8 gsk: Add private color node api
Add a constructor that takes a color state, a getter for it, and
also a getter for the color coordinates that avoids GdkRGBA.
2024-08-05 11:11:14 -04:00
Matthias Clasen
9f548efd32 gsk: Change color op apis
Make color-related ops take the ccs and a GdkColor, and make
decisions about color conversion on the cpu vs the gpu.

This makes the node processor code simpler, and lets use convert
the color directly into the op instance without extra copying.

We also pass opacity to the op, so it can be applied when we
write the color into the instance.

Lastly, rorder the offset to come right after the opacity argument.

Treat the color and rounded color ops the same way.

Update all callers.

With this, the prepare_color apis in gskgpunodeprocessor.c are
no longer used and have been dropped.
2024-08-05 11:11:14 -04:00
Matthias Clasen
9eebe8e547 gsk: Change the clear op api
A clear op is just a fancy memcpy. Make it the callers responsibility
to convert the color to the right color state before passing it
to the clear op.
2024-08-05 11:11:14 -04:00
Matthias Clasen
f9612533c2 css: Add gtk_css_color_to_color
This api lets one obtain a color state and color values from
a GtkCssColor. We don't want to force everything though sRGB,
but we can't quite avoid conversion here, since we don't have
a 100% match between the css color spaces and color states.

css color cleanup
2024-08-05 11:11:14 -04:00
Matthias Clasen
c9c0d444a2 cairo: Add gdk_cairo_set_source_color
This lets us set a GdkColor as a cairo source.
2024-08-05 11:11:14 -04:00
Matthias Clasen
13a8704f51 Add GdkColor
For now, this is all private api.

Parts of it will be opened up in 4.18.
2024-08-05 11:11:14 -04:00
Arjan Molenaar
f20714262c Merge branch 'macos-fix-window-transparency' into 'main'
macos: fix window transparency

Closes #6838

See merge request GNOME/gtk!7544
2024-08-05 12:20:32 +00:00
Matthias Clasen
11ffeeb55c Merge branch 'wip/otte/for-alice' into 'main'
Fix warning on startup

See merge request GNOME/gtk!7547
2024-08-05 12:18:00 +00:00
Sergey Bugaev
85830c059e Plug GTask leaks
The error-prone pattern seems to be:

  GTask *task = g_task_new (...);

  if (condition)
    {
      g_task_return_... (task, ...);
      /* need g_object_unref (task) here! */
      return;
    }

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-08-05 14:38:23 +03:00
Matthias Clasen
ffc89e40a0 colorstate: Add a color conversion function
Add a function for converting a single color from one
color state to another. This is a generalization of the
already existing function to convert a GdkRGBA to another
color state.
2024-08-04 14:21:15 -04:00
Matthias Clasen
1c92f2d963 Merge branch 'matthiasc/for-main' into 'main'
Disable blur-performance build

See merge request GNOME/gtk!7549
2024-08-04 02:52:53 +00:00
Matthias Clasen
12e0ec0b48 Add gtk_css_parser_has_percentage 2024-08-03 22:31:32 -04:00
Matthias Clasen
5574bf59f6 Disable blur-performance build
This is an old test that isn't very relevant anymore, and it has
some linking problems because it includes private headers that
have inlined functions.
2024-08-03 22:31:21 -04:00
Matthias Clasen
7ee27cc0ad Merge branch 'matthiasc/for-main' into 'main'
gpu: Rename function

See merge request GNOME/gtk!7548
2024-08-04 01:23:41 +00:00
Benjamin Otte
040974c8a2 iconhelper: Size no longer depends on scale
This is a leftover from GTK3 when iconhelper sizes depended on the
texture size.

Now we only need to queue a redraw with the new icon.

Fixes warnings about resizes during allocate caused by scale change
notification during allocation of GtkWindow.
2024-08-04 03:11:56 +02:00
Benjamin Otte
126d689086 gpu: Rename function
We want to reuse gsk_gpu_color_to_float() for use with GdkColor and this
function will be replaced. But until that's fully done, we need 2
different names.

So rename this one to something else
2024-08-03 20:59:40 -04:00
Benjamin Otte
8e676c7360 windowcontrols: No need to listen to scale factor changes
This is a GTK3 leftover where the icons were manually drawn and sized.
Now that they're managed by actual widgets that enforce a correct size
that is independent of scale factor, this is no longer necessary.

Fixes warnings about resizes during allocate caused by scale change
notification during allocation of GtkWindow.
2024-08-04 01:23:07 +02:00
Arjan Molenaar
84847e46fa macos: fix window transparency
Revert window decoration changes from
a6ce506714.
2024-08-02 17:30:48 +02:00
Matthias Clasen
3fca84f974 Merge branch 'matthiasc/for-main' into 'main'
Fix a copy-paste error

See merge request GNOME/gtk!7543
2024-08-02 13:45:40 +00:00
Matthias Clasen
2be48a8f86 Pass ccs to the cairo blur code
This is needed to set the color properly.
2024-08-02 09:13:41 -04:00
Matthias Clasen
389d246af8 Fix up the blur-performance test
Add a hack to work aroundt he fact that the blur performance test
includes private headers which inline accesses to non-exported
variables.
2024-08-02 09:12:37 -04:00
Matthias Clasen
9e0f41bd05 Fix a copy-paste error
We were using the wrong api to get the color of an outset shadow
node. This just worked by luck.
2024-08-02 09:00:51 -04:00
Matthias Clasen
564a237454 Merge branch 'matthiasc/for-main' into 'main'
Cosmetics: Remove a leftover line

See merge request GNOME/gtk!7540
2024-08-01 22:24:55 +00:00
Matthias Clasen
86b59ba643 Cosmetics: Remove a leftover line
This looks just like a copy-paste leftover. Suprisingly, it compiled
just fine and worked too.
2024-08-01 17:19:50 -04:00
Matthias Clasen
487e568722 Merge branch 'matthiasc/for-main' into 'main'
vulkan: Don't try srgb for the atlas

Closes #6887

See merge request GNOME/gtk!7539
2024-08-01 19:40:00 +00:00
Matthias Clasen
67080dab21 vulkan: Don't try srgb for the atlas
This makes the Emoji rendering come out wrong.

Fixes: #6887
2024-08-01 14:43:49 -04:00
Benjamin Otte
0809e6585d Merge branch 'wip/otte/for-main' into 'main'
vulkan: Add error checking in a place

See merge request GNOME/gtk!7538
2024-08-01 11:14:12 +00:00
Benjamin Otte
809b98c96e vulkan: Don't leak fds
It makes sense to close the fds before doing an early return.
D'oh.
2024-08-01 12:51:46 +02:00
Benjamin Otte
059af1365a vulkan: Add error checking in a place
Doesn't hurt to have, but I just added it while debugging something
unrelated.
2024-08-01 12:51:46 +02:00
Matthias Clasen
fbcffb36c8 Merge branch 'matthiasc/for-main' into 'main'
Drop debug code

See merge request GNOME/gtk!7536
2024-08-01 01:31:16 +00:00
Matthias Clasen
3af0cfb53b Drop debug code
The dmabuf download code for P010 had a hack left in it that
was preventing it from working.
2024-07-31 21:08:14 -04:00
Matthias Clasen
96422fcf52 Merge branch 'no-cursor-viewport' into 'main'
wayland: No viewporter for cursors

See merge request GNOME/gtk!7531
2024-07-31 20:23:34 +00:00
Matthias Clasen
2754f2be2d Merge branch 'test-cal-31' into 'main'
ci: avoid another date-dependent failure

See merge request GNOME/gtk!7535
2024-07-31 20:12:16 +00:00
Matthias Clasen
3d802177be wayland: No viewporter for cursors
The outlook for mutter supporting this in GNOME 47 are cloudy,
so lets flip the switch back. You can still set
USE_POINTER_VIEWPORT in the environment to try this code.
2024-07-31 07:44:48 -04:00
Matthias Clasen
a02d4ba2a1 Merge branch 'matthiasc/for-main' into 'main'
dmabuf: Fix the disjointness check

See merge request GNOME/gtk!7529
2024-07-31 05:04:02 +00:00
Matthias Clasen
249cf0833c dmabuf: Fix the disjointness check
We were checking the wrong fds here.

This came up while toying with udmabuf and creating multi-plane
NV12 buffers.
2024-07-30 23:44:07 -04:00
Jeremy Bícha
20b00d3947 ci: avoid another date-dependent failure
Set the day before setting the month to avoid
failure when running the test on the 31st day of a month
2024-07-30 15:50:12 -04:00
Matthias Clasen
269dcaaadf Post-release version bump 2024-07-30 15:14:25 -04:00
Matthias Clasen
322bbd2376 4.15.4 2024-07-30 12:50:22 -04:00
Benjamin Otte
52bec248ce Merge branch 'wip/otte/for-main' into 'main'
gpu: Fix shadows even more

See merge request GNOME/gtk!7527
2024-07-30 16:29:59 +00:00
Benjamin Otte
9f71528a05 gpu: Fix shadows even more
Math is hard.

But this time, it comes with a test!
2024-07-30 18:01:45 +02:00
Benjamin Otte
65e02a3bae Merge branch 'wip/otte/for-main' into 'main'
gpu: Fix shadows some more

Closes #6896

See merge request GNOME/gtk!7526
2024-07-30 14:48:34 +00:00
Benjamin Otte
defc4d335e gpu: Fix shadows some more
It turns out the "step" variable could up as 0 when p.y ~= 3.0 ||
p.y ~= r.y - 3.0
That was not enough to trigger it though because if "start" and "end"
were the same value, the "y <= end" check in the loop would immediately
terminate it.

However, if start + epsilon == end so that end != start but (end - start)
/ 7 == 0, then step would end up as 0 and the loop would never
terminate.

And if that happened, it would bring down GPUs.
So recode this whole machinery to make it impossible to infloop.

Fixes #6896
2024-07-30 16:09:38 +02:00
Benjamin Otte
bdcfcfa5b9 Merge branch 'wip/otte/for-main' into 'main'
gpu: Draw proper shadows again

Closes #6888

See merge request GNOME/gtk!7518
2024-07-30 00:19:37 +00:00
Benjamin Otte
4a94c91772 gpu: Don't blur tiny blur radii
We get those wrong, and there's not really a visual effect.

And since we do a check anyway, just disallow them and treat them as
unblurred.
2024-07-30 01:50:56 +02:00
Benjamin Otte
cc3ed89e34 gpu: Draw proper shadows again
The fix in commit 5e7f227d broke shadows while trying to make them
faster.
So use a better way to make them faster.

With the normalized blur radius, we can now conclude that all the values
too far from p.y will cause the gauss() call to return close to 0, so we
can skip any y value that is too far from p.y.

And that allows us to put an upper limit on the loop iterations.

Tests included

Fixes #6888
2024-07-30 01:50:56 +02:00
Benjamin Otte
87e8265a2d Merge branch 'wip/otte/colomplications' into 'main'
wayland: Do not use compositor-provided image descriptions

See merge request GNOME/gtk!7522
2024-07-29 17:56:41 +00:00
Matthias Clasen
9fd6d431e3 Merge branch 'fix-ephy-crash' into 'main'
subsurface: Avoid a crash

Closes #6891

See merge request GNOME/gtk!7521
2024-07-29 17:39:05 +00:00
Benjamin Otte
5059ae1d7b gpu: Simplify box-shadow shader
Instead of doing complicated math, normalize the values to a sigma
of 1.0, and then use that.
This should also be beneficial for shader performance, because 1.0 is a
constant and constant-elimination can kick in on the inlined functions.
2024-07-29 19:14:10 +02:00
Benjamin Otte
50bb42f0f3 gl: Don't crash on box shadows with negative scales
Some places didn't fabs() the scale values properly, leading to
assertions when offscreens with negative sizes were created.
2024-07-29 19:14:10 +02:00
Benjamin Otte
d71a7c901d wayland: Do not use compositor-provided image descriptions
When the compositor sends us an image description, we currently happily
reuse it.

However, those image descriptions may contain optional properties that
we do not handle - example: reference white level. So if we were to
reuse that image description, we would set a wrong reference white
level.

To avoid issues like that, never use compositor-provided image
descriptions.

However, query those image descriptions and map them to the closest
GdkColorState, so that we can quickly look up *our* version of that
image description and use that one.
2024-07-29 18:45:41 +02:00
Matthias Clasen
65f727731c subsurface: Avoid a crash
When finalizing a subsurface, we need to make sure it is removed
from the sibling lists in its parent, or bad things will happen.

This should crashes seen in Epiphany nightly.

Fixes: #6891
2024-07-29 11:54:10 -04:00
Matthias Clasen
ff60b19e4b Merge branch 'matthiasc/for-main' into 'main'
image-tool: Add an --undecorated option

See merge request GNOME/gtk!7520
2024-07-29 15:52:42 +00:00
Matthias Clasen
b8f12c5d28 cicp: Improve the docs
Fix some formatting issues, and document GdkCicpRange.
2024-07-29 11:17:13 -04:00
Matthias Clasen
bfb779ac2f gsk: Add missing cicp transfer functions
This was overlooked in 50ea9450ea.
2024-07-29 10:35:32 -04:00
Matthias Clasen
84c28d2efb image-tool: Add an --undecorated option
This is useful if you want to debug things and don't want to end
up in the decoration rendering code paths.
2024-07-29 08:13:21 -04:00
Matthias Clasen
06372c5f2a Merge branch 'matthiasc/for-main' into 'main'
Fix indirect color state conversions

See merge request GNOME/gtk!7519
2024-07-29 11:11:28 +00:00
Matthias Clasen
3d75292c4d Fix indirect color state conversions
convert_func2 is a 'from' conversion function, ie it expects to
be passed the target color state. This was wrong both in
gdk_memory_convert and gdk_memory_convert_color_state.
2024-07-28 23:40:59 -04:00
Matthias Clasen
541ffbe4b5 Merge branch 'matthiasc/for-main' into 'main'
gst: Fix a wrong unref function

See merge request GNOME/gtk!7517
2024-07-28 23:35:16 +00:00
Matthias Clasen
17524f2794 gst: Fix a wrong unref function
Use gdk_color_state_unref on a color state.
2024-07-28 19:09:05 -04:00
Matthias Clasen
1040d7c7e4 Merge branch 'matthiasc/for-main' into 'main'
cicp: Fill in some more transfer functions

See merge request GNOME/gtk!7515
2024-07-28 20:51:40 +00:00
Matthias Clasen
1b53359cd3 Merge branch 'wip/smcv/ubsan' into 'main'
Avoid undefined behaviour in a few simple cases

See merge request GNOME/gtk!7508
2024-07-28 20:00:06 +00:00
Matthias Clasen
1987738d16 Merge branch 'wip/smcv/c11' into 'main'
README: Officially require C11, matching GLib 2.81.x

See merge request GNOME/gtk!7516
2024-07-28 19:58:51 +00:00
Benjamin Otte
b8890ca27d Merge branch 'wip/smcv/warnings' into 'main'
Fix compiler warnings on 32-bit

See merge request GNOME/gtk!7507
2024-07-28 18:40:46 +00:00
Benjamin Otte
2e7916cf4f Merge branch 'wip/smcv/align-gsk-ops' into 'main'
gskpathop: Align graphene_point_t to match gskpathop assumptions where required

Closes #6395

See merge request GNOME/gtk!7510
2024-07-28 17:54:35 +00:00
Simon McVittie
24cf5b6df8 README: Officially require C11, matching GLib 2.81.x
Previously GTK required a C99 compiler, but as discussed on
GNOME/gtk!7510 there's at least one anonymous union in public API
(in `GskPathPoint`), and that's a C11 feature.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-28 17:47:47 +01:00
Simon McVittie
214f5a6f98 gskpathop: Introduce a type to represent an aligned graphene_point_t
When we allocate a graphene_point_t on the stack, there's no guarantee
that it will be aligned at an 8-byte boundary, which is an assumption
made by gsk_pathop_encode() (which wants to use the lowest 3 bits to
encode the operation). In the places where it matters, force the
points on the stack and embedded in structs to be nicely aligned.

By using a distinct type for this (a union with a suitable size and
alignment), we ensure that the compiler will warn or error whenever we
can't prove that a particular point is, in fact, suitably aligned.
We can go from a `GskAlignedPoint *` to a `graphene_point_t *`
(which is always valid, because the `GskAlignedPoint` is aligned)
via &aligned_points[0].pt, but we cannot go back the other way
(which is not always valid, because the `graphene_point_t` is not
necessarily aligned nicely) without a cast.

In practice, it seems that a graphene_point_t on x86_64 *is* usually
placed at an 8-byte boundary, but this is not the case on 32-bit
architectures or on s390x.

In many cases we can avoid needing an explicit reference to the more
complicated type by making use of a transparent union. There's already
at least one transparent union in GSK's public API, so it's presumably
portable enough to match GTK's requirements.

Increasing the alignment of GskAlignedPoint also requires adjusting how
a GskStandardContour is allocated and initialized. This data structure
allocates extra memory to hold an array of GskAlignedPoint outside the
bounds of the struct itself, and that array now needs to be aligned
suitably. Previously the array started with at next byte after the
flexible array of gskpathop, but the alignment of a gskpathop is only
4 bytes on 32-bit architectures, so depending on the number of gskpathop
in the trailing flexible array, that pointer might be an unsuitable
location to allocate a GskAlignedPoint.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6395
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-28 17:31:41 +01:00
Matthias Clasen
50ea9450ea cicp: Fill in some more transfer functions
Handle gamma 2.2 and gamma 2.8.
2024-07-28 11:56:43 -04:00
Matthias Clasen
d2028c7323 Cosmetics 2024-07-28 11:33:39 -04:00
Benjamin Otte
76c1ea0449 Merge branch 'wip/smcv/gsize-is-guintptr' into 'main'
gdk: Codify the requirement that gsize is pointer-sized

See merge request GNOME/gtk!7514
2024-07-28 14:12:59 +00:00
Simon McVittie
a97f378d64 gdk: Codify the requirement that gsize is pointer-sized
This is widely assumed, but is not guaranteed by Standard C, and is
known to be false on CHERI architectures (which have 64-bit sizes and
128-bit tagged pointers). Add a static assertion to ensure that GTK
will not build on platforms where this assumption does not hold.

As discussed on GNOME/gtk!7510, if GTK switches from gsize to uintptr_t
as its representation of the underlying bits in a pointer, GTK maintainers
would prefer that to be done project-wide so that it's done consistently,
after which this static assertion could be removed.

At the time of writing, GLib makes the same assumption (GNOME/glib#2842),
but GLib contributors are gradually removing it (mostly by replacing gsize
with uintptr_t where a pointer-sized quantity is needed). Finishing
that work in GLib would be a prerequisite for being able to make GTK
work on the affected platforms.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-28 14:31:31 +01:00
Matthias Clasen
ffe82b7641 Merge branch 'wip/smcv/ubsan-half-float' into 'main'
gsk, testsuite: Avoid undefined behaviour converting float <-> fp16

See merge request GNOME/gtk!7509
2024-07-28 02:59:59 +00:00
Matthias Clasen
785709d51c Merge branch 'matthiasc/for-main' into 'main'
Cosmetics

See merge request GNOME/gtk!7512
2024-07-28 02:55:57 +00:00
Matthias Clasen
8406c34166 Cosmetics 2024-07-27 22:11:39 -04:00
Matthias Clasen
2ee1f3e8cf Merge branch 'matthiasc/for-main' into 'main'
image-tool: Allow specifying cicp tuples

See merge request GNOME/gtk!7511
2024-07-27 23:45:21 +00:00
Matthias Clasen
1373a7a6f0 Change the matrix implementation
Go from float[3][3] to float[9]. That is easier to manage in
static initialization.
2024-07-27 19:20:14 -04:00
Matthias Clasen
a5aac30843 jpeg: Load grayscale as-is
We can handle grayscale textures just fine nowadays, so no need to
convert them to RGB.
2024-07-27 19:20:14 -04:00
Matthias Clasen
3149493679 jpeg: Set downloader color state explictly
This avoids surprises.
2024-07-27 19:02:59 -04:00
Matthias Clasen
a60cda3daa image-tool: Allow specifying cicp tuples
Accept --cicp=1/13/6/0 and similar to specify color states.
2024-07-27 18:42:39 -04:00
Simon McVittie
660c6c8d6f gsk, testsuite: Avoid undefined behaviour in half_to_float_one()
Similar to the previous commit, to avoid undefined behaviour we need
to avoid evaluating out-of-bounds shifts, even if their result is going
to ignored by being multiplied by 0 later.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:22:09 +01:00
Simon McVittie
ad679187d3 gsk, testsuite: Avoid undefined behaviour in float_to_half_one()
If, for example, e == 0, it is undefined behaviour to compute an
expression involving an out-of-range shift by (125 - e), even if the
result is in fact irrelevant because it's going to be multiplied by 0.

This was already fixed for the memorytexture test in
commit 5d1b839 "testsuite: Fix another ubsan warning", so use the
implementation from that test everywhere. It's in the header as an
inline function to keep the linking of the relevant tests simple:
its only caller in production code is fp16.c, so there will be no
duplication outside the test suite.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:22:09 +01:00
Simon McVittie
b769295682 gtkcssnodedeclaration: Avoid signed left shift by 31 bits
Left-shifting a signed 32-bit integer by 31 bits (such that the value
overflows into the sign bit) is undefined behaviour. Use an unsigned
integer instead.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:16:21 +01:00
Simon McVittie
6649af5ec6 Avoid calling memcpy with n == 0
Some callers of these functions ask to copy 0 items from a NULL source,
which would be valid if they were copied in a loop (because NULL would
never be dereferenced), but is declared to be undefined behaviour for
Standard C memcpy. Guard the call to memcpy so that we only call it
if we have more than 0 items, and therefore should have a non-NULL
source pointer.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:16:21 +01:00
Simon McVittie
ca7094296c gtktimsort: Avoid undefined behaviour on 32-bit
Shifting a 32-bit type by 32 bits is formally undefined behaviour,
even if it happens in code that is unreachable at runtime. Use a
compile-time check against GLib's GLIB_SIZEOF_SIZE_T, instead of hoping
a runtime check will be optimized away.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:16:21 +01:00
Simon McVittie
15a09c79f9 Fix debug format strings for non-LP64 platforms
Unfortunately the format string for a size_t, `%zu`, is not portable
to all Windows compilers, and the appropriate format string for the
fundamental type that implements size_t varies between platforms
(typically `%u` on 32-bit platforms, `%lu` on 64-bit Linux or
`%llu` on 64-bit Windows).

In gtk-demo, cast the number of search results to long, to avoid
breaking up a translatable string.

Elsewhere, use GLib's abstraction for this.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 18:14:31 +01:00
Simon McVittie
e2a7dc5427 vulkan: Fix compiler warnings on 32-bit
Vulkan handles are pointers on 64-bit, but 64-bit integers on 32-bit.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 15:14:57 +01:00
Benjamin Otte
d301d16aee Merge branch 'wip/otte/for-main' into 'main'
wayland: Redo the image description code

See merge request GNOME/gtk!7505
2024-07-27 06:09:15 +00:00
Benjamin Otte
ec489e673c wayland: Add preferred formats to the hash tables
So we don't look them up all the time.
2024-07-27 07:26:51 +02:00
Benjamin Otte
a904da12b7 wayland: Don't query preferred colorstate if we don't care
If there's no change callback connected, exit early, because all this
lot of work would be for invoking that callback.
2024-07-27 07:26:51 +02:00
Benjamin Otte
91865d172b wayland: Track color information identities
So we don't need to query them all the time.

Or so I thought, because I get different ones for the same colorstate.
Thx Mutter.
2024-07-27 07:26:51 +02:00
Benjamin Otte
adedb89779 wayland: Actually sync the colorstate with the compositor 2024-07-27 07:26:51 +02:00
Benjamin Otte
514dbcacd4 wayland: Actually query the preferred colorstate
We weren't doing that, so everything looked like it wanted SRGB.
2024-07-27 07:26:51 +02:00
Benjamin Otte
25c812fa87 wayland: Redo the image description code
Main changes:

1. Avoid invalid writes by not passing pointers to a GArray that
   realloc()s its data
2. Use a hash table to store image defs, instead of an array. This
   requires a custom hash/equal function
3. Make image desc computation sync, so that setting a cs always
   succeeds or always fails and doesn't depend on timing.
4. Add a few debug messages in failure paths. For lack of a category,
   they ended up in MISC.
2024-07-27 07:26:51 +02:00
Matthias Clasen
45e76c1604 Merge branch 'wip/smcv/a11y-tests' into 'main'
tests: Fix signature of GtkTestATContext::update-selection-bound handlers

Closes #6490

See merge request GNOME/gtk!7504
2024-07-27 04:50:14 +00:00
Matthias Clasen
a9c3163a64 Merge branch 'main' into 'main'
Tests: add GtkPicture builder test

See merge request GNOME/gtk!7486
2024-07-27 03:08:15 +00:00
Simon McVittie
a8bb71383a tests: Fix signature of GtkTestATContext::update-selection-bound handlers
The signal is declared in GtkTestATContext with 0 parameters, but these
handlers were written as if the signal had one `guint` parameter.
On some architectures this accidentally works as intended, but on
others (reproduced on i386 and riscv64) the test tries to use arbitrary
stack contents as the `TestData *` and crashes when it tries to
dereference the resulting non-pointer.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6490
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 00:59:03 +01:00
Matthias Clasen
3b08f8026e Merge branch 'matthiasc/for-main' into 'main'
jpeg: Port to GdkMemoryTextureBuilder

See merge request GNOME/gtk!7502
2024-07-26 23:09:27 +00:00
Matthias Clasen
2cdc2287a5 Merge branch 'amolenaar/macos-open-panel-create-folders' into 'main'
macos: Propagate the create-folders option also for Open panels

Closes #6872

See merge request GNOME/gtk!7492
2024-07-26 22:35:43 +00:00
Juan Pablo Ugarte
c80c4ee75c Tests: add GtkPicture builder test
Add test for GtkPicture::file GFile property.
2024-07-26 18:30:58 -04:00
Juan Pablo Ugarte
082691ba16 GtkBuilder: add support for paths and relative uris for GFile properties. 2024-07-26 18:30:58 -04:00
Matthias Clasen
d09a610433 Merge branch 'spinbutton-hint' into 'main'
gtkspinbutton: Set number input hint for text field

See merge request GNOME/gtk!7485
2024-07-26 22:05:34 +00:00
Matthias Clasen
ea9f8b2f77 downloader: Add some docs
Mention the default format and color state.
2024-07-26 17:38:27 -04:00
Matthias Clasen
e2d337740f gpu: Don't mess up color states
When uploading textures, we were unintentionally converting to
srgb. Avoid that, so that yuv data survives unmolested.
2024-07-26 17:34:48 -04:00
Matthias Clasen
45c5b250b9 texture: Don't mess up color states
gdk_texture_download_surface was converting twice from the texture
color state to the target color state, with predictably bad results.
2024-07-26 17:27:20 -04:00
Matthias Clasen
f4b35093bd jpeg: Port to GdkMemoryTextureBuilder
This is in preparation for some color state handling.
2024-07-26 16:43:54 -04:00
Matthias Clasen
5e52cefb28 Merge branch 'rtl-label-hickup' into 'main'
label: Clear layout when text direction changes

Closes #6836

See merge request GNOME/gtk!7497
2024-07-26 18:13:28 +00:00
Benjamin Otte
bf43aee690 Merge branch 'wip/otte/for-main' into 'main'
gstreamer: Specify values for unspecified values

See merge request GNOME/gtk!7500
2024-07-26 14:38:01 +00:00
Matthias Clasen
62f359a494 Merge branch 'css-relative-font' into 'main'
css: Fix relative font sizes

Closes #6868

See merge request GNOME/gtk!7498
2024-07-26 14:24:42 +00:00
Benjamin Otte
cbe09373a5 gstreamer: Specify values for unspecified values
When the cicp values coming out of GStreamer are unspecified, replace
them with the default cicp values for YUV video: 1/13/6.

We still may end up with unspecified values inside the params, because
GStreamer returns unspecified for primaries/tfs/matrices that aren't
supported by cicp.

See also https://github.com/AOMediaCodec/libavif/wiki/CICP#unspecified
fora similar discussion.
2024-07-26 15:16:05 +02:00
Matthias Clasen
b3451dda04 css: Fix relative font sizes
This regression was introduced in aeac2b54.

We need percentage values to stay non-computed, since we otherwise
fail to compute relative font sizes properly. But we want percentages
not to stick around in relative colors, so tweak things to be more
aggressive with simplication when creating relative color values.

Update affected tests.

Fixes: #6868
2024-07-26 08:45:58 -04:00
Matthias Clasen
d477bf3d93 Merge branch 'image-tool-side-by-side' into 'main'
image-tool: Allow showing images side-by-side

See merge request GNOME/gtk!7501
2024-07-26 12:08:12 +00:00
Matthias Clasen
12c7f2d4fd Merge branch 'matthiasc/for-main' into 'main'
gpu: More debug spew

See merge request GNOME/gtk!7499
2024-07-26 12:07:55 +00:00
Matthias Clasen
feca09b8a4 image-tool: Allow showing images side-by-side
This is useful for comparisons.
2024-07-26 07:44:31 -04:00
Matthias Clasen
150f57f706 gpu: Fix the cicp conversion
The fragment shader was mixing up pixel and color variables.
And the compilers don't have 'uninitialized variable' warnings :(
2024-07-26 07:24:48 -04:00
Matthias Clasen
33131ad24d gpu: Fix the cicp conversion shader for ngl
The compiler was unhappy with using signed labels with an unsigned
variable in a switch. Talk about being picky.
2024-07-26 07:23:18 -04:00
Matthias Clasen
d53b3f9941 gpu: More debug spew
Print out the direction of the cicp conversion.
2024-07-26 07:22:45 -04:00
Martin
da07f1221f Update Slovenian translation 2024-07-26 09:36:52 +00:00
Matthias Clasen
9aed7ab25f Merge branch 'matthiasc/for-main' into 'main'
Add an image tool

See merge request GNOME/gtk!7496
2024-07-26 03:36:57 +00:00
Matthias Clasen
5ae225fe52 Add an image tool
This is meant to provide a convenient way to produce images in
specific color states and memory formats.
2024-07-25 18:20:59 -06:00
Matthias Clasen
cc8fa39110 tools: Improve localization 2024-07-25 18:20:59 -06:00
Matthias Clasen
c673a0bcc3 label: Clear layout when text direction changes
Otherwise, wrong alignment settings may linger in the layout.

Fixes: #6836
2024-07-25 17:06:58 -06:00
Benjamin Otte
efc6d15dde Merge branch 'wip/otte/for-main' into 'main'
gpu: Don't run long loops in shaders

See merge request GNOME/gtk!7495
2024-07-25 20:42:55 +00:00
Benjamin Otte
50403fbca8 wayland: Actually compare the right values
Wayland primaries/transfer functions aren't cicp values, so we can't
compare them.
2024-07-25 22:06:56 +02:00
Benjamin Otte
7de91d1777 wayland: We use v4 of the protocol 2024-07-25 22:06:56 +02:00
Benjamin Otte
6f9a70bd4e gpu: Add a version of a function
With the changes in !7473 we now use sampler2D arguments in functions.
However, when there's a function we call with a samplerExternalOES -
which means we need to overload it with that shader variant.
2024-07-25 18:53:55 +02:00
Benjamin Otte
de1dfb99bc gpu: Add shader name to error message
When a shader cant be compiled, we produce a long error dump, but
nowhere did we mention the actual shader.

Fix that.
2024-07-25 18:53:55 +02:00
Benjamin Otte
103296d948 gstsink: Make it usable again
The later CICP changes made the cicp params we were setting unustable.

Set ones that work in the current state of git main. They are still
imperfect, but they reflect the current code.
2024-07-25 18:53:55 +02:00
Benjamin Otte
0001562850 dmabuf: Fix Vulkan formats for P010 and friends
The P01x and P21x formats were swapped.
2024-07-25 18:53:55 +02:00
Benjamin Otte
1f3c88b995 build: Skip vulkan parts in generated GLSL
Make the #include parsing script able to skip a predefined list of terms
with #ifdef

Put "VULKAN" in that list to skip the vulkan parts.
2024-07-25 17:32:19 +02:00
Benjamin Otte
5e7f227d92 gpu: Don't run long loops in shaders
If the border radius is too big, take bigger steps when computing the
shadow.

I randomly chose 8 because that looked good and was fast enough.
2024-07-25 17:32:19 +02:00
Arjan Molenaar
6bbda619f9 macos: Propagate the create-folders option also for Open panels
When opening a folder, it may come in handy to create a folder.

Fixes #6872.
2024-07-25 11:32:14 +02:00
Matthias Clasen
e216fa3b6d Merge branch 'cicp-color-states' into 'main'
Fix the hlg transfer function

See merge request GNOME/gtk!7493
2024-07-25 01:19:02 +00:00
Matthias Clasen
c9443dd04d Fix the hlg transfer function
Fix a bug in the formula, and enable hlg as a transfer function.

The tests are passing now.
2024-07-24 18:59:18 -06:00
Matthias Clasen
29cb5051d4 Merge branch 'cicp-color-states' into 'main'
colorstate: Add cicp support

See merge request GNOME/gtk!7453
2024-07-25 00:48:57 +00:00
Matthias Clasen
5f2e70df8e Drop hlg for now
For some reason, roundtrip tests  with the hlg tf are failing,
so we don't support it.
2024-07-24 17:53:12 -06:00
Matthias Clasen
d8775d0194 gsk: Make shader matrices match
We were using slightly different numbers here, which isn't good.

The matrices in gdkcolordefs.h are tested in the colorstate-internal
tests, so they are at least properly inverse, and the products match.

It would be better to generate the glsl definitions, somehow.
2024-07-24 16:45:21 -06:00
Matthias Clasen
8d87ed1a6a Add tests
Add some more texture conversion roundtrips. They are currently
ifdefed out, since they need cicp api.

Also add another test binary for internal tests.
2024-07-24 16:45:21 -06:00
Matthias Clasen
a46bcc2755 Move transfer functions and matrices to a header
This way, we can write tests against them without static linking.
2024-07-24 16:45:21 -06:00
Matthias Clasen
229edc5225 wayland: Normalize cicp values
We don't want to create multiple image descriptions for functionally
equivalent tuples.
2024-07-24 16:45:21 -06:00
Benjamin Otte
b1962de51a gtksink: Add colorstate handling
The part for matrix coefficients and range is commented out so far.

It requires fixes so the dmabuf handling code can properly deal with it.
2024-07-24 16:45:21 -06:00
Matthias Clasen
fb10b61528 gdk: Add public api for cicp
Add a GdkCicpParams object that acts a bit like a builder for
cicp color states.
2024-07-24 16:45:21 -06:00
Matthias Clasen
e415ec9ca5 gsk: Use the cicp convert shader
When we the image color state is not a default one, use the cicp
convert op to convert it to the ccs. And when the target color
state is a non-default one, use the shader in the reverse direction.
2024-07-24 08:16:08 -06:00
Matthias Clasen
226652edb0 gsk: Add a cicp convert shader
This shader receives cicp parameters via uniforms, and converts
the texture data from or to the output colorstate. It computes
the matrix in the vertex shader, and then picks the eotf/oetf
according to the cicp parameters in the fragment shader.
2024-07-24 08:16:08 -06:00
Matthias Clasen
64f4967867 png: Make loader use cicp api
This should make non-default color states work with our png
loading and saving machinery.
2024-07-24 08:16:08 -06:00
Matthias Clasen
c37fa3a895 wayland: Use cicp color states
This is entirely untested, and the Wayland protocol makes it very
annoying.
2024-07-24 08:16:08 -06:00
Matthias Clasen
d907c0a42e colorstate: Add cicp support
This adds machinery to create colorstate objects from cicp
tuples, as well as a function to return a cicp tuple for a
colorstate.

Still missing: a conversion shader for non-default colorstates.
2024-07-24 08:16:08 -06:00
Matthias Clasen
4255230e36 colorstate: Cosmetics
Document a private api.
2024-07-24 07:46:05 -06:00
Matthias Clasen
d8a0915ada colorstate: Slight reorg
Move the conversion functions out of the default section, since
we will reuse the conversion functions for cicp. No functional
changes.
2024-07-24 07:46:05 -06:00
Matthias Clasen
32b348776e memoryformat: Allow indirect conversions
If we don't have a direct conversion function between two
colorstates, go indirectly via rec2100-linear.
2024-07-24 07:46:05 -06:00
Matthias Clasen
bbe552d6a8 Add gdk_color_state_get_convert_from
Our conversion machinery supports converting from any color
state to any default color state or back. Direct conversion
between two non-default color states isn't guaranteed. For
converting *to* a cicp color state, we need this function.
2024-07-24 07:46:05 -06:00
Pablo Correa Gómez
cfc871f031 gtkspinbutton: Set number input hint for text field if numeric
The main reason to do this is so that the OSK shows a numeric touchpad
instead of the regular keyboard when the spin button only accepts
numbers
2024-07-24 10:39:37 +02:00
Matthias Clasen
b435f3c543 Merge branch 'matthiasc/for-main' into 'main'
wayland: Switch to v4 of the color management protocol

See merge request GNOME/gtk!7489
2024-07-24 06:24:20 +00:00
Matthias Clasen
ebc4bb2363 wayland: Switch to v4 of the color management protocol 2024-07-23 23:37:00 -06:00
Matthias Clasen
23e4c788fa Merge branch 'dmabuf-formats-autoptr' into 'main'
gdkdmabufformats: Add autoptr definition

See merge request GNOME/gtk!7484
2024-07-23 19:48:01 +00:00
Jordan Petridis
4e0a64c46c Merge branch 'alatiera/vulkan-semaphore' into 'main'
gdkvulkancontext: set the VkSemaphore to VK_NULL_HANDLE

See merge request GNOME/gtk!7483
2024-07-23 18:05:23 +00:00
Marco Trevisan (Treviño)
e46e61643c gdkdmabufformats: Add autoptr definition 2024-07-23 19:55:47 +02:00
Jordan Petridis
cc5526e019 gdkvulkancontext: set the VkSemaphore to VK_NULL_HANDLE
Vulkan objects are integers on 32bit and it's failing when it's set to
just NULL.

```
../gdk/gdkvulkancontext.c:677:24: error: assignment to ‘VkSemaphore’ {aka ‘long long unsigned int’} from ‘void *’ makes integer from pointer without a cast [-Wint-conversion]
  677 |   priv->draw_semaphore = NULL;
```
2024-07-23 18:01:56 +02:00
Benjamin Otte
e6cafa890d Merge branch 'wip/otte/for-main' into 'main'
gpu: Use correct shader clip mode for glyph nodes

See merge request GNOME/gtk!7480
2024-07-23 08:51:35 +00:00
Benjamin Otte
293d2fd19f gpu: Use correct shader clip mode for glyph nodes
We were passing the wrong rect to the clip mode computation, resulting
in a rounded rect every time, even though it should pretty much always
be unclipped.

The visual results are unaffected, because the clip sent to the shader
was still correct.
2024-07-23 10:03:11 +02:00
Benjamin Otte
7bca467e01 Merge branch 'wip/otte/kill-descriptors' into 'main'
Redo descriptors/texture binding

Closes #6564, #6574, and #6654

See merge request GNOME/gtk!7473
2024-07-22 23:49:46 +00:00
Benjamin Otte
40e25218e2 gpu: Compile with AMD's compiler, too
Apparently AMD's GLSL compiler doesn't like our #if statements. Turn
them into simple #ifdefs and compute them in the preamble instead.
2024-07-22 19:40:24 +02:00
Benjamin Otte
9e27acb0a6 gpu: Allocate Vulkan descriptor pools dynamically
Instead of allocating one large descriptor pool and hoping we never run
out of descriptors, allocate small ones dynamically, so we know we never
run out.

Test incldued, though the test doesn't fail in CI, because llvmpipe
doesn't care about pool size limits. It does fail on my AMD though.

A fun side note about that test is that the GL renderer handles it best
in normal operationbecause it caches offscreens per node and we draw the
same node repeatedly.
But, the replay test expands them to duplicated unique nodes, and then
the GL renderer runs out of command queue length, so I had to disable
the test on it.
2024-07-22 19:40:24 +02:00
Benjamin Otte
67b9fb43d0 gpu: Completely revamp YCbCr handling
There is now a GskGpuYcbcr struct that maintains all the Vulkan
machinery related to YCbCrConversions.
It's a GskGpuCached, so it will make itself go away when it is no longer
used, ie a video stopped playing.
2024-07-22 19:40:24 +02:00
Benjamin Otte
762b981dfe gpu: Make the device queryable from the cache
That's needed in cached subclasses during destruction, when they want to
destroy system resources.
2024-07-22 19:40:24 +02:00
Benjamin Otte
5e027ae5d9 gpu: Allow creating GskGpuCached objects externally
Export the GskGpuCached and GskGpuCachedClass objects in the header, and
make gsk_gpu_cached_new() available.
2024-07-22 19:40:24 +02:00
Benjamin Otte
7dd3680d7d gpu: Refactor code a bit
Turn the 2 ways to construct cached items into 2 constructors.

Useful for next commit.
2024-07-22 19:40:24 +02:00
Benjamin Otte
14a7b4b4b4 vulkan: Remove unused features
Now that we don't use the fancy features anymore, we don't need to
enable them.
And that also means we don't need an env var to disable it for testing.
2024-07-22 19:40:24 +02:00
Benjamin Otte
f5096fd11a vulkan: No need for different shaders anymore
Now that we don't do fancy texture stuff anymore, we don't need fancy
shaders either, so we can just compile against Vulkan 1.0 again.

And that means we need no fallback shaders for Vulkan 1.0 anymore.
2024-07-22 19:40:24 +02:00
Benjamin Otte
9c5ac13301 gpu: Remove now unused variables
No need to track them anymore.
2024-07-22 19:40:24 +02:00
Benjamin Otte
ecc33d6e62 gpu: Add the same cache as the GL shader uses
This avoids unnecessary rebinds of textures.

I can't really measure a performance change with it though.
2024-07-22 19:40:24 +02:00
Benjamin Otte
03c34021af gpu: Completely revamp descriptor set handling
Instead of trying to cram all descriptors into one large array and only
binding it at the start, we now keep 1 descriptor set per image+sampler
combo and just rebind it every time we switch textures.

This is the very dumb solution that essentially maps to what GL does,
but the performance impact is negligible compared to the complicated
dance we were attempting before.
2024-07-22 19:40:24 +02:00
Benjamin Otte
1b2156493b gpu: Remove descriptors
They are no longer a thing with the new way we manage textures.
2024-07-22 19:40:24 +02:00
Benjamin Otte
7b76170f46 gpu: Flip the big switch
Rewrite all shaders to use 2 predefined samplers called GSK_TEXTURE0 and
GSK_TEXTURE1 instead of wrapper functions.

On GL and Vulkan compat mode, these map directly to samplers.
On Vulkan proper, they map to 2 indices into the texture array, like
before.

From now on, the old nvidia GPUs - ie the 3xx drivers - should start
working again.

Fixes: #6564
Fixes: #6574
Fixes: #6654
2024-07-22 19:40:14 +02:00
Benjamin Otte
8109e8e3b6 gpu: Add GskGpuShaderFlags
This is just blowing up GskGpuShaderClip to hold more information so
that we don't need even more specialization constants.
2024-07-22 18:37:07 +02:00
Benjamin Otte
163278af0d gpu: Add infrastructure to write texture vertex data
This allows GskGpuFrame implementations to store data per vertex
attribute.

This is just the plumbing, no actual implementation is done in this
commit.
2024-07-22 18:37:07 +02:00
Benjamin Otte
677b6c1a81 gpu: Force new descriptors every time
This guarantees that the images get ID 0 and 1 (on GL), which is going
to be quite important for the next steps.

Just for funsies, here's fps numbers on my desktop for this change:
NGL     1500 => 1400
Vulkan  2650 => 2250
2024-07-22 18:37:07 +02:00
Benjamin Otte
1331a10e88 gpu: Remove buffer handling
We don't use buffers atm, and if we want to bring them back later, we
can just look at reverting this commit.

And it's in the way while refactoring.
2024-07-22 18:37:07 +02:00
Benjamin Otte
dc9f0869b1 gpu: Pass used images to shader ops
This by itself is just more work refcounting all those images, but
there's actually a goal here, that will become visible in future
commits.

But this is split out for correctness and benchmarking purposes (the
overhead from refcounting seems to be negligible on my computer).
2024-07-22 18:37:07 +02:00
Benjamin Otte
ea6253c1df gpu: Add a member in ShaderOpClass for number of textures
This just puts the number from the header into a strcut where it can be
accessed.
2024-07-22 18:37:07 +02:00
Benjamin Otte
b481fd854f gpu: Encode number of textures use in every shader
Just define GSK_N_TEXTURES in every glsl file, extract that #define in
the python parser and emit a static const uint variable
"{shader_name}_n_textures" in the generated header.
2024-07-22 18:37:07 +02:00
Benjamin Otte
68baa93460 gpu: Use GskGpuShaderImage for blur ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
52db54e803 gpu: Use GskGpuShaderImage for crossfade ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
71e412e8f8 gpu: Use GskGpuShaderImage for convert ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
9644fc2e8f gpu: Use GskGpuShaderImage for mask ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
0795d86df7 gpu: Use GskGpuShaderImage for colormatrix ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
21988ea700 gpu: Use GskGpuShaderImage for blendmode ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
23081d2bc4 gpu: Use GskGpuShaderImage for texture ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
b1e441d18a gpu: Introduce GskGpuShaderImage
It's a struct collecting all relevant info for a texture passed to a
shader.

The ultimate goal is to get rid of the descriptors and let ops
manage them on thir own.
2024-07-22 18:37:07 +02:00
Benjamin Otte
a118cbb3ff Merge branch 'wip/otte/for-main' into 'main'
gpu: Move code around

See merge request GNOME/gtk!7477
2024-07-22 16:30:45 +00:00
Benjamin Otte
4639b3bc4c gpu: Make cache keep track of time
If GskGpuCache has an idea of what time it is, cached items can use that
time to update their last-use time instead of having to carry it around
throught function calls everywhere.
2024-07-22 17:10:37 +02:00
Benjamin Otte
821eb92dfb gpu: Handle corner-case
Port an optimization of the GL renderer where it fast-paths crossfades
with progress <= 0 and >=1 - which should really never happen because
nobody should emit them in the first place, but oh well.
2024-07-22 17:10:37 +02:00
Benjamin Otte
0370043775 gpu: Add missing string
This made debug output kinda not so good.
2024-07-22 17:10:37 +02:00
Benjamin Otte
82bcc05ca1 gpu: Move code around
Move the atlas code to the top of the file, so that other code can use
it.

No functional changes.
2024-07-22 17:10:37 +02:00
Benjamin Otte
527852e1b8 Merge branch 'wip/otte/colorstates-are-as-fun-as-dmabufs' into 'main'
dmabuf: Make NULL the default colorstate in the builder

See merge request GNOME/gtk!7474
2024-07-22 13:09:56 +00:00
Benjamin Otte
2e1686091f dmabuf: Make NULL the default colorstate in the builder
YUV dmabufs are not sRGB.

So instead of making the dmabuf builder have sRGB as the default
colorstate, add a NULL default option that makes the builder choose
the colorstate based on fourcc when build() is called.

If that happens, we pick sRGB usually, but for YUV we pick narrow range
BT601, like we did in versions before colorstates.
2024-07-22 14:54:05 +02:00
Artur S0
5353e28dca Update Russian translation 2024-07-22 12:23:52 +00:00
Benjamin Otte
b58e89f380 Merge branch 'wip/otte/for-main' into 'main'
vulkan: dmabufs require ycbcr

See merge request GNOME/gtk!7476
2024-07-22 00:50:07 +00:00
Benjamin Otte
c1e008fa86 gpu: Improve cache stats printing
We no longer hardcode the few different classes we have, but generically
walk over all classes.

As a side effect we now get new classes added to stats automatically.

The content itself did not change.
2024-07-22 02:03:00 +02:00
Benjamin Otte
c47a3c54fd vulkan: Make images track the device
Now that the cache is a separate object, there are no longer cyclic
uncollectable references, so images can use the device like everyone
else.
2024-07-22 01:28:40 +02:00
Benjamin Otte
3bc1e0534f gpu: Clean up headers
After the device/cache split, this was forgotten.
2024-07-22 01:28:40 +02:00
Benjamin Otte
7fb11dfeb0 gpu: Print filename in exceptions
I want to know which shader I screwed up.
2024-07-22 01:28:40 +02:00
Benjamin Otte
6d09eed90e gpu: Remove unused argument
It's always passing NULL.
2024-07-22 01:28:40 +02:00
Benjamin Otte
496211727d vulkan: dmabufs require ycbcr
So make sure that GDK_VULKAN_DISABLE=ycbcr also disables dmabufs.
2024-07-22 01:28:39 +02:00
Benjamin Otte
ee5e3b5927 Merge branch 'fix-urilauncher-uaf' into 'main'
urilauncher: Fix use-after-free on GCC < 12

See merge request GNOME/gtk!7471
2024-07-21 12:57:36 +00:00
Benjamin Otte
2087595747 Merge branch 'wip/otte/for-main' into 'main'
ngl: Fix crash at startup

See merge request GNOME/gtk!7472
2024-07-19 20:17:14 +00:00
Benjamin Otte
25268c2086 gstsink: Don't use g_autoptr 2024-07-19 21:37:48 +02:00
Benjamin Otte
2a9056b49e ngl: Fix crash at startup
Commit 1580490670 included a reordering of
acquiring the frame before making the context current.

Sometimes (like at startup) new frames need to be created.

Setting up a new frame assumed the GL context was current.

Change it so that we delay the one GL setup we do in frames until later.
2024-07-19 21:37:48 +02:00
Sergey Bugaev
46363b617e urilauncher: Fix use-after-free on GCC < 12
Building GTK with GCC 8 results in the following warning:

  gtk/gtkurilauncher.c: In function ‘gtk_uri_launcher_launch’:
  gtk/gtkurilauncher.c:315:3: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation]
     else
     ^~~~
  gtk/gtkurilauncher.c:317:1: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘else’
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   ^~~

In the compiled code, gtk_show_uri_full () is invoked whether the portal
branch is taken or not, leading to use-after-free of the task.

It looks like GCC in versions older than 12 treats the _Pragma(s) that
G_GNUC_BEGIN_IGNORE_DEPRECATIONS expands to as C-level statements, and
therefore the pragma takes up the 'else' statement slot.

See https://godbolt.org/z/e5zqbaqxo for a simple reproducer.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-07-19 20:36:45 +03:00
Yaron Shahrabani
adb3baa7d2 Update Hebrew translation 2024-07-19 12:58:41 +00:00
Carlos Garnacho
31a79fbd9f Merge branch 'main' into 'main'
Ignore grabbing tablet devices without pads or tools

See merge request GNOME/gtk!7470
2024-07-18 12:10:36 +00:00
Jie Liu
d8919311b1 Ignore grabbing tablet devices without pads or tools
Signed-off-by: Jie Liu <liujie01@kylinos.cn>
2024-07-18 18:19:26 +08:00
Benjamin Otte
0e0158a825 Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Do a naive implementation of P010, P012 and P016

See merge request GNOME/gtk!7469
2024-07-18 03:13:32 +00:00
Benjamin Otte
619926ec83 dmabuf: fix mmap() calls
* We cannot map with offset, because offsets need to be page-size
  aligned. And our code doesn't expect an offset anyway.
* The error return value from mmap() is MAP_FAILED aka -1, not NULL aka
  0.
2024-07-18 04:33:14 +02:00
Benjamin Otte
1afb832ff0 dmabuf: Do a naive implementation of P010, P012 and P016
These are the common HDR formats, so we better have the baseline of
those.
2024-07-18 04:33:14 +02:00
Benjamin Otte
823b529f89 gstsink: Remove unused member variable 2024-07-18 04:33:14 +02:00
Benjamin Otte
4707784755 gstsink: Use GdkMemoryTextureBuilder 2024-07-18 04:33:14 +02:00
Benjamin Otte
1ebcd27605 Merge branch 'wip/otte/for-main' into 'main'
Various Vulkan fixes

See merge request GNOME/gtk!7468
2024-07-17 21:19:02 +00:00
Benjamin Otte
300639e537 vulkan: Use right check for waiting on external image semaphore
Commit 3aa6c27c26 changed the initial layout of imported dmabuf images,
but did not adapt this check.
2024-07-17 22:59:23 +02:00
Benjamin Otte
ad218f0786 gpu: Pass the pass to frame_submit()
We will need that in the next commit.
2024-07-17 22:59:23 +02:00
Benjamin Otte
4966f8cdf8 vulkan: Add an acquire semaphore to frames
Vulkan requires us waiting on the image acquired from
vkAcquireNextImageKHR() before we start rendering to it, as that
function is allowed to return images that are still in use by the
compositor.
Because of that requirement, vkAcquireNextImageKHR() requires a
semaphore or fence to be passed that it can signal once it's done.

We now use a side channel to begin_frame() - calling
set_draw_semaphore() - to pass that semaphore so that the
vkAcquireNextImageKHR() call inside begin_frame() can use it, and then
we can wait on it later when we submit.

And yes, this is insanely convoluted, the Vulkan developers should
totally have thought about GTK's internal designs before coming up
with that idea.
2024-07-17 22:59:23 +02:00
Benjamin Otte
1580490670 gpu: add gsk_gpu_frame_begin/end()
These are just factoring out gdk_draw_context_begin/end_frame() so I can
add one tiny thing there later.

And I did both even though I only need one, because it felt wrong to
just do one.
2024-07-17 22:59:23 +02:00
Benjamin Otte
3cf5e8cf4e gpu: Move gc calls further to the edges of the function
Make the function look like that:

1. handle special case
2. maybe GC
3. draw
4. queue next gc
5. cleanup

This seems like the sanest approach to avoid gc() collecting things
necessary for drawing in the future.

And I need to refactor stuff, so having it out of the way is a good
idea.
2024-07-17 22:59:23 +02:00
Benjamin Otte
d21ac80178 gpu: Simplify a function
Now that we only ever use 2 images max per shader due to the removal of
the ubershader, we can just hardcode it in the function.
2024-07-17 22:59:23 +02:00
Martin
effbaa7770 Update Slovenian translation 2024-07-17 07:07:05 +00:00
Quentin PAGÈS
a9a61abc81 Update Occitan translation 2024-07-17 07:02:10 +00:00
Ekaterine Papava
e5b05424c8 Update Georgian translation 2024-07-16 21:45:51 +00:00
Matthias Clasen
8f920101f3 Merge branch 'wip/otte/texture-colorstate-api' into 'main'
Add support for color states to texture constructors/downloader

See merge request GNOME/gtk!7461
2024-07-16 21:09:48 +00:00
Matthias Clasen
1c59474f45 Merge branch 'inspector-crash' into 'main'
inspector: Fix a crash

See merge request GNOME/gtk!7467
2024-07-16 20:58:37 +00:00
Benjamin Otte
9be7104b71 testsuite: Add a save=>load cycle test for PNGs with colorstates 2024-07-16 22:04:11 +02:00
Benjamin Otte
31e0ec71f2 png: Add color state support
When loading or saving png files, encode the CICP flags of the color
state into the PNG.

When loading, decode the CICP flags if available and detect the
colorstate they use.
If we do not support the cicp tags, we do not load the image.

So far, we ignore the ICC profiles.

Includes regeneration of nodeparse test *reference* output to include
the new tags we write to PNGs.
The original tests do not include those tags, so we implicitly test that
we read untagged files correctly.
2024-07-16 22:04:10 +02:00
Benjamin Otte
6c33afc13c png: Move texture data download further down
We only download the data when we actually need it for writing into the
PNG stream.

This allows modifying the download parameters (in particular color state
in the next commit) while writing out their settings, so the code for
selecting the right colorstate liives in only one place.

We have to be careful though, because the download now happens after the
setjmp(), so we need to make sure the error path handles both cases
without leaking: Where the download has happened and where it hasn't.
2024-07-16 22:03:48 +02:00
Benjamin Otte
03daf42fb5 png: Port to MemoryTextureBuilder 2024-07-16 22:03:46 +02:00
Matthias Clasen
b33b68ef75 dmabuf texture: color state support 2024-07-16 21:23:44 +02:00
Matthias Clasen
0ee8ca43d1 gl texture: color state support 2024-07-16 21:23:44 +02:00
Benjamin Otte
77da45a173 testsuite: Update colorstate test 2024-07-16 21:23:44 +02:00
Benjamin Otte
5e1c3c5d69 gdk: Add GdkMemoryTexture::color-state
This allows setting the color state of textures.
2024-07-16 21:23:44 +02:00
Benjamin Otte
05953a20cc testsuite: Allow colorstate properties to have SRGB as default value
This needs custom code because boxed paramspecs always default to NULL.
But we want to always default to SRGB.
2024-07-16 21:23:44 +02:00
Benjamin Otte
3c8a93b972 gdk: Add GdkMemoryTextureBuilder
Same thing as dmabuf and GL texture builders. Preparation for adding
color state support to texture constructors.

As a bonus, we can now do update regions with memory textures.
2024-07-16 21:23:44 +02:00
Benjamin Otte
11543a229a texturedownloader: Add color state
... and plumb the color state through the downloading machinery, where
no matter what path it takes it ends up in
gdk_memory_convert_color_state() or gdk_memory_convert().

The 2nd of those has been expanded to optionally do colorstate
conversion when the 2 colorstates are different.
2024-07-16 21:23:44 +02:00
Robert Mader
d448e12cf4 inspector: Fix a crash
gdk_wayland_color_get_color_manager() rightfully is not NULL-safe.

Fixes: 2031ec1b57 ("inspector: Show the color management protocol")
2024-07-16 10:30:56 +02:00
Benjamin Otte
fee4ad0174 Merge branch 'wip/otte/for-main' into 'main'
gpu: Don't transition invalid cache items

Closes #6867

See merge request GNOME/gtk!7466
2024-07-16 01:40:16 +00:00
Matthias Clasen
38f01cf1f2 Merge branch 'fix-subsurface-crash' into 'main'
wayland/subsurface: Handle NULL-buffers in dmabuf_buffer_release

See merge request GNOME/gtk!7465
2024-07-16 01:25:41 +00:00
Benjamin Otte
37bea9d162 gpu: Don't transition invalid cache items
When a cache item is invalid, don't move it into the hash table.
Instead, just delete it.

Something like this could happen:

1. A texture is cached
In the case of #6867 this would be a webpage in epiphany.

2. The texture cache item is garbage-collected
For example, epiphany might switch to a new tab, and the previous page's
texture will remain. After 15s or so, we collect our item for that
texture.

3. The texture is cached again, but in the target colorspace
We now decide we need the texture again, but not in any colorspace, we
need it in the target colorspace. This might be because we run an
effect on it (like a crossfade) or because we want mipmaps (like in the
overview map, where its zoomed out).

4. The old invalid item is transitioned into the hash table
We now have an invalid item in the hash table. This is extra bad,
because it had only one reference (from the texture), but we treat it
like it has 2 (from us in the hash table and from the texture).
So depending on if the texture is freed before we reuse it, we get
different results: If it was free, we get invalid memory accesses, if it
was not freed, we treat it like a valid cache item and think the image
inside is still valid.

Fixes #6867
2024-07-16 03:15:36 +02:00
Robert Mader
b241fcd418 wayland/subsurface: Handle NULL-buffers in dmabuf_buffer_release
This happens when buffer creation fails in `get_dmabuf_wl_buffer()` and
we manually call `listener->release (data, NULL)`.

Fixes: 2478dd8322 ("subsurface: Split a function")
2024-07-16 01:43:15 +02:00
Benjamin Otte
86e735cd5c Merge branch 'wip/otte/for-main' into 'main'
vulkan: Remove draw semaphore

Closes #6861

See merge request GNOME/gtk!7460
2024-07-14 21:11:06 +00:00
Michael Catanzaro
4c40395a38 gpu: fix memory corruption in cache_gc_cb()
gsk_gpu_device_gc() may release the last ref on the GskGpuDevice,
leading to memory corruption when setting priv->cache_gc_source = 0.

Includes a bit of refactoring, so the ref/unref wraps nicely around the
actual code.

Fixes crashes seen after using the inspector and closing the window,
thereby closing all windows of a display and releasing all references to
the device.

Fixes #6861
2024-07-14 21:54:57 +02:00
Benjamin Otte
d32fd76b31 docs: Fix typo 2024-07-14 21:54:40 +02:00
Benjamin Otte
5f8e83d75d gpu: Fix memleak in texture-scale code 2024-07-14 21:54:40 +02:00
Benjamin Otte
b08a17064e vulkan: Remove draw semaphore
That's unused (or wrongly used) leftover code from 2017.

The validation layers also don't like it.
2024-07-14 21:54:40 +02:00
Benjamin Otte
3f39cb38c4 Merge branch 'wayland-color-states' into 'main'
Wayland color management

See merge request GNOME/gtk!7444
2024-07-14 19:46:56 +00:00
Matthias Clasen
2031ec1b57 inspector: Show the color management protocol 2024-07-14 14:58:00 -04:00
Matthias Clasen
533aaba5eb wayland: Support xx-color-management-v2
This is a still experimental protocol (thus the xx prefix).

We are using it go obtain information about the compositors
preferred color state, and pass that on to our rendering machinery.

The currently supported color states are srgb, srgb-linear, rec2100-pq
and rec2100-linear. We don't have any support for ICC profiles.

Unlike other protocols, keep the support code for this protocol
fairly isolated behind wrapper objects, since the protocol is
still subject to change.
2024-07-14 14:58:00 -04:00
Matthias Clasen
72c782af17 Merge branch 'matthiasc/for-main' into 'main'
colorstate: Add autoptr definitions

See merge request GNOME/gtk!7457
2024-07-14 18:12:34 +00:00
Matthias Clasen
af8a3eff10 Merge branch 'surface-color-state' into 'main'
surface: Add a color state

See merge request GNOME/gtk!7456
2024-07-14 17:21:51 +00:00
Matthias Clasen
ee7ba54a7f colorstate: Add autoptr definitions
A little convenience never hurts.
2024-07-14 12:52:56 -04:00
Matthias Clasen
53d99f5521 Use the surface colorstate in begin_frame
begin_frame is the place where we make decisions about the format,
depth and colorstate for our rendering. Make these calls take the
surface color state into account.

In particular, if the surface colorstate is suitable for GL_SRGB,
and we don't need high depth, set things up for that.
2024-07-14 12:51:05 -04:00
Matthias Clasen
52d2975af3 surface: Add a color state
This will be set by the backend, and it will be used to set up
the draw context properly. For now, this is always SRGB.
2024-07-14 12:46:20 -04:00
Matthias Clasen
926a651f12 Merge branch 'more-color-states' into 'main'
More color states

See merge request GNOME/gtk!7445
2024-07-13 19:37:54 +00:00
Matthias Clasen
7aeab7a63f Add a debug flag for hdr rendering
Set GDK_DEBUG=hdr to force the use of rec2100 as compositing
colorstate.
2024-07-13 15:11:07 -04:00
Matthias Clasen
a2389b3169 Cosmetics
Shift debug flags around so we can put hdr next to linear.
2024-07-13 15:11:07 -04:00
Matthias Clasen
54e5cc296f colorstate: Add rec2100-pq and rec2100-linear
These are wide-gamut, HDR colorstates that we will need for HDR support.
2024-07-13 15:11:07 -04:00
Matthias Clasen
457fd68168 gpu: Make color conversion extensible
Change the glsl convert_color function to proceed in stages:
- first unpremultiply
- then linearize
- then transform linearly
- then delinearize
- then premultiply
All the steps are only taken if needed.
2024-07-13 15:09:12 -04:00
Matthias Clasen
2d69f35e0e colorstate: More details in the docs
Add links to srgb definitions and references.
2024-07-13 15:09:12 -04:00
Benjamin Otte
648c780e91 gpu: Respect colorstate for offscreens
We want to render in at least the minimum required depth of the used
colorstate.
2024-07-13 14:51:49 -04:00
Benjamin Otte
f36618f02a Merge branch 'fix-columnviewcolumn-visibility' into 'main'
columnview: check column visibility when measuring

See merge request GNOME/gtk!7452
2024-07-13 17:47:49 +00:00
Christian Hergert
8548a1dd7f columnview: check column visibility when measuring
We only want to measure visible columns so that they may consume the
maximum width available to the widget. This fixes a situation where hidden
columns would cause less-than the whole width to be allocated. Additionally
that fixes warnings where some widgets expect more horizontal space than
they would ultimately be allocated.
2024-07-13 10:12:41 -07:00
Matthias Clasen
5e1d58c41c Merge branch 'matthiasc/for-main' into 'main'
vulkan: Remove GDK_DEBUG=vulkan-validate

See merge request GNOME/gtk!7451
2024-07-13 13:19:54 +00:00
Benjamin Otte
a61d7f3864 vulkan: Remove GDK_DEBUG=vulkan-validate
The modern incantation to get validation layers enabled is via

VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation

Vulkan has a bunch of environment variables to toggle stuff, let's use
those instead of doing our own.
2024-07-13 08:52:28 -04:00
Benjamin Otte
c7fcaaf443 Merge branch 'wip/otte/for-main' into 'main'
gpu: Fix color convert path to not crash

See merge request GNOME/gtk!7450
2024-07-13 10:41:38 +00:00
Benjamin Otte
6d263f8680 gpu: Add GSK_GPU_BLEND_NONE
Allows writing without blending. This is useful when copying/converting
textures.

In particular, we use it for colorspace conversions.
2024-07-13 10:56:47 +02:00
Benjamin Otte
d9ab6495ef gpu: Fix color convert path to not crash
The occlusion culling reorganization messed up this branch.

Make it work again.
2024-07-13 10:56:47 +02:00
Ekaterine Papava
ceac0ce9aa Update Georgian translation 2024-07-13 05:34:08 +00:00
Benjamin Otte
e975d6db17 Merge branch 'wip/otte/for-main' into 'main'
gpu: Remove unused macro

See merge request GNOME/gtk!7449
2024-07-13 01:25:35 +00:00
Benjamin Otte
d54b68b93c gpu: Convert values to float[4] from GdkRGBA
We need to make sure our clear values are in the right colorstate, not
in sRGB.

The occluision culling managed to sneak through the big transition for
that.
2024-07-13 02:07:15 +02:00
Benjamin Otte
761346ed5a gpu: Remove unused macro
This is a leftover from the pre-color-managed times
2024-07-13 02:07:15 +02:00
Matthias Clasen
6d71dd0025 Merge branch 'matthiasc/for-main' into 'main'
colorstate: Consistent naming

See merge request GNOME/gtk!7448
2024-07-12 23:58:28 +00:00
Matthias Clasen
d0e2d9e2f4 colorstate: Small reorg
Introduce a helper macro.
2024-07-12 18:15:28 -04:00
Matthias Clasen
b0effee9b3 colorstate: Add tests for conversions
Test roundtrip tests between color states.

For now, this just tests srgb<>srgb-linear.
2024-07-12 18:14:54 -04:00
Matthias Clasen
abb7e85260 colorstate: Consistent naming
Make the conversion functions use srgb_linear in their names, since
the name of the color state is srgb-linear.
2024-07-12 18:14:44 -04:00
Matthias Clasen
3ccd03e226 Updates 2024-07-12 16:55:49 -04:00
Benjamin Otte
2ae345aa8f Merge branch 'wip/otte/big-bigger-oom' into 'main'
Implement tiling for large textures

Closes #6324

See merge request GNOME/gtk!7447
2024-07-12 17:47:53 +00:00
Benjamin Otte
1c1b78aa1c gpu: Implement tiling for texture-scale nodes
This is actually the node Loupe is using, so having tiling work with it
is important.

Because of the previous commit, different filters are supported fine.

Fixes: #6324
2024-07-12 18:09:46 +02:00
Benjamin Otte
cdb2308ddd gpu: Add filter support to tiled images
This allows mipmapping if downscaled a lot, like we do for non-tiled
images.

A side effect is that due to the simpler caching for tiles, we can only
cache the mipmapped images in one colorstate. But we need to pick a
potentially non-default one, because we want to mipmap in a linear
colorstate.

So this is somewhat suboptimal. Patches with improvements accepted.
2024-07-12 17:31:36 +02:00
Benjamin Otte
c581f722bd gpu: Split out a function
We'll need mapping scaling filters to samplers elsewhere soon.
2024-07-12 17:31:36 +02:00
Benjamin Otte
340c98c6cd gpu: Split a function
Split drawing the tiles from setting up the offscreen for drawing the
tiles.
2024-07-12 17:31:36 +02:00
Benjamin Otte
39f5c5bf49 gpu: Implement tiling for texture nodes
Use the new cache feature to split oversized textures into tiles the
size given by the new device API.

Then number those tiles from left to right and top to bottom and use
that number as the tile id.
2024-07-12 17:31:36 +02:00
Benjamin Otte
392f6855ca gpu: Add gsk_gpu_device_get_tile_size()
This allows managing tiling of images. And I'd like this value to live
somewhere prominent instead of as a hardcoded number in the
nodeprocessor.
2024-07-12 17:31:36 +02:00
Benjamin Otte
1cae48ab93 gpu: Add a tile cache
Nobody is using it yet, but it's the API.

It's very simple and just allows adding tiles by an index. What that
index means is up to the caller.
2024-07-12 17:31:36 +02:00
Benjamin Otte
25f04f3c37 Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Add DRM_FORMAT_INVALID to our formats

See merge request GNOME/gtk!7446
2024-07-12 15:29:40 +00:00
Benjamin Otte
d0f8ef09a0 gpu: Do a GC run after every tile of large images
When we draw large images, we absolutely do not want to keep memory that
we do not need. So do a GC run after every tile. That otentially slows
down things, but it also improves the chances of not running out of
memory.

Here's the node for the image I managed to create after I applied this
patch:

repeat {
  bounds: 0 0 50000 50000;
  child: text {
    font: "Noto Color Emoji 10000px";
    glyphs: 661 0 0 0 color;
    offset: 0 10000;
    hint-style: none;
  }
}
2024-07-12 16:57:23 +02:00
Benjamin Otte
0516dca116 vulkan: Don't try to use nonexisting formats
Handle the error that new rgba format exists.
2024-07-12 16:56:23 +02:00
Benjamin Otte
ebc6a043c9 gpu: Cleanups 2024-07-12 16:56:23 +02:00
Benjamin Otte
8e2ae79875 gpu: Change function to (transfer full)
Functions should behave as I expect, and I just spent an hour debugging
a refcount issue because I assumed our image creation functions return
refrences. Which is a very sane assumption.
2024-07-12 16:55:59 +02:00
Benjamin Otte
27ac764653 gpu: Don't multiply by 1/x, divide by x
This is less error-prone with floating point math, even though it is
somewhat slower.
2024-07-12 16:55:59 +02:00
Matthias Clasen
80df6e2b8d Merge branch 'matthiasc/for-main' into 'main'
wayland: Fix handling of the font-rendering setting

Closes #6855

See merge request GNOME/gtk!7443
2024-07-12 00:55:02 +00:00
Matthias Clasen
bfda8cf820 stylecontext: fix gtk_style_context_lookup_color
We need to ensure the value is computed.

Fixes: #6855
2024-07-11 19:58:55 -04:00
Matthias Clasen
cb91f96fd3 wayland: Fix handling of the font-rendering setting
The settings portal is reporting enums as string values, so
we need to translate this setting back to what we need.

Fixes

(gtk4-demo:18902): GLib-CRITICAL **: 19:06:14.783: g_variant_get_int32: assertion 'g_variant_is_of_type (value, G_VARIANT_TYPE_INT32)' failed

that could be seen in recent nightly flatpaks.
2024-07-11 19:06:50 -04:00
Matthias Clasen
549ec0aac8 Merge branch 'matthiasc/for-main' into 'main'
Small doc fixes

See merge request GNOME/gtk!7442
2024-07-11 21:15:10 +00:00
Matthias Clasen
5cea9f9e17 Small doc fixes
Pointed out be Emmanuele Bassi.
2024-07-11 16:56:10 -04:00
Benjamin Otte
a9cce55693 dmabuf: Add DRM_FORMAT_INVALID to our formats
That's gonna be necessary for the next commit.
2024-07-11 18:39:14 +02:00
Benjamin Otte
e1152c33c4 Merge branch 'wip/otte/linear-compositing' into 'main'
Linear compositing, take 2

See merge request GNOME/gtk!7391
2024-07-11 13:29:14 +00:00
Benjamin Otte
e40ad5faa5 gpu: Cache textures when doing copies
The texture and texture-scale node code is creating image copies
for mipmaps and to adapt to the compositing colorstate.

Those texture should be cached.
2024-07-11 14:57:20 +02:00
Benjamin Otte
dd393a4a0e gpu: Split out texture lookup function
It's unused in 3 function and has become somewhat unwieldy.
2024-07-11 14:57:20 +02:00
Benjamin Otte
881954dfca gpu: Rework texture caching
We want to cache textures in the compositing color state, not in their
original color state. However, the compositing color state may change
(think multimonitor setups).

So we additionally keep a cache per colorstate.

That means texture lookup is now a 3-step process:

1. Look up in the compositing colorstate's cache

2. Look up in the general cache

3. Upload
2024-07-11 14:57:20 +02:00
Benjamin Otte
cf12503fec gpu: Don't replace cache items
Instead, keep them. This is not useful yet, but will become so in the
next commits.
2024-07-11 14:57:20 +02:00
Benjamin Otte
ad757cccb6 Don't use GL_SRGB for premultiplied textures
GL_SRGB is doing postmultiplied alpha, so if the texture is
premultiplied, we can't use this optimization.

The optimization still works for unpremultiplied and opaque images,
because those don't do that step.
2024-07-11 14:57:20 +02:00
Benjamin Otte
b801eae00f gpu: All ops obey the ccs now
Remove the macro used for the not-yet converted ops.
2024-07-11 14:57:20 +02:00
Benjamin Otte
2fe9ff7918 gpu: Make mask op obey ccs
No colorstate conversions allowed here, though technically we could use
the alternate color state for the source most of the time, as the mask's
colorstate is only relevant for luminance.
2024-07-11 14:57:20 +02:00
Benjamin Otte
c407582096 gpu: Make blur op obey ccs
Blend ops don't do colorspace conversion, so this commit just hardcodes
that and rewrites the shader to use recent APIs.
2024-07-11 14:57:20 +02:00
Benjamin Otte
0fc3dbaa9b gpu: Make texture op obey ccs
Well, texture ops actually don't do any colorspace stuff, but let's
explicitly hardcode that.
2024-07-11 14:57:20 +02:00
Benjamin Otte
77ed264714 gpu: Introduce gsk_gpu_color_states_create_equal()
This is a function that's meant to be used whenever both color states
of the shader are equal. In that case no colorspace conversion code
needs to be created and shaders can be shared.
2024-07-11 14:57:20 +02:00
Benjamin Otte
a14efce914 gpu: Make blur op obey ccs 2024-07-11 14:57:20 +02:00
Benjamin Otte
08f90a188c gl: Force U8 textures for U8_SRGB depths
The GL renderer is using FLOAT32 instead of GL_SRGB, which is screwing
up the node-editor by making it turn on high bit depth unconditionally.

So until someone fixes the GL renderer properly, do this quickfix.
2024-07-11 14:57:20 +02:00
Benjamin Otte
df46eeafdb gpu: Make colormatrix op obey ccs
The colormatrix needs to be applied to unpremultiplied values, so we use
the alternative colorstate for that.
2024-07-11 14:57:20 +02:00
Benjamin Otte
0029286a1e gpu: Remove unused function
The colormatrix shader is no longer used for opacity.
2024-07-11 14:57:20 +02:00
Benjamin Otte
0e46d4eb98 gpu: Pass sampler to the image op
That way, we can use it in one other place where we want to use mipmaps.

I don't really like it because it adds yet another argument,
but then the one new caller was selecting suboptimal shaders, and that's
worse.
2024-07-11 14:57:20 +02:00
Benjamin Otte
f80e3fff92 gpu: Don't use the colormatrix shader for opacity
The colormatrix shade does a whole matrix multiplication, which is
absolutely not necessary.

The convert shader has builtin opacity handling and when the colorstates
match will do no conversion.
2024-07-11 14:57:20 +02:00
Benjamin Otte
504c6ba792 gpu: Don't use color matrix for opacity
We can use the regular image op which will select the fastest shader.
2024-07-11 14:57:20 +02:00
Benjamin Otte
c0aba9aee1 gpu: Make crossfade op obey ccs
I didn't have an idea what to use the alternate color state for, so I
don't use it.
2024-07-11 14:57:20 +02:00
Benjamin Otte
fa33af248e cairo: Improve gdk_texture_download_to_surface()
Previously, we were always downloading into CAIRO_FORMAT_ARGB32.
Now we check the texture depth and pick a suitable format.

This improves rendering for high depth content, but it's slower.

That's why we're not yet making sure the depth is suitable for the
colorspace conversion. That would force all SRGB textures into float
surfaces as we don't consider conversions suitable for U8 in our generic
code.
2024-07-11 14:57:20 +02:00
Benjamin Otte
e6cfbc00fc gdk: Support more formats in gdk_texture_new_for_surface() 2024-07-11 14:57:20 +02:00
Benjamin Otte
b97cf2b9d9 gpu: Track image colorstate
So far we only track the image colorstate and convert if necessary.

There is no caching of the converted images happening.
2024-07-11 14:57:20 +02:00
Benjamin Otte
f81e7b2112 gpu: Make conic gradient op obey ccs
Straight copy of the linear gradient changes.
2024-07-11 14:57:20 +02:00
Benjamin Otte
b59e4a929e gpu: Make radial gradient op obey ccs
Straight copy of the linear gradient changes.
2024-07-11 14:57:20 +02:00
Benjamin Otte
099d72f037 gpu: Make box shadow op obey ccs 2024-07-11 14:57:20 +02:00
Benjamin Otte
73acb41931 gpu: Make colorize op obey ccs 2024-07-11 14:57:20 +02:00
Benjamin Otte
ebb7fdb099 gpu: Make linear gradient op obey ccs
The alternative color state is used as the interpolation color state.
Colors are transformed into that space on the CPU.

For now we set the interpolation color state to SRGB, because ultimately
we want to let callers specify it, so having something that's easy to
map to that behavior is desirable.
Otherwise we might have chosen to interpolate in the compositing
colorstate.

It also means that we need to premultiply colors on the CPU now because
of the limitations of the shader colorstates APIs.
2024-07-11 14:57:20 +02:00
Benjamin Otte
ec3cb0ad9a gpu: Make border op obey ccs 2024-07-11 14:57:20 +02:00
Benjamin Otte
7ffef6792f gpu: Make rounded-color op obey ccs
This is the same as the color op.
2024-07-11 14:57:20 +02:00
Benjamin Otte
383148dc31 gpu: Make color op obey ccs
This makes use of the GskGpuColorStates by setting the ccs as output
colorstate and the color's colorstate as alternative color state.

The shader adaption is very straightforward because of that.
2024-07-11 14:57:20 +02:00
Benjamin Otte
a31601ccfc gpu: Make clear op obey ccs
This is the first op to obey the compositing color state. This means
from now on until all ops obey the ccs rendering is broken when ccs is
not set to linear.

I'll keep individual ops in seperate commits for easier review, because
they all need different adaptations.
2024-07-11 14:57:20 +02:00
Benjamin Otte
a587492cad gpu: Handle target not being composite colorstate
Render to an offscreen and add a final conversion if the target
colorstate is not a rendering colorstate.

This now allows the GPU renderer to render to any colorstate.
2024-07-11 14:57:20 +02:00
Benjamin Otte
f65d4914e4 gpu: Port convert op to GskGpuColorStates
Make it handle straight alpha, too, by checking if the alt colorspace is
premultiplied - which is the colorspace of the source.
2024-07-11 14:57:20 +02:00
Benjamin Otte
88dc49a5b6 gpu: Print the color states of shader ops
Makes the verbose output (a lot) more verbose, but it makes the
colorstates used in the shaders very visible.

And it will be relevant once people start using different colorstates
everywhere (like oklab for gradients/colors and so on).
2024-07-11 14:57:20 +02:00
Benjamin Otte
91d970e9c5 gpu: Add shaders for the new specialization constant
This adds the following functions:

output_color_from_alt()
alt_color_from_output()
  Converts between the two colors

output_color_alpha()
alt_color_alpha()
  Multiplies a color with an alpha value
2024-07-11 14:57:20 +02:00
Benjamin Otte
6c5ae48a05 gpu: Pass color states as specialization constant
This adds a GdkColorStates that encodes 2 of the default GdkColorStates
and wether their values are premultiplied or not.

Neither do the shaders do anything with this information yet, nor do the
shaders do anything with it yet, this is just the plumbing.
2024-07-11 14:57:20 +02:00
Benjamin Otte
d85ec2cbb4 gpu: create SRGB images
If desired, try creating GL_SRGB images. Pass a try_srgb boolean down to
the image creation functions and have them attempt to create images like
that.

When it is not possible to create srgb images in the given format, just
fall back to regular images. The calling code is meant to check the
GSK_GPU_IMAGE_SRGB flags to determine the actual format of the resulting
image.
2024-07-11 14:57:20 +02:00
Benjamin Otte
527f305690 vulkan: Compare different depths by their Vulkan format
GdkMemoryFormats can be identical for different Vulkan formats, in
particular in the srgb vs non-srgb case.
2024-07-11 14:57:20 +02:00
Benjamin Otte
b05c9c26bd vulkan: Add support for SRGB formats 2024-07-11 14:57:20 +02:00
Benjamin Otte
05b79bc378 gpu: Handle SRGB in render_texture()
When GDK_MEMORY_U8_SRGB is desired by the node, and a SRGB image is
created, pick SRGB_LINEAR as the colorspace to pass to frame_render().
2024-07-11 14:57:20 +02:00
Matthias Clasen
3ba63315d5 gpu: Pass compositing color states
Make the node processor and the pattern writer track the current
compositing color state. Color state nodes change it. We pass
the surface color state down via the frame apis.

The name of the variable is "ccs" for "compositing color space". It's an
unused variable name and it's common enough to deserve a short and sweet
name.
2024-07-11 14:57:20 +02:00
Benjamin Otte
eccdb594eb gpu: Remove straightalpha shader
As the new convert shader can do everything this shader could, use it
instead.
2024-07-11 14:57:20 +02:00
Matthias Clasen
a78796f22c gpu: Add a color convert shader
This shader converts between two color states, by using the
same functions that we use on the cpu. The conversion to perform
is passed as part of the variation.

As premultiplication is part of color states on the shader, we also
encode the premultiplication in the shader.
And because opacity is a useful optimization, we also allow setting
opacity.

For now, the only possible color states are srgb and srgb-linear.
2024-07-11 14:57:20 +02:00
Benjamin Otte
4fa6f791f4 cairo: Use the draw context's color state
This just passes through the sRGB set by the GDK backends instead of
hardcoding sRGB, so no functional changes.
2024-07-11 14:57:20 +02:00
Benjamin Otte
6287eaa745 cairo: Add colorstate to GskRenderNode::draw and use it
This adds the following:
- ccs argument to GskRenderNode::draw
  This is the compositing color state to use when drawing.

- make implementations use the CCS argument
  FIXME: Some implementations are missing

- gsk_render_node_draw_with_color_state()
  Draws a node with any color state, by switching to its compositing
  color state, drawing in that color state and then converting to the
  desired color state.
  This does draw the result OVER the previous contents in the passed in
  color state, so this function should be called with the target being
  empty.

- gsk_render_node_draw_ccs()
  This needs to be passed a css and then draws with that ccs.
  The main use for this is chaining up in rendernode draw()
  implementations.

- split out shared Cairo functions into gdkcairoprivate.h
  gskrendernode.c and gskrendernodeimpl.c need the same functions.
  Plus, there's various code in GDK that wants to use it, so put it in
  gdk/ not in gsk/

gsk_render_node_draw() now calls gsk_render_node_draw_with_color_state()
with GDK_COLOR_STATE_SRGB.
2024-07-11 14:57:20 +02:00
Benjamin Otte
2ae13229ea colorstate: Add utility function to convert GdkRGBA
This should end up in GdkColor, but that doesn't exist yet.

It's also why the bad name doesn't concern me much.
2024-07-11 14:57:20 +02:00
Matthias Clasen
2879d35f3d gdk: Add a fast-path
Special case u8 RGBA8p, which is the common case.
2024-07-11 14:57:20 +02:00
Benjamin Otte
ab7d969700 gdk: Add color state arg to gdk_texture_download_surface()
All callers set it to SRGB at the moment.
2024-07-11 14:57:20 +02:00
Matthias Clasen
e1031ac5ad gdk: Add gdk_memory_format_convert_color_state
This allows in-place color state conversions.
2024-07-11 14:57:20 +02:00
Benjamin Otte
1b1e7f4296 drawcontext: Make begin_frame() set colorstate + depth
Make begin_frame() set a rendering colorstate and depth, and provide it
to the renderers via gdk_draw_context_get_depth() and
gdk_draw_context_get_color_state().

This allows the draw contexts to define their own values, so that ie the
Cairo and GL renderer can choose different settings for rendering (in
particular, GL can choose GL_SRGB and do the srgb conversion; while
Cairo relies on the renderer).
2024-07-11 14:57:20 +02:00
Matthias Clasen
5a7d7cc9f5 gsk: Show srgb information in verbose output
Show which offscreens are using an srgb format.
2024-07-11 14:57:20 +02:00
Matthias Clasen
4253bb9922 memoryformat: Add test for depth merging
We want to ensure a few invariants:
- merge (a, a) == a
- merge (a, b) == merge (b, a)

Add tests to verify that this is now the case.
2024-07-11 14:57:20 +02:00
Benjamin Otte
1bbf5f7a17 gdk: Add GDK_MEMORY_NONE depth
That's basically the "undefined" value. We need that when drawing
nothing, which so far only happens with empty container nodes.

But empty container nodes can be children of other nodes, and that makes
things propagate. So instead of catching them, force the whole rest of
the code to deal with an undefined depth.

We also can't just set a random depth, because that will cause merging
to fail.
2024-07-11 14:57:20 +02:00
Benjamin Otte
9abc83fdad gdk: Make gdk_memory_depth_merge() use a table
This makes it clearer how depths are merged.

Also use the actual desired merge modes, the previous code had some
weird behaviors.
2024-07-11 14:57:20 +02:00
Matthias Clasen
8d5325b816 glx: Create srgb drawables if possible
Make our visual selection code prefer fbconfigs that are
'srgb framebuffer capable', and mark the surface as 'is srgb'
in this case.

This arranges things so that GSK knows not to use an offscreen
for converting contents back to srgb in the end.
2024-07-11 14:57:20 +02:00
Matthias Clasen
ad6fd451fb gdk: Create our egl surface with srgb colorspace
For GDK_MEMORY_U8_SRGB depth, try to create an SRGB surface.

This requires the EXT_KHR_gl_colorspace extension, which
isn't super-common in the wild (37%), so we fall back to regular U8 if
that fails.

But if we have the extension, create our egl surface with the
srgb colorspace, and report that fact in gdk_surface_gl_is_srgb().
2024-07-11 14:57:20 +02:00
Matthias Clasen
db3b3c62bb ngl: Mark backbuffers as srgb
When the surface tells us that a surface is using an sRGB backbuffer,
set the corresponding flag on the backbuffer.
2024-07-11 14:57:20 +02:00
Matthias Clasen
dfd181d7d5 gdk: Add gdk_surface_get_gl_is_srgb()
This is a way to query whether the framebuffer we use is using GL_SRGB
or equivalent. Currently, it just returns FALSE.
2024-07-11 14:57:20 +02:00
Matthias Clasen
de76045939 vulkan: Mark swapchain images as GSK_GPU_IMAGE_SRGB
Detect if an SRGB format is in use and mark the images as such.

So far this doesn't happen, but once it does, things will work.
2024-07-11 14:57:20 +02:00
Benjamin Otte
b707568fc1 egl: Pass depth through the fbconfig selection code
We still only differentiate between high bit depth or not, but we now
choose at the end instead of the start, which makes it easier to adapt
to a different method of choosing.
2024-07-11 14:57:20 +02:00
Benjamin Otte
16c29a7db5 texture: Add gdk_texture_get_depth()
... and use it.
2024-07-11 14:57:20 +02:00
Benjamin Otte
b5b0002d24 rendernode: Return the right depth for colors
This makes sure we return U8_SRGB for GdkRGBA colors with linear
compositing.
2024-07-11 14:57:19 +02:00
Benjamin Otte
127b92e3db color_state: Make U8_SRGB the depth for COLOR_STATE_SRGB
This will only be used with linear compositing, so we force U8 when
we're not compositing linear.
2024-07-11 14:57:19 +02:00
Benjamin Otte
a7ceb8ce66 gdk: Add GDK_MEMORY_U8_SRGB depth
This is an experiment for now, but it seems that encoding srgb inside
the depth makes sense, as we not just use depth to decide on the
GL fbconfigs/Vulkan formats to pick, depth also encodes how the [0...1]
color values are quantized when stored.

Let's see where this goes.
2024-07-11 14:57:19 +02:00
Benjamin Otte
6dea23128a gpu: Add the GSK_GPU_IMAGE_SRGB flag
This commit just adds the flag, but I wanted to make it an individual
commit to explain the purpose:

The SRGB flag is meant to be used for images that have an SRGB format.
In Vulkan terms, that means VK_FORMAT_*_SRGB.
In GL, it means GL_SRGB or GL_SRGB_ALPHA.

As these formats have been madatory since GL 3.0, we can (ab)use them
uncoditionally. Images in these formats are renderable, too, so it's
not just usable for uploading.

What these images allow is treating the data as sRGB while shaders
access them as linear, thereby getting sRGB<=>linear conversions for
free.

It is also possible to switch off the linearization of these images and
treat them as sRGB, which allows all sorts of shenanigans, though one
has to be careful if that turning off applies to the relevant GL/Vulkan
code in question.
2024-07-11 14:57:19 +02:00
Matthias Clasen
5297c5f2ee gdk: Give textures a color state
Adds gdk_texture_get_color_state() and GdkTexture::color-state property.

All texture implementations initialize the property to SRGB for now.
2024-07-11 14:57:19 +02:00
Benjamin Otte
bdb6b10be8 colorstate: Add gdk_color_state_get_rendering_color_state()
Returns the linear color state that renderers should render in when
this is the target color state.

We disable this function unless linear compositing is enabled and just
return @self by default.
2024-07-11 14:57:19 +02:00
Benjamin Otte
7f9031eae8 colorstate: Add gdk_color_state_get_no_srgb_tf()
This function checks if the colorstate uses an sRGB transfer function
as final operation. In that case, it is suitable for use with GL_SRGB
(and the Vulkan equivalents).

We disable this function (by always returning NULL) unless linear
compositing is enabled, because this function is used to transition
textures and framebuffers to their linear counterparts.
2024-07-11 14:57:19 +02:00
Matthias Clasen
aa746bc0c8 gdk: Add GdkColorState
This is mostly an empty shell for now. We only have static instances
for srgb and srgb-linear, which we will use as markers during our
node processing.

In the future, this object may grow more instances, as well as the
ability to create them from and save them to icc profiles or cicp
data. And a color conversion API.
2024-07-11 14:57:19 +02:00
Benjamin Otte
01ca59ea91 gdk: Add GDK_DEBUG=linear for experimental linear rendering
This is a temporary solution to allow testing how well linear rendering
already works while refactoring code.

This will be removed once linear rendering is the default.
2024-07-11 14:57:19 +02:00
Benjamin Otte
2f4e19d514 gdk: Allow querying GL SRGB formats
Nobody is using this yet.
2024-07-11 14:57:19 +02:00
Benjamin Otte
8d5224eba7 gdk: Allow querying Vulkan SRGB formats
Nobody is using this yet, this is just infrastructure.
2024-07-11 14:57:19 +02:00
Benjamin Otte
c8436d3c1e Merge branch 'wip/otte/pretend-gl-is-dmabuf' into 'main'
Handle GL textures like dmabuf textures when possible

See merge request GNOME/gtk!7439
2024-07-11 12:55:05 +00:00
Benjamin Otte
1273413c7b vulkan: Import GL textures via dmabufs
If the GL texture is exportable to a dmabuf, we can just use our dmabuf
importing code to get that texture into Vulkan.
There is no need to go via host memory in that case.

And if it doesn't work, we just fall back, like before.
2024-07-11 14:14:35 +02:00
Benjamin Otte
ef3f48a2be vulkan: Refactor gsk_vulkan_image_new_for_dmabuf()
It now works with just a dmabuf and doesn't take a texture anymore.

Which means it can be used from other codepaths in the future.
2024-07-11 14:14:35 +02:00
Benjamin Otte
4b1bca8b6e subsurface: Support GL textures via dmabuf export
We have code with proper error handling for dmabuf export, we can just
try to use it.

And if it doesn't work, we don't offload the texture like before.

But it does work - at least for me.
2024-07-11 14:14:35 +02:00
Benjamin Otte
2478dd8322 subsurface: Split a function
I want to call the inner one from a different place in future commits.
2024-07-11 14:14:35 +02:00
Benjamin Otte
4c1edd3881 subsurface: Change error handling
Instead of hardcoding which textures we presumably support, just try
creating a buffer and use the failure of that for the error message.

This makes the error message a bit less obvious, but it makes it
possible to refactor the get_buffer() code without having to deal with
the error path.

If we want to improve the debug message, we can start putting debug
messages into the get_buffer() function.
But I think this is good enough.
2024-07-11 14:14:35 +02:00
Benjamin Otte
14541480ae Merge branch 'wip/otte/for-main' into 'main'
testsuite: Add test for empty glshader node

See merge request GNOME/gtk!7438
2024-07-11 12:09:02 +00:00
Benjamin Otte
fff78b60e9 gpu: All nodes are implemented
Unimplemented nodes are a failure now.

We make this a soft failure with a g_warning() so that during
development when adding new nodes, the renderer doesn't instantly crash,
but instead prnts a warning.

But we do consider unimplemented nodes a bug now.

Because of that, add_fallback_node() is now renamed to add_cairo_node().
2024-07-11 13:34:37 +02:00
Benjamin Otte
9abc7fc80b gpu: Don't hand Cairo invalid nodes
When encountering an invalid node, exit asap. Don't draw it with Cairo,
Cairo won't know what to do with it either.
2024-07-11 13:34:37 +02:00
Benjamin Otte
d8059ebdd2 gpu: "Implement" GL shader nodes
Instead of falling back to Cairo, draw the pink error rectangle
directly.
2024-07-11 13:34:36 +02:00
Benjamin Otte
1001445d3e testsuite: Add test for empty glshader node
Everyone should draw the error pink here, because that's what the
renderers not supporting it do, and it's also what the default shader
does.

So no matter if a renderer supports GL shaders or not, it should draw
the same pink.
2024-07-11 13:34:36 +02:00
Benjamin Otte
fff72cf322 dmabuf: Add gdk_dmabuf_close_fds()
... and use it inside GtkGLArea

I made thatfunction available outside of HAVE_DMABUF so I don't need to
wrap it in ifdefs.
2024-07-11 13:34:36 +02:00
Matthias Clasen
fd9306a282 Merge branch 'vulkan-build-fix' into 'main'
build: Don't enable vulkan without glslc

Closes #6846

See merge request GNOME/gtk!7437
2024-07-11 11:25:47 +00:00
Matthias Clasen
7c0c2a8085 Merge branch 'wip/otte/dihedral' into 'main'
gpu: Add support for "dihedral" transforms

See merge request GNOME/gtk!7436
2024-07-10 23:47:39 +00:00
Matthias Clasen
b5b58ced2a Add gdk_dihedral_get_name
And use it everywhere we want to print out debug spew about
dihedral transforms.
2024-07-10 22:11:13 +02:00
Matthias Clasen
8c988a7b07 Take all transforms into account
When determining which way is up for the offloaded texture, we
must take all transforms into account - the ones outside the
subsurface node, and the ones inside.
2024-07-10 22:11:13 +02:00
Matthias Clasen
e68f58940c offload: Add more debug spew
Print what transform we are passing to the compositor.
Helps for debugging transforms.
2024-07-10 22:11:13 +02:00
Benjamin Otte
4f2b639a24 gpu: We can handle 90 degree rotations quite easily 2024-07-10 22:06:24 +02:00
Benjamin Otte
3e01924ca3 gpu: Handle dihedral transforms in occlusion culling 2024-07-10 22:06:24 +02:00
Benjamin Otte
3841ae935c surface: Cleanup 2 nonexisting functions from header 2024-07-10 21:34:12 +02:00
Matthias Clasen
4d2884bde7 offload: Support dihedral transforms
When looking for the texture transform, allow dihedral transforms,
and pass them along when attaching to the subsurface.
2024-07-10 21:34:12 +02:00
Matthias Clasen
a4a7255216 subsurface: Fix a precondition
When checking that the texture fits the area, take the transform
into account.
2024-07-10 21:34:12 +02:00
Benjamin Otte
6065165060 Add gdk_dihedral_swaps_xy
This function determines if a dihedral transform swaps x and y.
2024-07-10 21:34:12 +02:00
Matthias Clasen
61c22d1c72 Add a test for dihedral transforms
This reveals that the multiplication and inverse aren't quite
right.
2024-07-10 21:34:12 +02:00
Benjamin Otte
efacf2ff09 testsuite: Add tests for dihedral transforms
Just to make sure stuff shows up in the right place.
2024-07-10 21:34:12 +02:00
Benjamin Otte
9272bf96f6 gpu: Handle affine transforms without touching matrix
By moving negative affines to be treated like dihedrals, because they
also need support of the modelview, we can free up the affine branch for
doing work without it.

Not a big win I guess, but it makes scaling more efficient.
2024-07-10 21:34:12 +02:00
Benjamin Otte
ae3efb2d2f gpu: Implement transform support for dihedral transforms
This allows handling them without ever needing to offscreen for losing
the clip, because the clip can always be transformed.

Also, all the optimizations keep working, like occlusion culling,
clears, and so on.

The main benefit of this work is the ability for offloading to now
handle dihedral transforms of the video buffer.

The other big advantage is that we can now start our rendering with a
dihedral transform from the compositor.
2024-07-10 21:34:12 +02:00
Benjamin Otte
b9ecae84f5 gpu: Shuffle some transform flags around
No need to check for negative numbers now that we can just use the
category that doesn't give us any.
2024-07-10 21:34:12 +02:00
Benjamin Otte
cd3286c71a gpu: Switch to GskFineTransformCategory
This is purely replacing the enums, no functional changes.
2024-07-10 21:34:12 +02:00
Benjamin Otte
83c2766e3f rendernode: Handle rotation transforms in opacity calculations
Tests included.
2024-07-10 21:34:12 +02:00
Benjamin Otte
5f719c8ea3 transform: Implement transform_point() for dihedrals
No longer using the default path and risking rounding issues.
2024-07-10 21:34:12 +02:00
Benjamin Otte
555f7d5404 transform: Implement transform_bounds() for dihedrals
No longer using the default path and risking rounding issues.
2024-07-10 21:34:12 +02:00
Matthias Clasen
73b2913be3 build: Don't enable vulkan without glslc
We need glslc to compile the shaders.

Fixes: #6846
2024-07-10 12:28:30 -04:00
Benjamin Otte
3bcfc5539c transform: Add gsk_transform_to_dihedral()
I hate everything about this.

Is is xy or yx now?
Do I need to combine(a, b) or combine(b, a)?
2024-07-10 14:38:48 +02:00
Benjamin Otte
4cfcc7e521 wayland: Check that the enums match
They do, but better safe than sorry
2024-07-10 12:36:07 +02:00
Benjamin Otte
3221a8bdab gdk: Rename GdkTextureTransform to GdkDihedral
... and put it into its own header.

We want to use it in more places and the name and location are awkward.
2024-07-10 12:36:07 +02:00
Benjamin Otte
930f059f5e transform: Introduce GskFineTransformCategory
This category does a finer-grained categorization than
GskTransformCategory, but it is deliberatedly made to allow
easy backwards compatibility.

The reason for the categories is that they fit our renderers more
fine.

In particular, it allows implementing wl_output_transform support more
efficiently, thereby allowing rendering buffers the right way for
rotated phone screens or monitors.
2024-07-10 12:36:07 +02:00
Benjamin Otte
bd3e596243 Merge branch 'wip/otte/for-main' into 'main'
rect: There's no coverage witout overlap

Closes #6849

See merge request GNOME/gtk!7435
2024-07-09 23:39:51 +00:00
Benjamin Otte
9a6e61e510 rect: There's no coverage witout overlap
The rectangles need to touch/overlap in both directions, otherwise
there's no coverage that covers both rectangles.

Test included.

Fixes rendering glitches in various apps when redrawing.

Fixes: #6849
2024-07-10 00:28:33 +02:00
Matthias Clasen
56d2d65e25 Merge branch 'css-color-fixes' into 'main'
css: Resolve color coordinates properly

Closes #6833

See merge request GNOME/gtk!7430
2024-07-09 14:20:00 +00:00
Martin
ae08963acc Update Slovenian translation 2024-07-09 03:59:54 +00:00
Matthias Clasen
ed4f51436c Merge branch 'matthiasc/for-main' into 'main'
Add a missing include

Closes #6842

See merge request GNOME/gtk!7433
2024-07-09 03:04:25 +00:00
Matthias Clasen
7837354c6c Add a missing include
When building without Vulkan, we don't get this include for free.
So add it explicitly.

Fixes: #6842
2024-07-08 22:18:11 -04:00
Benjamin Otte
a203a28de0 Merge branch 'wip/otte/for-main' into 'main'
First set of occlusion culling fixes improvements

See merge request GNOME/gtk!7431
2024-07-08 21:51:46 +00:00
Benjamin Otte
5dc6f134c5 gpu: Make offscreening code use process()
... instead of init_draw(); add_node(); finish_node();

We hook into the infrastructure one step earlier and close to where the
default renderer_render() and renderer_render_texture() arrive in the
nodeprocessor.

Why is this relevant?
Because process() does occlusion culling.

TL;DR: offscreens do culling now
2024-07-08 23:22:55 +02:00
Benjamin Otte
6daeb7e504 gpu: Transition exported textures into GENERAL layout
We import them as general, so they should be exported like that.

This was a longstanding issue that I never got around to fixing and I'm
touching this code anyway atm.
See commit 3aa6c27c26 for more details.
2024-07-08 23:22:41 +02:00
Benjamin Otte
fcf59ad135 gpu: Allow NULL as clear color
NULL disables clearing. We only implement this for GL as in Vulkan we'd
need to create different renderpasses with different attachment
descriptions and that would require more plumbing.
2024-07-08 23:07:36 +02:00
Benjamin Otte
1dd905d976 gpu: Fix wrong rect check in occlusion fallback path
We need to check that the clip is inside the opaque region, not that the
opaque region is inside the clip.

Test included, using the only not that hits the fallback path with an
opaque region smaller than its bounds.
2024-07-08 23:07:36 +02:00
Benjamin Otte
155f7cdeec gpu: Chceck if a container node is opaque as fallback
Sometimes container nodes contain lots of overlapping opaque items. In
that case we can use the container node itself as the first node even
though none of the children cover the whole paint area.

The use case for this is a grid of cells like in a terminal where all
the cells are opaque and we want to avoid drawing the background behind
them.
2024-07-08 23:07:36 +02:00
Matthias Clasen
960967623a Add css value tests
Add some tests that check the details of calling compute() and
resolve() on number and color values.
2024-07-08 16:47:29 -04:00
Matthias Clasen
3c963f65a2 css: Short-circuit resolve like compute
This is the same idea: if the value doesn't contain currentcolor
(ie is already resolved), no need to resolve it again.
2024-07-08 16:09:35 -04:00
Matthias Clasen
168203ab0c css: Fix a font-weight parser test
0 is not a valid font weight.
2024-07-08 16:09:35 -04:00
Matthias Clasen
f2fff53169 testsuite fixes 2024-07-08 16:09:35 -04:00
Matthias Clasen
f74b8f715a css: Fix legacy relative colors
If the color was specified using the legacy rgb(), we must accept
values in the range [0, 255]. But when serializing it as
color(srgb...), we must scale those values to [0, 1].

Update the one affected test.
2024-07-08 16:09:35 -04:00
Matthias Clasen
aeac2b547f css: Fix confusion about computed numbers
As for colors: is_computed means that calling compute() won't change
the value. We need to make sure that after calling compute(), the
flag is set.
2024-07-08 16:09:35 -04:00
Matthias Clasen
827aa9ca05 css number value: More color coord fixes
Always use gtk_css_number_value_new_color_component to create
new color component values, and make that function simplify things
as far as possible.
2024-07-08 16:09:35 -04:00
Matthias Clasen
95c21acec1 css: For color, inherit the used value
When the color property is inherited, don't resolve the inherited
value to find the used value, just inherit the used value of the
parent style.

This is what browsers do, even though the spec says something else.

Update the currentcolor4 style test to reflect these changes.

Fixes: #6833
2024-07-08 14:53:00 -04:00
Matthias Clasen
4d035dce5d css: Fix confusion about computed colors
We were not handling the is_computed and contains_current_color
flags correctly when creating new color values. Set these flags
propertly. is_computed means: calling compute() won't change the
value. contains_current_color means what it says.
2024-07-08 14:53:00 -04:00
Matthias Clasen
7f6dce1c22 Add another css style test 2024-07-08 14:53:00 -04:00
Matthias Clasen
58568a36ce css: Handle relative colors properly 2024-07-08 14:53:00 -04:00
Matthias Clasen
9c2a2f01b7 css: Resolve color coordinates properly
We were not resolving currentcolor in color coordinates.

Implement resolve for number values to fix that.
2024-07-08 14:53:00 -04:00
Matthias Clasen
657e536941 Add more currentcolor css tests 2024-07-08 13:51:26 -04:00
Matthias Clasen
a81b6ea6af Merge branch 'fix-fallocate-fail' into 'main'
wayland: Work around fallocate bugs

See merge request GNOME/gtk!7429
2024-07-08 17:24:16 +00:00
Matthias Clasen
1887504666 wayland: Fall back to ftruncate
We are seeing posix_fallocate fail with ENOENT occasionally.
This shouldn't happen according to the docs, but it does. Fall back
to ftruncate if it does. It gives us less guarantees, but it makes
the ci not fail so much.
2024-07-08 12:36:46 -04:00
Matthias Clasen
8a61b01c06 Merge branch 'wip/otte/rendernode-opaque' into 'main'
Implement occlusion culling

See merge request GNOME/gtk!7425
2024-07-08 13:53:43 +00:00
Benjamin Otte
6d564075f3 gsk: texture-scale nodes with non-integer bounds aren't opaque
Due to the way the intermediate offscreen gets drawn, we might end up
with seams at the edges.

And I don't think it's worth spending more time on than saying "not
opaque".

Fixes the compare-render testsuite

New testcase included.
2024-07-08 15:28:14 +02:00
Benjamin Otte
4cdf7aa65a rendernode: Add containernode->opaque and fill it at startup
We want to operate with opacities, so it makes sense to have this radily
available.

And we're doing a walk over all children on creation anyway, so why not
just capture the rect there.
2024-07-08 15:28:14 +02:00
Benjamin Otte
329dc9e0cf gpu: Change get_opaque() implementation of containers
We want to be able to express opaque grids. This means that the app
provides either a row of columns of opaque nodes or a column of rows,
and then the containers will magically figure it out.

The main use case for this is terminals, which are uilt using cells. And
when there's a transparent background configured but the contents are
opaque, it'd be nice if we could figure that out.

Also remove the 80% requirement. It is rather arbitrary and while it
helps for some cases, the aforementioned grid would suffer.
2024-07-08 15:28:14 +02:00
Benjamin Otte
e02de45537 gpu: Add GSK_GPU_DISABLE=occlusion
This simply disables add_first_node() usage.

Useful to find bugs in its implementation or track performance
with/without it.
2024-07-08 15:28:14 +02:00
Benjamin Otte
29fbda49bb gpu: Implement add_first_node() for rounded clip nodes
This is a bit more expensive than clip nodes, because we have to check
the rounded edges are outside of the clip.
2024-07-08 15:28:14 +02:00
Benjamin Otte
1b155341bd gpu: Implement add_first_node() for clip nodes
Clip nodes often appear in the widget tree.

And the implementation can be trivial because of the sanity checks
already performed before calling the vfunc.
2024-07-08 15:28:14 +02:00
Benjamin Otte
96c02c1eb4 gpu: Implement add_first_node() for transform nodes
This is required because transform nodes appear everywhere.

We just exit for all transforms that can't transform the clip rect
losslessly. Both because they are rare and because we'd make the
coverage possibilities much lower.
2024-07-08 15:28:14 +02:00
Benjamin Otte
116d662e0f gpu: Add early exit to add_first_node()
A node must cover the full clip region to be eligible for being the
first opaque node.

Do an early exit for all nodes that aren't big enough for that.
2024-07-08 15:28:14 +02:00
Benjamin Otte
d81cd4751f gpu: Add add_first_node for colors
Color nodes can set the default background of the renderpass, instead of
doing a clear op or running a shader.
2024-07-08 15:28:14 +02:00
Benjamin Otte
dd33068943 gpu: Implement add_first_node for containers
Containers can walk the list of children back to front, trying to find
the topmost node that fully covers the viewport.

And then they can skip drawing all the nodes before that one.
2024-07-08 15:28:14 +02:00
Benjamin Otte
09c1e51b8a gpu: Add gsk_gpu_node_processor_add_first_node()
Asks a node to add itself if it is fully covering the clip rectangle.
In that case, it is the first node that needs to be added.

If the node is not fully covering the clip, it should not draw itself,
because there might be stuff needing to be drawn below.

If a node adds itself, it should call gsk_gpu_render_pass_begin_op().
2024-07-08 15:28:14 +02:00
Benjamin Otte
af9a9422c4 gpu: Allow passing a background color to renderpasses
It's not used yet, everybody is passing GDK_RGBA_TRANSPARENT.
2024-07-08 15:28:14 +02:00
Benjamin Otte
df3c85ea7f gpu: Move renderpass handling into the nodeprocessor
There's no need for the frame to do this.
2024-07-08 15:28:14 +02:00
Benjamin Otte
b14a115fc0 container: Implement get_opaque_rect()
We find the first child that covers >80% of the container and return
that.

This is a nice speedup for the common case of a GtkWindow being covered
by a large opaque background.
It will fall apart for fancy themes that play with transparency or for
small windows because the shadow region gets too large.

But then we just scan the whole node tree.

We could think about adapting the 80% number, because that wasn't chosen
with any real scientific data behind it.
2024-07-08 15:28:14 +02:00
Benjamin Otte
355a88d002 roundedclip: Implement get_opaque_rect
This takes both the vertical and horizontal rectangle that isn't
covering the rounded corners and intersects both with the child's opaque
rect.
And then it returns the larger of the two.

This means the small slices of a window near the left/right (or
top/bottom) will never be covered, but if we wanted that, we'd need to
use something else than a rectangle - either a region or actually a
rounded rect.

But that is a lot more expensive to implement.
2024-07-08 15:28:14 +02:00
Benjamin Otte
1014b3d972 rendernode: Implement a bunch of simple opque_rect getters
Not much to write home about here.
2024-07-08 15:28:14 +02:00
Benjamin Otte
1a2b1575d6 rendernode: Add fully-opaque flag
Allows rendernodes to advertise themselves as fully opaque.

This is used as a fast path for get_opaque_rect().
2024-07-08 15:28:14 +02:00
Benjamin Otte
cc25fdf602 testsuite: Add test runner for opacity tests
Tests are node files dumped into testsuite/gsk/opaque
They are named "name-X-Y-W-H.node" with X Y W H being the expected
opaque rectangle or "name.node" if there is no opacity.

A simple example is included here.
2024-07-08 15:28:14 +02:00
Benjamin Otte
444eb2630c rendernode-tool: Print opaque rect in "info" 2024-07-08 15:28:14 +02:00
Benjamin Otte
9c032bec89 gsk: Add gsk_render_node_get_opaque_rect()
Gets a rectangle inside the rendernode that is opaque.

This function only adds the API. So far, no implementation exists.
2024-07-08 15:28:14 +02:00
Matthias Clasen
5a59548d72 Merge branch 'fix-offload-transforms' into 'main'
offload: Don't assert things that might fail

Closes #6824

See merge request GNOME/gtk!7407
2024-07-08 12:58:28 +00:00
Matthias Clasen
39913c2001 Merge branch 'wip/otte/for-main' into 'main'
rendernode-extract: png files need .png extension

See merge request GNOME/gtk!7428
2024-07-08 12:29:53 +00:00
Matthias Clasen
a858736516 Merge branch 'matthiasc/for-main' into 'main'
ci: Add another offload test

See merge request GNOME/gtk!7414
2024-07-08 12:16:49 +00:00
Matthias Clasen
880c33a777 offload: Don't assert things that might fail
We can in fact meet complex transforms here. Asserting that they
are simple doesn't make it so. Instead, simply bail out if a
transform is too complex; in this case we can't offload anyway,
so no need to walk the tree further.

Test included.

Fixes: #6824
2024-07-08 08:15:02 -04:00
Matthias Clasen
c32ab9440d Merge branch 'document-save-icon' into 'main'
Add missing icon

See merge request GNOME/gtk!7416
2024-07-08 11:01:00 +00:00
Matthias Clasen
3a97b44321 Merge branch 'glshader-docs-typo' into 'main'
gskglshader: Fix typo in deprecation docs

See merge request GNOME/gtk!7426
2024-07-08 10:58:33 +00:00
Benjamin Otte
2f18d5584d rendernode-extract: Save files with the same name as the node
Instead of "gtk-foo.ext", use "filename-foo.ext". That avoids confusion
when having extracted things before.
2024-07-08 12:29:37 +02:00
Benjamin Otte
287b27dad3 rendernode-extract: png files need .png extension
I had a lot of ttf files suddenly. And there was no text in the node.
2024-07-08 12:29:37 +02:00
Benjamin Otte
33f0f2a2b1 rendernode-extract: Remove unnecessary check 2024-07-08 12:29:37 +02:00
Benjamin Otte
bf6ba18048 Merge branch 'wip/otte/for-main' into 'main'
vulkan: Can't blit to/from formats with a swizzle

See merge request GNOME/gtk!7427
2024-07-08 09:22:25 +00:00
Benjamin Otte
058252e895 vulkan: Can't blit to/from formats with a swizzle
Fixes grayscale images appearing red on some hardware.

Related: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11467
2024-07-08 10:51:37 +02:00
Benjamin Otte
c594de8302 vulkan: Code more defensively
Check for identity swizzle too, even though we don't use it.
2024-07-08 10:51:37 +02:00
Sebastian Dröge
8eaf05a3ef gskglshader: Fix typo in deprecation docs 2024-07-08 09:21:43 +03:00
Matthias Clasen
9736bea29f Merge branch 'css-image-fallback-fixes' into 'main'
css: Fix fallback image resolution

Closes #6844

See merge request GNOME/gtk!7423
2024-07-08 00:32:38 +00:00
Matthias Clasen
ea392cf2b6 css: Fix the fallback image implementation
If fallback->used is unset, we must not use it to index the array.

Fixes: #6844
2024-07-07 16:40:53 -04:00
Benjamin Otte
b0f8550b01 Merge branch 'wip/otte/for-main' into 'main'
gpu: Refactor parts of nodeprocessor

See merge request GNOME/gtk!7421
2024-07-07 14:01:55 +00:00
Benjamin Otte
ba05963729 gpu: Make get_node_as_image() always return premultiplied images
We wanted premultiplied images in all cases anyway, and moving that
requirement means we can also move the caching code for re-caching
textures into the texture specific code.
2024-07-07 14:39:07 +02:00
Benjamin Otte
f14f7e7df6 gpu: Add GSK_GPU_DISABLE=offscreen
This uses offscreens for every call to get_node_as_image().

This is useful both for benchmarking benefits of those implementations
as well as checking that the node-specific paths produce identical
results.
2024-07-07 14:39:07 +02:00
Benjamin Otte
daa97d4b79 gpu: Refactor functions
gsk_gpu_node_processor_ensure_image() was a weird amalgamation of stuff
withe weird required and disallowed flags.

Refactor it to make the two operations we actually do there more
explicit: Removing straight alpha and generating mipmaps.

This untangling is also desirable in the future when we also want to
handle colorstates here.
2024-07-07 14:39:07 +02:00
Benjamin Otte
4822b85cb0 gpu: Make gsk_gpu_node_processor_get_node_as_image() more restrictive
Always return premultiplied images.

2 fallback cases for clip and transform nodes did not require that. If
those cases turn out to be important, they can call
gsk_gpu_get_node_as_image() directly as that's the more flexible option.
2024-07-07 14:39:07 +02:00
Benjamin Otte
7f61d7ac8b gpu: Implement get_node_as_image() for subsurface nodes
Pass through to the child instead of offscreening.

I mainly implemented it for the assertion, because this might be a
sneaky way to introduce bugs without exhaustive checking that we don't
offload stuff that is offscreened.

No actual bugs that I'm aware of, so no tests.
Strictly defensive coding.
2024-07-07 14:39:04 +02:00
Benjamin Otte
010ca5feef gpu: Implement get_node_as_image() for debug nodes
Just pass through to the child instead of offscreening.
2024-07-07 12:54:05 +02:00
Benjamin Otte
31a907be35 gpu: Make sure textures used as image are mipmapped
When getting a texture as image, we were always returning the texture
unconditionally.

However, we want to mipmap textures when the scale factor is too large,
and this code path did not do that.

The same codepath on the GL renderer doesn't do that either, so the test
is disabled for it.
2024-07-07 12:54:05 +02:00
Benjamin Otte
ab37fed974 gpu: vfuncify get_node_as_image()
The switch statement was ugly.

Plus, the code should be close to the add_node() vfunc implementation,
so they can be modified together.

See future commits for an example where this matters.
2024-07-07 12:54:05 +02:00
Benjamin Otte
10a7650411 testsuite: Generate mask correctly
There's a corner case with width/height being exactly 25 pixels.
And of course I was hitting it with one of my tests.
2024-07-07 12:54:05 +02:00
Benjamin Otte
fc4c6525e6 Merge branch 'wip/otte/for-main' into 'main'
gpu: Remove the ubershader

See merge request GNOME/gtk!7419
2024-07-07 10:52:51 +00:00
Benjamin Otte
d7308f2d73 gsk: Rename GSK_DEBUG=glyphcache to GSK_DEBUG=cache
1. I mistype it all the time
2. It's shorter
3. We use it for all caching these days, not just glyphs.
2024-07-07 05:24:45 +02:00
Benjamin Otte
ead566b841 rendernode-tool: Hide window background when --undecorated
We want to only show the node, nothing else. So getting rid of as much
CSS as possible is good.
2024-07-07 05:19:32 +02:00
Benjamin Otte
ecc2e02453 rendernode-tool: Add a GtkWindowHandle
Make the whole window area draggable, like usually the titlebar.

This is especially useful with --undecorated.
In that case we need to make the window non-resizable though, becuase
otherwise it can be accidentally maximized and whatnot.
2024-07-07 05:19:32 +02:00
Benjamin Otte
012c4b9425 gpu: Remove the ubershader
It didn't bring any noticable benefits and it isn't compatible with the
way we intend to do colorstate support.

And nobody seems to want to spend time on it, so let's get rid of it.

We can bring it back later if someone wants to work on it.
2024-07-07 05:19:32 +02:00
Benjamin Otte
be8fef9811 Merge branch 'wip/otte/for-main' into 'main'
rendernode-tool: Show the whole node

See merge request GNOME/gtk!7417
2024-07-05 19:46:39 +00:00
Scrambled 777
2938b48939 Update Hindi translation 2024-07-05 17:11:31 +00:00
Benjamin Otte
16c2e0a642 gl: Use GdkTextureDownloader
Cairo surfaces are so outdated.
2024-07-05 13:55:18 +02:00
Balló György
017510ea5f Add missing icon
The fullcolor 'document-save' icon is used in the print dialog for the
'Print to File' element.
2024-07-05 13:22:54 +02:00
Benjamin Otte
c43c0275e3 testsuite: Improve memorytexture printing code
* The variables are const. Keep them const when casting

* Print float16 values

* Print integer values as hex. This is better for detecting
  byteswapping, off by one, and such. Besides, we tend to use values
  that have the same 2 hex digits, so detecting corruption is also easy.
2024-07-05 13:16:56 +02:00
Benjamin Otte
df5d233155 testsuite: Print the right pixel
Typo made us pass the wrong values
2024-07-05 13:16:56 +02:00
Benjamin Otte
a8238c2251 testsuite: Make png file argument optional
Just default to the node file but with a .png extension.
2024-07-05 10:43:28 +02:00
Benjamin Otte
c12d1fe29c rendernode-tool: Show the whole node
When the node had negative coords, those were cut off.

Translate by the node's origin to avoid this.
2024-07-05 05:49:15 +02:00
Benjamin Otte
347cdc63f8 Merge branch 'wip/otte/deprecate-gl-shader' into 'main'
gsk: Deprecate GskGLShader and the rendernode

See merge request GNOME/gtk!7415
2024-07-04 22:04:57 +00:00
Benjamin Otte
32625381fa gsk: Deprecate GskGLShader and the rendernode
The new renderers don't support them due to the required complexity of
integrating them with Vulkan and the assumptions those nodes make about
the renderer (the GL renderer exports its internal APIs into the
GLShader).

There haven't been any complaints that I'm aware of since 4.14 was
released where the default renderer does not support the nodes, so usage
in public seems to be close to nonexistant.

The 2 uses I know of were workarounds about missing features in GTK that
have stopped since GTK now supports them:

1. GStreamer used in to do premultiplication when the old GL renderer
   did not do so in hardware but on the CPU.
2. Adwaita used it for masking before the mask node wa added in 4.10.
2024-07-04 21:28:06 +02:00
Matthias Clasen
350f9e2636 wayland: Add more debug spew
Trying to track down why cursor theme loading fails in ci.
2024-07-04 10:05:13 -04:00
Matthias Clasen
4d9d50d8e1 build: Add a note about abi and backendsa
Trying to scare people away from playing with fire.

Related: #6832
2024-07-04 09:40:21 -04:00
Matthias Clasen
106db1a9be docs: Fix some links 2024-07-04 09:40:21 -04:00
Emmanuele Bassi
e6d22fd8df Merge branch 'ebassi/docs-wiki-links' into 'main'
Drop references to the GNOME wiki from the docs

See merge request GNOME/gtk!7413
2024-07-04 12:23:18 +00:00
Ekaterine Papava
8e2de53c3f Update Georgian translation 2024-07-04 11:40:07 +00:00
Emmanuele Bassi
0057af3668 Drop references to the GNOME wiki from the docs
The GNOME wiki is getting decommissioned and archived:

  https://gitlab.gnome.org/Teams/Websites/General/-/issues/311

While the pages will still exist, it's better to direct people to
locations that are actively maintained.
2024-07-04 12:03:19 +01:00
Matthias Clasen
7f7e4ab69e ci: Add another offload test
Sadly, it fails to demonstrate the crash I'm after.
But its still useful to have.
2024-07-04 06:41:09 -04:00
Matthias Clasen
db4f60cc9d Cosmetics 2024-07-04 06:40:52 -04:00
Matthias Clasen
77cf390727 Merge branch 'nullable-widget' into 'main'
eventcontroller: mark get_widget as nullable

See merge request GNOME/gtk!7359
2024-07-04 09:45:42 +00:00
tszymanski
dcadf1422b eventcontroller: mark get_widget as nullable 2024-07-03 21:48:35 -07:00
Matthias Clasen
53ac80d6c8 Merge branch 'matthiasc/for-main' into 'main'
wayland: Add debug spew

See merge request GNOME/gtk!7412
2024-07-04 02:19:54 +00:00
Matthias Clasen
2e9fcdad6e wayland: Add debug spew
Trying to track down ci failures from cursor theme loading.
2024-07-03 21:42:57 -04:00
Benjamin Otte
0f55b3bc18 Merge branch 'wip/otte/for-main' into 'main'
gpu: Split out the cache

See merge request GNOME/gtk!7411
2024-07-03 19:51:10 +00:00
Benjamin Otte
9c249fefc3 gpu: Improve periodic cache debug message
I was watching the log in my terminal and nothing happened.
And I wasn't sure if that was because nothing was printed or because the
same thing was printed every few seconds.

Fix that by printing a timestamp, so that in a few seconds something
else will be printed.
2024-07-03 20:36:56 +02:00
Benjamin Otte
eae7ee6c25 gpu: Track atlas differently
Previously we tracked the dead pixels, but that meant we didn't know the
alive pixels (because there's also unused pixels never accounted for).
And we would free the current atlas randomly due to that.

Now we track if any pixels are alive, and if so, we never gc the current
atlas.
2024-07-03 20:36:56 +02:00
Benjamin Otte
bf7f302ff5 gpu: gc atlas, too
After 60s, we gc the atlas, too. This ensures that after that time, we
free all cache resources, so if an application gets moved to the
background, it will no longer use GPU resources. (Well, at least the
cache won't.)
2024-07-03 19:55:18 +02:00
Benjamin Otte
0d6981bd54 gpu: Make the cache track if it's empty
Only if a non-stale item is in the cache do we consider the cache not
empty.

Once the cache is empty, the device frees it and stops running the
periodic GC.
2024-07-03 19:55:18 +02:00
Benjamin Otte
148d7bcc25 gpu: Don't remove gc timeout unless cache is empty
If the cache isn't empty, we want to rerun the GC.
2024-07-03 19:55:18 +02:00
Benjamin Otte
71161b6352 gpu: Split cache and device
This is for 3 reasons:

1. Separation of concerns
   The device is meant to manage the Vulkan/GL device and check stuff
   like image sizes.
   Caching is not part of that.

2. Refcounting
   Images etc want to reference the device, but the cache wants to
   reference images. If the cache is the device, that's a refcycle.

3. Flexibility
   It's now easier to implement >1 cache, say one per depth or one per
   color state.
2024-07-03 19:55:15 +02:00
Benjamin Otte
dd33a2f280 rendernode: Make sure depth variable has enough bits
This will be relevant when we add new values to it.
2024-07-03 19:55:15 +02:00
Emmanuele Bassi
9d48d684a5 Merge branch 'ebassi/closure-fixes' into 'main'
Use the appropriate annotations for callback closures

See merge request GNOME/gtk!7410
2024-07-03 17:34:48 +00:00
Matthias Clasen
eb252d33a9 Merge branch 'expander-non-child' into 'main'
expander: Don't leave dangling a11y relations

See merge request GNOME/gtk!7409
2024-07-03 17:24:44 +00:00
Emmanuele Bassi
40bdf7e0d4 Use the appropriate annotation for callbacks
All the callback-related annotations must go on the callback parameter:

- scope type
- closure arg-name
- destroy arg-name
2024-07-03 18:04:27 +01:00
Matthias Clasen
6aba047ace expander: Don't leave dangling a11y relations
If we unparent the widget, we should sever a11y relations too.
Otherwise, an a11y implementation might follow them and be surprised
to find a parentless widget (and not in a good way).

Updated tests to not check the relation on an unexpanded expander.
2024-07-03 12:55:15 -04:00
Emmanuele Bassi
554045de6e Use the appropriate annotations for a callback closure
The (closure) annotation with an parameter is meant to be used on the
callback argument, and point to the user data argument.
2024-07-03 17:21:04 +01:00
Emmanuele Bassi
fa42081556 Use the appropriate annotations for callback closures
The unary (closure) annotation is for function pointer types; function
arguments that represent the user data to be passed to the callback are
annotated on the callback argument itself, with (closure arg-name).
2024-07-03 16:57:47 +01:00
Artur S0
54d0bcab71 Update Russian translation 2024-07-03 11:35:15 +00:00
Benjamin Otte
3539128d42 memoryformat: Split out a function
It's used in many places and attaching a name to what it does is useful.
2024-07-03 04:16:56 +02:00
Matthias Clasen
372c68a1c9 Merge branch 'matthiasc/for-main' into 'main'
gsk: Avoid a crash

See merge request GNOME/gtk!7408
2024-07-02 20:19:47 +00:00
Matthias Clasen
f9856d547f gsk: Avoid a crash
The subsurface in subsurface nodes can be NULL, so check before
poking at it.
2024-07-02 15:52:51 -04:00
Matthias Clasen
d0d8f6b5ee Merge branch 'popover-layout-check-fix' into 'main'
popover: Fix invalid width/height check in layout

Closes #6826

See merge request GNOME/gtk!7405
2024-07-02 03:02:18 +00:00
Matthias Clasen
28c91bf767 Merge branch 'ci-catch-segfaults' into 'main'
testsuite: Use catch as testwrapper

See merge request GNOME/gtk!7406
2024-07-02 02:59:46 +00:00
Matthias Clasen
a8bfe4e6f2 Merge branch 'popover-critical-fix' into 'main'
popover: Take shadow size into account in measure

Closes #5782 and #6796

See merge request GNOME/gtk!7403
2024-07-02 02:39:21 +00:00
Matthias Clasen
1f076432db ci: Use catch to capture stacktraces
For now, just try this out for the release build. If it works,
we can add it to the other jobs too.
2024-07-01 22:29:36 -04:00
Matthias Clasen
b6e79a7234 testsuite: Use catch as testwrapper
If we find a binary named catch, use it as test wrapper. This
will be used to capture stacktraces for crashes in ci.
2024-07-01 22:29:36 -04:00
Matthijs Velsink
68b05cadd8 popover: Fix invalid width/height check in layout
Commit a4cc95b2 introduced a check in layout() that closes the popover
if the width or height is smaller than the minimum width or height,
respectively. However, that was using gtk_widget_get_preferred_size(),
which finds out the minimum height for the minimum width and vice versa,
but not the minimum height for the layout width and vice versa. So,
certain popovers were not showing, even though they would not have
generated a critical to begin with.

To fix this, we copy the logic from gtk_widget_allocate() that generates
the criticals, and use that to check if we have a good width/height for
the popover native or not.

Closes #6826
2024-07-02 03:54:08 +02:00
Matthijs Velsink
93c5fb0b31 popover: Take shadow size into account in measure
Commit b9487997 introduced shadows for GtkPopover. These are correctly
subtracted while allocating the child widget, but the child is not
measured with those shadows subtracted (as is correctly done for the
arrow). This can give criticals, for example with some wrapping labels.

To fix this, we subtract the shadow size from the `for_size` before
passing it to the measure() of the child widget.

Closes #5782
Fixes #6796
2024-07-02 02:50:29 +02:00
Benjamin Otte
cfdbf95cb6 Merge branch 'wip/otte/for-main' into 'main'
gdk: Add GDK_N_DEPTHS to the enum

See merge request GNOME/gtk!7402
2024-07-02 00:33:21 +00:00
Benjamin Otte
b80e33b209 testsuite: Add tests for empty mask children
The compare tests use an empty container node, but running them with
--replay ends up with empty nodes in snapshots due to how containers are
replayed.

Related: !7396
Related: #6761
2024-07-02 02:04:06 +02:00
Benjamin Otte
9f7254a2d0 gl: Fix wrong drawing of mask node corner case
An empty mask with inverted-alpha means the source is visible.
2024-07-02 02:04:06 +02:00
Benjamin Otte
00e59c385e snapshot: no inverted-alpha mask means everything visible
That's what inverted does to us.

Related: !7396
Related: #6761
2024-07-01 20:30:25 +02:00
Benjamin Otte
43c2b53811 rendernode: Remove default empty draw function
No node ever wants to draw nothing. So make sure code crashes if the
draw func is not set instead of silently drawing nothing.
2024-07-01 20:30:25 +02:00
Benjamin Otte
c645acc214 memoryformat: Use the correct type
Our color values are float[4], so make them float[4].
2024-07-01 20:07:22 +02:00
Benjamin Otte
33d87bc22e gdk: Add GDK_N_DEPTHS to the enum
We are indexing arrays by the number of depths, and when adding depths
we don't want to forget to grow those arrays.
2024-07-01 20:07:22 +02:00
Matthias Clasen
a35f9102f2 Merge branch 'aspectframe_doc_fix_css_name' into 'main'
aspectframe: fix CSS name in docs

See merge request GNOME/gtk!7400
2024-06-30 12:57:46 +00:00
Matthias Clasen
525d773a30 Merge branch 'matthiasc/for-main' into 'main'
Matthiasc/for main

See merge request GNOME/gtk!7399
2024-06-30 12:54:15 +00:00
g.willems
d22812ae35 aspectframe: fix CSS name in docs 2024-06-30 14:06:31 +02:00
Matthias Clasen
1dc70ebb07 Post-release version bump 2024-06-29 21:45:28 -04:00
Matthias Clasen
297e4f6134 4.15.3 2024-06-29 21:24:51 -04:00
Matthias Clasen
4e73297cb8 Merge branch 'matthiasc/for-main' into 'main'
ci: Build demos and man pages for docs

See merge request GNOME/gtk!7398
2024-06-29 23:16:04 +00:00
Matthias Clasen
8fe16190b9 ci: Build demos and man pages for docs
That way, we should get all the man pages online.
2024-06-29 18:48:15 -04:00
Matthias Clasen
047ab10a5c Merge branch 'matthiasc/for-main' into 'main'
css: Update flags for array values properly

Closes #6814

See merge request GNOME/gtk!7397
2024-06-29 19:33:29 +00:00
Matthias Clasen
3c8e9231ea css: Fix up incomplete resolve plumbing
I didn't quite get it right for all our image subtypes at first.

Fixes: #6814
2024-06-29 15:07:22 -04:00
Matthias Clasen
cb9c57f223 css: Update flags for array values properly
When computing or resolving array values, update the
is_computed and contains_current_color flags as needed.
2024-06-29 15:05:36 -04:00
Matthias Clasen
253e8f0d64 Merge branch 'docs-gtk-fix' into 'main'
Fix docstring errors in GTK

See merge request GNOME/gtk!7300
2024-06-29 15:23:30 +00:00
Emmanuele Bassi
4aee2c3c41 Merge branch 'amolenaar/macos-keybindings' into 'main'
macOS: Add native keyboard shortcuts

Closes #3421

See merge request GNOME/gtk!7260
2024-06-29 14:24:47 +00:00
Matthias Clasen
2641aad318 Merge branch 'matthiasc/for-main' into 'main'
snapshot: Don't crash and don't leak

See merge request GNOME/gtk!7396
2024-06-29 14:18:25 +00:00
Matthias Clasen
346fcdb405 snapshot: Don't crash and don't leak
We were trying to handle a NULL mask child, unsuccessfully.

Pointed out by Niels De Graef.
2024-06-29 09:31:21 -04:00
Maximiliano Sandoval
9564e4c178 gtkprinter: Add docs for GtkPrintBackend 2024-06-29 15:14:33 +02:00
Maximiliano Sandoval
50dd958890 gdktoplevel: Document toplevel_titlebar_gesture 2024-06-29 15:14:33 +02:00
Maximiliano Sandoval
9126bf2c9d docs: gsk: Add docstring for BroadwayRenderer 2024-06-29 15:14:33 +02:00
Maximiliano Sandoval
a692f0cb07 docs: Add gi-docgen check to tests
Can be called via:

    meson test --suite docs
2024-06-29 15:14:33 +02:00
Maximiliano Sandoval
2bbfa92504 docs: Skip checking deprecated classes in gtk4 2024-06-29 15:14:33 +02:00
Maximiliano Sandoval
0e74355782 gdk: docs: Do not check KEY_* symbols
Documenting them is overkill.
2024-06-29 15:14:33 +02:00
Maximiliano Sandoval
be137358f1 gdktypes: Hide DECLARE_INTERNAL_TYPE docs
This is private API.
2024-06-29 15:14:32 +02:00
Maximiliano Sandoval
d9564df6a7 gtk: docs: Ignore gtk-private-changed signal 2024-06-29 15:14:32 +02:00
Maximiliano Sandoval
3f9ad44948 gsk: docs: Ignore INCLUDE_WARNING macro
This is private.
2024-06-29 15:14:32 +02:00
Maximiliano Sandoval
c73ff197e0 gsk: meson: Document renderers
These contain docstrings.
2024-06-29 15:14:32 +02:00
Maximiliano Sandoval
1ad1a13085 gtktestatcontext: Document assertion_meesage_role
This, and many methods in this file, lands in GIR and should be documented.
2024-06-29 15:14:32 +02:00
Maximiliano Sandoval
50e3a37b7a gtk: meson: Add files with public API correctly
Example symbols documented in these files are:

- gtk_snapshot_append_layout
- gtk_accessible_state_init_value
- gtk_text_mark_set_visible
2024-06-29 15:14:31 +02:00
Matthias Clasen
7d3970546c Merge branch 'fix_help_text' into 'main'
a11y: Fix the help text property bridging to ATSPI

See merge request GNOME/gtk!7348
2024-06-29 13:01:09 +00:00
Matthias Clasen
3d739c6a15 Merge branch 'matthiasc/for-main' into 'main'
rendernode: Set proper values for fill and stroke nodes

See merge request GNOME/gtk!7394
2024-06-29 12:55:21 +00:00
Benjamin Otte
16692f9f5e vulkan: Remove unused function 2024-06-29 07:14:03 -04:00
Benjamin Otte
4f453ab521 vulkan: Rename variable
It's not a format.
2024-06-29 07:13:54 -04:00
Benjamin Otte
72a4fae8dc vulkan: More slight refactoring
This applies the same refactoring as commit
5fbdec2a29 to another function.
2024-06-29 07:13:27 -04:00
Matthias Clasen
36c7d05445 gpu: Keep actual clear values in clear op
Keeping the GdkRGBA requires doing later conversions, which isn't
necessary if we just keep the already converted float[4].

It also prepares for future color states, where the color will need to
be converted using the colorstate.
2024-06-29 07:12:28 -04:00
Matthias Clasen
f3d5683f67 rendernode: Fix container nodes preferred depth
The current code injects an implicit GDK_MEMORY_U8 into this.
It is harmless now, but may not be in future. So avoid it.
2024-06-29 07:12:10 -04:00
Benjamin Otte
120887979d rendernode: Set proper values for fill and stroke nodes
Fill and stroke nodes were not reporting proper offscreen-for-opacity
and preferred depth.

This was unlikely to have been noticed as their child is usually a solid
color.
2024-06-29 07:12:10 -04:00
Benjamin Otte
77434fc9f9 testsuite: Use a proper texture on defaultvalue test 2024-06-29 07:12:10 -04:00
Benjamin Otte
830846b39c testsuite: Use a proper texture on objects-finalize test 2024-06-29 07:12:10 -04:00
Benjamin Otte
3073704010 testsuite: Use a proper texture in notify test 2024-06-29 07:12:10 -04:00
Matthias Clasen
e165dcf78d Merge branch 'text-selection-changes-cleanup' into 'main'
text: Move a11y selection updates where they belong

Closes #6805

See merge request GNOME/gtk!7390
2024-06-29 10:45:54 +00:00
Matthias Clasen
2d2fc59597 Merge branch 'css-used-value-fixes' into 'main'
css: Fix oversights in handling of used values

Closes #6814

See merge request GNOME/gtk!7393
2024-06-29 10:25:14 +00:00
Matthias Clasen
89020892a8 css: Fix oversights in handling of used values
Some of the properties where currentcolor might make a difference
between computed and used value are arrays, so we need to be able
to resolve arrays of values. Change things around to make resolve
a GtkCssValue vfunc and turn the existing resolve() implementations
into implementations of that vfunc.

Fixes: #6814
2024-06-28 21:18:38 -04:00
Matthias Clasen
653f4d4183 Merge branch 'matthiasc/for-main' into 'main'
dnd: Avoid a critical

See merge request GNOME/gtk!7392
2024-06-28 19:19:46 +00:00
Matthias Clasen
d998d703ff testdnd: Human-readable spew
Nicer to read the names of actions and other enum values.
2024-06-28 14:12:45 -04:00
Matthias Clasen
43bec39794 dnd: Avoid a critical
There is no way for callers of this function to find out if
the drop is still the same, so spewing a critical if it isn't
seems useless. Just quietly do nothing.
2024-06-28 14:12:35 -04:00
Matthias Clasen
e2067e3703 text: Move a11y selection updates where they belong
gtk_text_set_positions is the central place for any changes to
text caret and selection bound. And it already filters out no-change
updates. So move the remaining signals from
gtk_text_set_selection_bounds here, for more accurate updates
of cursor positions in accessibility.

Fixes: #6805
2024-06-28 08:18:12 -04:00
Matthias Clasen
0e19a7d024 Merge branch 'matthiasc/for-main' into 'main'
Post-release version bump

See merge request GNOME/gtk!7389
2024-06-28 11:07:11 +00:00
Matthias Clasen
cdd0aa4cfd Post-release version bump 2024-06-28 07:02:34 -04:00
Matthias Clasen
157c714d86 Merge branch 'matthiasc/for-main' into 'main'
4.15.2

See merge request GNOME/gtk!7388
2024-06-28 11:01:04 +00:00
Matthias Clasen
4873bb3099 4.15.2 2024-06-28 06:39:59 -04:00
Arjan Molenaar
7207810ce4 docs: Updated docs regarding macOS keyboard shortcuts
Implemented review comments from @jralls.
2024-06-28 10:29:58 +02:00
Arjan Molenaar
f072ff3861 docs: Add a line on explicit use of modifiers on macOS 2024-06-28 10:29:58 +02:00
Arjan Molenaar
3f05b17d37 macos: Update default application shortcuts
Default key should be Meta (a.k.a. Command), and not Control.
2024-06-28 10:29:58 +02:00
Arjan Molenaar
4fef3c157a macos: keybindings for GtkCalendar
Use Cmd, instead of Ctrl on macOS.
2024-06-28 10:29:58 +02:00
Arjan Molenaar
38602823bb macos: keybings for shortcut window
Allow search with Cmd-F.
2024-06-28 10:29:58 +02:00
Arjan Molenaar
6e02b9d5bc macos: keybindings for deprecated widgets
mac-style select-all and unselect-all.
2024-06-28 10:29:58 +02:00
Arjan Molenaar
03337534f9 macos: add keybindings for search next/previous 2024-06-28 10:29:57 +02:00
Arjan Molenaar
613a004d18 macos: shortcuts for GtkListBase and GtkListBox
Select all and multi-select and toggle selection.
2024-06-28 10:29:57 +02:00
Arjan Molenaar
6fa23794fc macos: key bindings for GtkTextView 2024-06-28 10:29:57 +02:00
Arjan Molenaar
82027bb51e macos: Add macos key binding to GtkLabel 2024-06-28 10:29:57 +02:00
Arjan Molenaar
9e5ce813c4 events/macos: Support Cmd modifier for text editing
This makes key events feel more natural on macOS.
2024-06-28 10:29:57 +02:00
Arjan Molenaar
b7f3beda00 macos: Map Cmd directly to Meta
Why need a mapping via a MOD2 mask?
2024-06-28 10:29:57 +02:00
Matthias Clasen
f4509a63b0 Merge branch 'css-current-color1' into 'main'
css: Handle currentcolor more correctly

See merge request GNOME/gtk!7387
2024-06-28 01:22:03 +00:00
Matthias Clasen
29559deeeb reftests: Avoid some deprecated css
alpha() is deprecated, replace it with a relative color.
2024-06-27 21:03:14 -04:00
Matthias Clasen
0cff62335b Fix style variables test
Make the results match what the comments actually say.
2024-06-27 21:03:14 -04:00
Matthias Clasen
e4325e5b2b css: Add more currentcolor style tests
These tests check various situations with inheritance and
currentColor. In particular the caret-color test was not
working correctly before we handled used values explicitly.
2024-06-27 21:03:14 -04:00
Matthias Clasen
f57010180c css: Update style printing to show used values
This is what we want to see, most of the time.
2024-06-27 21:03:14 -04:00
Matthias Clasen
5807b68d5b gtk: Update all users to use used values
Update all widgets and rendering code to use the used values of
relevant css properties.
2024-06-27 21:03:14 -04:00
Matthias Clasen
1af746e136 css: Update animated styles to resolve used values
The way this works is that we first apply the value changes
from animations, which will trigger recomputation of the regular
style properies if the keyframes contains custom properties.

After that is done, we resolve the used values, base on the
new computed values. This is where currentcolor is resolved.
2024-06-27 21:03:14 -04:00
Matthias Clasen
d3c78c8811 css: Implement used values for static styles
Change the style computation machinery to populate the used
values struct, and stop relying on NULL values in the values
structs to indicate currentColor occurrences. Instead, use
gtk_css_color_value_contains_current_color() when determining
style changes.
2024-06-27 21:03:14 -04:00
Matthias Clasen
28a4f7a60a css: Add an assertion
Passing NULL as compute context does not work, so make it obvious
when it happens.
2024-06-27 21:02:37 -04:00
Matthias Clasen
d54a9d241d css: Add some new style apis
Add separate apis for getting computed and used values, and
a method to resolve used values of a style.
2024-06-27 21:00:18 -04:00
Matthias Clasen
8814c00573 css: Introduce a struct for used values
The GtkCssUsedValues struct will hold the used values of those
css properties where that makes a difference. The new structs
are not used yet.
2024-06-27 20:21:43 -04:00
Matthias Clasen
36b55a8b57 css: Make image values resolve used values
Separate out computed and used values for this type.
2024-06-27 20:21:43 -04:00
Matthias Clasen
e027843cb0 css: Add a way to resolve css images
This will be needed to separate out computed and used values
for css image values.
2024-06-27 20:21:43 -04:00
Matthias Clasen
5de0ebab26 css: Make shadow values resolve used values
Separate out computed and used values for this type.
2024-06-27 20:21:43 -04:00
Matthias Clasen
cc463d52f6 css: Make palette value resolve used values
Separate out computed and used values for this type.
2024-06-27 20:21:43 -04:00
Matthias Clasen
eeca361418 css: Make currentcolor compute to itself
This temporarily breaks currentcolor values. All uses of color
values will have to be fixed up to handle currentcolor at use time.
2024-06-27 19:51:56 -04:00
Matthias Clasen
bdf56ec6d6 css: Make color resolving more robust
Make gtk_css_color_value_resolve() handle situations where it can't
fully resolve a color expression. This will start to happen in the
next commits, when we make currentColor compute to itself

This commit also changes the api for gtk_css_color_value_resolve
to not take the property_id, since we already pass the currentcolor
value that it is meant to help determine. Update all callers.
2024-06-27 19:51:56 -04:00
Matthias Clasen
ee9e302b24 css: Introduce gtk_css_value_contains_current_color
Track whether a value contains currentcolor (in which case
it needs to be resolved at use time).

This just adds the bit and the getter, it isn't used yet.
2024-06-27 19:51:54 -04:00
Matthias Clasen
17b50f08b3 Merge branch 'document_shortcuts_and_actions' into 'main'
docs: Document shortcuts and actions

See merge request GNOME/gtk!7379
2024-06-27 16:20:17 +00:00
g.willems
d58297fa15 docs: Document shortcuts and actions 2024-06-27 16:33:31 +02:00
Matthias Clasen
c27516a1db NEWS: Updates 2024-06-26 21:20:17 -04:00
Matthias Clasen
cf4cd4abd8 Merge branch 'popover-positioning-improvements' into 'main'
popover: Recompute shape more often

See merge request GNOME/gtk!7385
2024-06-27 00:33:45 +00:00
Matthias Clasen
a4cc95b293 popover: Hide if we don't get enough size
If the compositor does not give us our min size, we have to
disappear, or we risk criticals from underallocating widgets.
2024-06-26 17:31:38 -04:00
Matthias Clasen
a8bb6d5918 Merge branch 'matthiasc/for-main' into 'main'
css: Fix animations

Closes #6807

See merge request GNOME/gtk!7382
2024-06-26 20:11:56 +00:00
Matthias Clasen
496c75617c css: Make recomputing animated styles make more sense
When we look for what values need recomputing, we also determine what
value we are going to use to recompute. For values that contain
variables, that is the 'original' value, as returned by
gtk_css_style_get_original_value. For values that we recompute
because they may contain currentcolor, that is the specified value
as returned by gtk_css_animated_style_get_intrinsic_value.

The one issue here is that we currently don't preserve currentcolor
in the computed value, so recomputing the value does not do us
any good in the color case. That will be fixed separately.
2024-06-26 15:51:07 -04:00
Matthias Clasen
6b14f221c1 css: Up our contains-color classification
The color property does not need recomputing here since we are
in the case where we know that the keyframes contain a color value.
And it is background-color, not background-image, that contains
the color for the background shorthand.
2024-06-26 14:23:00 -04:00
Matthias Clasen
9948e0a564 css: Fix animations
Determine whether the style needs recomputation, then recompute
the style, and then set the values from keyframes, so we don't
end up overwriting keyframe changes by recomputing properties from
their original values.

Fixes: #6807
2024-06-26 13:43:14 -04:00
Emmanuele Bassi
c89e029223 Merge branch 'wip/fl/fullscreen-selected-monitor-macos' into 'main'
gdk: Implement fullscreen on selected monitor on macos

See merge request GNOME/gtk!7384
2024-06-26 14:19:15 +00:00
Fabio Lagalla
0ca569baab gdk: Implement fullscreen on selected monitor on macos
The feature was apparently missing, as monitors were always fullscreened at the surface best monitor.

Keep using best monitor if the selected monitor is not specified, otherwise move the window to the selected monitor before going fullscreen.
2024-06-26 15:53:49 +02:00
Matthias Clasen
40b13bfa35 popover: Recompute shape more often
We want to recompute the shape when the attachment position has
changed, since that might require the arrow to be repositioned.
2024-06-26 07:33:15 -04:00
Matthias Clasen
1df3c87ed5 Cosmetics 2024-06-26 07:33:15 -04:00
Matthias Clasen
0b57bd5a53 Merge branch 'no-c-format' into 'main'
gtkfilechooserwidget: Mark string as no-c-format

See merge request GNOME/gtk!7376
2024-06-22 21:33:37 +00:00
Anders Jonsson
5df9b1cb5b gtkfilechooserwidget: Mark string as no-c-format
gettext 0.22 recognizes %b as a C string format which
not is true for date strings, so explicitly mark as
no-c-format.
2024-06-22 20:06:47 +02:00
Matthias Clasen
f5b7e131d6 Merge branch 'ngl-render-texture-dmabuf' into 'main'
ngl: Export dmabuf textures from render_texture

See merge request GNOME/gtk!7375
2024-06-22 17:19:24 +00:00
Matthias Clasen
51012c1802 ngl: Export dmabuf textures from render_texture
We want dmabufs because we can import them into Vulkan, amongst
other things.
2024-06-22 08:02:31 -04:00
Matthias Clasen
b5c1e77d4c Merge branch 'matthiasc/for-main' into 'main'
testsuite: Fix up memorytexture printing

See merge request GNOME/gtk!7374
2024-06-21 23:42:45 +00:00
Matthias Clasen
85149445e0 testsuite: Fix up memorytexture printing
This was bungled in 96cb38dd05.
2024-06-21 19:14:31 -04:00
Matthias Clasen
61d0043f9c Merge branch 'fontconfig-grrr' into 'main'
Try to avoid aliasing with system fonts

See merge request GNOME/gtk!7368
2024-06-21 23:02:00 +00:00
Matthias Clasen
5c97089e59 Update expected results
Since we've given up on embedding subsetted system fonts, we need
to regenerate our reference files once more.
2024-06-21 18:45:43 -04:00
Matthias Clasen
6f5c610858 gsk: Give up automatic font subsetting
Despite my best effort, it seems impossible to make ci and local
builds agree on what font subsetter and fonts to use, so make this
opt-in for now: If you want to produce a node file with embedded
fonts, set GSK_SUBSET_FONTS=1.
2024-06-21 18:45:32 -04:00
Matthias Clasen
a05dd4d194 Isolate our nodeparser tests better
Add a custom fontconfig setup and ship Cantarell as part of it.
This should hopefully make it so that the tests always see the
same default font, as long as you have FONTCONFIG_FILE set up
correctly.

Update all affected tests.
2024-06-21 18:17:11 -04:00
Matthias Clasen
b1a840bec0 Try to avoid aliasing with system fonts
The rendernode parser creates its own fontmap for the fonts that
we deserialize from blobs. But we were using the system fontconfig
configuration for it, leading to system fonts still being found.
This is bad, and causes test failures in ci. Try with an empty
fontconfig configuration instead.
2024-06-21 18:17:11 -04:00
Matthias Clasen
31fabecddd Merge branch 'print-pixesl' into 'main'
wip: print pixels when memorytexture tests fail

See merge request GNOME/gtk!7373
2024-06-21 20:33:21 +00:00
Matthias Clasen
96cb38dd05 wip: print pixels when memorytexture tests fail
This helps with debugging.
2024-06-21 15:48:30 -04:00
Matthias Clasen
b672dabee8 Merge branch 'wip/otte/for-main' into 'main'
node-editor: Make this app non-unique

See merge request GNOME/gtk!7372
2024-06-21 19:47:37 +00:00
Benjamin Otte
5fbdec2a29 vulkan: Slight refactoring for future changes
No functional changes.
2024-06-21 19:53:46 +02:00
Benjamin Otte
f22ae99b98 gdk: Improve memorytexture test output
On failures, don't immediately abort, just g_test_fail().
This allows running the test with -k to get full output.

Also print something useful as the error message, namely the bytes that
are different.
2024-06-21 19:53:46 +02:00
Benjamin Otte
3be7ef17ff node-editor: Make this app non-unique
There's no benefit in having multiple windows share the process.

But there's a huge disadvantage because running the app a 2nd time with
different environment variables will open a window in the first process
instead and discard the variables.

And my use of GSK_RENDERER hates that.
2024-06-21 19:53:46 +02:00
Милош Поповић
146422fabd Update Serbian translation 2024-06-20 17:41:29 +00:00
Matthias Clasen
a274a5ff4b Merge branch 'matthiasc/for-main' into 'main'
Simply some internal api

See merge request GNOME/gtk!7369
2024-06-19 06:40:25 +00:00
Matthias Clasen
d1d4d80a1d Simply some internal api
The only caller of gdk_memory_texture_from_texture doesn't use
the second argument.
2024-06-19 02:06:14 -04:00
Matthias Clasen
167d32811d Merge branch 'matthiasc/for-main' into 'main'
Fix a crash in rendernode serialization

See merge request GNOME/gtk!7367
2024-06-18 03:02:53 +00:00
Matthias Clasen
6ec4a2a4a5 Exclude some more gradient compare tests
These are prone to rounding errors.
2024-06-17 22:28:33 -04:00
Matthias Clasen
a11abf57e1 testsuite: Regenerate a bunch of .ref.node files
We serialize fonts now, so these show up in the node references.
2024-06-17 22:14:34 -04:00
Matthias Clasen
a63a201812 Fix a crash in rendernode serialization
This snuck in with a6ffd6b3b2.
2024-06-17 22:09:30 -04:00
Matthias Clasen
f09caced9b Drop debug spew 2024-06-17 21:44:33 -04:00
Emmanuele Bassi
01cd2fe4bb Merge branch 'wip/alice/about-dialog-fix' into 'main'
aboutdialog: Fix build on windows

See merge request GNOME/gtk!7365
2024-06-17 13:25:58 +00:00
Alice Mikhaylenko
45b93644b7 aboutdialog: Fix build on windows 2024-06-17 15:38:47 +04:00
Matthias Clasen
76a80d8f45 Merge branch 'docs-drawing-overview' into 'main'
docs: gtk_widget_queue_draw() is a single function, not a set anymore

See merge request GNOME/gtk!7362
2024-06-16 18:16:42 +00:00
Matthias Clasen
153b8399f7 Merge branch 'matthiasc/for-main' into 'main'
css: Move the color space enums to a better place

See merge request GNOME/gtk!7363
2024-06-16 18:14:01 +00:00
Matthias Clasen
da41271dd5 css: Parse interpolation for conic gradients
Parse things like "in hsl hue longer". For details, see the
CSS Images Module Level 4, https://www.w3.org/TR/css-images-4.

This commit fixes preexisting brokenness in conic-gradient parsing
and printing as well, and includes the relevant test changes.

Tests included.

Gradient interpolation color spaces aren't supported for
rendering yet.
2024-06-16 13:22:36 -04:00
Matthias Clasen
5610af1b77 css: Parse interpolation for radial gradients
Parse things like "in hsl hue longer". For details, see the
CSS Images Module Level 4, https://www.w3.org/TR/css-images-4.

Tests included.

Gradient interpolation color spaces aren't supported for
rendering yet.
2024-06-16 13:22:27 -04:00
Matthias Clasen
8da70fec91 css: Parse interpolation for linear gradients
Parse things like "in hsl hue longer". For details, see the
CSS Images Module Level 4, https://www.w3.org/TR/css-images-4.

Tests included.

Gradient interpolation color spaces aren't supported for
rendering yet.
2024-06-16 13:21:56 -04:00
Matthias Clasen
f9cd30a859 css: Better error reporting
I seem to mix up the order of 'longer hue' occasionally, so lets
throw a helpful error message if we see 'hue' first.
2024-06-16 13:04:58 -04:00
Matthias Clasen
763d620a23 css: Parse all supported color spaces
The code parsing interpolation methods hadn't learned about
or latest color space additions. While we're at it, improve
the error reporting a bit.

Tests included.
2024-06-16 13:04:52 -04:00
Matthias Clasen
500a3a6dee css: Add a helper function for parsing
This will be helpful in gradient parsing code, where the color
interpolation is optional.
2024-06-16 13:04:44 -04:00
Matthias Clasen
57073e1057 css: Move the color space enums to a better place
These will be used in the gradient code too, so put them into
a more better place.
2024-06-16 13:04:13 -04:00
Daniel Rusek
6bbfd2f62a Update Czech translation 2024-06-16 13:32:33 +00:00
Gabor Karsay
6c69a96cd7 docs: link some methods in drawing model overview 2024-06-16 10:30:44 +00:00
Gabor Karsay
fa247d5a84 docs: gtk_widget_queue_draw() is a single function, not a set anymore 2024-06-16 10:02:32 +00:00
Matthias Clasen
0320c4ac14 Merge branch 'matthiasc/for-main' into 'main'
gpu: Print some more details

See merge request GNOME/gtk!7360
2024-06-15 21:59:14 +00:00
Matthias Clasen
36993ac707 gpu: Print some more details
Print the variations of mask and blendmode operations.
Just because we can.
2024-06-15 14:00:46 -04:00
Matthias Clasen
2f93eb4a28 Merge branch 'matthiasc/for-main' into 'main'
Fix a copy-paste error

See merge request GNOME/gtk!7358
2024-06-14 23:18:55 +00:00
Matthias Clasen
5a2982ac31 testsuite: Fix one nodeparser error 2024-06-14 14:11:54 -04:00
Matthias Clasen
441b704afd testsuite: Stop relying on xpms
gdk-pixbuf isn't loading those anymore, by default.
2024-06-14 14:11:22 -04:00
Matthias Clasen
abf6ebd7fe label: Only put alpha in attributes when needed
It does not do much harm, but it broke some of our tests.
2024-06-14 14:04:23 -04:00
Matthias Clasen
34fb08af6e Fix a copy-paste error
This was obviously meant to compare two different colors.
2024-06-14 12:30:06 -04:00
Matthias Clasen
0b9dfdd41f Merge branch 'wip/alice/color-fix' into 'main'
More color clamping and redraw fixes

See merge request GNOME/gtk!7357
2024-06-14 11:07:49 +00:00
Alice Mikhaylenko
701e0812e4 treeview: Clamp tree line and grid line colors 2024-06-14 03:04:54 +04:00
Alice Mikhaylenko
4918a46172 textview: Redraw selection on style changes 2024-06-14 03:04:54 +04:00
Alice Mikhaylenko
ef5e3fae64 aboutdialog: Update link colors on css changes 2024-06-14 03:04:54 +04:00
Alice Mikhaylenko
9fcf55571e textlayout: Clamp colors before passing them to Pango 2024-06-14 03:04:54 +04:00
Alice Mikhaylenko
260898ecf6 text: Redraw when selection style changes 2024-06-14 01:41:22 +04:00
Alice Mikhaylenko
66c9132abe label: Update selection on css changes too 2024-06-14 01:41:22 +04:00
Alice Mikhaylenko
c5abdfb72b label: Fix critical when updating styles
Noticed when testing with libadwaita styles instead of GTK styles.
2024-06-13 23:36:38 +04:00
Matthias Clasen
4fe37847ba Merge branch 'wip/alice/color-fix' into 'main'
Fix GtkLabel link color

Closes #6781

See merge request GNOME/gtk!7355
2024-06-13 13:28:58 +00:00
Alice Mikhaylenko
c99a0b0518 label: Track link style changes
If we're gonna have system accents, would be nice to update links reliably
and not wait for other changes like changing color of the label itself.
2024-06-13 16:28:06 +04:00
Alice Mikhaylenko
31f3edec5c label: Clamp out-of-gamut link color
Support alpha too while we're here.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6781
2024-06-13 16:28:05 +04:00
Emmanuele Bassi
dee372c08e Merge branch 'ebassi/docs-for-master' into 'main'
docs: Fix link to DragIcon.get_for_drag()

See merge request GNOME/gtk!7347
2024-06-13 11:27:28 +00:00
Matthias Clasen
8c0a4e5a6e Merge branch 'matthiasc/for-main' into 'main'
Silence a compiler warning

See merge request GNOME/gtk!7354
2024-06-12 03:24:29 +00:00
Matthias Clasen
7195514fb5 Silence a compiler warning 2024-06-11 17:47:48 -04:00
Matthias Clasen
420bd5bc16 Merge branch 'more-css-color-spaces' into 'main'
css: Add more color spaces

See merge request GNOME/gtk!7352
2024-06-11 21:05:06 +00:00
Matthias Clasen
f024ee1adf Add more tests for css colors 2024-06-11 16:41:22 -04:00
Matthias Clasen
18c2c71cd5 css: Add support for rec2100-pq colors
This is our first HDR color space. Yay!!

The conversion between rec2020-linear and rec2100-linear
assumes that SDR 1,1,1 has a luminance of 203 cd/m².
2024-06-11 16:41:22 -04:00
Matthias Clasen
2d1bfc84b9 Expose more colorutils
We may want to have a rec2020-linear space available on the gsk
level, so expose the conversion functions for it.
2024-06-11 16:41:22 -04:00
Matthias Clasen
8edfa759fb css: Add support for rec2020 colors
Another extremely wide gamut color space.
2024-06-11 16:41:22 -04:00
Matthias Clasen
2d1e978599 css: Add support for xyz colors
This is somewhat central, and we have all the pieces to support
it, so we might as well add the css syntax for it.
2024-06-11 16:41:22 -04:00
Matthias Clasen
d71fc41152 css: Add support for display-p3 colors
A wide-gamut colorspace.
2024-06-11 16:41:22 -04:00
Matthias Clasen
d141cb7b72 Fix an oversight
This snuck in as part of 098d67f8befdb00d75.
2024-06-11 16:41:22 -04:00
Lukáš Tyrychtr
b19cf5998f a11y: Fix the help text property bridging to ATSPI
It needed to be added to the vendored XML introspection data, so it was not
marked by a GDBus client as missing outright, and the comparison in the
property handler was also wrong.
2024-06-10 22:18:36 +02:00
Matthias Clasen
7010067884 Merge branch 'vulkan-high-depth' into 'main'
gpu: Print more info for renderpasses

See merge request GNOME/gtk!7351
2024-06-09 21:10:25 +00:00
Matthias Clasen
0ec29c4176 gsk: Pass the memory format for back buffer
We can now get this information from the Vulkan context,
so use it to accurately represent the back buffer.

Related: #6767
2024-06-09 15:59:56 -04:00
Matthias Clasen
42c6e0249f vulkan: Fix updating swap chains
gdk_vulkan_context_check_swapchain uses priv->current_format,
so we must update it first, and undo that if check_swapchain
falls. This fixes handling of high-depth back buffers in gsk.
2024-06-09 15:59:56 -04:00
Matthias Clasen
54eb85f814 vulkan: Add a getter for the memory format
We need this to accurately set up the gpu image for the
backbuffer in gsk.
2024-06-09 15:59:56 -04:00
Matthias Clasen
18b3b4feed gpu: Print more info for images
Show the memory format.

This helps debugging our depth selection.
2024-06-09 15:59:32 -04:00
Matthias Clasen
0045ac839b Give memory formats a name
This is useful in debugging.

The names I chose are shortened a bit from the enum values. We
use just a single depth, * for premultiplied, and f for float.
2024-06-09 15:59:27 -04:00
Matthias Clasen
a9da807de3 Merge branch 'cmurtag/fix_harfbuzz_subset_wrap' into 'main'
Fix Harfbuzz subset dependency not found in wrap

See merge request GNOME/gtk!7349
2024-06-08 10:26:12 +00:00
cameron
366639b7e4 Fix Harfbuzz subset dependency not found in wrap
Add harfbuzz subset to the harfbuzz wrap file so Meson can find the
dependency.
2024-06-08 13:54:21 +10:00
Emmanuele Bassi
7d2e2171be docs: Fix link to DragIcon.get_for_drag()
It has been marked as a constructor in commit 13013053f7.
2024-06-07 13:33:32 +02:00
Matthias Clasen
e3ceda15ac Merge branch 'gsktransform-improve-docs' into 'main'
gsktransform: Document consuming functions

See merge request GNOME/gtk!7342
2024-06-06 10:53:17 +00:00
Matthias Clasen
7291a21a85 Merge branch 'wip/alice/css' into 'main'
CSS fixes and more tests

See merge request GNOME/gtk!7345
2024-06-05 20:54:12 +00:00
Matthias Clasen
888afe3e46 Merge branch 'wip/alice/opacity' into 'main'
css: Allow percents in opacity

See merge request GNOME/gtk!7346
2024-06-05 20:53:55 +00:00
Alice Mikhaylenko
171bfde133 csscolorvalue: Fix percentage ranges for relative colors
Add tests as well, now that they can be computed at parse time.
2024-06-06 00:35:52 +04:00
Alice Mikhaylenko
82d1fdb714 csscolorvalue: Resolve relative colors at parse time when possible 2024-06-06 00:35:52 +04:00
Alice Mikhaylenko
82b19daa7e csscolorvalue: Don't serialize relative colors as rgb()
Spec says it should be color(srgb).
2024-06-06 00:35:52 +04:00
Alice Mikhaylenko
dc1ff3c2e3 csscolorvalue: Fix oklab() percentage range 2024-06-06 00:35:52 +04:00
Alice Mikhaylenko
6602ac5eae testsuite: Fix css tests
There are a bunch of new deprecations, and some tests weren't in
meson.build.
2024-06-06 00:35:52 +04:00
Alice Mikhaylenko
5dab5bf0e9 css: Allow percents in opacity
Add another missing feature from web css. It's nice to be able to use the
same variables in color-mix() and here.
2024-06-06 00:22:19 +04:00
Matthijs Velsink
721be8fe9f gsktransform: Document consuming functions
Since GskTransform is immutable, a lot of the documented "methods" are
more like "functions", in the sense that they don't keep the instance
alive but rather consume it.

This is annotated with `(transfer full)`, but since these functions are
listed as methods, their first argument is not shown.

Instead, let's add a line to the docs of each consuming function that
clarifies this behavior.
2024-06-05 15:59:49 +02:00
Matthias Clasen
58fe590eae Merge branch 'matthiasc/for-main' into 'main'
css: Plug a memory leak

See merge request GNOME/gtk!7341
2024-06-05 12:18:50 +00:00
Matthias Clasen
c18a7ff5cf css: Plug a memory leak
This snuck in when the relative color support was merged.
2024-06-05 07:22:47 -04:00
Matthias Clasen
24fc38b287 Merge branch 'matthiasc/for-main' into 'main'
docs: Improve css color migration docs

See merge request GNOME/gtk!7340
2024-06-04 18:47:21 +00:00
Matthias Clasen
aa03c50f05 theme: Use better replacements for color expressions
These match what we recommend for migration.
2024-06-04 12:54:41 -04:00
Matthias Clasen
03e971b2e3 Revert "theme: Stop using alpha() and shade()"
This reverts commit 0e94e5ecda.
2024-06-04 12:48:55 -04:00
Matthias Clasen
a595133b77 docs: Improve css color migration docs
With relative colors, we can do better.
2024-06-04 12:39:40 -04:00
Matthias Clasen
e50f4ecccf NEWS: Updates 2024-06-04 12:00:02 -04:00
Matthias Clasen
67913e4af0 docs: Add more details about CSS colors 2024-06-04 12:00:02 -04:00
Matthias Clasen
b3d1795327 Merge branch 'file-chooser-shortcut-new-folder' into 'main'
gtkfilechooserwidget: Add shortcut to create a new folder

Closes #5527

See merge request GNOME/gtk!7338
2024-06-04 15:38:38 +00:00
Matthias Clasen
6edcc8f256 Merge branch 'css-relative-colors' into 'main'
css: Support relative colors

See merge request GNOME/gtk!7326
2024-06-04 14:59:00 +00:00
Matthias Clasen
d5e5f47666 css: Add tests for relative colors 2024-06-04 10:47:54 -04:00
Matthias Clasen
0524c40640 css: Support relative colors
Parse the various color(from <color> ...) syntaxes, and implement
them.

Add a new 'relative color' subtype for color values, and a new
'color coord' subtype for number values. Use these for relative
colors where the original color can't be resolved at parse time.
2024-06-04 10:47:54 -04:00
Matthias Clasen
b5fd894f77 css: Add a function to get color coords
This will be used in the implementation of relative colors.
2024-06-04 10:47:21 -04:00
Matthias Clasen
d8492121aa css: Rewrite the color parsing code
Make this more uniform, and easier to extend.

Also, use gtk_css_number_value_parse_with_context, since we
are going to add context here in the future.
2024-06-04 10:47:21 -04:00
Matthias Clasen
4a0bf603d7 css: Add context for parsing numbers
In the future, parsing numbers will depend one some context, so
add a context struct to the involved apis. This is not used yet.
2024-06-04 10:47:21 -04:00
Matthias Clasen
02fa89df9e css: Change the api for resolving colors
We will need to compute other values in here in the future, and for
that we need all the arguments that get passed to compute(), so carry
them along.

Update all callers.
2024-06-04 10:47:21 -04:00
Martin
5b6dde9a73 Update Slovenian translation 2024-06-04 07:27:42 +00:00
Automeris naranja
e9d8ebdfc9 gtkfilechooserwidget: Add shortcut to create a new folder
Closes https://gitlab.gnome.org/GNOME/gtk/-/issues/5527
2024-06-03 22:49:11 -03:00
Matthias Clasen
366efc3d61 Merge branch 'css-color-deprecations2' into 'main'
css: Deprecate our own color functions

See merge request GNOME/gtk!7311
2024-06-04 00:41:44 +00:00
Matthias Clasen
3b890fd3c1 css: Document replacements for color stuff
Document how named colors and non-standard color expressions
can be replaced.
2024-06-03 20:37:52 -04:00
Matthias Clasen
5de373a14b css: Deprecate our own color functions
We will soon have new standards-conformant color functions from
the css-colors-5 spec, so these can be phased out.
2024-06-03 20:37:52 -04:00
Matthias Clasen
24cb9d2437 docs: Fix the 4to5 migration guide
This was referring to a nonexisting api.
2024-06-03 20:37:52 -04:00
Matthias Clasen
83aa176466 docs: Add the 4to5 migration guide to the docs
Adding this to the built docs ensures that it is buildable.
2024-06-03 20:37:52 -04:00
Matthias Clasen
0e94e5ecda theme: Stop using alpha() and shade()
These are being phased out in favor of color-mix().
2024-06-03 20:37:52 -04:00
Matthias Clasen
130485a583 Merge branch 'wip/alice/colors-2' into 'main'
Implement color-mix()

See merge request GNOME/gtk!7336
2024-06-03 21:17:54 +00:00
Alice Mikhaylenko
f34c10abb5 csscolorvalue: Get rid of the literal type
Just use color with srgb color space and serialize_as_rgb=TRUE.
2024-06-03 23:59:44 +04:00
Alice Mikhaylenko
48b00f0ac1 testsuite: Add color-mix() tests 2024-06-03 23:59:44 +04:00
Alice Mikhaylenko
743329a3af csscolorvalue: Implement color-mix() 2024-06-03 23:59:44 +04:00
Alice Mikhaylenko
f5783f1637 csscolor: Add functions for parsing and printing interpolation method 2024-06-03 23:59:44 +04:00
Matthias Clasen
67f61a8d39 Merge branch 'matthiasc/for-main' into 'main'
Fix the build

See merge request GNOME/gtk!7337
2024-06-03 19:16:22 +00:00
Matthias Clasen
f7df663dea Fix the build
I typoed in a2223c0884.
2024-06-03 15:10:19 -04:00
Alice Mikhaylenko
c99278aa58 csscolor: Allow printing hsl and hwb as color() too 2024-06-03 22:09:26 +04:00
Alice Mikhaylenko
1765e1b7c2 testsuite: Add GTK_DEBUG=css
Make named color tests work, since they expect deprecation warnings atm.
2024-06-03 21:53:52 +04:00
Matthias Clasen
bf1a434d5c Merge branch 'font-subsetting-in-node-files' into 'main'
Use font subsetting in serialized nodes

See merge request GNOME/gtk!7227
2024-06-03 12:47:59 +00:00
Matthias Clasen
9256b5b552 rendernode tool: Add an extract command
This lets one extract the data urls from a node file.
2024-06-03 08:28:21 -04:00
Matthias Clasen
577e4afb3c Improve font deserialization
Even if we disable font fallback, after adding Cantarell Regular
to the custom fontmap, fontconfig will helpfully synthesize
Cantarell Bold for us. So, just don't check for the font at all.
If there is a url, add it to the fontmap and leave it up to the
serializing code to ensure that we don't end up with duplicate
fonts.
2024-06-03 07:45:57 -04:00
Matthias Clasen
2a05c04db7 Use the hb face as key when tracking fonts
The hb face is is a wrapper around the font file, which is what
we need to track here, since we want to subset and serialize each
used font file exactly once.
2024-06-03 07:44:16 -04:00
Matthias Clasen
a6ffd6b3b2 nodeparser: Subset fonts
When serializing nodes, collect the glyphs that are used from
each font, subset the font to that set of glyphs, and embed it
into the node file. We are careful to preserve the glyph IDs,
so our text nodes transparently work with the subsettted fonts.
2024-06-03 07:38:51 -04:00
Matthias Clasen
24eba7c4c1 Merge branch 'matthiasc/for-main' into 'main'
Drop redundant GLib version check

See merge request GNOME/gtk!7334
2024-06-03 00:22:16 +00:00
Matthias Clasen
80de844922 Cosmetics 2024-06-02 20:07:33 -04:00
Matthias Clasen
a2223c0884 Drop redundant GLib version check
We require GLib 2.76 now.
2024-06-02 20:07:33 -04:00
Matthias Clasen
5ffa2b757c Merge branch 'less-vulkan' into 'main'
Don't use Vulkan without dmabufs

See merge request GNOME/gtk!7220
2024-06-02 23:58:24 +00:00
Matthias Clasen
b660fa27d3 Merge branch 'fix-missing-listeners' into 'main'
wayland: Add missing listeners

See merge request GNOME/gtk!7331
2024-06-02 20:42:13 +00:00
Matthias Clasen
77f0e5e1ba wayland: Add missing listeners
Now that we are using version 6 of the compositor interface,
we need to have preferred scale and bufer transform callbacks
everywhere.
2024-06-02 12:07:51 -04:00
Matthias Clasen
1080822ffa Merge branch 'matthiasc/css-deprecation-warning' into 'main'
css: Emit deprecation warnings only under debug

See merge request GNOME/gtk!7330
2024-06-02 15:33:32 +00:00
Matthias Clasen
3fef45683c css: Emit deprecation warnings only under debug 2024-06-02 15:33:32 +00:00
Matthias Clasen
cfcc5c5c0b Merge branch 'docs-add-missing-returns-args' into 'main'
docs: Add missing returns and parameter annotations

See merge request GNOME/gtk!7325
2024-06-02 15:26:50 +00:00
Matthias Clasen
856f1808de Merge branch 'matthiasc/for-main' into 'main'
Fix a bug in color conversion

See merge request GNOME/gtk!7328
2024-06-02 15:24:09 +00:00
Matthias Clasen
4341344545 css: Add a utility for color space coords 2024-06-02 11:08:35 -04:00
Matthias Clasen
20392e8840 Cosmetics 2024-06-02 10:48:21 -04:00
Matthias Clasen
426fefff81 Merge branch 'bilelmoussaoui/gi-constructor' into 'main'
gtk: Mark DragIcon.get_for_drag as constructor

See merge request GNOME/gtk!7329
2024-06-02 14:43:29 +00:00
Bilal Elmoussaoui
13013053f7 gtk: Mark DragIcon.get_for_drag as constructor
Fixes downstream issue: https://github.com/gtk-rs/gtk4-rs/issues/1748
2024-06-02 16:54:17 +03:00
Matthias Clasen
62b9a4af75 Drop an unused static 2024-06-02 09:19:22 -04:00
Matthias Clasen
76caf2c812 color value: Organize the code
Add some sections, so I can find my way around.
2024-06-02 08:46:56 -04:00
Matthias Clasen
3d5fce1b9f Fix a bug in color conversion
The linear space corresponding to oklab is oklab, not srgb-linear.
2024-06-02 08:46:33 -04:00
Matthias Clasen
bfe8adbee4 Merge branch 'fix-obvious-doc-issues' into 'main'
Fix obvious docstring issues

See merge request GNOME/gtk!7320
2024-06-02 12:02:06 +00:00
Matthias Clasen
827642303c Merge branch 'fix-getter-for-dropdown' into 'main'
gtkdropdown: Use proper attribute

See merge request GNOME/gtk!7327
2024-06-02 11:56:53 +00:00
Maximiliano Sandoval
6b6a0e1257 docs: Fix {g,s}et_property attributes annotations
Do not use set_property on getters and vice versa.
2024-06-02 13:49:45 +02:00
Martin
7a98176a02 Update Slovenian translation 2024-06-01 08:53:47 +00:00
Maximiliano Sandoval
a93a986ef2 gtkiconview: docs: Add missing return annotation 2024-06-01 10:01:20 +02:00
Maximiliano Sandoval
39dbc5ea87 gtkcombobox: Document popdown signal return value 2024-06-01 10:01:20 +02:00
Maximiliano Sandoval
cf4d13bee3 gdkevents: gdk_event_get_position return value 2024-06-01 10:01:20 +02:00
Maximiliano Sandoval
0bacde8e0a gskpathbuilder: Document add_cairo_path path arg 2024-06-01 10:01:19 +02:00
Maximiliano Sandoval
949cd45bb7 gskstroke: Add missing return annotations 2024-06-01 10:01:19 +02:00
Maximiliano Sandoval
2e9e216641 gtkicontheme: Document lockup_icon arguments 2024-06-01 10:01:19 +02:00
Maximiliano Sandoval
1ab8ffaceb gtktextchild: Document new_with_replacement arg 2024-06-01 10:01:19 +02:00
Maximiliano Sandoval
3cc1726856 gtkstringlist: Document strings property 2024-06-01 10:01:19 +02:00
Maximiliano Sandoval
30eaa2c3cc gtk: Add missing return annotations 2024-06-01 10:01:19 +02:00
Maximiliano Sandoval
ba5993195a filedialog: Document get_accept_label 2024-06-01 10:01:19 +02:00
Maximiliano Sandoval
bf42351ebf cellrendererspinner: Fix active signal docs 2024-06-01 09:04:01 +02:00
Maximiliano Sandoval
ee277f4d92 gtksectionmodel: Fix typo in sections-changed link 2024-06-01 09:04:01 +02:00
Maximiliano Sandoval
00acc7957f gdkcursor: Fix typo in GdkCursorGetTestureCallback 2024-06-01 09:04:00 +02:00
Maximiliano Sandoval
a931335f24 gskglshader: Correct typo in source property 2024-06-01 09:04:00 +02:00
Maximiliano Sandoval
1ef320a9ec gsktransform: Document constructor 2024-06-01 09:04:00 +02:00
Maximiliano Sandoval
411b7f12b5 gtkicontheme: Fix typo in return annotation 2024-06-01 09:03:59 +02:00
Maximiliano Sandoval
611fcfb1c7 gtkgraphicsoffload: Fix typo in prop name 2024-06-01 09:03:59 +02:00
Maximiliano Sandoval
6257a51f4f gtkflowbox: Fix typos in annotations 2024-06-01 09:03:58 +02:00
Maximiliano Sandoval
e24630bd18 gtkenums: Correctly document AnnouncementPriority 2024-06-01 09:03:58 +02:00
Maximiliano Sandoval
6b0b3a4db7 gtkprintsettings: Delete extra whitespace 2024-06-01 09:03:58 +02:00
Maximiliano Sandoval
fd19c7c2ab gtkscrolledwindow: Fix typo in docstring 2024-06-01 09:03:57 +02:00
Maximiliano Sandoval
4aa2206699 gtktextview: Fix typo Textview in docstrings 2024-06-01 09:03:57 +02:00
Maximiliano Sandoval
eae23ebf69 gtkbuilderscope: Correct the argument values
These should match the function arguments.
2024-06-01 09:03:56 +02:00
Maximiliano Sandoval
ecd27f6c3c entry: Fix typos in tabs and show-emoji-icon 2024-06-01 09:03:56 +02:00
Maximiliano Sandoval
01f3c72338 sectionsmodel: Fix typo in docstring 2024-06-01 09:03:55 +02:00
Matthias Clasen
87be414c05 Merge branch 'color-fixes' into 'main'
Fix oklch conversion

See merge request GNOME/gtk!7324
2024-06-01 01:42:45 +00:00
Matthias Clasen
f6d676cc8a inspector: Use gdk_rgba_print when suitable 2024-05-31 21:39:32 -04:00
Matthias Clasen
4961241f26 gsk: Use gdk_rgba_print when suitable 2024-05-31 21:39:04 -04:00
Matthias Clasen
60c944bb94 Add tests for color conversion and interpolation
Add some tests for gtk_css_color_convert and
gtk_css_color_interpolate, mostly based on examples
in the spec.
2024-05-31 21:29:49 -04:00
Matthias Clasen
740c10282f Add gtk_css_color_print and gtk_css_color_to_string
These are useful for testing and debugging.
2024-05-31 21:29:49 -04:00
Matthias Clasen
3a4c69f370 gdk: Add gdk_rgba_print 2024-05-31 21:29:49 -04:00
Matthias Clasen
c3083572fb css: Small api fix
This should have been const.
2024-05-31 21:29:49 -04:00
Matthias Clasen
8ecb00be66 css: Export some color value api for tests
Export enough api to test color conversion and interpolation.
2024-05-31 21:29:49 -04:00
Matthias Clasen
48e707aceb css: Color interpolation fixes
Some minor gotchas and oversights.
2024-05-31 21:29:49 -04:00
Matthias Clasen
e2f9ff2304 Fix oklch conversion
The pseudo-code in the spec is broken.
2024-05-31 21:27:22 -04:00
Matthias Clasen
fa3a72c8f6 Fix oklch conversion
We want to normalize angles to be in [0, 360).
2024-05-31 21:25:54 -04:00
Matthias Clasen
fc45d90834 css: Fix oklab parsing 2024-05-31 19:33:56 -04:00
Matthias Clasen
fcd95cd5c6 css: Fix oklab conversion 2024-05-31 19:33:22 -04:00
Matthias Clasen
b8c1ac41d2 Merge branch 'css-color-missing-components' into 'main'
css: Add GtkCssColor

See merge request GNOME/gtk!7323
2024-05-31 21:05:24 +00:00
Matthias Clasen
90e1ce0906 Merge branch 'new-docstrings' into 'main'
Add missing docstrings

See merge request GNOME/gtk!7321
2024-05-31 19:57:53 +00:00
Matthias Clasen
d121fd5b7d css: Tweak compute for color values
Make color values carry their srgb equivalent and don't turn them
into literals at compute time. This is necessary so we can use their
original color space values in interpolation.

This makes color values a bit larger, but they still fit into one
cacheline.

We don't change handling of named colors and our color expressions.
They still get turned into literal colors.
2024-05-31 15:51:02 -04:00
Matthias Clasen
4d88fcc1db css: Use gtk_css_color_convert
Use gtk_css_color_convert for going to srgb and stop relying on
GdkRGBA for printing.
2024-05-31 15:51:02 -04:00
Matthias Clasen
85fcda178e css: Implement color interpolation
Implement gtk_css_color_convert, which is an attempt to implement
most of https://www.w3.org/TR/css-color-4/#interpolation for the
color spaces we support.
2024-05-31 15:51:02 -04:00
Matthias Clasen
ecc678454b css: Implement color conversion
Implement gtk_css_color_convert, which is an attempt to
implement https://www.w3.org/TR/css-color-4/#color-conversion
for the color spaces we support.

Missing:
- white point adaptation
- gamut mapping
2024-05-31 15:51:02 -04:00
Matthias Clasen
5a85bc691e css: Split off GtkCssColor
Break out a GtkCssColor struct.
2024-05-31 15:51:02 -04:00
Matthias Clasen
d506a5eea8 colorutils: Add some more utils
Add oklab<>srgb-linear and rgb<>hls conversions.
2024-05-31 15:51:02 -04:00
Matthias Clasen
aefa79413b css: Implement missing components in colors
Add support for parsing none for color components, and preserve
that information for serialization. We currently don't use it
for other things, but we should.
2024-05-31 15:51:02 -04:00
Matthias Clasen
73e4eb7552 css: gtk_css_color_value_new_literal static too
This function is only used inside gtkcsscolorvalue.c as well.
2024-05-31 15:50:43 -04:00
Matthias Clasen
dff340530a Merge branch 'matthiasc/for-main' into 'main'
css: Make some color value functions static

See merge request GNOME/gtk!7319
2024-05-31 16:40:33 +00:00
Matthias Clasen
f6ea3e1684 inspector: Make css deprecations opt-in
Add a button to show deprecation warnings (since those will
unfortunately be common for while, due to backwards compat).
2024-05-31 11:25:11 -04:00
Matthias Clasen
f790441505 colorutils: Add some more utils
Add oklab<>srgb-linear and hsl<>rgb conversions.
2024-05-31 10:13:35 -04:00
Matthias Clasen
0c307f7563 css: Make some color value functions static
These aren't used outside of gtkcsscolorvalue.c, so don't export
them.
2024-05-31 10:13:35 -04:00
Matthias Clasen
f89dc9644c Cosmetics 2024-05-31 10:12:28 -04:00
Matthias Clasen
735455b523 Merge branch 'memoryfix' into 'main'
Changes to fix the memorytexture regression

Closes #6260

See merge request GNOME/gtk!7111
2024-05-31 10:35:39 +00:00
Maximiliano Sandoval
d037cfaf44 Add docstrings for deprecated classes 2024-05-31 11:48:24 +02:00
Maximiliano Sandoval
293d63425a gtkiconview: Add missing docstrings 2024-05-31 11:48:24 +02:00
Maximiliano Sandoval
38f9bb87bc gtkentrycompletion: Document missing properties 2024-05-31 11:48:24 +02:00
Maximiliano Sandoval
64abadb370 gtkcolorchooserdialog: Document show-editor 2024-05-31 11:48:23 +02:00
Maximiliano Sandoval
6f85827fcb gtkfilechooserwidget: Document missing props 2024-05-31 11:48:23 +02:00
Maximiliano Sandoval
b0e321cfb8 gtkstylecontext: Document display property 2024-05-31 11:48:23 +02:00
Maximiliano Sandoval
46d0569365 gtktypes: Document GtkCssStyleChange
This is used in the css_changed virtual function of GtkWidget.
2024-05-31 11:48:19 +02:00
Maximiliano Sandoval
2eea911a0f gdktoplevel: Document TitlebarGesture 2024-05-31 11:47:30 +02:00
Maximiliano Sandoval
ee4a817121 gdk: docs: Document error quarks 2024-05-31 11:47:30 +02:00
Maximiliano Sandoval
3d1f914271 gskglrenderer: Document GL renderers 2024-05-31 11:47:30 +02:00
Maximiliano Sandoval
7bb0639a75 gskrendernode: Document serialization error quark 2024-05-31 11:47:29 +02:00
Maximiliano Sandoval
f8f38aab63 gskpathpoint: Document copy and free 2024-05-31 11:47:29 +02:00
Maximiliano Sandoval
75c2bd53aa gtkcsslocation: Document struct 2024-05-31 11:47:29 +02:00
Maximiliano Sandoval
83921750ae gtknotebook: Document signals 2024-05-31 11:47:29 +02:00
Maximiliano Sandoval
413512eba7 gtkheaderbar: Document title-widget property 2024-05-31 11:47:29 +02:00
Maximiliano Sandoval
e824764dc3 gtktexttag: Document properties 2024-05-31 11:47:28 +02:00
Maximiliano Sandoval
61b12abdab gtkshortcutssection: Document change-current-page 2024-05-31 11:47:28 +02:00
Maximiliano Sandoval
07bd5c7b05 gtkscale: Document FormatValueFunc 2024-05-31 11:47:28 +02:00
Maximiliano Sandoval
1dc20eda28 gtk: Document constants 2024-05-31 11:47:28 +02:00
Maximiliano Sandoval
5a9299f626 gtklistbox: Document signals
The docs of move-cursor is taken from FlowBox's.
2024-05-31 11:47:28 +02:00
Maximiliano Sandoval
9c86c67f06 gtkpadcontroller: Document properties 2024-05-31 11:47:27 +02:00
Maximiliano Sandoval
e6ca7668be gtkdebug: Document DEBUG_CHECK 2024-05-31 11:47:27 +02:00
Maximiliano Sandoval
0b540b9ad1 gtkactionable: Document properties 2024-05-31 11:47:25 +02:00
Maximiliano Sandoval
514cdf7398 gtk: Document PrintSettingsFunc 2024-05-31 10:22:44 +02:00
Maximiliano Sandoval
2ab52d73ab gtkprintsettings: Document constants
The docstring is taken form existing constants and their getters
docstring.
2024-05-31 10:22:38 +02:00
Maximiliano Sandoval
b3ae172c1e gtk: Document error quark functions 2024-05-31 10:22:23 +02:00
Maximiliano Sandoval
a6d1df66ec messagedialog: Document buttons property 2024-05-31 10:22:05 +02:00
gayathri.berli@ibm.com
ba92ce342e Merge branch 'main' into memoryfix 2024-05-30 18:21:06 +05:30
Matthias Clasen
9f4c715516 Merge branch 'css-color-minor' into 'main'
css: Simplify color values

See merge request GNOME/gtk!7316
2024-05-30 03:57:31 +00:00
Matthias Clasen
5aa47b6e45 Merge branch 'ebassi/doc-overview-link' into 'main'
docs: Fix link to the Pango reference

See merge request GNOME/gtk!7315
2024-05-30 03:45:13 +00:00
Matthias Clasen
3b40d95581 css: Fix currentcolor serialization
According to css specs, the serialization is supposed to be
all lowercase.
2024-05-29 21:45:10 -04:00
Matthias Clasen
3ad2d91e1c Cosmetics
Fix minor style issues in gtkcsscolorvalue.c.
2024-05-29 21:44:47 -04:00
Matthias Clasen
d4c586e882 css: Simplify color values
Drop the last_value. We don't do that for any other types of
values, so lets not do it here either.
2024-05-29 21:36:10 -04:00
Emmanuele Bassi
612c547ed3 docs: Fix link to the Pango reference
Reported at: https://discourse.gnome.org/t/broken-link-https-docs-gtk-org-gtk4-overview-html/21223
2024-05-30 02:10:48 +01:00
Matthias Clasen
1a777ce7f3 Merge branch 'online-man-pages' into 'main'
docs: Install man pages as html

See merge request GNOME/gtk!7314
2024-05-30 00:18:01 +00:00
Matthias Clasen
7ec4f6e297 Merge branch 'wip/xdg-dialog' into 'main'
gdk/wayland: Implement support for xdg-dialog Wayland protocol

See merge request GNOME/gtk!6837
2024-05-29 23:40:39 +00:00
Matthias Clasen
afaa0f3afd docs: Install man pages as html
This will let us link to them from the docs.
2024-05-29 19:30:09 -04:00
Matthias Clasen
8841a002ed Merge branch 'build-with-unicode' into 'main'
Windows: Build with UNICODE

See merge request GNOME/gtk!7230
2024-05-29 23:20:01 +00:00
Matthias Clasen
6da606aaad Merge branch 'issue-6401-legacy' into 'main'
Win32 GL: Also force not to use depth/stencil/accum bits on legacy contexts (for issue #6401)

See merge request GNOME/gtk!7176
2024-05-29 23:18:04 +00:00
Matthias Clasen
51bd155670 Merge branch 'css-error-fixes' into 'main'
css: Propagate errors properly

See merge request GNOME/gtk!7313
2024-05-29 23:13:14 +00:00
Matthias Clasen
8fa16ec1cc Merge branch '6332_fix_scale_highlight_clip' into 'main'
range: fix highlight clipping

Closes #6332

See merge request GNOME/gtk!7297
2024-05-29 21:03:11 +00:00
Matthias Clasen
04e5a0006d Merge branch '6332_fix_progressbar_highlight_clip' into 'main'
progressbar: fix highlight clipping

Closes #6332

See merge request GNOME/gtk!7312
2024-05-29 20:54:04 +00:00
Matthias Clasen
a1d2169992 Document GTK_DEBUG_CSS
This was overlooked in b603479fe2.
2024-05-29 15:47:40 -04:00
Matthias Clasen
778976f8da css: Propagate errors properly
We should not change the domain and code when we propagate errors
that happen while parsing variable references.

Pointed out in https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7308.
2024-05-29 15:47:40 -04:00
g.willems
f81dea58a2 range: fix highlight clipping
Clipping on padding box prevents the scale highlight to fully paint itself
over the scale trough, including its border.
Use the border box instead.

Fixes #6332
2024-05-29 21:16:34 +02:00
g.willems
e82606a538 progressbar: fix highlight clipping
Clipping using OVERFLOW_HIDDEN relies on widget's padding box.
This prevents the highlight to paint itself over the trough's borders.

Use the border box instead, with a custom snapshot implementation.

Fixes #6332
2024-05-29 21:14:32 +02:00
Matthias Clasen
fe5b28f5b8 Merge branch 'bilelmoussaoui/add-since-annotations' into 'main'
gtk: Add missing docs blob to CssSection

See merge request GNOME/gtk!7296
2024-05-29 19:09:07 +00:00
Matthias Clasen
82fd0d7eef Merge branch 'matthiasc/for-main' into 'main'
css: Fix serialization of oklab() etc

Closes #6748, #6732, and #6735

See merge request GNOME/gtk!7310
2024-05-29 17:08:38 +00:00
Matthias Clasen
16761fcb49 Merge branch 'wip/alice/color-func' into 'main'
csscolorvalue: Add color() support

See merge request GNOME/gtk!7286
2024-05-29 17:02:13 +00:00
Matthias Clasen
4fac5680fb Merge branch 'css-error-docs' into 'main'
css: Clarify docs for GtkCssProvider::parser-error

See merge request GNOME/gtk!7309
2024-05-29 16:41:55 +00:00
Matthias Clasen
4ec4280e51 css: Clarify docs for GtkCssProvider::parser-error
Some of these errors should not be fatal.

Related: #6736
2024-05-29 12:35:14 -04:00
Matthias Clasen
15bb77472d css: Add some parser tests for oklab() etc 2024-05-29 12:05:28 -04:00
Matthias Clasen
5c92d5e081 css: Fix serialization of oklab() etc
The spec requires that oklab() and oklch() are serialized as these
functions, while hwb() is serialized as rgb().

Fixes: #6748
2024-05-29 12:04:20 -04:00
Emmanuele Bassi
1626c5f1e7 css: Create a section if the variable does not have one
In case a variable definition does not have a CSS section associated to
it, we fall back to the previous behaviour of creating a CSS section
with the bounds of the error.

See: https://gitlab.gnome.org/GNOME/gnome-build-meta/-/issues/841
2024-05-29 12:04:20 -04:00
Michael Weghorn
3b5f0ed05e a11y: Use text instead of label for GtkLabel's a11y name
Update the `GTK_ACCESSIBLE_PROPERTY_LABEL` property
in `gtk_label_set_text_internal` using the new text
instead of using the label in
`gtk_label_set_label_internal`.

While the `label` "includes any embedded underlines
indicating mnemonics and Pango markup" [1], the
`text` is the "text is as it appears on screen" [2],
which is more suitable for the accessible name.

With this in place, the text is reported as the
accessible name again after

    commit d5b34aecdd
    Date:   Wed Jan 17 12:49:38 2024 +0100

        a11y: Remove special handling of accessible names for static text widgets

[1] https://docs.gtk.org/gtk4/method.Label.get_label.html
[2] https://docs.gtk.org/gtk4/method.Label.get_text.html

Fixes: #6732
Fixes: #6735
2024-05-29 12:04:20 -04:00
Chun-wei Fan
d2298f1c8f gskvulkandevice.c: Put Vk[Pipeline|RenderPass] in structures
This way, we can simply duplicate the keys as separate pointers to store
the corresponding Vulkan handles so that we can safely hash them, as
Vulkan handles may or may not be pointers depending on the target
platform.

This will fix builds on 32-bit Windows at least.
2024-05-29 12:04:20 -04:00
Chun-wei Fan
085062ab89 gdkvulkancontext.c: Use pointers to hash VkShaderModule
VkShaderModule's may or may not be pointers depending on the target
platform, so use pointers to hash those handles to be safe, and retrieve
them from hashes accordingly.

Fixes build on 32-bit Windows at least.
2024-05-29 12:04:20 -04:00
Chun-wei Fan
9741082467 gskvulkanmemory.c: Use VK_NULL_HANDLE for VkDeviceMemory
...rather than NULL, so that things will build fine on non-LLP, non-64-bit
systems.
2024-05-29 12:04:20 -04:00
Benjamin Otte
3db4a05493 testsuite: Shrink maximum texture size in test
1MB textures can lead to 20s runtimes - which with asan CI being a lot
slower can be a loooong time and cause timeouts.

Limiting them to 16kB still allows hitting max texture size sometimes
but makes sure the test only runs for 3-4s worst case.
I hope that doesn't trigger timeouts even under asan.
2024-05-29 12:04:20 -04:00
Georges Basile Stavracas Neto
e3b9df2cec filechooserwidget: Plug a bunch of GtkBitset leaks
gtk_selection_model_get_selection() is transfer full, and the returned
bitset must be freed by the caller. GtkFileChooserWidget freed none of
them.

Unref the bitsets.

Related: https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/91
2024-05-29 12:04:20 -04:00
Yosef Or Boczko
4a4e445a35 Update Hebrew translation 2024-05-29 12:04:20 -04:00
Chun-wei Fan
db0f9b60ac gsk: Call glDeleteSync() directly
This function does not use the standard __cdecl calling convention on
Windows, meaning using g_clear_pointer() on it directly will cause
crashes on 32-bit Windows.  Just call it directly if the GLsync it uses
exists.
2024-05-29 12:04:20 -04:00
Alice Mikhaylenko
d51de390ba csscolorvalue: Add color() support
Currently we only have sRGB, so it's a bit redundant, but we'll need this
for color-mix()

Once we have more color spaces, they should be added here (presumably the
enum would be in GDK instead, and instead of GdkRGBA these colors would
have a GdkColor.
2024-05-29 19:28:31 +04:00
Matthias Clasen
c14e167a11 Merge branch 'ebassi/css-section-warning' into 'main'
css: Create a section if the variable does not have one

See merge request GNOME/gtk!7306
2024-05-29 14:01:55 +00:00
Emmanuele Bassi
2837a85461 Merge branch 'michaelweghorn/a11y_label_name' into 'main'
a11y: Update label's accessible name on text update

Closes #6732 and #6735

See merge request GNOME/gtk!7293
2024-05-29 12:35:40 +00:00
Benjamin Otte
282510e113 Merge branch 'vulkan-windows-32' into 'main'
Vulkan: Fix build on 32-bit Windows (and likely other non-64-bit LLP platforms)

See merge request GNOME/gtk!7299
2024-05-29 10:34:42 +00:00
Emmanuele Bassi
accabe3eee css: Create a section if the variable does not have one
In case a variable definition does not have a CSS section associated to
it, we fall back to the previous behaviour of creating a CSS section
with the bounds of the error.

See: https://gitlab.gnome.org/GNOME/gnome-build-meta/-/issues/841
2024-05-29 11:29:13 +01:00
Chun-wei Fan
9dbdbaca43 gskvulkandevice.c: Put Vk[Pipeline|RenderPass] in structures
This way, we can simply duplicate the keys as separate pointers to store
the corresponding Vulkan handles so that we can safely hash them, as
Vulkan handles may or may not be pointers depending on the target
platform.

This will fix builds on 32-bit Windows at least.
2024-05-29 18:16:22 +08:00
Chun-wei Fan
5935bc95b7 gdkvulkancontext.c: Use pointers to hash VkShaderModule
VkShaderModule's may or may not be pointers depending on the target
platform, so use pointers to hash those handles to be safe, and retrieve
them from hashes accordingly.

Fixes build on 32-bit Windows at least.
2024-05-29 18:03:13 +08:00
Chun-wei Fan
4c677e4dcd gskvulkanmemory.c: Use VK_NULL_HANDLE for VkDeviceMemory
...rather than NULL, so that things will build fine on non-LLP, non-64-bit
systems.
2024-05-29 12:57:07 +08:00
Benjamin Otte
d4c25c9ec0 Merge branch 'wip/otte/for-main' into 'main'
testsuite: Shrink maximum texture size in test

See merge request GNOME/gtk!7303
2024-05-28 15:31:08 +00:00
Benjamin Otte
b69df2bc4d testsuite: Shrink maximum texture size in test
1MB textures can lead to 20s runtimes - which with asan CI being a lot
slower can be a loooong time and cause timeouts.

Limiting them to 16kB still allows hitting max texture size sometimes
but makes sure the test only runs for 3-4s worst case.
I hope that doesn't trigger timeouts even under asan.
2024-05-28 16:51:03 +02:00
Luca Bacci
7f9363d471 Windows: Build with UNICODE
Build with UNICODE (and _UNICODE) defined when targeting Windows.
2024-05-28 16:37:48 +02:00
Emmanuele Bassi
01d86eab66 Merge branch 'gbsneto/bitset-filechooser-leaks' into 'main'
filechooserwidget: Plug a bunch of GtkBitset leaks

See merge request GNOME/gtk!7302
2024-05-28 13:16:39 +00:00
Yosef Or Boczko
09e85aa809 Update Hebrew translation 2024-05-28 08:54:43 +00:00
Georges Basile Stavracas Neto
d49816d2e6 filechooserwidget: Plug a bunch of GtkBitset leaks
gtk_selection_model_get_selection() is transfer full, and the returned
bitset must be freed by the caller. GtkFileChooserWidget freed none of
them.

Unref the bitsets.

Related: https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/91
2024-05-28 10:24:27 +02:00
Benjamin Otte
59a00d6768 Merge branch 'ngl-windows-32' into 'main'
Fix using the NGL renderer on 32-bit Windows

See merge request GNOME/gtk!7294
2024-05-28 04:39:43 +00:00
Alice Mikhaylenko
6bd6c6acba colorutils: Add linear srgb conversion functions 2024-05-27 15:50:50 +04:00
Chun-wei Fan
be2ff60787 gsk: Call glDeleteSync() directly
This function does not use the standard __cdecl calling convention on
Windows, meaning using g_clear_pointer() on it directly will cause
crashes on 32-bit Windows.  Just call it directly if the GLsync it uses
exists.
2024-05-25 11:07:37 +08:00
Bilal Elmoussaoui
070b9a87b6 gtk: Add missing docs blob to CssSection
For the missing Since annotations mostly.
2024-05-24 12:05:51 +02:00
Emmanuele Bassi
ecbe6a421e Merge branch 'bilelmoussaoui/no-async-finish-docs' into 'main'
docs: Drop _finish blobs

See merge request GNOME/gtk!7295
2024-05-24 05:14:56 +00:00
Michael Weghorn
317e68a58c a11y: Use text instead of label for GtkLabel's a11y name
Update the `GTK_ACCESSIBLE_PROPERTY_LABEL` property
in `gtk_label_set_text_internal` using the new text
instead of using the label in
`gtk_label_set_label_internal`.

While the `label` "includes any embedded underlines
indicating mnemonics and Pango markup" [1], the
`text` is the "text is as it appears on screen" [2],
which is more suitable for the accessible name.

With this in place, the text is reported as the
accessible name again after

    commit d5b34aecdd
    Date:   Wed Jan 17 12:49:38 2024 +0100

        a11y: Remove special handling of accessible names for static text widgets

[1] https://docs.gtk.org/gtk4/method.Label.get_label.html
[2] https://docs.gtk.org/gtk4/method.Label.get_text.html

Fixes: #6732
Fixes: #6735
2024-05-24 05:48:22 +02:00
Bilal Elmoussaoui
9b42377347 docs: Drop _finish blobs
As they are generated by gi-docgen thanks to the newly added async annotations.
It allows bindings that don't expose the _finish
functions to propose less-confusing docs
2024-05-23 20:39:50 +02:00
Andre Klapper
7372a845fb Correct GNOME HIG 404 URI 2024-05-23 16:31:20 +02:00
Carlos Garnacho
cf8c3be030 gdk/wayland: Implement support for xdg-dialog Wayland protocol
This protocol lifts some functionality from the gtk-shell protocol,
namely the ability to tag dialogs as modal. Ensure to use this
new protocol if available for the task, instead of the gtk-shell
protocol.
2024-05-23 12:40:39 +02:00
Carlos Garnacho
4eb715cf81 build: Support in-tree copies of wayland protocols
Make the info about the required protocols an array of definitions
again (a dict instead of an array this time) and add a field that
may be used for version checks of the wayland-protocols found.

Also, make it possible to have versioned protocols in-tree. Both
of these things will allow us to ship in-tree copies of wayland-protocols
without necessarily having to bump the version we depend on.
2024-05-23 12:40:19 +02:00
Luca Bacci
d4899fdf1f Merge branch 'gdk4_win32_fix_dnd_move_cursor' into 'main'
gdk4-win32: Guarantee dnd-move as a cursor name

See merge request GNOME/gtk!7289
2024-05-23 10:16:30 +00:00
Emmanuele Bassi
4142c4d79e Merge branch 'mcatanzaro/#6734' into 'main'
text: fix critical in paste_received

Closes #6734

See merge request GNOME/gtk!7290
2024-05-22 23:17:15 +00:00
Matthias Clasen
ca442f8641 Merge branch 'css-color-spaces' into 'main'
gdk: Add support for some color conversions

See merge request GNOME/gtk!7285
2024-05-22 22:32:52 +00:00
Benjamin Otte
3c1491423a Merge branch 'wip/otte/for-main' into 'main'
gsk: use the correct memory type index

See merge request GNOME/gtk!7287
2024-05-22 21:47:44 +00:00
Michael Catanzaro
eb4993d3fb text: fix critical in paste_received
Here we calculate the length only in the truncate_multiline condition.
Then we pass pos - 1 to gtk_accessible_text_update_contents() as the end
position, triggering this critical that checks to ensure start <= end.
Fix it by always calculating the length of the string that we insert.

This is the first bug fixed as a result of enabling fatal criticals by
default in Epiphany! 🎉

Fixes #6734
2024-05-22 16:06:09 -05:00
g.willems
aa057da1ca win32: Guarantee dnd-move as a cursor name
gdk currently falls back to the default cursor, which may not be
approriate for rendering a DnD move.
2024-05-22 20:55:21 +02:00
Matthias Clasen
1de09d59fb css: Support some color spaces
Support the hwb(), oklab() and oklch() functions for specifying
colors in these color spaces.

See https://bottosson.github.io/posts/oklab/ and
https://www.w3.org/TR/css-color-4/.

Some tests included.
2024-05-22 14:31:56 -04:00
Alejandro Piñeiro
130a6fe0cf gsk: use the correct memory type index
https://gitlab.gnome.org/GNOME/gtk/-/issues/6726
2024-05-22 19:43:03 +02:00
Matthias Clasen
e1f7c027d7 Merge branch 'css-color-docs' into 'main'
css: Update docs slightly

See merge request GNOME/gtk!7281
2024-05-22 17:25:47 +00:00
Arjan Molenaar
396ef5ebe5 Merge branch 'macos-popup-shadows' into 'main'
macos: Take shadows into account when positioning popups

See merge request GNOME/gtk!7266
2024-05-22 13:15:34 +00:00
Emmanuele Bassi
840a20db3b Merge branch 'macos-surface-critical' into 'main'
gdkmacossurface: Set surface before accessing it

See merge request GNOME/gtk!7267
2024-05-22 09:10:35 +00:00
Matthias Clasen
8c6f7d1ae9 Merge branch 'matthiasc/for-main' into 'main'
4.15.1

See merge request GNOME/gtk!7283
2024-05-22 00:00:21 +00:00
Matthias Clasen
c69fa6221b Post-release version bump 2024-05-21 19:54:53 -04:00
Matthias Clasen
3c92c81705 4.15.1 2024-05-21 19:52:12 -04:00
Matthias Clasen
297de981c4 css: Update docs slightly
Add more details about units and calc(), mention new color
syntax and deprecations.
2024-05-21 17:11:30 -04:00
Matthias Clasen
53beb054b6 Merge branch 'wip/alice/colors' into 'main'
csscolorvalue: Actually discard invalid rgb() colors

See merge request GNOME/gtk!7282
2024-05-21 19:31:31 +00:00
Matthias Clasen
0431492284 Merge branch 'wip/alice/spinner' into 'main'
spinner: Only set :checked state when mapped

See merge request GNOME/gtk!7280
2024-05-21 18:54:17 +00:00
Alice Mikhaylenko
aed9cc1874 csscolorvalue: Actually discard invalid rgb() colors 2024-05-21 22:25:20 +04:00
Alice Mikhaylenko
c15804d124 spinner: Only set :checked state when mapped
Avoid doing the animation while it's invisible.

See https://gitlab.gnome.org/GNOME/gtk/-/issues/1025
2024-05-21 19:33:52 +04:00
Matthias Clasen
1bd208d937 Merge branch 'wip/alice/colors' into 'main'
Add modern rgb() and hsl() syntax

See merge request GNOME/gtk!7278
2024-05-21 14:50:08 +00:00
Alice Mikhaylenko
b70bcd6bfe csscolorvalue: Add modern rgb() and hsl() syntax
Make calc() work in colors too, since we need to support degrees for hsl()
hue anyway and it goes through the same machinery. Make that work for
legacy syntax too, matching the spec.

Ignore missing components/none for now.

Ignore gdk_rgba_parser_parse(), that's also used outside css.
2024-05-21 16:32:52 +04:00
Alice Mikhaylenko
74a1d45238 cssnumbervalue: Add get_canonical()
We'll need it to get angle values in degrees for color parsing.
2024-05-21 16:31:26 +04:00
Alice Mikhaylenko
3ada35460d doc: Mention the rad unit
It was missing.
2024-05-21 16:31:26 +04:00
Matthias Clasen
1f133c3d64 Merge branch 'css-color-deprecations' into 'main'
Add gtk_css_parser_warn_deprecated

See merge request GNOME/gtk!7270
2024-05-21 10:57:12 +00:00
Matthias Clasen
4440ce874e Merge branch 'nieldsg/font-filter' into 'main'
gtk: Introduce private GtkFontFilter helper

See merge request GNOME/gtk!7262
2024-05-21 01:22:38 +00:00
Matthias Clasen
db302df82a Merge branch 'fix-a-css-crash' into 'main'
Fix an oversight

See merge request GNOME/gtk!7276
2024-05-21 00:58:02 +00:00
Matthias Clasen
b550b58e8f Merge branch 'css-var-speedup' into 'main'
css: Speed up checking for var()

See merge request GNOME/gtk!7274
2024-05-21 00:57:47 +00:00
Matthias Clasen
ed889b951b css: Deprecate named colors
Warn for uses of @name colors, since these should be replaced with
CSS variables and custom properties. We don't issue deprecation
warnings for @define-color uses, since we may want to keep these
around in theme CSS for a while, for backwards compatibility.

Update all affected tests.
2024-05-20 16:19:30 -04:00
Matthias Clasen
b603479fe2 Add a debug flag for CSS deprecations
It seems better not to spam everybody with this all the time.
2024-05-20 16:02:38 -04:00
Matthias Clasen
7c39b2cea3 Add gtk_css_parser_warn_deprecated
This will come in handy when we start deprecating our homegrown
CSS extensions.
2024-05-20 16:02:38 -04:00
Matthias Clasen
b1bce7a62b Fix an oversight
GtkCssVariableValues are not GtkCssValues. Oops.
2024-05-20 16:02:38 -04:00
Matthias Clasen
fa73e17fba Fix an oversight
GtkCssVariableValues are not GtkCssValues. Oops.
2024-05-20 15:56:40 -04:00
Matthias Clasen
dee2150a04 css: Speed up checking for var()
gtk_css_parser_has_references is meant to be a quick check for
whether a property value contains a variable reference, it just
returns a boolean and doesn't need to report any errors, so lets
not parse the property value any more than we need to.
2024-05-20 13:56:52 -04:00
Matthias Clasen
f647fc3fe2 Merge branch 'css-animation-optimization' into 'main'
css: Avoid more recomputation during animation

See merge request GNOME/gtk!7273
2024-05-20 17:06:10 +00:00
Matthias Clasen
6bae80c331 css: Avoid more recomputation during animation
Don't trigger recomputation if the values didn't change. We only
do this for custom values, since those are animated with a flip
at 50%, so it is likely that we see no-change updates.
2024-05-20 11:59:46 -04:00
Matthias Clasen
2aeb80f490 Merge branch 'ccs-math' into 'main'
css: Implement math functions

See merge request GNOME/gtk!7249
2024-05-20 14:40:48 +00:00
Matthias Clasen
8a2f434443 Merge branch 'css-animation-optimization' into 'main'
css: Less recomputation in animation

See merge request GNOME/gtk!7263
2024-05-20 14:26:18 +00:00
Matthias Clasen
d4134430fc Merge branch 'matthiasc/for-main' into 'main'
css: Avoid a possible memory leak

See merge request GNOME/gtk!7272
2024-05-20 13:49:53 +00:00
Matthias Clasen
73f64971c8 css: Avoid a possible memory leak
Currently, style->variables is always NULL when we get here, but
better to be safe than sorry, and clear the fields before we
overwrite it.
2024-05-20 08:57:28 -04:00
Matthias Clasen
ecc2c953e5 css: Avoid more recomputation
Pass a reason into gtk_css_animated_style_recompute, and avoid
recomputing properties that aren't affected. The possible reasons
for now are that variables of color changes. Better tracking
for currentColor in properties will allow us to improve this
later.
2024-05-20 08:48:20 -04:00
Matthias Clasen
e353117937 css: Make animation recomputation more efficient
Use the same shorthand-keeping trick we do when computing
static styles.
2024-05-20 08:27:47 -04:00
Matthias Clasen
492ae6df35 css: Less recomputation in animation
Only recompute the animated style once all the custom variables
have been updated.
2024-05-20 08:27:47 -04:00
Matthias Clasen
a19d0471e9 Merge branch 'css-var-syntax-errors' into 'main'
css: Report some var() syntax errors

See merge request GNOME/gtk!7264
2024-05-20 12:21:18 +00:00
Matthias Clasen
5b5ba36999 Merge branch 'matthiasc/for-main' into 'main'
css: Add some more variables tests

See merge request GNOME/gtk!7268
2024-05-20 10:21:21 +00:00
Balázs Úr
89b64cbf47 Update Hungarian translation 2024-05-19 23:47:50 +00:00
Matthias Clasen
e65d1f2122 Cosmetics 2024-05-19 18:57:24 -04:00
Matthias Clasen
2756496d47 css: Cosmetics
Don't set the same field twice.
2024-05-19 18:04:20 -04:00
Matthias Clasen
8b653f21cc Drop more underscores
Drop the remaining _'s from css number value apis.
2024-05-19 17:27:37 -04:00
Matthias Clasen
4e6759a126 css: Implement math functions
Implement the functions described in the "Mathematical
Expressions" section of the "CSS Values and Units Module
Level 4" spec, https://www.w3.org/TR/css-values-4/.

Beyond calc(), which we already had, this includes
min(), max(), clamp(),
round(), rem(), mod(),
sin(), cos(), tan(), asin(), acos(), atan(), atan2(),
pow(), sqrt(), hypot(), log(), exp(),
abs(), sign(),
e, pi, infinity and NaN.

Some tests included.
2024-05-19 17:27:37 -04:00
Matthias Clasen
d20e0b0370 Merge branch 'gtk-4-macos-dock-quit' into 'main'
[GTK 4] macOS: Dock "Quit" invokes "app.quit" action

See merge request GNOME/gtk!7265
2024-05-19 21:06:11 +00:00
Mat
ed8255993f gdkmacossurface: Set surface before accessing it
Silences the following critial:
_gdk_macos_surface_update_fullscreen_state: assertion
'GDK_IS_MACOS_SURFACE (self)' failed
2024-05-19 23:58:35 +03:00
Matthias Clasen
f5d69fa0c5 css: Add some more variables tests
Add a test mixing color expressions with variables, and
empty fallback values.
2024-05-19 16:39:02 -04:00
Mat
e1431f31c1 macos: Take shadows into account when positioning popups
Otherwise popups will be misaligned. This becomes noticeable when larger
shadows are used, like in libadwaita.

Regression in 08216dcee9
2024-05-19 23:35:18 +03:00
Thomas Holder
f191fc0047 macOS: Dock "Quit" invokes "app.quit" action
Allows the application to handle "Dock icon > Quit" the same as
"Application menu > Quit".

Requires GtkApplication's `register-session` property.

Suitable replacement for gtk-mac-integration's
`NSApplicationBlockTermination` signal.
2024-05-19 23:10:31 +03:00
Matthias Clasen
b60c60f03b css: Report some var() syntax errors
Detect cases such as var(), var(-), var("a") or var(21) early
and report them as syntax errors.

Test included.

Related: #6715
2024-05-19 15:56:26 -04:00
Matthias Clasen
af0c277bba Merge branch 'matthiasc/for-main' into 'main'
css: Lose more underscores

See merge request GNOME/gtk!7261
2024-05-19 05:14:05 +00:00
Niels De Graef
88203fbf4d gtk: Introduce private GtkFontFilter helper
Extract the "user filter" code from the `GtkFontChooserWidget`, for a
couple of reasons:

* If we want to expand the filter in the future (e.g. to filter on
  variable fonts, or check for multiple languages), we have a nice place
  to put this.
* It simplifies the font chooser widget a tiny bit, as it's a pretty big
  file which can be hard to follow.
* With a custom `GtkFilter` subclass, we can actually avoid doing a bit
  of work when initially showing the widget, as we can return
  `GTK_FILTER_MATCH_ALL` when nothing is selected yet (which is not
  possible with a `GtkCustomFilter'). It's not much, but it's still nice
2024-05-18 15:34:13 +02:00
Matthias Clasen
970c9eef63 css: Use an anonymous union for color values
We already do this for number values, and it looks less messy.
2024-05-18 09:23:40 -04:00
Matthias Clasen
2439876bd3 css: Simplify color resolving a bit
We know the initial value of the color property, no need to
resolve it again.
2024-05-18 09:09:21 -04:00
Matthias Clasen
97582ae9ad css: Simplify color resolving
The cycle argument is purely a detail of the internal implementation,
no need to have it in the api.
2024-05-18 09:03:57 -04:00
Matthias Clasen
a5b85f0dc5 css: Lose more underscores
Drop the _ from the color value apis. Update all callers.
2024-05-18 08:59:24 -04:00
Matthias Clasen
aefb16510b Merge branch 'css-fiddling' into 'main'
css: Lose some underscores

See merge request GNOME/gtk!7255
2024-05-16 01:49:52 +00:00
Benjamin Otte
4360d433b5 Merge branch 'wip/otte/for-main' into 'main'
columnview: Actually check the listview in return_if_fail()

See merge request GNOME/gtk!7254
2024-05-16 01:30:20 +00:00
Matthias Clasen
5927319589 css: Inline a few functions
These are just operating on the value base and can easily be inlined.
2024-05-15 20:54:45 -04:00
Matthias Clasen
25db645f65 css: Lose some underscores
Drop the _ from all the gtk_css_value apis.
2024-05-15 20:54:43 -04:00
Benjamin Otte
b3c6a98132 vulkan: Add a missing extension
We need to enable this one, too.

Thanks validation layers!
2024-05-16 02:24:17 +02:00
Benjamin Otte
031109aec3 columnview: Actually check the listview in return_if_fail()
This was missed when adding return_if_fail()s in
172cdf8e21.

Related: !7240
2024-05-16 02:24:17 +02:00
Jordi Mas i Hernandez
18d2f9c8a4 Update Catalan translation
(cherry picked from commit 27d75be15e)
2024-05-15 19:53:58 +00:00
Jordi Mas i Hernandez
0ae721f144 Update Catalan translation
(cherry picked from commit 8ccc36c389)
2024-05-15 18:02:53 +00:00
Matthias Clasen
7898d1b46d Merge branch 'wip/sophie-h/print' into 'main'
printdialog: Fix some annotiations

Closes #6709

See merge request GNOME/gtk!7251
2024-05-14 20:51:54 +00:00
Sophie Herold
3648398f6d printsetup: Remove nullable from settings getters
GtkPrintSetup is initialized with the values returned from the portal.
Therefore the page setup and the print settings can never be NULL.
2024-05-14 22:21:19 +02:00
Sophie Herold
019916c5b9 printdialog: Remove nullable for GError functions
Functions that set a GError should not be marked as nullable if they
only return NULL on error.
2024-05-14 22:12:04 +02:00
Sophie Herold
ebb31590ae printdialog: Add missing nullable to getters
The initial values are NULL.
2024-05-14 22:10:29 +02:00
Benjamin Otte
32ea1cf32d Merge branch 'wip/kabus/scroll_to_null_tile' into 'main'
listbase: Fix a null dereference

See merge request GNOME/gtk!7240
2024-05-14 19:48:42 +00:00
Khalid Abu Shawarib
172cdf8e21 listbase: Return early on non-existent scroll position 2024-05-14 15:27:38 +03:00
Matthias Clasen
dc07bcf3a3 Merge branch 'michaelweghorn/a11y_atspi_map_level_property' into 'main'
a11y atspi: Map GTK_ACCESSIBLE_PROPERTY_LEVEL to AT-SPI attr

See merge request GNOME/gtk!6549
2024-05-13 16:02:53 +00:00
Matthias Clasen
bd96c10563 Merge branch 'matthiasc/for-main' into 'main'
testsuite: Improve test-css-parser

See merge request GNOME/gtk!7248
2024-05-13 14:57:15 +00:00
Matthias Clasen
76299396cf testsuite: Improve test-css-parser
Make it so that --generate parse produces output that can be
directly pasted into the ref.css file.
2024-05-13 10:04:28 -04:00
Ekaterine Papava
a96dd2ad0a Update Georgian translation 2024-05-13 00:45:14 +00:00
Matthias Clasen
1e210e83bb Merge branch 'structcleanup' into 'main'
gdk: Remove unused struct 'XPointerUngrabInfo'

See merge request GNOME/gtk!7245
2024-05-12 04:52:19 +00:00
Dr. David Alan Gilbert
14f1a91bff gdk: Remove unused struct 'XPointerUngrabInfo'
'XPointerUngrabInfo' appears unused since
commit 26cbf87d7d ("New approach for grab tracking code")
Remove it.

Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
2024-05-12 01:06:31 +01:00
Matthias Clasen
3f2bcdf82e Merge branch 'matthiasc/for-main' into 'main'
wayland: Tweak cursor sizing code

See merge request GNOME/gtk!7244
2024-05-11 03:40:53 +00:00
Matthias Clasen
c61d8bc188 wayland: Tweak cursor sizing code
We want to take advantage of a viewporter also for named cursors.
2024-05-10 23:10:50 -04:00
Matthias Clasen
4e5976427b NEWS: Updates 2024-05-10 21:47:44 -04:00
Matthias Clasen
7fcdb0205f Merge branch 'wip/alice/css-variables' into 'main'
CSS custom properties/variables

See merge request GNOME/gtk!6540
2024-05-11 01:38:10 +00:00
Benjamin Otte
4814c5f653 array: Don't overflow array size
Copy what gcc's libstdc++ does for vectors to avoid overflows:

1. Define a max size macro and assert against it
   Note that we don't assert but actually check, because this needs
   to abort even if assertions are disabled.
2. Don't do fancy math to compute new capacity.
   Just size *= 2 instead and be careful about overflow.
2024-05-10 21:22:03 -04:00
Alice Mikhaylenko
eb24e3548f inspector: Sort GTK CSS properties between standard and custom ones 2024-05-10 18:29:48 +04:00
Alice Mikhaylenko
87f0f374a9 inspector: Show custom properties for css nodes 2024-05-10 18:29:48 +04:00
Alice Mikhaylenko
0cd95951e6 testsuite: Add css variables tests 2024-05-10 18:29:48 +04:00
Matthias Clasen
c45815c217 css: Improve error reporting for variables
Emit errors for all the variables that were being expanded
if an error occurs while parsing a property value at compute time.

Include the variables that are being expanded in the error message.
2024-05-10 18:29:48 +04:00
Matthias Clasen
b914869715 css parser: Keep variables for tokenizers
Add a function that gets the names of the variables that the
parser is currently in the process of expanding. This will
be used for error reporting.
2024-05-10 18:29:48 +04:00
Matthias Clasen
ff5699e097 css parser: Inline the tokenizer array
This is in preparation of associating more data with the token streams.
2024-05-10 18:29:47 +04:00
Matthias Clasen
8846f85874 css provider: Set bytes on sections
Pass the bytes we're parsing to the sections, and keep a pointer
to them around, so we can compare them in the has_section
implementation.

This commit also corrects some of the location information that
we add into the section for variables to be more accurate.
2024-05-10 18:29:47 +04:00
Matthias Clasen
fc1c6cfb1a css parser: Add gtk_css_parser_get_bytes
Gets the bytes that the parser is operating on.
2024-05-10 18:29:47 +04:00
Matthias Clasen
77028362ab css provider: Set sections on all variable values
We were doing it in one case, but forgetting it in another.
These sections are necessary to report meaningful error locations
when parsing property values at compute time.
2024-05-10 18:29:47 +04:00
Matthias Clasen
496aee5b02 style cascade: Propagate errors
When we compute values, the provider we use ends up being the
style cascade. If we hit a parser error when parsing variable-bearing
property values at compute time, we emit the error on that provider.

By making the cascade propagate the error back to the proper css
provider that contains the section in question, we get it reported
back to the css editor in the inspector.
2024-05-10 18:29:47 +04:00
Matthias Clasen
b2fb624496 style provider: Add a has_section api
Add gtk_style_provider_has_section and implement it for
GtkCssProvider. This will be used later to direct error
emissions to the right provider.
2024-05-10 18:29:47 +04:00
Matthias Clasen
f2ef5d85ea css parser: Add bytes to sections
We will use this later to link sections back to the providers
they come from.
2024-05-10 18:29:47 +04:00
Matthias Clasen
7eca32edf0 css parser: Add gtk_css_parser_skip_whitespace
Does what it says.
2024-05-10 18:29:47 +04:00
Matthias Clasen
7775bcf2fb css: Don't accept junk
Check that there is no junk at the end of the property value
when parsing variable-bearing properties at compute time.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
ed35f6f8b8 css: Condense compute parameters into GtkCssComputeContext
That list is getting out of hand, let's make it a struct.
2024-05-10 18:29:47 +04:00
Matthias Clasen
307942e1f7 css: Only compute shorthand values once
When computing a style, only compute the shorthand value once.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
92b7231168 csskeyframes: Support variables 2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
14d7eb97d2 cssanimation: Recompute values while playing
This will be necessary for supporting variables in animations.

For this we need to pass all the gtk_css_value_compute() parameters into
GtkCssAnimatedStyle: parent style and provider.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
fed1c3d3fc cssstaticstyle: Split property lists into a separate header
We'll need to use them in GtkCssAnimatedStyle too.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
e1ac97a185 cssvalue: Pass an extra GtkCssVariableSet to compute()
We'll need this to support variables in @keyframes, since styles will
need to combine their own variables and the ones from the keyframes.

See the next commit, this one is split out to avoid a huge diff.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
08a48dd97e Implement basic support for CSS variables 2024-05-10 18:29:47 +04:00
Matthias Clasen
50df3ebb46 css: Give shorthand properties an ID
This will be used in future commits.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
df77f22740 cssvalue: Add contains_variables()
We'll need this to know which values to recompute for animations.

It will be used in the next commit, it's separate to avoid the diff
being too large.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
2437a551ec csstokenizer: Add save() and restore()
We'll need that to check if property values contain variables.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
46ab71fc8a cssprovider: Copy bytes when loading
We'll need to keep accessing them later to compute values with variables,
so we can't avoid this anymore.
2024-05-10 18:29:47 +04:00
Matthias Clasen
f922ff8597 Merge branch 'speed-up-cairo-icons' into 'main'
gsk: Speed up mask nodes with cairo

Closes #6700

See merge request GNOME/gtk!7243
2024-05-10 14:10:18 +00:00
Matthias Clasen
690c06109e gsk: Speed up mask nodes with cairo
Switch symbolc icon drawing from color-matrix to mask nodes
make the performance of the iconscroll demo crater (from 60fps
to 10fps).

Apply the same optimization we already have for color-matrix
nodes when drawing mask nodes. This gets us back to 60fps.

Fixes: #6700
2024-05-10 07:24:25 -04:00
Matthias Clasen
94505987fe Merge branch 'matthiasc/for-main' into 'main'
css parser: Fix a typo

See merge request GNOME/gtk!7241
2024-05-10 04:11:08 +00:00
Matthias Clasen
c6d7b704cb css parser: Fix a typo
Due to an ARAY vs ARRAY mishap, we weren't actually preallocating
any blocks. Fix that, and reduce the number of preallocated blocks
to 12. That seems sufficient, since parsing the Default theme never
needs more than 5 blocks.
2024-05-09 23:26:55 -04:00
Hugo Carvalho
349509c332 Update Portuguese translation
(cherry picked from commit 40e99590e7)
2024-05-09 16:01:52 +00:00
Matthias Clasen
84fd420271 Merge branch '6674_fix_flickering_tooltip' into 'main'
tooltip: query tooltip on widget under pointer only

Closes #6674

See merge request GNOME/gtk!7237
2024-05-08 00:43:05 +00:00
Matthias Clasen
0c40defaf1 Merge branch 'realize_accessible_before_add_event_emission' into 'main'
a11y: Realize the AT context before firing a children added event for it

See merge request GNOME/gtk!7229
2024-05-08 00:42:33 +00:00
Matthias Clasen
cda1733fc7 Merge branch 'css-parser-block-array' into 'main'
css parser: Use a GdkArray for blocks

See merge request GNOME/gtk!7236
2024-05-07 23:15:31 +00:00
Matthias Clasen
0ee851c8c7 Merge branch 'matthiasc/for-main' into 'main'
icontheme: Clarify docs a bit

See merge request GNOME/gtk!7234
2024-05-07 18:57:24 +00:00
g.willems
d665274eb1 tooltip: query tooltip on widget under pointer only
When changing the tooltip text or markup of widget A, we simulate a
motion event on that widget to update the display.
But if there is an active tooltip on widget B, then the current code
belives we moved the pointer from B to A thus hides/shows the tooltip
of B alternatively.

Instead, simulate the motion event on the widget currently under the pointer.
This will avoid flickering if we keep the pointer over widget B.

Fixes #6674
Closes #6674
2024-05-07 19:32:15 +02:00
Matthias Clasen
ed3b73871f css parser: Small optimization
Avoid creating a GFile until it is needed.
2024-05-07 12:34:37 -04:00
Matthias Clasen
e570eb4f86 css parser: Use a GdkArray for blocks
This avoids some allocations, and is typesafe.
2024-05-07 12:34:36 -04:00
Lukáš Tyrychtr
81b6251073 a11y: Realize the AT context before firing a children added event for it
This allows, with some other changes, AdwToasts to be read on appearance by Orca.
2024-05-07 15:49:59 +02:00
Matthias Clasen
cfaf619620 icontheme: Clarify docs a bit
Mention that 'desired size' is in application pixels.

Related: !7056
2024-05-06 20:37:34 -04:00
Benjamin Otte
de5b6764bc Merge branch 'wip/otte/for-6694' into 'main'
dmabuf: Ref previous context

Closes #6694

See merge request GNOME/gtk!7232
2024-05-06 22:56:05 +00:00
Benjamin Otte
bc17dfa83d dmabuf: Ref previous context
In case the context's only reference was held by being the current
context, setting the new context would free it.

Resetting it later would then be a use-after-free.

Fixes #6694
2024-05-07 00:34:47 +02:00
Matthias Clasen
84a98f74c1 Merge branch 'fix-test-breakage' into 'main'
Fix recent test breakage

See merge request GNOME/gtk!7233
2024-05-06 21:56:13 +00:00
Matthias Clasen
50facedc47 Fix recent test breakage
I neglected to fix affected tests in 76b0687467, since
ci was down at the time. Sorry about that.
2024-05-06 17:11:44 -04:00
Matthias Clasen
32a4f805b8 gsk: Require dmabuf support for Vulkan
Don't use the Vulkan renderer if Vulkan doesn't support any
dmabuf formats.
2024-05-05 15:19:17 -04:00
Matthias Clasen
200cacc3ad Merge branch 'matthiasc/for-main' into 'main'
inspector: Show more key event details

See merge request GNOME/gtk!7224
2024-05-05 17:29:29 +00:00
Matthias Clasen
eed3cab29f Merge branch 'list-item-factory-docs' into 'main'
docs: Clarify types for BuilderListItemFactory

See merge request GNOME/gtk!7226
2024-05-05 15:00:49 +00:00
Matthias Clasen
76b0687467 Put newlines before base64 blobs
This makes things look a bit cleaner in the node editor, since
the first line no longer sticks out.
2024-05-05 10:16:01 -04:00
Matthias Clasen
5039dc40f8 Merge branch 'main' into 'main'
vulkan: Don't queue presentation if image acquisition fails

See merge request GNOME/gtk!7204
2024-05-05 04:06:44 +00:00
Doğukan Korkmaztürk
7c3de4a2da vulkan: Recreate swapchain when it is necessary or beneficial
Currently, GTK does not check the result of vkAcquireNextImageKHR() and
assumes that it always succeeds. As a result, the vkQueuePresentKHR() is
unconditionally set to wait for the semaphore passed to
vkAcquireNextImageKHR() earlier.

However, if vkAcquireNextImageKHR() fails for some reason, the semaphore
passed to it does not get signalled. This causes the presentation
command to wait for the semaphore to be signalled indefinitely, which
causes GTK to hang.

This change adds error handling around vkAcquireNextImageKHR() to make
GTK recreate the Vulkan swapchain when it is necessary or beneficial and
helps avoiding situations that could cause indefinite waits.
2024-05-04 22:14:33 -04:00
Matthias Clasen
b486e9b760 inspector: Show more key event details
Consumed modifiers are relevant to understanding why shortcut
do or do not match, so show them.
2024-05-04 21:29:40 -04:00
Matthias Clasen
ce2fd8a0d0 NEWS: Updates 2024-05-04 21:29:40 -04:00
Hugo Carvalho
99b1b26fdb Update Portuguese translation
(cherry picked from commit a249b58094)
2024-05-04 22:23:06 +00:00
James Westman
b7e4bbaf74 docs: Clarify types for BuilderListItemFactory
The docs for GtkBuilderListItemFactory previously stated that the
template must extend GtkListItem. However, this is not always true.
GtkListView has headers which must extend GtkListHeader, and
GtkColumnView has its own types.

Clarified this in the GtkBuilderListItemFactory docs, and specified the
expected types in the GtkColumnView, GtkListView, and GtkGridView docs.
2024-05-04 13:20:41 -05:00
Matthias Clasen
f579b171a9 Merge branch 'gbsneto/more-win32-cleanups' into 'main'
Various cleanups around Win32

See merge request GNOME/gtk!7223
2024-05-03 17:27:05 +00:00
Georges Basile Stavracas Neto
f9929d15eb gtk-demo: Remove set-but-unused variable 2024-05-03 12:30:39 -03:00
Georges Basile Stavracas Neto
c45a6ad52d gsk/gpu: Use G_GSIZE_FORMAT for printing gsizes
On Windows, gsize is a long long unsigned. The compiler complains about
that.

Use G_GSIZE_FORMAT which translates to %llu on Windows, %lu on most
platforms, and sometimes just %u on rare cases.
2024-05-03 12:30:39 -03:00
Matthias Clasen
7233e38aa8 Merge branch 'gbsneto/cleanup-meson-profiler' into 'main'
testsuite: Remove leftover code from meson.build

See merge request GNOME/gtk!7222
2024-05-03 13:44:07 +00:00
Benjamin Otte
73ba97acd9 Merge branch 'duplicate-gl-version' into 'main'
glcontext: Remove duplicate check for GL version

See merge request GNOME/gtk!7221
2024-05-03 13:42:03 +00:00
Georges Basile Stavracas Neto
7d2ad604d2 win32/vulkancontext: Remove unused variable
Silences a compiler warning.
2024-05-03 09:52:57 -03:00
Georges Basile Stavracas Neto
45e64b915c win32/wgl: Initialize hwnd to NULL
Otherwise there's a valid code path that may return it uninitialized.
2024-05-03 09:51:46 -03:00
Georges Basile Stavracas Neto
ebaef9f18b win32/cursor: Ignore GdkPixbuf deprecation warning
Seems harmless to ignore this for now, other bits of code also ignore
this.
2024-05-03 09:49:46 -03:00
Robert Ancell
c73fe8ac4a glcontext: Remove duplicate check for GL version 2024-05-03 16:40:01 +12:00
Georges Basile Stavracas Neto
8ed8f883d1 testsuite: Remove leftover code from meson.build
Performance tests were dropped at 5dd0d39a6b. The 'profiler' option
was renamed to 'sysprof' by commit e915a1aa7f.
2024-05-02 20:28:27 -03:00
Matthias Clasen
032a5afc20 Merge branch 'accessible_help_text' into 'main'
accessible help text

See merge request GNOME/gtk!6992
2024-05-02 17:20:17 +00:00
Matthias Clasen
0064500146 Merge branch 'michaelweghorn/a11y_role_mapping' into 'main'
a11y atspi: Improve mapping for container roles

See merge request GNOME/gtk!7209
2024-05-02 01:33:02 +00:00
Matthias Clasen
4582ddcad9 Merge branch 'matthiasc/for-main' into 'main'
gtk-demo: Name some idles

See merge request GNOME/gtk!7218
2024-05-02 01:30:42 +00:00
Matthias Clasen
8bb2720494 icontheme: Move css style code where it belongs
Move gtk_icon_theme_lookup_symbolic_colors to gtkcssstyle.c, and
rename it to gtk_css_style_lookup_symbolic_colors.

Update all callers.
2024-05-01 16:06:16 -04:00
Matthias Clasen
3b8218a99e gtk-demo: Name some idles
These show up in profiles, so give them a name.
2024-05-01 16:06:16 -04:00
Matthias Clasen
9a8fa8dd82 Merge branch 'wip/chergert/fix-6684' into 'main'
undo: fix off-by-one when prepending to inline string

Closes #6684

See merge request GNOME/gtk!7217
2024-05-01 19:50:23 +00:00
Matthias Clasen
d6892c85dc Merge branch 'serialize-hint-metrics' into 'main'
gsk: Serialize hint metrics too

See merge request GNOME/gtk!7215
2024-05-01 18:40:13 +00:00
Christian Hergert
d3c20c3269 undo: fix off-by-one when prepending to inline string
This fixes the conditional in istring_prepend() to match other uses,
notably to match istring_append().

Fixes #6684
2024-05-01 11:28:55 -07:00
Matthias Clasen
9904259661 gsk: Serialize hint metrics too
We need this to ensure that we properly roundtrip text nodes
without any changes.
2024-05-01 14:00:18 -04:00
Emin Tufan Çetin
a8fcde11de Update Turkish translation 2024-05-01 16:19:02 +00:00
Matthias Clasen
d2d4cd64cd Merge branch 'no-a11y-focus-events' into 'main'
a11y: Stop emitting Focus events

See merge request GNOME/gtk!7213
2024-05-01 15:18:42 +00:00
Matthias Clasen
2c7e68d98f Merge branch 'matthiasc/for-main' into 'main'
Revert "gdk/frameclock: add mark when we discover frames may drop"

See merge request GNOME/gtk!7214
2024-05-01 12:43:52 +00:00
Matthias Clasen
6f42f8ef2c Revert "gdk/frameclock: add mark when we discover frames may drop"
This reverts commit 84a304e66e.

This produces marks that are confusing to me. They don't correlate
with actual gaps in the frame cycle and often overlap with regular
'window presented' marks. Also, the function we are emitting these
marks from is called from the get_frame_time getter, and we
definitely don't want to emit marks from there.
2024-05-01 08:03:16 -04:00
Matthias Clasen
152dd70cde a11y: Drop the Focus event from the interface too
We don't use it anymore.
2024-05-01 07:57:19 -04:00
Matthias Clasen
8ec1045c87 a11y: Stop emitting Focus events
These have been deprecated for a long time, and we have been asked
to stop emitting them.

Related: #454
2024-05-01 07:55:47 -04:00
Matthias Clasen
46866b8a66 Merge branch 'matthiasc/for-main' into 'main'
vulkan: Improve logging around caches

See merge request GNOME/gtk!7208
2024-04-30 16:11:25 +00:00
Matthias Clasen
9df6f802f2 gtk-demo: Better accessibility for the sidebar
Add an accessible description saying how many search reasults
we have. This is an experiment.

Related: #6678
2024-04-30 11:54:56 -04:00
Michael Weghorn
ad8613876c a11y atspi: Improve mapping for container roles
GTK_ACCESSIBLE_ROLE_GENERIC is for
"a nameless container that has no semantic meaning of its own",
for which AT-SPI role ATSPI_ROLE_PANEL [1]
("A generic container that is often used to group
objects.") fits better than ATSPI_ROLE_FILLER
("A object that fills up space in a user interface."),
so map to this one.

With this in place, widgets like GtkBox are again
reported with the panel role on AT-SPI level after
commit a86923de94
("a11y: Change the role for many containers"),
whose commit message suggests that the change
on the AT-SPI level was unintended.

For GTK_ACCESSIBLE_ROLE_GROUP, use the corresponding
ATSPI_ROLE_GROUPING ("A group of related widgets.
This group typically has a label.").

[1] https://docs.gtk.org/atspi2/enum.Role.html
2024-04-30 14:44:11 +02:00
Matthias Clasen
1bbca0cd25 vulkan: Don't forget to update the cache size
In order for the size change check to make sense, vk_pipeline_cache_size
needs to correspond to the size of the cache we last wrote to disk.

We were forgetting to update it after saving the cache, so the
check was ineffective.
2024-04-30 08:28:39 -04:00
Matthias Clasen
83784c17a3 vulkan: Improve logging around caches
Add some more logging around the pipeline cache.
2024-04-30 08:28:39 -04:00
Matthias Clasen
3f46d0f2fa Merge branch 'matthiasc/for-main' into 'main'
gsk: Improve logging

See merge request GNOME/gtk!7207
2024-04-30 11:59:06 +00:00
Matthias Clasen
ef1ff8313f gsk: Improve logging
Log the shader compilation with sufficient detail.
2024-04-30 07:36:42 -04:00
Matthias Clasen
119a07e055 vulkan: Add a profiler mark for pipeline cache save
This is a rare event, and the file isn't small, so show it in profiles.
2024-04-30 07:36:42 -04:00
Matthias Clasen
abfd94d2d9 Merge branch 'matthiasc/for-main' into 'main'
vulkan: Add profiling to Vulkan initialization

See merge request GNOME/gtk!7205
2024-04-29 23:09:15 +00:00
Matthias Clasen
6022fbcdf8 vulkan: Add profiling to Vulkan initialization
This helps understanding where our startup time is spent.
2024-04-29 18:28:03 -04:00
Matthias Clasen
744016e768 Merge branch 'matthiasc/for-main' into 'main'
gsk: Drop statistics from GSK_DEBUG=renderer

See merge request GNOME/gtk!7203
2024-04-29 18:30:59 +00:00
Benjamin Otte
d39f50a4ee Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Use narrow range instead of full range

Closes #6672

See merge request GNOME/gtk!7202
2024-04-29 16:28:28 +00:00
Matthias Clasen
c23d3c4406 gsk: Add debug spew to renderer selection
Reshuffle things a bit and make GSK_DEBUG=renderer print out
more information about why renderers were skipped or selected.
2024-04-29 12:28:15 -04:00
Matthias Clasen
1e2eae4ddf gsk: More detailed debug spew
Include information about why a renderer was selected in
GSK_DEBUG=renderer.
2024-04-29 12:12:22 -04:00
Matthias Clasen
77eb3df7c0 gsk: Drop statistics from GSK_DEBUG=renderer
This only works with the old gl renderer, and it interferes with
the setup information that is printed by that category.
2024-04-29 12:12:22 -04:00
Matthias Clasen
e540022869 x11: Implement a missing method
Vulkan on X11 was getting spew for missing an empty_frame
implementation.
2024-04-29 12:12:22 -04:00
Benjamin Otte
e6700405c9 dmabuf: Use narrow range instead of full range
It's way more common, and Mutter uses it, too.

Avoid visual glitches when going in/out of offload.

Fixes #6672
2024-04-29 14:30:56 +02:00
Artur S0
5bbd8e12fa Update Russian translation 2024-04-29 11:59:09 +00:00
Matthias Clasen
8b59771cd1 Merge branch 'matthiasc/for-main' into 'main'
inspector: Cosmetics

See merge request GNOME/gtk!7199
2024-04-29 10:27:26 +00:00
Matthias Clasen
8a0a08e4ce Merge branch 'only-fg-symbolics' into 'main'
Reencode all our symbolic pngs

See merge request GNOME/gtk!7196
2024-04-29 10:27:16 +00:00
Matthias Clasen
bef6352401 More consistency fixes for texture utils
Be consistent about filename vs path.
2024-04-29 00:42:49 -04:00
Matthias Clasen
60a43ddce0 All non-integral scales in texture utils
This might be used with fractional scales in the future.
2024-04-29 00:35:27 -04:00
Matthias Clasen
90c9e88ee9 scaler: Consistency fixes
Follow the pattern that we use in GDK:
scale_factor = int
scale = double
2024-04-29 00:35:27 -04:00
Matthias Clasen
d860bf95ab Consistency fixes for texture utils
Use the with_fg naming consistently.
2024-04-29 00:35:27 -04:00
Matthias Clasen
a3bd0a3e17 gsk: Cosmetics
Tweak a profiler counter name.
2024-04-28 23:54:55 -04:00
Matthias Clasen
d274c7df06 testsuite: Make offload tests more robust
Skip the offload tests when we find ourselves in situations
where offloading won't work.
2024-04-28 23:54:55 -04:00
Matthias Clasen
9a5f482e1a reftests: Stop using xpm images
We are phasing out the fringe pixbuf loaders, so xpm is going
away as a default-supported image format.
2024-04-28 23:54:55 -04:00
Matthias Clasen
2f6140c066 docs: Clarify the cairo interaction section
This was giving outdated advice.
2024-04-28 23:54:55 -04:00
Matthias Clasen
9ce4471527 Speed up symbolic svg loading
If the svg doesn't use the symbolic style classes, we can avoid
loading it multiple times.

This brought the time for loading system-run-symbolic at 256@2
from 6.8ms down to 2ms.
2024-04-28 23:54:03 -04:00
Matthias Clasen
cda4ec48b2 Merge branch 'doc-fixes' into 'main'
gskpathbuilder: Fix doc typo

See merge request GNOME/gtk!7200
2024-04-29 03:52:04 +00:00
Matthias Clasen
d9582c123e inspector: Cosmetics
We've been using title capitalization and spelled out names
in the node details pane, so be consistent.
2024-04-28 23:44:18 -04:00
Matthias Clasen
4d30aacb0c Reencode all our symbolic pngs
This adds the only-foreground information and will let us use
these symbolics more efficiently.
2024-04-28 23:42:02 -04:00
Matthias Clasen
4862c3f779 Add 'only foreground' to texture utility api
Add an 'only_fg' argument to all our internal texture utility
api, so GtkIconTheme can find out if a symbolic png or svg uses
colors beyond the foreground or not.

This information is used in gtk_symbolic_paintable_snapshot_symbolic
to optimize rendering of such symbolic icons.
2024-04-28 23:42:02 -04:00
Matthias Clasen
08d1353cde loaders: Make it possible to load png options
We want to store some metadata in our symbolic pngs, so make it
possible to get options when loading a png, along with the texture.

Update all callers.
2024-04-28 23:42:02 -04:00
Matthias Clasen
585dadf575 Small optimization
Avoid copying a potentially large blob more than necessary.
2024-04-28 23:42:02 -04:00
Joshua Lee
d069eb173a path builder: Fix doc typo 2024-04-28 22:24:38 +01:00
Matthias Clasen
6015560b63 Merge branch 'wip/otte/for-main' into 'main'
various fixes

Closes #6668 and #6656

See merge request GNOME/gtk!7194
2024-04-28 19:44:58 +00:00
Benjamin Otte
5a776389d7 reftests: Use longer words when testing wrapping
"Hello" might be shorter than "Hi Ho" in some fonts and then that one
gets wrapped, too.

So choose perfectly cromulent words for this purpose instead.
2024-04-28 13:51:42 +02:00
Benjamin Otte
6c2dfed5a5 inspector: Add details for textures
In particular, add all the dmabuf texture details.

I originally wanted this just to see if a texture was the type I
expected it to be while debugging, but then I thought "why not add the
rest, too?"

I did not add GL-internal texture details (like GL format,
internalformat etc), because that would require a make_current().
2024-04-28 13:51:42 +02:00
Benjamin Otte
7dec24c2cc inspector: Make add_text_row() be a printf-style function
There's a few cases where I had to add "%s" as the format string, but
most changes got rid of printf() + free() combinations.
2024-04-28 13:51:42 +02:00
Benjamin Otte
c20e7a0c5d glcontext: Split dmabuf import codepaths
Use different codepaths for known formats vs unknown formats.

Be more careful with unknown formats and always import them as
GL_TEXTURE_EXTERNAL_OES when possible (GL can't do EXTERNAL) to avoid
problems.

This is a more defensive approach towards older drivers that don't
support modifiers.

This fixes importing YUV textures on AMD Gen8.

Another approach would be to check for YUV and never try
GL_TEXTURE_2D with them, but I decided to go this way first.

Fixes #6668
2024-04-28 13:51:42 +02:00
Benjamin Otte
719021e1f4 gpu: Handle tiny offscreens
Due to rounding errors, it is possible after intersecting a lot of
rectangles to end up with a tiny size for an offscreen. And because we
allow an epsilon before ceil()ing to an integer (see commit afc7b46264
for details) it is now possible that we end up with a size of 0.

Avoid that by always enforcing a minimum size of 1px.

Test included

The test uses a different codepath to arrive at the same problem - it
specifies the small size instead of triggering it via rounding errors
and clipping like the original bug (and most likely the more common case
to encounter this problem.

Fixes #6656
2024-04-28 13:51:42 +02:00
Benjamin Otte
4856e115a9 path: document enum 2024-04-28 08:33:03 +02:00
Matthias Clasen
bfb5bbe862 Merge branch 'matthiasc/for-main' into 'main'
wayland: Break out dmabuf feedback code

See merge request GNOME/gtk!7193
2024-04-27 23:09:20 +00:00
Matthias Clasen
b98c86fb7b wayland: Break out dmabuf feedback code
This will need to be used in surfaces as well, in the future.
Prepare for that by moving this code into its own file and struct.
2024-04-27 11:47:26 -04:00
Matthias Clasen
e01c3f581e Merge branch 'fix-profiler-mark' into 'main'
gsk: Fix a profiler mark

See merge request GNOME/gtk!7192
2024-04-27 15:47:01 +00:00
Matthias Clasen
c45199e388 gsk: Fix a profiler mark
I messed this up in f26efd9adf.
2024-04-27 10:23:45 -04:00
Matthias Clasen
27fb9917d8 Merge branch 'matthiasc/for-main' into 'main'
atcontext: Add a few missing values

Closes #6575

See merge request GNOME/gtk!7190
2024-04-26 23:16:31 +00:00
Matthias Clasen
b5d6613a3f atcontext: Add a few missing values
Add a missing value to the naming array, and sort the recent additions
alphabetically.

Fixes: #6575
2024-04-26 18:46:00 -04:00
Matthias Clasen
5dc77edbe3 Merge branch 'matthiasc/for-main' into 'main'
linkbutton: Report errors

Closes #6446

See merge request GNOME/gtk!7189
2024-04-26 22:26:14 +00:00
Matthias Clasen
a3d63b3579 label: Report errors
Print a warning when launching a handler fails.
2024-04-26 17:25:27 -04:00
Matthias Clasen
57c12a8661 linkbutton: Report errors
Print a warning when launching a handler fails.

Fixes: #6446
2024-04-26 17:25:13 -04:00
Matthias Clasen
f1ccb9b81a Merge branch 'vulkan-gl-texture-warning' into 'main'
vulkan: Add a warning about GL textures

See merge request GNOME/gtk!7184
2024-04-26 20:16:27 +00:00
Matthias Clasen
2711cb8dcd Merge branch 'wip/xdg-activation-token' into 'main'
Improve xdg-activation-token handling for non-dbus activation

See merge request GNOME/gtk!7118
2024-04-26 18:32:08 +00:00
Matthias Clasen
c79925bd4a Merge branch 'listview-oversights' into 'main'
listview: Fix some oversights

See merge request GNOME/gtk!7187
2024-04-26 18:27:49 +00:00
Matthias Clasen
05d5860dc0 listview: Fix some oversights
The list factory widget was notifying the wrong properties.
2024-04-26 11:19:59 -04:00
Matthias Clasen
a1fdf06d80 gsk: Add a warning for inefficient texture import
With GSK_DEBUG=fallback, warn if a non-memory texture has to be
downloaded for importing it into Vulkan or GL.
2024-04-26 11:04:47 -04:00
Matthias Clasen
36d7ca058e Cosmetics 2024-04-26 10:59:21 -04:00
Matthias Clasen
2e08db91ca Merge branch 'offload-snapshot-no-child' into 'main'
Don't crash if snapshotting a GtkGraphicsOffload without child

See merge request GNOME/gtk!7183
2024-04-25 20:46:31 +00:00
Sebastian Dröge
2c9b47ff3c Don't crash if snapshotting a GtkGraphicsOffload without child 2024-04-25 22:46:35 +03:00
Matthias Clasen
62ad1a61dc Merge branch 'matthiasc/for-main' into 'main'
offload: Make logging more compact

See merge request GNOME/gtk!7181
2024-04-25 03:01:44 +00:00
Matthias Clasen
3fc9de7539 offload: Make logging more compact
Use a format of

[XXX] SYMBOL DETAILS

where SYMBOL indicates the offloading status:
 🗙 - no offload
 ▲ - offload above, with background
 △ - offload above, no background
 ▼ - offload below, with background
 ▽ - offload below, no background
2024-04-24 22:01:56 -04:00
Matthias Clasen
1c9a55d185 Merge branch 'vulkan-msvc' into 'main'
gskvulkandescriptors.c: Don't return value from void-rettype function

See merge request GNOME/gtk!7175
2024-04-25 01:37:49 +00:00
Matthias Clasen
492940205e Merge branch 'amolenaar/macos-fix-nsapp-shortcuts' into 'main'
macos: fix in-app native shortcuts (regression)

See merge request GNOME/gtk!7178
2024-04-25 01:35:59 +00:00
Arjan Molenaar
985e4906c8 macos: Add some docs for the different NSEvent getters 2024-04-24 23:49:37 +02:00
Benjamin Otte
e9dcf8167c Merge branch 'gbsneto/vulkan-dmabuf-general' into 'main'
vulkan/image: Use GENERAL for initial layout of DMA-BUF textures

See merge request GNOME/gtk!7179
2024-04-24 20:55:51 +00:00
Georges Basile Stavracas Neto
3aa6c27c26 vulkan/image: Use GENERAL for initial layout of DMA-BUF textures
The VK_IMAGE_LAYOUT_UNDEFINED layout means that the data hold by the
texture can be discarded, and we don't want to discard it. Because the
Vulkan spec is unclear (see [1] for a discussion), err on the side of
caution and use VK_IMAGE_LAYOUT_GENERAL.

Fixes import failures with WebKit.

[1] https://github.com/ValveSoftware/gamescope/issues/356
2024-04-24 17:21:51 -03:00
Emmanuele Bassi
f537a55b71 Coding style fixes 2024-04-24 11:57:00 +01:00
Emmanuele Bassi
7075e6be89 Merge branch 'gst-backend-msvc' into 'main'
GStreamer media backend: Fix building on Visual Studio

See merge request GNOME/gtk!7174
2024-04-24 10:04:11 +00:00
Chun-wei Fan
54a86a2a7e Win32 GL: Also force not to use depth/stencil/accum bits on legacy contexts
For completeness' sake, also specifiy in the PIXELFORMATDESCRIPTOR to use no
depth, stencil and accum bits to initializing WGL when we can't (yet) use
wglChoosePixelFormatARB(), as we must always fist have a base legacy WGL
context using ChoosePixelFormat() before we can use that to use
wglChoosePixelFormatARB(), or if wglChoosePixelFormatARB() is somehow not
available for us.

Some drivers, however, enforces enabling depth buffers, so if we can't
acquire a pixel format that disables depth buffers, retry acquiring one
with that, which sadly is not optimal but we must make do.

Attempts to complete fix for issue #6401.
2024-04-24 16:23:17 +08:00
Chun-wei Fan
016354b6dd gskvulkandescriptors.c: Don't return value from void-rettype function
Fixes builds on Visual Studio with Vulkan enabled, as later GLib releases
consider this as an error on Visual Studio builds.
2024-04-24 16:19:43 +08:00
Chun-wei Fan
1dfc6d65df GStreamer media backend: Fix building and running on Windows
Visual Studio (and possibly other non-GCC compilers) do not like
uses of #-preprocessor directives in macro usage (warning C5101: use of
preprocessor directive in function-like macro argument list is undefined
behavior is also shown), so fix the build by defining another macro
accordingly.
2024-04-24 16:15:32 +08:00
Matthias Clasen
b7d0295481 Merge branch 'macos-default-settings' into 'main'
macos: Respect the default-settings debug key

See merge request GNOME/gtk!7173
2024-04-23 16:38:00 +00:00
Matthias Clasen
a2854af325 macos: Respect the default-settings debug key
This makes our behavior more consistent across platforms.
The suggestion came up in discussion in #6545.
2024-04-23 07:52:25 -04:00
Changwoo Ryu
320496b039 Update Korean translation
(cherry picked from commit e1dafd7a5d)
2024-04-23 11:33:48 +00:00
Lukáš Tyrychtr
b0450d4b1b Do not perform a changed help-text check twice 2024-04-23 11:40:51 +02:00
Lukáš Tyrychtr
91ff8bf336 The new member needs a separate docblock 2024-04-23 11:40:51 +02:00
Emmanuele Bassi
7b145f72dc Apply review feedback fixes 2024-04-23 11:40:51 +02:00
Lukáš Tyrychtr
0dcc21b605 4.14 did not cut it 2024-04-23 11:40:51 +02:00
Lukáš Tyrychtr
bd43a9e868 Document the new property 2024-04-23 11:40:51 +02:00
Lukáš Tyrychtr
9bf23d80a1 Test the new property and fix oversights found by the test 2024-04-23 11:40:51 +02:00
Lukáš Tyrychtr
38fd66dc04 a11y: Support setting the accessible help text
This adds support for setting a string used to describe the operation of a control,
if there's something special about it.

This is mapped to the HelpText property in the AT-SPI2 backend,
and has equivalent in others.
2024-04-23 11:40:51 +02:00
Arjan Molenaar
f004f14b89 macos: fix in-app native shortcuts (again)
Popping an event of the queue in the IMContext handler
prevents it from being forwarded to the NSApp, in case the
(key) event was not handled by IMContext.

So I reverted to a mix of the original (4.13) and new (4.14.1) behavior
for fetching events: NSEvent lookup for IMContext uses loose matching,
so it can work with rewritten events. When sending events to NSApp, only
we're checking for an exact match.

Now in-app keyboard shortcuts (e.g. Ctrl-F2) work from within text
fields again.
2024-04-23 08:57:09 +02:00
Matthias Clasen
8f15f6959c Merge branch 'vulkan-profiler-mark' into 'main'
gsk: Add a profiler mark for pipeline creation

See merge request GNOME/gtk!7172
2024-04-23 01:19:20 +00:00
Matthias Clasen
f26efd9adf gsk: Add a profiler mark for pipeline creation
This is the Vulkan equivalent of shader compilation, it could be
expensive, so lets add a mark around it.
2024-04-22 20:47:25 -04:00
Matthias Clasen
3f342d75b2 Merge branch 'wip/alice/root-test' into 'main'
testsuite: Add css/style/root test

See merge request GNOME/gtk!7171
2024-04-22 20:26:46 +00:00
Alice Mikhaylenko
3ab189404e testsuite: Add css/style/root test
Should have been a part of 76421847a5
but I forgot to commit it.
2024-04-22 21:34:50 +04:00
Matthias Clasen
48fc8d6606 Merge branch 'wip/alice/root' into 'main'
cssselector: Support :root

See merge request GNOME/gtk!7170
2024-04-22 16:26:18 +00:00
Matthias Clasen
2e0f411de9 Merge branch 'amolenaar/macos-fix-delayed-rendering' into 'main'
macos: Avoid repeatedly sending events back to macOS

See merge request GNOME/gtk!7158
2024-04-22 16:25:57 +00:00
Matthias Clasen
f08e36e225 Merge branch 'wip/alice/bugfix' into 'main'
csstokenizer: Fix an out of bounds when reading an ident followed by EOF

See merge request GNOME/gtk!7169
2024-04-22 16:25:17 +00:00
Matthias Clasen
9f358ac655 Merge branch 'matthiasc/for-main' into 'main'
roaring: Fix some ubsan warnings

See merge request GNOME/gtk!7165
2024-04-22 15:52:04 +00:00
Matthias Clasen
33d1349e53 Merge branch 'wip/alice/wayland-crash' into 'main'
wayland: Consistently handle enum type

Closes #6649

See merge request GNOME/gtk!7168
2024-04-22 15:25:31 +00:00
Sebastian Wick
6b2b6ceb74 gdk: Consider XDG_ACTIVATION_TOKEN for the startup notification id
We prefer it over the old DESKTOP_STARTUP_ID environment variable if we
have it and it is valid.

We have to stash and unset XDG_ACTIVATION_TOKEN in addition to
DESKTOP_STARTUP_ID now as well. This makes sure that we don't call any
library functions which might rely on some environment variables. This
way unsetting the environment variables is safe and we can then
afterwards validate and print warnings.
2024-04-22 17:13:21 +02:00
Alice Mikhaylenko
76421847a5 cssselector: Support :root
This will be useful for defining global variables.
2024-04-22 18:55:35 +04:00
Alice Mikhaylenko
840cd6e44c csstokenizer: Fix an out of bounds when reading an ident followed by EOF 2024-04-22 17:59:29 +04:00
Arjan Molenaar
f81038e99a macos: Avoid repeatedly sending events back to macOS
in the old approach it was possible that one NSEvent was
sent to the underlying NSApp multiple times. This resulted in
those events being forwarded to our (glib) event queue again.

The visual result was that no screen updates were done. Under the hood
the application was very busy with passing events around.

By popping the events off of our event queue, we make sure they're sent
only once.
2024-04-22 15:51:12 +02:00
Alice Mikhaylenko
007e7c68dc wayland: Consistently handle enum type
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6649
2024-04-22 17:18:11 +04:00
Emmanuele Bassi
e5e147ad53 Merge branch 'wip/alice/flatpak-fix' into 'main'
Fix flatpak build

See merge request GNOME/gtk!7166
2024-04-22 13:04:33 +00:00
Alice Mikhaylenko
58e00040e0 Fix flatpak build
Regressed in 70cd0e28ab
2024-04-22 16:18:58 +04:00
Matthias Clasen
5d1b8399fb testsuite: Fix another ubsan warning
The expression here was a bit too dense for ubsan to figure out
what branches aren't hit.
2024-04-21 22:24:02 -04:00
Matthias Clasen
deec2b6c6c lsan: Don't suppress glib and gio leaks
These are useful to see and not all that common.
2024-04-21 22:02:44 -04:00
Matthias Clasen
246eb8ea25 gtk: Fix more ubsan warnings
Most of these are calling a get_instance_private() function before
checking that the object isn't NULL.
2024-04-21 22:01:06 -04:00
Matthias Clasen
815df9a76a wayland: Fix an ubsan warning
dev_t requires 8-byte alignment, so we need to use memcpy.
2024-04-21 21:32:41 -04:00
Matthias Clasen
f896dddadc inspector: Fix an ubsan warning
These values are too big for int, so cast them to double.
2024-04-21 21:21:11 -04:00
Matthias Clasen
d733e94a8b roaring: Fix some ubsan warnings
Avoid warnings about memcpy (NULL, NULL, 0).
2024-04-21 21:20:16 -04:00
Matthias Clasen
59db0ca328 Merge branch 'matthiasc/for-main' into 'main'
wayland: Use wl_compositor version 6

See merge request GNOME/gtk!7164
2024-04-22 01:00:22 +00:00
Matthias Clasen
3bd97590a1 wayland: Tweak a debug message
We aren't drawing to subsurfaces.
2024-04-21 20:37:45 -04:00
Matthias Clasen
722a0fa36d wayland: Check subsurface backgrounds better
Do the same checks for background coordinates that we do for the
subsurface coordinates themselves: they must be integral in both
application and device pixels.
2024-04-21 20:33:29 -04:00
Matthias Clasen
b21708c5e4 offload: Consolidate logging a bit
Spew a bit less per-frame. Unfortunately, we still spew for
every frame, and fixing that would require more extensive
refactoring to centralize all logging in gskoffload.c
2024-04-21 20:18:38 -04:00
Matthias Clasen
b5fb584316 wayland: Use gdk_debug_message consistently
For debug messages, we should always use gdk_debug_message.
2024-04-21 19:41:49 -04:00
Matthias Clasen
fd1e1b9b7c Cosmetics 2024-04-21 19:35:52 -04:00
Matthias Clasen
c0caae0ff0 wayland: Use wl_compositor version 6
This gives us events for preferred_buffer_scale (which we ignore)
and preferred_buffer_transform (which we also currently ignore).
2024-04-21 19:27:58 -04:00
Matthias Clasen
5c972e4786 Post-release version bump 2024-04-21 12:27:05 -04:00
Matthias Clasen
1a3c5cf420 4.15.0 2024-04-21 12:21:40 -04:00
Matthias Clasen
eb7affd911 testsuite: Fix the offload tests 2024-04-21 12:21:40 -04:00
Matthias Clasen
a05dbff2c9 testsuite: Tweak the offload tests
We set GDK_DEBUG=force-offload now, so we can look at the actual
offload status.
2024-04-21 12:21:40 -04:00
Matthias Clasen
4b0d17b332 wayland: Fix an offload cornercase
Treat textures with background as opaque for the purposes of
offloading.
2024-04-21 12:21:40 -04:00
Matthias Clasen
2d8f677e63 Merge branch 'matthiasc/for-main' into 'main'
build: Fix docs build

See merge request GNOME/gtk!7162
2024-04-21 15:25:37 +00:00
Matthias Clasen
b5c9b6aa25 docs: Some updates to the render tool manpage
List all supported output formats and fix a few typos.
2024-04-21 11:03:31 -04:00
Matthias Clasen
86924c2f9a docs: Add some metadata to man pages
It would be nice to include the version here, but that is trickier.
2024-04-21 11:03:14 -04:00
Matthias Clasen
af0f5e3f30 build: Fix docs build
There was an overlooked used of a dropped option here.
2024-04-21 10:15:06 -04:00
Matthias Clasen
9e6c72210d Merge branch 'fix-dconf-reference' into 'main'
docs: Improve a reference

Closes #6635

See merge request GNOME/gtk!7161
2024-04-21 14:03:37 +00:00
Matthias Clasen
ce0b2d6953 NEWS: Updates 2024-04-21 09:40:55 -04:00
Matthias Clasen
d1bb3f66ac ci: Use pangos documentation option
The gtk_doc option has been deprecated in pango.
Use the replacement to avoid a deprecation warning.
2024-04-21 09:40:55 -04:00
Matthias Clasen
70cd0e28ab Drop deprecated build options
These cause harm in connection with subprojects if the subprojects
yield to a deprecated option. So just rip the bandaid off and
drop the deprecated build options.
2024-04-21 09:40:55 -04:00
Matthias Clasen
2e00bcc580 docs: Improve a reference
DConf is not what we use, it is actually GSettings.

Fixes: #6635
2024-04-20 20:12:54 -04:00
Matthias Clasen
db68c1f2c6 NEWS: Updates 2024-04-20 19:14:54 -04:00
Matthias Clasen
e3fa60a070 Merge branch 'matthiasc/for-main' into 'main'
ci: Stop using deprecated options

See merge request GNOME/gtk!7160
2024-04-20 22:35:20 +00:00
Matthias Clasen
c9c29d8bde gsk: Only prefer Vulkan on Wayland
Make Vulkan the default on Vulkan-friendly platforms.
For now, that list only includes Wayland.
2024-04-20 18:10:21 -04:00
Matthias Clasen
cd59d62947 Merge branch 'offload-new-transfer-none' into 'main'
Drop return value annotation of gtk_graphics_offload_new()

See merge request GNOME/gtk!7159
2024-04-20 21:26:03 +00:00
Sebastian Dröge
4f4fe4ef44 Drop return value annotation of gtk_graphics_offload_new()
A floating reference is returned, not a full reference. By having no
annotation, like for all other widget constructors, the correct default
is used again.
2024-04-20 22:45:15 +03:00
Matthias Clasen
06f83847c6 ci: Stop using deprecated options
A small step towards being able to drop these eventually.
2024-04-20 13:44:08 -04:00
Matthias Clasen
941b5c2aeb NEWS: Updates 2024-04-20 12:45:32 -04:00
Matthias Clasen
d661b7f258 Merge branch 'docs-tweaks' into 'main'
docs: Tweaks

See merge request GNOME/gtk!7157
2024-04-20 14:15:30 +00:00
Matthias Clasen
f86d996d58 NEWS: Updates 2024-04-20 09:18:03 -04:00
Matthias Clasen
fe3031fb99 docs: Tweaks
Shuffle the gtk-font-rendering docs around a bit.
2024-04-20 09:10:57 -04:00
Matthias Clasen
4b001a24db Merge branch 'vulkan-by-default' into 'main'
gsk: Change the default renderer

Closes #6537

See merge request GNOME/gtk!7153
2024-04-20 13:09:02 +00:00
Matthias Clasen
4727fea631 Merge branch 'textview-text-shadow' into 'main'
Apply css text shadows in text views

See merge request GNOME/gtk!7154
2024-04-20 13:06:54 +00:00
Matthias Clasen
7ff4cba624 Apply css text shadows in text views
For now, this just applies the shadow from the widget's style,
there is no way to apply different shadows to text ranges (except
for the selection, which already has its own css style).
2024-04-20 08:48:39 -04:00
Matthias Clasen
0363cc83b9 Merge branch 'deprecate-cursor-theme-setters' into 'main'
gdk: Deprecate public cursor theme setters

See merge request GNOME/gtk!7155
2024-04-20 12:40:25 +00:00
Matthias Clasen
c1327e2c1b gdk: Deprecate public cursor theme setters
No need for this api, we've made the frontend setter private
for a reason.
2024-04-20 07:50:10 -04:00
Aurimas Černius
9971707544 Update Lithuanian translation
(cherry picked from commit 49046f5c34)
2024-04-20 10:39:37 +00:00
Matthias Clasen
02115912aa Cosmetics 2024-04-19 20:52:57 -04:00
Martin
e29571e6a6 Update Slovenian translation 2024-04-19 21:46:32 +00:00
Matthias Clasen
582ad79088 gsk: Change the default renderer
The intent of this change to get wider testing and verify that the
Vulkan drivers we get to use in the wild are good enough for our
needs. If significant problems show up, we will revert this change
for 4.16.

The new preference order is vulkan > ngl > gl > cairo.

The gl renderer is still there because we need it to support gles2.

If you need to override the default renderer choice, you can
still use the GSK_RENDERER environment variable.

Fixes: #6537
2024-04-19 13:50:40 -04:00
Matthias Clasen
3fac42fd3c Merge branch 'hint-font-metrics-redux' into 'main'
Add a new font rendering setting

See merge request GNOME/gtk!7113
2024-04-19 17:34:57 +00:00
Matthias Clasen
8f0b38b462 tests: Update for the new setting
One of our tests counts our settings. Not super-useful, but lets
keep it working.
2024-04-19 12:56:34 -04:00
Matthias Clasen
6c5a106d7e inspector: Show the font rendering setting
Replace the font options with the new font rendering setting.
The font options are still available for tweaking in the inspector
as properties of the GtkSettings object.
2024-04-19 12:56:34 -04:00
Matthias Clasen
5f7cab4632 Add a new font rendering setting
Add a high-level setting that gives us more freedom to tweak
font rendering knobs according to our needs. It has a 'manual'
value that lets users continue to influence font rendering using
the low-level font-related settings as before.

Once the schemas have this, we can support setting this session-wide.
See https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas/-/merge_requests/79

The initial implementation of 'automatic' font rendering is fairly
simplistic: if the monitor dpi is less than 200, prefer sharpness,
so turn on metrics hinting and slight hinting. If the monitor dpi
is at least 200, we both off.
2024-04-19 12:56:34 -04:00
Matthias Clasen
558db5a3a7 settings: Allow enums as settings
We can easily handle this, and it makes such settings appear
more natural, e.g. in the inspector.
2024-04-19 12:56:34 -04:00
Matthias Clasen
bc94b4f235 widget: Simplify our font options handling
Streamline the code that sets up pango contexts.

No functional change.
2024-04-19 09:39:52 -04:00
Matthias Clasen
4c809281b2 widget: Stop hardcoding hint-font-metrics
We used to hardcode hint-font-metrics = TRUE for unscaled
rendering. Stop doing that. Users should be able to decide
for themselves.
2024-04-19 09:19:53 -04:00
Matthias Clasen
81faf7caa3 settings: Change the default of hint-font-metrics
Change the default value to TRUE. This is because we want to stop
hardcoding this value for unscaled situations, but we don't want
to change everybody's font rendering.
2024-04-19 09:19:27 -04:00
Andi Chandler
7477e8626d Update British English translation
(cherry picked from commit e26c5945a9)
2024-04-18 22:44:51 +00:00
Matthias Clasen
47f30d208c Merge branch 'matthiasc/for-main' into 'main'
Add a missing deprecation note

See merge request GNOME/gtk!7152
2024-04-18 17:23:28 +00:00
Matthias Clasen
74a1c0916a Add a missing deprecation note
GdkVulkanContext is deprecated and only exposed in the api because
we need it as return type of the (deprecated)
gdk_surface_create_vulkan_context() API.
2024-04-18 12:49:18 -04:00
gayathri.berli@ibm.com
06351844bb changes to fix the memorytexture regression 2024-04-18 17:13:41 +05:30
Matthias Clasen
ee67edbe3a Merge branch 'matthiasc/for-main' into 'main'
inspector: Clean up refcounting in the recorder

Closes #6634

See merge request GNOME/gtk!7149
2024-04-18 00:33:17 +00:00
Matthias Clasen
ec9cdb74ef gsk: Actually punch transparent holes
In a57f7e3935 I accidentally replaced { 0, 0, 0, 0 } with
GDK_RGBA_BLACK instead of GDK_RGBA_TRANSPARENT. Oops.

Fixes: #6634
2024-04-17 20:09:13 -04:00
Matthias Clasen
ad0f9144ec inspector: Avoid writing settings back needlessly
We were a bit careless and were writing some values back to the
GtkSettings on init, possibly with rounding errors. Avoid that.
2024-04-17 19:02:57 -04:00
Matthias Clasen
3e8215a971 inspector: Cosmetics
Use GDK_RGBA macros instead of parsing colors from names for every
subsurface.
2024-04-17 16:53:52 -04:00
Matthias Clasen
8df7487e2a inspector: Clean up refcounting in the recorder
We were getting things mixed up here, and it was leading to crashes
when clicking around between frames.
2024-04-17 16:49:38 -04:00
Matthias Clasen
633692b53e NEWS: Updates 2024-04-17 15:34:26 -04:00
Matthias Clasen
e0a5c65003 Merge branch 'black-background' into 'main'
Add GtkGraphicsOffload:black-background

See merge request GNOME/gtk!7147
2024-04-17 17:38:18 +00:00
Matthias Clasen
e4753791c0 video: Use the black-background property
Instead of hardcoding a black background in the theme, use the
new property to tell the GtkGraphicsOffload widget to draw one.
2024-04-17 12:52:35 -04:00
Matthias Clasen
a57f7e3935 graphicsoffload: Add a black-background property
This property allows explicit control over whether to draw
a black background behind offloaded content or not, instead
of relying on the theme background.
2024-04-17 12:52:03 -04:00
Matthias Clasen
8de5a94eb7 Merge branch 'fixwmhints' into 'main'
x11: Remove last_wmspec_check_time

Closes #6558

See merge request GNOME/gtk!7145
2024-04-17 15:31:26 +00:00
Matthias Clasen
88872d1986 Merge branch 'rgba-tweaks' into 'main'
Use our defines for color

See merge request GNOME/gtk!7144
2024-04-17 00:17:06 +00:00
oreo639
ab33b56ec9 x11: Remove last_wmspec_check_time
In fetch_net_wm_check_window(), before updating the wmspec_check_window, a
check is performed to verify a 15s difference between last_wmspec_check_time
and the current monotonic time.

The comment suggests that this check is done to ensure that it doesn't check
for a new check window repeatedly over and over again. While that was the case
origionally, currently the last_wmspec_check_time only gets updated when
wmspec_check_window is set, which is already checked earlier, making the time
check useless.

This check causes issues on cold boots where gtk4 applications are not able
to obtain the wmspec_check_window until 15 seconds after boot, making gtk
unable to check for extended wm_hints during that time.

Fixes: #6558
2024-04-16 12:35:00 -07:00
Matthias Clasen
c37e88d561 Merge branch 'fix-typo' into 'main'
docs: Fix typo

See merge request GNOME/gtk!7146
2024-04-16 10:32:18 +00:00
Jan Willem
2638700435 Docs: Fix typo 2024-04-16 08:47:25 +00:00
Matthias Clasen
0a5a720fe1 Use gdkrgbaprivate.h in more places
This gets inline functions used where it matters.
2024-04-15 22:57:01 -04:00
Matthias Clasen
0e5f7601e4 Add some inline rgba functions
These are trivial enough to inline everywhere.
2024-04-15 22:57:01 -04:00
Matthias Clasen
e583e823b5 Use our defines for color
We have GDK_RGBA_WHITE, GDK_RGBA_BLACK and GDK_RGBA_TRANSPARENT,
lets use it instead of open-coding it.
2024-04-15 22:57:01 -04:00
Matthias Clasen
a96358046f Merge branch 'matthiasc/for-main' into 'main'
Drop another unwanted file

See merge request GNOME/gtk!7143
2024-04-16 02:21:26 +00:00
Matthias Clasen
40f26ea09b Drop another unwanted file 2024-04-15 21:40:52 -04:00
Matthias Clasen
71a7f0771b Merge branch 'matthiasc/for-main' into 'main'
Matthiasc/for main

See merge request GNOME/gtk!7142
2024-04-16 01:32:29 +00:00
Matthias Clasen
00739718ab Drop unwanted files 2024-04-15 20:50:27 -04:00
Matthias Clasen
19881c8c06 NEWS: Updates 2024-04-15 20:50:27 -04:00
Matthias Clasen
8b0aae8536 Merge branch 'matthiasc/single-pixel-buffer' into 'main'
wayland: Use single-pixel buffer optimization for offload

See merge request GNOME/gtk!7136
2024-04-16 00:20:07 +00:00
Matthias Clasen
fbe000734a wayland: Refuse offloading when we can't
If we have a subsurface with background, but no single-pixel
buffer support, refuse to offload.
2024-04-15 19:53:46 -04:00
Matthias Clasen
0c67b367ac subsurface: Tweak the attach implementation
Do the backend call before changing the stacking order in the
frontend. This is necessary so the backend can look at the current
stacking order to determine if it will change.
2024-04-15 19:53:46 -04:00
Matthias Clasen
f75b4aac1d wayland: Minimize work for subsurfaces
Only commit things that have changed. In the ideal scenario, only
the texture changes from frame to frame, and all the sizing related
setup and the background stay the same, causing the least amount
of work in the compositor.
2024-04-15 19:53:46 -04:00
Matthias Clasen
d563d158c0 subsurface: Add gdk_subsurface_get_sibling
This was just a missing getter. The backend implementation will
use this information to determine whether stacking changes.
2024-04-15 19:53:46 -04:00
Matthias Clasen
5c892fa4ea offload: Add more tests
Include background in offload tests.
2024-04-15 19:53:46 -04:00
Matthias Clasen
4aac64edf0 offload: Some renaming
Rename things to be more in line with the subsurface api.
2024-04-15 19:53:46 -04:00
Matthias Clasen
c97bbfdfb1 offload: Use subsurface bounds for diffing
When adding the whole subsurface to the diff, use the subsurface
bounds, which takes both the texture and the background into
account.
2024-04-15 19:53:46 -04:00
Matthias Clasen
a44598772d wayland: Use subsurface bounds for holes
When punching a hole into the opaque region, use the subsurface
bounds, which takes both the texture and the background into
account.
2024-04-15 19:53:46 -04:00
Matthias Clasen
933a0e5a98 subsurface: Some api revision and documentation
Rename things so they make more sense. The dest/source naming got
a bit unclear when we added background into the mix. Now we're going
for:

source_rect - the texture region to display
texture_rect - dimensions of the subsurface showing the texture
background_rect - dimensions of the background subsurface
bounds - union of texture_rect and background_rect

Also use this opportunity to add some api docs.
2024-04-15 19:53:46 -04:00
Matthias Clasen
e33e9c506d theme: Move the black background of the video
We need the black inside the subsurface node for the single-pixel
optimization to work, so put it there.
2024-04-15 19:53:46 -04:00
Matthias Clasen
0108a5f56d offload: Use subsurface background optimization
Detect a black color node below the texture node and pass that
information to the subsurface, to take advange of the single-pixel
buffer optimization.

To make this work, we need to stop using the bounds of the subsurface
node for sizing the offload, and instead use either the clip or
the texture node for that.
2024-04-15 19:53:46 -04:00
Matthias Clasen
c995473407 Add more subsurface tests
Add some more tests for the basic functioning of the subsurface API.
2024-04-15 19:53:46 -04:00
Matthias Clasen
3f9bdaa4c8 Add background to subsurfaces
Make it possible for subsurfaces to have a black background on a
secondary subsurface below the actual subsurface. Using a single-pixel
buffer for that background increases the changes that the compositor
will use direct scanout for the actual subsurface.

This changes the private subsurface API. All callers have been
updated to pass an empty background rect.
2024-04-15 19:53:46 -04:00
Robert Mader
a70998aa50 wayland: Support the single-pixel-buffer protocol
This just gets the manager object. It is not used yet.
2024-04-15 19:53:46 -04:00
Matthias Clasen
0fb1f44eec gdk: Add a debug flag to allow non-dmabuf offload
This is useful for debugging offloading without having to rely
on gstreamer giving us dmabufs. To use it, set

GDK_DEBUG=force-offload

in the environment.
2024-04-15 19:53:46 -04:00
Matthias Clasen
26cc96bb7f testsuite: Cosmetics
Correct a debug message.
2024-04-15 19:53:46 -04:00
Matthias Clasen
1c8b22cf05 subsurface: Cosmetics 2024-04-15 19:53:46 -04:00
Matthias Clasen
abbbd08931 Merge branch 'ebassi/docs-contributing' into 'main'
docs: Update contribution guide

See merge request GNOME/gtk!7141
2024-04-15 12:41:18 +00:00
Matthias Clasen
587cf28dd3 Merge branch 'rendernode-tool-pdf' into 'main'
rendernode-tool: add support for rendering to PDF

See merge request GNOME/gtk!7140
2024-04-15 10:58:36 +00:00
Emmanuele Bassi
53231a137c docs: Update contribution guide
- Fix link to the security policy
- Drop the confusing note about SSH access (with the old URL)
- Use modern idiomatic Meson subcommands for configuring and building
- Use `git switch` instead of `git checkout`
- Specify that you should always use merge requests, not patches
- Link to the handbook instead of the wiki
2024-04-15 11:56:13 +01:00
Christian Hergert
104a264d8b rendernode-tool: add support for rendering to PDF 2024-04-14 22:29:52 -07:00
Anders Jonsson
75fd582b97 Update Swedish translation
(cherry picked from commit f920f51300)
2024-04-14 11:22:05 +00:00
Matthias Clasen
89977412e9 Merge branch 'matthiasc/for-main' into 'main'
gsk: Fix a minor type mismatch

Closes #6628

See merge request GNOME/gtk!7138
2024-04-14 02:51:45 +00:00
Matthias Clasen
ce030b1b36 gsk: Fix a minor type mismatch
Use the same types in the declaration of gsk_standard_contour_init.

Fixes: #6628
2024-04-13 22:28:48 -04:00
Matthias Clasen
6c5dc8cd1f Merge branch 'matthiasc/for-main' into 'main'
wayland: Cosmetics

See merge request GNOME/gtk!7137
2024-04-13 21:56:27 +00:00
Matthias Clasen
fb4b38e5ea inspector: Fix a bunch of memory leaks
g_list_store_append is *not* transfer full. Oops.
2024-04-13 17:22:42 -04:00
Matthias Clasen
fc405f8882 wayland: Cosmetics
Don't clear the same pointer twice.
2024-04-13 17:22:42 -04:00
Benjamin Otte
afe61e28e0 Merge branch 'wip/p3732/no-additional-grid-tile' into 'main'
grid-view: make footer tile file empty space

Closes #6076

See merge request GNOME/gtk!6370
2024-04-13 15:35:43 +00:00
Peter Eisenmann
4f3f3c9ae2 grid-view: make footer tile file empty space 2024-04-13 15:35:42 +00:00
Matthias Clasen
e699685003 Merge branch 'mr7057-preparation' into 'main'
gdk/wayland: Make the surface handle empty commits

See merge request GNOME/gtk!7133
2024-04-12 15:54:33 +00:00
Robert Mader
9583195e96 gdk/wayland: Make the surface handle empty commits
In order to avoid some code duplication and ensure the Cairo and
Vulkan implementations behave like the GL one.
2024-04-12 17:04:54 +02:00
Matthias Clasen
a526f0770e Merge branch 'warning-fix' into 'main'
gdk/gsk: Fix a couple of maybe-uninitialized warnings

See merge request GNOME/gtk!7132
2024-04-12 11:55:04 +00:00
Philip Withnall
707e492f0d gsk: Fix a maybe-uninitialized warning
The compiler (gcc 13.2) thinks that `t` could be used uninitialised.
That’s obviously not the case, because there’s always going to be at
least one loop iteration due to the initial values of `t1` and `t2`.

Change the loop to a `do…while` to make that a bit clearer to the
compiler without making any functional changes to the code.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 12:08:03 +01:00
Philip Withnall
680dba6524 gdk: Fix a maybe-uninitialized warning
If there somehow end up being no `supported_versions`, `ctx` would end
up being dereferenced before being initialised. While I think that’s
unlikely, the compiler doesn’t know that, so let’s just initialise the
variable unconditionally.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 12:03:29 +01:00
Matthias Clasen
d1bb1d091c Merge branch 'gdk-build-dep-fix' into 'main'
build: Add a missing dependency

Closes #6618

See merge request GNOME/gtk!7127
2024-04-11 20:57:34 +00:00
Matthias Clasen
6510b876d1 build: Add a missing dependency
Add the generated gdk headers to the sources for all the backends,
to guarantee that they are generated before the library is used.

Fixes: #6618
2024-04-11 15:47:38 -04:00
Matthias Clasen
e376941e49 Merge branch 'scrollbar_accessible_range' into 'main'
a11y: Implement GtkAccessibleRange for scrollbars

Closes gnome-control-center#2994

See merge request GNOME/gtk!7129
2024-04-11 18:20:49 +00:00
Matthias Clasen
4889199b14 Merge branch 'glarea-dispose-fix' into 'main'
dmabuf texture: Survive multiple disposes

Closes #6623

See merge request GNOME/gtk!7131
2024-04-11 18:20:12 +00:00
Luca Bacci
2e15225446 Merge branch 'remove-work-arounds' into 'main'
GdkWin32: Remove some work arounds that are not needed anymore

Closes #6614

See merge request GNOME/gtk!7114
2024-04-11 17:03:08 +00:00
Matthias Clasen
9dad71513c glarea: Clean up dispose
We were getting our gl and dmabuf texture mixed up and ending
up freeing the Texture structs while they were still used as
callback data for dmabuf texture destroys. Avoid that by keeping
separate pointers for the gl and dmabuf textures.

Fixes: #6623
2024-04-11 12:48:01 -04:00
Matthias Clasen
ed072b4b5d dmabuf texture: Survive multiple disposes
dispose can be called more than once, so be safe for that.
2024-04-11 12:45:24 -04:00
Boyuan Yang
7ffc4e0a21 Update Chinese (China) translation 2024-04-11 15:46:08 +00:00
Emmanuele Bassi
b9403f4f5b Apply review suggestions 2024-04-11 14:04:12 +00:00
Lukáš Tyrychtr
9f1aa3141b a11y: Implement GtkAccessibleRange for scrollbars
Fixes gnome-control-center#2994
2024-04-11 14:25:42 +02:00
Matthias Clasen
06e905f87d Merge branch 'gtk-wlmod' into 'main'
Meson: Use wayland module

See merge request GNOME/gtk!7126
2024-04-11 01:29:29 +00:00
Xavier Claessens
2ba8dcebff Apply 1 suggestion(s) to 1 file(s) 2024-04-10 15:52:42 +00:00
Xavier Claessens
95a8def7c2 Meson: Use wayland module 2024-04-10 11:43:04 -04:00
Matthias Clasen
777799070d Merge branch 'simplify_widget_accessible_get_bounds' into 'main'
a11y: Simplify GtkWidget's GtkAccessible.get_bounds implementation

See merge request GNOME/gtk!7128
2024-04-10 15:40:44 +00:00
Lukáš Tyrychtr
0f83a9550b Proper rounding 2024-04-10 15:46:39 +02:00
Lukáš Tyrychtr
17f2443350 a11y: Simplify GtkWidget's GtkAccessible.get_bounds implementation
We can use the result from gtk_widget_get_bounds for the coordinates as well.
2024-04-10 15:32:16 +02:00
Matthias Clasen
6bfc995097 Merge branch 'matthiasc/for-main' into 'main'
docs: Update some links

See merge request GNOME/gtk!7125
2024-04-10 01:04:14 +00:00
Matthias Clasen
8068111c6e Merge branch 'fix-xi2-input-source-type-debug-msg' into 'main'
xi2: Fix incorrect input source type in Input debug message

Closes #6619

See merge request GNOME/gtk!7120
2024-04-10 00:45:14 +00:00
Matthias Clasen
6e1c47b021 Merge branch 'improve_gtkeditabledelegate_docs' into 'main'
GtkEditable: Document the usage restrictions of gtk_editable_delegate_get_accessible_platform_state

See merge request GNOME/gtk!5691
2024-04-10 00:36:44 +00:00
Matthias Clasen
aed4ced032 Merge branch 'broadway-port-2972-3130' into 'main'
[gtk4] gdk/broadway: Port !2972 and !3130 from gtk3

See merge request GNOME/gtk!4467
2024-04-10 00:12:28 +00:00
Matthias Clasen
96160ea5dc docs: Update some links
Use docs.gtk.org for all the documentation that is hosted there.
2024-04-09 20:00:00 -04:00
Matthias Clasen
c76c07ddfe Merge branch 'matthiasc/for-main' into 'main'
testsuite: Cosmetics

See merge request GNOME/gtk!7124
2024-04-09 23:41:01 +00:00
Matthias Clasen
7b82dc7ac5 inspector: Show monitor resolution 2024-04-09 19:14:01 -04:00
Matthias Clasen
a63e9d38fb gdk: Add private convenience api
Add a function to get the monitor resolution.

We may use this information in the future to make font rendering
decisions.
2024-04-09 19:13:34 -04:00
Matthias Clasen
cc8db1805d gsk: Be safer against bad font options
Some combinations of hint-style and hint-metrics lead to bad glyph
placement in the glyph cache, so avoid them.
2024-04-09 19:12:49 -04:00
Matthias Clasen
948532f3c9 Deprecate gtk_widget_set/get_font_options
cairo font options are too low-level, and setting them directly
prevents us from doing smarter things for font rendering.
2024-04-09 19:12:41 -04:00
Matthias Clasen
8f39f8d827 testsuite: Add another test
This test checks that pango attributes can be specified in serialized
form.
2024-04-09 19:06:31 -04:00
Matthias Clasen
5e28c05121 testsuite: Cosmetics
Make the builder parser test less verbose.
2024-04-09 19:06:12 -04:00
Matthias Clasen
32d15a5858 Merge branch 'builder-gtkshortcutaction-warning' into 'main'
builder: Show warning for invalid action on GtkShortcut

See merge request GNOME/gtk!7121
2024-04-09 20:36:59 +00:00
Benjamin Otte
460eaac1f4 Merge branch 'wip/otte/for-main' into 'main'
vulkan: Handle generating mipmaps for 1x1 images

Closes #6553

See merge request GNOME/gtk!7073
2024-04-09 16:25:20 +00:00
Benjamin Otte
02d7817632 demo: Use get_fps() in fishbowl demo
Hopefully that leads to somewhat more reliable fps measurements
2024-04-09 17:39:36 +02:00
Benjamin Otte
3080e2974d gpu: ceil() offscreen size before generating offscreen
The goal is to generate an offscreen at 1x scale.
When not ceil()ing the numbers the offscreen code would do it *and*
adjust the scale accordingly, so we'd end up with something like a
1.01x scale.

And that would cause the code to reenter this codepath with the goal to
generate an offscreen at 1x scale.
And indeed, this would lead to infinite recursion.

Tests included.

Fixes #6553
2024-04-09 17:39:32 +02:00
Juliano de Souza Camargo
be9d98ed38 Update Brazilian Portuguese translation 2024-04-09 13:31:35 +00:00
Leônidas Araújo
944274bc58 Update Brazilian Portuguese translation
(cherry picked from commit 235388fdcd)
2024-04-09 13:26:40 +00:00
Sabri Ünal
b555e909c4 Update Turkish translation 2024-04-09 09:55:55 +00:00
Matthijs Velsink
c0b813940e builder: Show warning for invalid action on GtkShortcut
The parsing for a `GTK_TYPE_SHORTCUT_ACTION` on a GtkShortcut in a
builder file can fail, resulting in a `NULL` GtkShortcutAction. This
currently does not result in any warnings, potentially making typos in
builder files tricky to debug.

Since `gtk_shortcut_action_parse_builder()` already sets an error if it
fails, we can just use that and simply return false.
2024-04-09 02:41:57 +02:00
Benjamin Otte
9fe9ea34fd vulkan: Handle generating mipmaps for 1x1 images
Testcase included.
2024-04-08 21:06:54 +02:00
Hansem Ro
d90dc7f75e xi2: Fix incorrect input source type in Input debug message
This drops cursor and eraser source names to account for their removal
from GdkInputSource so that GDK_DEBUG=input debug message correctly
prints source type in X11 environment.

Fixes: c1d90273 ("gdk: Drop GDK_SOURCE_ERASER")
Fixes: 3285f52d ("gdk: Drop GDK_SOURCE_CURSOR")
Closes: #6619
2024-04-08 10:15:00 -07:00
Matthias Clasen
f36f1b9829 Merge branch 'dmabuf-glarea' into 'main'
One approach to dmabufs in glarea

See merge request GNOME/gtk!7116
2024-04-07 17:24:33 +00:00
Matthias Clasen
2b09f5ea1e dmabuf: Reshuffle docs slightly
Move related parts together, for easier understanding.
2024-04-07 13:03:13 -04:00
Matthias Clasen
f51c82a2aa gtk-demo: Use offload for shadertoy
This is an easy way to verify that GtkGLArea delivers dmabufs
now, and it might have some practical uses to offload gl area.
2024-04-07 13:03:13 -04:00
Matthias Clasen
11d3be278d glarea: Return dmabuf textures
Export the GL texture as a dmabuf if we can, and provide the
texture in that form.
2024-04-07 13:03:13 -04:00
Benjamin Otte
cc98282caa Merge branch 'shortcutmanager-fix-phase-changes' into 'main'
shortcutmanager: Handle propagation phase changes of added controllers

Closes #6246

See merge request GNOME/gtk!7115
2024-04-07 15:45:51 +00:00
Matthias Clasen
85f2e1ccd8 Add gdk_dmabuf_texture_builder_set_dmabuf
Private utility api.
2024-04-07 11:12:13 -04:00
Matthias Clasen
91b98bc9e2 Add a private header
Just cosmetic reshuffling.
2024-04-07 11:12:13 -04:00
Matthias Clasen
704ee6a9d0 offload: Determine output transforms
When we look for the texture to attach to the subsurface, keep
track of transforms we see along the way, and look at their scale
component to determine if the texture needs to be flipped.
We currently don't allow rotations here.

This fixes glarea rendering being upside-down when offloaded.
2024-04-07 11:12:06 -04:00
Matthias Clasen
72e9f30937 subsurface: Add transforms
Allow to specify a D₂ transform when attaching a texture to a
subsurface, to handle flipped and rotated content. The Wayland
implementation handles these transforms by setting a buffer
transform on the subsurface.

All callers have been updated to pass GDK_TEXTURE_TRANSFORM_NORMAL.
2024-04-07 11:02:40 -04:00
Matthijs Velsink
aadaf4adf2 shortcutmanager: Track propagation phase of added controllers
GtkShortcutManager allows adding controllers to it. For the default
implementation, they get added to one of two models, based on the
propagation phase (either GTK_PHASE_CAPTURE or GTK_PHASE_BUBBLE).

However, when a controller is removed, its presence in the manager gets
checked against the current propagation phase of the controller, which
may have changed from when it was added. This can lead to crashes if the
controller was not disposed properly since it still has a reference in
one of the two models of the GtkShortcutManager.

To fix this, add a callback for `notify::propagation-phase`, which
removes the controller from all possible models and readds it again with
its current phase. This callback is only disconnected permanently when
the controller is manually removed with
`gtk_shortcut_manager_default_remove_controller()`.

Closes #6246
2024-04-07 16:29:08 +02:00
Yaron Shahrabani
d83ad6b505 Update Hebrew translation
(cherry picked from commit b19247e4ef)
2024-04-06 13:19:11 +00:00
Piotr Drąg
b647d1a58c Update Polish translation 2024-04-06 12:32:39 +02:00
Luca Bacci
3c94e91e5e GdkWin32: Do not clear surface contents when restoring from minimize
The code does not work anyway since we dropped WS_EX_LAYERED windows.
2024-04-06 10:58:40 +02:00
Luca Bacci
8a1bee1d79 GdkWin32: Don't explicitly set the transient owner as active
...when a transient child is hidden.

The system does that automatically
2024-04-06 10:58:25 +02:00
Luca Bacci
9297439de4 GdkWin32: Remove some work arounds that are not needed anymore
2cc650ce was added to work around some of the regressions
introduced by 79557271, but that commit was finally reverted
in 43476c09.

We can now revert 2cc650ce as well.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6614
2024-04-06 10:44:02 +02:00
Danial Behzadi
68cff3b108 Update Persian translation
(cherry picked from commit 58d48cd3e5)
2024-04-05 12:40:53 +00:00
Matthias Clasen
84846aace7 Merge branch 'matthiasc/for-main' into 'main'
wayland: Work around mutter deficiences

See merge request GNOME/gtk!7112
2024-04-05 09:47:34 +00:00
Athmane MOKRAOUI
7bd93730d1 Update Kabyle translation 2024-04-05 09:16:50 +00:00
Matthias Clasen
c5d05fdc88 wayland: Work around mutter deficiences
Add the environment variable NO_POINTER_VIEWPORT to force the use
of buffer scale for pointer surfaces. This is a temporary workaround
for https://gitlab.gnome.org/GNOME/mutter/-/issues/2633.
2024-04-05 11:13:24 +02:00
Asier Sarasua Garmendia
f6ff2cd1cb Update Basque translation
(cherry picked from commit e54ecf5e32)
2024-04-05 08:43:42 +00:00
Matthias Clasen
9b0060e84d Merge branch 'matthiasc/for-main' into 'main'
Bump the cairo dep

See merge request GNOME/gtk!7110
2024-04-05 08:00:56 +00:00
Matthias Clasen
8d5633cb88 Drop code handling old cairo
We require cairo 1.18 now, so know that we will get subpixel
positioning for text, and have a little less uncertainty in
our font rendering.
2024-04-05 09:00:22 +02:00
Matthias Clasen
f74b1d48b6 Merge branch 'update-gtkswitch-state-docs' into 'main'
docs: Clarify state and active properties in GtkSwitch

Closes #6600

See merge request GNOME/gtk!7109
2024-04-05 06:57:16 +00:00
Matthias Clasen
27ebf756fe Bump the cairo dep
Require cairo 1.18, now that we have this stable release.
2024-04-05 08:01:39 +02:00
Dylan McCall
631da2e723 docs: Clarify state and active properties in GtkSwitch
Remove duplicate descriptions of the switch's appearance, describe more
particularly how the default signal handler for `GtkSwitch::state-set`
behaves, and add a suggestion that the `state` property should
only be set when communicating a delayed state change.

Fixes #6600
2024-04-04 20:29:07 -07:00
Matthias Clasen
b5531d3d6f Merge branch 'michaelweghorn/a11y_atspi_getcharacterextents_getoffsetatpoint_fixes' into 'main'
a11y atspi: Misc fixes for AT-SPI Text methods GetCharacterExtents, GetRangeExtents and GetOffsetAtPoint

See merge request GNOME/gtk!7104
2024-04-04 22:28:50 +00:00
Martin
5e6bc41fdd Update Slovenian translation 2024-04-04 22:15:05 +00:00
Matthias Clasen
d0581af2af Merge branch 'matthiasc/for-main' into 'main'
printing: Add context to some strings

See merge request GNOME/gtk!7107
2024-04-04 16:15:30 +00:00
Artur S0
cec746804d Update Russian translation 2024-04-04 15:36:42 +00:00
Matthias Clasen
ade1aaa8be printing: Add context to some strings
The job priority strings need context to disambiguate them from
similar short strings elsewhere.
2024-04-04 16:56:50 +02:00
Matthias Clasen
345d23898d Merge branch 'matthiasc/for-main' into 'main'
Add context to some translatable strings

Closes #6609

See merge request GNOME/gtk!7105
2024-04-04 14:38:06 +00:00
Matthias Clasen
415717276a Merge branch 'fix-spinbutton-updates' into 'main'
Revert "spinbutton: Tangential refactoring, small fix"

Closes #6599

See merge request GNOME/gtk!7103
2024-04-04 13:27:56 +00:00
Matthias Clasen
cebe640bce Add context to some translatable strings
This was requested by Alexandre Franke.

Fixes: #6609
2024-04-04 15:25:07 +02:00
Emmanuele Bassi
73084b761f Apply code style fixes from review 2024-04-04 13:05:24 +00:00
Athmane MOKRAOUI
eb13ecfbe7 Update Kabyle translation 2024-04-04 12:13:23 +00:00
Matthias Clasen
85c4507609 spinbutton: Fix a corner case
Fix a bug where a zero increment would make the value unsettable,
when the more natural operation is to allow any value to be set.
2024-04-04 14:11:10 +02:00
Matthias Clasen
fcb6c8e447 Revert "spinbutton: Tangential refactoring, small fix"
This reverts commit 3d898af736.

The commit caused a regression where, depending on the update policy,
we would not apply value changes at all.

Fixes: #6599
2024-04-04 14:00:25 +02:00
Michael Weghorn
0b27f39c2b a11y atspi: Don't require GtkWidget for GetOffsetAtPoint
Use the existing `gtk_at_spi_translate_coordinates_to_accessible`
to translate the coordinates passed as parameters to AT-SPI
Text's GetOffsetAtPoint method instead of having a
custom GtkWidget-specific translation.

This makes this work for non-GtkWidget GtkAccessibles
as well, and also adds support for parent-relative
coordinates (ATSPI_COORD_TYPE_PARENT).
2024-04-04 13:53:49 +02:00
Michael Weghorn
2101f880af a11 atspi: Fix type for GetOffsetAtPoint result
With the fix from the previous commit in place,
trying to use the GetOffsetAtPoint AT-SPI Text method
from Accerciser's IPython console with the gtk4-demo
Hypertext example would still give this error:

    In [46]: acc.queryText().getCharacterExtents(5, pyatspi.XY_WINDOW)
    Out[46]: (58, 20, 5, 19)
    In [47]: acc.queryText().getOffsetAtPoint(59, 21, pyatspi.XY_WINDOW)
    ---------------------------------------------------------------------------
    Error                                     Traceback (most recent call last)
    Cell In[47], line 1
    ----> 1 acc.queryText().getOffsetAtPoint(59, 21, pyatspi.XY_WINDOW)

    File /usr/lib/python3/dist-packages/pyatspi/text.py:346, in Text.getOffsetAtPoint(self, x, y, coordType)
        331 def getOffsetAtPoint(self, x, y, coordType):
        332         """
        333         Get the offset of the character at a given onscreen coordinate.
        334         The coordinate system used to interpret x and y is determined
       (...)
        344         -1 if the point is outside the bounds of any glyph.
        345         """
    --> 346         return Atspi.Text.get_offset_at_point(self.obj, x, y, coordType)

    Error: atspi_error: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. (1)

and the gtk4-demo output would show the actual problem:

    (gtk4-demo:563491): GLib-GIO-WARNING **: 13:18:27.652: Type of return value is incorrect: expected '(i)', got '(u)'

Fix this by returning an int as expected.

With this in place, the result is now as expected:

    In [48]: acc.queryText().getCharacterExtents(5, pyatspi.XY_WINDOW)
    Out[48]: (58, 20, 5, 19)
    In [49]: acc.queryText().getOffsetAtPoint(59, 21, pyatspi.XY_WINDOW)
    Out[49]: 5
2024-04-04 13:52:28 +02:00
Michael Weghorn
2cc241732d a11y atspi: Fix input variant type for Text's GetOffsetAtPoint
Trying to use the AT-SPI Text GetOffsetAtPoint method
didn't work.

For example, trying to use it from Accerciser's IPython
console with the gtk4-demo Hypertext example, would
give this error:

    In [45]: acc.queryText().getOffsetAtPoint(59, 21, pyatspi.XY_WINDOW)
    ---------------------------------------------------------------------------
    Error                                     Traceback (most recent call last)
    Cell In[45], line 1
    ----> 1 acc.queryText().getOffsetAtPoint(59, 21, pyatspi.XY_WINDOW)

    File /usr/lib/python3/dist-packages/pyatspi/text.py:346, in Text.getOffsetAtPoint(self, x, y, coordType)
        331 def getOffsetAtPoint(self, x, y, coordType):
        332         """
        333         Get the offset of the character at a given onscreen coordinate.
        334         The coordinate system used to interpret x and y is determined
       (...)
        344         -1 if the point is outside the bounds of any glyph.
        345         """
    --> 346         return Atspi.Text.get_offset_at_point(self.obj, x, y, coordType)

    Error: atspi_error: Unsupported coordinate space (1)

and the gtk4-demo output would show the actual problem:

    (gtk4-demo:562820): GLib-CRITICAL **: 13:14:10.862: the GVariant format string '(i&s)' has a type of '(is)' but the given value has a type of '(iiu)'

    (gtk4-demo:562820): GLib-CRITICAL **: 13:14:10.863: g_variant_get: assertion 'valid_format_string (format_string, TRUE, value)' failed

Specify the proper type, which gets us one step further at least.
2024-04-04 13:50:13 +02:00
Michael Weghorn
c01782b0a9 a11y atspi: Reuse helper to translate text coords
Instead of reimplementing translating coordinates
relative to a GtkAccessible in a way that requires
that the GtkAccessible is a GtkWidget, reuse the
existing helper function
`gtk_at_spi_translate_coordinates_from_accessible`
in the implementations of AT-SPI Text methods
GetCharacterExtents and GetRangeExtents.

This makes the implementation work for non-GtkWidget
GtkAccessibles, adds support for parent-relative
coordinates (ATSPI_COORD_TYPE_PARENT)
and also fixes an issue with incorrect extents
being reported in a quick test with the "Hypertext"
sample from gtk4-demo.

Sample for querying extents in Accerciser's IPython
console for the Hypertext sample previously gave this
result:

    In [39]: acc.queryText().getCharacterExtents(5, pyatspi.XY_WINDOW)
    Out[39]: (58, 20, -53, -1)

Now, a positive width and height are returned as expected and
the result matches the one when using the GTK 3 version
in gtk3-demo:

    In [1]: acc.queryText().getCharacterExtents(5, pyatspi.XY_WINDOW)
    Out[1]: (58, 20, 5, 19)
2024-04-04 13:50:13 +02:00
Michael Weghorn
a62831562f a11y atspi: Move helpers for coord translation to gtkatspiutils
Move the (so far) local helper functions used for the
AT-SPI Component method implementations,
`translate_coordinates_from_accessible` and
`translate_coordinates_to_accessible` to
`gtkatspiutilsprivate` and add a "gtk_at_spi_"
prefix to the function names.

This will allow to reuse them elsewhere in
upcoming commits.
2024-04-04 13:50:06 +02:00
Matthias Clasen
40dd81e1a4 Merge branch 'drop-redundant-a11y-code' into 'main'
a11y: Drop the per-widget text implementations

See merge request GNOME/gtk!6924
2024-04-04 10:03:15 +00:00
Matthias Clasen
a9f3a52c18 Drop some per-widget a11y text implementations
We still keep the editable implementation, since not all our
editable widgets implement GtkAccessibleText yet, but the label,
inscription and textview implementations are unused.
2024-04-04 10:14:46 +02:00
Matthias Clasen
0978912922 Merge branch 'macos-color-picker' into 'main'
macos: color picker

Closes #5137

See merge request GNOME/gtk!7099
2024-04-04 06:56:08 +00:00
Matthias Clasen
3c9923d395 Merge branch 'a11y-text-work' into 'main'
a11y: Implement GetOffsetAtPoint

See merge request GNOME/gtk!7004
2024-04-04 05:31:17 +00:00
Matthias Clasen
0296f49eb0 Merge branch 'dynamic-cursor' into 'main'
gdk: Add dynamic cursors

See merge request GNOME/gtk!7067
2024-04-04 05:30:54 +00:00
Matthias Clasen
4b7a550366 Merge branch 'bump-pango-dep' into 'main'
Bump the pango dep

Closes #6554

See merge request GNOME/gtk!7100
2024-04-04 05:29:56 +00:00
Matthias Clasen
37e18b784e gtk-demo: Add a callback cursor
Make one of the GTK logo cursors in the cursors demo use a callback
cursor that follows the cursor theme size, to show that that is
possible.
2024-04-04 01:07:28 +02:00
Matthias Clasen
1275a2cb8d wayland: Use a viewport for pointer surfaces
This should give us more flexibility for buffer size vs surface
size.

Unfortunately, mutter doesn't play along currently, so this is
only useful for kwin, weston or sway.
2024-04-04 01:07:28 +02:00
Matthias Clasen
67a6f343a0 wayland: Keep pointer_output_scale as double
We can round up to the next integer when we need to.
2024-04-04 01:07:28 +02:00
Matthias Clasen
a98e6bff85 Add a test app
This app has a dynamic cursor that is the GTK logo, loaded from
an SVG to make it come out at the nominal size of the cursor
theme, while taking fractional scaling into account.
2024-04-04 01:07:28 +02:00
Matthias Clasen
d0f5644771 macos: Handle callback cursors
This implementation matches the X11 one closely.
2024-04-04 01:07:28 +02:00
Matthias Clasen
b1a3ac8330 win32: Handle callback cursors
This implementation matches the X11 one closely.
2024-04-04 01:07:28 +02:00
Matthias Clasen
80811069ac x11: Handle callback cursors
For these cursors, get the texture for the cursor image by
calling the callback. We always use scale 1.
2024-04-04 01:07:28 +02:00
Matthias Clasen
6e3dc1e669 wayland: Handle callback cursors
For these cursors, get the texture for the cursor image by
calling the callback. We don't do any caching of the cursor
images for now.
2024-04-04 01:07:28 +02:00
Matthias Clasen
d1aa0a74e4 gdk: Add callback cursors
Add a variant of GdkCursor that obtains the texture for the cursor
via a callback. The callback gives us the flexibility to handle
fractional scales and update the cursor for cursor theme size
changes as well as scale changes.
2024-04-04 01:07:28 +02:00
Matthias Clasen
7a6fb09179 inscription: Add tests for gtk_accessible_text_get_offset
Test that we get the expected values on an inscription.
2024-04-04 01:05:38 +02:00
Matthias Clasen
5732c5e3d0 label: Add tests for gtk_accessible_text_get_offset
Test that we get the expected values on a label.
2024-04-04 01:05:38 +02:00
Matthias Clasen
79fb3d9b0c textview: Implement gtk_accessible_text_get_offset
This is relatively straightforward, reusing existing infrastructure.
2024-04-04 01:05:31 +02:00
Matthias Clasen
17455054f1 text: Implement gtk_accessible_text_get_offset
Reusing existing infrastructure as much as possible.
2024-04-04 01:04:47 +02:00
Matthias Clasen
763f51cb98 inscription: Implement gtk_accessible_text_get_offset
This is copying the corresponding code from GtkLabel.
2024-04-04 01:04:13 +02:00
Matthias Clasen
9fb78603ec label: Implement gtk_accessible_text_get_offset
We can reuse existing infrastructure for this.
2024-04-04 01:03:33 +02:00
Matthias Clasen
f802be88e9 a11y: Use gtk_accessible_text_get_offset
Implement GetOffsetAtPoint using gtk_accessible_text_get_offset.
2024-04-04 01:02:42 +02:00
Matthias Clasen
b9d2049991 a11y: Add gtk_accessible_text_get_offset
This is not implemented yet.
2024-04-04 01:02:41 +02:00
Matthias Clasen
cfe3558610 a11y: Add GetOffsetAtPoint
We don't handle it yet.
2024-04-04 01:00:25 +02:00
Matthias Clasen
35d15de3b6 label: Fix provider info lifecycle
This is a follow-up fix to a48df87a85, which was insufficient.
2024-04-04 01:00:25 +02:00
Matthias Clasen
23a336df0e Bump the pango dep
Require pango 1.52, and drop the fallback code.

Fixes: #6554
2024-04-04 00:56:24 +02:00
Matthias Clasen
bacdc735a4 Merge branch 'a11y-text-work2' into 'main'
a11y: Add gtk_accessible_text_get_extents

See merge request GNOME/gtk!7006
2024-04-03 22:55:30 +00:00
Matthias Clasen
19a168446e textview: Implement gtk_accessible_text_get_extents
There is some question if this needs to be clipped to widget extents
- if the textview is in a scrolled window, we can easily return
extents here that go beyond the window or event the screen.
2024-04-04 00:29:24 +02:00
Matthias Clasen
47ec7bc66d text: Implement gtk_accessible_text_get_extents
Using existing infrastructure.
2024-04-04 00:29:24 +02:00
Matthias Clasen
b4178870dd inscription: Implement gtk_accessible_text_get_extents
Using existing infrastructure.
2024-04-04 00:29:24 +02:00
Matthias Clasen
03ef792802 label: Implement gtk_accessible_text_get_extents
Using existing infrastructure.
2024-04-04 00:29:24 +02:00
Matthias Clasen
7955efef6c atspi: Use gtk_accessible_text_get_extents
Implement the GetCharacterExtents and GetRangeExtents methods of
the atspi Text interface using the new GtkAccessibleText api.
2024-04-04 00:29:24 +02:00
Matthias Clasen
3134003376 a11y: Add gtk_accessible_text_get_extents
This will be used to implement GetRangeExtents in atspi.
2024-04-04 00:29:24 +02:00
Matthias Clasen
a508860d1f Merge branch 'matthiasc/for-main' into 'main'
Start 4.15 development

See merge request GNOME/gtk!7098
2024-04-03 22:04:11 +00:00
Arjan Molenaar
c835ca41e0 macos: Pick color with NSColorSampler
NSColorSampler is the easiest way to pick a color.
It does require macOS 10.15+ to work.
2024-04-03 21:10:20 +02:00
Arjan Molenaar
2d5eafd014 macos: Add skeleton for color picker 2024-04-03 21:01:24 +02:00
Matthias Clasen
9b34878208 Merge branch 'cursor-demo-cosmetics' into 'main'
gtk-demo: Cosmetic changes

See merge request GNOME/gtk!7068
2024-04-03 14:08:38 +00:00
Matthias Clasen
4b1b956d27 Start 4.15 development 2024-04-03 15:53:49 +02:00
Matthias Clasen
0dd58c4d1b gtk-demo: Cosmetic changes
Remove the periods from the tooltips in the cursor demo.
Tooltips are better without periods.
2024-04-03 14:39:51 +02:00
Matthias Clasen
4b2b6d6212 Merge branch 'matthiasc/for-main' into 'main'
Post-release version bump

See merge request GNOME/gtk!7097
2024-04-03 12:23:07 +00:00
Matthias Clasen
2cdb53d524 Post-release version bump 2024-04-03 14:19:31 +02:00
Matthias Clasen
4f7721e742 Merge branch 'matthiasc/for-main' into 'main'
4.14.2

See merge request GNOME/gtk!7096
2024-04-03 12:18:20 +00:00
Matthias Clasen
29c29b0e64 4.14.2 2024-04-03 12:20:34 +02:00
Matthias Clasen
3d7fc0a598 Merge branch 'cff-font-hinting' into 'main'
gsk: Use hinted extents

Closes #6577 and #6568

See merge request GNOME/gtk!7086
2024-04-03 10:12:47 +00:00
Matthias Clasen
9e3e0052dc Merge branch 'fix_accessible_text_changed_notifications' into 'main'
a11y: Provide correct end offset for GtkText text insertions

Closes libadwaita#824

See merge request GNOME/gtk!7075
2024-04-03 09:37:52 +00:00
Yaron Shahrabani
5ecfcaec0d Update Hebrew translation 2024-04-03 09:13:56 +00:00
Matthias Clasen
cc24401dfb Drop unused private API
We are not using gsk_get_unhinted_glyph_string_extents anymore.
2024-04-03 10:53:55 +02:00
Matthias Clasen
f445d8b518 gsk: Use hinted extents
This works better for cff fonts, where hinting is not as local as
what the autohinter does for ttf fonts, and it does not seem to
have negative effects.

Fixes: #6577
Fixes: #6568
2024-04-03 10:52:13 +02:00
Carlos Garnacho
af4c9ea61e Merge branch 'provide-touch-serial-later' into 'main'
gdk/wayland: Proivde latest touch serial even after a touch ended

See merge request GNOME/gtk!5782
2024-04-03 08:43:03 +00:00
Matthias Clasen
4a75c288b2 Merge branch 'cff-font-hinting2' into 'main'
gsk: Keep metrics hinting on when rendering

See merge request GNOME/gtk!7093
2024-04-02 08:48:07 +00:00
Andre Klapper
89fca57e68 Docs / README: Fix issue tracker URL
Link to public Issues overview page instead of a 404 New Issue page
when you are not already logged into GNOME GitLab.
2024-04-02 10:10:11 +02:00
Matthias Clasen
d50b780551 gsk: Keep metrics hinting on when rendering
It turns out that we mispositioned glyphs with some cff fonts
when metrics hinting is off, and hinting is on. Since we don't
fully understand the interactions of these settings at this point,
lets preserve metrics hinting as it was on the font we got.

This at least gives folks a workaround for when they experience
clipped rendering with cff fonts: Turn on hint-metrics.

We forced hint metrics off here because it made Pango do some
creative wfh for hex boxes at small sizes, but I've dropped that
on the Pango side.
2024-04-02 09:10:46 +02:00
Matthias Clasen
f4a8787219 Merge branch 'empty-settings-portal' into 'main'
wayland: Fix detection of empty settings portal response

See merge request GNOME/gtk!7090
2024-04-02 06:44:08 +00:00
Chris Williams
979d0f4b1d wayland: Fix detection of empty settings portal response
The ReadAll method returns a one-element tuple, so
g_variant_n_children() is always 1.
2024-04-01 10:33:00 -04:00
Matthias Clasen
5af7c7d0f2 Merge branch 'matthiasc/for-main' into 'main'
ci: Avoid silly date-dependent failures

See merge request GNOME/gtk!7088
2024-03-31 13:59:11 +00:00
Matthias Clasen
90aff59826 Merge branch 'no-fc-build' into 'main'
Fix build without fontconfig

Closes #6591

See merge request GNOME/gtk!7087
2024-03-31 13:58:21 +00:00
Matthias Clasen
f0f3ea1b3e Fix build without fontconfig
We were missing some ifdefs for Windows builds.

Fixes: #6591
2024-03-31 13:08:01 +02:00
Matthias Clasen
f4b7f5de2f ci: Avoid silly date-dependent failures
GtkCalendar defaults to the current date, and things get murky
if the current day is number 30 or 31 in a month. Avoid these
problems.
2024-03-31 09:57:50 +02:00
Danial Behzadi
ca5af396b0 Update Persian translation 2024-03-30 20:31:19 +00:00
Ekaterine Papava
9f56be3551 Update Georgian translation 2024-03-30 18:26:28 +00:00
Martin
389f41ead7 Update Slovenian translation 2024-03-30 17:03:18 +00:00
Yuri Chornoivan
62108f8c30 Update Ukrainian translation 2024-03-30 09:27:21 +00:00
Matthias Clasen
d3206f9b67 Merge branch 'inspector-font-settings' into 'main'
inspector: Add font settings

See merge request GNOME/gtk!7085
2024-03-30 09:14:59 +00:00
Emmanuele Bassi
9b81f4cc31 Merge branch 'ebassi/doc-fixes' into 'main'
docs: Fix the reference link

See merge request GNOME/gtk!7084
2024-03-29 14:56:41 +00:00
Matthias Clasen
a864084a4e inspector: Add font settings
Add dedicated UI for font-related settings.

This makes debugging font rendering easier.
2024-03-29 15:55:36 +01:00
Matthias Clasen
ba44464d2a inspector: Cosmetics
Line up the scale+entry rows better.
2024-03-29 15:55:36 +01:00
Emmanuele Bassi
9509876f10 docs: Fix the reference link 2024-03-29 13:31:36 +00:00
Matthias Clasen
f79549f5fc Merge branch 'typo-fix' into 'main'
docs: Corrected typo on gtkDirectoryList description

See merge request GNOME/gtk!7083
2024-03-29 06:47:37 +00:00
maxrdz
bfb451ff4d docs: Corrected typo on gtkDirectoryList description 2024-03-28 22:56:18 -07:00
Benjamin Otte
edfbfb2ba7 Merge branch 'wip/otte/msys-build' into 'main'
Fix msys CI build

Closes #6580

See merge request GNOME/gtk!7082
2024-03-28 20:50:24 +00:00
Benjamin Otte
6aa37a116d build: Install vulkan-headers on msys CI
Apparently those are 2 packages.

Fixes #6580
2024-03-28 21:09:44 +01:00
Benjamin Otte
a34c018592 build: Use "meson setup" instead of just "meson"
Gets rid of a warning.
2024-03-28 21:09:44 +01:00
Benjamin Otte
710d8b948b build: Remove stray file
How did that one get here?
2024-03-28 21:09:44 +01:00
Benjamin Otte
3df85581d5 Merge branch 'wip/otte/6582' into 'main'
wayland: On hide, remove frame callbacks from subsurfaces

Closes #6582

See merge request GNOME/gtk!7081
2024-03-28 19:59:29 +00:00
Benjamin Otte
91e3bc4496 wayland: On hide, remove frame callbacks from subsurfaces
Fixes subsurfaces receiving frame callbacks while the surface is hidden
or already destroyed.

Fixes #6582
2024-03-28 20:29:06 +01:00
Sabri Ünal
1f5df481a5 Update Turkish translation 2024-03-28 14:35:29 +00:00
Matthias Clasen
768522ce7f Merge branch 'matthiasc/for-main' into 'main'
icontheme: Trust the compiler

See merge request GNOME/gtk!7076
2024-03-28 00:02:50 +00:00
Benjamin Otte
5f4e5db91b Merge branch 'gtklistitemwidget-focus' into 'main'
gtk: Fix GtkListItemWidget focus chain

Closes #6340

See merge request GNOME/gtk!6777
2024-03-27 21:35:56 +00:00
Matthias Clasen
c5f73cb406 Tweak the eglconfig description once more
Just always print the depth and stencil buffer depth,
for maximum clarity.
2024-03-27 16:30:27 +01:00
Lukáš Tyrychtr
86c4a9b3bd a11y: Provide correct end offset for GtkText text insertions
Fixes libadwaita#824
2024-03-27 16:24:32 +01:00
Matthias Clasen
fb915dc8da NEWS: Updates 2024-03-27 14:18:16 +01:00
Matthias Clasen
7a2569be14 icontheme: Trust the compiler
Just trust the compiler to replace strlen (literal) by the length.
2024-03-27 14:18:16 +01:00
Athmane MOKRAOUI
b1eed1c153 Add Kabyle translation 2024-03-26 11:34:22 +00:00
Martin
fac6f6c712 Update Slovenian translation 2024-03-24 23:19:54 +00:00
Martin
3f1fc798f0 Update Slovenian translation 2024-03-24 23:17:49 +00:00
Luca Bacci
e6a86f61dc Merge branch 'fix-issue-3749' into 'main'
GdkWin32: Always set WS_MINIMIZEBOX on GdkToplevel

Closes #3749

See merge request GNOME/gtk!7072
2024-03-22 17:57:06 +00:00
Matthias Clasen
2799632c02 Merge branch 'scalefix' into 'main'
GtkScale: improving symmetry and value positioning

Closes #5171

See merge request GNOME/gtk!6935
2024-03-22 16:18:48 +00:00
Luca Bacci
8ffa681e02 GdkWin32: Always set WS_MINIMIZEBOX on GdkToplevel
Regardless if server-side decorated or not. This way the shell knows
that the window can be minimized.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3749
2024-03-22 16:47:59 +01:00
Matthias Clasen
154035e76f Merge branch 'entry-progress' into 'main'
theme: Make sure progress in entries is visible

Closes #6201

See merge request GNOME/gtk!7071
2024-03-22 15:00:48 +00:00
Matthias Clasen
1d4c664bfa theme: Make sure progress in entries is visible
Give the trough a min height, so it doesn't shrink to nothing.

Fixes: #6201
2024-03-22 09:34:11 -04:00
Matthias Clasen
85a650afce Merge branch 'dnd-cursor-malaise' into 'main'
wayland: Guarantee dnd-move as a cursor name

See merge request GNOME/gtk!7070
2024-03-22 02:15:32 +00:00
Matthias Clasen
f6c4d3731c dnd: Go back to using dnd-move as move cursor
The move cursor in Adwaita is stuck with the 4-headed arrow image
which isn't suitable for a dnd cursor.

See https://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/issues/286
2024-03-21 21:36:38 -04:00
Matthias Clasen
5e9070145e wayland: Guarantee dnd-move as a cursor name
We need to go back to using this, since move is widely abused
and thus can't change its image to one thats appropriate for dnd.
2024-03-21 21:35:45 -04:00
Matthias Clasen
81ced841dd Merge branch 'matthiasc/for-main' into 'main'
inspector: Show presentation time protocol

See merge request GNOME/gtk!7069
2024-03-21 12:35:33 +00:00
Matthias Clasen
9837a9dcfd inspector: Show presentation time protocol
We have a list of all the used Wayland protocols and their versions
in the inspector. Lets keep it up-to-date.
2024-03-21 07:29:58 -04:00
Matthias Clasen
1704ec3c7d Merge branch 'wip/chergert/presentation-time' into 'main'
gdk/wayland: implement client side of presentation-time

See merge request GNOME/gtk!6987
2024-03-21 11:28:19 +00:00
Matthias Clasen
c70a326055 Merge branch 'matthiasc/for-main' into 'main'
Sync cursor images with Adwaita

See merge request GNOME/gtk!7065
2024-03-21 02:37:35 +00:00
Christian Hergert
53616a73e9 gdk/wayland: use wp_presentation for more accurate frame timings
This attempts to improve the accuracy for the "presentation_time" of an
individual GdkFrameTimings. That information is currently filled in as soon
as we get a frame callback. However, if presentation-time wayland protocol
is available, that will be used to supliment a more accurate time which
may improve future presentation-time predictions within GdkFrameClockIdle.

The protocol states that all related and sub surfaces will receive the
same information so it is safe that this could be registered for more
than just the toplevel. The information becomes idempotent.
2024-03-20 14:45:58 -07:00
Jordan Petridis
2d3a3d6a78 Merge branch 'alatiera/ci-vulkan' into 'main'
flatpak-build.sh: Do not disable vulkan

See merge request GNOME/gtk!7066
2024-03-20 20:15:54 +00:00
Jordan Petridis
6ca9e5987b flatpak-build.sh: Do not disable vulkan
In a94d7abf0d we removed
the explicit disable from the manifest.

Now we should also have the CI build the vulkan render as well.
2024-03-20 21:18:13 +02:00
Matthias Clasen
2c1590001f Sync cursor images with Adwaita
Several cursor metaphors were changes in Adwaita. Update our docs
and the Cursors demo to match.
2024-03-20 13:19:12 -04:00
Matthias Clasen
82aee038e9 Merge branch 'alatiera/ci-vulkan' into 'main'
flatpak demos: Enable vulkan backend

See merge request GNOME/gtk!7064
2024-03-20 14:46:04 +00:00
Jordan Petridis
a94d7abf0d flatpak demos: Enable vulkan backend
glslc is now in the Sdk itself

https://gitlab.gnome.org/GNOME/gnome-build-meta/-/merge_requests/2640
2024-03-20 15:47:42 +02:00
Matthias Clasen
3b87903889 Merge branch 'wayland-min-version' into 'main'
wayland: Check some required globals

See merge request GNOME/gtk!7062
2024-03-20 02:57:06 +00:00
Matthias Clasen
191f826075 wayland: Only set buffer scale if we can
We check this in some other places, so be consistent.
2024-03-19 22:22:53 -04:00
Matthias Clasen
5d52c43074 wayland: Check all required globals for subsurfaces
Before trying to use subsurfaces, make sure we have both
a subcompositor and a viewporter.
2024-03-19 22:22:53 -04:00
Matthias Clasen
f6a67aeb20 wayland: Check some required globals
This may be largely cosmetics, since these are core protocols that
are unlikely to ever be missing. But lets check anyway.
2024-03-19 17:28:25 -04:00
Jordi Mas
370e2f0940 Update Catalan translation 2024-03-19 21:37:20 +01:00
Gergo Koteles
34028ea31e GtkScale: move value in line with the through.
The value is between the through and the markups, and appears scattered.

Move it in line with the through.

Fixes: #5171
2024-02-23 02:04:24 +01:00
Gergo Koteles
4244314a40 GtkScale: add symmetry border to the scales without markups
The scales with marks require css adjustments for center positioning.

Add border to the other side to make it symmetrical.

Fixes: #5171
2024-02-23 01:58:47 +01:00
Kévin Commaille
e6046e9493 gtk: Fix GtkListItemWidget focus chain
It would not check if the focus child can handle the focus,
so it wouldn't be possible to navigate through each focusable descendant

Fixes #6340
2024-01-17 15:14:12 +01:00
Michael Weghorn
bcf78aeb39 a11y atspi: Map GTK_ACCESSIBLE_PROPERTY_LEVEL to AT-SPI attr
Map GTK_ACCESSIBLE_PROPERTY_LEVEL to the corresponding
AT-SPI object attribute "level", as it is specified
e.g. in the Core Accessibility Mappings 1.2 for the
"aria-level" attribute, for both, headings [1] and
non-headings [2].

This e.g. makes reporting the header level via
AT-SPI work for the gtk4-based LibreOffice variant
when combined with the corresponding LibreOffice
change [3] to set the GTK_ACCESSIBLE_PROPERTY_LEVEL
property.

For a related discussion, see issue #6196.

[1] https://www.w3.org/TR/core-aam-1.2/#ariaLevelHeading
[2] https://www.w3.org/TR/core-aam-1.2/#ariaLevel
[3] https://gerrit.libreoffice.org/c/core/+/159216
2023-11-09 17:21:00 +01:00
Lukáš Tyrychtr
02cdb36421 Document what to do if the preconditions can not be met 2023-05-22 12:22:18 +02:00
Lukáš Tyrychtr
b3d4d70bc1 GtkEditable: Document the usage restrictions of gtk_editable_delegate_get_accessible_platform_state
The API is not always useful, because it depends on the position of the
delegated to widget in the widget tree, so document that.
2023-05-22 12:22:18 +02:00
Jonas Dreßler
e5ffbb19c0 gdk/wayland: Proivde latest touch serial even after a touch ended
When grabbing the seat for an xdg popup using xdg_popup_grab() in response
to a touch-end event, we request the grab a little late and the touch is no
longer being tracked by gdkseat. This means that
_gdk_wayland_seat_get_last_implicit_grab_serial() right now can not provide
us with the serial for that touchpoint, because that serial was stored on
the GdkWaylandTouchData that is already gone.

To still provide the compositor a valid serial in that case, store the
serial of the latest touchpoint more persistently in GdkWaylandSeat itself,
so that we can still access it when the touchpoint has already ended.
2023-04-03 15:12:55 +02:00
Maxim Zakharov
715c0bfc0a gdk/broadway: Port !2972 and !3130 from gtk3
!2972 fixes touchscreen events processing
 !3130 adds support for Android/Chrome on-screen keyboard
2022-02-11 09:29:57 +11:00
1143 changed files with 69738 additions and 29046 deletions

View File

@@ -117,10 +117,11 @@ release-build:
EXTRA_MESON_FLAGS: "--buildtype=release"
script:
- .gitlab-ci/show-info-linux.sh
- export PATH="$HOME/.local/bin:$PATH"
- mkdir _install
- export PATH="$HOME/.local/bin:${CI_PROJECT_DIR}/_install/bin:$PATH"
- .gitlab-ci/install-meson-project.sh --prefix ${CI_PROJECT_DIR}/_install https://gitlab.gnome.org/jadahl/catch.git main
- meson subprojects download
- meson subprojects update --reset
- mkdir _install
- meson setup
--prefix=${CI_PROJECT_DIR}/_install
${COMMON_MESON_FLAGS}
@@ -445,10 +446,10 @@ reference:
--force-fallback-for=gdk-pixbuf,pango
-Dintrospection=enabled
-Ddocumentation=true
-Dgtk_doc=true
-Dman-pages=true
-Dgdk-pixbuf:gtk_doc=true
-Dpango:gtk_doc=true
-Dbuild-demos=false
-Dpango:documentation=true
-Dbuild-demos=true
-Dbuild-examples=false
-Dbuild-tests=false
-Dbuild-testsuite=false
@@ -460,6 +461,7 @@ reference:
- mv _build/docs/reference/gdk/gdk4-wayland/ _reference/gdk4-wayland/
- mv _build/docs/reference/gsk/gsk4/ _reference/gsk4/
- mv _build/docs/reference/gtk/gtk4/ _reference/gtk4/
- mv _build/docs/reference/gtk/*.html _reference/gtk4/
- mv _build/subprojects/pango/docs/Pango/ _reference/Pango/
- mv _build/subprojects/pango/docs/PangoCairo/ _reference/PangoCairo/
- mv _build/subprojects/pango/docs/PangoFc/ _reference/PangoFc/

Binary file not shown.

View File

@@ -19,13 +19,12 @@ flatpak build ${builddir} meson \
--buildtype=debugoptimized \
-Dx11-backend=true \
-Dwayland-backend=true \
-Dvulkan=disabled \
-Dbuild-tests=false \
-Dbuild-testsuite=false \
-Dbuild-examples=false \
-Dintrospection=disabled \
-Dbuild-demos=true \
-Ddemo-profile=devel \
-Dprofile=devel \
_flatpak_build
flatpak build --env=CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA ${builddir} ninja -C _flatpak_build install

View File

@@ -0,0 +1,91 @@
#!/bin/bash
set -e
usage() {
cat <<-EOF
Usage: $(basename $0) [OPTION…] REPO_URL COMMIT
Check out and install a meson project
Options:
-Dkey=val Option to pass on to meson
--prefix Prefix to install to
--subdir Build subdirectory instead of whole project
--prepare Script to run before build
-h, --help Display this help
EOF
}
TEMP=$(getopt \
--name=$(basename $0) \
--options='D:h' \
--longoptions='prefix:' \
--longoptions='subdir:' \
--longoptions='prepare:' \
--longoptions='help' \
-- "$@")
eval set -- "$TEMP"
unset TEMP
MESON_OPTIONS=()
PREFIX=/usr
SUBDIR=.
PREPARE=:
while true; do
case "$1" in
-D)
MESON_OPTIONS+=( -D$2 )
shift 2
;;
--prefix)
PREFIX=$2
shift 2
;;
--subdir)
SUBDIR=$2
shift 2
;;
--prepare)
PREPARE=$2
shift 2
;;
-h|--help)
usage
exit 0
;;
--)
shift
break
;;
esac
done
if [[ $# -lt 2 ]]; then
usage
exit 1
fi
REPO_URL="$1"
COMMIT="$2"
CHECKOUT_DIR=$(mktemp --directory)
trap "rm -rf $CHECKOUT_DIR" EXIT
git clone --depth 1 "$REPO_URL" -b "$COMMIT" "$CHECKOUT_DIR"
pushd "$CHECKOUT_DIR/$SUBDIR"
sh -c "$PREPARE"
meson setup --prefix "$PREFIX" _build "${MESON_OPTIONS[@]}"
meson compile -C _build
meson install -C _build
popd

View File

@@ -34,7 +34,8 @@ pacman --noconfirm -S --needed \
mingw-w64-$MSYS2_ARCH-shared-mime-info \
mingw-w64-$MSYS2_ARCH-python-gobject \
mingw-w64-$MSYS2_ARCH-shaderc \
mingw-w64-$MSYS2_ARCH-vulkan
mingw-w64-$MSYS2_ARCH-vulkan \
mingw-w64-$MSYS2_ARCH-vulkan-headers
mkdir -p _ccache
export CCACHE_BASEDIR="$(pwd)"
@@ -44,7 +45,7 @@ export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
ccache --zero-stats
ccache --show-stats
export CCACHE_DISABLE=true
meson \
meson setup \
-Dx11-backend=false \
-Dwayland-backend=false \
-Dwin32-backend=true \

View File

@@ -35,7 +35,7 @@ The issue tracker is meant to be used for actionable issues only.
You should not open a new issue for security related questions.
When in doubt, follow [security](https://security.gnome.org/).
When in doubt, follow the process for [GNOME security issues](https://security.gnome.org/).
### Bug reports
@@ -100,14 +100,16 @@ development tools appropriate for your operating system, including:
- Meson
- Ninja
- Gettext (19.7 or newer)
- a [C99 compatible compiler](https://wiki.gnome.org/Projects/GLib/CompilerRequirements)
- a [C99 compatible compiler][glib-toolchain-reqs]
Up-to-date instructions about developing GNOME applications and libraries
can be found on [the GNOME Developer Center](https://developer.gnome.org).
The GTK project uses GitLab for code hosting and for tracking issues. More
information about using GitLab can be found [on the GNOME
wiki](https://wiki.gnome.org/GitLab).
information about using GitLab can be found on [the GNOME handbook][handbook].
[glib-toolchain-reqs]: https://gitlab.gnome.org/GNOME/glib/-/blob/main/docs/toolchain-requirements.md
[handbook]: https://handbook.gnome.org/infrastructure/gitlab.html
### Dependencies
@@ -131,7 +133,7 @@ GTK will attempt to download and build some of these dependencies if it
cannot find them on your system.
Additionally, you may want to look at projects that create a development
environment for you, like [jhbuild](https://wiki.gnome.org/HowDoI/Jhbuild)
environment for you, like [jhbuild](https://gitlab.gnome.org/GNOME/jhbuild)
and [gvsbuild](https://github.com/wingtk/gvsbuild).
### Getting started
@@ -144,33 +146,28 @@ $ git clone https://gitlab.gnome.org/yourusername/gtk.git
$ cd gtk
```
**Note**: if you plan to push changes to back to the main repository and
have a GNOME account, you can skip the fork, and use the following instead:
```sh
$ git clone git@gitlab.gnome.org:GNOME/gtk.git
$ cd gtk
```
To compile the Git version of GTK on your system, you will need to
configure your build using Meson:
```sh
$ meson _builddir .
$ cd _builddir
$ ninja
$ meson setup _builddir .
$ meson compile -C _builddir
```
Typically, you should work on your own branch:
```sh
$ git checkout -b your-branch
$ git switch -C your-branch
```
Once you've finished working on the bug fix or feature, push the branch
to the Git repository and open a new merge request, to let the GTK
maintainers review your contribution.
**Important**: Do **not** attach a diff or a patch file to a GitLab issue.
Patches cannot be reviewed, and do not not go through the CI pipeline. If
you wish to submit your changes to GTK, always use a merge request.
### Code reviews
Each contribution is reviewed by the core developers of the GTK project.
@@ -262,4 +259,4 @@ people committing to GTK to follow a few rules:
If you have been contributing to GTK for a while and you don't have commit
access to the repository, you may ask to obtain it following the [GNOME account
process](https://wiki.gnome.org/AccountsTeam/NewAccounts).
process](https://handbook.gnome.org/infrastructure/developer-access.html).

364
NEWS
View File

@@ -1,6 +1,368 @@
Overview of Changes in 4.14.2, xx-xx-xxxx
Overview of Changes in 4.15.5, xx-xx-xxxx
=========================================
Overview of Changes in 4.15.4, 30-07-2024
=========================================
* GtkPopover:
- Fix size allocation with wrapping labels
* GtkColumnView:
- Check column visibility when measuring
* CSS:
- Fix fallout from recent changes
- Make implementation of currentcolor inheritance match browsers
* Gdk:
- Introduce GdkColorState for encoding color space information
Currently, we support srgb, srgb-linear, rec2100-pq and rec2100-linear
- Add color states to GdkTexture, as well as to the texture builder
and downloader objects, and convert as necessary
- Add GdkMemoryTextureBuilder
- Attach color states when loading or saving textures
- Add GdkCicpParams to create color state objects for cicp tuples
- Drop GDK_DEBUG=vulkan-validate
Use VK_INSTEANCE_LAYERS=VK_LAYER_KHRONOS_validation instead
* Gsk:
- Improve caching of glyphs and textures
- Remove the uber shader
- Numerous bug fixes
- Fix corner cases in offload handling
- Implement occlusion culling for opaque content
- Allow offloading (some) transformed textures
- Take colorstate into account when compositing
- Add GDK_DEBUG=linear to opt into linear compositing
- Implement tiling for large textures
- Stop using descriptors and go back to simpler texture
management that should work better with older GL
- Use correct shader clip mode for glyphs
- Improve shadow rendering
* Media:
- Attach color states to textures obtained from gstreamer
* Wayland:
- Allow offloading GL textures via dmabuf export
- Suppot the xx-color-management-v4 protocol
* Deprecations:
- GskGLShader and the render node
* Tools:
- Improve the rendernode tool extract command
- Add an image tool that is about manipulating textures
* Build:
- GTK now requires a C11 compiler
* Translation updates
Georgian
Hebrew
Hindi
Occitan
Slovenian
Overview of Changes in 4.15.3, 29-06-2024
=========================================
* Accessibility:
- Only emit notifications when cursor positions change in GtkText
- Fix handling of help text properties
* CSS:
- Fix some crashes introduced in recent currentcolor changes
* DND:
- Avoid a critical
* Documentation:
- Fix many oversights and missing docs
* maxOS:
- Add native keyboard shortcuts
Overview of Changes in 4.15.2, 28-06-2024
=========================================
* GtkFileChooserWidget:
- Plug some memory leaks
- Make Ctrl-Shift-N create a new folder
* GtkPopover:
- Handle resizing and position changes better
* CSS:
- Support color(), oklab(), etc (https://www.w3.org/TR/css-color-4/)
- Support color-mix() (https://www.w3.org/TR/css-color-5/)
- Support relative colors (https://www.w3.org/TR/css-color-5/)
- Support more colorspaces in color()
- Allow percentages for opacity
- Handle currentcolor more correctly
* Accessibility:
- Avoid markup when reading labels
* GSK:
- Subset fonts when serializing node trees
- Make ngl export render_texture results as dmabufs
* Wayland:
- Use xdg-dialog protocol for attached dialogs
* Windows:
- Build with UNICODE
* macOS:
- Implement fullscreen-on-monitor
* Documentation:
- Widget shortcuts and actions are now described in the docs
* Debugging:
- Add GTK_DEBUG=css for warning about deprecated css syntax
* Tools:
- rendernode-tool: Add an extract command for data urls
* Deprecations:
- CSS Color functions shade(), lighter(), darker(), alpha(), mix()
* Translation updates:
Czech
Hebrew
Serbian
Overview of Changes in 4.15.1, 21-05-2024
=========================================
* GtkGraphicsOffload:
- Don't crash without a child
* GtkSpinner:
- Don't animate when unmapped
* CSS:
- Support the :root selector
- Support variables and custom properties (https://www.w3.org/TR/css-variables-1/)
- Implement math functions (https://www.w3.org/TR/css-values-4/)
- Support modern syntax and calc in rgb() and hsl()
* Icontheme:
- Make symbolic svg loading more efficient
- Handle color-free symbolics more efficiently
* Accessibility:
- Make the gtk-demo sidebar search more accessible
- Stop emitting focus events
- Realize child contexts when necessary
* GDK:
- Support XDG_ACTIVATION_TOKEN
- dmabuf: Be more defensive when importing unknown formats to GL
- dmabuf: Use narrow range for YUV
- vulkan: Recreate swapchains when necessary or beneficial
* GSK:
- Improve logging for GDK_DEBUG=offload
- Improve logging for GSK_DEBUG=renderer
- gpu: Warn about inefficient texture import
- gpu: Handle tiny offscreens correctly
- vulkan: Add profiler marks in various places
- vulkan: Fix a problem with imported dmabufs showing up black
- cairo: Speed up mask nodes, since we use them for symbolic icons
* Wayland:
- Use wl_compositor version 6
* X11:
- Implement a missing method
* Build:
- Fix many ubsan warnings
* Debugging:
- Show more texture details in the recorder
- Use GTK_DEBUG=css to see CSS deprecations
* macOS:
- Fix problems with events handed back to the OS
- Respect GDK_DEBUG=default-settings
- Allow applictions to handle Dock > Quit
* Deprecations:
- Use of @name colors in CSS
* Translation updates:
Catalan
Georgian
Hungarian
Korean
Portuguese
Turkish
Overview of Changes in 4.15.0, 21-04-2024
=========================================
This release changes the default GSK renderer to be Vulkan, on
Wayland. Other platforms still use ngl.
The intent of this change is to get wider testing and verify that
Vulkan drivers are good enough for us to rely on. If significant
problems show up, we will revert this change for 4.16.
You can still override the renderer choice using the GSK_RENDERER
environment variable.
---
This release also changes font rendering settings by introducing
a new high-level gtk-font-rendering settings which gives GTK more
freedom to decide on font rendering.
You can still use the low-level font-related settings by changing
the new property to 'manual'.
---
* GtkColumnView:
- Fix infinite loops in dispose
- Fix problems with weak ref cycles in GtkExpression
* GtkListView:
* GtkShortcutManager:
- Track the propagation phase of added controllers
* GtkGLArea:
- Produce dmabuf textures, so graphics offload is possible
* GtkTextView:
- Support text shadows
* GtkGraphicsOffload:
- Add a black-background property
* Settings:
- Add a new gtk-font-rendering setting
* Accessibility:
- Add support for GetRangeExtents to GtkAccessibleText
- Add support for GetOffsetAtPoint to GtkAccessibleText
- Implement GtkAccessibleRange for scrollbars
* GDK:
- Add a callback-based cursor API
* GSK:
- Use the Vulkan renderer by default
- Avoid an infinite recursion with offscreens in some cases
- Optimize graphics offload to make it more likely that compositors
can use direct scanout
* X11:
- Fix some confusing debug messages
- Drop a no-longer-relevant optimization that was interfering with
getting the current window manager capabilities
* macOS:
- Implement the color picker for macOS 10.15+
* Debugging:
- Snow monitor resolution in the inspector
* Demos:
- Use graphics offload in the shadertoy demo
- Show more reliable fps numbers in the fishbowl demo
* Tools:
- Support generating pdf in gtk4-rendernode-tool
* Build:
- Require pango 1.52
- Require cairo 1.18
- Add a missing dependency that was causing build failures
- Drop deprecated build options:
gtk_doc -> documentation
update_screenshots -> screenshots
demo-profile -> profile
demos -> build-demos
* Deprecations:
- gdk_widget_set/get_font_options
- gdk_wayland/x11_display_set_cursor_theme
* Translation updates:
Basque
Brazilian Portuguese
British English
Chinese (China)
Hebrew
Kabyle
Persian
Polish
Russian
Slovenian
Swedish
Turkish
Overview of Changes in 4.14.2, 03-04-2024
=========================================
* GtkScale:
- Improve positioning of values in some cases
* Theme:
- Make progress in entries visible
* Accessibility:
- Fix text insertion handling
* GDK:
- dnd: Use the default cursor durion motion
- dnd: Use a better cursor for indicating the move action
* GSK:
- gl: Handle offloads in offscreen context better
- Fix text rendering problems with some fonts
* Wayland:
- Tighten up some protocol version checks
- Use the presentation time protocol
- Fix a crash with subsurfaces
- Improve settings portal handling
* macOS:
- Fix up the app menu support
* Windows:
- Fix problems with minimization
- Fix build without fontconfig
* Debugging:
- Add font settings in the inspector
* Demos:
- Clean up the application demo
- Update cursor images for the cursor demo
* Translation updates:
Catalan
Czech
French
Georgian
Hebrew
Persian
Slovenian
Turkish
Ukrainian
Overview of Changes in 4.14.1, 16-03-2024
=========================================

View File

@@ -39,18 +39,21 @@ Nightly documentation can be found at
- Gsk: https://gnome.pages.gitlab.gnome.org/gtk/gsk4/
Nightly flatpaks of our demos can be installed from the
[GNOME Nightly](https://wiki.gnome.org/Apps/Nightly) repository:
- `flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo`
- `flatpak install gnome-nightly org.gtk.Demo4`
- `flatpak install gnome-nightly org.gtk.WidgetFactory4`
- `flatpak install gnome-nightly org.gtk.IconBrowser4`
[GNOME Nightly](https://nightly.gnome.org/) repository:
```sh
flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
flatpak install gnome-nightly org.gtk.Demo4
flatpak install gnome-nightly org.gtk.WidgetFactory4
flatpak install gnome-nightly org.gtk.IconBrowser4
```
Building and installing
-----------------------
In order to build GTK you will need:
- [a C99 compatible compiler](https://wiki.gnome.org/Projects/GLib/CompilerRequirements)
- [a C11 compatible compiler](https://gitlab.gnome.org/GNOME/glib/-/blob/main/docs/toolchain-requirements.md)
- [Python 3](https://www.python.org/)
- [Meson](http://mesonbuild.com)
- [Ninja](https://ninja-build.org)
@@ -125,7 +128,7 @@ version, for example `gtk-4-10`.
How to report bugs
------------------
Bugs should be reported on the [issues page](https://gitlab.gnome.org/GNOME/gtk/issues/new).
Bugs should be reported on the [issues page](https://gitlab.gnome.org/GNOME/gtk/issues/).
In the bug report please include:

View File

@@ -185,9 +185,8 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Ddemo-profile=devel"
"-Dprofile=devel"
],
"sources" : [
{

View File

@@ -114,9 +114,8 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Ddemo-profile=devel"
"-Dprofile=devel"
],
"sources" : [
{

View File

@@ -114,9 +114,8 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Ddemo-profile=devel"
"-Dprofile=devel"
],
"sources" : [
{
@@ -131,7 +130,6 @@
"env" : {
"DBUS_SESSION_BUS_ADDRESS" : "''",
"GSK_RENDERER" : "opengl",
"GDK_DEBUG" : "vulkan-disable",
"G_ENABLE_DEBUG" : "true"
}
}

View File

@@ -114,9 +114,8 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Ddemo-profile=devel"
"-Dprofile=devel"
],
"sources" : [
{
@@ -131,7 +130,6 @@
"env" : {
"DBUS_SESSION_BUS_ADDRESS" : "''",
"GSK_RENDERER" : "opengl",
"GDK_DEBUG" : "vulkan-disable",
"G_ENABLE_DEBUG" : "true"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -15,12 +15,54 @@ on_destroy (gpointer data)
window = NULL;
}
static GdkTexture *
cursor_callback (GdkCursor *cursor,
int cursor_size,
double scale,
int *width,
int *height,
int *hotspot_x,
int *hotspot_y,
gpointer data)
{
GdkPixbuf *pixbuf;
GdkTexture *texture;
GError *error = NULL;
int scaled_size;
scaled_size = ceil (cursor_size * scale);
pixbuf = gdk_pixbuf_new_from_resource_at_scale ("/cursors/images/gtk-logo.svg",
scaled_size, scaled_size,
TRUE,
&error);
if (!pixbuf)
{
g_print ("%s\n", error->message);
g_error_free (error);
return NULL;
}
texture = gdk_texture_new_for_pixbuf (pixbuf);
g_object_unref (pixbuf);
*width = cursor_size;
*height = cursor_size;
*hotspot_x = 18 * cursor_size / 32.0;
*hotspot_y = 2 * cursor_size / 32.0;
return texture;
}
GtkWidget *
do_cursors (GtkWidget *do_widget)
{
if (!window)
{
GtkBuilder *builder;
GtkWidget *logo_callback;
GdkCursor *cursor;
builder = gtk_builder_new_from_resource ("/cursors/cursors.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
@@ -29,6 +71,10 @@ do_cursors (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (on_destroy), NULL);
logo_callback = GTK_WIDGET (gtk_builder_get_object (builder, "logo_callback"));
cursor = gdk_cursor_new_from_callback (cursor_callback, NULL, NULL, NULL);
gtk_widget_set_cursor (logo_callback, cursor);
g_object_unref (cursor);
g_object_unref (builder);
}

File diff suppressed because it is too large Load Diff

View File

@@ -116,6 +116,7 @@
<file>w_resize_cursor.png</file>
<file>zoom_in_cursor.png</file>
<file>zoom_out_cursor.png</file>
<file>gtk-logo.svg</file>
</gresource>
<gresource prefix="/dnd">
<file>dnd.css</file>

View File

@@ -170,6 +170,7 @@ update_paintable (GtkWidget *widget,
static GtkWidget *
create_cogs (void)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
GtkWidget *picture;
static GskGLShader *cog_shader = NULL;
GdkPaintable *paintable;
@@ -182,6 +183,7 @@ create_cogs (void)
gtk_widget_add_tick_callback (picture, update_paintable, NULL, NULL);
return picture;
G_GNUC_END_IGNORE_DEPRECATIONS
}
static gboolean

View File

@@ -363,7 +363,9 @@ insert_markup_idle (gpointer data)
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
{
g_idle_add (insert_markup_idle, data);
guint id;
id = g_idle_add (insert_markup_idle, data);
g_source_set_name_by_id (id, "[gtk-demo] insert_markup_idle");
return G_SOURCE_REMOVE;
}
@@ -398,7 +400,9 @@ parse_markup_idle (gpointer data)
do {
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
{
g_idle_add (parse_markup_idle, data);
guint id;
id = g_idle_add (parse_markup_idle, data);
g_source_set_name_by_id (id, "[gtk-demo] parse_markup_idle");
return G_SOURCE_REMOVE;
}

View File

@@ -20,6 +20,8 @@
#include "gtkshadertoy.h"
#include "gskshaderpaintable.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *demo_window = NULL;
static void
@@ -360,3 +362,5 @@ do_gltransition (GtkWidget *do_widget)
return demo_window;
}
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -22,6 +22,8 @@
#include <gtk/gtk.h>
#include "gskshaderpaintable.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GskShaderPaintable:
*
@@ -332,3 +334,5 @@ gsk_shader_paintable_update_time (GskShaderPaintable *self,
g_bytes_unref (args);
}
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -22,6 +22,8 @@
#include <gdk/gdk.h>
#include <gsk/gsk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
G_BEGIN_DECLS
#define GSK_TYPE_SHADER_PAINTABLE (gsk_shader_paintable_get_type ())
@@ -41,3 +43,5 @@ void gsk_shader_paintable_update_time (GskShaderPaintable *self
int time_idx,
gint64 frame_time);
G_END_DECLS
G_GNUC_END_IGNORE_DEPRECATIONS

138
demos/gtk-demo/gtk-logo.svg Normal file
View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="128"
height="128"
id="svg6843"
sodipodi:version="0.32"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
version="1.0"
sodipodi:docname="gtk-logo.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:export-filename="/home/ebassi/Pictures/gtk-logo-256.png"
inkscape:export-xdpi="192"
inkscape:export-ydpi="192">
<defs
id="defs6845">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="-50 : 600 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="700 : 600 : 1"
inkscape:persp3d-origin="300 : 400 : 1"
id="perspective13" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="2.8284271"
inkscape:cx="69.874353"
inkscape:cy="64.313526"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:document-units="px"
inkscape:grid-bbox="true"
width="128px"
height="128px"
showguides="true"
inkscape:guide-bbox="true"
inkscape:window-width="1920"
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid7947" />
</sodipodi:namedview>
<metadata
id="metadata6848">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
<dc:date />
<dc:creator>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:creator>
<dc:rights>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:rights>
<dc:publisher>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:publisher>
<dc:identifier />
<dc:source />
<dc:relation />
<dc:language />
<dc:subject>
<rdf:Bag />
</dc:subject>
<dc:coverage />
<dc:description />
<dc:contributor>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:contributor>
<cc:license
rdf:resource="" />
</cc:Work>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
sodipodi:nodetypes="ccccc"
id="path6976"
d="M 20.88413,30.82696 L 53.816977,55.527708 L 107.33282,39.060543 L 70.587303,17.177763 L 20.88413,30.82696 z"
style="fill:#729fcf;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.12364459;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" />
<path
id="path6978"
d="M 22.94243,82.287118 L 20.88413,30.82696 L 53.816977,55.527708 L 53.816977,111.10486 L 22.94243,82.287118 z"
style="fill:#e40000;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.12364459;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" />
<path
id="path6980"
d="M 53.816977,111.10486 L 103.21619,90.5207 L 107.33282,39.060543 L 53.816977,55.527708 L 53.816977,111.10486 z"
style="fill:#7fe719;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.12364459;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" />
<path
sodipodi:nodetypes="ccc"
id="path6982"
d="M 23.216626,81.319479 L 70.48573,67.361442 L 103.38422,90.444516"
style="opacity:1;fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="cc"
id="path6984"
d="M 70.434539,17.875593 L 70.434539,66.984877"
style="opacity:1;fill:#babdb6;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -456,43 +456,33 @@ gtk_fishbowl_do_update (GtkFishbowl *fishbowl)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
GdkFrameClock *frame_clock;
GdkFrameTimings *start, *end;
gint64 start_counter, end_counter;
gint64 n_frames, expected_frames;
gint64 start_timestamp, end_timestamp;
GdkFrameTimings *end;
gint64 end_counter;
double fps, expected_fps;
gint64 interval;
frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (fishbowl));
if (frame_clock == NULL)
return;
start_counter = gdk_frame_clock_get_history_start (frame_clock);
end_counter = gdk_frame_clock_get_frame_counter (frame_clock);
start = gdk_frame_clock_get_timings (frame_clock, start_counter);
for (end = gdk_frame_clock_get_timings (frame_clock, end_counter);
end_counter > start_counter && end != NULL && !gdk_frame_timings_get_complete (end);
end = gdk_frame_clock_get_timings (frame_clock, end_counter))
end_counter--;
if (end_counter - start_counter < 4)
fps = gdk_frame_clock_get_fps (frame_clock);
if (fps <= 0.0)
return;
start_timestamp = gdk_frame_timings_get_presentation_time (start);
end_timestamp = gdk_frame_timings_get_presentation_time (end);
if (start_timestamp == 0 || end_timestamp == 0)
{
start_timestamp = gdk_frame_timings_get_frame_time (start);
end_timestamp = gdk_frame_timings_get_frame_time (end);
}
n_frames = end_counter - start_counter;
priv->framerate = ((double) n_frames) * G_USEC_PER_SEC / (end_timestamp - start_timestamp);
priv->framerate = ((int)(priv->framerate * 100))/100.0;
priv->framerate = fps;
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_FRAMERATE]);
if (!priv->benchmark)
return;
end_counter = gdk_frame_clock_get_frame_counter (frame_clock);
for (end = gdk_frame_clock_get_timings (frame_clock, end_counter);
end != NULL && !gdk_frame_timings_get_complete (end);
end = gdk_frame_clock_get_timings (frame_clock, end_counter))
end_counter--;
if (end == NULL)
return;
interval = gdk_frame_timings_get_refresh_interval (end);
if (interval == 0)
{
@@ -500,16 +490,16 @@ gtk_fishbowl_do_update (GtkFishbowl *fishbowl)
if (interval == 0)
return;
}
expected_frames = round ((double) (end_timestamp - start_timestamp) / interval);
expected_fps = (double) G_USEC_PER_SEC / interval;
if (n_frames >= expected_frames)
if (fps > (expected_fps - 1))
{
if (priv->last_benchmark_change > 0)
priv->last_benchmark_change *= 2;
else
priv->last_benchmark_change = 1;
}
else if (n_frames + 1 < expected_frames)
else if (0.95 * fps < expected_fps)
{
if (priv->last_benchmark_change < 0)
priv->last_benchmark_change--;

View File

@@ -1,5 +1,7 @@
#include "gtkshaderbin.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct {
GskGLShader *shader;
GtkStateFlags state;
@@ -262,3 +264,5 @@ gtk_shader_bin_new (void)
return GTK_WIDGET (self);
}
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -2,6 +2,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
G_BEGIN_DECLS
#define GTK_TYPE_SHADER_BIN (gtk_shader_bin_get_type ())
@@ -18,3 +20,5 @@ void gtk_shader_bin_set_child (GtkShaderBin *self,
GtkWidget *gtk_shader_bin_get_child (GtkShaderBin *self);
G_END_DECLS
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -1,5 +1,7 @@
#include "gtkshaderstack.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
struct _GtkShaderStack
{
GtkWidget parent_instance;
@@ -359,3 +361,5 @@ gtk_shader_stack_set_active (GtkShaderStack *self,
self->current = MIN (index, self->children->len);
update_child_visible (self);
}
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -2,6 +2,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
G_BEGIN_DECLS
#define GTK_TYPE_SHADER_STACK (gtk_shader_stack_get_type ())
@@ -18,3 +20,5 @@ void gtk_shader_stack_set_active (GtkShaderStack *self,
int index);
G_END_DECLS
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -40,7 +40,7 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
{
wchar_t *langname_w = NULL;
wchar_t locale_abbrev_w[9];
gchar *langname, *locale_abbrev, *locale, *p;
gchar *langname, *locale_abbrev, *locale;
gint i;
const LCTYPE iso639_lctypes[] = { LOCALE_SISO639LANGNAME, LOCALE_SISO639LANGNAME2 };
GHashTable *ht_scripts_langs = (GHashTable *) param;
@@ -59,7 +59,6 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
GetLocaleInfoEx (locale_w, LOCALE_SLOCALIZEDDISPLAYNAME, langname_w, langname_size);
langname = g_utf16_to_utf8 (langname_w, -1, NULL, NULL, NULL);
locale = g_utf16_to_utf8 (locale_w, -1, NULL, NULL, NULL);
p = strchr (locale, '-');
lang = pango_language_from_string (locale);
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
g_hash_table_insert (ht_scripts_langs, lang, langname);

View File

@@ -20,6 +20,7 @@
#include "config.h"
#include <gtk/gtk.h>
#include <glib/gstdio.h>
#include <glib/gi18n.h>
#include "demos.h"
#include "fontify.h"
@@ -923,6 +924,34 @@ clear_search (GtkSearchBar *bar)
}
}
static void
search_results_update (GObject *filter_model,
GParamSpec *pspec,
GtkEntry *entry)
{
gsize n_items = g_list_model_get_n_items (G_LIST_MODEL (filter_model));
if (strlen (gtk_editable_get_text (GTK_EDITABLE (entry))) > 0)
{
char *text;
if (n_items > 0)
text = g_strdup_printf (ngettext ("%ld search result", "%ld search results", (long) n_items), (long) n_items);
else
text = g_strdup (_("No search results"));
gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
GTK_ACCESSIBLE_PROPERTY_DESCRIPTION, text,
-1);
g_free (text);
}
else
{
gtk_accessible_reset_property (GTK_ACCESSIBLE (entry), GTK_ACCESSIBLE_PROPERTY_DESCRIPTION);
}
}
static void
activate (GApplication *app)
{
@@ -970,6 +999,7 @@ activate (GApplication *app)
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
g_signal_connect (filter_model, "notify::n-items", G_CALLBACK (search_results_update), search_entry);
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -120,7 +120,7 @@ create_shadertoy_window (GtkWidget *do_widget)
gtk_box_append (GTK_BOX (box), aspect);
shadertoy = new_shadertoy ("/shadertoy/alienplanet.glsl");
gtk_aspect_frame_set_child (GTK_ASPECT_FRAME (aspect), shadertoy);
gtk_aspect_frame_set_child (GTK_ASPECT_FRAME (aspect), gtk_graphics_offload_new (shadertoy));
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 250);

View File

@@ -299,7 +299,7 @@ node_editor_application_new (void)
app = g_object_new (NODE_EDITOR_APPLICATION_TYPE,
"application-id", "org.gtk.gtk4.NodeEditor",
"flags", G_APPLICATION_HANDLES_OPEN,
"flags", G_APPLICATION_HANDLES_OPEN | G_APPLICATION_NON_UNIQUE,
NULL);
g_application_add_main_option (G_APPLICATION (app), "version", 0, 0,G_OPTION_ARG_NONE, "Show program version", NULL);

View File

@@ -3,7 +3,7 @@
<gresource prefix="/org/gtk/gtk4/node-editor">
<file preprocess="xml-stripblanks">node-editor-window.ui</file>
<file preprocess="xml-stripblanks">help-window.ui</file>
<file>node-format.md</file>
<file alias='node-format.md'>../../docs/reference/gtk/node-format.md</file>
<file alias='icons/apps/org.gtk.gtk4.NodeEditor.svg'>data/scalable/apps/org.gtk.gtk4.NodeEditor.svg</file>
</gresource>
</gresources>

View File

@@ -5,8 +5,11 @@ Title: Cairo interaction
[Cairo](http://cairographics.org) is a graphics library that supports vector
graphics and image compositing that can be used with GTK.
GDK does not wrap the Cairo API; instead it allows to create Cairo
drawing contexts which can be used to draw on [class@Gdk.Surface]s.
GDK does not wrap the Cairo API and it is not possible to use cairo directly
to draw on a [class@Gdk.Surface]. You can either use a
[GtkDrawingArea](../gtk4/class.DrawingArea.html) widget or
[gtk_snapshot_append_cairo](../gtk4/func.Snapshot.append_cairo.html)
for drawing with cairo in a GTK4 application.
Additional functions allow use [struct@Gdk.Rectangle]s with Cairo
and to use [struct@Gdk.RGBA], `GdkPixbuf`, and [class@Gdk.Surface]

View File

@@ -111,3 +111,11 @@ content_images = [
]
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gdk/"
urlmap_file = "urlmap.js"
[[object]]
name = "DECLARE_INTERNAL_TYPE"
hidden = true
[[object]]
pattern = "KEY_*"
check_ignore = true

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -29,6 +29,18 @@ if get_option('documentation')
install_dir: docs_dir,
)
test('doc-check-gdk',
gidocgen,
args: [
'check',
'--config', gdk4_toml,
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
gdk_gir[0],
],
depends: gdk_gir[0],
suite: ['docs'],
)
if x11_enabled
gdk4x11_toml = configure_file(
input: 'gdk4-x11.toml.in',
@@ -87,5 +99,17 @@ if get_option('documentation')
install: true,
install_dir: docs_dir,
)
test('doc-check-gdk-wayland',
gidocgen,
args: [
'check',
'--config', gdk4wayland_toml,
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
gdk_wayland_gir[0],
],
depends: gdk_wayland_gir[0],
suite: ['docs'],
)
endif
endif

View File

@@ -66,3 +66,7 @@ content_images = [
]
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gsk/"
urlmap_file = "urlmap.js"
[[object]]
name = "INCLUDE_WARNING"
hidden = true

View File

@@ -30,4 +30,16 @@ if get_option('documentation')
install: true,
install_dir: docs_dir,
)
test('doc-check-gsk',
gidocgen,
args: [
'check',
'--config', gsk4_toml,
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
gsk_gir[0],
],
depends: gsk_gir[0],
suite: ['docs'],
)
endif

View File

@@ -140,7 +140,7 @@ Other libraries are maintained separately.
file formats. It is available [here](ttps://download.gnome.org/sources/gdk-pixbuf/).
- [Pango](http://www.pango.org) is a library for internationalized
text handling. It is available [here](https://download.gnome.org/sources/pango/).
- [GObject Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection)
- [GObject Introspection](https://gitlab.gnome.org/GNOME/gobject-introspection)
is a framework for making introspection data available to language
bindings. It is available [here](https://download.gnome.org/sources/gobject-introspection/).
- The [GNU libiconv](https://www.gnu.org/software/libiconv/) library

View File

@@ -74,6 +74,7 @@ in a selector, widget names must be prefixed with a &num; character.
| E:not(selector) | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#negation) | |
| E:dir(ltr), E:dir(rtl) | [CSS Selector Level 4](https://drafts.csswg.org/selectors/#the-dir-pseudo) | |
| E:drop(active) | [CSS Selector Level 4](https://drafts.csswg.org/selectors/#drag-pseudos) | |
| E:root | [CSS Selector Level 3](https://www.w3.org/TR/selectors-3/#root-pseudo) | |
| E F | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#descendent-combinators) | |
| E > F | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#child-combinators) | |
| E ~ F | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#general-sibling-combinators) | |

View File

@@ -15,16 +15,16 @@ spec.
The following units are supported for basic datatypes:
Length
: px, pt, em, ex, rem, pc, in, cm, mm, calc()
: px, pt, em, ex, rem, pc, in, cm, mm
Percentage
: %, calc()
: %
Angle
: deg, grad, turn, calc()
: deg, rad, grad, turn
Time
: s, ms, calc()
: s, ms
Length values with the em or ex units are resolved using the font
size value, unless they occur in setting the font-size itself, in
@@ -33,11 +33,15 @@ which case they are resolved using the inherited font size value.
The rem unit is resolved using the initial font size value, which is
not quite the same as the CSS definition of rem.
The calc() notation adds considerable expressive power. There are limits
on what types can be combined in such an expression (e.g. it does not make
sense to add a number and a time). For the full details, see the
[CSS3 Values and Units](https://www.w3.org/TR/css3-values/#calc-notation)
spec.
Length values using physical units (pt, pc, in, cm, mm) are translated
to px using the dpi value specified by the -gtk-dpi property, which is
different from the CSS definition, which uses a fixed dpi of 96.
The calc() notation adds considerable expressive power to all of these
datatypes. There are limits on what types can be combined in such an
expression (e.g. it does not make sense to add a number and a time).
For the full details, see the
[CSS Values and Units](https://www.w3.org/TR/css-values-4/) spec.
A common pattern among shorthand properties (called 'four sides') is one
where one to four values can be specified, to determine a value for each
@@ -56,38 +60,80 @@ follows:
1 value:
: all
## Custom Properties
GTK supports custom properties as defined in the
[CSS Custom Properties for Cascading Variables](https://www.w3.org/TR/css-variables-1)
spec.
Custom properties are defined as follows:
```css
--prop: red;
```
and used via the `var` keyword:
```css
color: var(--prop);
```
Custom properties can have a fallback for when the referred property is invalid:
```css
color: var(--prop, green);
```
## Colors
GTK extends the CSS syntax with several additional ways to specify colors.
### CSS Colors
Colors can be expressed in numerous ways in CSS (see the
[Color Module](https://www.w3.org/TR/css-color-5/). GTK supports
many (but not all) of these.
You can use rgb(), rgba(), hsl() with both the legacy or the modern CSS
syntax, and calc() can be used as well in color expressions. hwb(), oklab(),
oklch(), color(), color-mix() and relative colors are supported as well.
### Non-CSS Colors
GTK extends the CSS syntax with several additional ways to specify colors.
These extensions are deprecated and should be replaced by the equivalent
standard CSS notions.
The first is a reference to a color defined via a @define-color rule in CSS.
The syntax for @define-color rules is as follows:
```
@define-color Name Color
@define-color name color
```
To refer to the color defined by a @define-color rule, prefix the name with @.
The standard CSS mechanisms that should be used instead of @define-color are
custom properties, :root and var().
GTK also supports color expressions, which allow colors to be transformed to
new ones. Color expressions can be nested, providing a rich language to
define colors. Color expressions resemble functions, taking 1 or more colors
and in some cases a number as arguments.
`lighter(Color)`
: produces a brighter variant of Color
`lighter(color)`
: produces a brighter variant of `color`.
`darker(Color)`
: produces a darker variant of Color
`darker(color)`
: produces a darker variant of `color`.
`shade(Color, Number)`
: changes the lightness of Color. The number ranges from 0 for black to 2 for white.
`shade(color, number)`
: changes the lightness of `color`. The `number` ranges from 0 for black to 2 for white.
`alpha(Color, Number)`
: replaces the alpha value of color with number (between 0 and 1)
`alpha(color, number)`
: multiplies the alpha value of `color` by `number` (between 0 and 1).
`mix(Color1, Color2, Number)`
: interpolates between the two colors
`mix(color1, color2, number)`
: interpolates between the two colors.
## Images
@@ -95,7 +141,7 @@ GTK extends the CSS syntax for images and also uses it for specifying icons.
To load a themed icon, use
```
-gtk-icontheme(Name)
-gtk-icontheme(name)
```
The specified icon name is used to look up a themed icon, while taking into
@@ -124,14 +170,14 @@ and the
syntax makes this available. -gtk-recolor requires a url as first argument.
The remaining arguments specify the color palette to use. If the palette is
not explicitly specified, the current value of the -gtk-icon-palette property
is used.
is used.
GTK supports scaled rendering on hi-resolution displays. This works best if
images can specify normal and hi-resolution variants. From CSS, this can be
done with
```
-gtk-scaled(Image1, Image2)
-gtk-scaled(image1, image2)
```
## GTK CSS Properties

View File

@@ -99,16 +99,15 @@ reaches the requested phase. However, in practice most things
happen at higher levels:
- If you are doing an animation, you can use
gtk_widget_add_tick_callback() which will cause a regular
[method@Gtk.Widget.add_tick_callback] which will cause a regular
beating of the clock with a callback in the Update phase
until you stop the tick.
- If some state changes that causes the size of your widget to
change you call gtk_widget_queue_resize() which will request
change you call [method@Gtk.Widget.queue_resize] which will request
a Layout phase and mark your widget as needing relayout.
- If some state changes so you need to redraw some area of
your widget you use the normal gtk_widget_queue_draw()
set of functions. These will request a Paint phase and
mark the region as needing redraw.
- If some state changes so you need to redraw your widget you
use [method@Gtk.Widget.queue_draw] to request a Paint phase for
your widget.
There are also a lot of implicit triggers of these from the
CSS layer (which does animations, resizes and repaints as needed).

View File

@@ -245,9 +245,6 @@ to connect the "clicked" signal with [method@Gtk.Window.destroy], then the funct
would be called on `button` (which would not go well, since the function expects
a `GtkWindow` as argument).
More information about creating buttons can be found
[here](https://wiki.gnome.org/HowDoI/Buttons).
The rest of the code in `example-1.c` is identical to `example-0.c`. The next
section will elaborate further on how to add several [class@Gtk.Widget]s to your
GTK application.

View File

@@ -8,6 +8,10 @@ gtk4-broadwayd
The Broadway display server
---------------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------
| **gtk4-broadwayd** [OPTIONS...] <DISPLAY>

View File

@@ -8,6 +8,10 @@ gtk4-builder-tool
GtkBuilder File Utility
-----------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------
| **gtk4-builder-tool** <COMMAND> [OPTIONS...] <FILE>

View File

@@ -8,6 +8,9 @@ gtk4-demo-application
Demonstrate GtkApplication
--------------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-demo
Demonstrate GTK widgets
-----------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-encode-symbolic-svg
Symbolic icon conversion utility
--------------------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-icon-browser
List themed icons
-----------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -0,0 +1,97 @@
.. _gtk4-image-tool(1):
====================
gtk4-image-tool
====================
-----------------------
Image Utility
-----------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------
| **gtk4-image-tool** <COMMAND> [OPTIONS...] <FILE>...
|
| **gtk4-image-tool** compare [OPTIONS...] <FILE1> <FILE2>
| **gtk4-image-tool** convert [OPTIONS...] <FILE1> <FILE2>
| **gtk4-image-tool** info [OPTIONS...] <FILE>
| **gtk4-image-tool** relabel [OPTIONS...] <FILE1> <FILE2>
| **gtk4-image-tool** show [OPTIONS...] <FILE>...
DESCRIPTION
-----------
``gtk4-image-tool`` can perform various operations on images.
COMMANDS
--------
Information
^^^^^^^^^^^
The ``info`` command shows general information about the image, such
as its format and color state.
Showing
^^^^^^^
The ``show`` command displays one or more images, side-by-side.
``--undecorated``
Removes window decorations. This is meant for rendering of exactly the image
without any titlebar.
Compare
^^^^^^^
The ``compare`` command compares two images. If any differences are found,
the exit code is 1. If the images are identical, it is 0.
``--output=FILE``
Save the differences as a png image in ``FILE``.
``--quiet``
Don't write results to stdout.
Conversion
^^^^^^^^^^
The ``convert`` command converts the image to a different format or color state.
``--format=FORMAT``
Convert to the given format. The supported formats can be listed
with ``--format=list``.
``--color-state=COLORSTATE``
Convert to the given color state. The supported color states can be
listed with ``--format=list``.
``--cicp=CICP``
Convert to a color state that is specified as a cicp tuple. The cicp tuple
must be specified as four numbers, separated by /, e.g. 1/13/6/0.
Relabeling
^^^^^^^^^^
The ``relabel`` command changes the color state of an image without conversion.
This can be useful to produce wrong color renderings for diagnostics.
``--color-state=COLORSTATE``
Relabel to the given color state. The supported color states can be
listed with ``--format=list``.
``--cicp=CICP``
Relabel to a color state that is specified as a cicp tuple. The cicp tuple
must be specified as four numbers, separated by /, e.g. 1/13/6/0.

View File

@@ -8,6 +8,10 @@ gtk4-launch
Launch an application
---------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-node-editor
Editor render nodes
-----------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-path-tool
GskPath Utility
-----------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------
| **gtk4-path-tool** <COMMAND> [OPTIONS...] <PATH>

View File

@@ -8,6 +8,10 @@ gtk4-query-settings
Print name and value of GTK settings
------------------------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,12 +8,17 @@ gtk4-rendernode-tool
GskRenderNode Utility
-----------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------
| **gtk4-rendernode-tool** <COMMAND> [OPTIONS...] <FILE>
|
| **gtk4-rendernode-tool** benchmark [OPTIONS...] <FILE>
| **gtk4-rendernode-tool** compare [OPTIONS...] <FILE1> <FILE2>
| **gtk4-rendernode-tool** extract [OPTIONS...] <FILE>
| **gtk4-rendernode-tool** info [OPTIONS...] <FILE>
| **gtk4-rendernode-tool** render [OPTIONS...] <FILE> [<FILE>]
| **gtk4-rendernode-tool** show [OPTIONS...] <FILE>
@@ -45,13 +50,14 @@ without any titlebar.
Rendering
^^^^^^^^^
The ``render`` command saves a rendering of the rendernode as a png or tiff image.
The name of the file to write can be specified as a second FILE argument.
The ``render`` command saves a rendering of the rendernode as a png, tiff or svg
image or as pdf document. The name of the file to write can be specified as a second
FILE argument.
``--renderer=RENDERER``
Use the given renderer. Use ``--renderer=help`` to get a information
about poassible values for the ``RENDERER``.
about possible values for the ``RENDERER``.
Benchmark
^^^^^^^^^
@@ -93,4 +99,16 @@ exit code is 1. If the images are identical, it is 0.
``--quiet``
Don't write results to stdout.`
Don't write results to stdout.
Extract
^^^^^^^
The ``extract`` command saves all the data urls found in a node file to a given
directory. The file names for the extracted files are derived from the mimetype
of the url.
``--dir=DIRECTORY``
Save extracted files in ``DIRECTORY`` (defaults to the current directory).

View File

@@ -8,6 +8,10 @@ gtk4-update-icon-cache
Icon theme caching utility
--------------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-widget-factory
Showcase GTK widgets and styles
-------------------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -77,12 +77,15 @@ content_files = [
"section-tree-widget.md",
"migrating-2to4.md",
"migrating-3to4.md",
"migrating-4to5.md",
"broadway.md",
"osx.md",
"wayland.md",
"windows.md",
"x11.md",
"tools.md",
"visual_index.md",
"node-format.md",
]
content_images = [
"../images/favicon.svg",
@@ -249,3 +252,12 @@ content_images = [
]
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gtk/"
urlmap_file = "urlmap.js"
[[object]]
name = "StyleProvider"
[[object.signal]]
name = "gtk-private-changed"
hidden = true
[check]
skip_deprecated = true

View File

@@ -140,6 +140,11 @@ capture phase, and key bindings locally, during the target phase.
Under the hood, all shortcuts are represented as instances of `GtkShortcut`,
and they are managed by `GtkShortcutController`.
Note that GTK does not do anything to map the primary shortcut modifier
to <kbd>Command</kbd> on macOS. If you want to let your application to follow
macOS user experience conventions, you must create macOS-specific keyboard shortcuts.
The <kbd>Command</kbd> is named `Meta` (`GDK_META_MASK`) in GTK.
## Text input
When actual text input is needed (i.e. not just keyboard shortcuts),

View File

@@ -14,6 +14,7 @@ expand_content_md_files = [
'running.md',
'migrating-2to4.md',
'migrating-3to4.md',
'migrating-4to5.md',
'actions.md',
'input-handling.md',
'drawing-model.md',
@@ -25,7 +26,8 @@ expand_content_md_files = [
'section-tree-widget.md',
'section-list-widget.md',
'question_index.md',
'visual_index.md'
'visual_index.md',
'tools.md',
]
gtk_images = []
@@ -60,39 +62,52 @@ if get_option('documentation')
build_by_default: true,
install: true,
install_dir: docs_dir,
install_tag: 'doc',
)
test('doc-check-gtk',
gidocgen,
args: [
'check',
'--config', gtk4_toml,
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
gtk_gir[0],
],
depends: gtk_gir[0],
suite: ['docs'],
)
endif
rst2man = find_program('rst2man', 'rst2man.py', required: false)
if get_option('man-pages') and not rst2man.found()
error('No rst2man found, but man pages were explicitly enabled')
rst2man = find_program('rst2man', 'rst2man.py', required: get_option('man-pages'))
rst2html5 = find_program('rst2html5', 'rst2html5.py', required: get_option('documentation'))
rst_files = [
[ 'gtk4-broadwayd', '1' ],
[ 'gtk4-builder-tool', '1' ],
[ 'gtk4-encode-symbolic-svg', '1', ],
[ 'gtk4-image-tool', '1' ],
[ 'gtk4-launch', '1', ],
[ 'gtk4-query-settings', '1', ],
[ 'gtk4-rendernode-tool', '1' ],
[ 'gtk4-update-icon-cache', '1', ],
[ 'gtk4-path-tool', '1', ],
]
if get_option('build-demos')
rst_files += [
[ 'gtk4-demo', '1', ],
[ 'gtk4-demo-application', '1', ],
[ 'gtk4-widget-factory', '1', ],
[ 'gtk4-icon-browser', '1', ],
[ 'gtk4-node-editor', '1', ],
]
endif
if get_option('man-pages') and rst2man.found()
rst_files = [
[ 'gtk4-broadwayd', '1' ],
[ 'gtk4-builder-tool', '1' ],
[ 'gtk4-encode-symbolic-svg', '1', ],
[ 'gtk4-launch', '1', ],
[ 'gtk4-query-settings', '1', ],
[ 'gtk4-rendernode-tool', '1' ],
[ 'gtk4-update-icon-cache', '1', ],
[ 'gtk4-path-tool', '1', ],
]
rst2x_flags = [
'--syntax-highlight=none',
]
if get_option('demos')
rst_files += [
[ 'gtk4-demo', '1', ],
[ 'gtk4-demo-application', '1', ],
[ 'gtk4-widget-factory', '1', ],
[ 'gtk4-icon-browser', '1', ],
[ 'gtk4-node-editor', '1', ],
]
endif
rst2man_flags = [
'--syntax-highlight=none',
]
if get_option('man-pages')
foreach rst: rst_files
man_name = rst[0]
@@ -103,12 +118,34 @@ if get_option('man-pages') and rst2man.found()
output: '@0@.@1@'.format(man_name, man_section),
command: [
rst2man,
rst2man_flags,
rst2x_flags,
'@INPUT@',
],
capture: true,
install: true,
install_dir: get_option('mandir') / 'man@0@'.format(man_section),
install_tag: 'doc',
)
endforeach
endif
if get_option('documentation')
foreach rst: rst_files
man_name = rst[0]
custom_target(
input: '@0@.rst'.format(man_name),
output: '@0@.html'.format(man_name),
command: [
rst2html5,
rst2x_flags,
'@INPUT@',
],
capture: true,
install: true,
install_dir: docs_dir / 'gtk4',
install_tag: 'doc',
)
endforeach
endif

View File

@@ -451,11 +451,11 @@ hint about how modifiers are expected to be used. It also promoted
the use of `<Primary>` instead of `<Control>` to specify accelerators that
adapt to platform conventions.
In GTK 4, the meaning of modifiers has been fixed, and backends are
In GTK 4, the meaning of modifiers has been fixed, and applications are
expected to map the platform conventions to the existing modifiers.
The expected use of modifiers in GTK 4 is:
`GDK_CONTROL_MASK`
`GDK_CONTROL_MASK` (`GDK_META_MASK` on macOS)
: Primary accelerators
`GDK_ALT_MASK`
@@ -464,7 +464,7 @@ The expected use of modifiers in GTK 4 is:
`GDK_SHIFT_MASK`
: Extending selections
`GDK_CONTROL_MASK`
`GDK_CONTROL_MASK` (`GDK_META_MASK` on macOS)
: Modifying selections
`GDK_CONTROL_MASK|GDK_ALT_MASK`
@@ -473,9 +473,15 @@ The expected use of modifiers in GTK 4 is:
Consequently, `GdkModifierIntent` and related APIs have been removed,
and `<Control>` is preferred over `<Primary>` in accelerators.
In GTK 3 on macOS, the `<Primary>` modifier mapped to the <kbd>Command</kbd> key.
In GTK 4, this is no longer the case: `<Primary>` is synonymous to `<Control>`.
If you want to make your application to feel native on macOS,
you need to add accelerators for macOS that use the `<Meta>` modifier.
A related change is that GTK 4 no longer supports the use of archaic
X11 'real' modifiers with the names Mod1,..., Mod5, and `GDK_MOD1_MASK`
has been renamed to `GDK_ALT_MASK`.
has been renamed to `GDK_ALT_MASK` and `GDK_MOD2_MASK` has been renamed to
`GDK_META_MASK`.
### Replace `GtkClipboard` with `GdkClipboard`

View File

@@ -58,7 +58,7 @@ use a GtkLabel.
If you have a need for custom drawing that fits into the current
(dark or light) theme, e.g. for rendering a graph, you can still
get the current style foreground color, using
[method@Gtk.Widget.get_style_color].
[method@Gtk.Widget.get_color].
## Local stylesheets are going away
@@ -73,6 +73,103 @@ GTK 5 will no longer provide this functionality. The recommendations
is to use a global stylesheet (i.e. gtk_style_context_add_provider_for_display())
and rely on style classes to make your CSS apply only where desired.
## Non-standard CSS extensions are going away
GTK's CSS machinery has a some non-standard extensions around colors:
named colors with \@define-color and color functions: lighter(), darker(),
shade(), alpha(), mix().
GTK now implements equivalent functionality from the CSS specs.
### \@define-color is going away
\@define-color should be replaced by custom properties in the :root scope.
Instead of
```
@define-color fg_color #2e3436
...
box {
color: @fg_color;
}
```
use
```
:root {
--fg-color: #2e3436;
}
...
box {
color: var(--fg-color);
}
```
For more information about custom CSS properties and variables, see the
[CSS Custom Properties for Cascading Variables](https://www.w3.org/TR/css-variables-1/)
spec.
### Color expressions are going away
The color functions can all be replaced by combinations of calc() and color-mix().
ligher(c) and darker(c) are just shade(c, 1.3) or shade(c, 0.7), respectively, and
thus can be handled the same way as shade in the examples below.
Replace
```
a {
color: mix(red, green, 0.8);
}
b {
color: alpha(green, 0.6);
}
c {
color: shade(red, 1.3);
}
d {
color: shade(red, 0.7);
}
```
with
```
a {
color: color-mix(in srgb, red, green 80%);
}
b {
color: rgb(from green, r g b / calc(alpha * 0.6));
}
c {
color: hsl(from red, h calc(s * 1.3) calc(l * 1.3));
}
d {
color: hsl(from red, h calc(s * 0.7) calc(l * 0.7));
}
```
Variations of these replacements are possible.
Note that GTK has historically computed mix() and shade() values in the SRGB and HSL
colorspaces, but using OKLAB instead might yield slightly better results.
For more information about color-mix(), see the
[CSS Color](https://drafts.csswg.org/css-color-5) spec.
## Chooser interfaces are going away
The GtkColorChooser, GtkFontChooser, GtkFileChooser and GtkAppChooser

View File

@@ -1,13 +1,15 @@
# The Node file format
Title: The Node file format
GSK render nodes can be serialized and deserialized using APIs such as `gsk_render_node_serialize()` and `gsk_render_node_deserialize()`. The intended use for this is development - primarily the development of GTK - by allowing things such as creating testsuites and benchmarks, exchanging nodes in bug reports. GTK includes the `gtk4-node-editor` application for creating such test files.
The format is a text format that follows the [CSS syntax rules](https://drafts.csswg.org/css-syntax-3/). In particular, this means that every array of bytes will produce a render node when parsed, as there is a defined error recovery method. For more details on error handling, please refer to the documentation of the parsing APIs.
The grammar of a node text representation using [the CSS value definition syntax](https://drafts.csswg.org/css-values-3/#value-defs) looks like this:
**document**: `<node>\*`
**node**: container [ "name" ] { <document> } | `<node-type> [ "name" ] { <property>* }` | "name"
**property**: `<property-name>: <node> | <value> ;`
document: <@-rule>*<node>*
@-rule: @cicp "name" { <property>* }
node: container [ "name" ] { <document> } | <node-type> [ "name" ] { <property>* } | "name"
property: <property-name>: <node> | <value> ;
Each node has its own `<node-type>` and supports a custom set of properties, each with their own `<property-name>` and syntax. The following paragraphs document each of the nodes and their properties.
@@ -25,6 +27,45 @@ Nodes can be given a name by adding a string after the `<node-type>` in their de
Just like nodes, textures can be referenced by name. When defining a named texture, the name has to be placed in front of the URL.
# Color states
Color states are represented either by an ident (for builtin ones) or a string
(for custom ones):
color-state: <ident> | <string>
Custom color states can be defined at the beginning of the document, with an @cicp rule.
The format for @cicp rules is
@cicp "name" {
...
}
The following properties can be set for custom color states:
| property | syntax | default | printed |
| --------- | ---------------- | -------- | ----------- |
| primaries | `<integer>` | 2 | always |
| transfer | `<integer>` | 2 | always |
| matrix | `<integer>` | 2 | always |
| range | `narrow | full` | full | non-default |
Note that the primaries, transfer and matrix properties always need
to be specified, since GTK does not allow creating color state objects
with these being set to 2 (== unspecified).
# Colors
Colors can be specified with a variation of the modern CSS color syntax:
color(<color-state> <number> <number> <number> ["/" <number>])
The traditional syntax for sRGB colors still works as well:
rgba(<number>, <number>, <number>, <number)
rgb(<number, <number>, <number>)
# Nodes
### container
@@ -330,6 +371,7 @@ stroke bounds of the path.
| offset | `<point>` | 0 0 | non-default |
| hint-style | `<hint style>` | slight | non-default |
| antialias | `<antialias>` | gray | non-default |
| hint-metrics | `<hint metrics>` | off | non-default |
Creates a node like `gsk_text_node_new()` with the given properties.
@@ -346,6 +388,7 @@ font, an error node will be returned.
Possible values for hint-style are none, slight or full.
Possible value for antialias are none or gray.
Possible value for hint-metrics are on or off.
### texture

View File

@@ -7,5 +7,5 @@ on top of the Quartz API.
Currently, the macOS port does not use any additional commandline options
or environment variables.
For up-to-date information about the current status of this port, see the
[project page](https://wiki.gnome.org/Projects/GTK/OSX).
For up-to-date information on building, installation, and bundling, see the
[GTK website](https://www.gtk.org/docs/installations/macos).

View File

@@ -58,12 +58,12 @@ GTK is divided into three parts:
storage types for efficient use in GUI applications, and much more.
[gnu-lgpl]: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
[glib]: https://developer.gnome.org/glib/stable/
[gobject]: https://developer.gnome.org/gobject/stable/
[gio]: https://developer.gnome.org/gio/stable/
[glib]: https://docs.gtk.org/glib/
[gobject]: https://docs.gtk.org/gobject/
[gio]: https://docs.gtk.org/gio/
[cairo]: https://www.cairographics.org/manual/
[opengl]: https://www.opengl.org/about/
[vulkan]: https://www.vulkan.org/
[pango]: https://pango.gnome.org/
[gdkpixbuf]: https://developer.gnome.org/gdk-pixbuf/stable/
[pango]: https://docs.gtk.org/Pango/
[gdkpixbuf]: https://docs.gtk.org/gdk-pixbuf/
[graphene]: https://ebassi.github.io/graphene/

View File

@@ -27,7 +27,7 @@ the question you have, this list is a good place to start.
Every major version of GTK comes with a [migration guide](#migrating). You may also
find useful information in the documentation for specific widgets and functions. If
you have a question not covered in the manual, feel free to ask, and please
[file a bug report](https://gitlab.gnome.org/GNOME/gtk/issues/new) against the
[file a bug report](https://gitlab.gnome.org/GNOME/gtk/issues/) against the
documentation.
* Should I maintain parallel versions of my UI in GTK x and GTK y?
@@ -54,7 +54,7 @@ the question you have, this list is a good place to start.
For strings returned from functions, they will be declared "const" if they should
not be freed. Non-const strings should be freed with `g_free()`. Arrays follow the
same rule. If you find an undocumented exception to the rules, please
[file a bug report.](https://gitlab.gnome.org/GNOME/gtk/issues/new).
[file a bug report.](https://gitlab.gnome.org/GNOME/gtk/issues/).
The transfer annotations for gobject-introspection that are part of the
documentation can provide useful hints for memory handling semantics as well.

View File

@@ -4,7 +4,7 @@ Slug: gtk-resources
## Opening a bug or feature request
If you encounter a bug, misfeature, or missing feature in GTK, please
file a bug report on our [GitLab project](https://gitlab.gnome.org/GNOME/gtk/issues/new).
file a bug report on our [GitLab project](https://gitlab.gnome.org/GNOME/gtk/issues/).
You should also file issues if the documentation is out of date with the
existing API, or unclear.

View File

@@ -5,10 +5,12 @@ Slug: gtk-running
GTK inspects a number of environment variables in addition to
standard variables like `LANG`, `PATH`, `HOME` or `DISPLAY`; mostly
to determine paths to look for certain files. The [X11](#x11-envar),
[Wayland](#wayland-envar), [Windows](#win32-envar) and
[Broadway](#broadway-envar) GDK backends use some additional
environment variables.
to determine paths to look for certain files. The
[X11](https://docs.gtk.org/gtk4/x11.html#x11-specific-environment-variables),
[Wayland](https://docs.gtk.org/gtk4/wayland.html#wayland-specific-environment-variables),
[Windows](https://docs.gtk.org/gtk4/windows.html#windows-specific-environment-variables) and
[Broadway](https://docs.gtk.org/gtk4/broadway.html#broadway-specific-environment-variables)
GDK backends use some additional environment variables.
Note that environment variables are generally used for debugging
purposes. They are not guaranteed to be API stable, and should not
@@ -217,6 +219,10 @@ A number of options affect behavior instead of logging:
`no-portals`
: Disable use of [portals](https://docs.flatpak.org/en/latest/portals.html)
`force-offload`
: Force graphics offload for all textures, even when slower. This allows
to debug offloading in the absence of dmabufs.
`gl-disable`
: Disable OpenGL support
@@ -286,8 +292,8 @@ are only available when GTK has been configured with `-Ddebug=true`.
`fallback`
: Information about fallback usage in renderers
`glyphcache`
: Information about glyph caching
`cache`
: Information about caching
`verbose`
: Print verbose output while rendering

View File

@@ -155,6 +155,7 @@ Each property name is part of the `GtkAccessibleProperty` enumeration.
| %GTK_ACCESSIBLE_PROPERTY_VALUE_MIN | “aria-valuemin” | double |
| %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW | “aria-valuenow” | double |
| %GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT | “aria-valuetext” | translatable string |
| %GTK_ACCESSIBLE_PROPERTY_HELP_TEXT | N/A | translatable string |
#### List of accessible relations
@@ -216,6 +217,10 @@ are accessible as part of the development process. The GTK Inspector shows
the accessible attributes of each widget, and also provides an overlay that
can highlight accessibility issues.
If you support some non-standard keyboard interactions for a widget, you
**should** set an appropriate `GTK_ACCESSIBLE_PROPERTY_HELP_TEXT` to help
discoverability of the behavior.
It is possible to set accessible attributes in UI files as well:
```xml
<object class="GtkButton" id="button1">

View File

@@ -0,0 +1,18 @@
Title: Tools and Demos
GTK ships with a number of tools and demos that come with their own
documentation in the form of man pages.
- [gtk4-broadwayd](gtk4-broadwayd.html)
- [gtk4-builder-tool](gtk4-builder-tool.html)
- [gtk4-demo](gtk4-demo.html)
- [gtk4-demo-application](gtk4-demo-application.html)
- [gtk4-encode-symbolic-svg](gtk4-encode-symbolic-svg.html)
- [gtk4-icon-browser](gtk4-icon-browser.html)
- [gtk4-launch](gtk4-launch.html)
- [gtk4-node-editor](gtk4-node-editor.html)
- [gtk4-path-tool](gtk4-path-tool.html)
- [gtk4-query-settings](gtk4-query-settings.html)
- [gtk4-rendernode-tool](gtk4-rendernode-tool.html)
- [gtk4-update-icon-cache](gtk4-update-icon-cache.html)
- [gtk4-widget-factory](gtk4-widget-factory.html)

View File

@@ -43,7 +43,7 @@ X11 details, in particular the ICCCM and the Extended Window Manager
Hints specifications. [freedesktop.org](http://www.freedesktop.org/standards/)
has links to many relevant specifications.
The GDK manual covers [using Xlib in a GTK program](#gdk-X-Window-System-Interaction).
The GDK manual covers [using Xlib in a GTK program](https://docs.gtk.org/gdk4/x11.html).
### Server, client, window manager

View File

@@ -91,6 +91,31 @@ const GDK_META_MASK = 1 << 28;
var useDataUrls = window.location.search.includes("datauri");
/* check if we are on Android and using Chrome */
var isAndroidChrome = false;
{
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("android") > -1 && ua.indexOf("chrom") > -1) {
isAndroidChrome = true;
}
}
/* check for the passive option for Event listener */
let passiveSupported = false;
try {
const options = {
get passive() { // This function will be called when the browser
// attempts to access the passive property.
passiveSupported = true;
return false;
}
};
window.addEventListener("test", null, options);
window.removeEventListener("test", null, options);
} catch(err) {
passiveSupported = false;
}
/* This base64code is based on https://github.com/beatgammit/base64-js/blob/master/index.js which is MIT licensed */
var b64_lookup = [];
@@ -215,11 +240,32 @@ function logStackTrace(len) {
log(callstack[i]);
}
/* Helper functions for touch identifier to make it unique on Android */
var globalTouchIdentifier = Math.round(Date.now() / 1000);
function touchIdentifierStart(tId)
{
if (isAndroidChrome) {
if (tId == 0) {
return ++globalTouchIdentifier;
}
return globalTouchIdentifier + tId;
}
return tId;
}
function touchIdentifier(tId)
{
if (isAndroidChrome) {
return globalTouchIdentifier + tId;
}
return tId;
}
var grab = new Object();
grab.surface = null;
grab.ownerEvents = false;
grab.implicit = false;
var keyDownList = [];
var inputList = [];
var lastSerial = 0;
var lastX = 0;
var lastY = 0;
@@ -987,7 +1033,14 @@ function handleDisplayCommands(display_commands)
break;
case DISPLAY_OP_DELETE_SURFACE:
var id = cmd[1];
delete surfaces[id];
if (id == surfaceWithMouse) {
surfaceWithMouse = 0;
}
if (id == realSurfaceWithMouse) {
realSurfaceWithMouse = 0;
firstTouchDownId = null;
}
delete surfaces[id];
break;
case DISPLAY_OP_CHANGE_TEXTURE:
var image = cmd[1];
@@ -1371,8 +1424,14 @@ function getEffectiveEventTarget (id) {
function updateKeyboardStatus() {
if (fakeInput != null && showKeyboardChanged) {
showKeyboardChanged = false;
if (showKeyboard)
if (showKeyboard) {
if (isAndroidChrome) {
fakeInput.blur();
fakeInput.value = ' '.repeat(80); // TODO: Should be exchange with broadway server
// to bring real value here.
}
fakeInput.focus();
}
else
fakeInput.blur();
}
@@ -2924,6 +2983,19 @@ function pushKeyEvent(fev) {
keyDownList.push(fev);
}
function copyInputEvent(ev) {
var members = ['inputType', 'data'], i, obj = {};
for (i = 0; i < members.length; i++) {
if (typeof ev[members[i]] !== "undefined")
obj[members[i]] = ev[members[i]];
}
return obj;
}
function pushInputEvent(fev) {
inputList.push(fev);
}
function getKeyEvent(keyCode, pop) {
var i, fev = null;
for (i = keyDownList.length-1; i >= 0; i--) {
@@ -3022,6 +3094,29 @@ function handleKeyUp(e) {
keysym = fev.keysym;
else {
//log("Key event (keyCode = " + ev.keyCode + ") not found on keyDownList");
if (isAndroidChrome && (ev.keyCode == 229)) {
var i, fev = null, len = inputList.length, str;
for (i = 0; i < len; i++) {
fev = inputList[i];
switch(fev.inputType) {
case "deleteContentBackward":
sendInput(BROADWAY_EVENT_KEY_PRESS, [65288, lastState]);
sendInput(BROADWAY_EVENT_KEY_RELEASE, [65288, lastState]);
break;
case "insertText":
if (fev.data !== undefined) {
for (let sym of fev.data) {
sendInput(BROADWAY_EVENT_KEY_PRESS, [sym.codePointAt(0), lastState]);
sendInput(BROADWAY_EVENT_KEY_RELEASE, [sym.codePointAt(0), lastState]);
}
}
break;
default:
break;
}
}
inputList.splice(0, len);
}
keysym = 0;
}
@@ -3030,6 +3125,16 @@ function handleKeyUp(e) {
return cancelEvent(ev);
}
function handleInput (e) {
var fev = null, ev = (e ? e : window.event), keysym = null, suppress = false;
fev = copyInputEvent(ev);
pushInputEvent(fev);
// Stop keypress events just in case
return cancelEvent(ev);
}
function onKeyDown (ev) {
updateForEvent(ev);
return handleKeyDown(ev);
@@ -3045,6 +3150,11 @@ function onKeyUp (ev) {
return handleKeyUp(ev);
}
function onInput (ev) {
updateForEvent(ev);
return handleInput(ev);
}
function cancelEvent(ev)
{
ev = ev ? ev : window.event;
@@ -3076,13 +3186,14 @@ function onMouseWheel(ev)
}
function onTouchStart(ev) {
event.preventDefault();
ev.preventDefault();
updateKeyboardStatus();
updateForEvent(ev);
for (var i = 0; i < ev.changedTouches.length; i++) {
var touch = ev.changedTouches.item(i);
var touchId = touchIdentifierStart(touch.identifier);
var origId = getSurfaceId(touch);
var id = getEffectiveEventTarget (origId);
@@ -3090,7 +3201,7 @@ function onTouchStart(ev) {
var isEmulated = 0;
if (firstTouchDownId == null) {
firstTouchDownId = touch.identifier;
firstTouchDownId = touchId;
isEmulated = 1;
if (realSurfaceWithMouse != origId || id != surfaceWithMouse) {
@@ -3105,52 +3216,54 @@ function onTouchStart(ev) {
}
}
sendInput (BROADWAY_EVENT_TOUCH, [0, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
sendInput (BROADWAY_EVENT_TOUCH, [0, id, touchId, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
}
}
function onTouchMove(ev) {
event.preventDefault();
ev.preventDefault();
updateKeyboardStatus();
updateForEvent(ev);
for (var i = 0; i < ev.changedTouches.length; i++) {
var touch = ev.changedTouches.item(i);
var touchId = touchIdentifier(touch.identifier);
var origId = getSurfaceId(touch);
var id = getEffectiveEventTarget (origId);
var pos = getPositionsFromEvent(touch, id);
var isEmulated = 0;
if (firstTouchDownId == touch.identifier) {
if (firstTouchDownId == touchId) {
isEmulated = 1;
}
sendInput (BROADWAY_EVENT_TOUCH, [1, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
sendInput (BROADWAY_EVENT_TOUCH, [1, id, touchId, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
}
}
function onTouchEnd(ev) {
event.preventDefault();
ev.preventDefault();
updateKeyboardStatus();
updateForEvent(ev);
for (var i = 0; i < ev.changedTouches.length; i++) {
var touch = ev.changedTouches.item(i);
var touchId = touchIdentifier(touch.identifier);
var origId = getSurfaceId(touch);
var id = getEffectiveEventTarget (origId);
var pos = getPositionsFromEvent(touch, id);
var isEmulated = 0;
if (firstTouchDownId == touch.identifier) {
if (firstTouchDownId == touchId) {
isEmulated = 1;
firstTouchDownId = null;
}
sendInput (BROADWAY_EVENT_TOUCH, [2, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
sendInput (BROADWAY_EVENT_TOUCH, [2, id, touchId, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
}
}
@@ -3167,11 +3280,11 @@ function setupDocument(document)
document.onkeyup = onKeyUp;
if (document.addEventListener) {
document.addEventListener('DOMMouseScroll', onMouseWheel, false);
document.addEventListener('mousewheel', onMouseWheel, false);
document.addEventListener('touchstart', onTouchStart, false);
document.addEventListener('touchmove', onTouchMove, false);
document.addEventListener('touchend', onTouchEnd, false);
document.addEventListener('DOMMouseScroll', onMouseWheel, passiveSupported ? { passive: false, capture: false } : false);
document.addEventListener('mousewheel', onMouseWheel, passiveSupported ? { passive: false, capture: false } : false);
document.addEventListener('touchstart', onTouchStart, passiveSupported ? { passive: false, capture: false } : false);
document.addEventListener('touchmove', onTouchMove, passiveSupported ? { passive: false, capture: false } : false);
document.addEventListener('touchend', onTouchEnd, passiveSupported ? { passive: false, capture: false } : false);
} else if (document.attachEvent) {
element.attachEvent("onmousewheel", onMouseWheel);
}
@@ -3237,12 +3350,14 @@ function connect()
};
var iOS = /(iPad|iPhone|iPod)/g.test( navigator.userAgent );
if (iOS) {
if (iOS || isAndroidChrome) {
fakeInput = document.createElement("input");
fakeInput.type = "text";
fakeInput.style.position = "absolute";
fakeInput.style.left = "-1000px";
fakeInput.style.top = "-1000px";
document.body.appendChild(fakeInput);
if (isAndroidChrome)
fakeInput.addEventListener('input', onInput, passiveSupported ? { passive: false, capture: false } : false);
}
}

View File

@@ -33,9 +33,11 @@ gdk_broadway_cairo_context_dispose (GObject *object)
}
static void
gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
GdkMemoryDepth depth,
cairo_region_t *region)
gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
GdkMemoryDepth depth,
cairo_region_t *region,
GdkColorState **out_color_state,
GdkMemoryDepth *out_depth)
{
GdkBroadwayCairoContext *self = GDK_BROADWAY_CAIRO_CONTEXT (draw_context);
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self));
@@ -59,6 +61,9 @@ gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_fill (cr);
cairo_destroy (cr);
*out_color_state = GDK_COLOR_STATE_SRGB;
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
}
static void

View File

@@ -33,9 +33,11 @@ gdk_broadway_draw_context_dispose (GObject *object)
}
static void
gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
GdkMemoryDepth depth,
cairo_region_t *region)
gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
GdkMemoryDepth depth,
cairo_region_t *region,
GdkColorState **out_color_state,
GdkMemoryDepth *out_depth)
{
GdkBroadwayDrawContext *self = GDK_BROADWAY_DRAW_CONTEXT (draw_context);
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self));
@@ -52,6 +54,9 @@ gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
self->nodes = g_array_new (FALSE, FALSE, sizeof(guint32));
self->node_textures = g_ptr_array_new_with_free_func (g_object_unref);
*out_color_state = GDK_COLOR_STATE_SRGB;
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
}
static void

View File

@@ -52,8 +52,7 @@ broadwayjs_h = custom_target('broadwayjs.h',
)
libgdk_broadway = static_library('gdk-broadway',
clienthtml_h, broadwayjs_h,
gdk_broadway_sources, gdkconfig, gdkenum_h,
sources: [ clienthtml_h, broadwayjs_h, gdk_broadway_sources, gdk_gen_headers ],
include_directories: [confinc, gdkinc],
c_args: [
'-DGTK_COMPILATION',

View File

@@ -43,6 +43,14 @@
#include <fribidi.h>
/* GTK has a general architectural assumption that gsize is pointer-sized
* (equivalent to uintptr_t), making it non-portable to architectures like
* CHERI where that isn't true. If a future release relaxes that
* assumption, changes will be needed in numerous places.
* See also https://gitlab.gnome.org/GNOME/glib/-/issues/2842 for the
* equivalent in GLib, which would be a prerequisite. */
G_STATIC_ASSERT (sizeof (gsize) == sizeof (void *));
G_STATIC_ASSERT (G_ALIGNOF (gsize) == G_ALIGNOF (void *));
/**
* GDK_WINDOWING_X11:
@@ -120,8 +128,11 @@ static const GdkDebugKey gdk_debug_keys[] = {
{ "dmabuf", GDK_DEBUG_DMABUF, "Information about dmabuf buffers" },
{ "offload", GDK_DEBUG_OFFLOAD, "Information about subsurfaces and graphics offload" },
{ "linear", GDK_DEBUG_LINEAR, "Enable linear rendering" },
{ "hdr", GDK_DEBUG_HDR, "Force HDR rendering" },
{ "portals", GDK_DEBUG_PORTALS, "Force use of portals" },
{ "no-portals", GDK_DEBUG_NO_PORTALS, "Disable use of portals" },
{ "force-offload", GDK_DEBUG_FORCE_OFFLOAD, "Force graphics offload for all textures" },
{ "gl-disable", GDK_DEBUG_GL_DISABLE, "Disable OpenGL support" },
{ "gl-no-fractional", GDK_DEBUG_GL_NO_FRACTIONAL, "Disable fractional scaling for OpenGL" },
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL" },
@@ -132,7 +143,6 @@ static const GdkDebugKey gdk_debug_keys[] = {
{ "gl-glx", GDK_DEBUG_GL_GLX, "Use GLX on X11" },
{ "gl-wgl", GDK_DEBUG_GL_WGL, "Use WGL on Windows" },
{ "vulkan-disable", GDK_DEBUG_VULKAN_DISABLE, "Disable Vulkan support" },
{ "vulkan-validate", GDK_DEBUG_VULKAN_VALIDATE, "Load the Vulkan validation layer" },
{ "default-settings",GDK_DEBUG_DEFAULT_SETTINGS, "Force default values for xsettings" },
{ "high-depth", GDK_DEBUG_HIGH_DEPTH, "Use high bit depth rendering if possible" },
{ "no-vsync", GDK_DEBUG_NO_VSYNC, "Repaint instantly (uses 100% CPU with animations)" },
@@ -142,31 +152,50 @@ static const GdkDebugKey gdk_debug_keys[] = {
#ifdef G_HAS_CONSTRUCTORS
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(stash_desktop_startup_notification_id)
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(stash_and_unset_environment)
#endif
G_DEFINE_CONSTRUCTOR(stash_desktop_startup_notification_id)
G_DEFINE_CONSTRUCTOR(stash_and_unset_environment)
#endif
static char *startup_notification_id = NULL;
static char *xdg_activation_token = NULL;
static void
stash_desktop_startup_notification_id (void)
stash_and_unset_environment (void)
{
const char *desktop_startup_id;
desktop_startup_id = g_getenv ("DESKTOP_STARTUP_ID");
if (desktop_startup_id && *desktop_startup_id != '\0')
{
if (!g_utf8_validate (desktop_startup_id, -1, NULL))
g_warning ("DESKTOP_STARTUP_ID contains invalid UTF-8");
else
startup_notification_id = g_strdup (desktop_startup_id);
}
/* Clear the environment variable so it won't be inherited by
/* Copies environment variables and unsets them so they won't be inherited by
* child processes and confuse things.
*
* Changing environment variables can be racy so we try to do this as early as
* possible in the program flow and before any printing that might involve
* environment variables.
*/
g_unsetenv ("DESKTOP_STARTUP_ID");
struct {
const char *key;
char **dst;
} vars[] = {
{ "DESKTOP_STARTUP_ID", &startup_notification_id },
{ "XDG_ACTIVATION_TOKEN", &xdg_activation_token },
};
size_t i;
for (i = 0; i < G_N_ELEMENTS (vars); i++)
*vars[i].dst = g_strdup (g_getenv (vars[i].key));
for (i = 0; i < G_N_ELEMENTS (vars); i++)
g_unsetenv (vars[i].key);
for (i = 0; i < G_N_ELEMENTS (vars); i++)
{
if (*vars[i].dst == NULL)
continue;
if (!g_utf8_validate (*vars[i].dst, -1, NULL))
{
g_warning ("%s contains invalid UTF-8", vars[i].key);
g_clear_pointer (vars[i].dst, g_free);
}
}
}
static gpointer
@@ -291,7 +320,7 @@ gdk_pre_parse (void)
gdk_gl_backend_use (GDK_GL_WGL);
#ifndef G_HAS_CONSTRUCTORS
stash_desktop_startup_notification_id ();
stash_and_unset_environment ();
#endif
}
@@ -325,15 +354,20 @@ gdk_display_open_default (void)
/*< private >
* gdk_get_startup_notification_id:
*
* Returns the original value of the DESKTOP_STARTUP_ID environment
* variable if it was defined and valid, or %NULL otherwise.
* Returns the original value of the XDG_ACTIVATION_TOKEN environment
* variable if it was defined and valid, otherwise it returns the original
* value of the DESKTOP_STARTUP_ID environment variable if it was defined
* and valid, or %NULL if neither of them were defined and valid.
*
* Returns: (nullable) (transfer none): the original value of the
* DESKTOP_STARTUP_ID environment variable
* XDG_ACTIVATION_TOKEN or DESKTOP_STARTUP_ID environment variable
*/
const char *
gdk_get_startup_notification_id (void)
{
if (xdg_activation_token)
return xdg_activation_token;
return startup_notification_id;
}

View File

@@ -29,7 +29,9 @@
#include <gdk/gdkapplaunchcontext.h>
#include <gdk/gdkcairo.h>
#include <gdk/gdkcairocontext.h>
#include <gdk/gdkcicpparams.h>
#include <gdk/gdkclipboard.h>
#include <gdk/gdkcolorstate.h>
#include <gdk/gdkconfig.h>
#include <gdk/gdkcontentdeserializer.h>
#include <gdk/gdkcontentformats.h>
@@ -61,6 +63,7 @@
#include <gdk/gdkkeys.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkmemorytexture.h>
#include <gdk/gdkmemorytexturebuilder.h>
#include <gdk/gdkmonitor.h>
#include <gdk/gdkpaintable.h>
#include <gdk/gdkpango.h>

View File

@@ -41,8 +41,10 @@ G_BEGIN_DECLS
#ifdef GDK_ARRAY_NULL_TERMINATED
#define GDK_ARRAY_REAL_SIZE(_size) ((_size) + 1)
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_) - 1)
#else
#define GDK_ARRAY_REAL_SIZE(_size) (_size)
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_))
#endif
/* make this readable */
@@ -177,18 +179,23 @@ G_GNUC_UNUSED static inline void
gdk_array(reserve) (GdkArray *self,
gsize n)
{
gsize new_size, size;
gsize new_capacity, size, capacity;
if (n <= gdk_array(get_capacity) (self))
return;
if (G_UNLIKELY (n > GDK_ARRAY_MAX_SIZE))
g_error ("requesting array size of %zu, but maximum size is %zu", n, GDK_ARRAY_MAX_SIZE);
capacity = gdk_array(get_capacity) (self);
if (n <= capacity)
return;
size = gdk_array(get_size) (self);
new_size = ((gsize) 1) << g_bit_storage (MAX (GDK_ARRAY_REAL_SIZE (n), 16) - 1);
/* capacity * 2 can overflow, that's why we MAX() */
new_capacity = MAX (GDK_ARRAY_REAL_SIZE (n), capacity * 2);
#ifdef GDK_ARRAY_PREALLOC
if (self->start == self->preallocated)
{
self->start = g_new (_T_, new_size);
self->start = g_new (_T_, new_capacity);
memcpy (self->start, self->preallocated, sizeof (_T_) * GDK_ARRAY_REAL_SIZE (size));
}
else
@@ -196,15 +203,15 @@ gdk_array(reserve) (GdkArray *self,
#ifdef GDK_ARRAY_NULL_TERMINATED
if (self->start == NULL)
{
self->start = g_new (_T_, new_size);
self->start = g_new (_T_, new_capacity);
*self->start = *(_T_[1]) { 0 };
}
else
#endif
self->start = g_renew (_T_, self->start, new_size);
self->start = g_renew (_T_, self->start, new_capacity);
self->end = self->start + size;
self->end_allocation = self->start + new_size;
self->end_allocation = self->start + new_capacity;
#ifdef GDK_ARRAY_NULL_TERMINATED
self->end_allocation--;
#endif
@@ -312,6 +319,7 @@ gdk_array(get) (const GdkArray *self,
#undef gdk_array_paste
#undef gdk_array
#undef GDK_ARRAY_REAL_SIZE
#undef GDK_ARRAY_MAX_SIZE
#undef GDK_ARRAY_BY_VALUE
#undef GDK_ARRAY_ELEMENT_TYPE

159
gdk/gdkcairoprivate.h Normal file
View File

@@ -0,0 +1,159 @@
#pragma once
#include "gdkcolorstateprivate.h"
#include "gdkcolorprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytexture.h"
#include <cairo.h>
#include <graphene.h>
static inline cairo_format_t
gdk_cairo_format_for_depth (GdkMemoryDepth depth)
{
switch (depth)
{
case GDK_MEMORY_NONE:
case GDK_MEMORY_U8:
return CAIRO_FORMAT_ARGB32;
case GDK_MEMORY_U8_SRGB:
case GDK_MEMORY_U16:
case GDK_MEMORY_FLOAT16:
case GDK_MEMORY_FLOAT32:
return CAIRO_FORMAT_RGBA128F;
case GDK_N_DEPTHS:
default:
g_return_val_if_reached (CAIRO_FORMAT_ARGB32);
}
}
static inline GdkMemoryDepth
gdk_cairo_depth_for_format (cairo_format_t format)
{
switch (format)
{
case CAIRO_FORMAT_ARGB32:
case CAIRO_FORMAT_RGB24:
case CAIRO_FORMAT_RGB16_565:
case CAIRO_FORMAT_A1:
case CAIRO_FORMAT_A8:
return GDK_MEMORY_U8;
case CAIRO_FORMAT_RGB30:
return GDK_MEMORY_U16;
case CAIRO_FORMAT_RGB96F:
case CAIRO_FORMAT_RGBA128F:
return GDK_MEMORY_FLOAT32;
case CAIRO_FORMAT_INVALID:
default:
g_assert_not_reached ();
return GDK_MEMORY_NONE;
}
}
static GdkMemoryFormat
gdk_cairo_format_to_memory_format (cairo_format_t format)
{
switch (format)
{
case CAIRO_FORMAT_ARGB32:
return GDK_MEMORY_DEFAULT;
case CAIRO_FORMAT_RGB24:
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
return GDK_MEMORY_B8G8R8X8;
#elif G_BYTE_ORDER == G_BIG_ENDIAN
return GDK_MEMORY_X8R8G8B8;
#else
#error "Unknown byte order for Cairo format"
#endif
case CAIRO_FORMAT_A8:
return GDK_MEMORY_A8;
case CAIRO_FORMAT_RGB96F:
return GDK_MEMORY_R32G32B32_FLOAT;
case CAIRO_FORMAT_RGBA128F:
return GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
case CAIRO_FORMAT_RGB16_565:
case CAIRO_FORMAT_RGB30:
case CAIRO_FORMAT_INVALID:
case CAIRO_FORMAT_A1:
default:
g_assert_not_reached ();
return GDK_MEMORY_DEFAULT;
}
}
static inline void
gdk_cairo_set_source_color (cairo_t *cr,
GdkColorState *ccs,
const GdkColor *color)
{
float c[4];
gdk_color_to_float (color, ccs, c);
cairo_set_source_rgba (cr, c[0], c[1], c[2], c[3]);
}
static inline void
gdk_cairo_set_source_rgba_ccs (cairo_t *cr,
GdkColorState *ccs,
const GdkRGBA *rgba)
{
GdkColor c;
gdk_color_init_from_rgba (&c, rgba);
gdk_cairo_set_source_color (cr, ccs, &c);
gdk_color_finish (&c);
}
static inline void
gdk_cairo_pattern_add_color_stop_rgba_ccs (cairo_pattern_t *pattern,
GdkColorState *ccs,
double offset,
const GdkRGBA *rgba)
{
float color[4];
gdk_color_state_from_rgba (ccs, rgba, color);
cairo_pattern_add_color_stop_rgba (pattern, offset, color[0], color[1], color[2], color[3]);
}
static inline void
gdk_cairo_rect (cairo_t *cr,
const graphene_rect_t *rect)
{
cairo_rectangle (cr,
rect->origin.x, rect->origin.y,
rect->size.width, rect->size.height);
}
static inline void
gdk_cairo_surface_convert_color_state (cairo_surface_t *surface,
GdkColorState *source,
GdkColorState *target)
{
cairo_surface_t *image_surface;
if (gdk_color_state_equal (source, target))
return;
image_surface = cairo_surface_map_to_image (surface, NULL);
gdk_memory_convert_color_state (cairo_image_surface_get_data (image_surface),
cairo_image_surface_get_stride (image_surface),
gdk_cairo_format_to_memory_format (cairo_image_surface_get_format (image_surface)),
source,
target,
cairo_image_surface_get_width (image_surface),
cairo_image_surface_get_height (image_surface));
cairo_surface_mark_dirty (image_surface);
cairo_surface_unmap_image (surface, image_surface);
/* https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/487 */
cairo_surface_mark_dirty (surface);
}

481
gdk/gdkcicpparams.c Normal file
View File

@@ -0,0 +1,481 @@
/* gdkcicpparams.c
*
* Copyright 2024 Matthias Clasen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkcicpparamsprivate.h"
#include "gdkcolorstateprivate.h"
#include "gdkenumtypes.h"
/**
* GdkCicpParams:
*
* The `GdkCicpParams` struct contains the parameters that define
* a colorstate according to the ITU-T H.273
* [specification](https://www.itu.int/rec/T-REC-H.273/en).
*
* See the documentation of individual properties for supported values.
*
* The 'unspecified' value (2) is not treated in any special way, and
* must be replaced by a different value before creating a color state.
*
* `GdkCicpParams` can be used as a builder object to construct a color
* state from Cicp data with [method@Gdk.CicpParams.build_color_state].
* The function will return an error if the given parameters are not
* supported.
*
* You can obtain a `GdkCicpParams` object from a color state with
* [method@Gdk.ColorState.create_cicp_params]. This can be used to
* create a variant of a color state, by changing just one of the cicp
* parameters, or just to obtain information about the color state.
*
* Since: 4.16
*/
/* {{{ GObject boilerplate */
struct _GdkCicpParams
{
GObject parent_instance;
GdkCicp cicp;
};
struct _GdkCicpParamsClass
{
GObjectClass parent_class;
};
G_DEFINE_TYPE (GdkCicpParams, gdk_cicp_params, G_TYPE_OBJECT)
enum
{
PROP_COLOR_PRIMARIES = 1,
PROP_TRANSFER_FUNCTION,
PROP_MATRIX_COEFFICIENTS,
PROP_RANGE,
N_PROPERTIES,
};
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
static void
gdk_cicp_params_init (GdkCicpParams *self)
{
self->cicp.color_primaries = 2;
self->cicp.transfer_function = 2;
self->cicp.matrix_coefficients = 2;
self->cicp.range = GDK_CICP_RANGE_NARROW;
}
static void
gdk_cicp_params_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GdkCicpParams *self = GDK_CICP_PARAMS (object);
switch (property_id)
{
case PROP_COLOR_PRIMARIES:
g_value_set_uint (value, self->cicp.color_primaries);
break;
case PROP_TRANSFER_FUNCTION:
g_value_set_uint (value, self->cicp.transfer_function);
break;
case PROP_MATRIX_COEFFICIENTS:
g_value_set_uint (value, self->cicp.matrix_coefficients);
break;
case PROP_RANGE:
g_value_set_enum (value, self->cicp.range);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gdk_cicp_params_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GdkCicpParams *self = GDK_CICP_PARAMS (object);
switch (property_id)
{
case PROP_COLOR_PRIMARIES:
gdk_cicp_params_set_color_primaries (self, g_value_get_uint (value));
break;
case PROP_TRANSFER_FUNCTION:
gdk_cicp_params_set_transfer_function (self, g_value_get_uint (value));
break;
case PROP_MATRIX_COEFFICIENTS:
gdk_cicp_params_set_matrix_coefficients (self, g_value_get_uint (value));
break;
case PROP_RANGE:
gdk_cicp_params_set_range (self, g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gdk_cicp_params_class_init (GdkCicpParamsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = gdk_cicp_params_get_property;
object_class->set_property = gdk_cicp_params_set_property;
/**
* GdkCicpParams:color-primaries:
*
* The color primaries to use.
*
* Supported values:
*
* - 1: BT.709 / sRGB
* - 2: unspecified
* - 5: PAL
* - 6,7: BT.601 / NTSC
* - 9: BT.2020
* - 12: Display P3
*
* Since: 4.16
*/
properties[PROP_COLOR_PRIMARIES] =
g_param_spec_uint ("color-primaries", NULL, NULL,
0, 255, 2,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkCicpParams:transfer-function:
*
* The transfer function to use.
*
* Supported values:
*
* - 1,6,14,15: BT.709, BT.601, BT.2020
* - 2: unspecified
* - 4: gamma 2.2
* - 5: gamma 2.8
* - 8: linear
* - 13: sRGB
* - 16: BT.2100 PQ
* - 18: BT.2100 HLG
*
* Since: 4.16
*/
properties[PROP_TRANSFER_FUNCTION] =
g_param_spec_uint ("transfer-function", NULL, NULL,
0, 255, 2,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkCicpParams:matrix-coefficients:
*
* The matrix coefficients (for YUV to RGB conversion).
*
* Supported values:
*
* - 0: RGB
* - 2: unspecified
*
* Since: 4.16
*/
properties[PROP_MATRIX_COEFFICIENTS] =
g_param_spec_uint ("matrix-coefficients", NULL, NULL,
0, 255, 2,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkCicpParams:range:
*
* Whether the data is using the full range of values.
*
* The range of the data.
*
* Since: 4.16
*/
properties[PROP_RANGE] =
g_param_spec_enum ("range", NULL, NULL,
GDK_TYPE_CICP_RANGE,
GDK_CICP_RANGE_NARROW,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
}
/* }}} */
/* {{{ Public API */
/**
* gdk_cicp_params_new:
*
* Creates a new `GdkCicpParams` object.
*
* The initial values of the properties are the values for "undefined"
* and need to be set before a color state object can be built.
*
* Returns: (transfer full): a new `GdkCicpParams`
*
* Since: 4.16
*/
GdkCicpParams *
gdk_cicp_params_new (void)
{
return g_object_new (GDK_TYPE_CICP_PARAMS, NULL);
}
/**
* gdk_cicp_params_get_color_primaries:
* @self: a `GdkCicpParams`
*
* Returns the value of the color-primaries property
* of @self.
*
* Returns: the color-primaries value
*
* Since: 4.16
*/
guint
gdk_cicp_params_get_color_primaries (GdkCicpParams *self)
{
g_return_val_if_fail (GDK_IS_CICP_PARAMS (self), 0);
return self->cicp.color_primaries;
}
/**
* gdk_cicp_params_set_color_primaries:
* @self: a `GdkCicpParams`
* @color_primaries: the new color primaries value
*
* Sets the color-primaries property of @self.
*
* Since: 4.16
*/
void
gdk_cicp_params_set_color_primaries (GdkCicpParams *self,
guint color_primaries)
{
g_return_if_fail (GDK_IS_CICP_PARAMS (self));
if (self->cicp.color_primaries == color_primaries)
return;
self->cicp.color_primaries = color_primaries;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR_PRIMARIES]);
}
/**
* gdk_cicp_params_get_transfer_function:
* @self: a `GdkCicpParams`
*
* Gets the transfer-function property of @self.
*
* Returns: the transfer-function value
*
* Since: 4.16
*/
guint
gdk_cicp_params_get_transfer_function (GdkCicpParams *self)
{
g_return_val_if_fail (GDK_IS_CICP_PARAMS (self), 0);
return self->cicp.transfer_function;
}
/**
* gdk_cicp_params_set_transfer_function:
* @self: a `GdkCicpParams`
* @transfer_function: the new transfer-function value
*
* Sets the transfer-function property of @self.
*
* Since: 4.16
*/
void
gdk_cicp_params_set_transfer_function (GdkCicpParams *self,
guint transfer_function)
{
g_return_if_fail (GDK_IS_CICP_PARAMS (self));
if (self->cicp.transfer_function == transfer_function)
return;
self->cicp.transfer_function = transfer_function;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TRANSFER_FUNCTION]);
}
/**
* gdk_cicp_params_get_matrix_coefficients:
* @self: a `GdkCicpParams`
*
* Gets the matrix-coefficients property of @self.
*
* Returns: the matrix-coefficients value
*
* Since: 4.16
*/
guint
gdk_cicp_params_get_matrix_coefficients (GdkCicpParams *self)
{
g_return_val_if_fail (GDK_IS_CICP_PARAMS (self), 0);
return self->cicp.matrix_coefficients;
}
/**
* gdk_cicp_params_set_matrix_coefficients:
* @self a `GdkCicpParams`
* @matrix_coefficients: the new matrix-coefficients value
*
* Sets the matrix-coefficients property of @self.
*
* Since: 4.16
*/
void
gdk_cicp_params_set_matrix_coefficients (GdkCicpParams *self,
guint matrix_coefficients)
{
g_return_if_fail (GDK_IS_CICP_PARAMS (self));
if (self->cicp.matrix_coefficients == matrix_coefficients)
return;
self->cicp.matrix_coefficients = matrix_coefficients;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MATRIX_COEFFICIENTS]);
}
/**
* gdk_cicp_params_get_range:
* @self: a `GdkCicpParams`
*
* Gets the range property of @self.
*
* Returns: the range value
*
* Since: 4.16
*/
GdkCicpRange
gdk_cicp_params_get_range (GdkCicpParams *self)
{
g_return_val_if_fail (GDK_IS_CICP_PARAMS (self), GDK_CICP_RANGE_NARROW);
return self->cicp.range;
}
/**
* gdk_cicp_params_set_range:
* @self: a `GdkCipParams`
* @range: the range value
*
* Sets the range property of @self
*
* Since: 4.16
*/
void
gdk_cicp_params_set_range (GdkCicpParams *self,
GdkCicpRange range)
{
g_return_if_fail (GDK_IS_CICP_PARAMS (self));
if (self->cicp.range == range)
return;
self->cicp.range = range;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_RANGE]);
}
/**
* gdk_cicp_params_build_color_state:
* @self: a `GdkCicpParams`
* @error: return location for errors
*
* Creates a new `GdkColorState` object for the cicp parameters in @self.
*
* Note that this may fail if the cicp parameters in @self are not
* supported by GTK. In that case, `NULL` is returned, and @error is set
* with an error message that can be presented to the user.
*
* Returns: (transfer full) (nullable): A newly allocated `GdkColorState`
*
* Since: 4.16
*/
GdkColorState *
gdk_cicp_params_build_color_state (GdkCicpParams *self,
GError **error)
{
return gdk_color_state_new_for_cicp (gdk_cicp_params_get_cicp (self), error);
}
/* }}} */
/* {{{ Private API */
/*< private >
* gdk_cicp_params_new_for_cicp:
* @cicp: a GdkCicp struct
*
* Create a `GdkCicpParams` from the values in @cicp.
*
* Returns: (transfer full): a new `GdkCicpParams` object
*/
GdkCicpParams *
gdk_cicp_params_new_for_cicp (const GdkCicp *cicp)
{
return g_object_new (GDK_TYPE_CICP_PARAMS,
"color-primaries", cicp->color_primaries,
"transfer-function", cicp->transfer_function,
"matrix-coefficients", cicp->matrix_coefficients,
"range", cicp->range,
NULL);
}
/*< private >
* gdk_cicp_params_get_cicp:
* @self: a `GdkCicpParams` object
*
* Gets the `GdkCicp` struct of @self.
*
* Returns: (transfer none): a `GdkCicp` struct containing
* the values of @self
*/
const GdkCicp *
gdk_cicp_params_get_cicp (GdkCicpParams *self)
{
return &self->cicp;
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */

90
gdk/gdkcicpparams.h Normal file
View File

@@ -0,0 +1,90 @@
/* gdkcicpparams.h
*
* Copyright 2024 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdktypes.h>
G_BEGIN_DECLS
#define GDK_TYPE_CICP_PARAMS (gdk_cicp_params_get_type ())
GDK_AVAILABLE_IN_4_16
GDK_DECLARE_INTERNAL_TYPE (GdkCicpParams, gdk_cicp_params, GDK, CICP_PARAMS, GObject)
GDK_AVAILABLE_IN_4_16
GdkCicpParams *gdk_cicp_params_new (void);
GDK_AVAILABLE_IN_4_16
guint gdk_cicp_params_get_color_primaries (GdkCicpParams *self);
GDK_AVAILABLE_IN_4_16
void gdk_cicp_params_set_color_primaries (GdkCicpParams *self,
guint color_primaries);
GDK_AVAILABLE_IN_4_16
guint gdk_cicp_params_get_transfer_function (GdkCicpParams *self);
GDK_AVAILABLE_IN_4_16
void gdk_cicp_params_set_transfer_function (GdkCicpParams *self,
guint transfer_function);
GDK_AVAILABLE_IN_4_16
guint gdk_cicp_params_get_matrix_coefficients (GdkCicpParams *self);
GDK_AVAILABLE_IN_4_16
void gdk_cicp_params_set_matrix_coefficients (GdkCicpParams *self,
guint matrix_coefficients);
/**
* GdkCicpRange:
* @GDK_CICP_RANGE_NARROW: The values use the range of 16-235 (for Y) and 16-240 for u and v.
* @GDK_CICO_RANGE_FULL: The values use the full range.
*
* The values of this enumeration describe whether image data uses
* the full range of 8-bit values.
*
* In digital broadcasting, it is common to reserve the lowest and
* highest values. Typically the allowed values for the narrow range
* are 16-235 for Y and 16-240 for u,v (when dealing with YUV data).
*
* Since: 4.16
*/
typedef enum
{
GDK_CICP_RANGE_NARROW,
GDK_CICP_RANGE_FULL,
} GdkCicpRange;
GDK_AVAILABLE_IN_4_16
GdkCicpRange gdk_cicp_params_get_range (GdkCicpParams *self);
GDK_AVAILABLE_IN_4_16
void gdk_cicp_params_set_range (GdkCicpParams *self,
GdkCicpRange range);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_cicp_params_build_color_state (GdkCicpParams *self,
GError **error);
G_END_DECLS

View File

@@ -0,0 +1,84 @@
#pragma once
#include "gdkcicpparams.h"
typedef struct _GdkCicp GdkCicp;
struct _GdkCicp
{
guint color_primaries;
guint transfer_function;
guint matrix_coefficients;
GdkCicpRange range;
};
/*< private >
* gdk_cicp_equal:
* @p1: a `GdkCicp`
* @p2: another `GdkCicp`
*
* Compare two cicp tuples for equality.
*
* Note that several cicp values are 'functionally equivalent'.
* If you are interested in that notion, use gdk_cicp_equivalent().
*
* Returns: whether @p1 and @p2 are equal
*/
static inline gboolean
gdk_cicp_equal (const GdkCicp *p1,
const GdkCicp *p2)
{
return p1->color_primaries == p2->color_primaries &&
p1->transfer_function == p2->transfer_function &&
p1->matrix_coefficients == p2->matrix_coefficients &&
p1->range == p2->range;
}
static inline void
gdk_cicp_normalize (const GdkCicp *orig,
GdkCicp *out)
{
memcpy (out, orig, sizeof (GdkCicp));
/* ntsc */
if (out->color_primaries == 6)
out->color_primaries = 5;
/* bt709 */
if (out->transfer_function == 6 ||
out->transfer_function == 14 ||
out->transfer_function == 15)
out->transfer_function = 1;
/* bt601 */
if (out->matrix_coefficients == 6)
out->matrix_coefficients = 5;
}
/*< private >
* gdk_cicp_equivalent:
* @p1: a `GdkCicp`
* @p2: another `GdkCicp`
*
* Determine whether two cicp tuples are functionally equivalent.
*
* Returns: whether @p1 and @p2 are functionally equivalent
*/
static inline gboolean
gdk_cicp_equivalent (const GdkCicp *p1,
const GdkCicp *p2)
{
GdkCicp n1, n2;
if (gdk_cicp_equal (p1, p2))
return TRUE;
gdk_cicp_normalize (p1, &n1);
gdk_cicp_normalize (p2, &n2);
return gdk_cicp_equal (&n1, &n2);
}
const GdkCicp * gdk_cicp_params_get_cicp (GdkCicpParams *params);
GdkCicpParams * gdk_cicp_params_new_for_cicp (const GdkCicp *cicp);

View File

@@ -515,15 +515,13 @@ gdk_clipboard_get_content (GdkClipboard *clipboard)
* @clipboard: a `GdkClipboard`
* @io_priority: the I/O priority of the request
* @cancellable: (nullable): optional `GCancellable` object
* @callback: (scope async): callback to call when the request is satisfied
* @user_data: (closure): the data to pass to callback function
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
* @user_data:: the data to pass to callback function
*
* Asynchronously instructs the @clipboard to store its contents remotely.
*
* If the clipboard is not local, this function does nothing but report success.
*
* The @callback must call [method@Gdk.Clipboard.store_finish].
*
* The purpose of this call is to preserve clipboard contents beyond the
* lifetime of an application, so this function is typically called on
* exit. Depending on the platform, the functionality may not be available
@@ -632,15 +630,12 @@ gdk_clipboard_read_internal (GdkClipboard *clipboard,
* @mime_types: (array zero-terminated=1): a %NULL-terminated array of mime types to choose from
* @io_priority: the I/O priority of the request
* @cancellable: (nullable): optional `GCancellable` object
* @callback: (scope async): callback to call when the request is satisfied
* @user_data: (closure): the data to pass to callback function
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
* @user_data: the data to pass to callback function
*
* Asynchronously requests an input stream to read the @clipboard's
* contents from.
*
* When the operation is finished @callback will be called. You must then
* call [method@Gdk.Clipboard.read_finish] to get the result of the operation.
*
* The clipboard will choose the most suitable mime type from the given list
* to fulfill the request, preferring the ones listed first.
*/
@@ -828,15 +823,12 @@ gdk_clipboard_read_value_internal (GdkClipboard *clipboard,
* @type: a `GType` to read
* @io_priority: the I/O priority of the request
* @cancellable: (nullable): optional `GCancellable` object
* @callback: (scope async): callback to call when the request is satisfied
* @user_data: (closure): the data to pass to callback function
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
* @user_data: the data to pass to callback function
*
* Asynchronously request the @clipboard contents converted to the given
* @type.
*
* When the operation is finished @callback will be called. You must then call
* [method@Gdk.Clipboard.read_value_finish] to get the resulting `GValue`.
*
* For local clipboard contents that are available in the given `GType`,
* the value will be copied directly. Otherwise, GDK will try to use
* [func@content_deserialize_async] to convert the clipboard's data.
@@ -890,14 +882,11 @@ gdk_clipboard_read_value_finish (GdkClipboard *clipboard,
* gdk_clipboard_read_texture_async:
* @clipboard: a `GdkClipboard`
* @cancellable: (nullable): optional `GCancellable` object, %NULL to ignore.
* @callback: (scope async): callback to call when the request is satisfied
* @user_data: (closure): the data to pass to callback function
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
* @user_data: the data to pass to callback function
*
* Asynchronously request the @clipboard contents converted to a `GdkPixbuf`.
*
* When the operation is finished @callback will be called. You must then
* call [method@Gdk.Clipboard.read_texture_finish] to get the result.
*
* This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
* need more control over the operation.
@@ -955,14 +944,11 @@ gdk_clipboard_read_texture_finish (GdkClipboard *clipboard,
* gdk_clipboard_read_text_async:
* @clipboard: a `GdkClipboard`
* @cancellable: (nullable): optional `GCancellable` object
* @callback: (scope async): callback to call when the request is satisfied
* @user_data: (closure): the data to pass to callback function
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
* @user_data: the data to pass to callback function
*
* Asynchronously request the @clipboard contents converted to a string.
*
* When the operation is finished @callback will be called. You must then
* call [method@Gdk.Clipboard.read_text_finish] to get the result.
*
* This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
* need more control over the operation.

301
gdk/gdkcolor.c Normal file
View File

@@ -0,0 +1,301 @@
/* GDK - The GIMP Drawing Kit
*
* Copyright (C) 2021 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkcolorprivate.h"
#include "gdkcolorstateprivate.h"
#include "gdkrgbaprivate.h"
/*< private >
* GdkColor:
* @color_state: the color state to interpret the values in
* @values: the 3 coordinates that define the color, followed
* by the alpha value
*
* A `GdkColor` represents a color.
*
* The color state defines the meaning and range of the values.
* E.g., the srgb color state has r, g, b components representing
* red, green and blue with a range of [0,1], while the oklch color
* state has l, c, h components representing luminosity, chromaticity
* and hue, with l ranging from 0 to 1 and c from 0 to about 0.4, while
* h is interpreted as angle in degrees.
*
* value[3] is always the alpha value with a range of [0,1].
*
* The values are also available under the names red, green, blue
* and alpha, or r, g, b and a.
*/
/*< private >
* gdk_color_init:
* @self: the `GdkColor` struct to initialize
* @color_state: the color state
* @values: the values
*
* Initializes the `GdkColor` with the given color state
* and values.
*
* Note that this takes a reference on @color_state that
* must be freed by calling [function@Gdk.Color.finish]
* when the `GdkColor` is no longer needed.
*/
void
(gdk_color_init) (GdkColor *self,
GdkColorState *color_state,
const float values[4])
{
_gdk_color_init (self, color_state, values);
}
/*< private >
* gdk_color_init_copy:
* @self: the `GdkColor` struct to initialize
* @color: the `GdkColor` to copy
*
* Initializes the `GdkColor` by copying the contents
* of another `GdkColor`.
*
* Note that this takes a reference on the color state
* that must be freed by calling [function@Gdk.Color.finish]
* when the `GdkColor` is no longer needed.
*/
void
(gdk_color_init_copy) (GdkColor *self,
const GdkColor *color)
{
_gdk_color_init_copy (self, color);
}
/*< private >
* gdk_color_init_from_rgba:
* @self: the `GdkColor` struct to initialize
* @rgba: the `GdkRGBA` to copy
*
* Initializes the `GdkColor` by copying the contents
* of a `GdkRGBA`.
*
* Note that `GdkRGBA` colors are always in the sRGB
* color state.
*
* Note that this takes a reference on the color state
* that must be freed by calling [function@Gdk.Color.finish]
* when the `GdkColor` is no longer needed.
*/
void
(gdk_color_init_from_rgba) (GdkColor *self,
const GdkRGBA *rgba)
{
_gdk_color_init_from_rgba (self, rgba);
}
/*< private >
* @self: a `GdkColor`
*
* Drop the reference on the color state of @self.
*
* After this, @self is empty and can be initialized again
* with [function@Gdk.Color.init] and its variants.
*/
void
(gdk_color_finish) (GdkColor *self)
{
_gdk_color_finish (self);
}
/*< private >
* gdk_color_equal:
* @self: a `GdkColor`
* @other: another `GdkColor`
*
* Compares two `GdkColor` structs for equality.
*
* Returns: `TRUE` if @self and @other are equal
*/
gboolean
(gdk_color_equal) (const GdkColor *self,
const GdkColor *other)
{
return _gdk_color_equal (self, other);
}
/*< private >
* gdk_color_is_clear:
* @self: a `GdkColor`
*
* Returns whether @self is fully transparent.
*
* Returns: `TRUE` if @self is transparent
*/
gboolean
(gdk_color_is_clear) (const GdkColor *self)
{
return _gdk_color_is_clear (self);
}
/*< private >
* gdk_color_is_opaque:
* @self: a `GdkColor`
*
* Returns whether @self is fully opaque.
*
* Returns: `TRUE` if @self if opaque
*/
gboolean
(gdk_color_is_opaque) (const GdkColor *self)
{
return _gdk_color_is_opaque (self);
}
/*< private >
* gdk_color_convert:
* @self: the `GdkColor` to store the result in
* @color_state: the target color start
* @other: the `GdkColor` to convert
*
* Converts a given `GdkColor` to another color state.
*
* After the conversion, @self will represent the same
* color as @other in @color_state, to the degree possible.
*
* Different color states have different gamuts of colors
* they can represent, and converting a color to a color
* state with a smaller gamut may yield an 'out of gamut'
* result.
*/
void
(gdk_color_convert) (GdkColor *self,
GdkColorState *color_state,
const GdkColor *other)
{
gdk_color_convert (self, color_state, other);
}
/*< private >
* gdk_color_to_float:
* @self: a `GdkColor`
* @target: the color state to convert to
* @values: the location to store the result in
*
* Converts a given `GdkColor to another color state
* and stores the result in a `float[4]`.
*/
void
(gdk_color_to_float) (const GdkColor *self,
GdkColorState *target,
float values[4])
{
gdk_color_to_float (self, target, values);
}
/*< private >
* gdk_color_from_rgba:
* @self: the `GdkColor` to store the result in
* @color_state: the target color state
* @rgba: the `GdkRGBA` to convert
*
* Converts a given `GdkRGBA` to the target @color_state.
*/
void
gdk_color_from_rgba (GdkColor *self,
GdkColorState *color_state,
const GdkRGBA *rgba)
{
GdkColor tmp = {
.color_state = GDK_COLOR_STATE_SRGB,
.r = rgba->red,
.g = rgba->green,
.b = rgba->blue,
.a = rgba->alpha
};
gdk_color_convert (self, color_state, &tmp);
gdk_color_finish (&tmp);
}
/*< private >
* gdk_color_get_depth:
* @self: a `GdkColor`
*
* Returns the preferred depth for the color state of @self.
*
* Returns: the preferred depth
*/
GdkMemoryDepth
(gdk_color_get_depth) (const GdkColor *self)
{
return gdk_color_state_get_depth (self->color_state);
}
/*< private >
* gdk_color_print:
* @self: the `GdkColor` to print
* @string: the string to print to
*
* Appends a representation of @self to @string.
*
* The representation is inspired by CSS3 colors,
* but not 100% identical, and looks like this:
*
* color(NAME R G B / A)
*
* where `NAME` identifies color state, and
* `R`, `G`, `B` and `A` are the components of the color.
*
* The alpha may be omitted if it is 1.
*/
void
gdk_color_print (const GdkColor *self,
GString *string)
{
if (gdk_color_state_equal (self->color_state, GDK_COLOR_STATE_SRGB))
{
gdk_rgba_print ((const GdkRGBA *) self->values, string);
}
else
{
g_string_append_printf (string, "color(%s %g %g %g",
gdk_color_state_get_name (self->color_state),
self->r, self->g, self->b);
if (self->a < 1)
g_string_append_printf (string, " / %g", self->a);
g_string_append_c (string, ')');
}
}
/*< private >
* gdk_color_print:
* @self: the `GdkColor` to print
*
* Create a string representation of @self.
*
* See [method@Gdk.Color.print] for details about
* the format.
* Returns: (transfer full): a newly-allocated string
*/
char *
gdk_color_to_string (const GdkColor *self)
{
GString *string = g_string_new ("");
gdk_color_print (self, string);
return g_string_free (string, FALSE);
}

224
gdk/gdkcolordefs.h Normal file
View File

@@ -0,0 +1,224 @@
/* gdkcolordefs.h
*
* Copyright 2024 Matthias Clasen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/* Note that this header is shared between the color state implementation
* and tests, and must not include other headers.
*/
static inline float
srgb_oetf (float v)
{
if (v > 0.0031308f)
return 1.055f * powf (v, 1.f / 2.4f) - 0.055f;
else
return 12.92f * v;
}
static inline float
srgb_eotf (float v)
{
if (v >= 0.04045f)
return powf (((v + 0.055f) / (1.f + 0.055f)), 2.4f);
else
return v / 12.92f;
}
static inline float
gamma22_oetf (float v)
{
return powf (v, 1.f / 2.2f);
}
static inline float
gamma22_eotf (float v)
{
return powf (v, 2.2f);
}
static inline float
gamma28_oetf (float v)
{
return powf (v, 1.f / 2.8f);
}
static inline float
gamma28_eotf (float v)
{
return powf (v, 2.8f);
}
static inline float
pq_eotf (float v)
{
float ninv = (1 << 14) / 2610.0;
float minv = (1 << 5) / 2523.0;
float c1 = 3424.0 / (1 << 12);
float c2 = 2413.0 / (1 << 7);
float c3 = 2392.0 / (1 << 7);
float x = powf (MAX ((powf (v, minv) - c1), 0) / (c2 - (c3 * (powf (v, minv)))), ninv);
return x * 10000 / 203.0;
}
static inline float
pq_oetf (float v)
{
float x = v * 203.0 / 10000.0;
float n = 2610.0 / (1 << 14);
float m = 2523.0 / (1 << 5);
float c1 = 3424.0 / (1 << 12);
float c2 = 2413.0 / (1 << 7);
float c3 = 2392.0 / (1 << 7);
return powf (((c1 + (c2 * powf (x, n))) / (1 + (c3 * powf (x, n)))), m);
}
static inline float
bt709_eotf (float v)
{
const float a = 1.099;
const float d = 0.0812;
if (v < d)
return v / 4.5f;
else
return powf ((v + (a - 1)) / a, 1 / 0.45f);
}
static inline float
bt709_oetf (float v)
{
const float a = 1.099;
const float b = 0.018;
if (v < b)
return v * 4.5f;
else
return a * powf (v, 0.45f) - (a - 1);
}
static inline float
hlg_eotf (float v)
{
const float a = 0.17883277;
const float b = 0.28466892;
const float c = 0.55991073;
if (v <= 0.5)
return (v * v) / 3;
else
return (expf ((v - c) / a) + b) / 12.0;
}
static inline float
hlg_oetf (float v)
{
const float a = 0.17883277;
const float b = 0.28466892;
const float c = 0.55991073;
if (v <= 1/12.0)
return sqrtf (3 * v);
else
return a * logf (12 * v - b) + c;
}
/* See http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
* for how to derive the abc_to_xyz matrices from chromaticity coordinates.
*/
static const float identity[9] = {
1, 0, 0,
0, 1, 0,
0, 0, 1,
};
static const float srgb_to_xyz[9] = {
0.4124564, 0.3575761, 0.1804375,
0.2126729, 0.7151522, 0.0721750,
0.0193339, 0.1191920, 0.9503041,
};
static const float xyz_to_srgb[9] = {
3.2404542, -1.5371385, -0.4985314,
-0.9692660, 1.8760108, 0.0415560,
0.0556434, -0.2040259, 1.0572252,
};
static const float rec2020_to_xyz[9] = {
0.6369580, 0.1446169, 0.1688810,
0.2627002, 0.6779981, 0.0593017,
0.0000000, 0.0280727, 1.0609851,
};
static const float xyz_to_rec2020[9] = {
1.7166512, -0.3556708, -0.2533663,
-0.6666844, 1.6164812, 0.0157685,
0.0176399, -0.0427706, 0.9421031,
};
static const float pal_to_xyz[9] = {
0.4305538, 0.3415498, 0.1783523,
0.2220043, 0.7066548, 0.0713409,
0.0201822, 0.1295534, 0.9393222,
};
static const float xyz_to_pal[9] = {
3.0633611, -1.3933902, -0.4758237,
-0.9692436, 1.8759675, 0.0415551,
0.0678610, -0.2287993, 1.0690896,
};
static const float ntsc_to_xyz[9] = {
0.3935209, 0.3652581, 0.1916769,
0.2123764, 0.7010599, 0.0865638,
0.0187391, 0.1119339, 0.9583847,
};
static const float xyz_to_ntsc[9] = {
3.5060033, -1.7397907, -0.5440583,
-1.0690476, 1.9777789, 0.0351714,
0.0563066, -0.1969757, 1.0499523,
};
static const float p3_to_xyz[9] = {
0.4865709, 0.2656677, 0.1982173,
0.2289746, 0.6917385, 0.0792869,
0.0000000, 0.0451134, 1.0439444,
};
static const float xyz_to_p3[9] = {
2.4934969, -0.9313836, -0.4027108,
-0.8294890, 1.7626641, 0.0236247,
0.0358458, -0.0761724, 0.9568845,
};
/* premultiplied matrices for default conversions */
static const float rec2020_to_srgb[9] = {
1.660227, -0.587548, -0.072838,
-0.124553, 1.132926, -0.008350,
-0.018155, -0.100603, 1.118998,
};
static const float srgb_to_rec2020[9] = {
0.627504, 0.329275, 0.043303,
0.069108, 0.919519, 0.011360,
0.016394, 0.088011, 0.895380,
};

135
gdk/gdkcolorimpl.h Normal file
View File

@@ -0,0 +1,135 @@
/* GDK - The GIMP Drawing Kit
*
* Copyright (C) 2021 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "gdkcolorstateprivate.h"
#define gdk_color_init(...) _gdk_color_init (__VA_ARGS__)
static inline void
_gdk_color_init (GdkColor *self,
GdkColorState *color_state,
const float values[4])
{
self->color_state = gdk_color_state_ref (color_state);
memcpy (self->values, values, sizeof (float) * 4);
}
#define gdk_color_init_copy(self, color) _gdk_color_init_copy ((self), (color))
static inline void
_gdk_color_init_copy (GdkColor *self,
const GdkColor *color)
{
_gdk_color_init (self, color->color_state, color->values);
}
#define gdk_color_init_from_rgb(self, rgba) _gdk_color_init_from_rgba ((self), (rgba))
static inline void
_gdk_color_init_from_rgba (GdkColor *self,
const GdkRGBA *rgba)
{
_gdk_color_init (self, GDK_COLOR_STATE_SRGB, (const float *) rgba);
}
#define gdk_color_finish(self) _gdk_color_finish ((self))
static inline void
_gdk_color_finish (GdkColor *self)
{
gdk_color_state_unref (self->color_state);
self->color_state = NULL;
}
#define gdk_color_get_color_state(self) _gdk_color_get_color_state ((self))
static inline GdkColorState *
_gdk_color_get_color_state (const GdkColor *self)
{
return self->color_state;
}
#define gdk_color_equal(self, other) _gdk_color_equal ((self), (other))
static inline gboolean
_gdk_color_equal (const GdkColor *self,
const GdkColor *other)
{
return self->values[0] == other->values[0] &&
self->values[1] == other->values[1] &&
self->values[2] == other->values[2] &&
self->values[3] == other->values[3] &&
gdk_color_state_equal (self->color_state, other->color_state);
}
#define gdk_color_is_clear(self) _gdk_color_is_clear ((self))
static inline gboolean
_gdk_color_is_clear (const GdkColor *self)
{
return self->alpha < (255.f / 65535.f);
}
#define gdk_color_is_opaque(self) _gdk_color_is_opaque ((self))
static inline gboolean
_gdk_color_is_opaque (const GdkColor *self)
{
return self->alpha > (65280.f / 65535.f);
}
#define gdk_color_convert(self, cs, other) _gdk_color_convert ((self), (cs), (other))
static inline void
_gdk_color_convert (GdkColor *self,
GdkColorState *color_state,
const GdkColor *other)
{
if (gdk_color_state_equal (color_state, other->color_state))
{
gdk_color_init_copy (self, other);
return;
}
self->color_state = gdk_color_state_ref (color_state);
gdk_color_state_convert_color (other->color_state,
other->values,
self->color_state,
self->values);
}
#define gdk_color_to_float(self, cs, values) _gdk_color_to_float ((self), (cs), (values))
static inline void
_gdk_color_to_float (const GdkColor *self,
GdkColorState *color_state,
float values[4])
{
if (gdk_color_state_equal (self->color_state, color_state))
{
memcpy (values, self->values, sizeof (float) * 4);
return;
}
gdk_color_state_convert_color (self->color_state,
self->values,
color_state,
values);
}
#define gdk_color_get_depth(self) _gdk_color_get_depth ((self))
static inline GdkMemoryDepth
_gdk_color_get_depth (const GdkColor *self)
{
return gdk_color_state_get_depth (self->color_state);
}

107
gdk/gdkcolorprivate.h Normal file
View File

@@ -0,0 +1,107 @@
/* GDK - The GIMP Drawing Kit
*
* Copyright (C) 2021 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <gdk/gdktypes.h>
#include <gdk/gdkcolorstate.h>
#include <gdk/gdkrgba.h>
#include <gdk/gdkmemoryformatprivate.h>
typedef struct _GdkColor GdkColor;
/* The interpretation of the first 3 components depends on the color state.
* values[3] is always alpha.
*/
struct _GdkColor
{
GdkColorState *color_state;
union {
float values[4];
struct {
float r;
float g;
float b;
float a;
};
struct {
float red;
float green;
float blue;
float alpha;
};
};
};
G_STATIC_ASSERT (G_STRUCT_OFFSET (GdkColor, r) == G_STRUCT_OFFSET (GdkColor, red));
G_STATIC_ASSERT (G_STRUCT_OFFSET (GdkColor, g) == G_STRUCT_OFFSET (GdkColor, green));
G_STATIC_ASSERT (G_STRUCT_OFFSET (GdkColor, b) == G_STRUCT_OFFSET (GdkColor, blue));
G_STATIC_ASSERT (G_STRUCT_OFFSET (GdkColor, a) == G_STRUCT_OFFSET (GdkColor, alpha));
/* The committee notes that since all known implementations but one "get it right"
* this may well not be a defect at all.
* https://open-std.org/JTC1/SC22/WG14/www/docs/n2396.htm#dr_496
*/
#ifndef _MSC_VER
G_STATIC_ASSERT (G_STRUCT_OFFSET (GdkColor, r) == G_STRUCT_OFFSET (GdkColor, values[0]));
G_STATIC_ASSERT (G_STRUCT_OFFSET (GdkColor, g) == G_STRUCT_OFFSET (GdkColor, values[1]));
G_STATIC_ASSERT (G_STRUCT_OFFSET (GdkColor, b) == G_STRUCT_OFFSET (GdkColor, values[2]));
G_STATIC_ASSERT (G_STRUCT_OFFSET (GdkColor, a) == G_STRUCT_OFFSET (GdkColor, values[3]));
#endif
#define GDK_COLOR_SRGB(r,g,b,a) (GdkColor) { \
.color_state = GDK_COLOR_STATE_SRGB, \
.values = { (r), (g), (b), (a) } \
}
void gdk_color_init (GdkColor *self,
GdkColorState *color_state,
const float values[4]);
void gdk_color_init_copy (GdkColor *self,
const GdkColor *color);
void gdk_color_init_from_rgba (GdkColor *self,
const GdkRGBA *rgba);
void gdk_color_finish (GdkColor *self);
gboolean gdk_color_equal (const GdkColor *color1,
const GdkColor *color2);
gboolean gdk_color_is_clear (const GdkColor *self);
gboolean gdk_color_is_opaque (const GdkColor *self);
GdkMemoryDepth gdk_color_get_depth (const GdkColor *self);
void gdk_color_convert (GdkColor *self,
GdkColorState *color_state,
const GdkColor *other);
void gdk_color_to_float (const GdkColor *self,
GdkColorState *target,
float values[4]);
void gdk_color_from_rgba (GdkColor *self,
GdkColorState *color_state,
const GdkRGBA *rgba);
void gdk_color_print (const GdkColor *self,
GString *string);
char * gdk_color_to_string (const GdkColor *self);
#include "gdkcolorimpl.h"
G_END_DECLS

774
gdk/gdkcolorstate.c Normal file
View File

@@ -0,0 +1,774 @@
/* gdkcolorstate.c
*
* Copyright 2024 Matthias Clasen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkcolorstateprivate.h"
#include <math.h>
#include "gdkcolordefs.h"
#include <glib/gi18n-lib.h>
/**
* GdkColorState:
*
* A `GdkColorState` object provides the information to interpret
* colors and pixels in a variety of ways.
*
* They are also known as
* [*color spaces*](https://en.wikipedia.org/wiki/Color_space).
*
* Crucially, GTK knows how to convert colors from one color
* state to another.
*
* `GdkColorState objects are immutable and therefore threadsafe.
*
* Since 4.16
*/
G_DEFINE_BOXED_TYPE (GdkColorState, gdk_color_state,
gdk_color_state_ref, gdk_color_state_unref);
/* {{{ Public API */
/**
* gdk_color_state_ref:
* @self: a `GdkColorState`
*
* Increase the reference count of @self.
*
* Returns: the object that was passed in
*
* Since: 4.16
*/
GdkColorState *
(gdk_color_state_ref) (GdkColorState *self)
{
return _gdk_color_state_ref (self);
}
/**
* gdk_color_state_unref:
* @self:a `GdkColorState`
*
* Decrease the reference count of @self.
*
* Unless @self is static, it will be freed
* when the reference count reaches zero.
*
* Since: 4.16
*/
void
(gdk_color_state_unref) (GdkColorState *self)
{
_gdk_color_state_unref (self);
}
/**
* gdk_color_state_get_srgb:
*
* Returns the color state object representing the sRGB color space.
*
* This color state uses the primaries defined by BT.709-6 and the transfer function
* defined by IEC 61966-2-1.
*
* It is equivalent to the [Cicp](class.CicpParams.html) tuple 1/13/0/1.
*
* See e.g. [the CSS Color Module](https://www.w3.org/TR/css-color-4/#predefined-sRGB)
* for details about this colorstate.
*
* Returns: the color state object for sRGB
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_srgb (void)
{
return GDK_COLOR_STATE_SRGB;
}
/**
* gdk_color_state_get_srgb_linear:
*
* Returns the color state object representing the linearized sRGB color space.
*
* This color state uses the primaries defined by BT.709-6 and a linear transfer function.
*
* It is equivalent to the [Cicp](class.CicpParams.html) tuple 1/8/0/1.
*
* See e.g. [the CSS Color Module](https://www.w3.org/TR/css-color-4/#predefined-sRGB-linear)
* for details about this colorstate.
*
* Returns: the color state object for linearized sRGB
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_srgb_linear (void)
{
return GDK_COLOR_STATE_SRGB_LINEAR;
}
/**
* gdk_color_state_get_rec2100_pq:
*
* Returns the color state object representing the rec2100-pq color space.
*
* This color state uses the primaries defined by BT.2020-2 and BT.2100-0 and the transfer
* function defined by SMPTE ST 2084 and BT.2100-2.
*
* It is equivalent to the [Cicp](class.CicpParams.html) tuple 9/16/0/1.
*
* See e.g. [the CSS HDR Module](https://drafts.csswg.org/css-color-hdr/#valdef-color-rec2100-pq)
* for details about this colorstate.
*
* Returns: the color state object for rec2100-pq
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_rec2100_pq (void)
{
return GDK_COLOR_STATE_REC2100_PQ;
}
/**
* gdk_color_state_get_rec2100_linear:
*
* Returns the color state object representing the linear rec2100 color space.
*
* This color state uses the primaries defined by BT.2020-2 and BT.2100-0 and a linear
* transfer function.
*
* It is equivalent to the [Cicp](class.CicpParams.html) tuple 9/8/0/1.
*
* See e.g. [the CSS HDR Module](https://drafts.csswg.org/css-color-hdr/#valdef-color-rec2100-linear)
* for details about this colorstate.
*
* Returns: the color state object for linearized rec2100
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_rec2100_linear (void)
{
return GDK_COLOR_STATE_REC2100_LINEAR;
}
/**
* gdk_color_state_equal:
* @self: a `GdkColorState`
* @other: another `GdkColorStatee`
*
* Compares two `GdkColorStates` for equality.
*
* Note that this function is not guaranteed to be perfect and two objects
* describing the same color state may compare not equal. However, different
* color states will never compare equal.
*
* Returns: %TRUE if the two color states compare equal
*
* Since: 4.16
*/
gboolean
(gdk_color_state_equal) (GdkColorState *self,
GdkColorState *other)
{
return _gdk_color_state_equal (self, other);
}
/**
* gdk_color_state_create_cicp_params:
* @self: a `GdkColorState`
*
* Create a [class@Gdk.CicpParams] representing the colorstate.
*
* It is not guaranteed that every `GdkColorState` can be
* represented with Cicp parameters. If that is the case,
* this function returns `NULL`.
*
* Returns: (transfer full) (nullable): A new [class@Gdk.CicpParams]
*
* Since: 4.16
*/
GdkCicpParams *
gdk_color_state_create_cicp_params (GdkColorState *self)
{
const GdkCicp *cicp = gdk_color_state_get_cicp (self);
if (cicp)
return gdk_cicp_params_new_for_cicp (cicp);
return NULL;
}
/* }}} */
/* {{{ Conversion functions */
typedef float (* GdkTransferFunc) (float v);
typedef const float GdkColorMatrix[9];
#define IDENTITY ((float*)0)
#define NONE ((GdkTransferFunc)0)
#define TRANSFORM(name, eotf, matrix, oetf) \
static void \
name (GdkColorState *self, \
float (*values)[4], \
gsize n_values) \
{ \
for (gsize i = 0; i < n_values; i++) \
{ \
if (eotf != NONE) \
{ \
values[i][0] = eotf (values[i][0]); \
values[i][1] = eotf (values[i][1]); \
values[i][2] = eotf (values[i][2]); \
} \
if (matrix != IDENTITY) \
{ \
float res[3]; \
res[0] = matrix[0] * values[i][0] + matrix[1] * values[i][1] + matrix[2] * values[i][2]; \
res[1] = matrix[3] * values[i][0] + matrix[4] * values[i][1] + matrix[5] * values[i][2]; \
res[2] = matrix[6] * values[i][0] + matrix[7] * values[i][1] + matrix[8] * values[i][2]; \
values[i][0] = res[0]; \
values[i][1] = res[1]; \
values[i][2] = res[2]; \
} \
if (oetf != NONE) \
{ \
values[i][0] = oetf (values[i][0]); \
values[i][1] = oetf (values[i][1]); \
values[i][2] = oetf (values[i][2]); \
} \
} \
}
TRANSFORM(gdk_default_srgb_to_srgb_linear, srgb_eotf, IDENTITY, NONE);
TRANSFORM(gdk_default_srgb_linear_to_srgb, NONE, IDENTITY, srgb_oetf)
TRANSFORM(gdk_default_rec2100_pq_to_rec2100_linear, pq_eotf, IDENTITY, NONE)
TRANSFORM(gdk_default_rec2100_linear_to_rec2100_pq, NONE, IDENTITY, pq_oetf)
TRANSFORM(gdk_default_srgb_linear_to_rec2100_linear, NONE, srgb_to_rec2020, NONE)
TRANSFORM(gdk_default_rec2100_linear_to_srgb_linear, NONE, rec2020_to_srgb, NONE)
TRANSFORM(gdk_default_srgb_to_rec2100_linear, srgb_eotf, srgb_to_rec2020, NONE)
TRANSFORM(gdk_default_rec2100_pq_to_srgb_linear, pq_eotf, rec2020_to_srgb, NONE)
TRANSFORM(gdk_default_srgb_linear_to_rec2100_pq, NONE, srgb_to_rec2020, pq_oetf)
TRANSFORM(gdk_default_rec2100_linear_to_srgb, NONE, rec2020_to_srgb, srgb_oetf)
TRANSFORM(gdk_default_srgb_to_rec2100_pq, srgb_eotf, srgb_to_rec2020, pq_oetf)
TRANSFORM(gdk_default_rec2100_pq_to_srgb, pq_eotf, rec2020_to_srgb, srgb_oetf)
/* }}} */
/* {{{ Default implementation */
/* {{{ Vfuncs */
static gboolean
gdk_default_color_state_equal (GdkColorState *self,
GdkColorState *other)
{
return self == other;
}
static const char *
gdk_default_color_state_get_name (GdkColorState *color_state)
{
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
return self->name;
}
static GdkColorState *
gdk_default_color_state_get_no_srgb_tf (GdkColorState *color_state)
{
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
return self->no_srgb;
}
static GdkFloatColorConvert
gdk_default_color_state_get_convert_to (GdkColorState *color_state,
GdkColorState *target)
{
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
if (GDK_IS_DEFAULT_COLOR_STATE (target))
return self->convert_to[GDK_DEFAULT_COLOR_STATE_ID (target)];
return NULL;
}
static GdkFloatColorConvert
gdk_default_color_state_get_convert_from (GdkColorState *color_state,
GdkColorState *source)
{
/* This is ok because the default-to-default conversion functions
* don't use the passed colorstate at all.
*/
return gdk_default_color_state_get_convert_to (source, color_state);
}
static const GdkCicp *
gdk_default_color_state_get_cicp (GdkColorState *color_state)
{
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
return &self->cicp;
}
/* }}} */
static const
GdkColorStateClass GDK_DEFAULT_COLOR_STATE_CLASS = {
.free = NULL, /* crash here if this ever happens */
.equal = gdk_default_color_state_equal,
.get_name = gdk_default_color_state_get_name,
.get_no_srgb_tf = gdk_default_color_state_get_no_srgb_tf,
.get_convert_to = gdk_default_color_state_get_convert_to,
.get_convert_from = gdk_default_color_state_get_convert_from,
.get_cicp = gdk_default_color_state_get_cicp,
};
GdkDefaultColorState gdk_default_color_states[] = {
[GDK_COLOR_STATE_ID_SRGB] = {
.parent = {
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
.ref_count = 0,
.depth = GDK_MEMORY_U8_SRGB,
.rendering_color_state = GDK_COLOR_STATE_SRGB_LINEAR,
},
.name = "srgb",
.no_srgb = GDK_COLOR_STATE_SRGB_LINEAR,
.convert_to = {
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_srgb_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_srgb_to_rec2100_pq,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_srgb_to_rec2100_linear,
},
.cicp = { 1, 13, 0, 1 },
},
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = {
.parent = {
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
.ref_count = 0,
.depth = GDK_MEMORY_U8,
.rendering_color_state = GDK_COLOR_STATE_SRGB_LINEAR,
},
.name = "srgb-linear",
.no_srgb = NULL,
.convert_to = {
[GDK_COLOR_STATE_ID_SRGB] = gdk_default_srgb_linear_to_srgb,
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_srgb_linear_to_rec2100_pq,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_srgb_linear_to_rec2100_linear,
},
.cicp = { 1, 8, 0, 1 },
},
[GDK_COLOR_STATE_ID_REC2100_PQ] = {
.parent = {
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
.ref_count = 0,
.depth = GDK_MEMORY_FLOAT16,
.rendering_color_state = GDK_COLOR_STATE_REC2100_LINEAR,
},
.name = "rec2100-pq",
.no_srgb = NULL,
.convert_to = {
[GDK_COLOR_STATE_ID_SRGB] = gdk_default_rec2100_pq_to_srgb,
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_rec2100_pq_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_rec2100_pq_to_rec2100_linear,
},
.cicp = { 9, 16, 0, 1 },
},
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = {
.parent = {
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
.ref_count = 0,
.depth = GDK_MEMORY_FLOAT16,
.rendering_color_state = GDK_COLOR_STATE_REC2100_LINEAR,
},
.name = "rec2100-linear",
.no_srgb = NULL,
.convert_to = {
[GDK_COLOR_STATE_ID_SRGB] = gdk_default_rec2100_linear_to_srgb,
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_rec2100_linear_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_rec2100_linear_to_rec2100_pq,
},
.cicp = { 9, 8, 0, 1 },
},
};
/* }}} */
/* {{{ Cicp implementation */
typedef struct _GdkCicpColorState GdkCicpColorState;
struct _GdkCicpColorState
{
GdkColorState parent;
GdkColorState *no_srgb;
const char *name;
GdkTransferFunc eotf;
GdkTransferFunc oetf;
float *to_srgb;
float *to_rec2020;
float *from_srgb;
float *from_rec2020;
GdkCicp cicp;
};
/* {{{ Conversion functions */
#define cicp ((GdkCicpColorState *)self)
TRANSFORM(gdk_cicp_to_srgb, cicp->eotf, cicp->to_srgb, srgb_oetf)
TRANSFORM(gdk_cicp_to_srgb_linear, cicp->eotf, cicp->to_srgb, NONE)
TRANSFORM(gdk_cicp_to_rec2100_pq, cicp->eotf, cicp->to_rec2020, pq_oetf)
TRANSFORM(gdk_cicp_to_rec2100_linear, cicp->eotf, cicp->to_rec2020, NONE)
TRANSFORM(gdk_cicp_from_srgb, srgb_eotf, cicp->from_srgb, cicp->oetf)
TRANSFORM(gdk_cicp_from_srgb_linear, NONE, cicp->from_srgb, cicp->oetf)
TRANSFORM(gdk_cicp_from_rec2100_pq, pq_eotf, cicp->from_rec2020, cicp->oetf)
TRANSFORM(gdk_cicp_from_rec2100_linear, NONE, cicp->from_rec2020, cicp->oetf)
#undef cicp
/* }}} */
/* }}} */
/* {{{ Vfuncs */
static void
gdk_cicp_color_state_free (GdkColorState *cs)
{
GdkCicpColorState *self = (GdkCicpColorState *) cs;
if (self->no_srgb)
gdk_color_state_unref (self->no_srgb);
g_free (self->to_srgb);
g_free (self->to_rec2020);
g_free (self->from_srgb);
g_free (self->from_rec2020);
g_free (self);
}
static gboolean
gdk_cicp_color_state_equal (GdkColorState *self,
GdkColorState *other)
{
GdkCicpColorState *cs1 = (GdkCicpColorState *) self;
GdkCicpColorState *cs2 = (GdkCicpColorState *) other;
return gdk_cicp_equal (&cs1->cicp, &cs2->cicp);
}
static const char *
gdk_cicp_color_state_get_name (GdkColorState *self)
{
GdkCicpColorState *cs = (GdkCicpColorState *) self;
return cs->name;
}
static GdkColorState *
gdk_cicp_color_state_get_no_srgb_tf (GdkColorState *self)
{
GdkCicpColorState *cs = (GdkCicpColorState *) self;
return cs->no_srgb;
}
static GdkFloatColorConvert
gdk_cicp_color_state_get_convert_to (GdkColorState *self,
GdkColorState *target)
{
if (!GDK_IS_DEFAULT_COLOR_STATE (target))
return NULL;
switch (GDK_DEFAULT_COLOR_STATE_ID (target))
{
case GDK_COLOR_STATE_ID_SRGB:
return gdk_cicp_to_srgb;
case GDK_COLOR_STATE_ID_SRGB_LINEAR:
return gdk_cicp_to_srgb_linear;
case GDK_COLOR_STATE_ID_REC2100_PQ:
return gdk_cicp_to_rec2100_pq;
case GDK_COLOR_STATE_ID_REC2100_LINEAR:
return gdk_cicp_to_rec2100_linear;
case GDK_COLOR_STATE_N_IDS:
default:
g_assert_not_reached ();
}
return NULL;
}
static GdkFloatColorConvert
gdk_cicp_color_state_get_convert_from (GdkColorState *self,
GdkColorState *source)
{
if (!GDK_IS_DEFAULT_COLOR_STATE (source))
return NULL;
switch (GDK_DEFAULT_COLOR_STATE_ID (source))
{
case GDK_COLOR_STATE_ID_SRGB:
return gdk_cicp_from_srgb;
case GDK_COLOR_STATE_ID_SRGB_LINEAR:
return gdk_cicp_from_srgb_linear;
case GDK_COLOR_STATE_ID_REC2100_PQ:
return gdk_cicp_from_rec2100_pq;
case GDK_COLOR_STATE_ID_REC2100_LINEAR:
return gdk_cicp_from_rec2100_linear;
case GDK_COLOR_STATE_N_IDS:
default:
g_assert_not_reached ();
}
return NULL;
}
static const GdkCicp *
gdk_cicp_color_state_get_cicp (GdkColorState *color_state)
{
GdkCicpColorState *self = (GdkCicpColorState *) color_state;
return &self->cicp;
}
/* }}} */
static const
GdkColorStateClass GDK_CICP_COLOR_STATE_CLASS = {
.free = gdk_cicp_color_state_free,
.equal = gdk_cicp_color_state_equal,
.get_name = gdk_cicp_color_state_get_name,
.get_no_srgb_tf = gdk_cicp_color_state_get_no_srgb_tf,
.get_convert_to = gdk_cicp_color_state_get_convert_to,
.get_convert_from = gdk_cicp_color_state_get_convert_from,
.get_cicp = gdk_cicp_color_state_get_cicp,
};
static inline float *
multiply (float res[9],
const float m1[9],
const float m2[9])
{
#define IDX(i,j) 3*i+j
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
res[IDX(i,j)] = m1[IDX(i,0)] * m2[IDX(0,j)]
+ m1[IDX(i,1)] * m2[IDX(1,j)]
+ m1[IDX(i,2)] * m2[IDX(2,j)];
return res;
}
GdkColorState *
gdk_color_state_new_for_cicp (const GdkCicp *cicp,
GError **error)
{
GdkCicpColorState *self;
GdkTransferFunc eotf;
GdkTransferFunc oetf;
gconstpointer to_xyz;
gconstpointer from_xyz;
if (cicp->range == GDK_CICP_RANGE_NARROW || cicp->matrix_coefficients != 0)
{
g_set_error (error,
G_IO_ERROR, G_IO_ERROR_FAILED,
_("cicp: Narrow range or YUV not supported"));
return NULL;
}
if (cicp->color_primaries == 2 ||
cicp->transfer_function == 2 ||
cicp->matrix_coefficients == 2)
{
g_set_error (error,
G_IO_ERROR, G_IO_ERROR_FAILED,
_("cicp: Unspecified parameters not supported"));
return NULL;
}
for (guint i = 0; i < GDK_COLOR_STATE_N_IDS; i++)
{
if (gdk_cicp_equivalent (cicp, &gdk_default_color_states[i].cicp))
return (GdkColorState *) &gdk_default_color_states[i];
}
switch (cicp->transfer_function)
{
case 1:
case 6:
case 14:
case 15:
eotf = bt709_eotf;
oetf = bt709_oetf;
break;
case 4:
eotf = gamma22_eotf;
oetf = gamma22_oetf;
break;
case 5:
eotf = gamma28_eotf;
oetf = gamma28_oetf;
break;
case 8:
eotf = NONE;
oetf = NONE;
break;
case 13:
eotf = srgb_eotf;
oetf = srgb_oetf;
break;
case 16:
eotf = pq_eotf;
oetf = pq_oetf;
break;
case 18:
eotf = hlg_eotf;
oetf = hlg_oetf;
break;
default:
g_set_error (error,
G_IO_ERROR, G_IO_ERROR_FAILED,
_("cicp: Transfer function %u not supported"),
cicp->transfer_function);
return NULL;
}
switch (cicp->color_primaries)
{
case 1:
to_xyz = srgb_to_xyz;
from_xyz = xyz_to_srgb;
break;
case 5:
to_xyz = pal_to_xyz;
from_xyz = xyz_to_pal;
break;
case 6:
to_xyz = ntsc_to_xyz;
from_xyz = xyz_to_ntsc;
break;
case 9:
to_xyz = rec2020_to_xyz;
from_xyz = xyz_to_rec2020;
break;
case 12:
to_xyz = p3_to_xyz;
from_xyz = xyz_to_p3;
break;
default:
g_set_error (error,
G_IO_ERROR, G_IO_ERROR_FAILED,
_("cicp: Color primaries %u not supported"),
cicp->color_primaries);
return NULL;
}
self = g_new0 (GdkCicpColorState, 1);
self->parent.klass = &GDK_CICP_COLOR_STATE_CLASS;
self->parent.ref_count = 1;
/* sRGB is special-cased by being a default colorstate */
self->parent.rendering_color_state = GDK_COLOR_STATE_REC2100_LINEAR;
self->parent.depth = GDK_MEMORY_FLOAT16;
memcpy (&self->cicp, cicp, sizeof (GdkCicp));
self->eotf = eotf;
self->oetf = oetf;
self->to_srgb = multiply (g_new (float, 9), xyz_to_srgb, to_xyz);
self->to_rec2020 = multiply (g_new (float, 9), xyz_to_rec2020, to_xyz);
self->from_srgb = multiply (g_new (float, 9), from_xyz, srgb_to_xyz);
self->from_rec2020 = multiply (g_new (float, 9), from_xyz, rec2020_to_xyz);
self->name = g_strdup_printf ("cicp-%u/%u/%u/%u",
cicp->color_primaries,
cicp->transfer_function,
cicp->matrix_coefficients,
cicp->range);
if (cicp->transfer_function == 13)
{
GdkCicp no_srgb;
memcpy (&no_srgb, cicp, sizeof (GdkCicp));
no_srgb.transfer_function = 8;
self->no_srgb = gdk_color_state_new_for_cicp (&no_srgb, NULL);
}
return (GdkColorState *) self;
}
/* }}} */
/* {{{ Private API */
/*<private>
* gdk_color_state_get_name:
* @self: a colorstate
*
* Returns the name of @self.
*
* This is *not* a translated, user-visible string.
*
* Returns: (transfer none): a name for representing the color state
* in diagnostic output
*/
const char *
gdk_color_state_get_name (GdkColorState *self)
{
return self->klass->get_name (self);
}
/*<private>
* gdk_color_state_get_no_srgb_tf:
* @self: a colorstate
*
* This function checks if the colorstate uses an sRGB transfer function
* as final operation. In that case, it is suitable for use with GL_SRGB
* (and the Vulkan equivalents).
*
* If it is suitable, the colorstate without the transfer function is
* returned. Otherwise, this function returns NULL.
*
* Returns: (transfer none): the colorstate without sRGB transfer function.
**/
GdkColorState *
gdk_color_state_get_no_srgb_tf (GdkColorState *self)
{
if (!GDK_DEBUG_CHECK (LINEAR))
return FALSE;
return self->klass->get_no_srgb_tf (self);
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */

62
gdk/gdkcolorstate.h Normal file
View File

@@ -0,0 +1,62 @@
/* gdkcolorstate.h
*
* Copyright 2024 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdktypes.h>
G_BEGIN_DECLS
#define GDK_TYPE_COLOR_STATE (gdk_color_state_get_type ())
GDK_AVAILABLE_IN_4_16
GType gdk_color_state_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_ref (GdkColorState *self);
GDK_AVAILABLE_IN_4_16
void gdk_color_state_unref (GdkColorState *self);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_srgb (void);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_srgb_linear (void);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_rec2100_pq (void);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_rec2100_linear (void);
GDK_AVAILABLE_IN_4_16
gboolean gdk_color_state_equal (GdkColorState *self,
GdkColorState *other);
GDK_AVAILABLE_IN_4_16
GdkCicpParams *gdk_color_state_create_cicp_params (GdkColorState *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkColorState, gdk_color_state_unref);
G_END_DECLS

220
gdk/gdkcolorstateprivate.h Normal file
View File

@@ -0,0 +1,220 @@
#pragma once
#include "gdkcolorstate.h"
#include "gdkcicpparamsprivate.h"
#include "gdkdebugprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkrgba.h"
typedef enum
{
GDK_COLOR_STATE_ID_SRGB,
GDK_COLOR_STATE_ID_SRGB_LINEAR,
GDK_COLOR_STATE_ID_REC2100_PQ,
GDK_COLOR_STATE_ID_REC2100_LINEAR,
GDK_COLOR_STATE_N_IDS
} GdkColorStateId;
typedef struct _GdkColorStateClass GdkColorStateClass;
struct _GdkColorState
{
const GdkColorStateClass *klass;
gatomicrefcount ref_count;
GdkMemoryDepth depth;
GdkColorState *rendering_color_state;
};
/* Note: self may be the source or the target colorstate */
typedef void (* GdkFloatColorConvert)(GdkColorState *self,
float (*values)[4],
gsize n_values);
struct _GdkColorStateClass
{
void (* free) (GdkColorState *self);
gboolean (* equal) (GdkColorState *self,
GdkColorState *other);
const char * (* get_name) (GdkColorState *self);
GdkColorState * (* get_no_srgb_tf) (GdkColorState *self);
GdkFloatColorConvert (* get_convert_to) (GdkColorState *self,
GdkColorState *target);
GdkFloatColorConvert (* get_convert_from) (GdkColorState *self,
GdkColorState *source);
const GdkCicp * (* get_cicp) (GdkColorState *self);
};
typedef struct _GdkDefaultColorState GdkDefaultColorState;
struct _GdkDefaultColorState
{
GdkColorState parent;
const char *name;
GdkColorState *no_srgb;
GdkFloatColorConvert convert_to[GDK_COLOR_STATE_N_IDS];
GdkCicp cicp;
};
extern GdkDefaultColorState gdk_default_color_states[GDK_COLOR_STATE_N_IDS];
#define GDK_COLOR_STATE_SRGB ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB])
#define GDK_COLOR_STATE_SRGB_LINEAR ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB_LINEAR])
#define GDK_COLOR_STATE_REC2100_PQ ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_REC2100_PQ])
#define GDK_COLOR_STATE_REC2100_LINEAR ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_REC2100_LINEAR])
#define GDK_IS_DEFAULT_COLOR_STATE(c) ((GdkDefaultColorState *) (c) >= &gdk_default_color_states[0] && \
(GdkDefaultColorState *) (c) < &gdk_default_color_states[GDK_COLOR_STATE_N_IDS])
#define GDK_DEFAULT_COLOR_STATE_ID(c) ((GdkColorStateId) (((GdkDefaultColorState *) c) - gdk_default_color_states))
const char * gdk_color_state_get_name (GdkColorState *color_state);
GdkColorState * gdk_color_state_get_no_srgb_tf (GdkColorState *self);
GdkColorState * gdk_color_state_new_for_cicp (const GdkCicp *cicp,
GError **error);
static inline GdkColorState *
gdk_color_state_get_rendering_color_state (GdkColorState *self,
gboolean srgb)
{
if (srgb)
{
self = gdk_color_state_get_no_srgb_tf (self);
g_assert (self);
}
if (GDK_DEBUG_CHECK (HDR))
self = GDK_COLOR_STATE_REC2100_PQ;
if (!GDK_DEBUG_CHECK (LINEAR))
return self;
return self->rendering_color_state;
}
static inline GdkMemoryDepth
gdk_color_state_get_depth (GdkColorState *self)
{
if (!GDK_DEBUG_CHECK (LINEAR) && self->depth == GDK_MEMORY_U8_SRGB)
return GDK_MEMORY_U8;
return self->depth;
}
static inline GdkColorState *
gdk_color_state_get_by_id (GdkColorStateId id)
{
return (GdkColorState *) &gdk_default_color_states[id];
}
#define gdk_color_state_ref(self) _gdk_color_state_ref (self)
static inline GdkColorState *
_gdk_color_state_ref (GdkColorState *self)
{
if (GDK_IS_DEFAULT_COLOR_STATE (self))
return self;
g_atomic_ref_count_inc (&self->ref_count);
return self;
}
#define gdk_color_state_unref(self) _gdk_color_state_unref (self)
static inline void
_gdk_color_state_unref (GdkColorState *self)
{
if (GDK_IS_DEFAULT_COLOR_STATE (self))
return;
if (g_atomic_ref_count_dec (&self->ref_count))
self->klass->free (self);
}
#define gdk_color_state_equal(a,b) _gdk_color_state_equal ((a), (b))
static inline gboolean
_gdk_color_state_equal (GdkColorState *self,
GdkColorState *other)
{
if (self == other)
return TRUE;
if (self->klass != other->klass)
return FALSE;
return self->klass->equal (self, other);
}
/* Note: the functions returned from this expect the source
* color state to be passed as self
*/
static inline GdkFloatColorConvert
gdk_color_state_get_convert_to (GdkColorState *self,
GdkColorState *target)
{
return self->klass->get_convert_to (self, target);
}
/* Note: the functions returned from this expect the target
* color state to be passed as self
*/
static inline GdkFloatColorConvert
gdk_color_state_get_convert_from (GdkColorState *self,
GdkColorState *source)
{
return self->klass->get_convert_from (self, source);
}
static inline const GdkCicp *
gdk_color_state_get_cicp (GdkColorState *self)
{
return self->klass->get_cicp (self);
}
static inline void
gdk_color_state_convert_color (GdkColorState *src_cs,
const float src[4],
GdkColorState *dest_cs,
float dest[4])
{
GdkFloatColorConvert convert = NULL;
GdkFloatColorConvert convert2 = NULL;
memcpy (dest, src, sizeof (float) * 4);
if (gdk_color_state_equal (src_cs, dest_cs))
return;
convert = gdk_color_state_get_convert_to (src_cs, dest_cs);
if (!convert)
convert2 = gdk_color_state_get_convert_from (dest_cs, src_cs);
if (!convert && !convert2)
{
GdkColorState *connection = GDK_COLOR_STATE_REC2100_LINEAR;
convert = gdk_color_state_get_convert_to (src_cs, connection);
convert2 = gdk_color_state_get_convert_from (dest_cs, connection);
}
if (convert)
convert (src_cs, (float(*)[4]) dest, 1);
if (convert2)
convert2 (dest_cs, (float(*)[4]) dest, 1);
}
static inline void
gdk_color_state_from_rgba (GdkColorState *self,
const GdkRGBA *rgba,
float out_color[4])
{
gdk_color_state_convert_color (GDK_COLOR_STATE_SRGB,
(const float *) rgba,
self,
out_color);
}

View File

@@ -533,16 +533,13 @@ deserialize_not_found (GdkContentDeserializer *deserializer)
* @type: the GType to deserialize from
* @io_priority: the I/O priority of the operation
* @cancellable: (nullable): optional `GCancellable` object
* @callback: (scope async): callback to call when the operation is done
* @user_data: (closure): data to pass to the callback function
* @callback: (scope async) (closure user_data): callback to call when the operation is done
* @user_data: data to pass to the callback function
*
* Read content from the given input stream and deserialize it, asynchronously.
*
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
* indicate a higher priority.
*
* When the operation is finished, @callback will be called. You must then
* call [func@Gdk.content_deserialize_finish] to get the result of the operation.
*/
void
gdk_content_deserialize_async (GInputStream *stream,

View File

@@ -273,16 +273,12 @@ gdk_content_provider_content_changed (GdkContentProvider *provider)
* @stream: the `GOutputStream` to write to
* @io_priority: I/O priority of the request.
* @cancellable: (nullable): optional `GCancellable` object, %NULL to ignore.
* @callback: (scope async): callback to call when the request is satisfied
* @user_data: (closure): the data to pass to callback function
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
* @user_data: the data to pass to callback function
*
* Asynchronously writes the contents of @provider to @stream in the given
* @mime_type.
*
* When the operation is finished @callback will be called. You must then call
* [method@Gdk.ContentProvider.write_mime_type_finish] to get the result
* of the operation.
*
* The given mime type does not need to be listed in the formats returned by
* [method@Gdk.ContentProvider.ref_formats]. However, if the given `GType` is
* not supported, `G_IO_ERROR_NOT_SUPPORTED` will be reported.

Some files were not shown because too many files have changed in this diff Show More