Compare commits

...

914 Commits

Author SHA1 Message Date
Matthias Clasen
a71e97fbe8 Start an image tool
This is meant to provide a convenient way to produce images in
specific color states and memory formats.
2024-06-22 17:04:28 -04:00
Matthias Clasen
a5a3ea73d3 Add tests for colorstate saving
Make sure that we successfully round-trip the color state
information through the image formats that we support for
writing, regardless of memory format.
2024-06-22 13:42:34 -04:00
Matthias Clasen
7ae4b41cb5 pixbuf: Add color state support
When creating a GdkTexture from a GdkPixbuf, see if it has an
icc profile attached, and if so, use it.
2024-06-22 13:42:34 -04:00
Matthias Clasen
67992454a7 tiff: Add color state support
When loading or saving tiff files, translate between embedded
icc profiles and color state objects.
2024-06-22 13:42:33 -04:00
Benjamin Otte
5c3bb62ca4 jpeg: Add color state support
When loading or saving jpeg files, translate between embedded
icc profiles and color state objects.
2024-06-22 13:42:33 -04:00
Matthias Clasen
2f032ad0e1 Tell libpng not to poke icc profiles
We do that outselves.
2024-06-22 13:42:33 -04:00
Benjamin Otte
88613204eb png: Add color state support
When loading or saving png files, translate between embedded
icc profiles or cicp data and color state objects.
2024-06-22 13:21:33 -04:00
Matthias Clasen
ead70de246 Add GdkDmabufTextureBuilder:color-state
Add an api that lets us associate a color state with dmabuf textures
when we turn them into a GdkTexture object.
2024-06-22 13:21:33 -04:00
Matthias Clasen
0136696e34 Add GdkGLTextureBuilder:color-state
Add an api that lets us associate a color state with GL textures
when we turn them into a GdkTexture object.
2024-06-22 13:21:33 -04:00
Matthias Clasen
400ae52809 Add gdk_memory_texture_new_with_color_state
Add an api that lets us associate a color state with image
data when we wrap it in a GdkTexture object.
2024-06-22 13:21:33 -04:00
Matthias Clasen
2c2d868366 colorstate: Add serialization
Allow to save and load cicp and icc. We still only support
srgb and srgb-linear, though. To avoid dragging in lcms at
this stage, simply include the srgb and srgb-linear icc
profiles as resources. Keep this private api for now.
2024-06-22 13:21:33 -04:00
Matthias Clasen
ca6fe07b27 gl: Do linear compositing 2024-06-22 13:19:57 -04:00
Matthias Clasen
bdb6552408 gpu: Use stem darkening for linear composited glyphs
This involves tweaking a freetype driver property
directly, since cairo font options don't cover this.

So the code is a bit ugly, but it does make text
appear better, in particular at small sizes.

See https://freetype.org/freetype2/docs/hinting/text-rendering-general.html
2024-06-22 13:19:57 -04:00
Matthias Clasen
7626f8262d cairo: Use stem darkening for glyphs
This involves tweaking a freetype driver property
directly, since cairo font options don't cover this.

So the code is a bit ugly, but it does make text
appear better, in particular at small sizes.

See https://freetype.org/freetype2/docs/hinting/text-rendering-general.html
2024-06-22 13:19:57 -04:00
Matthias Clasen
05e470f2cd cairo: Convert the contents back to srgb
We let cairo operate in linear srgb (by giving it all colors and
texture input in linear srgb), and so we need to convert the
results back to srgb in the end.
2024-06-22 13:19:57 -04:00
Matthias Clasen
c5883853d7 cairo: Convert textures to srgb-linear
Use the new gdk_memort_format_convert_color_state api to
convert textures to linear srgb before passing them to
cairo.
2024-06-22 13:19:57 -04:00
Matthias Clasen
2250761474 cairo: Convert colors to srgb-linear 2024-06-22 13:19:57 -04:00
Matthias Clasen
d35df199b0 gdk: Add a fast-path
Special case u8 RGBA8p, which is the common case.
2024-06-22 13:19:57 -04:00
Matthias Clasen
87f9c26414 gdk: Add gdk_memory_format_convert_color_state
This allows in-place color state conversions.
2024-06-22 13:19:57 -04:00
Matthias Clasen
d2cc2b6ea8 Temporarily disable gsk compare test variant
Too much failure.
2024-06-22 13:19:57 -04:00
Matthias Clasen
f73a34e71a 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-06-22 13:19:57 -04:00
Matthias Clasen
b5f5e6e34b gl: Enable GL_FRAMEBUFFER_SRGB
It seems that we need this for GL_SRGB to work in GLX.
2024-06-22 13:19:57 -04:00
Matthias Clasen
7f71443d6b gdk: Use the vulkan srgb image format
We want to do compositing in a linear colorspace, and this
will take care of the 'convert back to srgb in the end' step.
2024-06-22 13:19:57 -04:00
Matthias Clasen
bb130960e2 gdk: Create our egl surface with srgb colorspace
We want to do our compositing in a linear colorspace, and the
EXT_KHR_gl_colorspace extension helps for that. We don't hard-
require it, since it isn't super-common in the wild (37%).

If we have the extension, create our egl surface with the
srgb colorspace, and report that face in gdk_surface_gl_is_srgb().
2024-06-22 13:19:57 -04:00
Matthias Clasen
0ebc7660a2 gpu: Add debug spew 2024-06-22 13:19:57 -04:00
Matthias Clasen
fe885d9f41 gpu: Make compositing happen in linear space
For now, we always deliver our framebuffer in srgb, and we always
want to composite in srgb-linear. If GL/Vulkan have provided us
with a back buffer that does this conversion on its own, we just
use it. The is expected to work at least for cases where we use
an u8 frame buffer.

Otherwise, we pass the target and compositing color states down
to where we call into the node processor to process nodes, create
an offscreen for rendering to, and then do manual color conversion
afterwards to put the result into the frame buffer.
2024-06-22 13:19:57 -04:00
Matthias Clasen
3076cd9a47 gpu: Convert textures to the right color state
Add function to convert an image from one color state to another,
and call it whenever we upload a texture.
2024-06-22 13:19:57 -04:00
Matthias Clasen
b710e72e1e gpu: Return color state when uploading textures
We want to allow for the possibility that we can automatically
convert from srgb to srgb-linear by picking the right image
format, so we need the upload operation to return the proper
color state for the image that it created.

For now, we do nothing with the returned information.
2024-06-22 13:19:57 -04:00
Matthias Clasen
c6bb894507 gpu: Pass color state to upload ops
This is so we can make decisions about the kind of image to create
based on the kind of colorstate we are going to upload.
2024-06-22 13:19:57 -04:00
Matthias Clasen
a6351ea8be gpu: track color state in the texture cache
Keep the color state information around for cached images.

We keep up to two different images per texture - that is enough to
keep the original uploaded image and the one that has been converted
to the compositing colorstate.
2024-06-22 13:19:57 -04:00
Matthias Clasen
68e132d2c0 gpu: Pass linear colors to clear ops too
This was forgotten when colors were converted.
2024-06-22 13:19:57 -04:00
Matthias Clasen
dd79dd0a52 gpu: Pass colors in srgb-linear
GdkRGBA is defined to be in srgb. Since we want to do our
compositing in srgb-linear, convert the coors as we send
them to the shader.
2024-06-22 13:19:57 -04:00
Matthias Clasen
f7ff943d08 gpu: Pass compositing color states around
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.
2024-06-22 13:19:57 -04:00
Matthias Clasen
6f37b64e4c 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 an integer encoding the pair of color states.

For now, the only possible color states are srgb and srgb-linear.
2024-06-22 13:19:57 -04:00
Matthias Clasen
7f7b104438 gpu: Mark images that convert srgb
This is a special property that gpu images can have, that they
automatically convert between the linear srgb that the shaders
see, and the nonlinear srgb that the image is stored in.
2024-06-22 13:19:57 -04:00
Matthias Clasen
c76a22224b 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-06-22 13:19:57 -04:00
Matthias Clasen
531ca56a20 gdk: Add gdk_texture_get_color_state
This does not do anything yet, just return srgb.
2024-06-22 13:19:57 -04:00
Matthias Clasen
5eaba3b123 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-06-22 13:19:57 -04:00
Benjamin Otte
d697cce5b0 gdk: Allow querying GL SRGB formats
Nobody is using this yet.
2024-06-22 13:19:57 -04:00
Benjamin Otte
ccc646dda7 gdk: Allow querying Vulkan SRGB formats
Nobody is using this yet, this is just infrastructure.
2024-06-22 13:19:57 -04: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
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
Alexandre Franke
2ec9fc26d3 Update French translation 2024-03-19 13:06:37 +00:00
Matthias Clasen
c2d898d462 Merge branch 'fix-macos-typo' into 'main'
quartz: Fix a crash

See merge request GNOME/gtk!7059
2024-03-19 03:11:58 +00:00
Matthias Clasen
7c04231255 Merge branch 'macos-remove-shadows' into 'main'
macos: Drop shadow related code from macos backend

See merge request GNOME/gtk!7048
2024-03-19 02:38:38 +00:00
Arjan Molenaar
08216dcee9 macos: Drop shadow related code from macos backend 2024-03-19 02:38:37 +00:00
Matthias Clasen
9817df12ff quartz: Fix a crash
This was an oversight in 816f8807a3.
2024-03-18 21:51:24 -04:00
Matthias Clasen
5b0e8eb574 Merge branch 'fix-macos-typo' into 'main'
macos: Fix a typo in the appmenu handling code

See merge request GNOME/gtk!7055
2024-03-19 01:49:08 +00:00
Matthias Clasen
cecde85faa Merge branch 'drag-cursor-tweak' into 'main'
dnd: Use the default cursor during motion

Closes #6337 and #6511

See merge request GNOME/gtk!7058
2024-03-19 01:46:35 +00:00
Matthias Clasen
aa95b4f341 dnd: Use the default cursor during motion
When no action is selected, use the default cursor, and only
switch to one of the action-indicating cursors when we are over
a drop target.

Fixes: #6337
Fixes: #6511
2024-03-18 21:17:55 -04:00
Matthias Clasen
816f8807a3 macos: Fix a typo in the appmenu handling code
We were using APP_DATA in one place, and APP_MENU in the other.
Just stop using object data for this.
2024-03-18 18:49:55 -04:00
Martin
26d3c407b3 Update Slovenian translation 2024-03-18 17:36:52 +00:00
Matthias Clasen
a973e8ea8d Merge branch 'gl-offload-fixes' into 'main'
gl: Handle offloads in offscreen context better

Closes #6551

See merge request GNOME/gtk!7053
2024-03-18 15:22:22 +00:00
Matthias Clasen
b007597c58 Merge branch 'macos-application-demo' into 'main'
Revert "macos: fix weird menubar rendering."

Closes #6524

See merge request GNOME/gtk!7052
2024-03-18 14:40:45 +00:00
Matthias Clasen
1e83a44c93 gl: Handle offloads in offscreen context better
Back out of offloading below if we are in an offscreen context,
since the hole will get lost in the offscreen.

Fixes: #6551
2024-03-18 08:41:31 -04:00
Matthias Clasen
259ad83de9 macos: Fix up app menu support
We were forgetting to add the newly loaded app menu to the
combined menubar. Pointed out by Dominik Reichardt in #6524.

