Compare commits
12 Commits
macos-tran
...
wip/matthi
Author | SHA1 | Date | |
---|---|---|---|
|
4c5fc2db89 | ||
|
9faeea801e | ||
|
26aecbb006 | ||
|
17ccb849b3 | ||
|
4a3894e820 | ||
|
156a7450be | ||
|
b7988d133d | ||
|
1baaeeb048 | ||
|
63f489dc64 | ||
|
3323f08c75 | ||
|
35060aae8d | ||
|
c6c13ded6a |
@@ -117,11 +117,10 @@ release-build:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||
script:
|
||||
- .gitlab-ci/show-info-linux.sh
|
||||
- mkdir _install
|
||||
- export PATH="$HOME/.local/bin:${CI_PROJECT_DIR}/_install/bin:$PATH"
|
||||
- .gitlab-ci/install-meson-project.sh --prefix ${CI_PROJECT_DIR}/_install https://gitlab.gnome.org/jadahl/catch.git main
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- meson subprojects download
|
||||
- meson subprojects update --reset
|
||||
- mkdir _install
|
||||
- meson setup
|
||||
--prefix=${CI_PROJECT_DIR}/_install
|
||||
${COMMON_MESON_FLAGS}
|
||||
@@ -446,10 +445,10 @@ reference:
|
||||
--force-fallback-for=gdk-pixbuf,pango
|
||||
-Dintrospection=enabled
|
||||
-Ddocumentation=true
|
||||
-Dman-pages=true
|
||||
-Dgtk_doc=true
|
||||
-Dgdk-pixbuf:gtk_doc=true
|
||||
-Dpango:documentation=true
|
||||
-Dbuild-demos=true
|
||||
-Dpango:gtk_doc=true
|
||||
-Dbuild-demos=false
|
||||
-Dbuild-examples=false
|
||||
-Dbuild-tests=false
|
||||
-Dbuild-testsuite=false
|
||||
@@ -461,7 +460,6 @@ 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/
|
||||
|
BIN
.gitlab-ci/.fedora.Dockerfile.swp
Normal file
@@ -19,12 +19,13 @@ 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 \
|
||||
-Dprofile=devel \
|
||||
-Ddemo-profile=devel \
|
||||
_flatpak_build
|
||||
|
||||
flatpak build --env=CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA ${builddir} ninja -C _flatpak_build install
|
||||
|
@@ -1,91 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
usage() {
|
||||
cat <<-EOF
|
||||
Usage: $(basename $0) [OPTION…] REPO_URL COMMIT
|
||||
|
||||
Check out and install a meson project
|
||||
|
||||
Options:
|
||||
-Dkey=val Option to pass on to meson
|
||||
--prefix Prefix to install to
|
||||
--subdir Build subdirectory instead of whole project
|
||||
--prepare Script to run before build
|
||||
|
||||
-h, --help Display this help
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
TEMP=$(getopt \
|
||||
--name=$(basename $0) \
|
||||
--options='D:h' \
|
||||
--longoptions='prefix:' \
|
||||
--longoptions='subdir:' \
|
||||
--longoptions='prepare:' \
|
||||
--longoptions='help' \
|
||||
-- "$@")
|
||||
|
||||
eval set -- "$TEMP"
|
||||
unset TEMP
|
||||
|
||||
MESON_OPTIONS=()
|
||||
PREFIX=/usr
|
||||
SUBDIR=.
|
||||
PREPARE=:
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-D)
|
||||
MESON_OPTIONS+=( -D$2 )
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--prefix)
|
||||
PREFIX=$2
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--subdir)
|
||||
SUBDIR=$2
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--prepare)
|
||||
PREPARE=$2
|
||||
shift 2
|
||||
;;
|
||||
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $# -lt 2 ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REPO_URL="$1"
|
||||
COMMIT="$2"
|
||||
|
||||
CHECKOUT_DIR=$(mktemp --directory)
|
||||
trap "rm -rf $CHECKOUT_DIR" EXIT
|
||||
|
||||
git clone --depth 1 "$REPO_URL" -b "$COMMIT" "$CHECKOUT_DIR"
|
||||
|
||||
pushd "$CHECKOUT_DIR/$SUBDIR"
|
||||
sh -c "$PREPARE"
|
||||
meson setup --prefix "$PREFIX" _build "${MESON_OPTIONS[@]}"
|
||||
meson compile -C _build
|
||||
meson install -C _build
|
||||
popd
|
@@ -34,8 +34,7 @@ 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-headers
|
||||
mingw-w64-$MSYS2_ARCH-vulkan
|
||||
|
||||
mkdir -p _ccache
|
||||
export CCACHE_BASEDIR="$(pwd)"
|
||||
@@ -45,7 +44,7 @@ export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
|
||||
ccache --zero-stats
|
||||
ccache --show-stats
|
||||
export CCACHE_DISABLE=true
|
||||
meson setup \
|
||||
meson \
|
||||
-Dx11-backend=false \
|
||||
-Dwayland-backend=false \
|
||||
-Dwin32-backend=true \
|
||||
|
@@ -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 the process for [GNOME security issues](https://security.gnome.org/).
|
||||
When in doubt, follow [security](https://security.gnome.org/).
|
||||
|
||||
### Bug reports
|
||||
|
||||
@@ -100,16 +100,14 @@ development tools appropriate for your operating system, including:
|
||||
- Meson
|
||||
- Ninja
|
||||
- Gettext (19.7 or newer)
|
||||
- a [C99 compatible compiler][glib-toolchain-reqs]
|
||||
- a [C99 compatible compiler](https://wiki.gnome.org/Projects/GLib/CompilerRequirements)
|
||||
|
||||
Up-to-date instructions about developing GNOME applications and libraries
|
||||
can be found on [the GNOME Developer Center](https://developer.gnome.org).
|
||||
|
||||
The GTK project uses GitLab for code hosting and for tracking issues. More
|
||||
information about using GitLab can be found on [the GNOME handbook][handbook].
|
||||
|
||||
[glib-toolchain-reqs]: https://gitlab.gnome.org/GNOME/glib/-/blob/main/docs/toolchain-requirements.md
|
||||
[handbook]: https://handbook.gnome.org/infrastructure/gitlab.html
|
||||
information about using GitLab can be found [on the GNOME
|
||||
wiki](https://wiki.gnome.org/GitLab).
|
||||
|
||||
### Dependencies
|
||||
|
||||
@@ -133,7 +131,7 @@ GTK will attempt to download and build some of these dependencies if it
|
||||
cannot find them on your system.
|
||||
|
||||
Additionally, you may want to look at projects that create a development
|
||||
environment for you, like [jhbuild](https://gitlab.gnome.org/GNOME/jhbuild)
|
||||
environment for you, like [jhbuild](https://wiki.gnome.org/HowDoI/Jhbuild)
|
||||
and [gvsbuild](https://github.com/wingtk/gvsbuild).
|
||||
|
||||
### Getting started
|
||||
@@ -146,28 +144,33 @@ $ 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 setup _builddir .
|
||||
$ meson compile -C _builddir
|
||||
$ meson _builddir .
|
||||
$ cd _builddir
|
||||
$ ninja
|
||||
```
|
||||
|
||||
Typically, you should work on your own branch:
|
||||
|
||||
```sh
|
||||
$ git switch -C your-branch
|
||||
$ git checkout -b 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.
|
||||
@@ -259,4 +262,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://handbook.gnome.org/infrastructure/developer-access.html).
|
||||
process](https://wiki.gnome.org/AccountsTeam/NewAccounts).
|
||||
|
364
NEWS
@@ -1,368 +1,6 @@
|
||||
Overview of Changes in 4.15.5, xx-xx-xxxx
|
||||
Overview of Changes in 4.14.2, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
Overview of Changes in 4.15.4, 30-07-2024
|
||||
=========================================
|
||||
|
||||
* GtkPopover:
|
||||
- Fix size allocation with wrapping labels
|
||||
|
||||
* GtkColumnView:
|
||||
- Check column visibility when measuring
|
||||
|
||||
* CSS:
|
||||
- Fix fallout from recent changes
|
||||
- Make implementation of currentcolor inheritance match browsers
|
||||
|
||||
* Gdk:
|
||||
- Introduce GdkColorState for encoding color space information
|
||||
Currently, we support srgb, srgb-linear, rec2100-pq and rec2100-linear
|
||||
- Add color states to GdkTexture, as well as to the texture builder
|
||||
and downloader objects, and convert as necessary
|
||||
- Add GdkMemoryTextureBuilder
|
||||
- Attach color states when loading or saving textures
|
||||
- Add GdkCicpParams to create color state objects for cicp tuples
|
||||
- Drop GDK_DEBUG=vulkan-validate
|
||||
Use VK_INSTEANCE_LAYERS=VK_LAYER_KHRONOS_validation instead
|
||||
|
||||
* Gsk:
|
||||
- Improve caching of glyphs and textures
|
||||
- Remove the uber shader
|
||||
- Numerous bug fixes
|
||||
- Fix corner cases in offload handling
|
||||
- Implement occlusion culling for opaque content
|
||||
- Allow offloading (some) transformed textures
|
||||
- Take colorstate into account when compositing
|
||||
- Add GDK_DEBUG=linear to opt into linear compositing
|
||||
- Implement tiling for large textures
|
||||
- Stop using descriptors and go back to simpler texture
|
||||
management that should work better with older GL
|
||||
- Use correct shader clip mode for glyphs
|
||||
- Improve shadow rendering
|
||||
|
||||
* Media:
|
||||
- Attach color states to textures obtained from gstreamer
|
||||
|
||||
* Wayland:
|
||||
- Allow offloading GL textures via dmabuf export
|
||||
- Suppot the xx-color-management-v4 protocol
|
||||
|
||||
* Deprecations:
|
||||
- GskGLShader and the render node
|
||||
|
||||
* Tools:
|
||||
- Improve the rendernode tool extract command
|
||||
- Add an image tool that is about manipulating textures
|
||||
|
||||
* Build:
|
||||
- GTK now requires a C11 compiler
|
||||
|
||||
* Translation updates
|
||||
Georgian
|
||||
Hebrew
|
||||
Hindi
|
||||
Occitan
|
||||
Slovenian
|
||||
|
||||
|
||||
Overview of Changes in 4.15.3, 29-06-2024
|
||||
=========================================
|
||||
|
||||
* Accessibility:
|
||||
- Only emit notifications when cursor positions change in GtkText
|
||||
- Fix handling of help text properties
|
||||
|
||||
* CSS:
|
||||
- Fix some crashes introduced in recent currentcolor changes
|
||||
|
||||
* DND:
|
||||
- Avoid a critical
|
||||
|
||||
* Documentation:
|
||||
- Fix many oversights and missing docs
|
||||
|
||||
* maxOS:
|
||||
- Add native keyboard shortcuts
|
||||
|
||||
|
||||
Overview of Changes in 4.15.2, 28-06-2024
|
||||
=========================================
|
||||
|
||||
* GtkFileChooserWidget:
|
||||
- Plug some memory leaks
|
||||
- Make Ctrl-Shift-N create a new folder
|
||||
|
||||
* GtkPopover:
|
||||
- Handle resizing and position changes better
|
||||
|
||||
* CSS:
|
||||
- Support color(), oklab(), etc (https://www.w3.org/TR/css-color-4/)
|
||||
- Support color-mix() (https://www.w3.org/TR/css-color-5/)
|
||||
- Support relative colors (https://www.w3.org/TR/css-color-5/)
|
||||
- Support more colorspaces in color()
|
||||
- Allow percentages for opacity
|
||||
- Handle currentcolor more correctly
|
||||
|
||||
* Accessibility:
|
||||
- Avoid markup when reading labels
|
||||
|
||||
* GSK:
|
||||
- Subset fonts when serializing node trees
|
||||
- Make ngl export render_texture results as dmabufs
|
||||
|
||||
* Wayland:
|
||||
- Use xdg-dialog protocol for attached dialogs
|
||||
|
||||
* Windows:
|
||||
- Build with UNICODE
|
||||
|
||||
* macOS:
|
||||
- Implement fullscreen-on-monitor
|
||||
|
||||
* Documentation:
|
||||
- Widget shortcuts and actions are now described in the docs
|
||||
|
||||
* Debugging:
|
||||
- Add GTK_DEBUG=css for warning about deprecated css syntax
|
||||
|
||||
* Tools:
|
||||
- rendernode-tool: Add an extract command for data urls
|
||||
|
||||
* Deprecations:
|
||||
- CSS Color functions shade(), lighter(), darker(), alpha(), mix()
|
||||
|
||||
* Translation updates:
|
||||
Czech
|
||||
Hebrew
|
||||
Serbian
|
||||
|
||||
|
||||
Overview of Changes in 4.15.1, 21-05-2024
|
||||
=========================================
|
||||
|
||||
* GtkGraphicsOffload:
|
||||
- Don't crash without a child
|
||||
|
||||
* GtkSpinner:
|
||||
- Don't animate when unmapped
|
||||
|
||||
* CSS:
|
||||
- Support the :root selector
|
||||
- Support variables and custom properties (https://www.w3.org/TR/css-variables-1/)
|
||||
- Implement math functions (https://www.w3.org/TR/css-values-4/)
|
||||
- Support modern syntax and calc in rgb() and hsl()
|
||||
|
||||
* Icontheme:
|
||||
- Make symbolic svg loading more efficient
|
||||
- Handle color-free symbolics more efficiently
|
||||
|
||||
* Accessibility:
|
||||
- Make the gtk-demo sidebar search more accessible
|
||||
- Stop emitting focus events
|
||||
- Realize child contexts when necessary
|
||||
|
||||
* GDK:
|
||||
- Support XDG_ACTIVATION_TOKEN
|
||||
- dmabuf: Be more defensive when importing unknown formats to GL
|
||||
- dmabuf: Use narrow range for YUV
|
||||
- vulkan: Recreate swapchains when necessary or beneficial
|
||||
|
||||
* GSK:
|
||||
- Improve logging for GDK_DEBUG=offload
|
||||
- Improve logging for GSK_DEBUG=renderer
|
||||
- gpu: Warn about inefficient texture import
|
||||
- gpu: Handle tiny offscreens correctly
|
||||
- vulkan: Add profiler marks in various places
|
||||
- vulkan: Fix a problem with imported dmabufs showing up black
|
||||
- cairo: Speed up mask nodes, since we use them for symbolic icons
|
||||
|
||||
* Wayland:
|
||||
- Use wl_compositor version 6
|
||||
|
||||
* X11:
|
||||
- Implement a missing method
|
||||
|
||||
* Build:
|
||||
- Fix many ubsan warnings
|
||||
|
||||
* Debugging:
|
||||
- Show more texture details in the recorder
|
||||
- Use GTK_DEBUG=css to see CSS deprecations
|
||||
|
||||
* macOS:
|
||||
- Fix problems with events handed back to the OS
|
||||
- Respect GDK_DEBUG=default-settings
|
||||
- Allow applictions to handle Dock > Quit
|
||||
|
||||
* Deprecations:
|
||||
- Use of @name colors in CSS
|
||||
|
||||
* Translation updates:
|
||||
Catalan
|
||||
Georgian
|
||||
Hungarian
|
||||
Korean
|
||||
Portuguese
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.15.0, 21-04-2024
|
||||
=========================================
|
||||
|
||||
This release changes the default GSK renderer to be Vulkan, on
|
||||
Wayland. Other platforms still use ngl.
|
||||
|
||||
The intent of this change is to get wider testing and verify that
|
||||
Vulkan drivers are good enough for us to rely on. If significant
|
||||
problems show up, we will revert this change for 4.16.
|
||||
|
||||
You can still override the renderer choice using the GSK_RENDERER
|
||||
environment variable.
|
||||
|
||||
---
|
||||
|
||||
This release also changes font rendering settings by introducing
|
||||
a new high-level gtk-font-rendering settings which gives GTK more
|
||||
freedom to decide on font rendering.
|
||||
|
||||
You can still use the low-level font-related settings by changing
|
||||
the new property to 'manual'.
|
||||
|
||||
---
|
||||
|
||||
* GtkColumnView:
|
||||
- Fix infinite loops in dispose
|
||||
- Fix problems with weak ref cycles in GtkExpression
|
||||
|
||||
* GtkListView:
|
||||
* GtkShortcutManager:
|
||||
- Track the propagation phase of added controllers
|
||||
|
||||
* GtkGLArea:
|
||||
- Produce dmabuf textures, so graphics offload is possible
|
||||
|
||||
* GtkTextView:
|
||||
- Support text shadows
|
||||
|
||||
* GtkGraphicsOffload:
|
||||
- Add a black-background property
|
||||
|
||||
* Settings:
|
||||
- Add a new gtk-font-rendering setting
|
||||
|
||||
* Accessibility:
|
||||
- Add support for GetRangeExtents to GtkAccessibleText
|
||||
- Add support for GetOffsetAtPoint to GtkAccessibleText
|
||||
- Implement GtkAccessibleRange for scrollbars
|
||||
|
||||
* GDK:
|
||||
- Add a callback-based cursor API
|
||||
|
||||
* GSK:
|
||||
- Use the Vulkan renderer by default
|
||||
- Avoid an infinite recursion with offscreens in some cases
|
||||
- Optimize graphics offload to make it more likely that compositors
|
||||
can use direct scanout
|
||||
|
||||
* X11:
|
||||
- Fix some confusing debug messages
|
||||
- Drop a no-longer-relevant optimization that was interfering with
|
||||
getting the current window manager capabilities
|
||||
|
||||
* macOS:
|
||||
- Implement the color picker for macOS 10.15+
|
||||
|
||||
* Debugging:
|
||||
- Snow monitor resolution in the inspector
|
||||
|
||||
* Demos:
|
||||
- Use graphics offload in the shadertoy demo
|
||||
- Show more reliable fps numbers in the fishbowl demo
|
||||
|
||||
* Tools:
|
||||
- Support generating pdf in gtk4-rendernode-tool
|
||||
|
||||
* Build:
|
||||
- Require pango 1.52
|
||||
- Require cairo 1.18
|
||||
- Add a missing dependency that was causing build failures
|
||||
- Drop deprecated build options:
|
||||
gtk_doc -> documentation
|
||||
update_screenshots -> screenshots
|
||||
demo-profile -> profile
|
||||
demos -> build-demos
|
||||
|
||||
* Deprecations:
|
||||
- gdk_widget_set/get_font_options
|
||||
- gdk_wayland/x11_display_set_cursor_theme
|
||||
|
||||
* Translation updates:
|
||||
Basque
|
||||
Brazilian Portuguese
|
||||
British English
|
||||
Chinese (China)
|
||||
Hebrew
|
||||
Kabyle
|
||||
Persian
|
||||
Polish
|
||||
Russian
|
||||
Slovenian
|
||||
Swedish
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.14.2, 03-04-2024
|
||||
=========================================
|
||||
|
||||
* GtkScale:
|
||||
- Improve positioning of values in some cases
|
||||
|
||||
* Theme:
|
||||
- Make progress in entries visible
|
||||
|
||||
* Accessibility:
|
||||
- Fix text insertion handling
|
||||
|
||||
* GDK:
|
||||
- dnd: Use the default cursor durion motion
|
||||
- dnd: Use a better cursor for indicating the move action
|
||||
|
||||
* GSK:
|
||||
- gl: Handle offloads in offscreen context better
|
||||
- Fix text rendering problems with some fonts
|
||||
|
||||
* Wayland:
|
||||
- Tighten up some protocol version checks
|
||||
- Use the presentation time protocol
|
||||
- Fix a crash with subsurfaces
|
||||
- Improve settings portal handling
|
||||
|
||||
* macOS:
|
||||
- Fix up the app menu support
|
||||
|
||||
* Windows:
|
||||
- Fix problems with minimization
|
||||
- Fix build without fontconfig
|
||||
|
||||
* Debugging:
|
||||
- Add font settings in the inspector
|
||||
|
||||
* Demos:
|
||||
- Clean up the application demo
|
||||
- Update cursor images for the cursor demo
|
||||
|
||||
* Translation updates:
|
||||
Catalan
|
||||
Czech
|
||||
French
|
||||
Georgian
|
||||
Hebrew
|
||||
Persian
|
||||
Slovenian
|
||||
Turkish
|
||||
Ukrainian
|
||||
|
||||
|
||||
Overview of Changes in 4.14.1, 16-03-2024
|
||||
=========================================
|
||||
|
||||
|
17
README.md
@@ -39,21 +39,18 @@ Nightly documentation can be found at
|
||||
- Gsk: https://gnome.pages.gitlab.gnome.org/gtk/gsk4/
|
||||
|
||||
Nightly flatpaks of our demos can be installed from the
|
||||
[GNOME Nightly](https://nightly.gnome.org/) repository:
|
||||
|
||||
```sh
|
||||
flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
|
||||
flatpak install gnome-nightly org.gtk.Demo4
|
||||
flatpak install gnome-nightly org.gtk.WidgetFactory4
|
||||
flatpak install gnome-nightly org.gtk.IconBrowser4
|
||||
```
|
||||
[GNOME Nightly](https://wiki.gnome.org/Apps/Nightly) repository:
|
||||
- `flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo`
|
||||
- `flatpak install gnome-nightly org.gtk.Demo4`
|
||||
- `flatpak install gnome-nightly org.gtk.WidgetFactory4`
|
||||
- `flatpak install gnome-nightly org.gtk.IconBrowser4`
|
||||
|
||||
Building and installing
|
||||
-----------------------
|
||||
|
||||
In order to build GTK you will need:
|
||||
|
||||
- [a C11 compatible compiler](https://gitlab.gnome.org/GNOME/glib/-/blob/main/docs/toolchain-requirements.md)
|
||||
- [a C99 compatible compiler](https://wiki.gnome.org/Projects/GLib/CompilerRequirements)
|
||||
- [Python 3](https://www.python.org/)
|
||||
- [Meson](http://mesonbuild.com)
|
||||
- [Ninja](https://ninja-build.org)
|
||||
@@ -128,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/).
|
||||
Bugs should be reported on the [issues page](https://gitlab.gnome.org/GNOME/gtk/issues/new).
|
||||
|
||||
In the bug report please include:
|
||||
|
||||
|
@@ -185,8 +185,9 @@
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib",
|
||||
"-Dvulkan=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Dprofile=devel"
|
||||
"-Ddemo-profile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
@@ -114,8 +114,9 @@
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib",
|
||||
"-Dvulkan=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Dprofile=devel"
|
||||
"-Ddemo-profile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
@@ -114,8 +114,9 @@
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib",
|
||||
"-Dvulkan=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Dprofile=devel"
|
||||
"-Ddemo-profile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
@@ -130,6 +131,7 @@
|
||||
"env" : {
|
||||
"DBUS_SESSION_BUS_ADDRESS" : "''",
|
||||
"GSK_RENDERER" : "opengl",
|
||||
"GDK_DEBUG" : "vulkan-disable",
|
||||
"G_ENABLE_DEBUG" : "true"
|
||||
}
|
||||
}
|
||||
|
@@ -114,8 +114,9 @@
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib",
|
||||
"-Dvulkan=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Dprofile=devel"
|
||||
"-Ddemo-profile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
@@ -130,6 +131,7 @@
|
||||
"env" : {
|
||||
"DBUS_SESSION_BUS_ADDRESS" : "''",
|
||||
"GSK_RENDERER" : "opengl",
|
||||
"GDK_DEBUG" : "vulkan-disable",
|
||||
"G_ENABLE_DEBUG" : "true"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -15,54 +15,12 @@ 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"));
|
||||
@@ -71,10 +29,6 @@ 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);
|
||||
}
|
||||
|
||||
|
@@ -116,7 +116,6 @@
|
||||
<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>
|
||||
|
@@ -170,7 +170,6 @@ update_paintable (GtkWidget *widget,
|
||||
static GtkWidget *
|
||||
create_cogs (void)
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
GtkWidget *picture;
|
||||
static GskGLShader *cog_shader = NULL;
|
||||
GdkPaintable *paintable;
|
||||
@@ -183,7 +182,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_widget_add_tick_callback (picture, update_paintable, NULL, NULL);
|
||||
|
||||
return picture;
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@@ -363,9 +363,7 @@ insert_markup_idle (gpointer data)
|
||||
|
||||
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
||||
{
|
||||
guint id;
|
||||
id = g_idle_add (insert_markup_idle, data);
|
||||
g_source_set_name_by_id (id, "[gtk-demo] insert_markup_idle");
|
||||
g_idle_add (insert_markup_idle, data);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
@@ -400,9 +398,7 @@ parse_markup_idle (gpointer data)
|
||||
do {
|
||||
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
||||
{
|
||||
guint id;
|
||||
id = g_idle_add (parse_markup_idle, data);
|
||||
g_source_set_name_by_id (id, "[gtk-demo] parse_markup_idle");
|
||||
g_idle_add (parse_markup_idle, data);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
|
@@ -20,8 +20,6 @@
|
||||
#include "gtkshadertoy.h"
|
||||
#include "gskshaderpaintable.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *demo_window = NULL;
|
||||
|
||||
static void
|
||||
@@ -362,5 +360,3 @@ do_gltransition (GtkWidget *do_widget)
|
||||
|
||||
return demo_window;
|
||||
}
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
@@ -22,8 +22,6 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "gskshaderpaintable.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* GskShaderPaintable:
|
||||
*
|
||||
@@ -334,5 +332,3 @@ gsk_shader_paintable_update_time (GskShaderPaintable *self,
|
||||
|
||||
g_bytes_unref (args);
|
||||
}
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
@@ -22,8 +22,6 @@
|
||||
#include <gdk/gdk.h>
|
||||
#include <gsk/gsk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_SHADER_PAINTABLE (gsk_shader_paintable_get_type ())
|
||||
@@ -43,5 +41,3 @@ void gsk_shader_paintable_update_time (GskShaderPaintable *self
|
||||
int time_idx,
|
||||
gint64 frame_time);
|
||||
G_END_DECLS
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
@@ -1,138 +0,0 @@
|
||||
<?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>
|
Before Width: | Height: | Size: 4.8 KiB |
@@ -456,33 +456,43 @@ gtk_fishbowl_do_update (GtkFishbowl *fishbowl)
|
||||
{
|
||||
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
|
||||
GdkFrameClock *frame_clock;
|
||||
GdkFrameTimings *end;
|
||||
gint64 end_counter;
|
||||
double fps, expected_fps;
|
||||
GdkFrameTimings *start, *end;
|
||||
gint64 start_counter, end_counter;
|
||||
gint64 n_frames, expected_frames;
|
||||
gint64 start_timestamp, end_timestamp;
|
||||
gint64 interval;
|
||||
|
||||
frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (fishbowl));
|
||||
if (frame_clock == NULL)
|
||||
return;
|
||||
|
||||
fps = gdk_frame_clock_get_fps (frame_clock);
|
||||
if (fps <= 0.0)
|
||||
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)
|
||||
return;
|
||||
|
||||
priv->framerate = fps;
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -490,16 +500,16 @@ gtk_fishbowl_do_update (GtkFishbowl *fishbowl)
|
||||
if (interval == 0)
|
||||
return;
|
||||
}
|
||||
expected_fps = (double) G_USEC_PER_SEC / interval;
|
||||
expected_frames = round ((double) (end_timestamp - start_timestamp) / interval);
|
||||
|
||||
if (fps > (expected_fps - 1))
|
||||
if (n_frames >= expected_frames)
|
||||
{
|
||||
if (priv->last_benchmark_change > 0)
|
||||
priv->last_benchmark_change *= 2;
|
||||
else
|
||||
priv->last_benchmark_change = 1;
|
||||
}
|
||||
else if (0.95 * fps < expected_fps)
|
||||
else if (n_frames + 1 < expected_frames)
|
||||
{
|
||||
if (priv->last_benchmark_change < 0)
|
||||
priv->last_benchmark_change--;
|
||||
|
@@ -1,7 +1,5 @@
|
||||
#include "gtkshaderbin.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef struct {
|
||||
GskGLShader *shader;
|
||||
GtkStateFlags state;
|
||||
@@ -264,5 +262,3 @@ gtk_shader_bin_new (void)
|
||||
|
||||
return GTK_WIDGET (self);
|
||||
}
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_SHADER_BIN (gtk_shader_bin_get_type ())
|
||||
@@ -20,5 +18,3 @@ void gtk_shader_bin_set_child (GtkShaderBin *self,
|
||||
GtkWidget *gtk_shader_bin_get_child (GtkShaderBin *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
@@ -1,7 +1,5 @@
|
||||
#include "gtkshaderstack.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
struct _GtkShaderStack
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
@@ -361,5 +359,3 @@ gtk_shader_stack_set_active (GtkShaderStack *self,
|
||||
self->current = MIN (index, self->children->len);
|
||||
update_child_visible (self);
|
||||
}
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_SHADER_STACK (gtk_shader_stack_get_type ())
|
||||
@@ -20,5 +18,3 @@ void gtk_shader_stack_set_active (GtkShaderStack *self,
|
||||
int index);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
@@ -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;
|
||||
gchar *langname, *locale_abbrev, *locale, *p;
|
||||
gint i;
|
||||
const LCTYPE iso639_lctypes[] = { LOCALE_SISO639LANGNAME, LOCALE_SISO639LANGNAME2 };
|
||||
GHashTable *ht_scripts_langs = (GHashTable *) param;
|
||||
@@ -59,6 +59,7 @@ 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);
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include "config.h"
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "demos.h"
|
||||
#include "fontify.h"
|
||||
@@ -924,34 +923,6 @@ clear_search (GtkSearchBar *bar)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
search_results_update (GObject *filter_model,
|
||||
GParamSpec *pspec,
|
||||
GtkEntry *entry)
|
||||
{
|
||||
gsize n_items = g_list_model_get_n_items (G_LIST_MODEL (filter_model));
|
||||
|
||||
if (strlen (gtk_editable_get_text (GTK_EDITABLE (entry))) > 0)
|
||||
{
|
||||
char *text;
|
||||
|
||||
if (n_items > 0)
|
||||
text = g_strdup_printf (ngettext ("%ld search result", "%ld search results", (long) n_items), (long) n_items);
|
||||
else
|
||||
text = g_strdup (_("No search results"));
|
||||
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_PROPERTY_DESCRIPTION, text,
|
||||
-1);
|
||||
|
||||
g_free (text);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_accessible_reset_property (GTK_ACCESSIBLE (entry), GTK_ACCESSIBLE_PROPERTY_DESCRIPTION);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
activate (GApplication *app)
|
||||
{
|
||||
@@ -999,7 +970,6 @@ 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);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<interface>
|
||||
<menu id="menubar">
|
||||
<submenu>
|
||||
<attribute name="label" translatable="yes">_File</attribute>
|
||||
<attribute name="label" translatable="yes">_Application</attribute>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_New</attribute>
|
||||
@@ -33,7 +33,7 @@
|
||||
</section>
|
||||
</submenu>
|
||||
<submenu>
|
||||
<attribute name="label" translatable="yes">_Preferences</attribute>
|
||||
<attribute name="label" translatable="yes">_File</attribute>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Prefer Dark Theme</attribute>
|
||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -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), gtk_graphics_offload_new (shadertoy));
|
||||
gtk_aspect_frame_set_child (GTK_ASPECT_FRAME (aspect), shadertoy);
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 250);
|
||||
|
@@ -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 | G_APPLICATION_NON_UNIQUE,
|
||||
"flags", G_APPLICATION_HANDLES_OPEN,
|
||||
NULL);
|
||||
|
||||
g_application_add_main_option (G_APPLICATION (app), "version", 0, 0,G_OPTION_ARG_NONE, "Show program version", NULL);
|
||||
|
@@ -330,7 +330,6 @@ 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.
|
||||
|
||||
@@ -347,7 +346,6 @@ 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
|
||||
|
||||
|
@@ -5,11 +5,8 @@ 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 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.
|
||||
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.
|
||||
|
||||
Additional functions allow use [struct@Gdk.Rectangle]s with Cairo
|
||||
and to use [struct@Gdk.RGBA], `GdkPixbuf`, and [class@Gdk.Surface]
|
||||
|
@@ -111,11 +111,3 @@ content_images = [
|
||||
]
|
||||
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gdk/"
|
||||
urlmap_file = "urlmap.js"
|
||||
|
||||
[[object]]
|
||||
name = "DECLARE_INTERNAL_TYPE"
|
||||
hidden = true
|
||||
|
||||
[[object]]
|
||||
pattern = "KEY_*"
|
||||
check_ignore = true
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -29,18 +29,6 @@ if get_option('documentation')
|
||||
install_dir: docs_dir,
|
||||
)
|
||||
|
||||
test('doc-check-gdk',
|
||||
gidocgen,
|
||||
args: [
|
||||
'check',
|
||||
'--config', gdk4_toml,
|
||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
||||
gdk_gir[0],
|
||||
],
|
||||
depends: gdk_gir[0],
|
||||
suite: ['docs'],
|
||||
)
|
||||
|
||||
if x11_enabled
|
||||
gdk4x11_toml = configure_file(
|
||||
input: 'gdk4-x11.toml.in',
|
||||
@@ -99,17 +87,5 @@ if get_option('documentation')
|
||||
install: true,
|
||||
install_dir: docs_dir,
|
||||
)
|
||||
|
||||
test('doc-check-gdk-wayland',
|
||||
gidocgen,
|
||||
args: [
|
||||
'check',
|
||||
'--config', gdk4wayland_toml,
|
||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
||||
gdk_wayland_gir[0],
|
||||
],
|
||||
depends: gdk_wayland_gir[0],
|
||||
suite: ['docs'],
|
||||
)
|
||||
endif
|
||||
endif
|
||||
|
@@ -66,7 +66,3 @@ content_images = [
|
||||
]
|
||||
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gsk/"
|
||||
urlmap_file = "urlmap.js"
|
||||
|
||||
[[object]]
|
||||
name = "INCLUDE_WARNING"
|
||||
hidden = true
|
||||
|
@@ -30,16 +30,4 @@ if get_option('documentation')
|
||||
install: true,
|
||||
install_dir: docs_dir,
|
||||
)
|
||||
|
||||
test('doc-check-gsk',
|
||||
gidocgen,
|
||||
args: [
|
||||
'check',
|
||||
'--config', gsk4_toml,
|
||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
||||
gsk_gir[0],
|
||||
],
|
||||
depends: gsk_gir[0],
|
||||
suite: ['docs'],
|
||||
)
|
||||
endif
|
||||
|
@@ -140,7 +140,7 @@ Other libraries are maintained separately.
|
||||
file formats. It is available [here](ttps://download.gnome.org/sources/gdk-pixbuf/).
|
||||
- [Pango](http://www.pango.org) is a library for internationalized
|
||||
text handling. It is available [here](https://download.gnome.org/sources/pango/).
|
||||
- [GObject Introspection](https://gitlab.gnome.org/GNOME/gobject-introspection)
|
||||
- [GObject Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection)
|
||||
is a framework for making introspection data available to language
|
||||
bindings. It is available [here](https://download.gnome.org/sources/gobject-introspection/).
|
||||
- The [GNU libiconv](https://www.gnu.org/software/libiconv/) library
|
||||
|
@@ -74,7 +74,6 @@ in a selector, widget names must be prefixed with a # 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) | |
|
||||
|
@@ -15,16 +15,16 @@ spec.
|
||||
The following units are supported for basic datatypes:
|
||||
|
||||
Length
|
||||
: px, pt, em, ex, rem, pc, in, cm, mm
|
||||
: px, pt, em, ex, rem, pc, in, cm, mm, calc()
|
||||
|
||||
Percentage
|
||||
: %
|
||||
: %, calc()
|
||||
|
||||
Angle
|
||||
: deg, rad, grad, turn
|
||||
: deg, grad, turn, calc()
|
||||
|
||||
Time
|
||||
: s, ms
|
||||
: s, ms, calc()
|
||||
|
||||
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,15 +33,11 @@ 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.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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
|
||||
@@ -60,80 +56,38 @@ 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
|
||||
|
||||
### 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.
|
||||
GTK extends the CSS syntax with several additional ways to specify colors.
|
||||
|
||||
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)`
|
||||
: multiplies the alpha value of `color` by `number` (between 0 and 1).
|
||||
`alpha(Color, Number)`
|
||||
: replaces the alpha value of color with number (between 0 and 1)
|
||||
|
||||
`mix(color1, color2, number)`
|
||||
: interpolates between the two colors.
|
||||
`mix(Color1, Color2, Number)`
|
||||
: interpolates between the two colors
|
||||
|
||||
## Images
|
||||
|
||||
@@ -141,7 +95,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
|
||||
@@ -170,14 +124,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
|
||||
|
@@ -99,15 +99,16 @@ reaches the requested phase. However, in practice most things
|
||||
happen at higher levels:
|
||||
|
||||
- If you are doing an animation, you can use
|
||||
[method@Gtk.Widget.add_tick_callback] which will cause a regular
|
||||
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 [method@Gtk.Widget.queue_resize] which will request
|
||||
change you call 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 your widget you
|
||||
use [method@Gtk.Widget.queue_draw] to request a Paint phase for
|
||||
your widget.
|
||||
- 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.
|
||||
|
||||
There are also a lot of implicit triggers of these from the
|
||||
CSS layer (which does animations, resizes and repaints as needed).
|
||||
|
@@ -245,6 +245,9 @@ to connect the "clicked" signal with [method@Gtk.Window.destroy], then the funct
|
||||
would be called on `button` (which would not go well, since the function expects
|
||||
a `GtkWindow` as argument).
|
||||
|
||||
More information about creating buttons can be found
|
||||
[here](https://wiki.gnome.org/HowDoI/Buttons).
|
||||
|
||||
The rest of the code in `example-1.c` is identical to `example-0.c`. The next
|
||||
section will elaborate further on how to add several [class@Gtk.Widget]s to your
|
||||
GTK application.
|
||||
|
@@ -8,10 +8,6 @@ gtk4-broadwayd
|
||||
The Broadway display server
|
||||
---------------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
| **gtk4-broadwayd** [OPTIONS...] <DISPLAY>
|
||||
|
@@ -8,10 +8,6 @@ gtk4-builder-tool
|
||||
GtkBuilder File Utility
|
||||
-----------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
| **gtk4-builder-tool** <COMMAND> [OPTIONS...] <FILE>
|
||||
|
@@ -8,9 +8,6 @@ gtk4-demo-application
|
||||
Demonstrate GtkApplication
|
||||
--------------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
@@ -8,10 +8,6 @@ gtk4-demo
|
||||
Demonstrate GTK widgets
|
||||
-----------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
@@ -8,10 +8,6 @@ gtk4-encode-symbolic-svg
|
||||
Symbolic icon conversion utility
|
||||
--------------------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
@@ -8,10 +8,6 @@ gtk4-icon-browser
|
||||
List themed icons
|
||||
-----------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
@@ -1,97 +0,0 @@
|
||||
.. _gtk4-image-tool(1):
|
||||
|
||||
====================
|
||||
gtk4-image-tool
|
||||
====================
|
||||
|
||||
-----------------------
|
||||
Image Utility
|
||||
-----------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
| **gtk4-image-tool** <COMMAND> [OPTIONS...] <FILE>...
|
||||
|
|
||||
| **gtk4-image-tool** compare [OPTIONS...] <FILE1> <FILE2>
|
||||
| **gtk4-image-tool** convert [OPTIONS...] <FILE1> <FILE2>
|
||||
| **gtk4-image-tool** info [OPTIONS...] <FILE>
|
||||
| **gtk4-image-tool** relabel [OPTIONS...] <FILE1> <FILE2>
|
||||
| **gtk4-image-tool** show [OPTIONS...] <FILE>...
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
``gtk4-image-tool`` can perform various operations on images.
|
||||
|
||||
COMMANDS
|
||||
--------
|
||||
|
||||
Information
|
||||
^^^^^^^^^^^
|
||||
|
||||
The ``info`` command shows general information about the image, such
|
||||
as its format and color state.
|
||||
|
||||
Showing
|
||||
^^^^^^^
|
||||
|
||||
The ``show`` command displays one or more images, side-by-side.
|
||||
|
||||
``--undecorated``
|
||||
|
||||
Removes window decorations. This is meant for rendering of exactly the image
|
||||
without any titlebar.
|
||||
|
||||
Compare
|
||||
^^^^^^^
|
||||
|
||||
The ``compare`` command compares two images. If any differences are found,
|
||||
the exit code is 1. If the images are identical, it is 0.
|
||||
|
||||
``--output=FILE``
|
||||
|
||||
Save the differences as a png image in ``FILE``.
|
||||
|
||||
``--quiet``
|
||||
|
||||
Don't write results to stdout.
|
||||
|
||||
Conversion
|
||||
^^^^^^^^^^
|
||||
|
||||
The ``convert`` command converts the image to a different format or color state.
|
||||
|
||||
``--format=FORMAT``
|
||||
|
||||
Convert to the given format. The supported formats can be listed
|
||||
with ``--format=list``.
|
||||
|
||||
``--color-state=COLORSTATE``
|
||||
|
||||
Convert to the given color state. The supported color states can be
|
||||
listed with ``--format=list``.
|
||||
|
||||
``--cicp=CICP``
|
||||
|
||||
Convert to a color state that is specified as a cicp tuple. The cicp tuple
|
||||
must be specified as four numbers, separated by /, e.g. 1/13/6/0.
|
||||
|
||||
Relabeling
|
||||
^^^^^^^^^^
|
||||
|
||||
The ``relabel`` command changes the color state of an image without conversion.
|
||||
This can be useful to produce wrong color renderings for diagnostics.
|
||||
|
||||
``--color-state=COLORSTATE``
|
||||
|
||||
Relabel to the given color state. The supported color states can be
|
||||
listed with ``--format=list``.
|
||||
|
||||
``--cicp=CICP``
|
||||
|
||||
Relabel to a color state that is specified as a cicp tuple. The cicp tuple
|
||||
must be specified as four numbers, separated by /, e.g. 1/13/6/0.
|
@@ -8,10 +8,6 @@ gtk4-launch
|
||||
Launch an application
|
||||
---------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
@@ -8,10 +8,6 @@ gtk4-node-editor
|
||||
Editor render nodes
|
||||
-----------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
@@ -8,10 +8,6 @@ gtk4-path-tool
|
||||
GskPath Utility
|
||||
-----------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
| **gtk4-path-tool** <COMMAND> [OPTIONS...] <PATH>
|
||||
|
@@ -8,10 +8,6 @@ gtk4-query-settings
|
||||
Print name and value of GTK settings
|
||||
------------------------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
@@ -8,17 +8,12 @@ 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>
|
||||
@@ -50,14 +45,13 @@ without any titlebar.
|
||||
Rendering
|
||||
^^^^^^^^^
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
``--renderer=RENDERER``
|
||||
|
||||
Use the given renderer. Use ``--renderer=help`` to get a information
|
||||
about possible values for the ``RENDERER``.
|
||||
about poassible values for the ``RENDERER``.
|
||||
|
||||
Benchmark
|
||||
^^^^^^^^^
|
||||
@@ -99,16 +93,4 @@ exit code is 1. If the images are identical, it is 0.
|
||||
|
||||
``--quiet``
|
||||
|
||||
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).
|
||||
Don't write results to stdout.`
|
||||
|
@@ -8,10 +8,6 @@ gtk4-update-icon-cache
|
||||
Icon theme caching utility
|
||||
--------------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
@@ -8,10 +8,6 @@ gtk4-widget-factory
|
||||
Showcase GTK widgets and styles
|
||||
-------------------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
@@ -77,13 +77,11 @@ 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 = [
|
||||
@@ -251,12 +249,3 @@ content_images = [
|
||||
]
|
||||
content_base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gtk/"
|
||||
urlmap_file = "urlmap.js"
|
||||
|
||||
[[object]]
|
||||
name = "StyleProvider"
|
||||
[[object.signal]]
|
||||
name = "gtk-private-changed"
|
||||
hidden = true
|
||||
|
||||
[check]
|
||||
skip_deprecated = true
|
||||
|
@@ -140,11 +140,6 @@ capture phase, and key bindings locally, during the target phase.
|
||||
Under the hood, all shortcuts are represented as instances of `GtkShortcut`,
|
||||
and they are managed by `GtkShortcutController`.
|
||||
|
||||
Note that GTK does not do anything to map the primary shortcut modifier
|
||||
to <kbd>Command</kbd> on macOS. If you want to let your application to follow
|
||||
macOS user experience conventions, you must create macOS-specific keyboard shortcuts.
|
||||
The <kbd>Command</kbd> is named `Meta` (`GDK_META_MASK`) in GTK.
|
||||
|
||||
## Text input
|
||||
|
||||
When actual text input is needed (i.e. not just keyboard shortcuts),
|
||||
|
@@ -14,7 +14,6 @@ expand_content_md_files = [
|
||||
'running.md',
|
||||
'migrating-2to4.md',
|
||||
'migrating-3to4.md',
|
||||
'migrating-4to5.md',
|
||||
'actions.md',
|
||||
'input-handling.md',
|
||||
'drawing-model.md',
|
||||
@@ -26,8 +25,7 @@ expand_content_md_files = [
|
||||
'section-tree-widget.md',
|
||||
'section-list-widget.md',
|
||||
'question_index.md',
|
||||
'visual_index.md',
|
||||
'tools.md',
|
||||
'visual_index.md'
|
||||
]
|
||||
|
||||
gtk_images = []
|
||||
@@ -62,52 +60,39 @@ if get_option('documentation')
|
||||
build_by_default: true,
|
||||
install: true,
|
||||
install_dir: docs_dir,
|
||||
install_tag: 'doc',
|
||||
)
|
||||
|
||||
test('doc-check-gtk',
|
||||
gidocgen,
|
||||
args: [
|
||||
'check',
|
||||
'--config', gtk4_toml,
|
||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
||||
gtk_gir[0],
|
||||
],
|
||||
depends: gtk_gir[0],
|
||||
suite: ['docs'],
|
||||
)
|
||||
endif
|
||||
|
||||
rst2man = find_program('rst2man', 'rst2man.py', required: get_option('man-pages'))
|
||||
rst2html5 = find_program('rst2html5', 'rst2html5.py', required: get_option('documentation'))
|
||||
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')
|
||||
endif
|
||||
|
||||
rst_files = [
|
||||
[ 'gtk4-broadwayd', '1' ],
|
||||
[ 'gtk4-builder-tool', '1' ],
|
||||
[ 'gtk4-encode-symbolic-svg', '1', ],
|
||||
[ 'gtk4-image-tool', '1' ],
|
||||
[ 'gtk4-launch', '1', ],
|
||||
[ 'gtk4-query-settings', '1', ],
|
||||
[ 'gtk4-rendernode-tool', '1' ],
|
||||
[ 'gtk4-update-icon-cache', '1', ],
|
||||
[ 'gtk4-path-tool', '1', ],
|
||||
]
|
||||
|
||||
if get_option('build-demos')
|
||||
rst_files += [
|
||||
[ 'gtk4-demo', '1', ],
|
||||
[ 'gtk4-demo-application', '1', ],
|
||||
[ 'gtk4-widget-factory', '1', ],
|
||||
[ 'gtk4-icon-browser', '1', ],
|
||||
[ 'gtk4-node-editor', '1', ],
|
||||
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', ],
|
||||
]
|
||||
endif
|
||||
|
||||
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
|
||||
|
||||
if get_option('man-pages')
|
||||
rst2man_flags = [
|
||||
'--syntax-highlight=none',
|
||||
]
|
||||
|
||||
foreach rst: rst_files
|
||||
man_name = rst[0]
|
||||
@@ -118,34 +103,12 @@ if get_option('man-pages')
|
||||
output: '@0@.@1@'.format(man_name, man_section),
|
||||
command: [
|
||||
rst2man,
|
||||
rst2x_flags,
|
||||
rst2man_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
|
||||
|
@@ -451,11 +451,11 @@ hint about how modifiers are expected to be used. It also promoted
|
||||
the use of `<Primary>` instead of `<Control>` to specify accelerators that
|
||||
adapt to platform conventions.
|
||||
|
||||
In GTK 4, the meaning of modifiers has been fixed, and applications are
|
||||
In GTK 4, the meaning of modifiers has been fixed, and backends are
|
||||
expected to map the platform conventions to the existing modifiers.
|
||||
The expected use of modifiers in GTK 4 is:
|
||||
|
||||
`GDK_CONTROL_MASK` (`GDK_META_MASK` on macOS)
|
||||
`GDK_CONTROL_MASK`
|
||||
: Primary accelerators
|
||||
|
||||
`GDK_ALT_MASK`
|
||||
@@ -464,7 +464,7 @@ The expected use of modifiers in GTK 4 is:
|
||||
`GDK_SHIFT_MASK`
|
||||
: Extending selections
|
||||
|
||||
`GDK_CONTROL_MASK` (`GDK_META_MASK` on macOS)
|
||||
`GDK_CONTROL_MASK`
|
||||
: Modifying selections
|
||||
|
||||
`GDK_CONTROL_MASK|GDK_ALT_MASK`
|
||||
@@ -473,15 +473,9 @@ The expected use of modifiers in GTK 4 is:
|
||||
Consequently, `GdkModifierIntent` and related APIs have been removed,
|
||||
and `<Control>` is preferred over `<Primary>` in accelerators.
|
||||
|
||||
In GTK 3 on macOS, the `<Primary>` modifier mapped to the <kbd>Command</kbd> key.
|
||||
In GTK 4, this is no longer the case: `<Primary>` is synonymous to `<Control>`.
|
||||
If you want to make your application to feel native on macOS,
|
||||
you need to add accelerators for macOS that use the `<Meta>` modifier.
|
||||
|
||||
A related change is that GTK 4 no longer supports the use of archaic
|
||||
X11 'real' modifiers with the names Mod1,..., Mod5, and `GDK_MOD1_MASK`
|
||||
has been renamed to `GDK_ALT_MASK` and `GDK_MOD2_MASK` has been renamed to
|
||||
`GDK_META_MASK`.
|
||||
has been renamed to `GDK_ALT_MASK`.
|
||||
|
||||
### Replace `GtkClipboard` with `GdkClipboard`
|
||||
|
||||
|
@@ -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_color].
|
||||
[method@Gtk.Widget.get_style_color].
|
||||
|
||||
## Local stylesheets are going away
|
||||
|
||||
@@ -73,103 +73,6 @@ 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
|
||||
|
@@ -7,5 +7,5 @@ on top of the Quartz API.
|
||||
Currently, the macOS port does not use any additional commandline options
|
||||
or environment variables.
|
||||
|
||||
For up-to-date information on building, installation, and bundling, see the
|
||||
[GTK website](https://www.gtk.org/docs/installations/macos).
|
||||
For up-to-date information about the current status of this port, see the
|
||||
[project page](https://wiki.gnome.org/Projects/GTK/OSX).
|
||||
|
@@ -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://docs.gtk.org/glib/
|
||||
[gobject]: https://docs.gtk.org/gobject/
|
||||
[gio]: https://docs.gtk.org/gio/
|
||||
[glib]: https://developer.gnome.org/glib/stable/
|
||||
[gobject]: https://developer.gnome.org/gobject/stable/
|
||||
[gio]: https://developer.gnome.org/gio/stable/
|
||||
[cairo]: https://www.cairographics.org/manual/
|
||||
[opengl]: https://www.opengl.org/about/
|
||||
[vulkan]: https://www.vulkan.org/
|
||||
[pango]: https://docs.gtk.org/Pango/
|
||||
[gdkpixbuf]: https://docs.gtk.org/gdk-pixbuf/
|
||||
[pango]: https://pango.gnome.org/
|
||||
[gdkpixbuf]: https://developer.gnome.org/gdk-pixbuf/stable/
|
||||
[graphene]: https://ebassi.github.io/graphene/
|
||||
|
@@ -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/) against the
|
||||
[file a bug report](https://gitlab.gnome.org/GNOME/gtk/issues/new) 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/).
|
||||
[file a bug report.](https://gitlab.gnome.org/GNOME/gtk/issues/new).
|
||||
|
||||
The transfer annotations for gobject-introspection that are part of the
|
||||
documentation can provide useful hints for memory handling semantics as well.
|
||||
|
@@ -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/).
|
||||
file a bug report on our [GitLab project](https://gitlab.gnome.org/GNOME/gtk/issues/new).
|
||||
You should also file issues if the documentation is out of date with the
|
||||
existing API, or unclear.
|
||||
|
||||
|
@@ -5,12 +5,10 @@ Slug: gtk-running
|
||||
|
||||
GTK inspects a number of environment variables in addition to
|
||||
standard variables like `LANG`, `PATH`, `HOME` or `DISPLAY`; mostly
|
||||
to determine paths to look for certain files. The
|
||||
[X11](https://docs.gtk.org/gtk4/x11.html#x11-specific-environment-variables),
|
||||
[Wayland](https://docs.gtk.org/gtk4/wayland.html#wayland-specific-environment-variables),
|
||||
[Windows](https://docs.gtk.org/gtk4/windows.html#windows-specific-environment-variables) and
|
||||
[Broadway](https://docs.gtk.org/gtk4/broadway.html#broadway-specific-environment-variables)
|
||||
GDK backends use some additional environment variables.
|
||||
to determine paths to look for certain files. The [X11](#x11-envar),
|
||||
[Wayland](#wayland-envar), [Windows](#win32-envar) and
|
||||
[Broadway](#broadway-envar) GDK backends use some additional
|
||||
environment variables.
|
||||
|
||||
Note that environment variables are generally used for debugging
|
||||
purposes. They are not guaranteed to be API stable, and should not
|
||||
@@ -219,10 +217,6 @@ 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
|
||||
|
||||
@@ -292,8 +286,8 @@ are only available when GTK has been configured with `-Ddebug=true`.
|
||||
`fallback`
|
||||
: Information about fallback usage in renderers
|
||||
|
||||
`cache`
|
||||
: Information about caching
|
||||
`glyphcache`
|
||||
: Information about glyph caching
|
||||
|
||||
`verbose`
|
||||
: Print verbose output while rendering
|
||||
|
@@ -155,7 +155,6 @@ 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
|
||||
|
||||
@@ -217,10 +216,6 @@ 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">
|
||||
|
@@ -1,18 +0,0 @@
|
||||
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)
|
@@ -43,7 +43,7 @@ X11 details, in particular the ICCCM and the Extended Window Manager
|
||||
Hints specifications. [freedesktop.org](http://www.freedesktop.org/standards/)
|
||||
has links to many relevant specifications.
|
||||
|
||||
The GDK manual covers [using Xlib in a GTK program](https://docs.gtk.org/gdk4/x11.html).
|
||||
The GDK manual covers [using Xlib in a GTK program](#gdk-X-Window-System-Interaction).
|
||||
|
||||
### Server, client, window manager
|
||||
|
||||
|
@@ -91,31 +91,6 @@ 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 = [];
|
||||
@@ -240,32 +215,11 @@ 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;
|
||||
@@ -1033,14 +987,7 @@ function handleDisplayCommands(display_commands)
|
||||
break;
|
||||
case DISPLAY_OP_DELETE_SURFACE:
|
||||
var id = cmd[1];
|
||||
if (id == surfaceWithMouse) {
|
||||
surfaceWithMouse = 0;
|
||||
}
|
||||
if (id == realSurfaceWithMouse) {
|
||||
realSurfaceWithMouse = 0;
|
||||
firstTouchDownId = null;
|
||||
}
|
||||
delete surfaces[id];
|
||||
delete surfaces[id];
|
||||
break;
|
||||
case DISPLAY_OP_CHANGE_TEXTURE:
|
||||
var image = cmd[1];
|
||||
@@ -1424,14 +1371,8 @@ function getEffectiveEventTarget (id) {
|
||||
function updateKeyboardStatus() {
|
||||
if (fakeInput != null && showKeyboardChanged) {
|
||||
showKeyboardChanged = false;
|
||||
if (showKeyboard) {
|
||||
if (isAndroidChrome) {
|
||||
fakeInput.blur();
|
||||
fakeInput.value = ' '.repeat(80); // TODO: Should be exchange with broadway server
|
||||
// to bring real value here.
|
||||
}
|
||||
if (showKeyboard)
|
||||
fakeInput.focus();
|
||||
}
|
||||
else
|
||||
fakeInput.blur();
|
||||
}
|
||||
@@ -2983,19 +2924,6 @@ 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--) {
|
||||
@@ -3094,29 +3022,6 @@ 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;
|
||||
}
|
||||
|
||||
@@ -3125,16 +3030,6 @@ 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);
|
||||
@@ -3150,11 +3045,6 @@ function onKeyUp (ev) {
|
||||
return handleKeyUp(ev);
|
||||
}
|
||||
|
||||
function onInput (ev) {
|
||||
updateForEvent(ev);
|
||||
return handleInput(ev);
|
||||
}
|
||||
|
||||
function cancelEvent(ev)
|
||||
{
|
||||
ev = ev ? ev : window.event;
|
||||
@@ -3186,14 +3076,13 @@ function onMouseWheel(ev)
|
||||
}
|
||||
|
||||
function onTouchStart(ev) {
|
||||
ev.preventDefault();
|
||||
event.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);
|
||||
@@ -3201,7 +3090,7 @@ function onTouchStart(ev) {
|
||||
var isEmulated = 0;
|
||||
|
||||
if (firstTouchDownId == null) {
|
||||
firstTouchDownId = touchId;
|
||||
firstTouchDownId = touch.identifier;
|
||||
isEmulated = 1;
|
||||
|
||||
if (realSurfaceWithMouse != origId || id != surfaceWithMouse) {
|
||||
@@ -3216,54 +3105,52 @@ function onTouchStart(ev) {
|
||||
}
|
||||
}
|
||||
|
||||
sendInput (BROADWAY_EVENT_TOUCH, [0, id, touchId, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
|
||||
sendInput (BROADWAY_EVENT_TOUCH, [0, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
|
||||
}
|
||||
}
|
||||
|
||||
function onTouchMove(ev) {
|
||||
ev.preventDefault();
|
||||
event.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 == touchId) {
|
||||
if (firstTouchDownId == touch.identifier) {
|
||||
isEmulated = 1;
|
||||
}
|
||||
|
||||
sendInput (BROADWAY_EVENT_TOUCH, [1, id, touchId, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
|
||||
sendInput (BROADWAY_EVENT_TOUCH, [1, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
|
||||
}
|
||||
}
|
||||
|
||||
function onTouchEnd(ev) {
|
||||
ev.preventDefault();
|
||||
event.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 == touchId) {
|
||||
if (firstTouchDownId == touch.identifier) {
|
||||
isEmulated = 1;
|
||||
firstTouchDownId = null;
|
||||
}
|
||||
|
||||
sendInput (BROADWAY_EVENT_TOUCH, [2, id, touchId, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
|
||||
sendInput (BROADWAY_EVENT_TOUCH, [2, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3280,11 +3167,11 @@ function setupDocument(document)
|
||||
document.onkeyup = onKeyUp;
|
||||
|
||||
if (document.addEventListener) {
|
||||
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);
|
||||
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);
|
||||
} else if (document.attachEvent) {
|
||||
element.attachEvent("onmousewheel", onMouseWheel);
|
||||
}
|
||||
@@ -3350,14 +3237,12 @@ function connect()
|
||||
};
|
||||
|
||||
var iOS = /(iPad|iPhone|iPod)/g.test( navigator.userAgent );
|
||||
if (iOS || isAndroidChrome) {
|
||||
if (iOS) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -33,11 +33,9 @@ gdk_broadway_cairo_context_dispose (GObject *object)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
cairo_region_t *region,
|
||||
GdkColorState **out_color_state,
|
||||
GdkMemoryDepth *out_depth)
|
||||
gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkBroadwayCairoContext *self = GDK_BROADWAY_CAIRO_CONTEXT (draw_context);
|
||||
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self));
|
||||
@@ -61,9 +59,6 @@ gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
|
||||
cairo_fill (cr);
|
||||
cairo_destroy (cr);
|
||||
|
||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
||||
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -33,11 +33,9 @@ gdk_broadway_draw_context_dispose (GObject *object)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
cairo_region_t *region,
|
||||
GdkColorState **out_color_state,
|
||||
GdkMemoryDepth *out_depth)
|
||||
gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkBroadwayDrawContext *self = GDK_BROADWAY_DRAW_CONTEXT (draw_context);
|
||||
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self));
|
||||
@@ -54,9 +52,6 @@ gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
|
||||
|
||||
self->nodes = g_array_new (FALSE, FALSE, sizeof(guint32));
|
||||
self->node_textures = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
|
||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
||||
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -52,7 +52,8 @@ broadwayjs_h = custom_target('broadwayjs.h',
|
||||
)
|
||||
|
||||
libgdk_broadway = static_library('gdk-broadway',
|
||||
sources: [ clienthtml_h, broadwayjs_h, gdk_broadway_sources, gdk_gen_headers ],
|
||||
clienthtml_h, broadwayjs_h,
|
||||
gdk_broadway_sources, gdkconfig, gdkenum_h,
|
||||
include_directories: [confinc, gdkinc],
|
||||
c_args: [
|
||||
'-DGTK_COMPILATION',
|
||||
|
74
gdk/gdk.c
@@ -43,14 +43,6 @@
|
||||
|
||||
#include <fribidi.h>
|
||||
|
||||
/* GTK has a general architectural assumption that gsize is pointer-sized
|
||||
* (equivalent to uintptr_t), making it non-portable to architectures like
|
||||
* CHERI where that isn't true. If a future release relaxes that
|
||||
* assumption, changes will be needed in numerous places.
|
||||
* See also https://gitlab.gnome.org/GNOME/glib/-/issues/2842 for the
|
||||
* equivalent in GLib, which would be a prerequisite. */
|
||||
G_STATIC_ASSERT (sizeof (gsize) == sizeof (void *));
|
||||
G_STATIC_ASSERT (G_ALIGNOF (gsize) == G_ALIGNOF (void *));
|
||||
|
||||
/**
|
||||
* GDK_WINDOWING_X11:
|
||||
@@ -128,11 +120,8 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
||||
{ "dmabuf", GDK_DEBUG_DMABUF, "Information about dmabuf buffers" },
|
||||
{ "offload", GDK_DEBUG_OFFLOAD, "Information about subsurfaces and graphics offload" },
|
||||
|
||||
{ "linear", GDK_DEBUG_LINEAR, "Enable linear rendering" },
|
||||
{ "hdr", GDK_DEBUG_HDR, "Force HDR rendering" },
|
||||
{ "portals", GDK_DEBUG_PORTALS, "Force use of portals" },
|
||||
{ "no-portals", GDK_DEBUG_NO_PORTALS, "Disable use of portals" },
|
||||
{ "force-offload", GDK_DEBUG_FORCE_OFFLOAD, "Force graphics offload for all textures" },
|
||||
{ "gl-disable", GDK_DEBUG_GL_DISABLE, "Disable OpenGL support" },
|
||||
{ "gl-no-fractional", GDK_DEBUG_GL_NO_FRACTIONAL, "Disable fractional scaling for OpenGL" },
|
||||
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL" },
|
||||
@@ -143,6 +132,7 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
||||
{ "gl-glx", GDK_DEBUG_GL_GLX, "Use GLX on X11" },
|
||||
{ "gl-wgl", GDK_DEBUG_GL_WGL, "Use WGL on Windows" },
|
||||
{ "vulkan-disable", GDK_DEBUG_VULKAN_DISABLE, "Disable Vulkan support" },
|
||||
{ "vulkan-validate", GDK_DEBUG_VULKAN_VALIDATE, "Load the Vulkan validation layer" },
|
||||
{ "default-settings",GDK_DEBUG_DEFAULT_SETTINGS, "Force default values for xsettings" },
|
||||
{ "high-depth", GDK_DEBUG_HIGH_DEPTH, "Use high bit depth rendering if possible" },
|
||||
{ "no-vsync", GDK_DEBUG_NO_VSYNC, "Repaint instantly (uses 100% CPU with animations)" },
|
||||
@@ -152,50 +142,31 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
||||
|
||||
#ifdef G_HAS_CONSTRUCTORS
|
||||
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
|
||||
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(stash_and_unset_environment)
|
||||
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(stash_desktop_startup_notification_id)
|
||||
#endif
|
||||
G_DEFINE_CONSTRUCTOR(stash_and_unset_environment)
|
||||
G_DEFINE_CONSTRUCTOR(stash_desktop_startup_notification_id)
|
||||
#endif
|
||||
|
||||
static char *startup_notification_id = NULL;
|
||||
static char *xdg_activation_token = NULL;
|
||||
|
||||
static void
|
||||
stash_and_unset_environment (void)
|
||||
stash_desktop_startup_notification_id (void)
|
||||
{
|
||||
/* 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.
|
||||
*/
|
||||
struct {
|
||||
const char *key;
|
||||
char **dst;
|
||||
} vars[] = {
|
||||
{ "DESKTOP_STARTUP_ID", &startup_notification_id },
|
||||
{ "XDG_ACTIVATION_TOKEN", &xdg_activation_token },
|
||||
};
|
||||
size_t i;
|
||||
const char *desktop_startup_id;
|
||||
|
||||
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++)
|
||||
desktop_startup_id = g_getenv ("DESKTOP_STARTUP_ID");
|
||||
if (desktop_startup_id && *desktop_startup_id != '\0')
|
||||
{
|
||||
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);
|
||||
}
|
||||
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
|
||||
* child processes and confuse things.
|
||||
*/
|
||||
g_unsetenv ("DESKTOP_STARTUP_ID");
|
||||
}
|
||||
|
||||
static gpointer
|
||||
@@ -320,7 +291,7 @@ gdk_pre_parse (void)
|
||||
gdk_gl_backend_use (GDK_GL_WGL);
|
||||
|
||||
#ifndef G_HAS_CONSTRUCTORS
|
||||
stash_and_unset_environment ();
|
||||
stash_desktop_startup_notification_id ();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -354,20 +325,15 @@ gdk_display_open_default (void)
|
||||
/*< private >
|
||||
* gdk_get_startup_notification_id:
|
||||
*
|
||||
* 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 the original value of the DESKTOP_STARTUP_ID environment
|
||||
* variable if it was defined and valid, or %NULL otherwise.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the original value of the
|
||||
* XDG_ACTIVATION_TOKEN or DESKTOP_STARTUP_ID environment variable
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
@@ -29,9 +29,7 @@
|
||||
#include <gdk/gdkapplaunchcontext.h>
|
||||
#include <gdk/gdkcairo.h>
|
||||
#include <gdk/gdkcairocontext.h>
|
||||
#include <gdk/gdkcicpparams.h>
|
||||
#include <gdk/gdkclipboard.h>
|
||||
#include <gdk/gdkcolorstate.h>
|
||||
#include <gdk/gdkconfig.h>
|
||||
#include <gdk/gdkcontentdeserializer.h>
|
||||
#include <gdk/gdkcontentformats.h>
|
||||
@@ -63,7 +61,6 @@
|
||||
#include <gdk/gdkkeys.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gdk/gdkmemorytexture.h>
|
||||
#include <gdk/gdkmemorytexturebuilder.h>
|
||||
#include <gdk/gdkmonitor.h>
|
||||
#include <gdk/gdkpaintable.h>
|
||||
#include <gdk/gdkpango.h>
|
||||
|
@@ -41,10 +41,8 @@ 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 */
|
||||
@@ -179,23 +177,18 @@ G_GNUC_UNUSED static inline void
|
||||
gdk_array(reserve) (GdkArray *self,
|
||||
gsize n)
|
||||
{
|
||||
gsize new_capacity, size, capacity;
|
||||
gsize new_size, size;
|
||||
|
||||
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;
|
||||
if (n <= gdk_array(get_capacity) (self))
|
||||
return;
|
||||
|
||||
size = gdk_array(get_size) (self);
|
||||
/* capacity * 2 can overflow, that's why we MAX() */
|
||||
new_capacity = MAX (GDK_ARRAY_REAL_SIZE (n), capacity * 2);
|
||||
new_size = ((gsize) 1) << g_bit_storage (MAX (GDK_ARRAY_REAL_SIZE (n), 16) - 1);
|
||||
|
||||
#ifdef GDK_ARRAY_PREALLOC
|
||||
if (self->start == self->preallocated)
|
||||
{
|
||||
self->start = g_new (_T_, new_capacity);
|
||||
self->start = g_new (_T_, new_size);
|
||||
memcpy (self->start, self->preallocated, sizeof (_T_) * GDK_ARRAY_REAL_SIZE (size));
|
||||
}
|
||||
else
|
||||
@@ -203,15 +196,15 @@ gdk_array(reserve) (GdkArray *self,
|
||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||
if (self->start == NULL)
|
||||
{
|
||||
self->start = g_new (_T_, new_capacity);
|
||||
self->start = g_new (_T_, new_size);
|
||||
*self->start = *(_T_[1]) { 0 };
|
||||
}
|
||||
else
|
||||
#endif
|
||||
self->start = g_renew (_T_, self->start, new_capacity);
|
||||
self->start = g_renew (_T_, self->start, new_size);
|
||||
|
||||
self->end = self->start + size;
|
||||
self->end_allocation = self->start + new_capacity;
|
||||
self->end_allocation = self->start + new_size;
|
||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||
self->end_allocation--;
|
||||
#endif
|
||||
@@ -319,7 +312,6 @@ 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
|
||||
|
@@ -1,148 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "gdkcolorstateprivate.h"
|
||||
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
#include "gdkmemorytexture.h"
|
||||
|
||||
#include <cairo.h>
|
||||
#include <graphene.h>
|
||||
|
||||
static inline cairo_format_t
|
||||
gdk_cairo_format_for_depth (GdkMemoryDepth depth)
|
||||
{
|
||||
switch (depth)
|
||||
{
|
||||
case GDK_MEMORY_NONE:
|
||||
case GDK_MEMORY_U8:
|
||||
return CAIRO_FORMAT_ARGB32;
|
||||
|
||||
case GDK_MEMORY_U8_SRGB:
|
||||
case GDK_MEMORY_U16:
|
||||
case GDK_MEMORY_FLOAT16:
|
||||
case GDK_MEMORY_FLOAT32:
|
||||
return CAIRO_FORMAT_RGBA128F;
|
||||
|
||||
case GDK_N_DEPTHS:
|
||||
default:
|
||||
g_return_val_if_reached (CAIRO_FORMAT_ARGB32);
|
||||
}
|
||||
}
|
||||
|
||||
static inline GdkMemoryDepth
|
||||
gdk_cairo_depth_for_format (cairo_format_t format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
case CAIRO_FORMAT_RGB24:
|
||||
case CAIRO_FORMAT_RGB16_565:
|
||||
case CAIRO_FORMAT_A1:
|
||||
case CAIRO_FORMAT_A8:
|
||||
return GDK_MEMORY_U8;
|
||||
|
||||
case CAIRO_FORMAT_RGB30:
|
||||
return GDK_MEMORY_U16;
|
||||
|
||||
case CAIRO_FORMAT_RGB96F:
|
||||
case CAIRO_FORMAT_RGBA128F:
|
||||
return GDK_MEMORY_FLOAT32;
|
||||
|
||||
case CAIRO_FORMAT_INVALID:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return GDK_MEMORY_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static GdkMemoryFormat
|
||||
gdk_cairo_format_to_memory_format (cairo_format_t format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
return GDK_MEMORY_DEFAULT;
|
||||
|
||||
case CAIRO_FORMAT_RGB24:
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
return GDK_MEMORY_B8G8R8X8;
|
||||
#elif G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
return GDK_MEMORY_X8R8G8B8;
|
||||
#else
|
||||
#error "Unknown byte order for Cairo format"
|
||||
#endif
|
||||
case CAIRO_FORMAT_A8:
|
||||
return GDK_MEMORY_A8;
|
||||
case CAIRO_FORMAT_RGB96F:
|
||||
return GDK_MEMORY_R32G32B32_FLOAT;
|
||||
case CAIRO_FORMAT_RGBA128F:
|
||||
return GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
|
||||
|
||||
case CAIRO_FORMAT_RGB16_565:
|
||||
case CAIRO_FORMAT_RGB30:
|
||||
case CAIRO_FORMAT_INVALID:
|
||||
case CAIRO_FORMAT_A1:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return GDK_MEMORY_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
gdk_cairo_set_source_rgba_ccs (cairo_t *cr,
|
||||
GdkColorState *ccs,
|
||||
const GdkRGBA *rgba)
|
||||
{
|
||||
float color[4];
|
||||
|
||||
gdk_color_state_from_rgba (ccs, rgba, color);
|
||||
cairo_set_source_rgba (cr, color[0], color[1], color[2], color[3]);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gdk_cairo_pattern_add_color_stop_rgba_ccs (cairo_pattern_t *pattern,
|
||||
GdkColorState *ccs,
|
||||
double offset,
|
||||
const GdkRGBA *rgba)
|
||||
{
|
||||
float color[4];
|
||||
|
||||
gdk_color_state_from_rgba (ccs, rgba, color);
|
||||
cairo_pattern_add_color_stop_rgba (pattern, offset, color[0], color[1], color[2], color[3]);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gdk_cairo_rect (cairo_t *cr,
|
||||
const graphene_rect_t *rect)
|
||||
{
|
||||
cairo_rectangle (cr,
|
||||
rect->origin.x, rect->origin.y,
|
||||
rect->size.width, rect->size.height);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gdk_cairo_surface_convert_color_state (cairo_surface_t *surface,
|
||||
GdkColorState *source,
|
||||
GdkColorState *target)
|
||||
{
|
||||
cairo_surface_t *image_surface;
|
||||
|
||||
if (gdk_color_state_equal (source, target))
|
||||
return;
|
||||
|
||||
image_surface = cairo_surface_map_to_image (surface, NULL);
|
||||
|
||||
gdk_memory_convert_color_state (cairo_image_surface_get_data (image_surface),
|
||||
cairo_image_surface_get_stride (image_surface),
|
||||
gdk_cairo_format_to_memory_format (cairo_image_surface_get_format (image_surface)),
|
||||
source,
|
||||
target,
|
||||
cairo_image_surface_get_width (image_surface),
|
||||
cairo_image_surface_get_height (image_surface));
|
||||
|
||||
cairo_surface_mark_dirty (image_surface);
|
||||
cairo_surface_unmap_image (surface, image_surface);
|
||||
/* https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/487 */
|
||||
cairo_surface_mark_dirty (surface);
|
||||
}
|
||||
|
@@ -1,482 +0,0 @@
|
||||
/* gdkcicpparams.c
|
||||
*
|
||||
* Copyright 2024 Matthias Clasen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkcicpparamsprivate.h"
|
||||
#include "gdkcolorstateprivate.h"
|
||||
#include "gdkenumtypes.h"
|
||||
|
||||
/**
|
||||
* GdkCicpParams:
|
||||
*
|
||||
* The `GdkCicpParams` struct contains the parameters that define
|
||||
* a colorstate according to the ITU-T H.273
|
||||
* [specification](https://www.itu.int/rec/T-REC-H.273/en).
|
||||
*
|
||||
* See the documentation of individual properties for supported values.
|
||||
*
|
||||
* The 'unspecified' value (2) is not treated in any special way, and
|
||||
* must be replaced by a different value before creating a color state.
|
||||
*
|
||||
* `GdkCicpParams` can be used as a builder object to construct a color
|
||||
* state from Cicp data with [method@Gdk.CicpParams.build_color_state].
|
||||
* The function will return an error if the given parameters are not
|
||||
* supported.
|
||||
*
|
||||
* You can obtain a `GdkCicpParams` object from a color state with
|
||||
* [method@Gdk.ColorState.create_cicp_params]. This can be used to
|
||||
* create a variant of a color state, by changing just one of the cicp
|
||||
* parameters, or just to obtain information about the color state.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
|
||||
/* {{{ GObject boilerplate */
|
||||
|
||||
struct _GdkCicpParams
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GdkCicp cicp;
|
||||
};
|
||||
|
||||
struct _GdkCicpParamsClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GdkCicpParams, gdk_cicp_params, G_TYPE_OBJECT)
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_COLOR_PRIMARIES = 1,
|
||||
PROP_TRANSFER_FUNCTION,
|
||||
PROP_MATRIX_COEFFICIENTS,
|
||||
PROP_RANGE,
|
||||
|
||||
N_PROPERTIES,
|
||||
};
|
||||
|
||||
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
|
||||
|
||||
static void
|
||||
gdk_cicp_params_init (GdkCicpParams *self)
|
||||
{
|
||||
self->cicp.color_primaries = 2;
|
||||
self->cicp.transfer_function = 2;
|
||||
self->cicp.matrix_coefficients = 2;
|
||||
self->cicp.range = GDK_CICP_RANGE_NARROW;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_cicp_params_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkCicpParams *self = GDK_CICP_PARAMS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_COLOR_PRIMARIES:
|
||||
g_value_set_uint (value, self->cicp.color_primaries);
|
||||
break;
|
||||
|
||||
case PROP_TRANSFER_FUNCTION:
|
||||
g_value_set_uint (value, self->cicp.transfer_function);
|
||||
break;
|
||||
|
||||
case PROP_MATRIX_COEFFICIENTS:
|
||||
g_value_set_uint (value, self->cicp.matrix_coefficients);
|
||||
break;
|
||||
|
||||
case PROP_RANGE:
|
||||
g_value_set_enum (value, self->cicp.range);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_cicp_params_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkCicpParams *self = GDK_CICP_PARAMS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_COLOR_PRIMARIES:
|
||||
gdk_cicp_params_set_color_primaries (self, g_value_get_uint (value));
|
||||
break;
|
||||
|
||||
case PROP_TRANSFER_FUNCTION:
|
||||
gdk_cicp_params_set_transfer_function (self, g_value_get_uint (value));
|
||||
break;
|
||||
|
||||
case PROP_MATRIX_COEFFICIENTS:
|
||||
gdk_cicp_params_set_matrix_coefficients (self, g_value_get_uint (value));
|
||||
break;
|
||||
|
||||
case PROP_RANGE:
|
||||
gdk_cicp_params_set_range (self, g_value_get_enum (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_cicp_params_class_init (GdkCicpParamsClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->get_property = gdk_cicp_params_get_property;
|
||||
object_class->set_property = gdk_cicp_params_set_property;
|
||||
|
||||
/**
|
||||
* GdkCicpParams:color-primaries:
|
||||
*
|
||||
* The color primaries to use.
|
||||
*
|
||||
* Supported values:
|
||||
*
|
||||
* - 1: BT.709 / sRGB
|
||||
* - 2: unspecified
|
||||
* - 5: PAL
|
||||
* - 6,7: BT.601 / NTSC
|
||||
* - 9: BT.2020
|
||||
* - 10: CIE XYZ
|
||||
* - 12: Display P3
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
properties[PROP_COLOR_PRIMARIES] =
|
||||
g_param_spec_uint ("color-primaries", NULL, NULL,
|
||||
0, 255, 2,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkCicpParams:transfer-function:
|
||||
*
|
||||
* The transfer function to use.
|
||||
*
|
||||
* Supported values:
|
||||
*
|
||||
* - 1,6,14,15: BT.709, BT.601, BT.2020
|
||||
* - 2: unspecified
|
||||
* - 4: gamma 2.2
|
||||
* - 5: gamma 2.8
|
||||
* - 8: linear
|
||||
* - 13: sRGB
|
||||
* - 16: BT.2100 PQ
|
||||
* - 18: BT.2100 HLG
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
properties[PROP_TRANSFER_FUNCTION] =
|
||||
g_param_spec_uint ("transfer-function", NULL, NULL,
|
||||
0, 255, 2,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkCicpParams:matrix-coefficients:
|
||||
*
|
||||
* The matrix coefficients (for YUV to RGB conversion).
|
||||
*
|
||||
* Supported values:
|
||||
*
|
||||
* - 0: RGB
|
||||
* - 2: unspecified
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
properties[PROP_MATRIX_COEFFICIENTS] =
|
||||
g_param_spec_uint ("matrix-coefficients", NULL, NULL,
|
||||
0, 255, 2,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkCicpParams:range:
|
||||
*
|
||||
* Whether the data is using the full range of values.
|
||||
*
|
||||
* The range of the data.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
properties[PROP_RANGE] =
|
||||
g_param_spec_enum ("range", NULL, NULL,
|
||||
GDK_TYPE_CICP_RANGE,
|
||||
GDK_CICP_RANGE_NARROW,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Public API */
|
||||
|
||||
/**
|
||||
* gdk_cicp_params_new:
|
||||
*
|
||||
* Creates a new `GdkCicpParams` object.
|
||||
*
|
||||
* The initial values of the properties are the values for "undefined"
|
||||
* and need to be set before a color state object can be built.
|
||||
*
|
||||
* Returns: (transfer full): a new `GdkCicpParams`
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkCicpParams *
|
||||
gdk_cicp_params_new (void)
|
||||
{
|
||||
return g_object_new (GDK_TYPE_CICP_PARAMS, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cicp_params_get_color_primaries:
|
||||
* @self: a `GdkCicpParams`
|
||||
*
|
||||
* Returns the value of the color-primaries property
|
||||
* of @self.
|
||||
*
|
||||
* Returns: the color-primaries value
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
guint
|
||||
gdk_cicp_params_get_color_primaries (GdkCicpParams *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_CICP_PARAMS (self), 0);
|
||||
|
||||
return self->cicp.color_primaries;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cicp_params_set_color_primaries:
|
||||
* @self: a `GdkCicpParams`
|
||||
* @color_primaries: the new color primaries value
|
||||
*
|
||||
* Sets the color-primaries property of @self.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
void
|
||||
gdk_cicp_params_set_color_primaries (GdkCicpParams *self,
|
||||
guint color_primaries)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_CICP_PARAMS (self));
|
||||
|
||||
if (self->cicp.color_primaries == color_primaries)
|
||||
return;
|
||||
|
||||
self->cicp.color_primaries = color_primaries;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR_PRIMARIES]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cicp_params_get_transfer_function:
|
||||
* @self: a `GdkCicpParams`
|
||||
*
|
||||
* Gets the transfer-function property of @self.
|
||||
*
|
||||
* Returns: the transfer-function value
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
guint
|
||||
gdk_cicp_params_get_transfer_function (GdkCicpParams *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_CICP_PARAMS (self), 0);
|
||||
|
||||
return self->cicp.transfer_function;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cicp_params_set_transfer_function:
|
||||
* @self: a `GdkCicpParams`
|
||||
* @transfer_function: the new transfer-function value
|
||||
*
|
||||
* Sets the transfer-function property of @self.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
void
|
||||
gdk_cicp_params_set_transfer_function (GdkCicpParams *self,
|
||||
guint transfer_function)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_CICP_PARAMS (self));
|
||||
|
||||
if (self->cicp.transfer_function == transfer_function)
|
||||
return;
|
||||
|
||||
self->cicp.transfer_function = transfer_function;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TRANSFER_FUNCTION]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cicp_params_get_matrix_coefficients:
|
||||
* @self: a `GdkCicpParams`
|
||||
*
|
||||
* Gets the matrix-coefficients property of @self.
|
||||
*
|
||||
* Returns: the matrix-coefficients value
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
guint
|
||||
gdk_cicp_params_get_matrix_coefficients (GdkCicpParams *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_CICP_PARAMS (self), 0);
|
||||
|
||||
return self->cicp.matrix_coefficients;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cicp_params_set_matrix_coefficients:
|
||||
* @self a `GdkCicpParams`
|
||||
* @matrix_coefficients: the new matrix-coefficients value
|
||||
*
|
||||
* Sets the matrix-coefficients property of @self.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
void
|
||||
gdk_cicp_params_set_matrix_coefficients (GdkCicpParams *self,
|
||||
guint matrix_coefficients)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_CICP_PARAMS (self));
|
||||
|
||||
if (self->cicp.matrix_coefficients == matrix_coefficients)
|
||||
return;
|
||||
|
||||
self->cicp.matrix_coefficients = matrix_coefficients;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MATRIX_COEFFICIENTS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cicp_params_get_range:
|
||||
* @self: a `GdkCicpParams`
|
||||
*
|
||||
* Gets the range property of @self.
|
||||
*
|
||||
* Returns: the range value
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkCicpRange
|
||||
gdk_cicp_params_get_range (GdkCicpParams *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_CICP_PARAMS (self), GDK_CICP_RANGE_NARROW);
|
||||
|
||||
return self->cicp.range;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cicp_params_set_range:
|
||||
* @self: a `GdkCipParams`
|
||||
* @range: the range value
|
||||
*
|
||||
* Sets the range property of @self
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
void
|
||||
gdk_cicp_params_set_range (GdkCicpParams *self,
|
||||
GdkCicpRange range)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_CICP_PARAMS (self));
|
||||
|
||||
if (self->cicp.range == range)
|
||||
return;
|
||||
|
||||
self->cicp.range = range;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_RANGE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cicp_params_build_color_state:
|
||||
* @self: a `GdkCicpParams`
|
||||
* @error: return location for errors
|
||||
*
|
||||
* Creates a new `GdkColorState` object for the cicp parameters in @self.
|
||||
*
|
||||
* Note that this may fail if the cicp parameters in @self are not
|
||||
* supported by GTK. In that case, `NULL` is returned, and @error is set
|
||||
* with an error message that can be presented to the user.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): A newly allocated `GdkColorState`
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
gdk_cicp_params_build_color_state (GdkCicpParams *self,
|
||||
GError **error)
|
||||
{
|
||||
return gdk_color_state_new_for_cicp (gdk_cicp_params_get_cicp (self), error);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Private API */
|
||||
|
||||
/*< private >
|
||||
* gdk_cicp_params_new_for_cicp:
|
||||
* @cicp: a GdkCicp struct
|
||||
*
|
||||
* Create a `GdkCicpParams` from the values in @cicp.
|
||||
*
|
||||
* Returns: (transfer full): a new `GdkCicpParams` object
|
||||
*/
|
||||
GdkCicpParams *
|
||||
gdk_cicp_params_new_for_cicp (const GdkCicp *cicp)
|
||||
{
|
||||
return g_object_new (GDK_TYPE_CICP_PARAMS,
|
||||
"color-primaries", cicp->color_primaries,
|
||||
"transfer-function", cicp->transfer_function,
|
||||
"matrix-coefficients", cicp->matrix_coefficients,
|
||||
"range", cicp->range,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_cicp_params_get_cicp:
|
||||
* @self: a `GdkCicpParams` object
|
||||
*
|
||||
* Gets the `GdkCicp` struct of @self.
|
||||
*
|
||||
* Returns: (transfer none): a `GdkCicp` struct containing
|
||||
* the values of @self
|
||||
*/
|
||||
const GdkCicp *
|
||||
gdk_cicp_params_get_cicp (GdkCicpParams *self)
|
||||
{
|
||||
return &self->cicp;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* vim:set foldmethod=marker expandtab: */
|
@@ -1,90 +0,0 @@
|
||||
/* gdkcicpparams.h
|
||||
*
|
||||
* Copyright 2024 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GDK_TYPE_CICP_PARAMS (gdk_cicp_params_get_type ())
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GDK_DECLARE_INTERNAL_TYPE (GdkCicpParams, gdk_cicp_params, GDK, CICP_PARAMS, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkCicpParams *gdk_cicp_params_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
guint gdk_cicp_params_get_color_primaries (GdkCicpParams *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
void gdk_cicp_params_set_color_primaries (GdkCicpParams *self,
|
||||
guint color_primaries);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
guint gdk_cicp_params_get_transfer_function (GdkCicpParams *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
void gdk_cicp_params_set_transfer_function (GdkCicpParams *self,
|
||||
guint transfer_function);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
guint gdk_cicp_params_get_matrix_coefficients (GdkCicpParams *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
void gdk_cicp_params_set_matrix_coefficients (GdkCicpParams *self,
|
||||
guint matrix_coefficients);
|
||||
|
||||
/**
|
||||
* GdkCicpRange:
|
||||
* @GDK_CICP_RANGE_NARROW: The values use the range of 16-235 (for Y) and 16-240 for u and v.
|
||||
* @GDK_CICO_RANGE_FULL: The values use the full range.
|
||||
*
|
||||
* The values of this enumeration describe whether image data uses
|
||||
* the full range of 8-bit values.
|
||||
*
|
||||
* In digital broadcasting, it is common to reserve the lowest and
|
||||
* highest values. Typically the allowed values for the narrow range
|
||||
* are 16-235 for Y and 16-240 for u,v (when dealing with YUV data).
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_CICP_RANGE_NARROW,
|
||||
GDK_CICP_RANGE_FULL,
|
||||
} GdkCicpRange;
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkCicpRange gdk_cicp_params_get_range (GdkCicpParams *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
void gdk_cicp_params_set_range (GdkCicpParams *self,
|
||||
GdkCicpRange range);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkColorState * gdk_cicp_params_build_color_state (GdkCicpParams *self,
|
||||
GError **error);
|
||||
|
||||
|
||||
G_END_DECLS
|
@@ -1,84 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "gdkcicpparams.h"
|
||||
|
||||
typedef struct _GdkCicp GdkCicp;
|
||||
|
||||
struct _GdkCicp
|
||||
{
|
||||
guint color_primaries;
|
||||
guint transfer_function;
|
||||
guint matrix_coefficients;
|
||||
GdkCicpRange range;
|
||||
};
|
||||
|
||||
/*< private >
|
||||
* gdk_cicp_equal:
|
||||
* @p1: a `GdkCicp`
|
||||
* @p2: another `GdkCicp`
|
||||
*
|
||||
* Compare two cicp tuples for equality.
|
||||
*
|
||||
* Note that several cicp values are 'functionally equivalent'.
|
||||
* If you are interested in that notion, use gdk_cicp_equivalent().
|
||||
*
|
||||
* Returns: whether @p1 and @p2 are equal
|
||||
*/
|
||||
static inline gboolean
|
||||
gdk_cicp_equal (const GdkCicp *p1,
|
||||
const GdkCicp *p2)
|
||||
{
|
||||
return p1->color_primaries == p2->color_primaries &&
|
||||
p1->transfer_function == p2->transfer_function &&
|
||||
p1->matrix_coefficients == p2->matrix_coefficients &&
|
||||
p1->range == p2->range;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gdk_cicp_normalize (const GdkCicp *orig,
|
||||
GdkCicp *out)
|
||||
{
|
||||
memcpy (out, orig, sizeof (GdkCicp));
|
||||
|
||||
/* ntsc */
|
||||
if (out->color_primaries == 6)
|
||||
out->color_primaries = 5;
|
||||
|
||||
/* bt709 */
|
||||
if (out->transfer_function == 6 ||
|
||||
out->transfer_function == 14 ||
|
||||
out->transfer_function == 15)
|
||||
out->transfer_function = 1;
|
||||
|
||||
/* bt601 */
|
||||
if (out->matrix_coefficients == 6)
|
||||
out->matrix_coefficients = 5;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_cicp_equivalent:
|
||||
* @p1: a `GdkCicp`
|
||||
* @p2: another `GdkCicp`
|
||||
*
|
||||
* Determine whether two cicp tuples are functionally equivalent.
|
||||
*
|
||||
* Returns: whether @p1 and @p2 are functionally equivalent
|
||||
*/
|
||||
static inline gboolean
|
||||
gdk_cicp_equivalent (const GdkCicp *p1,
|
||||
const GdkCicp *p2)
|
||||
{
|
||||
GdkCicp n1, n2;
|
||||
|
||||
if (gdk_cicp_equal (p1, p2))
|
||||
return TRUE;
|
||||
|
||||
gdk_cicp_normalize (p1, &n1);
|
||||
gdk_cicp_normalize (p2, &n2);
|
||||
|
||||
return gdk_cicp_equal (&n1, &n2);
|
||||
}
|
||||
|
||||
const GdkCicp * gdk_cicp_params_get_cicp (GdkCicpParams *params);
|
||||
|
||||
GdkCicpParams * gdk_cicp_params_new_for_cicp (const GdkCicp *cicp);
|
@@ -515,13 +515,15 @@ gdk_clipboard_get_content (GdkClipboard *clipboard)
|
||||
* @clipboard: a `GdkClipboard`
|
||||
* @io_priority: the I/O priority of the request
|
||||
* @cancellable: (nullable): optional `GCancellable` object
|
||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
||||
* @user_data:: the data to pass to callback function
|
||||
* @callback: (scope async): callback to call when the request is satisfied
|
||||
* @user_data: (closure): the data to pass to callback function
|
||||
*
|
||||
* Asynchronously instructs the @clipboard to store its contents remotely.
|
||||
*
|
||||
* If the clipboard is not local, this function does nothing but report success.
|
||||
*
|
||||
* The @callback must call [method@Gdk.Clipboard.store_finish].
|
||||
*
|
||||
* The purpose of this call is to preserve clipboard contents beyond the
|
||||
* lifetime of an application, so this function is typically called on
|
||||
* exit. Depending on the platform, the functionality may not be available
|
||||
@@ -630,12 +632,15 @@ gdk_clipboard_read_internal (GdkClipboard *clipboard,
|
||||
* @mime_types: (array zero-terminated=1): a %NULL-terminated array of mime types to choose from
|
||||
* @io_priority: the I/O priority of the request
|
||||
* @cancellable: (nullable): optional `GCancellable` object
|
||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
||||
* @user_data: the data to pass to callback function
|
||||
* @callback: (scope async): callback to call when the request is satisfied
|
||||
* @user_data: (closure): the data to pass to callback function
|
||||
*
|
||||
* Asynchronously requests an input stream to read the @clipboard's
|
||||
* contents from.
|
||||
*
|
||||
* When the operation is finished @callback will be called. You must then
|
||||
* call [method@Gdk.Clipboard.read_finish] to get the result of the operation.
|
||||
*
|
||||
* The clipboard will choose the most suitable mime type from the given list
|
||||
* to fulfill the request, preferring the ones listed first.
|
||||
*/
|
||||
@@ -823,12 +828,15 @@ gdk_clipboard_read_value_internal (GdkClipboard *clipboard,
|
||||
* @type: a `GType` to read
|
||||
* @io_priority: the I/O priority of the request
|
||||
* @cancellable: (nullable): optional `GCancellable` object
|
||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
||||
* @user_data: the data to pass to callback function
|
||||
* @callback: (scope async): callback to call when the request is satisfied
|
||||
* @user_data: (closure): the data to pass to callback function
|
||||
*
|
||||
* Asynchronously request the @clipboard contents converted to the given
|
||||
* @type.
|
||||
*
|
||||
* When the operation is finished @callback will be called. You must then call
|
||||
* [method@Gdk.Clipboard.read_value_finish] to get the resulting `GValue`.
|
||||
*
|
||||
* For local clipboard contents that are available in the given `GType`,
|
||||
* the value will be copied directly. Otherwise, GDK will try to use
|
||||
* [func@content_deserialize_async] to convert the clipboard's data.
|
||||
@@ -882,11 +890,14 @@ gdk_clipboard_read_value_finish (GdkClipboard *clipboard,
|
||||
* gdk_clipboard_read_texture_async:
|
||||
* @clipboard: a `GdkClipboard`
|
||||
* @cancellable: (nullable): optional `GCancellable` object, %NULL to ignore.
|
||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
||||
* @user_data: the data to pass to callback function
|
||||
* @callback: (scope async): callback to call when the request is satisfied
|
||||
* @user_data: (closure): the data to pass to callback function
|
||||
*
|
||||
* Asynchronously request the @clipboard contents converted to a `GdkPixbuf`.
|
||||
*
|
||||
* When the operation is finished @callback will be called. You must then
|
||||
* call [method@Gdk.Clipboard.read_texture_finish] to get the result.
|
||||
*
|
||||
* This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
|
||||
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
|
||||
* need more control over the operation.
|
||||
@@ -944,11 +955,14 @@ gdk_clipboard_read_texture_finish (GdkClipboard *clipboard,
|
||||
* gdk_clipboard_read_text_async:
|
||||
* @clipboard: a `GdkClipboard`
|
||||
* @cancellable: (nullable): optional `GCancellable` object
|
||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
||||
* @user_data: the data to pass to callback function
|
||||
* @callback: (scope async): callback to call when the request is satisfied
|
||||
* @user_data: (closure): the data to pass to callback function
|
||||
*
|
||||
* Asynchronously request the @clipboard contents converted to a string.
|
||||
*
|
||||
* When the operation is finished @callback will be called. You must then
|
||||
* call [method@Gdk.Clipboard.read_text_finish] to get the result.
|
||||
*
|
||||
* This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
|
||||
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
|
||||
* need more control over the operation.
|
||||
|
@@ -1,224 +0,0 @@
|
||||
/* gdkcolordefs.h
|
||||
*
|
||||
* Copyright 2024 Matthias Clasen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Note that this header is shared between the color state implementation
|
||||
* and tests, and must not include other headers.
|
||||
*/
|
||||
|
||||
static inline float
|
||||
srgb_oetf (float v)
|
||||
{
|
||||
if (v > 0.0031308f)
|
||||
return 1.055f * powf (v, 1.f / 2.4f) - 0.055f;
|
||||
else
|
||||
return 12.92f * v;
|
||||
}
|
||||
|
||||
static inline float
|
||||
srgb_eotf (float v)
|
||||
{
|
||||
if (v >= 0.04045f)
|
||||
return powf (((v + 0.055f) / (1.f + 0.055f)), 2.4f);
|
||||
else
|
||||
return v / 12.92f;
|
||||
}
|
||||
|
||||
static inline float
|
||||
gamma22_oetf (float v)
|
||||
{
|
||||
return powf (v, 1.f / 2.2f);
|
||||
}
|
||||
|
||||
static inline float
|
||||
gamma22_eotf (float v)
|
||||
{
|
||||
return powf (v, 2.2f);
|
||||
}
|
||||
|
||||
static inline float
|
||||
gamma28_oetf (float v)
|
||||
{
|
||||
return powf (v, 1.f / 2.8f);
|
||||
}
|
||||
|
||||
static inline float
|
||||
gamma28_eotf (float v)
|
||||
{
|
||||
return powf (v, 2.8f);
|
||||
}
|
||||
|
||||
static inline float
|
||||
pq_eotf (float v)
|
||||
{
|
||||
float ninv = (1 << 14) / 2610.0;
|
||||
float minv = (1 << 5) / 2523.0;
|
||||
float c1 = 3424.0 / (1 << 12);
|
||||
float c2 = 2413.0 / (1 << 7);
|
||||
float c3 = 2392.0 / (1 << 7);
|
||||
|
||||
float x = powf (MAX ((powf (v, minv) - c1), 0) / (c2 - (c3 * (powf (v, minv)))), ninv);
|
||||
|
||||
return x * 10000 / 203.0;
|
||||
}
|
||||
|
||||
static inline float
|
||||
pq_oetf (float v)
|
||||
{
|
||||
float x = v * 203.0 / 10000.0;
|
||||
float n = 2610.0 / (1 << 14);
|
||||
float m = 2523.0 / (1 << 5);
|
||||
float c1 = 3424.0 / (1 << 12);
|
||||
float c2 = 2413.0 / (1 << 7);
|
||||
float c3 = 2392.0 / (1 << 7);
|
||||
|
||||
return powf (((c1 + (c2 * powf (x, n))) / (1 + (c3 * powf (x, n)))), m);
|
||||
}
|
||||
|
||||
static inline float
|
||||
bt709_eotf (float v)
|
||||
{
|
||||
const float a = 1.099;
|
||||
const float d = 0.0812;
|
||||
|
||||
if (v < d)
|
||||
return v / 4.5f;
|
||||
else
|
||||
return powf ((v + (a - 1)) / a, 1 / 0.45f);
|
||||
}
|
||||
|
||||
static inline float
|
||||
bt709_oetf (float v)
|
||||
{
|
||||
const float a = 1.099;
|
||||
const float b = 0.018;
|
||||
|
||||
if (v < b)
|
||||
return v * 4.5f;
|
||||
else
|
||||
return a * powf (v, 0.45f) - (a - 1);
|
||||
}
|
||||
|
||||
static inline float
|
||||
hlg_eotf (float v)
|
||||
{
|
||||
const float a = 0.17883277;
|
||||
const float b = 0.28466892;
|
||||
const float c = 0.55991073;
|
||||
|
||||
if (v <= 0.5)
|
||||
return (v * v) / 3;
|
||||
else
|
||||
return (expf ((v - c) / a) + b) / 12.0;
|
||||
}
|
||||
|
||||
static inline float
|
||||
hlg_oetf (float v)
|
||||
{
|
||||
const float a = 0.17883277;
|
||||
const float b = 0.28466892;
|
||||
const float c = 0.55991073;
|
||||
|
||||
if (v <= 1/12.0)
|
||||
return sqrtf (3 * v);
|
||||
else
|
||||
return a * logf (12 * v - b) + c;
|
||||
}
|
||||
|
||||
/* See http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
||||
* for how to derive the abc_to_xyz matrices from chromaticity coordinates.
|
||||
*/
|
||||
|
||||
static const float identity[9] = {
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1,
|
||||
};
|
||||
|
||||
static const float srgb_to_xyz[9] = {
|
||||
0.4124564, 0.3575761, 0.1804375,
|
||||
0.2126729, 0.7151522, 0.0721750,
|
||||
0.0193339, 0.1191920, 0.9503041,
|
||||
};
|
||||
|
||||
static const float xyz_to_srgb[9] = {
|
||||
3.2404542, -1.5371385, -0.4985314,
|
||||
-0.9692660, 1.8760108, 0.0415560,
|
||||
0.0556434, -0.2040259, 1.0572252,
|
||||
};
|
||||
|
||||
static const float rec2020_to_xyz[9] = {
|
||||
0.6369580, 0.1446169, 0.1688810,
|
||||
0.2627002, 0.6779981, 0.0593017,
|
||||
0.0000000, 0.0280727, 1.0609851,
|
||||
};
|
||||
|
||||
static const float xyz_to_rec2020[9] = {
|
||||
1.7166512, -0.3556708, -0.2533663,
|
||||
-0.6666844, 1.6164812, 0.0157685,
|
||||
0.0176399, -0.0427706, 0.9421031,
|
||||
};
|
||||
|
||||
static const float pal_to_xyz[9] = {
|
||||
0.4305538, 0.3415498, 0.1783523,
|
||||
0.2220043, 0.7066548, 0.0713409,
|
||||
0.0201822, 0.1295534, 0.9393222,
|
||||
};
|
||||
|
||||
static const float xyz_to_pal[9] = {
|
||||
3.0633611, -1.3933902, -0.4758237,
|
||||
-0.9692436, 1.8759675, 0.0415551,
|
||||
0.0678610, -0.2287993, 1.0690896,
|
||||
};
|
||||
|
||||
static const float ntsc_to_xyz[9] = {
|
||||
0.3935209, 0.3652581, 0.1916769,
|
||||
0.2123764, 0.7010599, 0.0865638,
|
||||
0.0187391, 0.1119339, 0.9583847,
|
||||
};
|
||||
|
||||
static const float xyz_to_ntsc[9] = {
|
||||
3.5060033, -1.7397907, -0.5440583,
|
||||
-1.0690476, 1.9777789, 0.0351714,
|
||||
0.0563066, -0.1969757, 1.0499523,
|
||||
};
|
||||
|
||||
static const float p3_to_xyz[9] = {
|
||||
0.4865709, 0.2656677, 0.1982173,
|
||||
0.2289746, 0.6917385, 0.0792869,
|
||||
0.0000000, 0.0451134, 1.0439444,
|
||||
};
|
||||
|
||||
static const float xyz_to_p3[9] = {
|
||||
2.4934969, -0.9313836, -0.4027108,
|
||||
-0.8294890, 1.7626641, 0.0236247,
|
||||
0.0358458, -0.0761724, 0.9568845,
|
||||
};
|
||||
|
||||
/* premultiplied matrices for default conversions */
|
||||
|
||||
static const float rec2020_to_srgb[9] = {
|
||||
1.660227, -0.587548, -0.072838,
|
||||
-0.124553, 1.132926, -0.008350,
|
||||
-0.018155, -0.100603, 1.118998,
|
||||
};
|
||||
|
||||
static const float srgb_to_rec2020[9] = {
|
||||
0.627504, 0.329275, 0.043303,
|
||||
0.069108, 0.919519, 0.011360,
|
||||
0.016394, 0.088011, 0.895380,
|
||||
};
|
@@ -1,778 +0,0 @@
|
||||
/* gdkcolorstate.c
|
||||
*
|
||||
* Copyright 2024 Matthias Clasen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkcolorstateprivate.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "gdkcolordefs.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
/**
|
||||
* GdkColorState:
|
||||
*
|
||||
* A `GdkColorState` object provides the information to interpret
|
||||
* colors and pixels in a variety of ways.
|
||||
*
|
||||
* They are also known as
|
||||
* [*color spaces*](https://en.wikipedia.org/wiki/Color_space).
|
||||
*
|
||||
* Crucially, GTK knows how to convert colors from one color
|
||||
* state to another.
|
||||
*
|
||||
* `GdkColorState objects are immutable and therefore threadsafe.
|
||||
*
|
||||
* Since 4.16
|
||||
*/
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GdkColorState, gdk_color_state,
|
||||
gdk_color_state_ref, gdk_color_state_unref);
|
||||
|
||||
/* {{{ Public API */
|
||||
|
||||
/**
|
||||
* gdk_color_state_ref:
|
||||
* @self: a `GdkColorState`
|
||||
*
|
||||
* Increase the reference count of @self.
|
||||
*
|
||||
* Returns: the object that was passed in
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
(gdk_color_state_ref) (GdkColorState *self)
|
||||
{
|
||||
return _gdk_color_state_ref (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_state_unref:
|
||||
* @self:a `GdkColorState`
|
||||
*
|
||||
* Decrease the reference count of @self.
|
||||
*
|
||||
* Unless @self is static, it will be freed
|
||||
* when the reference count reaches zero.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
void
|
||||
(gdk_color_state_unref) (GdkColorState *self)
|
||||
{
|
||||
_gdk_color_state_unref (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_state_get_srgb:
|
||||
*
|
||||
* Returns the color state object representing the sRGB color space.
|
||||
*
|
||||
* This color state uses the primaries defined by BT.709-6 and the transfer function
|
||||
* defined by IEC 61966-2-1.
|
||||
*
|
||||
* It is equivalent to the [Cicp](class.CicpParams.html) tuple 1/13/0/1.
|
||||
*
|
||||
* See e.g. [the CSS Color Module](https://www.w3.org/TR/css-color-4/#predefined-sRGB)
|
||||
* for details about this colorstate.
|
||||
*
|
||||
* Returns: the color state object for sRGB
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
gdk_color_state_get_srgb (void)
|
||||
{
|
||||
return GDK_COLOR_STATE_SRGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_state_get_srgb_linear:
|
||||
*
|
||||
* Returns the color state object representing the linearized sRGB color space.
|
||||
*
|
||||
* This color state uses the primaries defined by BT.709-6 and a linear transfer function.
|
||||
*
|
||||
* It is equivalent to the [Cicp](class.CicpParams.html) tuple 1/8/0/1.
|
||||
*
|
||||
* See e.g. [the CSS Color Module](https://www.w3.org/TR/css-color-4/#predefined-sRGB-linear)
|
||||
* for details about this colorstate.
|
||||
*
|
||||
* Returns: the color state object for linearized sRGB
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
gdk_color_state_get_srgb_linear (void)
|
||||
{
|
||||
return GDK_COLOR_STATE_SRGB_LINEAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_state_get_rec2100_pq:
|
||||
*
|
||||
* Returns the color state object representing the rec2100-pq color space.
|
||||
*
|
||||
* This color state uses the primaries defined by BT.2020-2 and BT.2100-0 and the transfer
|
||||
* function defined by SMPTE ST 2084 and BT.2100-2.
|
||||
*
|
||||
* It is equivalent to the [Cicp](class.CicpParams.html) tuple 9/16/0/1.
|
||||
*
|
||||
* See e.g. [the CSS HDR Module](https://drafts.csswg.org/css-color-hdr/#valdef-color-rec2100-pq)
|
||||
* for details about this colorstate.
|
||||
*
|
||||
* Returns: the color state object for rec2100-pq
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
gdk_color_state_get_rec2100_pq (void)
|
||||
{
|
||||
return GDK_COLOR_STATE_REC2100_PQ;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_state_get_rec2100_linear:
|
||||
*
|
||||
* Returns the color state object representing the linear rec2100 color space.
|
||||
*
|
||||
* This color state uses the primaries defined by BT.2020-2 and BT.2100-0 and a linear
|
||||
* transfer function.
|
||||
*
|
||||
* It is equivalent to the [Cicp](class.CicpParams.html) tuple 9/8/0/1.
|
||||
*
|
||||
* See e.g. [the CSS HDR Module](https://drafts.csswg.org/css-color-hdr/#valdef-color-rec2100-linear)
|
||||
* for details about this colorstate.
|
||||
*
|
||||
* Returns: the color state object for linearized rec2100
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
gdk_color_state_get_rec2100_linear (void)
|
||||
{
|
||||
return GDK_COLOR_STATE_REC2100_LINEAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_state_equal:
|
||||
* @self: a `GdkColorState`
|
||||
* @other: another `GdkColorStatee`
|
||||
*
|
||||
* Compares two `GdkColorStates` for equality.
|
||||
*
|
||||
* Note that this function is not guaranteed to be perfect and two objects
|
||||
* describing the same color state may compare not equal. However, different
|
||||
* color states will never compare equal.
|
||||
*
|
||||
* Returns: %TRUE if the two color states compare equal
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
gboolean
|
||||
(gdk_color_state_equal) (GdkColorState *self,
|
||||
GdkColorState *other)
|
||||
{
|
||||
return _gdk_color_state_equal (self, other);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_state_create_cicp_params:
|
||||
* @self: a `GdkColorState`
|
||||
*
|
||||
* Create a [class@Gdk.CicpParams] representing the colorstate.
|
||||
*
|
||||
* It is not guaranteed that every `GdkColorState` can be
|
||||
* represented with Cicp parameters. If that is the case,
|
||||
* this function returns `NULL`.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): A new [class@Gdk.CicpParams]
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkCicpParams *
|
||||
gdk_color_state_create_cicp_params (GdkColorState *self)
|
||||
{
|
||||
const GdkCicp *cicp = gdk_color_state_get_cicp (self);
|
||||
|
||||
if (cicp)
|
||||
return gdk_cicp_params_new_for_cicp (cicp);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Conversion functions */
|
||||
|
||||
typedef float (* GdkTransferFunc) (float v);
|
||||
typedef const float GdkColorMatrix[9];
|
||||
|
||||
#define IDENTITY ((float*)0)
|
||||
#define NONE ((GdkTransferFunc)0)
|
||||
|
||||
#define TRANSFORM(name, eotf, matrix, oetf) \
|
||||
static void \
|
||||
name (GdkColorState *self, \
|
||||
float (*values)[4], \
|
||||
gsize n_values) \
|
||||
{ \
|
||||
for (gsize i = 0; i < n_values; i++) \
|
||||
{ \
|
||||
if (eotf != NONE) \
|
||||
{ \
|
||||
values[i][0] = eotf (values[i][0]); \
|
||||
values[i][1] = eotf (values[i][1]); \
|
||||
values[i][2] = eotf (values[i][2]); \
|
||||
} \
|
||||
if (matrix != IDENTITY) \
|
||||
{ \
|
||||
float res[3]; \
|
||||
res[0] = matrix[0] * values[i][0] + matrix[1] * values[i][1] + matrix[2] * values[i][2]; \
|
||||
res[1] = matrix[3] * values[i][0] + matrix[4] * values[i][1] + matrix[5] * values[i][2]; \
|
||||
res[2] = matrix[6] * values[i][0] + matrix[7] * values[i][1] + matrix[8] * values[i][2]; \
|
||||
values[i][0] = res[0]; \
|
||||
values[i][1] = res[1]; \
|
||||
values[i][2] = res[2]; \
|
||||
} \
|
||||
if (oetf != NONE) \
|
||||
{ \
|
||||
values[i][0] = oetf (values[i][0]); \
|
||||
values[i][1] = oetf (values[i][1]); \
|
||||
values[i][2] = oetf (values[i][2]); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
TRANSFORM(gdk_default_srgb_to_srgb_linear, srgb_eotf, IDENTITY, NONE);
|
||||
TRANSFORM(gdk_default_srgb_linear_to_srgb, NONE, IDENTITY, srgb_oetf)
|
||||
TRANSFORM(gdk_default_rec2100_pq_to_rec2100_linear, pq_eotf, IDENTITY, NONE)
|
||||
TRANSFORM(gdk_default_rec2100_linear_to_rec2100_pq, NONE, IDENTITY, pq_oetf)
|
||||
TRANSFORM(gdk_default_srgb_linear_to_rec2100_linear, NONE, srgb_to_rec2020, NONE)
|
||||
TRANSFORM(gdk_default_rec2100_linear_to_srgb_linear, NONE, rec2020_to_srgb, NONE)
|
||||
TRANSFORM(gdk_default_srgb_to_rec2100_linear, srgb_eotf, srgb_to_rec2020, NONE)
|
||||
TRANSFORM(gdk_default_rec2100_pq_to_srgb_linear, pq_eotf, rec2020_to_srgb, NONE)
|
||||
TRANSFORM(gdk_default_srgb_linear_to_rec2100_pq, NONE, srgb_to_rec2020, pq_oetf)
|
||||
TRANSFORM(gdk_default_rec2100_linear_to_srgb, NONE, rec2020_to_srgb, srgb_oetf)
|
||||
TRANSFORM(gdk_default_srgb_to_rec2100_pq, srgb_eotf, srgb_to_rec2020, pq_oetf)
|
||||
TRANSFORM(gdk_default_rec2100_pq_to_srgb, pq_eotf, rec2020_to_srgb, srgb_oetf)
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Default implementation */
|
||||
/* {{{ Vfuncs */
|
||||
|
||||
static gboolean
|
||||
gdk_default_color_state_equal (GdkColorState *self,
|
||||
GdkColorState *other)
|
||||
{
|
||||
return self == other;
|
||||
}
|
||||
|
||||
static const char *
|
||||
gdk_default_color_state_get_name (GdkColorState *color_state)
|
||||
{
|
||||
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
|
||||
|
||||
return self->name;
|
||||
}
|
||||
|
||||
static GdkColorState *
|
||||
gdk_default_color_state_get_no_srgb_tf (GdkColorState *color_state)
|
||||
{
|
||||
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
|
||||
|
||||
return self->no_srgb;
|
||||
}
|
||||
|
||||
static GdkFloatColorConvert
|
||||
gdk_default_color_state_get_convert_to (GdkColorState *color_state,
|
||||
GdkColorState *target)
|
||||
{
|
||||
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
|
||||
|
||||
if (GDK_IS_DEFAULT_COLOR_STATE (target))
|
||||
return self->convert_to[GDK_DEFAULT_COLOR_STATE_ID (target)];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GdkFloatColorConvert
|
||||
gdk_default_color_state_get_convert_from (GdkColorState *color_state,
|
||||
GdkColorState *source)
|
||||
{
|
||||
/* This is ok because the default-to-default conversion functions
|
||||
* don't use the passed colorstate at all.
|
||||
*/
|
||||
return gdk_default_color_state_get_convert_to (source, color_state);
|
||||
}
|
||||
|
||||
static const GdkCicp *
|
||||
gdk_default_color_state_get_cicp (GdkColorState *color_state)
|
||||
{
|
||||
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
|
||||
|
||||
return &self->cicp;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
static const
|
||||
GdkColorStateClass GDK_DEFAULT_COLOR_STATE_CLASS = {
|
||||
.free = NULL, /* crash here if this ever happens */
|
||||
.equal = gdk_default_color_state_equal,
|
||||
.get_name = gdk_default_color_state_get_name,
|
||||
.get_no_srgb_tf = gdk_default_color_state_get_no_srgb_tf,
|
||||
.get_convert_to = gdk_default_color_state_get_convert_to,
|
||||
.get_convert_from = gdk_default_color_state_get_convert_from,
|
||||
.get_cicp = gdk_default_color_state_get_cicp,
|
||||
};
|
||||
|
||||
GdkDefaultColorState gdk_default_color_states[] = {
|
||||
[GDK_COLOR_STATE_ID_SRGB] = {
|
||||
.parent = {
|
||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
||||
.ref_count = 0,
|
||||
.depth = GDK_MEMORY_U8_SRGB,
|
||||
.rendering_color_state = GDK_COLOR_STATE_SRGB_LINEAR,
|
||||
},
|
||||
.name = "srgb",
|
||||
.no_srgb = GDK_COLOR_STATE_SRGB_LINEAR,
|
||||
.convert_to = {
|
||||
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_srgb_to_srgb_linear,
|
||||
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_srgb_to_rec2100_pq,
|
||||
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_srgb_to_rec2100_linear,
|
||||
},
|
||||
.cicp = { 1, 13, 0, 1 },
|
||||
},
|
||||
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = {
|
||||
.parent = {
|
||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
||||
.ref_count = 0,
|
||||
.depth = GDK_MEMORY_U8,
|
||||
.rendering_color_state = GDK_COLOR_STATE_SRGB_LINEAR,
|
||||
},
|
||||
.name = "srgb-linear",
|
||||
.no_srgb = NULL,
|
||||
.convert_to = {
|
||||
[GDK_COLOR_STATE_ID_SRGB] = gdk_default_srgb_linear_to_srgb,
|
||||
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_srgb_linear_to_rec2100_pq,
|
||||
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_srgb_linear_to_rec2100_linear,
|
||||
},
|
||||
.cicp = { 1, 8, 0, 1 },
|
||||
},
|
||||
[GDK_COLOR_STATE_ID_REC2100_PQ] = {
|
||||
.parent = {
|
||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
||||
.ref_count = 0,
|
||||
.depth = GDK_MEMORY_FLOAT16,
|
||||
.rendering_color_state = GDK_COLOR_STATE_REC2100_LINEAR,
|
||||
},
|
||||
.name = "rec2100-pq",
|
||||
.no_srgb = NULL,
|
||||
.convert_to = {
|
||||
[GDK_COLOR_STATE_ID_SRGB] = gdk_default_rec2100_pq_to_srgb,
|
||||
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_rec2100_pq_to_srgb_linear,
|
||||
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_rec2100_pq_to_rec2100_linear,
|
||||
},
|
||||
.cicp = { 9, 16, 0, 1 },
|
||||
},
|
||||
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = {
|
||||
.parent = {
|
||||
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
|
||||
.ref_count = 0,
|
||||
.depth = GDK_MEMORY_FLOAT16,
|
||||
.rendering_color_state = GDK_COLOR_STATE_REC2100_LINEAR,
|
||||
},
|
||||
.name = "rec2100-linear",
|
||||
.no_srgb = NULL,
|
||||
.convert_to = {
|
||||
[GDK_COLOR_STATE_ID_SRGB] = gdk_default_rec2100_linear_to_srgb,
|
||||
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_rec2100_linear_to_srgb_linear,
|
||||
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_rec2100_linear_to_rec2100_pq,
|
||||
},
|
||||
.cicp = { 9, 8, 0, 1 },
|
||||
},
|
||||
};
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Cicp implementation */
|
||||
|
||||
typedef struct _GdkCicpColorState GdkCicpColorState;
|
||||
struct _GdkCicpColorState
|
||||
{
|
||||
GdkColorState parent;
|
||||
|
||||
GdkColorState *no_srgb;
|
||||
|
||||
const char *name;
|
||||
|
||||
GdkTransferFunc eotf;
|
||||
GdkTransferFunc oetf;
|
||||
|
||||
float *to_srgb;
|
||||
float *to_rec2020;
|
||||
float *from_srgb;
|
||||
float *from_rec2020;
|
||||
|
||||
GdkCicp cicp;
|
||||
};
|
||||
|
||||
/* {{{ Conversion functions */
|
||||
|
||||
#define cicp ((GdkCicpColorState *)self)
|
||||
|
||||
TRANSFORM(gdk_cicp_to_srgb, cicp->eotf, cicp->to_srgb, srgb_oetf)
|
||||
TRANSFORM(gdk_cicp_to_srgb_linear, cicp->eotf, cicp->to_srgb, NONE)
|
||||
TRANSFORM(gdk_cicp_to_rec2100_pq, cicp->eotf, cicp->to_rec2020, pq_oetf)
|
||||
TRANSFORM(gdk_cicp_to_rec2100_linear, cicp->eotf, cicp->to_rec2020, NONE)
|
||||
TRANSFORM(gdk_cicp_from_srgb, srgb_eotf, cicp->from_srgb, cicp->oetf)
|
||||
TRANSFORM(gdk_cicp_from_srgb_linear, NONE, cicp->from_srgb, cicp->oetf)
|
||||
TRANSFORM(gdk_cicp_from_rec2100_pq, pq_eotf, cicp->from_rec2020, cicp->oetf)
|
||||
TRANSFORM(gdk_cicp_from_rec2100_linear, NONE, cicp->from_rec2020, cicp->oetf)
|
||||
|
||||
#undef cicp
|
||||
|
||||
/* }}} */
|
||||
/* }}} */
|
||||
/* {{{ Vfuncs */
|
||||
|
||||
static void
|
||||
gdk_cicp_color_state_free (GdkColorState *cs)
|
||||
{
|
||||
GdkCicpColorState *self = (GdkCicpColorState *) cs;
|
||||
|
||||
if (self->no_srgb)
|
||||
gdk_color_state_unref (self->no_srgb);
|
||||
|
||||
g_free (self->to_srgb);
|
||||
g_free (self->to_rec2020);
|
||||
g_free (self->from_srgb);
|
||||
g_free (self->from_rec2020);
|
||||
|
||||
g_free (self);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_cicp_color_state_equal (GdkColorState *self,
|
||||
GdkColorState *other)
|
||||
{
|
||||
GdkCicpColorState *cs1 = (GdkCicpColorState *) self;
|
||||
GdkCicpColorState *cs2 = (GdkCicpColorState *) other;
|
||||
|
||||
return gdk_cicp_equal (&cs1->cicp, &cs2->cicp);
|
||||
}
|
||||
|
||||
static const char *
|
||||
gdk_cicp_color_state_get_name (GdkColorState *self)
|
||||
{
|
||||
GdkCicpColorState *cs = (GdkCicpColorState *) self;
|
||||
|
||||
return cs->name;
|
||||
}
|
||||
|
||||
static GdkColorState *
|
||||
gdk_cicp_color_state_get_no_srgb_tf (GdkColorState *self)
|
||||
{
|
||||
GdkCicpColorState *cs = (GdkCicpColorState *) self;
|
||||
|
||||
return cs->no_srgb;
|
||||
}
|
||||
|
||||
static GdkFloatColorConvert
|
||||
gdk_cicp_color_state_get_convert_to (GdkColorState *self,
|
||||
GdkColorState *target)
|
||||
{
|
||||
if (!GDK_IS_DEFAULT_COLOR_STATE (target))
|
||||
return NULL;
|
||||
|
||||
switch (GDK_DEFAULT_COLOR_STATE_ID (target))
|
||||
{
|
||||
case GDK_COLOR_STATE_ID_SRGB:
|
||||
return gdk_cicp_to_srgb;
|
||||
case GDK_COLOR_STATE_ID_SRGB_LINEAR:
|
||||
return gdk_cicp_to_srgb_linear;
|
||||
case GDK_COLOR_STATE_ID_REC2100_PQ:
|
||||
return gdk_cicp_to_rec2100_pq;
|
||||
case GDK_COLOR_STATE_ID_REC2100_LINEAR:
|
||||
return gdk_cicp_to_rec2100_linear;
|
||||
|
||||
case GDK_COLOR_STATE_N_IDS:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GdkFloatColorConvert
|
||||
gdk_cicp_color_state_get_convert_from (GdkColorState *self,
|
||||
GdkColorState *source)
|
||||
{
|
||||
if (!GDK_IS_DEFAULT_COLOR_STATE (source))
|
||||
return NULL;
|
||||
|
||||
switch (GDK_DEFAULT_COLOR_STATE_ID (source))
|
||||
{
|
||||
case GDK_COLOR_STATE_ID_SRGB:
|
||||
return gdk_cicp_from_srgb;
|
||||
case GDK_COLOR_STATE_ID_SRGB_LINEAR:
|
||||
return gdk_cicp_from_srgb_linear;
|
||||
case GDK_COLOR_STATE_ID_REC2100_PQ:
|
||||
return gdk_cicp_from_rec2100_pq;
|
||||
case GDK_COLOR_STATE_ID_REC2100_LINEAR:
|
||||
return gdk_cicp_from_rec2100_linear;
|
||||
|
||||
case GDK_COLOR_STATE_N_IDS:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const GdkCicp *
|
||||
gdk_cicp_color_state_get_cicp (GdkColorState *color_state)
|
||||
{
|
||||
GdkCicpColorState *self = (GdkCicpColorState *) color_state;
|
||||
|
||||
return &self->cicp;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
static const
|
||||
GdkColorStateClass GDK_CICP_COLOR_STATE_CLASS = {
|
||||
.free = gdk_cicp_color_state_free,
|
||||
.equal = gdk_cicp_color_state_equal,
|
||||
.get_name = gdk_cicp_color_state_get_name,
|
||||
.get_no_srgb_tf = gdk_cicp_color_state_get_no_srgb_tf,
|
||||
.get_convert_to = gdk_cicp_color_state_get_convert_to,
|
||||
.get_convert_from = gdk_cicp_color_state_get_convert_from,
|
||||
.get_cicp = gdk_cicp_color_state_get_cicp,
|
||||
};
|
||||
|
||||
static inline float *
|
||||
multiply (float res[9],
|
||||
const float m1[9],
|
||||
const float m2[9])
|
||||
{
|
||||
#define IDX(i,j) 3*i+j
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 3; j++)
|
||||
res[IDX(i,j)] = m1[IDX(i,0)] * m2[IDX(0,j)]
|
||||
+ m1[IDX(i,1)] * m2[IDX(1,j)]
|
||||
+ m1[IDX(i,2)] * m2[IDX(2,j)];
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GdkColorState *
|
||||
gdk_color_state_new_for_cicp (const GdkCicp *cicp,
|
||||
GError **error)
|
||||
{
|
||||
GdkCicpColorState *self;
|
||||
GdkTransferFunc eotf;
|
||||
GdkTransferFunc oetf;
|
||||
gconstpointer to_xyz;
|
||||
gconstpointer from_xyz;
|
||||
|
||||
if (cicp->range == GDK_CICP_RANGE_NARROW || cicp->matrix_coefficients != 0)
|
||||
{
|
||||
g_set_error (error,
|
||||
G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
_("cicp: Narrow range or YUV not supported"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (cicp->color_primaries == 2 ||
|
||||
cicp->transfer_function == 2 ||
|
||||
cicp->matrix_coefficients == 2)
|
||||
{
|
||||
g_set_error (error,
|
||||
G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
_("cicp: Unspecified parameters not supported"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (guint i = 0; i < GDK_COLOR_STATE_N_IDS; i++)
|
||||
{
|
||||
if (gdk_cicp_equivalent (cicp, &gdk_default_color_states[i].cicp))
|
||||
return (GdkColorState *) &gdk_default_color_states[i];
|
||||
}
|
||||
|
||||
switch (cicp->transfer_function)
|
||||
{
|
||||
case 1:
|
||||
case 6:
|
||||
case 14:
|
||||
case 15:
|
||||
eotf = bt709_eotf;
|
||||
oetf = bt709_oetf;
|
||||
break;
|
||||
case 4:
|
||||
eotf = gamma22_eotf;
|
||||
oetf = gamma22_oetf;
|
||||
break;
|
||||
case 5:
|
||||
eotf = gamma28_eotf;
|
||||
oetf = gamma28_oetf;
|
||||
break;
|
||||
case 8:
|
||||
eotf = NONE;
|
||||
oetf = NONE;
|
||||
break;
|
||||
case 13:
|
||||
eotf = srgb_eotf;
|
||||
oetf = srgb_oetf;
|
||||
break;
|
||||
case 16:
|
||||
eotf = pq_eotf;
|
||||
oetf = pq_oetf;
|
||||
break;
|
||||
case 18:
|
||||
eotf = hlg_eotf;
|
||||
oetf = hlg_oetf;
|
||||
break;
|
||||
default:
|
||||
g_set_error (error,
|
||||
G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
_("cicp: Transfer function %u not supported"),
|
||||
cicp->transfer_function);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (cicp->color_primaries)
|
||||
{
|
||||
case 1:
|
||||
to_xyz = srgb_to_xyz;
|
||||
from_xyz = xyz_to_srgb;
|
||||
break;
|
||||
case 5:
|
||||
to_xyz = pal_to_xyz;
|
||||
from_xyz = xyz_to_pal;
|
||||
break;
|
||||
case 6:
|
||||
to_xyz = ntsc_to_xyz;
|
||||
from_xyz = xyz_to_ntsc;
|
||||
break;
|
||||
case 9:
|
||||
to_xyz = rec2020_to_xyz;
|
||||
from_xyz = xyz_to_rec2020;
|
||||
break;
|
||||
case 10:
|
||||
to_xyz = identity;
|
||||
from_xyz = identity;
|
||||
break;
|
||||
case 12:
|
||||
to_xyz = p3_to_xyz;
|
||||
from_xyz = xyz_to_p3;
|
||||
break;
|
||||
default:
|
||||
g_set_error (error,
|
||||
G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
_("cicp: Color primaries %u not supported"),
|
||||
cicp->color_primaries);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
self = g_new0 (GdkCicpColorState, 1);
|
||||
|
||||
self->parent.klass = &GDK_CICP_COLOR_STATE_CLASS;
|
||||
self->parent.ref_count = 1;
|
||||
|
||||
/* sRGB is special-cased by being a default colorstate */
|
||||
self->parent.rendering_color_state = GDK_COLOR_STATE_REC2100_LINEAR;
|
||||
|
||||
self->parent.depth = GDK_MEMORY_FLOAT16;
|
||||
|
||||
memcpy (&self->cicp, cicp, sizeof (GdkCicp));
|
||||
|
||||
self->eotf = eotf;
|
||||
self->oetf = oetf;
|
||||
|
||||
self->to_srgb = multiply (g_new (float, 9), xyz_to_srgb, to_xyz);
|
||||
self->to_rec2020 = multiply (g_new (float, 9), xyz_to_rec2020, to_xyz);
|
||||
self->from_srgb = multiply (g_new (float, 9), from_xyz, srgb_to_xyz);
|
||||
self->from_rec2020 = multiply (g_new (float, 9), from_xyz, rec2020_to_xyz);
|
||||
|
||||
self->name = g_strdup_printf ("cicp-%u/%u/%u/%u",
|
||||
cicp->color_primaries,
|
||||
cicp->transfer_function,
|
||||
cicp->matrix_coefficients,
|
||||
cicp->range);
|
||||
|
||||
if (cicp->transfer_function == 13)
|
||||
{
|
||||
GdkCicp no_srgb;
|
||||
|
||||
memcpy (&no_srgb, cicp, sizeof (GdkCicp));
|
||||
no_srgb.transfer_function = 8;
|
||||
|
||||
self->no_srgb = gdk_color_state_new_for_cicp (&no_srgb, NULL);
|
||||
}
|
||||
|
||||
return (GdkColorState *) self;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Private API */
|
||||
|
||||
/*<private>
|
||||
* gdk_color_state_get_name:
|
||||
* @self: a colorstate
|
||||
*
|
||||
* Returns the name of @self.
|
||||
*
|
||||
* This is *not* a translated, user-visible string.
|
||||
*
|
||||
* Returns: (transfer none): a name for representing the color state
|
||||
* in diagnostic output
|
||||
*/
|
||||
const char *
|
||||
gdk_color_state_get_name (GdkColorState *self)
|
||||
{
|
||||
return self->klass->get_name (self);
|
||||
}
|
||||
|
||||
/*<private>
|
||||
* gdk_color_state_get_no_srgb_tf:
|
||||
* @self: a colorstate
|
||||
*
|
||||
* This function checks if the colorstate uses an sRGB transfer function
|
||||
* as final operation. In that case, it is suitable for use with GL_SRGB
|
||||
* (and the Vulkan equivalents).
|
||||
*
|
||||
* If it is suitable, the colorstate without the transfer function is
|
||||
* returned. Otherwise, this function returns NULL.
|
||||
*
|
||||
* Returns: (transfer none): the colorstate without sRGB transfer function.
|
||||
**/
|
||||
GdkColorState *
|
||||
gdk_color_state_get_no_srgb_tf (GdkColorState *self)
|
||||
{
|
||||
if (!GDK_DEBUG_CHECK (LINEAR))
|
||||
return FALSE;
|
||||
|
||||
return self->klass->get_no_srgb_tf (self);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* vim:set foldmethod=marker expandtab: */
|
@@ -1,62 +0,0 @@
|
||||
/* gdkcolorstate.h
|
||||
*
|
||||
* Copyright 2024 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_COLOR_STATE (gdk_color_state_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GType gdk_color_state_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkColorState * gdk_color_state_ref (GdkColorState *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
void gdk_color_state_unref (GdkColorState *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkColorState * gdk_color_state_get_srgb (void);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkColorState * gdk_color_state_get_srgb_linear (void);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkColorState * gdk_color_state_get_rec2100_pq (void);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkColorState * gdk_color_state_get_rec2100_linear (void);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
gboolean gdk_color_state_equal (GdkColorState *self,
|
||||
GdkColorState *other);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkCicpParams *gdk_color_state_create_cicp_params (GdkColorState *self);
|
||||
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkColorState, gdk_color_state_unref);
|
||||
|
||||
G_END_DECLS
|
@@ -1,187 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "gdkcolorstate.h"
|
||||
|
||||
#include "gdkcicpparamsprivate.h"
|
||||
#include "gdkdebugprivate.h"
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
#include "gdkrgba.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_COLOR_STATE_ID_SRGB,
|
||||
GDK_COLOR_STATE_ID_SRGB_LINEAR,
|
||||
GDK_COLOR_STATE_ID_REC2100_PQ,
|
||||
GDK_COLOR_STATE_ID_REC2100_LINEAR,
|
||||
|
||||
GDK_COLOR_STATE_N_IDS
|
||||
} GdkColorStateId;
|
||||
|
||||
typedef struct _GdkColorStateClass GdkColorStateClass;
|
||||
|
||||
struct _GdkColorState
|
||||
{
|
||||
const GdkColorStateClass *klass;
|
||||
gatomicrefcount ref_count;
|
||||
|
||||
GdkMemoryDepth depth;
|
||||
GdkColorState *rendering_color_state;
|
||||
};
|
||||
|
||||
/* Note: self may be the source or the target colorstate */
|
||||
typedef void (* GdkFloatColorConvert)(GdkColorState *self,
|
||||
float (*values)[4],
|
||||
gsize n_values);
|
||||
|
||||
struct _GdkColorStateClass
|
||||
{
|
||||
void (* free) (GdkColorState *self);
|
||||
gboolean (* equal) (GdkColorState *self,
|
||||
GdkColorState *other);
|
||||
const char * (* get_name) (GdkColorState *self);
|
||||
GdkColorState * (* get_no_srgb_tf) (GdkColorState *self);
|
||||
GdkFloatColorConvert (* get_convert_to) (GdkColorState *self,
|
||||
GdkColorState *target);
|
||||
GdkFloatColorConvert (* get_convert_from) (GdkColorState *self,
|
||||
GdkColorState *source);
|
||||
const GdkCicp * (* get_cicp) (GdkColorState *self);
|
||||
};
|
||||
|
||||
typedef struct _GdkDefaultColorState GdkDefaultColorState;
|
||||
|
||||
struct _GdkDefaultColorState
|
||||
{
|
||||
GdkColorState parent;
|
||||
|
||||
const char *name;
|
||||
GdkColorState *no_srgb;
|
||||
GdkFloatColorConvert convert_to[GDK_COLOR_STATE_N_IDS];
|
||||
|
||||
GdkCicp cicp;
|
||||
};
|
||||
|
||||
extern GdkDefaultColorState gdk_default_color_states[GDK_COLOR_STATE_N_IDS];
|
||||
|
||||
#define GDK_COLOR_STATE_SRGB ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB])
|
||||
#define GDK_COLOR_STATE_SRGB_LINEAR ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB_LINEAR])
|
||||
#define GDK_COLOR_STATE_REC2100_PQ ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_REC2100_PQ])
|
||||
#define GDK_COLOR_STATE_REC2100_LINEAR ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_REC2100_LINEAR])
|
||||
|
||||
#define GDK_IS_DEFAULT_COLOR_STATE(c) ((GdkDefaultColorState *) (c) >= &gdk_default_color_states[0] && \
|
||||
(GdkDefaultColorState *) (c) < &gdk_default_color_states[GDK_COLOR_STATE_N_IDS])
|
||||
#define GDK_DEFAULT_COLOR_STATE_ID(c) ((GdkColorStateId) (((GdkDefaultColorState *) c) - gdk_default_color_states))
|
||||
|
||||
const char * gdk_color_state_get_name (GdkColorState *color_state);
|
||||
GdkColorState * gdk_color_state_get_no_srgb_tf (GdkColorState *self);
|
||||
|
||||
static inline GdkColorState *
|
||||
gdk_color_state_get_rendering_color_state (GdkColorState *self)
|
||||
{
|
||||
if (GDK_DEBUG_CHECK (HDR))
|
||||
self = GDK_COLOR_STATE_REC2100_PQ;
|
||||
|
||||
if (!GDK_DEBUG_CHECK (LINEAR))
|
||||
return self;
|
||||
|
||||
return self->rendering_color_state;
|
||||
}
|
||||
|
||||
static inline GdkMemoryDepth
|
||||
gdk_color_state_get_depth (GdkColorState *self)
|
||||
{
|
||||
if (!GDK_DEBUG_CHECK (LINEAR) && self->depth == GDK_MEMORY_U8_SRGB)
|
||||
return GDK_MEMORY_U8;
|
||||
|
||||
return self->depth;
|
||||
}
|
||||
|
||||
static inline GdkColorState *
|
||||
gdk_color_state_get_by_id (GdkColorStateId id)
|
||||
{
|
||||
return (GdkColorState *) &gdk_default_color_states[id];
|
||||
}
|
||||
|
||||
#define gdk_color_state_ref(self) _gdk_color_state_ref (self)
|
||||
static inline GdkColorState *
|
||||
_gdk_color_state_ref (GdkColorState *self)
|
||||
{
|
||||
if (GDK_IS_DEFAULT_COLOR_STATE (self))
|
||||
return self;
|
||||
|
||||
g_atomic_ref_count_inc (&self->ref_count);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
#define gdk_color_state_unref(self) _gdk_color_state_unref (self)
|
||||
static inline void
|
||||
_gdk_color_state_unref (GdkColorState *self)
|
||||
{
|
||||
if (GDK_IS_DEFAULT_COLOR_STATE (self))
|
||||
return;
|
||||
|
||||
if (g_atomic_ref_count_dec (&self->ref_count))
|
||||
self->klass->free (self);
|
||||
}
|
||||
|
||||
#define gdk_color_state_equal(a,b) _gdk_color_state_equal ((a), (b))
|
||||
static inline gboolean
|
||||
_gdk_color_state_equal (GdkColorState *self,
|
||||
GdkColorState *other)
|
||||
{
|
||||
if (self == other)
|
||||
return TRUE;
|
||||
|
||||
if (self->klass != other->klass)
|
||||
return FALSE;
|
||||
|
||||
return self->klass->equal (self, other);
|
||||
}
|
||||
|
||||
/* Note: the functions returned from this expect the source
|
||||
* color state to be passed as self
|
||||
*/
|
||||
static inline GdkFloatColorConvert
|
||||
gdk_color_state_get_convert_to (GdkColorState *self,
|
||||
GdkColorState *target)
|
||||
{
|
||||
return self->klass->get_convert_to (self, target);
|
||||
}
|
||||
|
||||
/* Note: the functions returned from this expect the target
|
||||
* color state to be passed as self
|
||||
*/
|
||||
static inline GdkFloatColorConvert
|
||||
gdk_color_state_get_convert_from (GdkColorState *self,
|
||||
GdkColorState *source)
|
||||
{
|
||||
return self->klass->get_convert_from (self, source);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gdk_color_state_from_rgba (GdkColorState *self,
|
||||
const GdkRGBA *rgba,
|
||||
float out_color[4])
|
||||
{
|
||||
GdkFloatColorConvert convert;
|
||||
|
||||
out_color[0] = rgba->red;
|
||||
out_color[1] = rgba->green;
|
||||
out_color[2] = rgba->blue;
|
||||
out_color[3] = rgba->alpha;
|
||||
|
||||
if (gdk_color_state_equal (GDK_COLOR_STATE_SRGB, self))
|
||||
return;
|
||||
|
||||
convert = gdk_color_state_get_convert_to (GDK_COLOR_STATE_SRGB, self);
|
||||
convert (GDK_COLOR_STATE_SRGB, (float(*)[4]) out_color, 1);
|
||||
}
|
||||
|
||||
static inline const GdkCicp *
|
||||
gdk_color_state_get_cicp (GdkColorState *self)
|
||||
{
|
||||
return self->klass->get_cicp (self);
|
||||
}
|
||||
|
||||
GdkColorState * gdk_color_state_new_for_cicp (const GdkCicp *cicp,
|
||||
GError **error);
|
@@ -533,13 +533,16 @@ deserialize_not_found (GdkContentDeserializer *deserializer)
|
||||
* @type: the GType to deserialize from
|
||||
* @io_priority: the I/O priority of the operation
|
||||
* @cancellable: (nullable): optional `GCancellable` object
|
||||
* @callback: (scope async) (closure user_data): callback to call when the operation is done
|
||||
* @user_data: data to pass to the callback function
|
||||
* @callback: (scope async): callback to call when the operation is done
|
||||
* @user_data: (closure): data to pass to the callback function
|
||||
*
|
||||
* Read content from the given input stream and deserialize it, asynchronously.
|
||||
*
|
||||
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
|
||||
* indicate a higher priority.
|
||||
*
|
||||
* When the operation is finished, @callback will be called. You must then
|
||||
* call [func@Gdk.content_deserialize_finish] to get the result of the operation.
|
||||
*/
|
||||
void
|
||||
gdk_content_deserialize_async (GInputStream *stream,
|
||||
|
@@ -273,12 +273,16 @@ gdk_content_provider_content_changed (GdkContentProvider *provider)
|
||||
* @stream: the `GOutputStream` to write to
|
||||
* @io_priority: I/O priority of the request.
|
||||
* @cancellable: (nullable): optional `GCancellable` object, %NULL to ignore.
|
||||
* @callback: (scope async) (closure user_data): callback to call when the request is satisfied
|
||||
* @user_data: the data to pass to callback function
|
||||
* @callback: (scope async): callback to call when the request is satisfied
|
||||
* @user_data: (closure): the data to pass to callback function
|
||||
*
|
||||
* Asynchronously writes the contents of @provider to @stream in the given
|
||||
* @mime_type.
|
||||
*
|
||||
* When the operation is finished @callback will be called. You must then call
|
||||
* [method@Gdk.ContentProvider.write_mime_type_finish] to get the result
|
||||
* of the operation.
|
||||
*
|
||||
* The given mime type does not need to be listed in the formats returned by
|
||||
* [method@Gdk.ContentProvider.ref_formats]. However, if the given `GType` is
|
||||
* not supported, `G_IO_ERROR_NOT_SUPPORTED` will be reported.
|
||||
|
@@ -539,13 +539,16 @@ serialize_not_found (GdkContentSerializer *serializer)
|
||||
* @value: the content to serialize
|
||||
* @io_priority: the I/O priority of the operation
|
||||
* @cancellable: (nullable): optional `GCancellable` object
|
||||
* @callback: (scope async) (closure): callback to call when the operation is done
|
||||
* @user_data: data to pass to the callback function
|
||||
* @callback: (scope async): callback to call when the operation is done
|
||||
* @user_data: (closure): data to pass to the callback function
|
||||
*
|
||||
* Serialize content and write it to the given output stream, asynchronously.
|
||||
*
|
||||
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
|
||||
* indicate a higher priority.
|
||||
*
|
||||
* When the operation is finished, @callback will be called. You must then
|
||||
* call [func@Gdk.content_serialize_finish] to get the result of the operation.
|
||||
*/
|
||||
void
|
||||
gdk_content_serialize_async (GOutputStream *stream,
|
||||
|
@@ -156,9 +156,6 @@ 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);
|
||||
}
|
||||
|
||||
@@ -256,11 +253,6 @@ 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;
|
||||
|
||||
@@ -289,10 +281,6 @@ 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;
|
||||
}
|
||||
|
||||
@@ -367,45 +355,6 @@ 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`
|
||||
@@ -510,22 +459,3 @@ 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);
|
||||
}
|
||||
|
@@ -51,52 +51,6 @@ 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
|
||||
|