Fixes: #6524
2024-03-18 07:50:30 -04:00
Matthias Clasen
b4f5432d5a gtk4-demo: Clean up the application demo
This partially reverts ca1c570c21.
2024-03-17 22:29:22 -04:00
Matthias Clasen
4fe4523c49 Revert "macos: fix weird menubar rendering."
This reverts commit 75868dfee4.
2024-03-17 22:29:22 -04: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
817 changed files with 42791 additions and 14421 deletions

View File

@@ -445,9 +445,8 @@ reference:
--force-fallback-for=gdk-pixbuf,pango
-Dintrospection=enabled
-Ddocumentation=true
-Dgtk_doc=true
-Dgdk-pixbuf:gtk_doc=true
-Dpango:gtk_doc=true
-Dpango:documentation=true
-Dbuild-demos=false
-Dbuild-examples=false
-Dbuild-tests=false
@@ -460,6 +459,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

@@ -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
@@ -144,33 +144,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 +257,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).

262
NEWS
View File

@@ -1,6 +1,266 @@
Overview of Changes in 4.14.2, xx-xx-xxxx
Overview of Changes in 4.15.2, xx-xx-xxxx
=========================================
* GtkFileChooserWidget:
- Plug some memory leaks
- Make Ctrl-Shift-N create a new folder
* 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/)
* Accessibility:
- Avoid markup when reading labels
* GSK:
- Subset fonts when serializing node trees
* Wayland:
- Use xdg-dialog protocol for attached dialogs
* Windows:
- Build with UNICODE
* Debugging:
- Add GTK_DEBUG=css for warning about deprecated css syntax
* Tools:
- nodeparser: Add an extract command for data urls
* Deprecations:
- CSS Color functions shade(), lighter(), darker(), alpha(), mix()
* Translation updates:
Hebrew
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

@@ -125,7 +125,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

@@ -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;
}

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

@@ -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", n_items), 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);

View File

@@ -2,7 +2,7 @@
<interface>
<menu id="menubar">
<submenu>
<attribute name="label" translatable="yes">_Application</attribute>
<attribute name="label" translatable="yes">_File</attribute>
<section>
<item>
<attribute name="label" translatable="yes">_New</attribute>
@@ -33,7 +33,7 @@
</section>
</submenu>
<submenu>
<attribute name="label" translatable="yes">_File</attribute>
<attribute name="label" translatable="yes">_Preferences</attribute>
<section>
<item>
<attribute name="label" translatable="yes">_Prefer Dark Theme</attribute>

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

@@ -330,6 +330,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 +347,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

@@ -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]

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

@@ -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

@@ -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

@@ -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,11 +77,13 @@ 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",
]
content_images = [

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,39 @@ if get_option('documentation')
build_by_default: true,
install: true,
install_dir: docs_dir,
install_tag: 'doc',
)
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-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 +105,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

@@ -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

@@ -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

@@ -217,6 +217,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

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

@@ -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

@@ -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

@@ -122,6 +122,7 @@ static const GdkDebugKey gdk_debug_keys[] = {
{ "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" },
@@ -142,31 +143,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 +311,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 +345,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

@@ -30,6 +30,7 @@
#include <gdk/gdkcairo.h>
#include <gdk/gdkcairocontext.h>
#include <gdk/gdkclipboard.h>
#include <gdk/gdkcolorstate.h>
#include <gdk/gdkconfig.h>
#include <gdk/gdkcontentdeserializer.h>
#include <gdk/gdkcontentformats.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

View File

@@ -522,8 +522,6 @@ gdk_clipboard_get_content (GdkClipboard *clipboard)
*
* 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
@@ -638,9 +636,6 @@ gdk_clipboard_read_internal (GdkClipboard *clipboard,
* 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.
*/
@@ -834,9 +829,6 @@ gdk_clipboard_read_value_internal (GdkClipboard *clipboard,
* 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.
@@ -895,9 +887,6 @@ gdk_clipboard_read_value_finish (GdkClipboard *clipboard,
*
* 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.
@@ -960,9 +949,6 @@ gdk_clipboard_read_texture_finish (GdkClipboard *clipboard,
*
* 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.

355
gdk/gdkcolorstate.c Normal file
View File

@@ -0,0 +1,355 @@
/* 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 <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.
*
* 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.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_srgb_linear (void)
{
return GDK_COLOR_STATE_SRGB_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);
}
/*< private >
* gdk_color_state_new_from_icc_profile:
* @icc_profile: The ICC profiles given as a `GBytes`
* @error: Return location for an error
*
* Creates a new color state for the given ICC profile data.
*
* If the given ICC profile can not be represented as a
* [struct@Gdk.ColorState], `NULL` is returned and an error
* is raised.
*
* Returns: a new `GdkColorState` or %NULL on error
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_new_from_icc_profile (GBytes *icc_profile,
GError **error)
{
GBytes *bytes;
g_return_val_if_fail (icc_profile != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
bytes = g_resources_lookup_data ("/org/gtk/libgdk/icc/srgb.icc", 0, NULL);
if (g_bytes_equal (icc_profile, bytes))
{
g_bytes_unref (bytes);
return GDK_COLOR_STATE_SRGB;
}
bytes = g_resources_lookup_data ("/org/gtk/libgdk/icc/srgb-linear.icc", 0, NULL);
if (g_bytes_equal (icc_profile, bytes))
{
g_bytes_unref (bytes);
return GDK_COLOR_STATE_SRGB_LINEAR;
}
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
_("Failed to load ICC profile"));
return NULL;
}
/*< private >
* gdk_color_state_new_from_cicp_data:
* @color_primaries: the color primaries
* @transfer_characteristics: the transfer function
* @matrix_coefficients: the color matrix
* @full_range: whether the data is 'full-range'
* @error: Return location for an error
*
* Creates a new color state for the given CICP data.
*
* If the given CICP data can not be represented as a
* [struct@Gdk.ColorState], `NULL` is returned and an error
* is raised.
*
* See [CICP](https://en.wikipedia.org/wiki/Coding-independent_code_points)
* for more information about CICP.
*
* Returns: a new `GdkColorState` or %NULL on error
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_new_from_cicp_data (int color_primaries,
int transfer_characteristics,
int matrix_coefficients,
gboolean full_range)
{
if (color_primaries == 0 && transfer_characteristics == 13 &&
matrix_coefficients == 0 && full_range)
return GDK_COLOR_STATE_SRGB;
else if (color_primaries == 0 && transfer_characteristics == 8 &&
matrix_coefficients == 0 && full_range)
return GDK_COLOR_STATE_SRGB_LINEAR;
return NULL;
}
/*< private >
* gdk_color_state_save_to_icc_profile:
* @self: a `GdkColorState`
* @error: Return location for an error
*
* Saves the color state to an
* [ICC profile](https://en.wikipedia.org/wiki/ICC_profile).
*
* It may not be possible to represent a color state as ICC profile.
* In that case, @error will be set and %NULL will be returned.
*
* Returns: (nullable): A new `GBytes` containing the ICC profile
*
* Since: 4.16
*/
GBytes *
gdk_color_state_save_to_icc_profile (GdkColorState *self,
GError **error)
{
GBytes *bytes;
if (self == GDK_COLOR_STATE_SRGB)
{
bytes = g_resources_lookup_data ("/org/gtk/libgdk/icc/srgb.icc", 0, NULL);
g_assert (bytes != NULL);
}
else if (self == GDK_COLOR_STATE_SRGB_LINEAR)
{
bytes = g_resources_lookup_data ("/org/gtk/libgdk/icc/srgb-linear.icc", 0, NULL);
g_assert (bytes != NULL);
}
else
{
bytes = NULL;
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
_("ICC profile not supported for this color state"));
}
return bytes;
}
/*< private >
* gdk_color_state_save_to_cicp_data:
* @self: a `GdkColorState`
* @color_primaries: return location for color primaries
* @transfer_characteristics: return location for transfer characteristics
* @matrix_coefficients: return location for matrix_coefficients
* @full_range: return location for the full range flag
* @error: Return location for an error
*
* Saves the color state as CICP data.
*
* It may not be possible to represent a color state as CICP data.
* In that case, @error will be set and `FALSE` will be returned.
*
* See [CICP](https://en.wikipedia.org/wiki/Coding-independent_code_points)
* for more information about CICP.
*
* Returns: (nullable): `TRUE` if the out arguments were set
*
* Since: 4.16
*/
gboolean
gdk_color_state_save_to_cicp_data (GdkColorState *self,
int *color_primaries,
int *transfer_characteristics,
int *matrix_coefficients,
gboolean *full_range,
GError **error)
{
if (self == GDK_COLOR_STATE_SRGB)
{
*color_primaries = 0;
*transfer_characteristics = 13;
*matrix_coefficients = 0;
*full_range = TRUE;
return TRUE;
}
else if (self == GDK_COLOR_STATE_SRGB_LINEAR)
{
*color_primaries = 0;
*transfer_characteristics = 8;
*matrix_coefficients = 0;
*full_range = TRUE;
return TRUE;
}
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
_("This color state does not support CICP data"));
return FALSE;
}
/* }}} */
/* {{{ Default implementation */
const char *
gdk_color_state_get_name_from_id (GdkColorStateId id)
{
const char *names[] = {
"srgb", "srgb-linear",
};
return names[id];
}
GdkColorState gdk_default_color_states[] = {
{ NULL, 0 },
{ NULL, 0 },
};
/* }}} */
/* {{{ Private API */
const char *
gdk_color_state_get_name (GdkColorState *self)
{
if (GDK_IS_DEFAULT_COLOR_STATE (self))
{
switch (GDK_DEFAULT_COLOR_STATE_ID (self))
{
case GDK_COLOR_STATE_ID_SRGB: return "srgb";
case GDK_COLOR_STATE_ID_SRGB_LINEAR: return "srgb-linear";
default: g_assert_not_reached ();
}
}
return self->klass->get_name (self);
}
void
gdk_color_state_print (GdkColorState *self,
GString *string)
{
g_string_append (string, gdk_color_state_get_name (self));
}
GdkMemoryDepth
gdk_color_state_get_min_depth (GdkColorState *self)
{
if (self == GDK_COLOR_STATE_SRGB || self == GDK_COLOR_STATE_SRGB_LINEAR)
return GDK_MEMORY_U8;
return GDK_MEMORY_FLOAT16;
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */

50
gdk/gdkcolorstate.h Normal file
View File

@@ -0,0 +1,50 @@
/* 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
gboolean gdk_color_state_equal (GdkColorState *self,
GdkColorState *other);
G_END_DECLS

102
gdk/gdkcolorstateprivate.h Normal file
View File

@@ -0,0 +1,102 @@
#pragma once
#include "gdkcolorstate.h"
#include "gdkmemoryformatprivate.h"
typedef enum
{
GDK_COLOR_STATE_ID_SRGB,
GDK_COLOR_STATE_ID_SRGB_LINEAR,
} GdkColorStateId;
typedef struct _GdkColorStateClass GdkColorStateClass;
struct _GdkColorState
{
GdkColorStateClass *klass;
int ref_count;
};
struct _GdkColorStateClass
{
void (* free) (GdkColorState *self);
gboolean (* equal) (GdkColorState *self,
GdkColorState *other);
const char * (* get_name) (GdkColorState *self);
};
extern GdkColorState gdk_default_color_states[];
#define GDK_COLOR_STATE_SRGB (&gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB])
#define GDK_COLOR_STATE_SRGB_LINEAR (&gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB_LINEAR])
#define GDK_IS_DEFAULT_COLOR_STATE(c) (GDK_COLOR_STATE_SRGB <= (c) && (c) <= GDK_COLOR_STATE_SRGB_LINEAR)
#define GDK_DEFAULT_COLOR_STATE_ID(c) ((GdkColorStateId) (c - gdk_default_color_states))
const char * gdk_color_state_get_name (GdkColorState *color_state);
const char * gdk_color_state_get_name_from_id (GdkColorStateId id);
void gdk_color_state_print (GdkColorState *color_state,
GString *string);
GdkMemoryDepth gdk_color_state_get_min_depth (GdkColorState *color_state);
#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;
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;
self->ref_count--;
if (self->ref_count == 0)
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 (GDK_IS_DEFAULT_COLOR_STATE (self) || GDK_IS_DEFAULT_COLOR_STATE (other))
return FALSE;
if (self->klass != other->klass)
return FALSE;
return self->klass->equal (self, other);
}
GdkColorState * gdk_color_state_new_from_icc_profile (GBytes *icc_profile,
GError **error);
GdkColorState * gdk_color_state_new_from_cicp_data (int color_primaries,
int transfer_characteristics,
int matrix_coefficients,
gboolean full_range);
GBytes * gdk_color_state_save_to_icc_profile (GdkColorState *self,
GError **error);
gboolean gdk_color_state_save_to_cicp_data (GdkColorState *self,
int *color_primaries,
int *transfer_characteristic,
int *matrix_coefficients,
gboolean *full_range,
GError **error);

View File

@@ -540,9 +540,6 @@ deserialize_not_found (GdkContentDeserializer *deserializer)
*
* 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

@@ -279,10 +279,6 @@ gdk_content_provider_content_changed (GdkContentProvider *provider)
* 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.

View File

@@ -546,9 +546,6 @@ serialize_not_found (GdkContentSerializer *serializer)
*
* 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_serialize_finish] to get the result of the operation.
*/
void
gdk_content_serialize_async (GOutputStream *stream,

View File

@@ -156,6 +156,9 @@ gdk_cursor_finalize (GObject *object)
g_clear_object (&cursor->texture);
g_clear_object (&cursor->fallback);
if (cursor->destroy)
cursor->destroy (cursor->data);
G_OBJECT_CLASS (gdk_cursor_parent_class)->finalize (object);
}
@@ -253,6 +256,11 @@ gdk_cursor_hash (gconstpointer pointer)
hash ^= g_str_hash (cursor->name);
else if (cursor->texture)
hash ^= g_direct_hash (cursor->texture);
else if (cursor->callback)
{
hash ^= g_direct_hash (cursor->callback);
hash ^= g_direct_hash (cursor->data);
}
hash ^= (cursor->hotspot_x << 8) | cursor->hotspot_y;
@@ -281,6 +289,10 @@ gdk_cursor_equal (gconstpointer a,
ca->hotspot_y != cb->hotspot_y)
return FALSE;
if (ca->callback != cb->callback ||
ca->data != cb->data)
return FALSE;
return TRUE;
}
@@ -355,6 +367,45 @@ gdk_cursor_new_from_texture (GdkTexture *texture,
NULL);
}
/**
* gdk_cursor_new_from_callback:
* @callback: the `GdkCursorGetTextureCallback`
* @data: data to pass to @callback
* @destroy: destroy notify for @data
* @fallback: (nullable): the `GdkCursor` to fall back to when
* this one cannot be supported
*
* Creates a new callback-based cursor object.
*
* Cursors of this kind produce textures for the cursor
* image on demand, when the @callback is called.
*
* Returns: (nullable): a new `GdkCursor`
*
* Since: 4.16
*/
GdkCursor *
gdk_cursor_new_from_callback (GdkCursorGetTextureCallback callback,
gpointer data,
GDestroyNotify destroy,
GdkCursor *fallback)
{
GdkCursor *cursor;
g_return_val_if_fail (callback != NULL, NULL);
g_return_val_if_fail (fallback == NULL || GDK_IS_CURSOR (fallback), NULL);
cursor = g_object_new (GDK_TYPE_CURSOR,
"fallback", fallback,
NULL);
cursor->callback = callback;
cursor->data = data;
cursor->destroy = destroy;
return cursor;
}
/**
* gdk_cursor_get_fallback: (attributes org.gtk.Method.get_property=fallback)
* @cursor: a `GdkCursor`
@@ -459,3 +510,22 @@ gdk_cursor_get_hotspot_y (GdkCursor *cursor)
return cursor->hotspot_y;
}
GdkTexture *
gdk_cursor_get_texture_for_size (GdkCursor *cursor,
int cursor_size,
double scale,
int *width,
int *height,
int *hotspot_x,
int *hotspot_y)
{
if (cursor->callback == NULL)
return NULL;
return cursor->callback (cursor,
cursor_size, scale,
width, height,
hotspot_x, hotspot_y,
cursor->data);
}

View File

@@ -51,6 +51,52 @@ GDK_AVAILABLE_IN_ALL
GdkCursor* gdk_cursor_new_from_name (const char *name,
GdkCursor *fallback);
/**
* GdkCursorGetTextureCallback:
* @cursor: the `GdkCursor`
* @cursor_size: the nominal cursor size, in application pixels
* @scale: the device scale
* @width: (out): return location for the actual cursor width,
* in application pixels
* @height: (out): return location for the actual cursor height,
* in application pixels
* @hotspot_x: (out): return location for the hotspot X position,
* in application pixels
* @hotspot_y: (out): return location for the hotspot Y position,
* in application pixels
* @data: User data for the callback
*
* The type of callback used by a dynamic `GdkCursor` to generate
* a texture for the cursor image at the given @cursor_size
* and @scale.
*
* The actual cursor size in application pixels may be different
* from @cursor_size x @cursor_size, and will be returned in
* @width, @height. The returned texture should have a size that
* corresponds to the actual cursor size, in device pixels (i.e.
* application pixels, multiplied by @scale).
*
* This function may fail and return `NULL`, in which case
* the fallback cursor will be used.
*
* Returns: (nullable) (transfer full): the cursor image, or
* `NULL` if none could be produced.
*/
typedef GdkTexture * (* GdkCursorGetTextureCallback) (GdkCursor *cursor,
int cursor_size,
double scale,
int *width,
int *height,
int *hotspot_x,
int *hotspot_y,
gpointer data);
GDK_AVAILABLE_IN_4_16
GdkCursor * gdk_cursor_new_from_callback (GdkCursorGetTextureCallback callback,
gpointer data,
GDestroyNotify destroy,
GdkCursor *fallback);
GDK_AVAILABLE_IN_ALL
GdkCursor * gdk_cursor_get_fallback (GdkCursor *cursor);
GDK_AVAILABLE_IN_ALL

View File

@@ -44,6 +44,10 @@ struct _GdkCursor
GdkTexture *texture;
int hotspot_x;
int hotspot_y;
GdkCursorGetTextureCallback callback;
gpointer data;
GDestroyNotify destroy;
};
struct _GdkCursorClass
@@ -55,5 +59,13 @@ guint gdk_cursor_hash (gconstpointer
gboolean gdk_cursor_equal (gconstpointer a,
gconstpointer b);
GdkTexture * gdk_cursor_get_texture_for_size (GdkCursor *cursor,
int cursor_size,
double scale,
int *width,
int *height,
int *hotspot_x,
int *hotspot_y);
G_END_DECLS

View File

@@ -44,7 +44,7 @@ typedef enum {
GDK_DEBUG_NO_PORTALS = 1 << 15,
GDK_DEBUG_GL_DISABLE = 1 << 16,
GDK_DEBUG_GL_NO_FRACTIONAL= 1 << 17,
GDK_DEBUG_FORCE_OFFLOAD = 1 << 18,
GDK_DEBUG_GL_DISABLE_GL = 1 << 19,
GDK_DEBUG_GL_DISABLE_GLES = 1 << 20,
GDK_DEBUG_GL_PREFER_GL = 1 << 21,

View File

@@ -1559,13 +1559,14 @@ describe_egl_config (EGLDisplay egl_display,
if (!eglGetConfigAttrib (egl_display, egl_config, EGL_DEPTH_SIZE, &depth))
depth = 0;
if (!eglGetConfigAttrib (egl_display, egl_config, EGL_STENCIL_SIZE, &stencil))
stencil = 0;
return g_strdup_printf ("R%dG%dB%dA%d%s%s%s", red, green, blue, alpha,
return g_strdup_printf ("R%dG%dB%dA%d%s, depth %d, stencil %d", red, green, blue, alpha,
type == EGL_COLOR_COMPONENT_TYPE_FIXED_EXT ? "" : " float",
depth > 0 ? ", depth buffer" : "",
stencil > 0 ? ", stencil buffer" : "");
depth,
stencil);
}
gpointer
@@ -1873,6 +1874,8 @@ gdk_display_init_egl (GdkDisplay *self,
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_image_dma_buf_import_modifiers");
self->have_egl_dma_buf_export =
epoxy_has_egl_extension (priv->egl_display, "EGL_MESA_image_dma_buf_export");
self->have_egl_gl_colorspace =
epoxy_has_egl_extension (priv->egl_display, "EGL_KHR_gl_colorspace");
if (self->have_egl_no_config_context)
priv->egl_config_high_depth = gdk_display_create_egl_config (self,

View File

@@ -130,6 +130,7 @@ struct _GdkDisplay
guint have_egl_pixel_format_float : 1;
guint have_egl_dma_buf_import : 1;
guint have_egl_dma_buf_export : 1;
guint have_egl_gl_colorspace : 1;
GdkDmabufFormats *dmabuf_formats;
GdkDmabufDownloader *dmabuf_downloaders[4];

View File

@@ -144,8 +144,8 @@ struct _YUVCoefficients
};
/* multiplied by 65536 */
//static const YUVCoefficients itu601_narrow = { 104597, -25675, -53279, 132201 };
static const YUVCoefficients itu601_wide = { 74711, -25864, -38050, 133176 };
static const YUVCoefficients itu601_narrow = { 104597, -25675, -53279, 132201 };
//static const YUVCoefficients itu601_wide = { 74711, -25864, -38050, 133176 };
static inline void
get_uv_values (const YUVCoefficients *coeffs,
@@ -229,7 +229,7 @@ download_nv12 (guchar *dst_data,
int r, g, b;
gsize xs, ys;
get_uv_values (&itu601_wide, uv_data[x / X_SUB * 2 + U], uv_data[x / X_SUB * 2 + V], &r, &g, &b);
get_uv_values (&itu601_narrow, uv_data[x / X_SUB * 2 + U], uv_data[x / X_SUB * 2 + V], &r, &g, &b);
for (ys = 0; ys < Y_SUB && y + ys < height; ys++)
for (xs = 0; xs < X_SUB && x + xs < width; xs++)
@@ -309,7 +309,7 @@ download_yuv_3 (guchar *dst_data,
int r, g, b;
gsize xs, ys;
get_uv_values (&itu601_wide, u_data[x / X_SUB], v_data[x / X_SUB], &r, &g, &b);
get_uv_values (&itu601_narrow, u_data[x / X_SUB], v_data[x / X_SUB], &r, &g, &b);
for (ys = 0; ys < Y_SUB && y + ys < height; ys++)
for (xs = 0; xs < X_SUB && x + xs < width; xs++)
@@ -365,7 +365,7 @@ download_yuyv (guchar *dst_data,
{
int r, g, b;
get_uv_values (&itu601_wide, src_data[2 * x + U], src_data[2 * x + V], &r, &g, &b);
get_uv_values (&itu601_narrow, src_data[2 * x + U], src_data[2 * x + V], &r, &g, &b);
set_rgb_values (&dst_data[3 * x], src_data[2 * x + Y1], r, g, b);
if (x + 1 < width)
set_rgb_values (&dst_data[3 * (x + 1)], src_data[2 * x + Y2], r, g, b);

View File

@@ -163,6 +163,8 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
return NULL;
previous = gdk_gl_context_get_current ();
if (previous)
g_object_ref (previous);
formats = gdk_dmabuf_formats_builder_new ();
external = gdk_dmabuf_formats_builder_new ();
@@ -194,7 +196,10 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
}
if (previous)
gdk_gl_context_make_current (previous);
{
gdk_gl_context_make_current (previous);
g_object_unref (previous);
}
return GDK_DMABUF_DOWNLOADER (renderer);
}
@@ -239,7 +244,7 @@ gdk_dmabuf_egl_create_image (GdkDisplay *display,
attribs[i++] = EGL_YUV_COLOR_SPACE_HINT_EXT;
attribs[i++] = EGL_ITU_REC601_EXT;
attribs[i++] = EGL_SAMPLE_RANGE_HINT_EXT;
attribs[i++] = EGL_YUV_FULL_RANGE_EXT;
attribs[i++] = EGL_YUV_NARROW_RANGE_EXT;
#define ADD_PLANE(plane) \
{ \
@@ -265,6 +270,7 @@ gdk_dmabuf_egl_create_image (GdkDisplay *display,
if (dmabuf->n_planes > 3) ADD_PLANE (3);
attribs[i++] = EGL_NONE;
g_assert (i < G_N_ELEMENTS (attribs));
image = eglCreateImageKHR (egl_display,
EGL_NO_CONTEXT,

View File

@@ -25,6 +25,7 @@
#include "gdkdmabufformatsbuilderprivate.h"
#include "gdkdmabuffourccprivate.h"
#include "gdkdmabufprivate.h"
#include "gdkdmabuftexturebuilderprivate.h"
#include "gdktextureprivate.h"
#include <gdk/gdkglcontext.h>
#include <gdk/gdkgltexturebuilder.h>
@@ -61,6 +62,13 @@ struct _GdkDmabufTextureClass
GdkTextureClass parent_class;
};
/**
* gdk_dmabuf_error_quark:
*
* Registers an error quark for [class@Gdk.DmabufTexture] errors.
*
* Returns: the error quark
**/
G_DEFINE_QUARK (gdk-dmabuf-error-quark, gdk_dmabuf_error)
G_DEFINE_TYPE (GdkDmabufTexture, gdk_dmabuf_texture, GDK_TYPE_TEXTURE)
@@ -71,7 +79,10 @@ gdk_dmabuf_texture_dispose (GObject *object)
GdkDmabufTexture *self = GDK_DMABUF_TEXTURE (object);
if (self->destroy)
self->destroy (self->data);
{
self->destroy (self->data);
self->destroy = NULL;
}
g_clear_object (&self->downloader);
g_clear_object (&self->display);
@@ -189,6 +200,7 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
self = g_object_new (GDK_TYPE_DMABUF_TEXTURE,
"width", width,
"height", height,
"color-state", gdk_dmabuf_texture_builder_get_color_state (builder),
NULL);
g_set_object (&self->display, display);

View File

@@ -24,7 +24,9 @@
#include "gdkdebugprivate.h"
#include "gdkdisplay.h"
#include "gdkenumtypes.h"
#include "gdkcolorstate.h"
#include "gdkdmabuftextureprivate.h"
#include "gdkdmabuftexturebuilderprivate.h"
#include <cairo-gobject.h>
@@ -40,6 +42,8 @@ struct _GdkDmabufTextureBuilder
GdkDmabuf dmabuf;
GdkColorState *color_state;
GdkTexture *update_texture;
cairo_region_t *update_region;
};
@@ -123,6 +127,7 @@ enum
PROP_MODIFIER,
PROP_PREMULTIPLIED,
PROP_N_PLANES,
PROP_COLOR_STATE,
PROP_UPDATE_REGION,
PROP_UPDATE_TEXTURE,
@@ -140,6 +145,7 @@ gdk_dmabuf_texture_builder_dispose (GObject *object)
g_clear_object (&self->update_texture);
g_clear_pointer (&self->update_region, cairo_region_destroy);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
G_OBJECT_CLASS (gdk_dmabuf_texture_builder_parent_class)->dispose (object);
}
@@ -182,6 +188,10 @@ gdk_dmabuf_texture_builder_get_property (GObject *object,
g_value_set_uint (value, self->dmabuf.n_planes);
break;
case PROP_COLOR_STATE:
g_value_set_boxed (value, self->color_state);
break;
case PROP_UPDATE_REGION:
g_value_set_boxed (value, self->update_region);
break;
@@ -234,6 +244,10 @@ gdk_dmabuf_texture_builder_set_property (GObject *object,
gdk_dmabuf_texture_builder_set_n_planes (self, g_value_get_uint (value));
break;
case PROP_COLOR_STATE:
gdk_dmabuf_texture_builder_set_color_state (self, g_value_get_boxed (value));
break;
case PROP_UPDATE_REGION:
gdk_dmabuf_texture_builder_set_update_region (self, g_value_get_boxed (value));
break;
@@ -346,6 +360,18 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
1, GDK_DMABUF_MAX_PLANES, 1,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkDmabufTextureBuilder:color-state: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_color_state org.gtk.Property.set=gdk_dmabuf_texture_builder_set_color_state)
*
* The color state of the texture.
*
* Since: 4.16
*/
properties[PROP_COLOR_STATE] =
g_param_spec_boxed ("color-state", NULL, NULL,
GDK_TYPE_COLOR_STATE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkDmabufTextureBuilder:update-region: (attributes org.gtk.Property.get=gdk_dmabuf_texture_builder_get_update_region org.gtk.Property.set=gdk_dmabuf_texture_builder_set_update_region)
*
@@ -382,6 +408,8 @@ gdk_dmabuf_texture_builder_init (GdkDmabufTextureBuilder *self)
for (int i = 0; i < GDK_DMABUF_MAX_PLANES; i++)
self->dmabuf.planes[i].fd = -1;
self->color_state = gdk_color_state_get_srgb ();
}
/**
@@ -842,6 +870,48 @@ gdk_dmabuf_texture_builder_set_offset (GdkDmabufTextureBuilder *self,
self->dmabuf.planes[plane].offset = offset;
}
/**
* gdk_dmabuf_texture_builder_get_color_state: (attributes org.gtk.Method.get_property=color-state)
* @self: a `GdkDmabufTextureBuilder`
*
* Gets the color state previously set via gdk_dmabuf_texture_builder_set_color_state().
*
* Returns: the color state
*
* Since: 4.16
*/
GdkColorState *
gdk_dmabuf_texture_builder_get_color_state (GdkDmabufTextureBuilder *self)
{
g_return_val_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self), NULL);
return self->color_state;
}
/**
* gdk_dmabuf_texture_builder_set_color_state: (attributes org.gtk.Method.set_property=color-state)
* @self: a `GdkDmabufTextureBuilder`
* @color_state: a `GdkColorState`
*
* Sets the color state for the texture. The default is SRGB.
*
* Since: 4.16
*/
void
gdk_dmabuf_texture_builder_set_color_state (GdkDmabufTextureBuilder *self,
GdkColorState *color_state)
{
g_return_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self));
g_return_if_fail (color_state != NULL);
if (self->color_state != color_state)
{
g_clear_pointer (&self->color_state, gdk_color_state_unref);
self->color_state = gdk_color_state_ref (color_state);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR_STATE]);
}
}
/**
* gdk_dmabuf_texture_builder_get_update_texture: (attributes org.gtk.Method.get_property=update-texture)
* @self: a `GdkDmabufTextureBuilder`
@@ -948,22 +1018,20 @@ gdk_dmabuf_texture_builder_set_update_region (GdkDmabufTextureBuilder *self,
*
* Builds a new `GdkTexture` with the values set up in the builder.
*
* It is a programming error to call this function if any mandatory
* property has not been set.
* It is a programming error to call this function if any mandatory property has not been set.
*
* If the dmabuf is not supported by GTK, %NULL will be returned and @error will be set.
* Not all formats defined in the `drm_fourcc.h` header are supported. You can use
* [method@Gdk.Display.get_dmabuf_formats] to get a list of supported formats. If the
* format is not supported by GTK, %NULL will be returned and @error will be set.
*
* The `destroy` function gets called when the returned texture gets released.
*
* It is possible to call this function multiple times to create multiple textures,
* possibly with changing properties in between.
*
* It is the responsibility of the caller to keep the file descriptors for the planes
* open until the created texture is no longer used, and close them afterwards (possibly
* using the @destroy notify).
*
* Not all formats defined in the `drm_fourcc.h` header are supported. You can use
* [method@Gdk.Display.get_dmabuf_formats] to get a list of supported formats.
* It is possible to call this function multiple times to create multiple textures,
* possibly with changing properties in between.
*
* Returns: (transfer full) (nullable): a newly built `GdkTexture` or `NULL`
* if the format is not supported
@@ -1004,3 +1072,19 @@ gdk_dmabuf_texture_builder_get_dmabuf (GdkDmabufTextureBuilder *self)
{
return &self->dmabuf;
}
void
gdk_dmabuf_texture_builder_set_dmabuf (GdkDmabufTextureBuilder *self,
const GdkDmabuf *dmabuf)
{
gdk_dmabuf_texture_builder_set_fourcc (self, dmabuf->fourcc);
gdk_dmabuf_texture_builder_set_modifier (self, dmabuf->modifier);
gdk_dmabuf_texture_builder_set_n_planes (self, dmabuf->n_planes);
for (unsigned int i = 0; i < dmabuf->n_planes; i++)
{
gdk_dmabuf_texture_builder_set_fd (self, i, dmabuf->planes[i].fd);
gdk_dmabuf_texture_builder_set_stride (self, i, dmabuf->planes[i].stride);
gdk_dmabuf_texture_builder_set_offset (self, i, dmabuf->planes[i].offset);
}
}

View File

@@ -100,6 +100,12 @@ void gdk_dmabuf_texture_builder_set_offset (GdkDmabufT
unsigned int plane,
unsigned int offset);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_dmabuf_texture_builder_get_color_state (GdkDmabufTextureBuilder *self);
GDK_AVAILABLE_IN_4_16
void gdk_dmabuf_texture_builder_set_color_state (GdkDmabufTextureBuilder *self,
GdkColorState *color_state);
GDK_AVAILABLE_IN_4_14
GdkTexture * gdk_dmabuf_texture_builder_get_update_texture (GdkDmabufTextureBuilder *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_14

View File

@@ -0,0 +1,14 @@
#pragma once
#include "gdkdmabuftexturebuilder.h"
#include "gdkdmabufprivate.h"
G_BEGIN_DECLS
const GdkDmabuf * gdk_dmabuf_texture_builder_get_dmabuf (GdkDmabufTextureBuilder *builder);
void gdk_dmabuf_texture_builder_set_dmabuf (GdkDmabufTextureBuilder *builder,
const GdkDmabuf *dmabuf);
G_END_DECLS

View File

@@ -7,8 +7,6 @@
G_BEGIN_DECLS
const GdkDmabuf * gdk_dmabuf_texture_builder_get_dmabuf (GdkDmabufTextureBuilder *builder);
GdkTexture * gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
GDestroyNotify destroy,
gpointer data,

View File

@@ -50,18 +50,6 @@
#include "gdkenumtypes.h"
#include "gdkeventsprivate.h"
static struct {
GdkDragAction action;
const char *name;
GdkCursor *cursor;
} drag_cursors[] = {
{ GDK_ACTION_ASK, "dnd-ask", NULL },
{ GDK_ACTION_COPY, "copy", NULL },
{ GDK_ACTION_MOVE, "move", NULL },
{ GDK_ACTION_LINK, "alias", NULL },
{ 0, "no-drop", NULL },
};
enum {
PROP_0,
PROP_CONTENT,
@@ -786,6 +774,20 @@ gdk_drag_handle_source_event (GdkEvent *event)
return FALSE;
}
static struct {
GdkDragAction action;
const char *name;
GdkCursor *cursor;
} drag_cursors[] = {
{ 0, "default", NULL },
{ GDK_ACTION_ASK, "dnd-ask", NULL },
{ GDK_ACTION_COPY, "copy", NULL },
{ GDK_ACTION_MOVE, "dnd-move", NULL }, /* Not using move here, since move is stuck using
* a mismatched visual metaphor in Adwaita
*/
{ GDK_ACTION_LINK, "alias", NULL },
};
GdkCursor *
gdk_drag_get_cursor (GdkDrag *drag,
GdkDragAction action)

View File

@@ -134,7 +134,7 @@ gdk_drop_read_local_async (GdkDrop *self,
g_object_get (priv->drag, "content", &content, NULL);
content_formats = gdk_content_provider_ref_formats (content);
g_object_unref (content);
g_object_unref (content);
content_formats = gdk_content_formats_union_serialize_mime_types (content_formats);
mime_type = gdk_content_formats_match_mime_type (content_formats, formats);
@@ -784,7 +784,7 @@ gdk_drop_read_value_internal (GdkDrop *self,
GdkContentFormats *formats;
GValue *value;
GTask *task;
g_return_if_fail (priv->state != GDK_DROP_STATE_FINISHED);
task = g_task_new (self, cancellable, callback, user_data);
@@ -849,10 +849,6 @@ gdk_drop_read_value_internal (GdkDrop *self,
* Asynchronously request the drag operation's contents converted
* to the given @type.
*
* When the operation is finished @callback will be called. You must
* then call [method@Gdk.Drop.read_value_finish] to get the resulting
* `GValue`.
*
* For local drag-and-drop operations that are available in the given
* `GType`, the value will be copied directly. Otherwise, GDK will
* try to use [func@Gdk.content_deserialize_async] to convert the data.

View File

@@ -1371,6 +1371,8 @@ gdk_event_get_modifier_state (GdkEvent *event)
* Extract the event surface relative x/y coordinates from an event.
*
* This position is in [surface coordinates](coordinates.html).
*
* Returns: whether the positions were set
*/
gboolean
gdk_event_get_position (GdkEvent *event,

View File

@@ -192,13 +192,6 @@ compute_smooth_frame_time (GdkFrameClock *clock,
* and new_frame_time >= old_frame_time. */
frames_passed = (new_frame_time - smoothed_frame_time_base + frame_interval / 2) / frame_interval;
if (frames_passed > 1)
gdk_profiler_add_markf ((smoothed_frame_time_base - (frame_interval * (frames_passed-1))) * 1000L,
frame_interval * (frames_passed-1) * 1000L,
"Dropped Frames",
"%u frames may have been dropped",
frames_passed-1);
/* We use an approximately whole number of frames in the future from
* last smoothed frame time. This way we avoid minor jitter in the
* frame times making the animation speed uneven, but still animate

View File

@@ -152,6 +152,13 @@ enum {
static GParamSpec *properties[LAST_PROP] = { NULL, };
/**
* gdk_gl_error_quark:
*
* Registers an error quark for [class@Gdk.GLContext] errors.
*
* Returns: the error quark
**/
G_DEFINE_QUARK (gdk-gl-error-quark, gdk_gl_error)
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, GDK_TYPE_DRAW_CONTEXT)
@@ -1751,6 +1758,8 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
priv->features = supported_features & ~disabled_features;
glEnable (GL_FRAMEBUFFER_SRGB);
gdk_gl_context_init_memory_flags (context);
if ((priv->features & GDK_GL_FEATURE_DEBUG) && gl_debug)
@@ -1956,8 +1965,6 @@ gdk_gl_context_get_glsl_version_string (GdkGLContext *self)
return "#version 310 es";
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
return "#version 300 es";
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
return "#version 300 es";
else
return "#version 100";
}
@@ -2198,12 +2205,78 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
gdk_display_init_dmabuf (display);
if (!gdk_dmabuf_formats_contains (display->egl_external_formats, dmabuf->fourcc, dmabuf->modifier))
if (gdk_dmabuf_formats_contains (display->egl_dmabuf_formats, dmabuf->fourcc, dmabuf->modifier))
{
/* This is the path for modern drivers that support modifiers */
if (!gdk_dmabuf_formats_contains (display->egl_external_formats, dmabuf->fourcc, dmabuf->modifier))
{
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
width, height,
dmabuf,
GL_TEXTURE_2D);
if (texture_id == 0)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Import of %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
GDK_DISPLAY_DEBUG (display, DMABUF,
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_2D texture",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
*external = FALSE;
return texture_id;
}
if (!gdk_gl_context_get_use_es (self))
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Can't import external_only %.4s:%#" G_GINT64_MODIFIER "x outside of GLES",
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
width, height,
dmabuf,
GL_TEXTURE_2D);
GL_TEXTURE_EXTERNAL_OES);
if (texture_id == 0)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Import of external_only %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
GDK_DISPLAY_DEBUG (display, DMABUF,
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_EXTERNAL_OES texture",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
*external = TRUE;
return texture_id;
}
else
{
/* This is the opportunistic path.
* We hit it both for drivers that do not support modifiers as well as for dmabufs
* that the driver did not explicitly advertise. */
int target;
if (gdk_gl_context_get_use_es (self))
target = GL_TEXTURE_EXTERNAL_OES;
else
target = GL_TEXTURE_2D;
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
width, height,
dmabuf,
target);
if (texture_id == 0)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
@@ -2214,40 +2287,13 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
}
GDK_DISPLAY_DEBUG (display, DMABUF,
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_2D texture",
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as %s texture",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
*external = FALSE;
(char *) &dmabuf->fourcc, dmabuf->modifier,
target == GL_TEXTURE_EXTERNAL_OES ? "GL_TEXTURE_EXTERNAL_OES" : "GL_TEXTURE_2D");
*external = target == GL_TEXTURE_EXTERNAL_OES;
return texture_id;
}
if (!gdk_gl_context_get_use_es (self))
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Can't import external_only %.4s:%#" G_GINT64_MODIFIER "x outside of GLES",
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
width, height,
dmabuf,
GL_TEXTURE_EXTERNAL_OES);
if (texture_id == 0)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Import of external_only %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
GDK_DISPLAY_DEBUG (display, DMABUF,
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_EXTERNAL_OES texture",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
*external = TRUE;
return texture_id;
}
gboolean

View File

@@ -151,7 +151,7 @@ gdk_gl_texture_find_format (GdkGLContext *context,
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
{
GLint q_internal_format;
GLint q_internal_format, q_internal_srgb_format;
GLenum q_format, q_type;
GLint q_swizzle[4];
@@ -164,6 +164,7 @@ gdk_gl_texture_find_format (GdkGLContext *context,
gdk_memory_format_gl_format (format,
gdk_gl_context_get_use_es (context),
&q_internal_format,
&q_internal_srgb_format,
&q_format,
&q_type,
q_swizzle);
@@ -187,7 +188,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
GdkMemoryFormat format;
gsize expected_stride;
Download *download = download_;
GLint gl_internal_format;
GLint gl_internal_format, gl_internal_srgb_format;
GLenum gl_format, gl_type;
GLint gl_swizzle[4];
@@ -199,7 +200,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
{
gdk_memory_format_gl_format (format,
gdk_gl_context_get_use_es (context),
&gl_internal_format,
&gl_internal_format, &gl_internal_srgb_format,
&gl_format, &gl_type, gl_swizzle);
if (download->stride == expected_stride &&
download->format == format)
@@ -262,7 +263,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gdk_memory_format_gl_format (actual_format,
gdk_gl_context_get_use_es (context),
&gl_internal_format,
&gl_internal_format, &gl_internal_srgb_format,
&gl_read_format, &gl_read_type, gl_swizzle);
}
}
@@ -274,7 +275,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gdk_memory_format_gl_format (actual_format,
gdk_gl_context_get_use_es (context),
&gl_internal_format,
&gl_internal_format, &gl_internal_srgb_format,
&gl_read_format, &gl_read_type, gl_swizzle);
}
@@ -471,8 +472,7 @@ gdk_gl_texture_release (GdkGLTexture *self)
g_return_if_fail (self->saved == NULL);
texture = GDK_TEXTURE (self);
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture,
gdk_texture_get_format (texture)));
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture));
drop_gl_resources (self);
}
@@ -488,6 +488,7 @@ gdk_gl_texture_new_from_builder (GdkGLTextureBuilder *builder,
self = g_object_new (GDK_TYPE_GL_TEXTURE,
"width", gdk_gl_texture_builder_get_width (builder),
"height", gdk_gl_texture_builder_get_height (builder),
"color-state", gdk_gl_texture_builder_get_color_state (builder),
NULL);
self->context = g_object_ref (gdk_gl_texture_builder_get_context (builder));

View File

@@ -23,6 +23,7 @@
#include "gdkenumtypes.h"
#include "gdkglcontext.h"
#include "gdkcolorstate.h"
#include "gdkgltextureprivate.h"
#include <cairo-gobject.h>
@@ -38,6 +39,7 @@ struct _GdkGLTextureBuilder
GdkMemoryFormat format;
gboolean has_mipmap;
gpointer sync;
GdkColorState *color_state;
GdkTexture *update_texture;
cairo_region_t *update_region;
@@ -75,6 +77,7 @@ enum
PROP_HEIGHT,
PROP_ID,
PROP_SYNC,
PROP_COLOR_STATE,
PROP_UPDATE_REGION,
PROP_UPDATE_TEXTURE,
PROP_WIDTH,
@@ -95,6 +98,7 @@ gdk_gl_texture_builder_dispose (GObject *object)
g_clear_object (&self->update_texture);
g_clear_pointer (&self->update_region, cairo_region_destroy);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
G_OBJECT_CLASS (gdk_gl_texture_builder_parent_class)->dispose (object);
}
@@ -133,6 +137,10 @@ gdk_gl_texture_builder_get_property (GObject *object,
g_value_set_pointer (value, self->sync);
break;
case PROP_COLOR_STATE:
g_value_set_object (value, self->color_state);
break;
case PROP_UPDATE_REGION:
g_value_set_boxed (value, self->update_region);
break;
@@ -185,6 +193,10 @@ gdk_gl_texture_builder_set_property (GObject *object,
gdk_gl_texture_builder_set_sync (self, g_value_get_pointer (value));
break;
case PROP_COLOR_STATE:
gdk_gl_texture_builder_set_color_state (self, g_value_get_object (value));
break;
case PROP_UPDATE_REGION:
gdk_gl_texture_builder_set_update_region (self, g_value_get_boxed (value));
break;
@@ -286,6 +298,18 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
g_param_spec_pointer ("sync", NULL, NULL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkGLTextureBuilder:color-state: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_color_state org.gtk.Property.set=gdk_gl_texture_builder_set_color_state)
*
* The color state of the texture.
*
* Since: 4.16
*/
properties[PROP_COLOR_STATE] =
g_param_spec_boxed ("color-state", NULL, NULL,
GDK_TYPE_COLOR_STATE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GdkGLTextureBuilder:update-region: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_update_region org.gtk.Property.set=gdk_gl_texture_builder_set_update_region)
*
@@ -329,6 +353,7 @@ static void
gdk_gl_texture_builder_init (GdkGLTextureBuilder *self)
{
self->format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
self->color_state = gdk_color_state_get_srgb ();
}
/**
@@ -672,6 +697,49 @@ gdk_gl_texture_builder_set_format (GdkGLTextureBuilder *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FORMAT]);
}
/**
* gdk_gl_texture_builder_get_color_state: (attributes org.gtk.Method.get_property=color-state)
* @self: a `GdkGLTextureBuilder`
*
* Gets the color state previously set via gdk_gl_texture_builder_set_color_state().
*
* Returns: the color state
*
* Since: 4.16
*/
GdkColorState *
gdk_gl_texture_builder_get_color_state (GdkGLTextureBuilder *self)
{
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), NULL);
return self->color_state;
}
/**
* gdk_gl_texture_builder_set_color_state: (attributes org.gtk.Method.set_property=color-state)
* @self: a `GdkGLTextureBuilder`
* @color_state: a `GdkColorState`
*
* Sets the color state for the texture.
* Sets the color state of the texture. The default is SRGB.
*
* Since: 4.16
*/
void
gdk_gl_texture_builder_set_color_state (GdkGLTextureBuilder *self,
GdkColorState *color_state)
{
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
g_return_if_fail (color_state != NULL);
if (self->color_state != color_state)
{
g_clear_pointer (&self->color_state, gdk_color_state_unref);
self->color_state = gdk_color_state_ref (color_state);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR_STATE]);
}
}
/**
* gdk_gl_texture_builder_get_update_texture: (attributes org.gtk.Method.get_property=update-texture)
* @self: a `GdkGLTextureBuilder`

View File

@@ -64,6 +64,12 @@ GDK_AVAILABLE_IN_4_12
void gdk_gl_texture_builder_set_format (GdkGLTextureBuilder *self,
GdkMemoryFormat format);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_gl_texture_builder_get_color_state (GdkGLTextureBuilder *self);
GDK_AVAILABLE_IN_4_16
void gdk_gl_texture_builder_set_color_state (GdkGLTextureBuilder *self,
GdkColorState *color_state);
GDK_AVAILABLE_IN_4_12
gboolean gdk_gl_texture_builder_get_has_mipmap (GdkGLTextureBuilder *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_12

View File

@@ -23,6 +23,8 @@
#include "gdkdmabuffourccprivate.h"
#include "gdkglcontextprivate.h"
#include "gdkcolorstateprivate.h"
#include "gtk/gtkcolorutilsprivate.h"
#include "gsk/gl/fp16private.h"
@@ -327,6 +329,7 @@ ADD_ALPHA_FUNC(r8g8b8_to_a8b8g8r8, 0, 1, 2, 3, 2, 1, 0)
struct _GdkMemoryFormatDescription
{
const char *name;
GdkMemoryAlpha alpha;
GdkMemoryFormat premultiplied;
GdkMemoryFormat straight;
@@ -337,7 +340,9 @@ struct _GdkMemoryFormatDescription
struct {
GLint internal_gl_format;
GLint internal_gles_format;
GLint internal_srgb_format;
GLenum format;
GLenum srgb_format;
GLenum type;
GLint swizzle[4];
/* -1 if none exists, ie the format is already RGBA
@@ -347,6 +352,7 @@ struct _GdkMemoryFormatDescription
} gl;
#ifdef GDK_RENDERING_VULKAN
VkFormat vk_format;
VkFormat vk_srgb_format;
#endif
#ifdef HAVE_DMABUF
guint32 dmabuf_fourcc;
@@ -366,6 +372,7 @@ struct _GdkMemoryFormatDescription
static const GdkMemoryFormatDescription memory_formats[] = {
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = {
.name = "*BGRA8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_B8G8R8A8,
@@ -378,6 +385,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_BGRA,
.internal_srgb_format = -1,
.format = GL_BGRA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -386,6 +394,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8A8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ARGB8888,
@@ -394,6 +403,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8a8_premultiplied_from_float,
},
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = {
.name = "*ARGB8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A8R8G8B8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8R8G8B8,
@@ -406,6 +416,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_BGRA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -414,6 +425,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGRA8888,
@@ -422,6 +434,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8r8g8b8_premultiplied_from_float,
},
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = {
.name = "*RGBA8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_R8G8B8A8,
@@ -434,6 +447,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -441,6 +455,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8A8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR8888,
@@ -449,6 +464,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8a8_premultiplied_from_float,
},
[GDK_MEMORY_A8B8G8R8_PREMULTIPLIED] = {
.name = "*ABGR8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A8B8G8R8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8B8G8R8,
@@ -461,6 +477,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -469,6 +486,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGBA8888,
@@ -477,6 +495,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8b8g8r8_premultiplied_from_float,
},
[GDK_MEMORY_B8G8R8A8] = {
.name = "BGRA8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_B8G8R8A8,
@@ -489,6 +508,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_BGRA,
.internal_srgb_format = -1,
.format = GL_BGRA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -497,6 +517,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8A8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ARGB8888,
@@ -505,6 +526,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8a8_from_float,
},
[GDK_MEMORY_A8R8G8B8] = {
.name = "ARGB8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_A8R8G8B8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8R8G8B8,
@@ -517,6 +539,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_BGRA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -525,6 +548,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGRA8888,
@@ -533,6 +557,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8r8g8b8_from_float,
},
[GDK_MEMORY_R8G8B8A8] = {
.name = "RGBA8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_R8G8B8A8,
@@ -545,6 +570,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -552,6 +578,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8A8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR8888,
@@ -560,6 +587,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8a8_from_float,
},
[GDK_MEMORY_A8B8G8R8] = {
.name = "ABGR8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_A8B8G8R8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8B8G8R8,
@@ -572,6 +600,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -580,6 +609,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGBA8888,
@@ -588,6 +618,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8b8g8r8_from_float,
},
[GDK_MEMORY_B8G8R8X8] = {
.name = "BGRX8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_B8G8R8X8,
.straight = GDK_MEMORY_B8G8R8X8,
@@ -601,6 +632,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_BGRA,
.internal_srgb_format = -1,
.format = GL_BGRA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -609,6 +641,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8A8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_XRGB8888,
@@ -617,6 +650,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8x8_from_float,
},
[GDK_MEMORY_X8R8G8B8] = {
.name = "XRGB8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_X8R8G8B8,
.straight = GDK_MEMORY_X8R8G8B8,
@@ -630,6 +664,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_BGRA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -638,6 +673,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGRX8888,
@@ -646,6 +682,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = x8r8g8b8_from_float,
},
[GDK_MEMORY_R8G8B8X8] = {
.name = "RGBX8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R8G8B8X8,
.straight = GDK_MEMORY_R8G8B8X8,
@@ -659,6 +696,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -666,6 +704,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8A8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_XBGR8888,
@@ -674,6 +713,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8x8_from_float,
},
[GDK_MEMORY_X8B8G8R8] = {
.name = "XBGR8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_X8B8G8R8,
.straight = GDK_MEMORY_X8B8G8R8,
@@ -687,6 +727,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -695,6 +736,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGBX8888,
@@ -703,6 +745,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = x8b8g8r8_from_float,
},
[GDK_MEMORY_R8G8B8] = {
.name = "RGB8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R8G8B8,
.straight = GDK_MEMORY_R8G8B8,
@@ -716,6 +759,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB8,
.internal_gles_format = GL_RGB8,
.internal_srgb_format = GL_SRGB8,
.format = GL_RGB,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -723,6 +767,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGR888,
@@ -731,6 +776,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8_from_float,
},
[GDK_MEMORY_B8G8R8] = {
.name = "BGR8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_B8G8R8,
.straight = GDK_MEMORY_B8G8R8,
@@ -744,6 +790,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB8,
.internal_gles_format = GL_RGB8,
.internal_srgb_format = GL_SRGB8,
.format = GL_BGR,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -752,6 +799,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGB888,
@@ -760,6 +808,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8_from_float,
},
[GDK_MEMORY_R16G16B16] = {
.name = "RGB16",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R16G16B16,
.straight = GDK_MEMORY_R16G16B16,
@@ -776,6 +825,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB16,
.internal_gles_format = GL_RGB16,
.internal_srgb_format = -1,
.format = GL_RGB,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -783,6 +833,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -791,6 +842,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16_from_float,
},
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = {
.name = "*RGBA16",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16,
@@ -806,6 +858,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA16,
.internal_gles_format = GL_RGBA16,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -813,6 +866,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616,
@@ -821,6 +875,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_from_float,
},
[GDK_MEMORY_R16G16B16A16] = {
.name = "RGBA16",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16,
@@ -836,6 +891,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA16,
.internal_gles_format = GL_RGBA16,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -843,6 +899,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616,
@@ -851,6 +908,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_from_float,
},
[GDK_MEMORY_R16G16B16_FLOAT] = {
.name = "RGBA16f",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R16G16B16_FLOAT,
.straight = GDK_MEMORY_R16G16B16_FLOAT,
@@ -866,6 +924,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB16F,
.internal_gles_format = GL_RGB16F,
.internal_srgb_format = -1,
.format = GL_RGB,
.type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -873,6 +932,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -881,6 +941,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16_float_from_float,
},
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = {
.name = "*RGBA16f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16_FLOAT,
@@ -895,6 +956,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA16F,
.internal_gles_format = GL_RGBA16F,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -902,6 +964,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616F,
@@ -910,6 +973,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_float_from_float,
},
[GDK_MEMORY_R16G16B16A16_FLOAT] = {
.name = "RGBA16f",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16_FLOAT,
@@ -924,6 +988,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA16F,
.internal_gles_format = GL_RGBA16F,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -931,6 +996,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616F,
@@ -939,6 +1005,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_float_from_float,
},
[GDK_MEMORY_R32G32B32_FLOAT] = {
.name = "RGB32f",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R32G32B32_FLOAT,
.straight = GDK_MEMORY_R32G32B32_FLOAT,
@@ -954,6 +1021,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB32F,
.internal_gles_format = GL_RGB32F,
.internal_srgb_format = -1,
.format = GL_RGB,
.type = GL_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -961,6 +1029,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32G32B32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -969,6 +1038,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r32g32b32_float_from_float,
},
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = {
.name = "*RGBA32f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R32G32B32A32_FLOAT,
@@ -983,6 +1053,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA32F,
.internal_gles_format = GL_RGBA32F,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -990,6 +1061,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32G32B32A32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -998,6 +1070,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r32g32b32a32_float_from_float,
},
[GDK_MEMORY_R32G32B32A32_FLOAT] = {
.name = "RGBA32f",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R32G32B32A32_FLOAT,
@@ -1012,6 +1085,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA32F,
.internal_gles_format = GL_RGBA32F,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -1019,6 +1093,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32G32B32A32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1027,6 +1102,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r32g32b32a32_float_from_float,
},
[GDK_MEMORY_G8A8_PREMULTIPLIED] = {
.name = "*GA8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_G8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_G8A8,
@@ -1040,6 +1116,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RG8,
.internal_gles_format = GL_RG8,
.internal_srgb_format = -1,
.format = GL_RG,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1047,6 +1124,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1055,6 +1133,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g8a8_premultiplied_from_float,
},
[GDK_MEMORY_G8A8] = {
.name = "GA8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_G8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_G8A8,
@@ -1068,6 +1147,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RG8,
.internal_gles_format = GL_RG8,
.internal_srgb_format = -1,
.format = GL_RG,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1075,6 +1155,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1083,6 +1164,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g8a8_from_float,
},
[GDK_MEMORY_G8] = {
.name = "G8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_G8,
.straight = GDK_MEMORY_G8,
@@ -1096,6 +1178,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R8,
.internal_gles_format = GL_R8,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_ONE },
@@ -1103,6 +1186,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8_UNORM,
.vk_srgb_format = VK_FORMAT_R8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_R8,
@@ -1111,6 +1195,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g8_from_float,
},
[GDK_MEMORY_G16A16_PREMULTIPLIED] = {
.name = "*GA16",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_G16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_G16A16,
@@ -1127,6 +1212,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RG16,
.internal_gles_format = GL_RG16,
.internal_srgb_format = -1,
.format = GL_RG,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1134,6 +1220,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1142,6 +1229,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g16a16_premultiplied_from_float,
},
[GDK_MEMORY_G16A16] = {
.name = "GA16",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_G16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_G16A16,
@@ -1158,6 +1246,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RG16,
.internal_gles_format = GL_RG16,
.internal_srgb_format = -1,
.format = GL_RG,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1165,6 +1254,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1173,6 +1263,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g16a16_from_float,
},
[GDK_MEMORY_G16] = {
.name = "G16",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_G16,
.straight = GDK_MEMORY_G16,
@@ -1189,6 +1280,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R16,
.internal_gles_format = GL_R16,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_ONE },
@@ -1196,6 +1288,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_R16,
@@ -1204,6 +1297,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g16_from_float,
},
[GDK_MEMORY_A8] = {
.name = "A8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A8,
.straight = GDK_MEMORY_A8,
@@ -1217,6 +1311,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R8,
.internal_gles_format = GL_R8,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1224,6 +1319,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1232,6 +1328,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8_from_float,
},
[GDK_MEMORY_A16] = {
.name = "A16",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A16,
.straight = GDK_MEMORY_A16,
@@ -1248,6 +1345,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R16,
.internal_gles_format = GL_R16,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1255,6 +1353,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1263,6 +1362,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a16_from_float,
},
[GDK_MEMORY_A16_FLOAT] = {
.name = "A16f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A16_FLOAT,
.straight = GDK_MEMORY_A16_FLOAT,
@@ -1278,6 +1378,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R16F,
.internal_gles_format = GL_R16F,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1285,6 +1386,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1293,6 +1395,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a16_float_from_float,
},
[GDK_MEMORY_A32_FLOAT] = {
.name = "A32f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A32_FLOAT,
.straight = GDK_MEMORY_A32_FLOAT,
@@ -1308,6 +1411,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R32F,
.internal_gles_format = GL_R32F,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_FLOAT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1315,6 +1419,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1509,6 +1614,7 @@ void
gdk_memory_format_gl_format (GdkMemoryFormat format,
gboolean gles,
GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format,
GLenum *out_type,
GLint out_swizzle[4])
@@ -1517,6 +1623,7 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
*out_internal_format = memory_formats[format].gl.internal_gles_format;
else
*out_internal_format = memory_formats[format].gl.internal_gl_format;
*out_internal_srgb_format = memory_formats[format].gl.internal_srgb_format;
*out_format = memory_formats[format].gl.format;
*out_type = memory_formats[format].gl.type;
memcpy (out_swizzle, memory_formats[format].gl.swizzle, sizeof(GLint) * 4);
@@ -1528,6 +1635,8 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
* @gles: TRUE for GLES, FALSE for GL
* @out_actual_format: The actual RGBA format
* @out_internal_format: the GL internal format
* @out_internal_srgb_format: the GL internal format to use for automatic
* sRGB<=>linear conversion
* @out_format: the GL format
* @out_type: the GL type
* @out_swizzle: The swizzle to use
@@ -1546,6 +1655,7 @@ gdk_memory_format_gl_rgba_format (GdkMemoryFormat format,
gboolean gles,
GdkMemoryFormat *out_actual_format,
GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format,
GLenum *out_type,
GLint out_swizzle[4])
@@ -1560,6 +1670,7 @@ gdk_memory_format_gl_rgba_format (GdkMemoryFormat format,
*out_internal_format = memory_formats[actual].gl.internal_gles_format;
else
*out_internal_format = memory_formats[actual].gl.internal_gl_format;
*out_internal_srgb_format = memory_formats[actual].gl.internal_srgb_format;
*out_format = memory_formats[actual].gl.format;
*out_type = memory_formats[actual].gl.type;
memcpy (out_swizzle, memory_formats[format].gl.rgba_swizzle, sizeof(GLint) * 4);
@@ -1613,6 +1724,14 @@ gdk_memory_format_vk_format (GdkMemoryFormat format,
return memory_formats[format].vk_format;
}
/* Gets the matching SRGB version of a VkFormat
* Returns VK_FORMAT_UNDEFINED if none exists */
VkFormat
gdk_memory_format_vk_srgb_format (GdkMemoryFormat format)
{
return memory_formats[format].vk_srgb_format;
}
/* Vulkan version of gdk_memory_format_gl_rgba_format()
* Returns VK_FORMAT_UNDEFINED on failure */
VkFormat
@@ -1661,6 +1780,12 @@ gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat format)
#endif
}
const char *
gdk_memory_format_get_name (GdkMemoryFormat format)
{
return memory_formats[format].name;
}
static void
premultiply (float *rgba,
gsize n)
@@ -1708,6 +1833,10 @@ gdk_memory_convert (guchar *dest_data,
g_assert (dest_format < GDK_MEMORY_N_FORMATS);
g_assert (src_format < GDK_MEMORY_N_FORMATS);
/* We don't allow overlap here. If you want to do in-place color state conversions,
* use gdk_memory_convert_color_state.
*/
g_assert (dest_data + height * dest_stride < src_data || src_data + height * src_stride < dest_data);
if (src_format == dest_format)
{
@@ -1793,3 +1922,201 @@ gdk_memory_convert (guchar *dest_data,
g_free (tmp);
}
static const guchar srgb_lookup[] = {
0, 12, 21, 28, 33, 38, 42, 46, 49, 52, 55, 58, 61, 63, 66, 68,
70, 73, 75, 77, 79, 81, 82, 84, 86, 88, 89, 91, 93, 94, 96, 97,
99, 100, 102, 103, 104, 106, 107, 109, 110, 111, 112, 114, 115, 116, 117, 118,
120, 121, 122, 123, 124, 125, 126, 127, 129, 130, 131, 132, 133, 134, 135, 136,
137, 138, 139, 140, 141, 142, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
151, 152, 153, 154, 155, 156, 157, 157, 158, 159, 160, 161, 161, 162, 163, 164,
165, 165, 166, 167, 168, 168, 169, 170, 171, 171, 172, 173, 174, 174, 175, 176,
176, 177, 178, 179, 179, 180, 181, 181, 182, 183, 183, 184, 185, 185, 186, 187,
187, 188, 189, 189, 190, 191, 191, 192, 193, 193, 194, 194, 195, 196, 196, 197,
197, 198, 199, 199, 200, 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206,
207, 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214, 214, 215, 215,
216, 217, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, 223, 223, 224,
224, 225, 226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232,
233, 233, 234, 234, 235, 235, 236, 236, 237, 237, 237, 238, 238, 239, 239, 240,
240, 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 245, 246, 246, 247, 247,
248, 248, 249, 249, 250, 250, 251, 251, 251, 252, 252, 253, 253, 254, 254, 255
};
static const guchar srgb_inverse_lookup[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7,
7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12,
13, 13, 13, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 19, 19,
20, 20, 21, 22, 22, 23, 23, 24, 24, 25, 26, 26, 27, 27, 28, 29,
29, 30, 31, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38, 38, 39, 40,
41, 42, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54,
55, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70,
71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 87, 88,
89, 90, 92, 93, 94, 95, 97, 98, 99, 101, 102, 103, 105, 106, 107, 109,
110, 112, 113, 114, 116, 117, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132,
134, 135, 137, 139, 140, 142, 144, 145, 147, 148, 150, 152, 153, 155, 157, 159,
160, 162, 164, 166, 167, 169, 171, 173, 175, 176, 178, 180, 182, 184, 186, 188,
190, 192, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 218, 220,
222, 224, 226, 228, 230, 232, 235, 237, 239, 241, 243, 245, 248, 250, 252, 255
};
static void
convert_srgb_to_srgb_linear (guchar *data,
gsize n)
{
for (gsize i = 0; i < n; i++)
{
guint8 r = data[0];
guint8 g = data[1];
guint8 b = data[2];
guchar a = data[3];
float f = a / 255.0;
if (a < 255)
{
r = r / f;
g = g / f;
b = b / f;
}
r = srgb_inverse_lookup[r];
g = srgb_inverse_lookup[g];
b = srgb_inverse_lookup[b];
data[0] = r * f;
data[1] = g * f;
data[2] = b * f;
data += 4;
}
}
static void
convert_srgb_linear_to_srgb (guchar *data,
gsize n)
{
for (gsize i = 0; i < n; i++)
{
guint8 r = data[0];
guint8 g = data[1];
guint8 b = data[2];
guchar a = data[3];
float f = a / 255.0;
if (a < 255)
{
r = r / f;
g = g / f;
b = b / f;
}
r = srgb_lookup[r];
g = srgb_lookup[g];
b = srgb_lookup[b];
data[0] = r * f;
data[1] = g * f;
data[2] = b * f;
data += 4;
}
}
static void
convert_srgb_to_srgb_linear_in_place (guchar *data,
gsize stride,
gsize width,
gsize height)
{
if (stride == width * 4)
{
convert_srgb_to_srgb_linear (data, height * width);
}
else
{
for (gsize y = 0; y < height; y++)
{
convert_srgb_to_srgb_linear (data, width);
data += stride;
}
}
}
static void
convert_srgb_linear_to_srgb_in_place (guchar *data,
gsize stride,
gsize width,
gsize height)
{
if (stride == width * 4)
{
convert_srgb_linear_to_srgb (data, height * width);
}
else
{
for (gsize y = 0; y < height; y++)
{
convert_srgb_linear_to_srgb (data, width);
data += stride;
}
}
}
typedef void (* StepFunc) (float s0, float s1, float s2,
float *d0, float *d1, float *d2);
void
gdk_memory_convert_color_state (guchar *data,
gsize stride,
GdkMemoryFormat format,
GdkColorState *src_color_state,
GdkColorState *dest_color_state,
gsize width,
gsize height)
{
if (format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED &&
src_color_state == GDK_COLOR_STATE_SRGB &&
dest_color_state == GDK_COLOR_STATE_SRGB_LINEAR)
{
convert_srgb_to_srgb_linear_in_place (data, stride, width, height);
}
else if (format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED &&
src_color_state == GDK_COLOR_STATE_SRGB_LINEAR &&
dest_color_state == GDK_COLOR_STATE_SRGB)
{
convert_srgb_linear_to_srgb_in_place (data, stride, width, height);
}
else
{
/* General case, treat it just like gdk_memory_convert */
const GdkMemoryFormatDescription *desc = &memory_formats[format];
StepFunc func;
float *tmp;
if (src_color_state == GDK_COLOR_STATE_SRGB &&
dest_color_state == GDK_COLOR_STATE_SRGB_LINEAR)
func = gtk_rgb_to_linear_srgb;
else if (src_color_state == GDK_COLOR_STATE_SRGB_LINEAR &&
dest_color_state == GDK_COLOR_STATE_SRGB)
func = gtk_linear_srgb_to_rgb;
else
return;
tmp = g_new (float, width * 4);
for (gsize y = 0; y < height; y++)
{
desc->to_float (tmp, data, width);
if (desc->alpha == GDK_MEMORY_ALPHA_PREMULTIPLIED)
unpremultiply (tmp, width);
for (gsize x = 0; x < 4 * width; x += 4)
func (tmp[x], tmp[x+1], tmp[x+2], &tmp[x], &tmp[x+1], &tmp[x+2]);
if (desc->alpha != GDK_MEMORY_ALPHA_STRAIGHT)
premultiply (tmp, width);
desc->from_float (data, tmp, width);
data += stride;
}
g_free (tmp);
}
}

View File

@@ -57,6 +57,7 @@ GdkMemoryFormat gdk_memory_depth_get_alpha_format (GdkMemoryDepth
void gdk_memory_format_gl_format (GdkMemoryFormat format,
gboolean gles,
GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format,
GLenum *out_type,
GLint out_swizzle[4]);
@@ -64,18 +65,20 @@ gboolean gdk_memory_format_gl_rgba_format (GdkMemoryFormat
gboolean gles,
GdkMemoryFormat *out_actual_format,
GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format,
GLenum *out_type,
GLint out_swizzle[4]);
#ifdef GDK_RENDERING_VULKAN
VkFormat gdk_memory_format_vk_format (GdkMemoryFormat format,
VkComponentMapping *out_swizzle);
VkFormat gdk_memory_format_vk_srgb_format (GdkMemoryFormat format);
VkFormat gdk_memory_format_vk_rgba_format (GdkMemoryFormat format,
GdkMemoryFormat *out_rgba_format,
VkComponentMapping *out_swizzle);
#endif
guint32 gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat format);
const char * gdk_memory_format_get_name (GdkMemoryFormat format);
void gdk_memory_convert (guchar *dest_data,
gsize dest_stride,
@@ -85,6 +88,13 @@ void gdk_memory_convert (guchar
GdkMemoryFormat src_format,
gsize width,
gsize height);
void gdk_memory_convert_color_state (guchar *data,
gsize stride,
GdkMemoryFormat format,
GdkColorState *src_color_state,
GdkColorState *dest_color_state,
gsize width,
gsize height);
G_END_DECLS

View File

@@ -22,6 +22,7 @@
#include "gdkmemorytextureprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkcolorstateprivate.h"
#include "gsk/gl/fp16private.h"
/**
@@ -131,11 +132,15 @@ gdk_memory_sanitize (GBytes *bytes,
* @bytes: the `GBytes` containing the pixel data
* @stride: rowstride for the data
*
* Creates a new texture for a blob of image data.
* Creates a new texture for a blob of sRGB image data.
*
* The `GBytes` must contain @stride × @height pixels
* in the given format.
*
* The data is assumed to be in SRGB. See
* [constructor@Gdk.MemoryTexutre.new_with_color_state]
* for data in other color states.
*
* Returns: (type GdkMemoryTexture): A newly-created `GdkTexture`
*/
GdkTexture *
@@ -144,11 +149,43 @@ gdk_memory_texture_new (int width,
GdkMemoryFormat format,
GBytes *bytes,
gsize stride)
{
return gdk_memory_texture_new_with_color_state (width, height, format,
GDK_COLOR_STATE_SRGB,
bytes, stride);
}
/**
* gdk_memory_texture_new_with_color_state:
* @width: the width of the texture
* @height: the height of the texture
* @format: the format of the data
* @color_state: the `GdkColorState` of the data
* @bytes: the `GBytes` containing the pixel data
* @stride: rowstride for the data
*
* Creates a new texture for a blob of image data.
*
* The `GBytes` must contain @stride x @height pixels
* in the given format and color state.
*
* Returns: A newly-created `GdkTexture`
*
* Since: 4.16
*/
GdkTexture *
gdk_memory_texture_new_with_color_state (int width,
int height,
GdkMemoryFormat format,
GdkColorState *color_state,
GBytes *bytes,
gsize stride)
{
GdkMemoryTexture *self;
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
g_return_val_if_fail (color_state != NULL, NULL);
g_return_val_if_fail (bytes != NULL, NULL);
g_return_val_if_fail (stride >= width * gdk_memory_format_bytes_per_pixel (format), NULL);
/* needs to be this complex to support subtexture of the bottom right part */
@@ -159,6 +196,7 @@ gdk_memory_texture_new (int width,
self = g_object_new (GDK_TYPE_MEMORY_TEXTURE,
"width", width,
"height", height,
"color-state", color_state,
NULL);
GDK_TEXTURE (self)->format = format;
@@ -191,19 +229,19 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
size = source->stride * (height - 1) + width * bpp;
bytes = g_bytes_new_from_bytes (source->bytes, offset, size);
result = gdk_memory_texture_new (width,
height,
texture->format,
bytes,
source->stride);
result = gdk_memory_texture_new_with_color_state (width,
height,
texture->format,
texture->color_state,
bytes,
source->stride);
g_bytes_unref (bytes);
return result;
}
GdkMemoryTexture *
gdk_memory_texture_from_texture (GdkTexture *texture,
GdkMemoryFormat format)
gdk_memory_texture_from_texture (GdkTexture *texture)
{
GdkTexture *result;
GBytes *bytes;
@@ -213,23 +251,19 @@ gdk_memory_texture_from_texture (GdkTexture *texture,
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
if (GDK_IS_MEMORY_TEXTURE (texture))
{
GdkMemoryTexture *memtex = GDK_MEMORY_TEXTURE (texture);
return g_object_ref (GDK_MEMORY_TEXTURE (texture));
if (gdk_texture_get_format (texture) == format)
return g_object_ref (memtex);
}
stride = texture->width * gdk_memory_format_bytes_per_pixel (format);
stride = texture->width * gdk_memory_format_bytes_per_pixel (texture->format);
data = g_malloc_n (stride, texture->height);
gdk_texture_do_download (texture, format, data, stride);
gdk_texture_do_download (texture, texture->format, data, stride);
bytes = g_bytes_new_take (data, stride * texture->height);
result = gdk_memory_texture_new (texture->width,
texture->height,
format,
bytes,
stride);
result = gdk_memory_texture_new_with_color_state (texture->width,
texture->height,
texture->format,
texture->color_state,
bytes,
stride);
g_bytes_unref (bytes);
return GDK_MEMORY_TEXTURE (result);

View File

@@ -68,6 +68,14 @@ GdkTexture * gdk_memory_texture_new (int
GBytes *bytes,
gsize stride);
GDK_AVAILABLE_IN_4_16
GdkTexture * gdk_memory_texture_new_with_color_state (int width,
int height,
GdkMemoryFormat format,
GdkColorState *color_state,
GBytes *bytes,
gsize stride);
G_END_DECLS

View File

@@ -28,8 +28,7 @@ G_BEGIN_DECLS
#define GDK_MEMORY_GDK_PIXBUF_OPAQUE GDK_MEMORY_R8G8B8
#define GDK_MEMORY_GDK_PIXBUF_ALPHA GDK_MEMORY_R8G8B8A8
GdkMemoryTexture * gdk_memory_texture_from_texture (GdkTexture *texture,
GdkMemoryFormat format);
GdkMemoryTexture * gdk_memory_texture_from_texture (GdkTexture *texture);
GdkTexture * gdk_memory_texture_new_subtexture (GdkMemoryTexture *texture,
int x,
int y,

View File

@@ -744,3 +744,11 @@ gdk_monitor_set_description (GdkMonitor *monitor,
g_object_notify_by_pspec (G_OBJECT (monitor), props[PROP_DESCRIPTION]);
}
#define MM_PER_INCH 25.4
double
gdk_monitor_get_dpi (GdkMonitor *monitor)
{
return MAX ((monitor->geometry.width * monitor->scale) / (monitor->width_mm / MM_PER_INCH),
(monitor->geometry.height * monitor->scale) / (monitor->height_mm / MM_PER_INCH));
}

View File

@@ -76,6 +76,7 @@ void gdk_monitor_set_subpixel_layout (GdkMonitor *monitor,
void gdk_monitor_invalidate (GdkMonitor *monitor);
void gdk_monitor_set_description (GdkMonitor *monitor,
const char *description);
double gdk_monitor_get_dpi (GdkMonitor *monitor);
G_END_DECLS

View File

@@ -59,7 +59,7 @@ typedef enum {
* @get_current_image: return a `GdkPaintable` that does not change over
* time. This means the `GDK_PAINTABLE_STATIC_SIZE` and
* `GDK_PAINTABLE_STATIC_CONTENTS` flag are set.
* @get_flags: Get the flags for this instance. See [enum@Gdk.PaintableFlags]
* @get_flags: Get the flags for this instance. See [flags@Gdk.PaintableFlags]
* for details.
* @get_intrinsic_width: The preferred width for this object to be
* snapshot at or 0 if none. This is purely a hint. The object must still

Some files were not shown because too many files have changed in this diff Show More