Compare commits
391 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 95a3d3c26f | |||
| df1bca3027 | |||
| acf81a0377 | |||
| bf8fca391a | |||
| aa722dcfac | |||
| f5ccf63550 | |||
| 61f9b1d9e0 | |||
| aa8ba37a0f | |||
| 86c1493b4b | |||
| f58513e4dd | |||
| c816eee4d1 | |||
| 436fe18084 | |||
| 3ba2659860 | |||
| ffc5fdb9de | |||
| e88cf34642 | |||
| 5eb79b3b01 | |||
| cf793f94ac | |||
| ba405bfbf1 | |||
| 4b6223e07d | |||
| 8637ea8fb8 | |||
| ab8a32bc76 | |||
| 6aa38e6b39 | |||
| 46bef9b667 | |||
| 86862d56bd | |||
| 1e5c025a1e | |||
| 60f87f2a7d | |||
| 001903aeef | |||
| 3b04f5a963 | |||
| de29a01682 | |||
| bd3b88b276 | |||
| e7a9030fb5 | |||
| 98aca9e2cd | |||
| 6e8b23d485 | |||
| 05678d44ca | |||
| 7b4bc08254 | |||
| 3b81a9e529 | |||
| 6a0901c40e | |||
| a7b3a0c472 | |||
| 645eddf838 | |||
| ada1cc7dc5 | |||
| 042a3a1344 | |||
| 2542d913bc | |||
| fc619b9783 | |||
| 3c56f326fc | |||
| 4c81600fc9 | |||
| 68661b7291 | |||
| b6a2a8b0fc | |||
| d08802a2c3 | |||
| 759bf152d3 | |||
| 021bca4629 | |||
| f91995db06 | |||
| ad145e201b | |||
| 0bef169b32 | |||
| 5f40db5043 | |||
| afd398112b | |||
| 98591b383b | |||
| 319e75c73f | |||
| c80d5f89d8 | |||
| 8dd4f022c1 | |||
| ee42889790 | |||
| bd0f92fa8b | |||
| c438527e49 | |||
| dad4e1da22 | |||
| 52394b1520 | |||
| 3efd6c9a12 | |||
| 6d04869c85 | |||
| 5781a8c66a | |||
| 65813c3f19 | |||
| 33d5acf1db | |||
| d0d62ee0d6 | |||
| e359e0b146 | |||
| 4a633e4476 | |||
| 78c2fca48e | |||
| 9b93dcbbd8 | |||
| 5acdc8358e | |||
| 9ecd508b86 | |||
| 452eb951d7 | |||
| a6e665c6f3 | |||
| 19f2eddf46 | |||
| a79d427a4b | |||
| f9d794d315 | |||
| 75b96fa7cf | |||
| a5763a3de1 | |||
| 6c9206d46a | |||
| 918b07967c | |||
| 2f3aae002d | |||
| a1f9a45f17 | |||
| 57cf7e6fc2 | |||
| 5c817aef62 | |||
| b7c83ce45c | |||
| 8b13ea22be | |||
| a21b3c7337 | |||
| eb04db32e0 | |||
| faf0c8d1f9 | |||
| 2f91089b71 | |||
| b0a1b4f672 | |||
| 599baee1c4 | |||
| 51d645168f | |||
| 5991f4b6c9 | |||
| a41b9ebec7 | |||
| 50098ba75b | |||
| c804a3863e | |||
| a94a8857cc | |||
| 4b5ee6e45d | |||
| e30ef1989d | |||
| 288e8a46cf | |||
| db8d6e3d99 | |||
| 9d313b3264 | |||
| a28311883f | |||
| aa695ae1c2 | |||
| 42b017d073 | |||
| 0414c15537 | |||
| 98435e15dd | |||
| 7f63e426cc | |||
| 9e450370e8 | |||
| 5fe35cb0fd | |||
| 70f097ebd7 | |||
| 1f1641fdfc | |||
| dce77dc2a5 | |||
| 1500250116 | |||
| 8a5c2e771a | |||
| 419f4f87a4 | |||
| 0f848aace9 | |||
| c1111d9c4d | |||
| 614e043c94 | |||
| ee8ad62bb5 | |||
| ec6d102dc5 | |||
| c82cfa8b0c | |||
| ab41ef43d8 | |||
| aa913100ba | |||
| 0e256a6935 | |||
| 2559885415 | |||
| d9a79c0a2f | |||
| 268efbd5a6 | |||
| a14770a47d | |||
| d42f45bc5a | |||
| 87b108209e | |||
| 5ac2abc6d9 | |||
| 9c721bff1b | |||
| 78cae537a9 | |||
| 69cdeb6037 | |||
| 8d1f354d01 | |||
| c8928bf064 | |||
| 2b029af78f | |||
| 592bab384f | |||
| ffebe0c340 | |||
| 16ca8f75fd | |||
| 955762c5e8 | |||
| c49205c1e6 | |||
| fc67b5a8cf | |||
| ce1b970b46 | |||
| ceb77d6100 | |||
| 02579a1333 | |||
| 2f7fa10434 | |||
| 6be352f446 | |||
| 4d2be2e322 | |||
| d5c01098fd | |||
| d2bda8ea77 | |||
| c517e945de | |||
| e3a1a2e0c6 | |||
| b9c2a925e2 | |||
| 59238c6e73 | |||
| 652ab1ac72 | |||
| bdf879427c | |||
| 4058b80d56 | |||
| be949496ac | |||
| b57b12fdb7 | |||
| e64bb40d0b | |||
| c8d83b7a63 | |||
| 9539cc4a93 | |||
| 72cf304a86 | |||
| 67ad566188 | |||
| db46a8dd06 | |||
| 2611a996ff | |||
| 3e7618fef7 | |||
| 5b1b75b055 | |||
| f1612e36ee | |||
| bfd3d714b9 | |||
| 5a42ccc575 | |||
| b3b0321620 | |||
| e0deacd236 | |||
| f66172451d | |||
| e80238120e | |||
| 07cfdd8ca0 | |||
| ade7509b97 | |||
| 8d1956921d | |||
| 354fa6544a | |||
| 291c50202a | |||
| ce8faa2e90 | |||
| 50e4ca8593 | |||
| ddd5704c92 | |||
| 3ba6d2bd27 | |||
| cd9b730735 | |||
| f593f3da0a | |||
| e9d8bf96e0 | |||
| 6b3a612bbc | |||
| c742debea8 | |||
| cd60ec1576 | |||
| 95e6453823 | |||
| 7e0279b15c | |||
| 791f0d70ac | |||
| 0709dc7a6a | |||
| 15528599f4 | |||
| 031aab3ef6 | |||
| c990134e49 | |||
| 822508f33e | |||
| 358893aa84 | |||
| 344fac5aa7 | |||
| 27965d5fdc | |||
| c025bc5098 | |||
| 170bc0a8de | |||
| 891fd5c604 | |||
| 5b1cd335bb | |||
| eefb6a0dd4 | |||
| 9aaf54140f | |||
| c5786916f7 | |||
| b8e009eb05 | |||
| 256d226d4b | |||
| 7b3208092c | |||
| 1eb86d6394 | |||
| a0ca936e8d | |||
| de3c50a237 | |||
| 244ddea0ea | |||
| 6c94835f5d | |||
| 617566128d | |||
| 7bf772111c | |||
| 50e0893497 | |||
| 7459d430eb | |||
| 163616cc0a | |||
| e378dc4c28 | |||
| 4876028f29 | |||
| 22847563ce | |||
| 0996113d14 | |||
| f019e9d856 | |||
| 48b83d3e97 | |||
| c3211e32ae | |||
| c1790bf0d8 | |||
| 6690197673 | |||
| 384196efb1 | |||
| b801125797 | |||
| aecdd6f68f | |||
| 899cb44519 | |||
| 86175f043c | |||
| 74c6b8e9bc | |||
| d3347e64ba | |||
| 4c8081bafc | |||
| 5995e89a80 | |||
| b9bdbe9aae | |||
| c86789427d | |||
| 0852084884 | |||
| 96778fca92 | |||
| 0c53b608f9 | |||
| 27350ad71b | |||
| d9d220cfc9 | |||
| 2026256823 | |||
| 012baeb909 | |||
| 7249961aa4 | |||
| 3d77e526d6 | |||
| c4b2fe6ee5 | |||
| cea320af24 | |||
| a5bf0591ee | |||
| 22f5236943 | |||
| f84bcfbb97 | |||
| f36ee67226 | |||
| 615b8fc569 | |||
| ff3bb7f671 | |||
| 39e4e48fdc | |||
| 300a88922e | |||
| c003260d63 | |||
| 40c08954db | |||
| fd69b41748 | |||
| a2191c0a68 | |||
| c17451557f | |||
| b91dca9ad0 | |||
| 7586e535ff | |||
| 7859b88f19 | |||
| 7f7809f523 | |||
| b4c2d1dabb | |||
| 362e91c40b | |||
| acf6d47b6f | |||
| 0903ad48f0 | |||
| 46f8600b6a | |||
| fcb3638ac3 | |||
| e599b2548a | |||
| 98d14b4655 | |||
| 96f7e59832 | |||
| 061026f21f | |||
| 330e9a8424 | |||
| 1e47b1c610 | |||
| bf40b89b53 | |||
| 9f2dbf4fc5 | |||
| 235b0482dd | |||
| cbd332bc57 | |||
| fc8aa80e62 | |||
| 56404b7006 | |||
| 08d48201e9 | |||
| 76c4673944 | |||
| 0a31201c88 | |||
| afe94e303a | |||
| b004706009 | |||
| 129042425d | |||
| 81169d18c3 | |||
| cce6a603a6 | |||
| 1c6608f426 | |||
| fcdc5538cf | |||
| dd327bc8a6 | |||
| b878353f0b | |||
| 27d286eb7a | |||
| 01cf559d9d | |||
| 20fd760a52 | |||
| cca8ae04b6 | |||
| 60c45dac56 | |||
| 7bee4fa44b | |||
| 4c029af6cd | |||
| 1c6efea370 | |||
| 895dc94cc9 | |||
| 9f9479a50f | |||
| 13d559119f | |||
| 018388d321 | |||
| cf69d917c1 | |||
| 41599e5e90 | |||
| 1b2e69f6c0 | |||
| ee45869759 | |||
| 048fe84888 | |||
| 480031439f | |||
| dc9b145e27 | |||
| 0e27a49d1a | |||
| 4afd416840 | |||
| 25142abebf | |||
| 60d50bcb13 | |||
| 59f45aa30c | |||
| 14c32a7cf0 | |||
| 4c8e703803 | |||
| 8338e55549 | |||
| da72cfea40 | |||
| 0632e94e68 | |||
| 4a356ae331 | |||
| 4f4f2d169a | |||
| 577d520006 | |||
| 222d6f1db1 | |||
| 4ffa60be50 | |||
| 7da72d1295 | |||
| c9735e8ea9 | |||
| 8a7868d006 | |||
| c4e5242be0 | |||
| 935f7f19f3 | |||
| 5c9ae28937 | |||
| 8e27fc7f9b | |||
| e0c97e6fcc | |||
| e80d938ee5 | |||
| a6f1737861 | |||
| c78ed25e30 | |||
| c87d1c2fb9 | |||
| c66d24b41a | |||
| 155b791d43 | |||
| c5ac80be2b | |||
| 53acff167b | |||
| 9c1a41052b | |||
| a1861112ee | |||
| b2a1fb7149 | |||
| db2a03ed33 | |||
| 9e8bf10653 | |||
| c20a631ab7 | |||
| 8c63244855 | |||
| 9a31922709 | |||
| 3c2818b30a | |||
| e017e4252b | |||
| 97365a8ffe | |||
| df12a41cbb | |||
| 0aa3a7e71c | |||
| 3918cdd989 | |||
| c4df987eef | |||
| c125ffb384 | |||
| 6536e3dc54 | |||
| 164d0a5201 | |||
| 95574f98c4 | |||
| bca77b5505 | |||
| 96f63a6bf3 | |||
| 37cbd0662e | |||
| 9b23602806 | |||
| 68f2e1bc06 | |||
| bc80eb616d | |||
| d005049084 | |||
| 142571d0b8 | |||
| 5cc6b3e342 | |||
| 49032b4b63 | |||
| 1903c6d009 | |||
| 266fceddf0 | |||
| 973aa8583a | |||
| ca06aeeb2d | |||
| d1e246c68d |
+16
-17
@@ -158,7 +158,6 @@ msys2-mingw64:
|
||||
CHERE_INVOKING: "yes"
|
||||
|
||||
macos:
|
||||
allow_failure: true
|
||||
extends: .only-default
|
||||
only:
|
||||
- branches@GNOME/gtk
|
||||
@@ -222,11 +221,11 @@ vs2017-x64:
|
||||
extends: .flatpak-defaults
|
||||
when: manual
|
||||
|
||||
# Only build Flatpak bundles automatically on master
|
||||
.flatpak-master:
|
||||
# Only build Flatpak bundles automatically on main
|
||||
.flatpak-main:
|
||||
extends: .flatpak-defaults
|
||||
only:
|
||||
- master
|
||||
- main
|
||||
|
||||
flatpak-manual:demo:
|
||||
extends: .flatpak-manual
|
||||
@@ -234,8 +233,8 @@ flatpak-manual:demo:
|
||||
variables:
|
||||
APPID: org.gtk.Demo4
|
||||
|
||||
flatpak-master:demo:
|
||||
extends: .flatpak-master
|
||||
flatpak-main:demo:
|
||||
extends: .flatpak-main
|
||||
needs: []
|
||||
variables:
|
||||
APPID: org.gtk.Demo4
|
||||
@@ -246,8 +245,8 @@ flatpak-manual:widget-factory:
|
||||
variables:
|
||||
APPID: org.gtk.WidgetFactory4
|
||||
|
||||
flatpak-master:widget-factory:
|
||||
extends: .flatpak-master
|
||||
flatpak-main:widget-factory:
|
||||
extends: .flatpak-main
|
||||
needs: []
|
||||
variables:
|
||||
APPID: org.gtk.WidgetFactory4
|
||||
@@ -258,8 +257,8 @@ flatpak-manual:icon-browser:
|
||||
variables:
|
||||
APPID: org.gtk.IconBrowser4
|
||||
|
||||
flatpak-master:icon-browser:
|
||||
extends: .flatpak-master
|
||||
flatpak-main:icon-browser:
|
||||
extends: .flatpak-main
|
||||
needs: []
|
||||
variables:
|
||||
APPID: org.gtk.IconBrowser4
|
||||
@@ -269,18 +268,18 @@ flatpak-master:icon-browser:
|
||||
# https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/DevOps-with-Flatpak
|
||||
nightly demo:
|
||||
extends: '.publish_nightly'
|
||||
dependencies: ['flatpak-master:demo']
|
||||
needs: ['flatpak-master:demo']
|
||||
dependencies: ['flatpak-main:demo']
|
||||
needs: ['flatpak-main:demo']
|
||||
|
||||
nightly factory:
|
||||
extends: '.publish_nightly'
|
||||
dependencies: ['flatpak-master:widget-factory']
|
||||
needs: ['flatpak-master:widget-factory']
|
||||
dependencies: ['flatpak-main:widget-factory']
|
||||
needs: ['flatpak-main:widget-factory']
|
||||
|
||||
nightly icon-browser:
|
||||
extends: '.publish_nightly'
|
||||
dependencies: ['flatpak-master:icon-browser']
|
||||
needs: ['flatpak-master:icon-browser']
|
||||
dependencies: ['flatpak-main:icon-browser']
|
||||
needs: ['flatpak-main:icon-browser']
|
||||
|
||||
static-scan:
|
||||
image: $FEDORA_IMAGE
|
||||
@@ -347,4 +346,4 @@ publish-docs:
|
||||
- "curl -X POST -F token=${PAGES_TRIGGER_TOKEN} -F ref=docs-gtk-org https://gitlab.gnome.org/api/v4/projects/665/trigger/pipeline"
|
||||
only:
|
||||
refs:
|
||||
- master
|
||||
- main
|
||||
|
||||
@@ -43,6 +43,6 @@ flatpak build-bundle \
|
||||
${appid}
|
||||
|
||||
# to be consumed by the nightly publish jobs
|
||||
if [[ $CI_COMMIT_BRANCH == master ]]; then
|
||||
if [[ $CI_COMMIT_BRANCH == main ]]; then
|
||||
tar cf repo.tar ${repodir}
|
||||
fi
|
||||
|
||||
@@ -268,7 +268,7 @@ aparser.add_argument('--job-id', metavar='ID',
|
||||
default=None)
|
||||
aparser.add_argument('--branch', metavar='NAME',
|
||||
help='Branch of the project being tested',
|
||||
default='master')
|
||||
default='main')
|
||||
aparser.add_argument('--output', metavar='FILE',
|
||||
help='The output HTML file, stdout by default',
|
||||
type=argparse.FileType('w', encoding='UTF-8'),
|
||||
|
||||
@@ -27,7 +27,7 @@ aparser.add_argument('--job-id', metavar='ID',
|
||||
default='Unknown')
|
||||
aparser.add_argument('--branch', metavar='NAME',
|
||||
help='Branch of the project being tested',
|
||||
default='master')
|
||||
default='main')
|
||||
aparser.add_argument('--output', metavar='FILE',
|
||||
help='The output file, stdout by default',
|
||||
type=argparse.FileType('w', encoding='UTF-8'),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
# We need to add a new remote for the upstream master, since this script could
|
||||
# We need to add a new remote for the upstream main, since this script could
|
||||
# be running in a personal fork of the repository which has out of date branches.
|
||||
if [ "${CI_PROJECT_NAMESPACE}" != "GNOME" ]; then
|
||||
echo "Retrieving the current upstream repository from ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}..."
|
||||
@@ -16,7 +16,7 @@ fi
|
||||
|
||||
# Work out the newest common ancestor between the detached HEAD that this CI job
|
||||
# has checked out, and the upstream target branch (which will typically be
|
||||
# `upstream/master` or `upstream/gtk-3-24`).
|
||||
# `upstream/main` or `upstream/gtk-3-24`).
|
||||
#
|
||||
# `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` is only defined if we’re running in
|
||||
# a merge request pipeline; fall back to `${CI_DEFAULT_BRANCH}` otherwise.
|
||||
@@ -36,7 +36,7 @@ exit_status=$?
|
||||
echo ""
|
||||
echo "Note that clang-format output is advisory and cannot always match the"
|
||||
echo "GTK coding style, documented at:"
|
||||
echo " https://gitlab.gnome.org/GNOME/gtk/blob/master/docs/CODING-STYLE"
|
||||
echo " https://gitlab.gnome.org/GNOME/gtk/blob/main/docs/CODING-STYLE"
|
||||
echo "Warnings from this tool can be ignored in favour of the documented "
|
||||
echo "coding style, or in favour of matching the style of existing"
|
||||
echo "surrounding code."
|
||||
|
||||
@@ -48,7 +48,7 @@ if ! pkg-config --atleast-version=2.66.0 glib-2.0; then
|
||||
fi
|
||||
pkg-config --modversion glib-2.0
|
||||
|
||||
if ! pkg-config --atleast-version=1.49.1 pango; then
|
||||
if ! pkg-config --atleast-version=1.50.0 pango; then
|
||||
git clone https://gitlab.gnome.org/GNOME/pango.git _pango
|
||||
meson setup _pango_build _pango
|
||||
meson compile -C _pango_build
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
Please, read the CONTRIBUTING.md guide on how to file a new issue.
|
||||
|
||||
https://gitlab.gnome.org/GNOME/gtk/-/blob/master/CONTRIBUTING.md
|
||||
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/CONTRIBUTING.md
|
||||
-->
|
||||
## Steps to reproduce
|
||||
<!--
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
Please, read the CONTRIBUTING.md guide on how to file a new issue.
|
||||
|
||||
https://gitlab.gnome.org/GNOME/gtk/-/blob/master/CONTRIBUTING.md
|
||||
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/CONTRIBUTING.md
|
||||
-->
|
||||
|
||||
## Steps to reproduce
|
||||
|
||||
+1
-1
@@ -256,7 +256,7 @@ people committing to GTK to follow a few rules:
|
||||
0. Always write a meaningful commit message. Changes without a sufficient
|
||||
commit message will be reverted.
|
||||
|
||||
0. Never push to the `master` branch, or any stable branches, directly; you
|
||||
0. Never push to the `main` branch, or any stable branches, directly; you
|
||||
should always go through a merge request, to ensure that the code is
|
||||
tested on the CI infrastructure at the very least. A merge request is
|
||||
also the proper place to get a comprehensive code review from the core
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
Overview of Changes
|
||||
===================
|
||||
|
||||
* Rename git `master` branch to `main`
|
||||
|
||||
Overview of Changes in 4.5.0
|
||||
============================
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
GTK — The GTK toolkit
|
||||
=====================
|
||||
|
||||
[](https://gitlab.gnome.org/GNOME/gtk/-/commits/master)
|
||||
[](https://gitlab.gnome.org/GNOME/gtk/-/commits/main)
|
||||
|
||||
General information
|
||||
-------------------
|
||||
@@ -40,7 +40,7 @@ Nightly documentation can be found at
|
||||
|
||||
Nightly flatpaks of our demos can be installed from the
|
||||
[GNOME Nightly](https://wiki.gnome.org/Apps/Nightly) repository:
|
||||
- `flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo`
|
||||
- `flatpak 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`
|
||||
@@ -116,6 +116,20 @@ docs/reference/gtk/html/gtk-building.html
|
||||
|
||||
Or [online](https://docs.gtk.org/gtk4/building.html)
|
||||
|
||||
Default branch renamed to `main`
|
||||
--------------------------------
|
||||
|
||||
The default development branch of GTK has been renamed to `main`.
|
||||
To update your local checkout, use:
|
||||
```sh
|
||||
git checkout master
|
||||
git branch -m master main
|
||||
git fetch
|
||||
git branch --unset-upstream
|
||||
git branch -u origin/main
|
||||
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
|
||||
```
|
||||
|
||||
How to report bugs
|
||||
------------------
|
||||
|
||||
|
||||
@@ -164,6 +164,21 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "pango",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://gitlab.gnome.org/GNOME/pango.git",
|
||||
"branch" : "main"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "gtk",
|
||||
"buildsystem" : "meson",
|
||||
@@ -177,7 +192,8 @@
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://gitlab.gnome.org/GNOME/gtk.git"
|
||||
"url" : "https://gitlab.gnome.org/GNOME/gtk.git",
|
||||
"branch" : "main"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -93,6 +93,21 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "pango",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://gitlab.gnome.org/GNOME/pango.git",
|
||||
"branch" : "main"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "gtk",
|
||||
"buildsystem" : "meson",
|
||||
@@ -106,7 +121,8 @@
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://gitlab.gnome.org/GNOME/gtk.git"
|
||||
"url" : "https://gitlab.gnome.org/GNOME/gtk.git",
|
||||
"branch" : "main"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -93,6 +93,21 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "pango",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://gitlab.gnome.org/GNOME/pango.git",
|
||||
"branch" : "main"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "gtk",
|
||||
"buildsystem" : "meson",
|
||||
@@ -106,7 +121,8 @@
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://gitlab.gnome.org/GNOME/gtk.git"
|
||||
"url" : "https://gitlab.gnome.org/GNOME/gtk.git",
|
||||
"branch" : "main"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ do_cursors (GtkWidget *do_widget)
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/cursors/cursors.ui");
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_signal_connect (window, "destroy",
|
||||
@@ -34,9 +35,7 @@ do_cursors (GtkWidget *do_widget)
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
{
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
}
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CURVE_TYPE_EDITOR (curve_editor_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (CurveEditor, curve_editor, CURVE, EDITOR, GtkWidget)
|
||||
|
||||
GtkWidget * curve_editor_new (void);
|
||||
|
||||
void curve_editor_set_edit (CurveEditor *self,
|
||||
gboolean edit);
|
||||
|
||||
void curve_editor_set_path (CurveEditor *self,
|
||||
GskPath *path);
|
||||
|
||||
GskPath * curve_editor_get_path (CurveEditor *self);
|
||||
|
||||
void curve_editor_set_stroke (CurveEditor *self,
|
||||
GskStroke *stroke);
|
||||
|
||||
const GskStroke * curve_editor_get_stroke (CurveEditor *self);
|
||||
|
||||
|
||||
void curve_editor_set_color (CurveEditor *self,
|
||||
GdkRGBA *color);
|
||||
|
||||
const GdkRGBA * curve_editor_get_color (CurveEditor *self);
|
||||
|
||||
gboolean curve_editor_get_show_outline (CurveEditor *self);
|
||||
|
||||
void curve_editor_set_show_outline (CurveEditor *self,
|
||||
gboolean show_outline);
|
||||
|
||||
G_END_DECLS
|
||||
@@ -0,0 +1,272 @@
|
||||
/* Path/Curve Editor
|
||||
*
|
||||
* This demo shows an elaborate curve editor that you would expect to find
|
||||
* in a vector graphics editor. It is built on top of GTK's path APIs.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "curve-editor.h"
|
||||
|
||||
|
||||
static GskPath *
|
||||
make_circle_path (void)
|
||||
{
|
||||
float w = 310;
|
||||
float h = 310;
|
||||
float cx = w / 2;
|
||||
float cy = h / 2;
|
||||
float pad = 20;
|
||||
float r = (w - 2 * pad) / 2;
|
||||
float k = 0.55228;
|
||||
float kr = k * r;
|
||||
GskPathBuilder *builder;
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
|
||||
gsk_path_builder_move_to (builder, cx, pad);
|
||||
gsk_path_builder_curve_to (builder, cx + kr, pad,
|
||||
w - pad, cy - kr,
|
||||
w - pad, cy);
|
||||
gsk_path_builder_curve_to (builder, w - pad, cy + kr,
|
||||
cx + kr, h - pad,
|
||||
cx, h - pad);
|
||||
gsk_path_builder_curve_to (builder, cx - kr, h - pad,
|
||||
pad, cy + kr,
|
||||
pad, cy);
|
||||
gsk_path_builder_curve_to (builder, pad, cy - kr,
|
||||
cx - kr, pad,
|
||||
cx, pad);
|
||||
gsk_path_builder_close (builder);
|
||||
|
||||
return gsk_path_builder_free_to_path (builder);
|
||||
}
|
||||
|
||||
static void
|
||||
edit_changed (GtkToggleButton *button,
|
||||
GParamSpec *pspec,
|
||||
CurveEditor *editor)
|
||||
{
|
||||
curve_editor_set_edit (editor, gtk_toggle_button_get_active (button));
|
||||
}
|
||||
|
||||
static void
|
||||
reset (GtkButton *button,
|
||||
CurveEditor *editor)
|
||||
{
|
||||
GskPath *path;
|
||||
|
||||
path = make_circle_path ();
|
||||
curve_editor_set_path (editor, path);
|
||||
gsk_path_unref (path);
|
||||
}
|
||||
|
||||
static void
|
||||
line_width_changed (GtkSpinButton *spin,
|
||||
CurveEditor *editor)
|
||||
{
|
||||
GskStroke *stroke;
|
||||
|
||||
stroke = gsk_stroke_copy (curve_editor_get_stroke (editor));
|
||||
gsk_stroke_set_line_width (stroke, gtk_spin_button_get_value (spin));
|
||||
curve_editor_set_stroke (editor, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
}
|
||||
|
||||
static void
|
||||
cap_changed (GtkDropDown *combo,
|
||||
GParamSpec *pspec,
|
||||
CurveEditor *editor)
|
||||
{
|
||||
GskStroke *stroke;
|
||||
|
||||
stroke = gsk_stroke_copy (curve_editor_get_stroke (editor));
|
||||
gsk_stroke_set_line_cap (stroke, (GskLineCap)gtk_drop_down_get_selected (combo));
|
||||
curve_editor_set_stroke (editor, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
}
|
||||
|
||||
static void
|
||||
join_changed (GtkDropDown *combo,
|
||||
GParamSpec *pspec,
|
||||
CurveEditor *editor)
|
||||
{
|
||||
GskStroke *stroke;
|
||||
|
||||
stroke = gsk_stroke_copy (curve_editor_get_stroke (editor));
|
||||
gsk_stroke_set_line_join (stroke, (GskLineJoin)gtk_drop_down_get_selected (combo));
|
||||
curve_editor_set_stroke (editor, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
}
|
||||
|
||||
static void
|
||||
color_changed (GtkColorChooser *chooser,
|
||||
GParamSpec *pspec,
|
||||
CurveEditor *editor)
|
||||
{
|
||||
GdkRGBA color;
|
||||
|
||||
gtk_color_chooser_get_rgba (chooser, &color);
|
||||
curve_editor_set_color (editor, &color);
|
||||
}
|
||||
|
||||
static void
|
||||
stroke_toggled (GtkCheckButton *button,
|
||||
CurveEditor *editor)
|
||||
{
|
||||
curve_editor_set_show_outline (editor, gtk_check_button_get_active (button));
|
||||
gtk_widget_queue_draw (GTK_WIDGET (editor));
|
||||
}
|
||||
|
||||
static void
|
||||
limit_changed (GtkSpinButton *spin,
|
||||
CurveEditor *editor)
|
||||
{
|
||||
GskStroke *stroke;
|
||||
|
||||
stroke = gsk_stroke_copy (curve_editor_get_stroke (editor));
|
||||
gsk_stroke_set_miter_limit (stroke, gtk_spin_button_get_value (spin));
|
||||
curve_editor_set_stroke (editor, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
}
|
||||
|
||||
static void
|
||||
dashes_changed (GtkEntry *entry,
|
||||
GParamSpec *spec,
|
||||
CurveEditor *editor)
|
||||
{
|
||||
const char *text;
|
||||
char **split;
|
||||
GArray *dash;
|
||||
GskStroke *stroke;
|
||||
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
split = g_strsplit (text, " ", 0);
|
||||
|
||||
dash = g_array_new (FALSE, FALSE, sizeof (float));
|
||||
for (int i = 0; split[i] != NULL; i++)
|
||||
{
|
||||
double d;
|
||||
char *endp = 0;
|
||||
|
||||
d = g_strtod (split[i], &endp);
|
||||
if (*endp == '\0')
|
||||
g_array_append_vals (dash, (float[1]) { d }, 1);
|
||||
}
|
||||
|
||||
g_strfreev (split);
|
||||
|
||||
stroke = gsk_stroke_copy (curve_editor_get_stroke (editor));
|
||||
gsk_stroke_set_dash (stroke, (const float *)dash->data, dash->len);
|
||||
curve_editor_set_stroke (editor, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
|
||||
g_array_free (dash, TRUE);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_curve (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *demo;
|
||||
GtkWidget *edit_toggle;
|
||||
GtkWidget *reset_button;
|
||||
GtkWidget *titlebar;
|
||||
GtkWidget *stroke_toggle;
|
||||
GtkWidget *line_width_spin;
|
||||
GtkWidget *stroke_button;
|
||||
GtkWidget *popover;
|
||||
GtkWidget *grid;
|
||||
GtkWidget *cap_combo;
|
||||
GtkWidget *join_combo;
|
||||
GtkWidget *color_button;
|
||||
GtkWidget *limit_spin;
|
||||
GtkWidget *dash_entry;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Curve Editor");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 310, 350);
|
||||
|
||||
edit_toggle = gtk_toggle_button_new ();
|
||||
gtk_button_set_icon_name (GTK_BUTTON (edit_toggle), "document-edit-symbolic");
|
||||
|
||||
reset_button = gtk_button_new_from_icon_name ("edit-undo-symbolic");
|
||||
|
||||
stroke_button = gtk_menu_button_new ();
|
||||
gtk_menu_button_set_icon_name (GTK_MENU_BUTTON (stroke_button), "open-menu-symbolic");
|
||||
popover = gtk_popover_new ();
|
||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (stroke_button), popover);
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), grid);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Color:"), 0, 0, 1, 1);
|
||||
color_button = gtk_color_button_new_with_rgba (&(GdkRGBA){ 0., 0., 0., 1.});
|
||||
gtk_grid_attach (GTK_GRID (grid), color_button, 1, 0, 1, 1);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Line width:"), 0, 1, 1, 1);
|
||||
line_width_spin = gtk_spin_button_new_with_range (1, 20, 1);
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (line_width_spin), 1);
|
||||
gtk_grid_attach (GTK_GRID (grid), line_width_spin, 1, 1, 1, 1);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Line cap:"), 0, 2, 1, 1);
|
||||
cap_combo = gtk_drop_down_new_from_strings ((const char *[]){"Butt", "Round", "Square", NULL});
|
||||
gtk_grid_attach (GTK_GRID (grid), cap_combo, 1, 2, 1, 1);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Line join:"), 0, 3, 1, 1);
|
||||
join_combo = gtk_drop_down_new_from_strings ((const char *[]){"Miter", "Miter-clip", "Round", "Bevel", "Arcs", NULL});
|
||||
gtk_grid_attach (GTK_GRID (grid), join_combo, 1, 3, 1, 1);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Miter limit:"), 0, 4, 1, 1);
|
||||
limit_spin = gtk_spin_button_new_with_range (0, 10, 1);
|
||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (limit_spin), 1);
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (limit_spin), 4);
|
||||
gtk_grid_attach (GTK_GRID (grid), limit_spin, 1, 4, 1, 1);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Dashes:"), 0, 5, 1, 1);
|
||||
dash_entry = gtk_entry_new ();
|
||||
gtk_grid_attach (GTK_GRID (grid), dash_entry, 1, 5, 1, 1);
|
||||
|
||||
stroke_toggle = gtk_check_button_new_with_label ("Show outline");
|
||||
gtk_grid_attach (GTK_GRID (grid), stroke_toggle, 1, 6, 1, 1);
|
||||
|
||||
titlebar = gtk_header_bar_new ();
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (titlebar), edit_toggle);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (titlebar), reset_button);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (titlebar), stroke_button);
|
||||
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), titlebar);
|
||||
|
||||
demo = curve_editor_new ();
|
||||
|
||||
g_signal_connect (stroke_toggle, "toggled", G_CALLBACK (stroke_toggled), demo);
|
||||
g_signal_connect (edit_toggle, "notify::active", G_CALLBACK (edit_changed), demo);
|
||||
g_signal_connect (reset_button, "clicked", G_CALLBACK (reset), demo);
|
||||
g_signal_connect (cap_combo, "notify::selected", G_CALLBACK (cap_changed), demo);
|
||||
g_signal_connect (join_combo, "notify::selected", G_CALLBACK (join_changed), demo);
|
||||
g_signal_connect (color_button, "notify::rgba", G_CALLBACK (color_changed), demo);
|
||||
g_signal_connect (line_width_spin, "value-changed", G_CALLBACK (line_width_changed), demo);
|
||||
g_signal_connect (limit_spin, "value-changed", G_CALLBACK (limit_changed), demo);
|
||||
g_signal_connect (dash_entry, "notify::text", G_CALLBACK (dashes_changed), demo);
|
||||
|
||||
reset (NULL, CURVE_EDITOR (demo));
|
||||
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (line_width_spin), 6);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (color_button), &(GdkRGBA) { 1, 0, 0, 1 });
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (cap_combo), GSK_LINE_CAP_ROUND);
|
||||
gtk_editable_set_text (GTK_EDITABLE (dash_entry), "0 8");
|
||||
|
||||
gtk_window_set_child (GTK_WINDOW (window), demo);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
||||
@@ -249,6 +249,10 @@
|
||||
<gresource prefix="/video-player">
|
||||
<file>bbb.png</file>
|
||||
</gresource>
|
||||
<gresource prefix="/curve">
|
||||
<file>curve-editor.c</file>
|
||||
<file>curve-editor.h</file>
|
||||
</gresource>
|
||||
<gresource prefix="/sources">
|
||||
<file>application_demo.c</file>
|
||||
<file>assistant.c</file>
|
||||
@@ -266,6 +270,7 @@
|
||||
<file>css_pixbufs.c</file>
|
||||
<file>css_shadows.c</file>
|
||||
<file>cursors.c</file>
|
||||
<file>curve.c</file>
|
||||
<file>dialog.c</file>
|
||||
<file>drawingarea.c</file>
|
||||
<file>dropdown.c</file>
|
||||
@@ -286,6 +291,7 @@
|
||||
<file>gears.c</file>
|
||||
<file>gestures.c</file>
|
||||
<file>glarea.c</file>
|
||||
<file>glyphs.c</file>
|
||||
<file>gltransition.c</file>
|
||||
<file>headerbar.c</file>
|
||||
<file>hypertext.c</file>
|
||||
@@ -324,6 +330,9 @@
|
||||
<file>paintable_symbolic.c</file>
|
||||
<file>panes.c</file>
|
||||
<file>password_entry.c</file>
|
||||
<file>path_fill.c</file>
|
||||
<file>path_maze.c</file>
|
||||
<file>path_text.c</file>
|
||||
<file>peg_solitaire.c</file>
|
||||
<file>pickers.c</file>
|
||||
<file>printing.c</file>
|
||||
@@ -408,6 +417,9 @@
|
||||
<gresource prefix="/fontrendering">
|
||||
<file>fontrendering.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/path_text">
|
||||
<file>path_text.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/org/gtk/Demo4">
|
||||
<file>icons/16x16/actions/application-exit.png</file>
|
||||
<file>icons/16x16/actions/document-new.png</file>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,8 @@
|
||||
* shows.
|
||||
*
|
||||
* We also demonstrate adding other things to a text view, such as
|
||||
* clickable icons.
|
||||
* clickable icons and widgets which can also replace a character
|
||||
* (try copying the ghost text).
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
@@ -94,13 +95,12 @@ show_page (GtkTextView *text_view,
|
||||
gtk_text_buffer_insert (buffer, &iter, " can easily be realized with ", -1);
|
||||
insert_link (buffer, &iter, "tags", 2);
|
||||
gtk_text_buffer_insert (buffer, &iter, ".\n", -1);
|
||||
gtk_text_buffer_insert (buffer, &iter,
|
||||
"Of course you can also embed Emoji 😋, "
|
||||
"icons ", -1);
|
||||
gtk_text_buffer_insert (buffer, &iter, "Of course you can also embed Emoji 😋, ", -1);
|
||||
gtk_text_buffer_insert (buffer, &iter, "icons ", -1);
|
||||
|
||||
theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (text_view)));
|
||||
icon = gtk_icon_theme_lookup_icon (theme,
|
||||
"microphone-sensitivity-high-symbolic",
|
||||
"eye-not-looking-symbolic",
|
||||
NULL,
|
||||
16,
|
||||
1,
|
||||
@@ -114,7 +114,12 @@ show_page (GtkTextView *text_view,
|
||||
gtk_level_bar_set_value (GTK_LEVEL_BAR (child), 50);
|
||||
gtk_widget_set_size_request (child, 100, -1);
|
||||
gtk_text_view_add_child_at_anchor (text_view, child, anchor);
|
||||
gtk_text_buffer_insert (buffer, &iter, ".", -1);
|
||||
gtk_text_buffer_insert (buffer, &iter, " and labels with ", -1);
|
||||
anchor = gtk_text_child_anchor_new_with_replacement ("👻");
|
||||
gtk_text_buffer_insert_child_anchor (buffer, &iter, anchor);
|
||||
child = gtk_label_new ("ghost");
|
||||
gtk_text_view_add_child_at_anchor (text_view, child, anchor);
|
||||
gtk_text_buffer_insert (buffer, &iter, " text.", -1);
|
||||
}
|
||||
else if (page == 2)
|
||||
{
|
||||
|
||||
@@ -192,7 +192,7 @@ activate_about (GSimpleAction *action,
|
||||
glib_micro_version);
|
||||
g_string_append_printf (s, "\tPango\t%s\n",
|
||||
pango_version_string ());
|
||||
g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
|
||||
g_string_append_printf (s, "\tGTK \t%d.%d.%d\n",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
|
||||
@@ -17,6 +17,7 @@ demos = files([
|
||||
'css_pixbufs.c',
|
||||
'css_shadows.c',
|
||||
'cursors.c',
|
||||
'curve.c',
|
||||
'dialog.c',
|
||||
'drawingarea.c',
|
||||
'dnd.c',
|
||||
@@ -34,6 +35,7 @@ demos = files([
|
||||
'gestures.c',
|
||||
'glarea.c',
|
||||
'gltransition.c',
|
||||
'glyphs.c',
|
||||
'headerbar.c',
|
||||
'hypertext.c',
|
||||
'iconscroll.c',
|
||||
@@ -70,6 +72,9 @@ demos = files([
|
||||
'paintable_symbolic.c',
|
||||
'panes.c',
|
||||
'password_entry.c',
|
||||
'path_fill.c',
|
||||
'path_maze.c',
|
||||
'path_text.c',
|
||||
'peg_solitaire.c',
|
||||
'pickers.c',
|
||||
'printing.c',
|
||||
@@ -128,6 +133,7 @@ extra_demo_sources = files([
|
||||
'script-names.c',
|
||||
'unicode-names.c',
|
||||
'suggestionentry.c',
|
||||
'curve-editor.c',
|
||||
])
|
||||
|
||||
if harfbuzz_dep.found() and pangoft_dep.found()
|
||||
@@ -140,7 +146,7 @@ if os_unix
|
||||
demos += files('pagesetup.c')
|
||||
endif
|
||||
|
||||
librsvg_dep = dependency('librsvg-2.0', version: '>= 2.46.0', required: false)
|
||||
librsvg_dep = dependency('librsvg-2.0', version: '>= 2.52.0', required: false)
|
||||
|
||||
if librsvg_dep.found()
|
||||
demos += files('paintable_svg.c')
|
||||
@@ -228,7 +234,9 @@ endif
|
||||
# Use a subset of compiler flags
|
||||
demo_cflags = []
|
||||
foreach flag: common_cflags
|
||||
if flag not in ['-Werror=missing-prototypes', '-Werror=missing-declarations', '-fvisibility=hidden']
|
||||
if flag not in ['-Werror=missing-prototypes', '-Wmissing-prototypes',
|
||||
'-Werror=missing-declarations', '-Wmissing-declarations',
|
||||
'-fvisibility=hidden']
|
||||
demo_cflags += flag
|
||||
endif
|
||||
endforeach
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
/* Path/Text Fill
|
||||
*
|
||||
* This demo shows how to use PangoCairo to draw text with more than
|
||||
* just a single color.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "paintable.h"
|
||||
#include "gsk/gskpathdashprivate.h"
|
||||
|
||||
#define GTK_TYPE_PATH_PAINTABLE (gtk_path_paintable_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GtkPathPaintable, gtk_path_paintable, GTK, PATH_PAINTABLE, GObject)
|
||||
|
||||
struct _GtkPathPaintable
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
GskPath *path;
|
||||
GdkPaintable *background;
|
||||
};
|
||||
|
||||
struct _GtkPathPaintableClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
static int
|
||||
gtk_path_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||
{
|
||||
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
|
||||
|
||||
if (self->background)
|
||||
return MAX (gdk_paintable_get_intrinsic_width (self->background), self->width);
|
||||
else
|
||||
return self->width;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_path_paintable_get_intrinsic_height (GdkPaintable *paintable)
|
||||
{
|
||||
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
|
||||
|
||||
if (self->background)
|
||||
return MAX (gdk_paintable_get_intrinsic_height (self->background), self->height);
|
||||
else
|
||||
return self->height;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_paintable_snapshot (GdkPaintable *paintable,
|
||||
GdkSnapshot *snapshot,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
|
||||
|
||||
#if 0
|
||||
gtk_snapshot_push_fill (snapshot, self->path, GSK_FILL_RULE_WINDING);
|
||||
#else
|
||||
GskStroke *stroke = gsk_stroke_new (2.0);
|
||||
gtk_snapshot_push_stroke (snapshot, self->path, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
#endif
|
||||
|
||||
if (self->background)
|
||||
{
|
||||
gdk_paintable_snapshot (self->background, snapshot, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_snapshot_append_linear_gradient (snapshot,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height),
|
||||
&GRAPHENE_POINT_INIT (0, 0),
|
||||
&GRAPHENE_POINT_INIT (width, height),
|
||||
(GskColorStop[8]) {
|
||||
{ 0.0, { 1.0, 0.0, 0.0, 1.0 } },
|
||||
{ 0.2, { 1.0, 0.0, 0.0, 1.0 } },
|
||||
{ 0.3, { 1.0, 1.0, 0.0, 1.0 } },
|
||||
{ 0.4, { 0.0, 1.0, 0.0, 1.0 } },
|
||||
{ 0.6, { 0.0, 1.0, 1.0, 1.0 } },
|
||||
{ 0.7, { 0.0, 0.0, 1.0, 1.0 } },
|
||||
{ 0.8, { 1.0, 0.0, 1.0, 1.0 } },
|
||||
{ 1.0, { 1.0, 0.0, 1.0, 1.0 } }
|
||||
},
|
||||
8);
|
||||
}
|
||||
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
}
|
||||
|
||||
static GdkPaintableFlags
|
||||
gtk_path_paintable_get_flags (GdkPaintable *paintable)
|
||||
{
|
||||
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
|
||||
|
||||
if (self->background)
|
||||
return gdk_paintable_get_flags (self->background);
|
||||
else
|
||||
return GDK_PAINTABLE_STATIC_CONTENTS | GDK_PAINTABLE_STATIC_SIZE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_paintable_paintable_init (GdkPaintableInterface *iface)
|
||||
{
|
||||
iface->get_intrinsic_width = gtk_path_paintable_get_intrinsic_width;
|
||||
iface->get_intrinsic_height = gtk_path_paintable_get_intrinsic_height;
|
||||
iface->snapshot = gtk_path_paintable_snapshot;
|
||||
iface->get_flags = gtk_path_paintable_get_flags;
|
||||
}
|
||||
|
||||
/* When defining the GType, we need to implement the GdkPaintable interface */
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkPathPaintable, gtk_path_paintable, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
|
||||
gtk_path_paintable_paintable_init))
|
||||
|
||||
/* Here's the boilerplate for the GObject declaration.
|
||||
* We don't need to do anything special here, because we keep no
|
||||
* data of our own.
|
||||
*/
|
||||
static void
|
||||
gtk_path_paintable_class_init (GtkPathPaintableClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_paintable_init (GtkPathPaintable *self)
|
||||
{
|
||||
}
|
||||
|
||||
/* And finally, we add a simple constructor.
|
||||
* It is declared in the header so that the other examples
|
||||
* can use it.
|
||||
*/
|
||||
GdkPaintable *
|
||||
gtk_path_paintable_new (GskPath *path,
|
||||
GdkPaintable *background,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
GtkPathPaintable *self;
|
||||
|
||||
self = g_object_new (GTK_TYPE_PATH_PAINTABLE, NULL);
|
||||
self->path = path;
|
||||
self->background = background;
|
||||
if (self->background)
|
||||
{
|
||||
g_signal_connect_swapped (self->background, "invalidate-contents", G_CALLBACK (gdk_paintable_invalidate_contents), self);
|
||||
g_signal_connect_swapped (self->background, "invalidate-size", G_CALLBACK (gdk_paintable_invalidate_size), self);
|
||||
}
|
||||
self->width = width;
|
||||
self->height = height;
|
||||
|
||||
return GDK_PAINTABLE (self);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_path_paintable_set_path (GtkPathPaintable *self,
|
||||
GskPath *path)
|
||||
{
|
||||
g_clear_pointer (&self->path, gsk_path_unref);
|
||||
self->path = gsk_path_ref (path);
|
||||
|
||||
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
|
||||
}
|
||||
|
||||
static GskPath *
|
||||
create_hexagon (GtkWidget *widget)
|
||||
{
|
||||
GskPathBuilder *builder;
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
|
||||
gsk_path_builder_move_to (builder, 120, 0);
|
||||
gsk_path_builder_line_to (builder, 360, 0);
|
||||
gsk_path_builder_line_to (builder, 480, 208);
|
||||
gsk_path_builder_line_to (builder, 360, 416);
|
||||
gsk_path_builder_line_to (builder, 120, 416);
|
||||
gsk_path_builder_line_to (builder, 0, 208);
|
||||
gsk_path_builder_close (builder);
|
||||
|
||||
return gsk_path_builder_free_to_path (builder);
|
||||
}
|
||||
|
||||
static GskPath *
|
||||
create_path_from_text (GtkWidget *widget)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
PangoFontDescription *desc;
|
||||
GskPathBuilder *builder;
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, "Pango power!\nPango power!\nPango power!");
|
||||
desc = pango_font_description_from_string ("sans bold 36");
|
||||
pango_layout_set_font_description (layout, desc);
|
||||
pango_font_description_free (desc);
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
|
||||
gsk_path_builder_add_layout (builder, layout);
|
||||
|
||||
return gsk_path_builder_free_to_path (builder);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
build_path (GskPathOperation op,
|
||||
const graphene_point_t *pts,
|
||||
gsize n_pts,
|
||||
float weight,
|
||||
gpointer user_data)
|
||||
{
|
||||
GskPathBuilder *builder = user_data;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case GSK_PATH_MOVE:
|
||||
gsk_path_builder_move_to (builder, pts[0].x, pts[0].y);
|
||||
break;
|
||||
|
||||
case GSK_PATH_CLOSE:
|
||||
gsk_path_builder_close (builder);
|
||||
break;
|
||||
|
||||
case GSK_PATH_LINE:
|
||||
gsk_path_builder_line_to (builder, pts[1].x, pts[1].y);
|
||||
break;
|
||||
|
||||
case GSK_PATH_CURVE:
|
||||
gsk_path_builder_curve_to (builder, pts[1].x, pts[1].y, pts[2].x, pts[2].y, pts[3].x, pts[3].y);
|
||||
break;
|
||||
|
||||
case GSK_PATH_CONIC:
|
||||
gsk_path_builder_conic_to (builder, pts[1].x, pts[1].y, pts[2].x, pts[2].y, weight);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
update_path (GtkWidget *widget,
|
||||
GdkFrameClock *frame_clock,
|
||||
gpointer measure)
|
||||
{
|
||||
float progress = gdk_frame_clock_get_frame_time (frame_clock) % (60 * G_USEC_PER_SEC) / (float) (30 * G_USEC_PER_SEC);
|
||||
GskPathBuilder *builder;
|
||||
GskPath *path;
|
||||
graphene_point_t pos;
|
||||
graphene_vec2_t tangent;
|
||||
GskStroke *stroke;
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
gsk_path_builder_add_segment (builder,
|
||||
measure,
|
||||
#if 1
|
||||
0.0, gsk_path_measure_get_length (measure));
|
||||
#else
|
||||
progress > 1 ? (progress - 1) * gsk_path_measure_get_length (measure) : 0.0,
|
||||
(progress < 1 ? progress : 1.0) * gsk_path_measure_get_length (measure));
|
||||
#endif
|
||||
|
||||
path = gsk_path_builder_free_to_path (builder);
|
||||
|
||||
stroke = gsk_stroke_new (1);
|
||||
gsk_stroke_set_dash (stroke, (float[2]) { 10, 5 }, 2);
|
||||
gsk_stroke_set_dash_offset (stroke, - (gdk_frame_clock_get_frame_time (frame_clock) % G_USEC_PER_SEC) * 15. / G_USEC_PER_SEC);
|
||||
builder = gsk_path_builder_new ();
|
||||
gsk_path_dash (path, stroke, 0.2, build_path, builder);
|
||||
gsk_path_unref (path);
|
||||
|
||||
gsk_path_measure_get_point (measure,
|
||||
(progress > 1 ? (progress - 1) : progress) * gsk_path_measure_get_length (measure),
|
||||
&pos,
|
||||
&tangent);
|
||||
gsk_path_builder_move_to (builder, pos.x + 5 * graphene_vec2_get_x (&tangent), pos.y + 5 * graphene_vec2_get_y (&tangent));
|
||||
gsk_path_builder_line_to (builder, pos.x + 3 * graphene_vec2_get_y (&tangent), pos.y + 3 * graphene_vec2_get_x (&tangent));
|
||||
gsk_path_builder_line_to (builder, pos.x - 3 * graphene_vec2_get_y (&tangent), pos.y - 3 * graphene_vec2_get_x (&tangent));
|
||||
gsk_path_builder_close (builder);
|
||||
|
||||
path = gsk_path_builder_free_to_path (builder);
|
||||
|
||||
gtk_path_paintable_set_path (GTK_PATH_PAINTABLE (gtk_picture_get_paintable (GTK_PICTURE (widget))),
|
||||
path);
|
||||
gsk_path_unref (path);
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_path_fill (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *picture;
|
||||
GdkPaintable *paintable;
|
||||
GtkMediaStream *stream;
|
||||
GskPath *path;
|
||||
graphene_rect_t bounds;
|
||||
GskPathMeasure *measure;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Path Fill");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
#if 0
|
||||
stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
|
||||
#else
|
||||
stream = gtk_nuclear_media_stream_new ();
|
||||
#endif
|
||||
gtk_media_stream_play (stream);
|
||||
gtk_media_stream_set_loop (stream, TRUE);
|
||||
|
||||
path = create_hexagon (window);
|
||||
path = create_path_from_text (window);
|
||||
gsk_path_get_bounds (path, &bounds);
|
||||
|
||||
paintable = gtk_path_paintable_new (path,
|
||||
GDK_PAINTABLE (stream),
|
||||
bounds.origin.x + bounds.size.width,
|
||||
bounds.origin.y + bounds.size.height);
|
||||
picture = gtk_picture_new_for_paintable (paintable);
|
||||
measure = gsk_path_measure_new (path);
|
||||
gtk_widget_add_tick_callback (picture, update_path, measure, (GDestroyNotify) gsk_path_measure_unref);
|
||||
gtk_picture_set_keep_aspect_ratio (GTK_PICTURE (picture), FALSE);
|
||||
gtk_picture_set_can_shrink (GTK_PICTURE (picture), FALSE);
|
||||
g_object_unref (paintable);
|
||||
|
||||
gtk_window_set_child (GTK_WINDOW (window), picture);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
/* Path/Maze
|
||||
* #Keywords: game, mouse
|
||||
*
|
||||
* This demo shows how to use a GskPath to create a maze and use
|
||||
* gsk_path_measure_get_closest_point() to check the mouse stays
|
||||
* on the path.
|
||||
*
|
||||
* It also shows off the performance of GskPath (or not) as this
|
||||
* is a rather complex path.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "paintable.h"
|
||||
|
||||
#define MAZE_GRID_SIZE 20
|
||||
#define MAZE_STROKE_SIZE_ACTIVE (MAZE_GRID_SIZE - 4)
|
||||
#define MAZE_STROKE_SIZE_INACTIVE (MAZE_GRID_SIZE - 12)
|
||||
#define MAZE_WIDTH 31
|
||||
#define MAZE_HEIGHT 21
|
||||
|
||||
#define GTK_TYPE_MAZE (gtk_maze_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GtkMaze, gtk_maze, GTK, MAZE, GtkWidget)
|
||||
|
||||
struct _GtkMaze
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
GskPath *path;
|
||||
GskPathMeasure *measure;
|
||||
GdkPaintable *background;
|
||||
|
||||
gboolean active;
|
||||
};
|
||||
|
||||
struct _GtkMazeClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkMaze, gtk_maze, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
gtk_maze_measure (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
int for_size,
|
||||
int *minimum,
|
||||
int *natural,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline)
|
||||
{
|
||||
GtkMaze *self = GTK_MAZE (widget);
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
*minimum = *natural = self->width;
|
||||
else
|
||||
*minimum = *natural = self->height;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_maze_snapshot (GtkWidget *widget,
|
||||
GdkSnapshot *snapshot)
|
||||
{
|
||||
GtkMaze *self = GTK_MAZE (widget);
|
||||
double width = gtk_widget_get_width (widget);
|
||||
double height = gtk_widget_get_height (widget);
|
||||
GskStroke *stroke;
|
||||
|
||||
stroke = gsk_stroke_new (MAZE_STROKE_SIZE_INACTIVE);
|
||||
if (self->active)
|
||||
gsk_stroke_set_line_width (stroke, MAZE_STROKE_SIZE_ACTIVE);
|
||||
gsk_stroke_set_line_join (stroke, GSK_LINE_JOIN_ROUND);
|
||||
gsk_stroke_set_line_cap (stroke, GSK_LINE_CAP_ROUND);
|
||||
gtk_snapshot_push_stroke (snapshot, self->path, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
|
||||
if (self->background)
|
||||
{
|
||||
gdk_paintable_snapshot (self->background, snapshot, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_snapshot_append_linear_gradient (snapshot,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height),
|
||||
&GRAPHENE_POINT_INIT (0, 0),
|
||||
&GRAPHENE_POINT_INIT (width, height),
|
||||
(GskColorStop[8]) {
|
||||
{ 0.0, { 1.0, 0.0, 0.0, 1.0 } },
|
||||
{ 0.2, { 1.0, 0.0, 0.0, 1.0 } },
|
||||
{ 0.3, { 1.0, 1.0, 0.0, 1.0 } },
|
||||
{ 0.4, { 0.0, 1.0, 0.0, 1.0 } },
|
||||
{ 0.6, { 0.0, 1.0, 1.0, 1.0 } },
|
||||
{ 0.7, { 0.0, 0.0, 1.0, 1.0 } },
|
||||
{ 0.8, { 1.0, 0.0, 1.0, 1.0 } },
|
||||
{ 1.0, { 1.0, 0.0, 1.0, 1.0 } }
|
||||
},
|
||||
8);
|
||||
}
|
||||
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_maze_dispose (GObject *object)
|
||||
{
|
||||
GtkMaze *self = GTK_MAZE (object);
|
||||
|
||||
g_clear_pointer (&self->path, gsk_path_unref);
|
||||
g_clear_pointer (&self->measure, gsk_path_measure_unref);
|
||||
if (self->background)
|
||||
{
|
||||
g_signal_handlers_disconnect_matched (self->background, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, self);
|
||||
g_clear_object (&self->background);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gtk_maze_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_maze_class_init (GtkMazeClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = gtk_maze_dispose;
|
||||
|
||||
widget_class->measure = gtk_maze_measure;
|
||||
widget_class->snapshot = gtk_maze_snapshot;
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_motion (GtkEventControllerMotion *controller,
|
||||
double x,
|
||||
double y,
|
||||
GtkMaze *self)
|
||||
{
|
||||
if (!self->active)
|
||||
return;
|
||||
|
||||
if (gsk_path_measure_get_closest_point (self->measure, &GRAPHENE_POINT_INIT (x, y), NULL) <= MAZE_STROKE_SIZE_ACTIVE / 2.0f)
|
||||
return;
|
||||
|
||||
self->active = FALSE;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_leave (GtkEventControllerMotion *controller,
|
||||
GtkMaze *self)
|
||||
{
|
||||
if (!self->active)
|
||||
{
|
||||
self->active = TRUE;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_maze_init (GtkMaze *self)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
|
||||
controller = GTK_EVENT_CONTROLLER (gtk_event_controller_motion_new ());
|
||||
g_signal_connect (controller, "motion", G_CALLBACK (pointer_motion), self);
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (pointer_leave), self);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||
|
||||
self->active = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_maze_set_path (GtkMaze *self,
|
||||
GskPath *path)
|
||||
{
|
||||
g_clear_pointer (&self->path, gsk_path_unref);
|
||||
g_clear_pointer (&self->measure, gsk_path_measure_unref);
|
||||
self->path = gsk_path_ref (path);
|
||||
self->measure = gsk_path_measure_new (path);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_maze_new (GskPath *path,
|
||||
GdkPaintable *background,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
GtkMaze *self;
|
||||
|
||||
self = g_object_new (GTK_TYPE_MAZE, NULL);
|
||||
|
||||
gtk_maze_set_path (self, path);
|
||||
gsk_path_unref (path);
|
||||
self->background = background;
|
||||
if (self->background)
|
||||
{
|
||||
g_signal_connect_swapped (self->background, "invalidate-contents", G_CALLBACK (gtk_widget_queue_draw), self);
|
||||
g_signal_connect_swapped (self->background, "invalidate-size", G_CALLBACK (gtk_widget_queue_resize), self);
|
||||
}
|
||||
self->width = width;
|
||||
self->height = height;
|
||||
|
||||
return GTK_WIDGET (self);
|
||||
}
|
||||
|
||||
static void
|
||||
add_point_to_maze (GtkBitset *maze,
|
||||
GskPathBuilder *builder,
|
||||
guint x,
|
||||
guint y)
|
||||
{
|
||||
gboolean set[4] = { };
|
||||
guint dir;
|
||||
|
||||
gtk_bitset_add (maze, y * MAZE_WIDTH + x);
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
set[0] = set[0] || x == 0 || gtk_bitset_contains (maze, y * MAZE_WIDTH + x - 1);
|
||||
set[1] = set[1] || y == 0 || gtk_bitset_contains (maze, (y - 1) * MAZE_WIDTH + x);
|
||||
set[2] = set[2] || x + 1 == MAZE_WIDTH || gtk_bitset_contains (maze, y * MAZE_WIDTH + x + 1);
|
||||
set[3] = set[3] || y + 1 == MAZE_HEIGHT || gtk_bitset_contains (maze, (y + 1) * MAZE_WIDTH + x);
|
||||
|
||||
if (set[0] && set[1] && set[2] && set[3])
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
dir = g_random_int_range (0, 4);
|
||||
}
|
||||
while (set[dir]);
|
||||
|
||||
switch (dir)
|
||||
{
|
||||
case 0:
|
||||
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_line_to (builder, (x - 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||
add_point_to_maze (maze, builder, x - 1, y);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_line_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y - 0.5) * MAZE_GRID_SIZE);
|
||||
add_point_to_maze (maze, builder, x, y - 1);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_line_to (builder, (x + 1.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||
add_point_to_maze (maze, builder, x + 1, y);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_line_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 1.5) * MAZE_GRID_SIZE);
|
||||
add_point_to_maze (maze, builder, x, y + 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GskPath *
|
||||
create_path_for_maze (GtkWidget *widget)
|
||||
{
|
||||
GskPathBuilder *builder;
|
||||
GtkBitset *maze;
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
maze = gtk_bitset_new_empty ();
|
||||
/* make sure the outer lines are unreachable:
|
||||
* Set the full range, then remove the center again. */
|
||||
gtk_bitset_add_range (maze, 0, MAZE_WIDTH * MAZE_HEIGHT);
|
||||
gtk_bitset_remove_rectangle (maze, MAZE_WIDTH + 1, MAZE_WIDTH - 2, MAZE_HEIGHT - 2, MAZE_WIDTH);
|
||||
|
||||
/* Fill the maze */
|
||||
add_point_to_maze (maze, builder, MAZE_WIDTH / 2, MAZE_HEIGHT / 2);
|
||||
|
||||
/* Add start and stop lines */
|
||||
gsk_path_builder_move_to (builder, 1.5 * MAZE_GRID_SIZE, -0.5 * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_line_to (builder, 1.5 * MAZE_GRID_SIZE, 1.5 * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_move_to (builder, (MAZE_WIDTH - 1.5) * MAZE_GRID_SIZE, (MAZE_HEIGHT - 1.5) * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_line_to (builder, (MAZE_WIDTH - 1.5) * MAZE_GRID_SIZE, (MAZE_HEIGHT + 0.5) * MAZE_GRID_SIZE);
|
||||
|
||||
|
||||
gtk_bitset_unref (maze);
|
||||
|
||||
return gsk_path_builder_free_to_path (builder);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_path_maze (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *maze;
|
||||
GtkMediaStream *stream;
|
||||
GskPath *path;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Follow the maze with the mouse");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
#if 0
|
||||
stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
|
||||
#else
|
||||
stream = gtk_nuclear_media_stream_new ();
|
||||
#endif
|
||||
gtk_media_stream_play (stream);
|
||||
gtk_media_stream_set_loop (stream, TRUE);
|
||||
|
||||
path = create_path_for_maze (window);
|
||||
|
||||
maze = gtk_maze_new (path,
|
||||
GDK_PAINTABLE (stream),
|
||||
MAZE_WIDTH * MAZE_GRID_SIZE,
|
||||
MAZE_HEIGHT * MAZE_GRID_SIZE);
|
||||
|
||||
gtk_window_set_child (GTK_WINDOW (window), maze);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
||||
@@ -0,0 +1,594 @@
|
||||
/* Path/Curved Text
|
||||
*
|
||||
* This demo shows how to use GskPath to animate a path along another path.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define GTK_TYPE_PATH_WIDGET (gtk_path_widget_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GtkPathWidget, gtk_path_widget, GTK, PATH_WIDGET, GtkWidget)
|
||||
|
||||
#define POINT_SIZE 8
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_TEXT,
|
||||
PROP_EDITABLE,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
struct _GtkPathWidget
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
char *text;
|
||||
gboolean editable;
|
||||
|
||||
graphene_point_t points[4];
|
||||
|
||||
guint active_point;
|
||||
float line_closest;
|
||||
|
||||
GskPath *line_path;
|
||||
GskPathMeasure *line_measure;
|
||||
GskPath *text_path;
|
||||
|
||||
GdkPaintable *background;
|
||||
};
|
||||
|
||||
struct _GtkPathWidgetClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
G_DEFINE_TYPE (GtkPathWidget, gtk_path_widget, GTK_TYPE_WIDGET)
|
||||
|
||||
static GskPath *
|
||||
create_path_from_text (GtkWidget *widget,
|
||||
const char *text)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
cairo_path_t *path;
|
||||
PangoLayout *layout;
|
||||
PangoFontDescription *desc;
|
||||
GskPath *result;
|
||||
|
||||
surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, NULL);
|
||||
cr = cairo_create (surface);
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, text);
|
||||
desc = pango_font_description_from_string ("sans bold 36");
|
||||
pango_layout_set_font_description (layout, desc);
|
||||
pango_font_description_free (desc);
|
||||
|
||||
cairo_move_to (cr, 0, - pango_layout_get_baseline (layout) / (double) PANGO_SCALE);
|
||||
pango_cairo_layout_path (cr, layout);
|
||||
path = cairo_copy_path_flat (cr);
|
||||
result = gsk_path_new_from_cairo (path);
|
||||
|
||||
cairo_path_destroy (path);
|
||||
g_object_unref (layout);
|
||||
cairo_destroy (cr);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GskPathMeasure *measure;
|
||||
GskPathBuilder *builder;
|
||||
double scale;
|
||||
} GtkPathTransform;
|
||||
|
||||
static void
|
||||
gtk_path_transform_point (GskPathMeasure *measure,
|
||||
const graphene_point_t *pt,
|
||||
float scale,
|
||||
graphene_point_t *res)
|
||||
{
|
||||
graphene_vec2_t tangent;
|
||||
|
||||
gsk_path_measure_get_point (measure, pt->x * scale, res, &tangent);
|
||||
|
||||
res->x -= pt->y * scale * graphene_vec2_get_y (&tangent);
|
||||
res->y += pt->y * scale * graphene_vec2_get_x (&tangent);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_path_transform_op (GskPathOperation op,
|
||||
const graphene_point_t *pts,
|
||||
gsize n_pts,
|
||||
float weight,
|
||||
gpointer data)
|
||||
{
|
||||
GtkPathTransform *transform = data;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case GSK_PATH_MOVE:
|
||||
{
|
||||
graphene_point_t res;
|
||||
gtk_path_transform_point (transform->measure, &pts[0], transform->scale, &res);
|
||||
gsk_path_builder_move_to (transform->builder, res.x, res.y);
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_PATH_LINE:
|
||||
{
|
||||
graphene_point_t res;
|
||||
gtk_path_transform_point (transform->measure, &pts[1], transform->scale, &res);
|
||||
gsk_path_builder_line_to (transform->builder, res.x, res.y);
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_PATH_CURVE:
|
||||
{
|
||||
graphene_point_t res[3];
|
||||
gtk_path_transform_point (transform->measure, &pts[1], transform->scale, &res[0]);
|
||||
gtk_path_transform_point (transform->measure, &pts[2], transform->scale, &res[1]);
|
||||
gtk_path_transform_point (transform->measure, &pts[3], transform->scale, &res[2]);
|
||||
gsk_path_builder_curve_to (transform->builder, res[0].x, res[0].y, res[1].x, res[1].y, res[2].x, res[2].y);
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_PATH_CONIC:
|
||||
{
|
||||
graphene_point_t res[2];
|
||||
gtk_path_transform_point (transform->measure, &pts[1], transform->scale, &res[0]);
|
||||
gtk_path_transform_point (transform->measure, &pts[2], transform->scale, &res[1]);
|
||||
gsk_path_builder_conic_to (transform->builder, res[0].x, res[0].y, res[1].x, res[1].y, weight);
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_PATH_CLOSE:
|
||||
gsk_path_builder_close (transform->builder);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GskPath *
|
||||
gtk_path_transform (GskPathMeasure *measure,
|
||||
GskPath *path)
|
||||
{
|
||||
GtkPathTransform transform = { measure, gsk_path_builder_new () };
|
||||
graphene_rect_t bounds;
|
||||
|
||||
gsk_path_get_bounds (path, &bounds);
|
||||
if (bounds.origin.x + bounds.size.width > 0)
|
||||
transform.scale = gsk_path_measure_get_length (measure) / (bounds.origin.x + bounds.size.width);
|
||||
else
|
||||
transform.scale = 1.0f;
|
||||
|
||||
gsk_path_foreach (path, GSK_PATH_FOREACH_ALLOW_CURVE, gtk_path_transform_op, &transform);
|
||||
|
||||
return gsk_path_builder_free_to_path (transform.builder);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_clear_text_path (GtkPathWidget *self)
|
||||
{
|
||||
g_clear_pointer (&self->text_path, gsk_path_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_clear_paths (GtkPathWidget *self)
|
||||
{
|
||||
gtk_path_widget_clear_text_path (self);
|
||||
|
||||
g_clear_pointer (&self->line_path, gsk_path_unref);
|
||||
g_clear_pointer (&self->line_measure, gsk_path_measure_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_create_text_path (GtkPathWidget *self)
|
||||
{
|
||||
GskPath *path;
|
||||
|
||||
gtk_path_widget_clear_text_path (self);
|
||||
|
||||
if (self->line_measure == NULL)
|
||||
return;
|
||||
|
||||
path = create_path_from_text (GTK_WIDGET (self), self->text);
|
||||
self->text_path = gtk_path_transform (self->line_measure, path);
|
||||
|
||||
gsk_path_unref (path);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_create_paths (GtkPathWidget *self)
|
||||
{
|
||||
double width = gtk_widget_get_width (GTK_WIDGET (self));
|
||||
double height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||
GskPathBuilder *builder;
|
||||
|
||||
gtk_path_widget_clear_paths (self);
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
gsk_path_builder_move_to (builder,
|
||||
self->points[0].x * width, self->points[0].y * height);
|
||||
gsk_path_builder_curve_to (builder,
|
||||
self->points[1].x * width, self->points[1].y * height,
|
||||
self->points[2].x * width, self->points[2].y * height,
|
||||
self->points[3].x * width, self->points[3].y * height);
|
||||
self->line_path = gsk_path_builder_free_to_path (builder);
|
||||
|
||||
self->line_measure = gsk_path_measure_new (self->line_path);
|
||||
|
||||
gtk_path_widget_create_text_path (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline)
|
||||
{
|
||||
GtkPathWidget *self = GTK_PATH_WIDGET (widget);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_path_widget_parent_class)->size_allocate (widget, width, height, baseline);
|
||||
|
||||
gtk_path_widget_create_paths (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkPathWidget *self = GTK_PATH_WIDGET (widget);
|
||||
double width = gtk_widget_get_width (widget);
|
||||
double height = gtk_widget_get_height (widget);
|
||||
GskPath *path;
|
||||
GskStroke *stroke;
|
||||
gsize i;
|
||||
|
||||
/* frosted glass the background */
|
||||
gtk_snapshot_push_blur (snapshot, 100);
|
||||
gdk_paintable_snapshot (self->background, snapshot, width, height);
|
||||
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 1, 1, 1, 0.5 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
/* draw the text */
|
||||
if (self->text_path)
|
||||
{
|
||||
gtk_snapshot_push_fill (snapshot, self->text_path, GSK_FILL_RULE_WINDING);
|
||||
gdk_paintable_snapshot (self->background, snapshot, width, height);
|
||||
|
||||
/* ... with an emboss effect */
|
||||
stroke = gsk_stroke_new (2.0);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT(1, 1));
|
||||
gtk_snapshot_push_stroke (snapshot, self->text_path, stroke);
|
||||
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 0.2 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gsk_stroke_free (stroke);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
|
||||
if (self->editable && self->line_path)
|
||||
{
|
||||
/* draw the control line */
|
||||
stroke = gsk_stroke_new (1.0);
|
||||
gtk_snapshot_push_stroke (snapshot, self->line_path, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
|
||||
if (self->line_closest >= 0)
|
||||
{
|
||||
GskPathBuilder *builder;
|
||||
graphene_point_t closest;
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
gsk_path_measure_get_point (self->line_measure, self->line_closest, &closest, NULL);
|
||||
gsk_path_builder_add_circle (builder, &closest, POINT_SIZE);
|
||||
path = gsk_path_builder_free_to_path (builder);
|
||||
|
||||
gtk_snapshot_push_fill (snapshot, path, GSK_FILL_RULE_WINDING);
|
||||
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 1, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
gsk_path_unref (path);
|
||||
}
|
||||
|
||||
if (self->editable && self->line_path)
|
||||
{
|
||||
GskPathBuilder *builder;
|
||||
|
||||
/* draw the points */
|
||||
builder = gsk_path_builder_new ();
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
gsk_path_builder_add_circle (builder, &GRAPHENE_POINT_INIT (self->points[i].x * width, self->points[i].y * height), POINT_SIZE);
|
||||
}
|
||||
path = gsk_path_builder_free_to_path (builder);
|
||||
|
||||
gtk_snapshot_push_fill (snapshot, path, GSK_FILL_RULE_WINDING);
|
||||
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 1, 1, 1, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
stroke = gsk_stroke_new (1.0);
|
||||
gtk_snapshot_push_stroke (snapshot, path, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
gsk_path_unref (path);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_set_text (GtkPathWidget *self,
|
||||
const char *text)
|
||||
{
|
||||
if (g_strcmp0 (self->text, text) == 0)
|
||||
return;
|
||||
|
||||
g_free (self->text);
|
||||
self->text = g_strdup (text);
|
||||
|
||||
gtk_path_widget_create_paths (self);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TEXT]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_set_editable (GtkPathWidget *self,
|
||||
gboolean editable)
|
||||
{
|
||||
if (self->editable == editable)
|
||||
return;
|
||||
|
||||
self->editable = editable;
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_EDITABLE]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
|
||||
{
|
||||
GtkPathWidget *self = GTK_PATH_WIDGET (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TEXT:
|
||||
gtk_path_widget_set_text (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_EDITABLE:
|
||||
gtk_path_widget_set_editable (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkPathWidget *self = GTK_PATH_WIDGET (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TEXT:
|
||||
g_value_set_string (value, self->text);
|
||||
break;
|
||||
|
||||
case PROP_EDITABLE:
|
||||
g_value_set_boolean (value, self->editable);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_dispose (GObject *object)
|
||||
{
|
||||
GtkPathWidget *self = GTK_PATH_WIDGET (object);
|
||||
|
||||
gtk_path_widget_clear_paths (self);
|
||||
|
||||
G_OBJECT_CLASS (gtk_path_widget_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_class_init (GtkPathWidgetClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = gtk_path_widget_dispose;
|
||||
object_class->set_property = gtk_path_widget_set_property;
|
||||
object_class->get_property = gtk_path_widget_get_property;
|
||||
|
||||
widget_class->size_allocate = gtk_path_widget_allocate;
|
||||
widget_class->snapshot = gtk_path_widget_snapshot;
|
||||
|
||||
properties[PROP_TEXT] =
|
||||
g_param_spec_string ("text",
|
||||
"text",
|
||||
"Text transformed along a path",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
properties[PROP_EDITABLE] =
|
||||
g_param_spec_boolean ("editable",
|
||||
"editable",
|
||||
"If the path can be edited by the user",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
drag_begin (GtkGestureDrag *gesture,
|
||||
double x,
|
||||
double y,
|
||||
GtkPathWidget *self)
|
||||
{
|
||||
graphene_point_t mouse = GRAPHENE_POINT_INIT (x, y);
|
||||
double width = gtk_widget_get_width (GTK_WIDGET (self));
|
||||
double height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||
gsize i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (graphene_point_distance (&GRAPHENE_POINT_INIT (self->points[i].x * width, self->points[i].y * height), &mouse, NULL, NULL) <= POINT_SIZE)
|
||||
{
|
||||
self->active_point = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 4)
|
||||
{
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
drag_update (GtkGestureDrag *drag,
|
||||
double offset_x,
|
||||
double offset_y,
|
||||
GtkPathWidget *self)
|
||||
{
|
||||
double width = gtk_widget_get_width (GTK_WIDGET (self));
|
||||
double height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||
double start_x, start_y;
|
||||
|
||||
gtk_gesture_drag_get_start_point (drag, &start_x, &start_y);
|
||||
|
||||
self->points[self->active_point] = GRAPHENE_POINT_INIT ((start_x + offset_x) / width,
|
||||
(start_y + offset_y) / height);
|
||||
self->points[self->active_point].x = CLAMP (self->points[self->active_point].x, 0, 1);
|
||||
self->points[self->active_point].y = CLAMP (self->points[self->active_point].y, 0, 1);
|
||||
|
||||
gtk_path_widget_create_paths (self);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_motion (GtkEventControllerMotion *controller,
|
||||
double x,
|
||||
double y,
|
||||
GtkPathWidget *self)
|
||||
{
|
||||
gsk_path_measure_get_closest_point_full (self->line_measure,
|
||||
&GRAPHENE_POINT_INIT (x, y),
|
||||
INFINITY,
|
||||
NULL, NULL,
|
||||
&self->line_closest,
|
||||
NULL);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_leave (GtkEventControllerMotion *controller,
|
||||
GtkPathWidget *self)
|
||||
{
|
||||
self->line_closest = -1;
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_init (GtkPathWidget *self)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
|
||||
controller = GTK_EVENT_CONTROLLER (gtk_gesture_drag_new ());
|
||||
g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self);
|
||||
g_signal_connect (controller, "drag-update", G_CALLBACK (drag_update), self);
|
||||
g_signal_connect (controller, "drag-end", G_CALLBACK (drag_update), self);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||
|
||||
controller = GTK_EVENT_CONTROLLER (gtk_event_controller_motion_new ());
|
||||
g_signal_connect (controller, "enter", G_CALLBACK (pointer_motion), self);
|
||||
g_signal_connect (controller, "motion", G_CALLBACK (pointer_motion), self);
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (pointer_leave), self);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||
|
||||
self->line_closest = -1;
|
||||
|
||||
self->points[0] = GRAPHENE_POINT_INIT (0.1, 0.9);
|
||||
self->points[1] = GRAPHENE_POINT_INIT (0.3, 0.1);
|
||||
self->points[2] = GRAPHENE_POINT_INIT (0.7, 0.1);
|
||||
self->points[3] = GRAPHENE_POINT_INIT (0.9, 0.9);
|
||||
|
||||
self->background = GDK_PAINTABLE (gdk_texture_new_from_resource ("/sliding_puzzle/portland-rose.jpg"));
|
||||
|
||||
gtk_path_widget_set_text (self, "It's almost working");
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_path_widget_new (void)
|
||||
{
|
||||
GtkPathWidget *self;
|
||||
|
||||
self = g_object_new (GTK_TYPE_PATH_WIDGET, NULL);
|
||||
|
||||
return GTK_WIDGET (self);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_path_text (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
|
||||
g_type_ensure (GTK_TYPE_PATH_WIDGET);
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/path_text/path_text.ui");
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="title" translatable="yes">Text along a Path</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<child type="end">
|
||||
<object class="GtkToggleButton" id="edit-toggle">
|
||||
<property name="icon-name">document-edit-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkRevealer">
|
||||
<property name="reveal-child" bind-source="edit-toggle" bind-property="active" bind-flags="sync-create"></property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="text">
|
||||
<property name="text">Through the looking glass</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkPathWidget" id="view">
|
||||
<property name="editable" bind-source="edit-toggle" bind-property="active" bind-flags="sync-create"></property>
|
||||
<property name="text" bind-source="text" bind-property="text" bind-flags="sync-create"></property>
|
||||
<property name="hexpand">true</property>
|
||||
<property name="vexpand">true</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
@@ -47,22 +47,24 @@ static int
|
||||
svg_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (paintable);
|
||||
RsvgDimensionData data;
|
||||
double width;
|
||||
|
||||
rsvg_handle_get_dimensions (self->handle, &data);
|
||||
if (!rsvg_handle_get_intrinsic_size_in_pixels (self->handle, &width, NULL))
|
||||
return 0;
|
||||
|
||||
return data.width;
|
||||
return ceil (width);
|
||||
}
|
||||
|
||||
static int
|
||||
svg_paintable_get_intrinsic_height (GdkPaintable *paintable)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (paintable);
|
||||
RsvgDimensionData data;
|
||||
double height;
|
||||
|
||||
rsvg_handle_get_dimensions (self->handle, &data);
|
||||
if (!rsvg_handle_get_intrinsic_size_in_pixels (self->handle, NULL, &height))
|
||||
return 0;
|
||||
|
||||
return data.height;
|
||||
return ceil (height);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+11
-5
@@ -1,6 +1,11 @@
|
||||
/* Text View/Tabs
|
||||
*
|
||||
* GtkTextView can position text at fixed positions, using tabs.
|
||||
* Tabs can specify alignment, and also allow aligning numbers
|
||||
* on the decimal point.
|
||||
*
|
||||
* The example here has three tabs, with left, numeric and right
|
||||
* alignment.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
@@ -22,7 +27,7 @@ do_tabs (GtkWidget *do_widget)
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Tabs");
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 330, 330);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 330, 130);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
@@ -35,17 +40,18 @@ do_tabs (GtkWidget *do_widget)
|
||||
|
||||
tabs = pango_tab_array_new (3, TRUE);
|
||||
pango_tab_array_set_tab (tabs, 0, PANGO_TAB_LEFT, 0);
|
||||
pango_tab_array_set_tab (tabs, 1, PANGO_TAB_LEFT, 100);
|
||||
pango_tab_array_set_tab (tabs, 2, PANGO_TAB_LEFT, 200);
|
||||
pango_tab_array_set_tab (tabs, 1, PANGO_TAB_DECIMAL, 150);
|
||||
pango_tab_array_set_decimal_point (tabs, 1, '.');
|
||||
pango_tab_array_set_tab (tabs, 2, PANGO_TAB_RIGHT, 290);
|
||||
gtk_text_view_set_tabs (GTK_TEXT_VIEW (view), tabs);
|
||||
pango_tab_array_free (tabs);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_buffer_set_text (buffer, "one\ttwo\tthree\nfour\tfive\tsix\nseven\teight\tnine", -1);
|
||||
gtk_text_buffer_set_text (buffer, "one\t2.0\tthree\nfour\t5.555\tsix\nseven\t88.88\tnine", -1);
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_window_set_child (GTK_WINDOW (window), sw);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), view);
|
||||
|
||||
@@ -72,7 +72,7 @@ about_activated (GSimpleAction *action,
|
||||
glib_micro_version);
|
||||
g_string_append_printf (s, "\tPango\t%s\n",
|
||||
pango_version_string ());
|
||||
g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
|
||||
g_string_append_printf (s, "\tGTK \t%d.%d.%d\n",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
|
||||
@@ -79,7 +79,7 @@ activate_about (GSimpleAction *action,
|
||||
glib_micro_version);
|
||||
g_string_append_printf (s, "\tPango\t%s\n",
|
||||
pango_version_string ());
|
||||
g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
|
||||
g_string_append_printf (s, "\tGTK \t%d.%d.%d\n",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
|
||||
@@ -336,12 +336,39 @@ text_view_query_tooltip_cb (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
load_bytes (NodeEditorWindow *self,
|
||||
GBytes *bytes);
|
||||
|
||||
static void
|
||||
load_error (NodeEditorWindow *self,
|
||||
const char *error_message)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
GtkSnapshot *snapshot;
|
||||
GskRenderNode *node;
|
||||
GBytes *bytes;
|
||||
|
||||
layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), error_message);
|
||||
pango_layout_set_width (layout, 300 * PANGO_SCALE);
|
||||
snapshot = gtk_snapshot_new ();
|
||||
gtk_snapshot_append_layout (snapshot, layout, &(GdkRGBA) { 0.7, 0.13, 0.13, 1.0 });
|
||||
node = gtk_snapshot_free_to_node (snapshot);
|
||||
bytes = gsk_render_node_serialize (node);
|
||||
|
||||
load_bytes (self, bytes);
|
||||
|
||||
gsk_render_node_unref (node);
|
||||
g_object_unref (layout);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
load_bytes (NodeEditorWindow *self,
|
||||
GBytes *bytes)
|
||||
{
|
||||
if (!g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL))
|
||||
{
|
||||
load_error (self, "Invalid UTF-8");
|
||||
g_bytes_unref (bytes);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -359,11 +386,16 @@ static gboolean
|
||||
load_file_contents (NodeEditorWindow *self,
|
||||
GFile *file)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GBytes *bytes;
|
||||
|
||||
bytes = g_file_load_bytes (file, NULL, NULL, NULL);
|
||||
bytes = g_file_load_bytes (file, NULL, NULL, &error);
|
||||
if (bytes == NULL)
|
||||
return FALSE;
|
||||
{
|
||||
load_error (self, error->message);
|
||||
g_clear_error (&error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return load_bytes (self, bytes);
|
||||
}
|
||||
@@ -473,17 +505,18 @@ node_editor_window_load (NodeEditorWindow *self,
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
g_clear_object (&self->file_monitor);
|
||||
|
||||
if (!load_file_contents (self, file))
|
||||
return FALSE;
|
||||
|
||||
g_clear_object (&self->file_monitor);
|
||||
self->file_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error);
|
||||
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_warning ("couldn't monitor file: %s", error->message);
|
||||
g_error_free (error);
|
||||
g_clear_object (&self->file_monitor);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -161,9 +161,10 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkPaned">
|
||||
<property name="shrink-start-child">false</property>
|
||||
<property name="shrink-end-child">false</property>
|
||||
<property name="position">400</property>
|
||||
<child>
|
||||
<property name="start-child">
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="hexpand">1</property>
|
||||
@@ -184,8 +185,8 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
</property>
|
||||
<property name="end-child">
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
@@ -231,7 +232,7 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
|
||||
@@ -42,7 +42,7 @@ update_statusbar (void)
|
||||
const char *print_str;
|
||||
|
||||
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 0);
|
||||
|
||||
|
||||
gtk_text_buffer_get_iter_at_mark (buffer,
|
||||
&iter,
|
||||
gtk_text_buffer_get_insert (buffer));
|
||||
@@ -56,7 +56,7 @@ update_statusbar (void)
|
||||
GtkPrintOperation *op = active_prints->data;
|
||||
print_str = gtk_print_operation_get_status_string (op);
|
||||
}
|
||||
|
||||
|
||||
msg = g_strdup_printf ("%d, %d%s %s",
|
||||
row, col,
|
||||
file_changed?" - Modified":"",
|
||||
@@ -188,10 +188,10 @@ save_file (GFile *save_filename)
|
||||
"Error saving to file %s:\n%s",
|
||||
display_name,
|
||||
error->message);
|
||||
|
||||
|
||||
g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (error_dialog);
|
||||
|
||||
|
||||
g_error_free (error);
|
||||
g_object_unref (info);
|
||||
}
|
||||
@@ -229,7 +229,7 @@ begin_print (GtkPrintOperation *operation,
|
||||
pango_font_description_free (desc);
|
||||
|
||||
pango_layout_set_width (print_data->layout, width * PANGO_SCALE);
|
||||
|
||||
|
||||
pango_layout_set_text (print_data->layout, print_data->text, -1);
|
||||
|
||||
num_lines = pango_layout_get_line_count (print_data->layout);
|
||||
@@ -241,7 +241,7 @@ begin_print (GtkPrintOperation *operation,
|
||||
{
|
||||
PangoRectangle ink_rect, logical_rect;
|
||||
double line_height;
|
||||
|
||||
|
||||
layout_line = pango_layout_get_line (print_data->layout, line);
|
||||
pango_layout_line_get_extents (layout_line, &ink_rect, &logical_rect);
|
||||
|
||||
@@ -258,7 +258,7 @@ begin_print (GtkPrintOperation *operation,
|
||||
|
||||
page_breaks = g_list_reverse (page_breaks);
|
||||
gtk_print_operation_set_n_pages (operation, g_list_length (page_breaks) + 1);
|
||||
|
||||
|
||||
print_data->page_breaks = page_breaks;
|
||||
}
|
||||
|
||||
@@ -287,11 +287,11 @@ draw_page (GtkPrintOperation *operation,
|
||||
end = pango_layout_get_line_count (print_data->layout);
|
||||
else
|
||||
end = GPOINTER_TO_INT (pagebreak->data);
|
||||
|
||||
|
||||
cr = gtk_print_context_get_cairo_context (context);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
|
||||
|
||||
i = 0;
|
||||
start_pos = 0;
|
||||
iter = pango_layout_get_iter (print_data->layout);
|
||||
@@ -307,12 +307,12 @@ draw_page (GtkPrintOperation *operation,
|
||||
|
||||
pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
|
||||
baseline = pango_layout_iter_get_baseline (iter);
|
||||
|
||||
|
||||
if (i == start)
|
||||
start_pos = logical_rect.y / 1024.0;
|
||||
|
||||
|
||||
cairo_move_to (cr, logical_rect.x / 1024.0, baseline / 1024.0 - start_pos);
|
||||
|
||||
|
||||
pango_cairo_show_layout_line (cr, line);
|
||||
}
|
||||
i++;
|
||||
@@ -383,9 +383,9 @@ print_done (GtkPrintOperation *op,
|
||||
{
|
||||
|
||||
GtkWidget *error_dialog;
|
||||
|
||||
|
||||
gtk_print_operation_get_error (op, &error);
|
||||
|
||||
|
||||
error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
@@ -405,13 +405,13 @@ print_done (GtkPrintOperation *op,
|
||||
g_free (print_data->text);
|
||||
g_free (print_data->font);
|
||||
g_free (print_data);
|
||||
|
||||
|
||||
if (!gtk_print_operation_is_finished (op))
|
||||
{
|
||||
g_object_ref (op);
|
||||
active_prints = g_list_append (active_prints, op);
|
||||
update_statusbar ();
|
||||
|
||||
|
||||
/* This ref is unref:ed when we get the final state change */
|
||||
g_signal_connect (op, "status_changed",
|
||||
G_CALLBACK (status_changed_cb), NULL);
|
||||
@@ -628,7 +628,7 @@ activate_about (GSimpleAction *action,
|
||||
glib_micro_version);
|
||||
g_string_append_printf (sysinfo, "\tPango\t%s\n",
|
||||
pango_version_string ());
|
||||
g_string_append_printf (sysinfo, "\tGTK\t%d.%d.%d\n",
|
||||
g_string_append_printf (sysinfo, "\tGTK \t%d.%d.%d\n",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
|
||||
@@ -78,6 +78,21 @@ change_theme_state (GSimpleAction *action,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
change_fullscreen (GSimpleAction *action,
|
||||
GVariant *state,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWindow *window = user_data;
|
||||
|
||||
if (g_variant_get_boolean (state))
|
||||
gtk_window_fullscreen (window);
|
||||
else
|
||||
gtk_window_unfullscreen (window);
|
||||
|
||||
g_simple_action_set_state (action, state);
|
||||
}
|
||||
|
||||
static GtkWidget *page_stack;
|
||||
|
||||
static void
|
||||
@@ -283,7 +298,7 @@ activate_about (GSimpleAction *action,
|
||||
glib_micro_version);
|
||||
g_string_append_printf (s, "\tPango\t%s\n",
|
||||
pango_version_string ());
|
||||
g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
|
||||
g_string_append_printf (s, "\tGTK \t%d.%d.%d\n",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
@@ -384,7 +399,7 @@ print_operation_done (GtkPrintOperation *op,
|
||||
g_clear_error (&error);
|
||||
break;
|
||||
case GTK_PRINT_OPERATION_RESULT_APPLY:
|
||||
break;
|
||||
break;
|
||||
case GTK_PRINT_OPERATION_RESULT_CANCEL:
|
||||
g_print ("Printing was canceled\n");
|
||||
break;
|
||||
@@ -2012,11 +2027,12 @@ activate (GApplication *app)
|
||||
GMenuModel *model;
|
||||
static GActionEntry win_entries[] = {
|
||||
{ "dark", NULL, NULL, "false", change_dark_state },
|
||||
{ "theme", NULL, "s", "'current'", change_theme_state },
|
||||
{ "theme", NULL, "s", "'current'", change_theme_state },
|
||||
{ "transition", NULL, NULL, "true", change_transition_state },
|
||||
{ "search", activate_search, NULL, NULL, NULL },
|
||||
{ "delete", activate_delete, NULL, NULL, NULL },
|
||||
{ "busy", get_busy, NULL, NULL, NULL },
|
||||
{ "fullscreen", NULL, NULL, "false", change_fullscreen },
|
||||
{ "background", activate_background, NULL, NULL, NULL },
|
||||
{ "open", activate_open, NULL, NULL, NULL },
|
||||
{ "record", activate_record, NULL, NULL, NULL },
|
||||
@@ -2182,7 +2198,7 @@ activate (GApplication *app)
|
||||
g_object_set_data (G_OBJECT (window), "searchbar", widget);
|
||||
|
||||
widget = (GtkWidget *)gtk_builder_get_object (builder, "infobar");
|
||||
g_signal_connect (widget, "response", G_CALLBACK (info_bar_response), NULL);
|
||||
g_signal_connect (widget, "response", G_CALLBACK (info_bar_response), NULL);
|
||||
g_object_set_data (G_OBJECT (window), "infobar", widget);
|
||||
|
||||
dialog = (GtkWidget *)gtk_builder_get_object (builder, "info_dialog");
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
<attribute name="label" translatable="yes">Get Busy</attribute>
|
||||
<attribute name="action">win.busy</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Fullscreen</attribute>
|
||||
<attribute name="action">win.fullscreen</attribute>
|
||||
</item>
|
||||
<submenu>
|
||||
<attribute name="label" translatable="yes">Style</attribute>
|
||||
<section>
|
||||
@@ -2923,7 +2927,7 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
<property name="resizable">0</property>
|
||||
<property name="modal">1</property>
|
||||
<property name="text" translatable="1">Do something?</property>
|
||||
<property name="secondary-text" translatable="1">If you do something,
|
||||
<property name="secondary-text" translatable="1">If you don't do something,
|
||||
bad things might happen.</property>
|
||||
<property name="hide-on-close">1</property>
|
||||
<child type="action">
|
||||
|
||||
@@ -3,6 +3,7 @@ version = "@version@"
|
||||
browse_url = "https://gitlab.gnome.org/GNOME/gtk/"
|
||||
repository_url = "https://gitlab.gnome.org/GNOME/gtk.git"
|
||||
website_url = "https://www.gtk.org"
|
||||
docs_url = "https://docs.gtk.org/gdk4/"
|
||||
authors = "GTK Development Team"
|
||||
logo_url = "gtk-logo.svg"
|
||||
license = "LGPL-2.1-or-later"
|
||||
|
||||
@@ -33,7 +33,7 @@ calls to different backends, and error out on unsupported windowing systems:
|
||||
else
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if (GTK_IS_WAYLAND_DISPLAY (display))
|
||||
if (GDK_IS_WAYLAND_DISPLAY (display))
|
||||
{
|
||||
// make Wayland-specific calls here
|
||||
}
|
||||
|
||||
@@ -16,12 +16,10 @@ if get_option('gtk_doc')
|
||||
command: [
|
||||
gidocgen,
|
||||
'generate',
|
||||
'--quiet',
|
||||
'--fatal-warnings',
|
||||
gidocgen_common_args,
|
||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
||||
'--config=@INPUT0@',
|
||||
'--output-dir=@OUTPUT@',
|
||||
'--no-namespace-dir',
|
||||
'--content-dir=@0@'.format(meson.current_source_dir()),
|
||||
'@INPUT1@',
|
||||
],
|
||||
@@ -46,12 +44,10 @@ if get_option('gtk_doc')
|
||||
command: [
|
||||
gidocgen,
|
||||
'generate',
|
||||
'--quiet',
|
||||
'--fatal-warnings',
|
||||
gidocgen_common_args,
|
||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
||||
'--config=@INPUT0@',
|
||||
'--output-dir=@OUTPUT@',
|
||||
'--no-namespace-dir',
|
||||
'--content-dir=@0@'.format(meson.current_source_dir()),
|
||||
'@INPUT1@',
|
||||
],
|
||||
@@ -78,12 +74,10 @@ if get_option('gtk_doc')
|
||||
command: [
|
||||
gidocgen,
|
||||
'generate',
|
||||
'--quiet',
|
||||
'--fatal-warnings',
|
||||
gidocgen_common_args,
|
||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
||||
'--config=@INPUT0@',
|
||||
'--output-dir=@OUTPUT@',
|
||||
'--no-namespace-dir',
|
||||
'--content-dir=@0@'.format(meson.current_source_dir()),
|
||||
'@INPUT1@',
|
||||
],
|
||||
|
||||
@@ -23,7 +23,7 @@ calls to different backends, and error out on unsupported windowing systems:
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if (GTK_IS_WAYLAND_DISPLAY (display))
|
||||
if (GDK_IS_WAYLAND_DISPLAY (display))
|
||||
{
|
||||
// make Wayland-specific calls here
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ calls to different backends, and error out on unsupported windowing systems:
|
||||
else
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if (GTK_IS_WAYLAND_DISPLAY (display))
|
||||
if (GDK_IS_WAYLAND_DISPLAY (display))
|
||||
{
|
||||
// make Wayland-specific calls here
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ version = "@version@"
|
||||
browse_url = "https://gitlab.gnome.org/GNOME/gtk/"
|
||||
repository_url = "https://gitlab.gnome.org/GNOME/gtk.git"
|
||||
website_url = "https://www.gtk.org"
|
||||
docs_url = "https://docs.gtk.org/gsk4/"
|
||||
authors = "GTK Development Team"
|
||||
logo_url = "gtk-logo.svg"
|
||||
license = "LGPL-2.1-or-later"
|
||||
|
||||
@@ -13,12 +13,10 @@ if get_option('gtk_doc')
|
||||
command: [
|
||||
gidocgen,
|
||||
'generate',
|
||||
'--quiet',
|
||||
'--fatal-warnings',
|
||||
gidocgen_common_args,
|
||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
||||
'--config=@INPUT0@',
|
||||
'--output-dir=@OUTPUT@',
|
||||
'--no-namespace-dir',
|
||||
'--content-dir=@0@'.format(meson.current_source_dir()),
|
||||
'@INPUT1@',
|
||||
],
|
||||
|
||||
@@ -3,6 +3,7 @@ version = "@version@"
|
||||
browse_url = "https://gitlab.gnome.org/GNOME/gtk/"
|
||||
repository_url = "https://gitlab.gnome.org/GNOME/gtk.git"
|
||||
website_url = "https://www.gtk.org"
|
||||
docs_url = "https://docs.gtk.org/gtk4/"
|
||||
authors = "GTK Development Team"
|
||||
logo_url = "gtk-logo.svg"
|
||||
license = "LGPL-2.1-or-later"
|
||||
|
||||
@@ -42,12 +42,10 @@ if get_option('gtk_doc')
|
||||
command: [
|
||||
gidocgen,
|
||||
'generate',
|
||||
'--quiet',
|
||||
'--fatal-warnings',
|
||||
gidocgen_common_args,
|
||||
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
|
||||
'--config=@INPUT0@',
|
||||
'--output-dir=@OUTPUT@',
|
||||
'--no-namespace-dir',
|
||||
'--content-dir=@0@'.format(meson.current_source_dir()),
|
||||
'@INPUT1@',
|
||||
],
|
||||
|
||||
@@ -315,7 +315,7 @@ have been added to `GdkDisplay`.
|
||||
|
||||
The root window is an X11-centric concept that is no longer exposed in the
|
||||
backend-neutral GDK API. If you need to interact with the X11 root window,
|
||||
you can use [method@GdkX11.Display.get_xrootwindow] to get its XID.
|
||||
you can use [`method@GdkX11.Display.get_xrootwindow`] to get its XID.
|
||||
|
||||
### Stop using `GdkVisual`
|
||||
|
||||
@@ -333,9 +333,9 @@ had replacements in GTK 3 and were deprecated in favor of `GdkSeat`.
|
||||
|
||||
In GTK 4, the two roles of a standalone toplevel window and of a popup that
|
||||
is placed relative to a parent window have been separated out into two
|
||||
interfaces, [class@Gdk.Toplevel] and [class@Gdk.Popup]. Surfaces
|
||||
implementing these interfaces are created with [ctor@Gdk.Surface.new_toplevel]
|
||||
and [ctor@Gdk.Surface.new_popup], respectively, and they are presented on
|
||||
interfaces, [iface@Gdk.Toplevel] and [iface@Gdk.Popup]. Surfaces
|
||||
implementing these interfaces are created with [`ctor@Gdk.Surface.new_toplevel`]
|
||||
and [`ctor@Gdk.Surface.new_popup`], respectively, and they are presented on
|
||||
screen using [method@Gdk.Toplevel.present] and [method@Gdk.Popup.present].
|
||||
The `present()` functions take parameters in the form of an auxiliary layout
|
||||
struct, [struct@Gdk.PopupLayout] or [struct@Gdk.ToplevelLayout].
|
||||
@@ -362,9 +362,9 @@ windows, you you will have to use Xlib apis.
|
||||
|
||||
A number of minor API cleanups have happened in `GdkSurface`
|
||||
as well. For example, `gdk_surface_input_shape_combine_region()`
|
||||
has been renamed to [method@Gdk.Surface.set_input_region], and
|
||||
has been renamed to [`method@Gdk.Surface.set_input_region`], and
|
||||
`gdk_surface_begin_resize_drag()` has been renamed to
|
||||
[method@Gdk.Toplevel.begin_resize].
|
||||
[`method@Gdk.Toplevel.begin_resize`].
|
||||
|
||||
### The "iconified" window state has been renamed to "minimized"
|
||||
|
||||
@@ -388,7 +388,7 @@ have accessors that you will have to use.
|
||||
|
||||
Event compression is always enabled in GTK 4, for both motion and
|
||||
scroll events. If you need to see the uncoalesced motion or scroll
|
||||
history, use [method@Gdk.Event.get_history] on the latest event.
|
||||
history, use [`method@Gdk.Event.get_history`] on the latest event.
|
||||
|
||||
### Stop using grabs
|
||||
|
||||
@@ -410,8 +410,8 @@ have been removed. Update your code accordingly.
|
||||
Any APIs that deal with global (or root) coordinates have been
|
||||
removed in GTK 4, since not all backends support them. You should
|
||||
replace your use of such APIs with surface-relative equivalents.
|
||||
Examples of this are `gdk_surface_get_origin()`, `gdk_surface_move()`
|
||||
or `gdk_event_get_root_coords()`.
|
||||
Examples of such removed APIs are `gdk_window_get_origin()`,
|
||||
`gdk_window_move()` or `gdk_event_get_root_coords()`.
|
||||
|
||||
### Adapt to `GdkKeymap` API changes
|
||||
|
||||
@@ -1054,7 +1054,7 @@ Observing widget contents and widget size is now done by using the
|
||||
|
||||
### Monitor handling has changed
|
||||
|
||||
Instead of a monitor number, [class@Gdk.Monitor] is now used throughout.
|
||||
Instead of a monitor number, [class@Gdk.Monitor] is now used throughout.
|
||||
[method@Gdk.Display.get_monitors] returns the list of monitors that can be queried
|
||||
or observed for monitors to pass to APIs like [method@Gtk.Window.fullscreen_on_monitor].
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ the question you have, this list is a good place to start.
|
||||
(most of it about GTK 2.x and 3.x, but still somewhat applicable). This
|
||||
reference manual also contains a introductory
|
||||
[Getting Started](#gtk-getting-started) part.
|
||||
|
||||
|
||||
More documentation ranging from whitepapers to online books can be found at
|
||||
the [GNOME developer's site](https://developer.gnome.org). After studying these
|
||||
materials you should be well prepared to come back to this reference manual for details.
|
||||
@@ -93,11 +93,11 @@ the question you have, this list is a good place to start.
|
||||
|
||||
`gi18n.h` provides the following shorthand macros for convenience.
|
||||
Conventionally, people define macros as follows for convenience:
|
||||
|
||||
|
||||
#define _(x) gettext (x)
|
||||
#define N_(x) x
|
||||
#define C_(ctx,x) pgettext (ctx, x)
|
||||
|
||||
|
||||
You use `N_()` (N stands for no-op) to mark a string for translation in
|
||||
a location where a function call to gettext() is not allowed, such as
|
||||
in an array initializer. You eventually have to call gettext() on the
|
||||
@@ -205,14 +205,14 @@ the question you have, this list is a good place to start.
|
||||
Here is an example showing the three approaches using the copyright
|
||||
sign © which has Unicode and ISO-8859-1 codepoint 169 and is represented
|
||||
in UTF-8 by the two bytes 194, 169, or `"\302\251"` as a string literal:
|
||||
|
||||
|
||||
g_print ("direct UTF-8: ©");
|
||||
g_print ("escaped UTF-8: \302\251");
|
||||
text = g_convert ("runtime conversion: ©", -1,
|
||||
"ISO-8859-1", "UTF-8", NULL, NULL, NULL);
|
||||
g_print (text);
|
||||
g_free (text);
|
||||
|
||||
|
||||
If you are using gettext() to localize your application, you need
|
||||
to call bind_textdomain_codeset() to ensure that translated strings
|
||||
are returned in UTF-8 encoding.
|
||||
@@ -432,10 +432,10 @@ the question you have, this list is a good place to start.
|
||||
|
||||
26. How do I associate some data with a row in the tree?
|
||||
|
||||
Remember that the [class@Gtk.TreeModel] columns don't necessarily have to be
|
||||
Remember that the [iface@Gtk.TreeModel] columns don't necessarily have to be
|
||||
displayed. So you can put non-user-visible data in your model just
|
||||
like any other data, and retrieve it with [method@Gtk.TreeModel.get].
|
||||
See the [tree widget overview](#TreeWidget).
|
||||
See the [tree widget overview](#TreeWidget).
|
||||
|
||||
27. How do I put an image and some text in the same column?
|
||||
|
||||
@@ -447,7 +447,7 @@ the question you have, this list is a good place to start.
|
||||
28. I can set data easily on my [class@Gtk.TreeStore] or [class@Gtk.ListStore] models using
|
||||
[method@Gtk.ListStore.set] and [method@Gtk.TreeStore.set], but can't read it back?
|
||||
|
||||
Both the [class@Gtk.TreeStore] and the [class@Gtk.ListStore] implement the [class@Gtk.TreeModel]
|
||||
Both the [class@Gtk.TreeStore] and the [class@Gtk.ListStore] implement the [iface@Gtk.TreeModel]
|
||||
interface. As a consequence, you can use any function this interface
|
||||
implements. The easiest way to read a set of data back is to use
|
||||
[method@Gtk.TreeModel.get].
|
||||
|
||||
@@ -133,7 +133,7 @@ gtk_text_buffer_set_text (buffer, "Hello, this is some text", -1);
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider,
|
||||
"textview {"
|
||||
" font: 15 serif;"
|
||||
" font: 15px serif;"
|
||||
" color: green;"
|
||||
"}",
|
||||
-1);
|
||||
@@ -149,9 +149,9 @@ gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 30);
|
||||
tag = gtk_text_buffer_create_tag (buffer, "blue_foreground",
|
||||
"foreground", "blue",
|
||||
NULL);
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &start, 7);
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &end, 12);
|
||||
gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &start, 7);
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &end, 12);
|
||||
gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
|
||||
```
|
||||
|
||||
The `gtk4-demo` application that comes with
|
||||
|
||||
@@ -3,6 +3,15 @@ toml_conf.set('version', meson.project_version())
|
||||
|
||||
gidocgen = find_program('gi-docgen', required: get_option('gtk_doc'))
|
||||
|
||||
gidocgen_common_args = [
|
||||
'--quiet',
|
||||
'--no-namespace-dir',
|
||||
]
|
||||
|
||||
if get_option('werror')
|
||||
gidocgen_common_args += ['--fatal-warnings']
|
||||
endif
|
||||
|
||||
docs_dir = gtk_datadir / 'doc'
|
||||
|
||||
if get_option('gtk_doc') and not build_gir
|
||||
|
||||
+3
-3
@@ -1253,14 +1253,14 @@ gdk_clipboard_set_content (GdkClipboard *clipboard,
|
||||
* @...: value contents conforming to @type
|
||||
*
|
||||
* Sets the clipboard to contain the value collected from the given varargs.
|
||||
*
|
||||
*
|
||||
* Values should be passed the same way they are passed to other value
|
||||
* collecting APIs, such as [`method@GObject.Object.set`] or
|
||||
* [`id@g_signal_emit`].
|
||||
* [`func@GObject.signal_emit`].
|
||||
*
|
||||
* ```c
|
||||
* gdk_clipboard_set (clipboard, GTK_TYPE_STRING, "Hello World");
|
||||
*
|
||||
*
|
||||
* gdk_clipboard_set (clipboard, GDK_TYPE_TEXTURE, some_texture);
|
||||
* ```
|
||||
*/
|
||||
|
||||
+29
-25
@@ -1438,31 +1438,6 @@ describe_egl_config (EGLDisplay egl_display,
|
||||
}
|
||||
#endif
|
||||
|
||||
/*<private>
|
||||
* gdk_display_get_egl_display:
|
||||
* @self: a display
|
||||
*
|
||||
* Retrieves the EGL display connection object for the given GDK display.
|
||||
*
|
||||
* This function returns `NULL` if GL is not supported or GDK is using
|
||||
* a different OpenGL framework than EGL.
|
||||
*
|
||||
* Returns: (nullable): the EGL display object
|
||||
*/
|
||||
gpointer
|
||||
gdk_display_get_egl_display (GdkDisplay *self)
|
||||
{
|
||||
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL);
|
||||
|
||||
if (!priv->egl_display &&
|
||||
!gdk_display_prepare_gl (self, NULL))
|
||||
return NULL;
|
||||
|
||||
return priv->egl_display;
|
||||
}
|
||||
|
||||
gpointer
|
||||
gdk_display_get_egl_config (GdkDisplay *self)
|
||||
{
|
||||
@@ -1789,6 +1764,35 @@ gdk_display_init_egl (GdkDisplay *self,
|
||||
}
|
||||
#endif
|
||||
|
||||
/*<private>
|
||||
* gdk_display_get_egl_display:
|
||||
* @self: a display
|
||||
*
|
||||
* Retrieves the EGL display connection object for the given GDK display.
|
||||
*
|
||||
* This function returns `NULL` if GL is not supported or GDK is using
|
||||
* a different OpenGL framework than EGL.
|
||||
*
|
||||
* Returns: (nullable): the EGL display object
|
||||
*/
|
||||
gpointer
|
||||
gdk_display_get_egl_display (GdkDisplay *self)
|
||||
{
|
||||
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL);
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
if (!priv->egl_display &&
|
||||
!gdk_display_prepare_gl (self, NULL))
|
||||
return NULL;
|
||||
|
||||
return priv->egl_display;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
GdkDebugFlags
|
||||
gdk_display_get_debug_flags (GdkDisplay *display)
|
||||
{
|
||||
|
||||
@@ -105,7 +105,7 @@ struct _GdkDeleteEvent
|
||||
* GdkMotionEvent:
|
||||
* @state: (type GdkModifierType): a bit-mask representing the state of
|
||||
* the modifier keys (e.g. Control, Shift and Alt) set during the motion
|
||||
* event. See [enum@Gdk.ModifierType]
|
||||
* event. See [flags@Gdk.ModifierType]
|
||||
* @x: the x coordinate of the pointer relative to the surface.
|
||||
* @y: the y coordinate of the pointer relative to the surface.
|
||||
* @axes: @x, @y translated to the axes of @device, or %NULL if @device is
|
||||
@@ -132,7 +132,7 @@ struct _GdkMotionEvent
|
||||
* GdkButtonEvent:
|
||||
* @state: (type GdkModifierType): a bit-mask representing the state of
|
||||
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
|
||||
* buttons. See [enum@Gdk.ModifierType]
|
||||
* buttons. See [flags@Gdk.ModifierType]
|
||||
* @button: the button which was pressed or released, numbered from 1 to 5.
|
||||
* Normally button 1 is the left mouse button, 2 is the middle button,
|
||||
* and 3 is the right button. On 2-button mice, the middle button can
|
||||
@@ -162,7 +162,7 @@ struct _GdkButtonEvent
|
||||
* GdkTouchEvent:
|
||||
* @state: (type GdkModifierType): a bit-mask representing the state of
|
||||
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
|
||||
* buttons. See [enum@Gdk.ModifierType]
|
||||
* buttons. See [flags@Gdk.ModifierType]
|
||||
* @x: the x coordinate of the pointer relative to the surface
|
||||
* @y: the y coordinate of the pointer relative to the surface
|
||||
* @axes: @x, @y translated to the axes of the event's device, or %NULL
|
||||
@@ -200,7 +200,7 @@ struct _GdkTouchEvent
|
||||
* @y: the y coordinate of the pointer relative to the surface.
|
||||
* @state: (type GdkModifierType): a bit-mask representing the state of
|
||||
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
|
||||
* buttons. See [enum@Gdk.ModifierType]
|
||||
* buttons. See [flags@Gdk.ModifierType]
|
||||
* @direction: the direction to scroll to (one of %GDK_SCROLL_UP,
|
||||
* %GDK_SCROLL_DOWN, %GDK_SCROLL_LEFT, %GDK_SCROLL_RIGHT or
|
||||
* %GDK_SCROLL_SMOOTH).
|
||||
@@ -256,7 +256,7 @@ typedef struct {
|
||||
* GdkKeyEvent:
|
||||
* @state: (type GdkModifierType): a bit-mask representing the state of
|
||||
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
|
||||
* buttons. See [enum@Gdk.ModifierType]
|
||||
* buttons. See [flags@Gdk.ModifierType]
|
||||
* @keycode: the raw code of the key that was pressed or released.
|
||||
* @translated: the result of translating @keycode. First with the full
|
||||
* @state, then while ignoring Caps Lock.
|
||||
@@ -277,7 +277,7 @@ struct _GdkKeyEvent
|
||||
* GdkCrossingEvent:
|
||||
* @state: (type GdkModifierType): a bit-mask representing the state of
|
||||
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
|
||||
* buttons. See [enum@Gdk.ModifierType]
|
||||
* buttons. See [flags@Gdk.ModifierType]
|
||||
* @mode: the crossing mode (%GDK_CROSSING_NORMAL, %GDK_CROSSING_GRAB,
|
||||
* %GDK_CROSSING_UNGRAB, %GDK_CROSSING_GTK_GRAB, %GDK_CROSSING_GTK_UNGRAB or
|
||||
* %GDK_CROSSING_STATE_CHANGED). %GDK_CROSSING_GTK_GRAB, %GDK_CROSSING_GTK_UNGRAB,
|
||||
@@ -383,7 +383,7 @@ struct _GdkDNDEvent
|
||||
* GdkTouchpadEvent:
|
||||
* @state: (type GdkModifierType): a bit-mask representing the state of
|
||||
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
|
||||
* buttons. See [enum@Gdk.ModifierType]
|
||||
* buttons. See [flags@Gdk.ModifierType]
|
||||
* @phase: (type GdkTouchpadGesturePhase): the current phase of the gesture
|
||||
* @n_fingers: The number of fingers triggering the pinch
|
||||
* @time: the time of the event in milliseconds
|
||||
|
||||
+6
-1
@@ -255,7 +255,7 @@ static GdkGLAPI
|
||||
gdk_gl_context_real_realize (GdkGLContext *context,
|
||||
GError **error)
|
||||
{
|
||||
#if HAVE_EGL
|
||||
#ifdef HAVE_EGL
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
GdkDisplay *display = gdk_gl_context_get_display (context);
|
||||
EGLDisplay egl_display = gdk_display_get_egl_display (display);
|
||||
@@ -572,6 +572,11 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
|
||||
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glViewport (0, 0, ww, wh);
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
if (priv->egl_context)
|
||||
glDrawBuffers (1, (GLenum[1]) { GL_BACK_LEFT });
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+3
-3
@@ -58,8 +58,8 @@
|
||||
* It’s a low-level object, used to implement high-level objects
|
||||
* such as [class@Gtk.Window] or [class@Gtk.Dialog] in GTK.
|
||||
*
|
||||
* The surfaces you see in practice are either [class@Gdk.Toplevel] or
|
||||
* [class@Gdk.Popup], and those interfaces provide much of the required
|
||||
* The surfaces you see in practice are either [iface@Gdk.Toplevel] or
|
||||
* [iface@Gdk.Popup], and those interfaces provide much of the required
|
||||
* API to interact with these surfaces. Other, more specialized surface
|
||||
* types exist, but you will rarely interact with them directly.
|
||||
*/
|
||||
@@ -2099,7 +2099,7 @@ gdk_surface_get_root_coords (GdkSurface *surface,
|
||||
*root_y = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
GDK_SURFACE_GET_CLASS (surface)->get_root_coords (surface, x, y, root_x, root_y);
|
||||
}
|
||||
|
||||
|
||||
+1
-44
@@ -28,8 +28,7 @@
|
||||
* `GdkPixbuf`, or a Cairo surface, or other pixel data.
|
||||
*
|
||||
* The ownership of the pixel data is transferred to the `GdkTexture`
|
||||
* instance; you can only make a copy of it, via [method@Gdk.Texture.download]
|
||||
* or [method@Gdk.Texture.download_float].
|
||||
* instance; you can only make a copy of it, via [method@Gdk.Texture.download].
|
||||
*
|
||||
* `GdkTexture` is an immutable object: That means you cannot change
|
||||
* anything about it other than increasing the reference count via
|
||||
@@ -743,48 +742,6 @@ gdk_texture_download (GdkTexture *texture,
|
||||
stride);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_texture_download_float:
|
||||
* @texture: a `GdkTexture`
|
||||
* @data: (array): pointer to enough memory to be filled with the
|
||||
* downloaded data of @texture
|
||||
* @stride: rowstride in elements, will usually be equal to
|
||||
* gdk_texture_get_width() * 4
|
||||
*
|
||||
* Downloads the @texture into local memory in a high dynamic range format.
|
||||
*
|
||||
* This may be an expensive operation, as the actual texture data
|
||||
* may reside on a GPU or on a remote display server and because the data
|
||||
* may need to be upsampled if it was not already available in this
|
||||
* format.
|
||||
*
|
||||
* You may want to use [method@Gdk.Texture.download] instead if you don't
|
||||
* need high dynamic range support.
|
||||
*
|
||||
* The data format of the downloaded data is equivalent to
|
||||
* GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, so every downloaded
|
||||
* pixel requires 16 bytes of memory.
|
||||
*
|
||||
* Note that the caller is responsible to provide sufficiently
|
||||
* aligned memory to access the resulting data directly as floats.
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
void
|
||||
gdk_texture_download_float (GdkTexture *texture,
|
||||
float *data,
|
||||
gsize stride)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_TEXTURE (texture));
|
||||
g_return_if_fail (data != NULL);
|
||||
g_return_if_fail (stride >= gdk_texture_get_width (texture) * 4);
|
||||
|
||||
gdk_texture_do_download (texture,
|
||||
GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
|
||||
(guchar *) data,
|
||||
stride);
|
||||
}
|
||||
|
||||
GdkMemoryFormat
|
||||
gdk_texture_get_format (GdkTexture *self)
|
||||
{
|
||||
|
||||
@@ -727,6 +727,13 @@ gdk_toplevel_begin_move (GdkToplevel *toplevel,
|
||||
timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_toplevel_titlebar_gesture:
|
||||
* @toplevel: a `GdkToplevel`
|
||||
* @gesture: a `GdkTitlebarGesture`
|
||||
*
|
||||
* Since: 4.4
|
||||
*/
|
||||
gboolean
|
||||
gdk_toplevel_titlebar_gesture (GdkToplevel *toplevel,
|
||||
GdkTitlebarGesture gesture)
|
||||
|
||||
@@ -115,6 +115,14 @@ typedef enum
|
||||
GDK_TOPLEVEL_STATE_LEFT_RESIZABLE = 1 << 15
|
||||
} GdkToplevelState;
|
||||
|
||||
/**
|
||||
* GdkTitlebarGesture:
|
||||
* @GDK_TITLEBAR_GESTURE_DOUBLE_CLICK:
|
||||
* @GDK_TITLEBAR_GESTURE_RIGHT_CLICK:
|
||||
* @GDK_TITLEBAR_GESTURE_MIDDLE_CLICK:
|
||||
*
|
||||
* Since: 4.4
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_TITLEBAR_GESTURE_DOUBLE_CLICK = 1,
|
||||
|
||||
@@ -251,7 +251,7 @@ gdk_load_png (GBytes *bytes,
|
||||
png_destroy_read_struct (&png, &info, NULL);
|
||||
g_set_error (error,
|
||||
GDK_TEXTURE_ERROR, GDK_TEXTURE_ERROR_UNSUPPORTED_CONTENT,
|
||||
_("Unsupportd color type %u in png image"), color_type);
|
||||
_("Unsupported color type %u in png image"), color_type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ ensure_gl_view (GdkMacosGLContext *self)
|
||||
return [nswindow contentView];
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static GdkGLAPI
|
||||
gdk_macos_gl_context_real_realize (GdkGLContext *context,
|
||||
GError **error)
|
||||
{
|
||||
|
||||
@@ -3606,6 +3606,10 @@ tablet_tool_handle_proximity_out (void *data,
|
||||
g_object_unref (tablet->pointer_info.focus);
|
||||
tablet->pointer_info.focus = NULL;
|
||||
|
||||
tablet->pointer_info.button_modifiers &=
|
||||
~(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK |
|
||||
GDK_BUTTON4_MASK | GDK_BUTTON5_MASK);
|
||||
|
||||
gdk_device_update_tool (tablet->stylus_device, NULL);
|
||||
g_clear_object (&tablet->pointer_info.cursor);
|
||||
}
|
||||
@@ -3621,7 +3625,6 @@ tablet_create_button_event_frame (GdkWaylandTabletData *tablet,
|
||||
GdkEventType evtype,
|
||||
guint button)
|
||||
{
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
|
||||
GdkEvent *event;
|
||||
|
||||
event = gdk_button_event_new (evtype,
|
||||
@@ -3629,7 +3632,7 @@ tablet_create_button_event_frame (GdkWaylandTabletData *tablet,
|
||||
tablet->logical_device,
|
||||
tablet->current_tool->tool,
|
||||
tablet->pointer_info.time,
|
||||
device_get_modifiers (seat->logical_pointer),
|
||||
device_get_modifiers (tablet->logical_device),
|
||||
button,
|
||||
tablet->pointer_info.surface_x,
|
||||
tablet->pointer_info.surface_y,
|
||||
|
||||
@@ -130,10 +130,6 @@ xdg_wm_base_ping (void *data,
|
||||
struct xdg_wm_base *xdg_wm_base,
|
||||
uint32_t serial)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = data;
|
||||
|
||||
_gdk_wayland_display_update_serial (display_wayland, serial);
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("ping, shell %p, serial %u\n", xdg_wm_base, serial));
|
||||
|
||||
|
||||
@@ -53,8 +53,6 @@ gdk_wayland_gl_context_begin_frame (GdkDrawContext *draw_context,
|
||||
gdk_wayland_surface_ensure_wl_egl_window (gdk_draw_context_get_surface (draw_context));
|
||||
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->begin_frame (draw_context, prefers_high_depth, region);
|
||||
|
||||
glDrawBuffers (1, (GLenum[1]) { GL_BACK });
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -104,8 +104,6 @@ struct _GdkWaylandSurface
|
||||
|
||||
struct gtk_surface1 *gtk_surface;
|
||||
struct wl_egl_window *egl_window;
|
||||
struct zxdg_exported_v1 *xdg_exported;
|
||||
struct org_kde_kwin_server_decoration *server_decoration;
|
||||
} display_server;
|
||||
|
||||
struct wl_event_queue *event_queue;
|
||||
@@ -224,17 +222,8 @@ struct _GdkWaylandSurface
|
||||
|
||||
int state_freeze_count;
|
||||
|
||||
struct {
|
||||
GdkWaylandToplevelExported callback;
|
||||
gpointer user_data;
|
||||
GDestroyNotify destroy_func;
|
||||
} exported;
|
||||
|
||||
struct zxdg_imported_v1 *imported_transient_for;
|
||||
GHashTable *shortcuts_inhibitors;
|
||||
|
||||
struct zwp_idle_inhibitor_v1 *idle_inhibitor;
|
||||
size_t idle_inhibitor_refcount;
|
||||
};
|
||||
|
||||
typedef struct _GdkWaylandSurfaceClass GdkWaylandSurfaceClass;
|
||||
@@ -250,6 +239,18 @@ struct _GdkWaylandToplevel
|
||||
GdkWaylandSurface parent_instance;
|
||||
|
||||
GdkWaylandToplevel *transient_for;
|
||||
|
||||
struct org_kde_kwin_server_decoration *server_decoration;
|
||||
struct zxdg_exported_v1 *xdg_exported;
|
||||
|
||||
struct {
|
||||
GdkWaylandToplevelExported callback;
|
||||
gpointer user_data;
|
||||
GDestroyNotify destroy_func;
|
||||
} exported;
|
||||
|
||||
struct zwp_idle_inhibitor_v1 *idle_inhibitor;
|
||||
size_t idle_inhibitor_refcount;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@@ -329,7 +330,7 @@ static void update_popup_layout_state (GdkSurface *surface,
|
||||
int height,
|
||||
GdkPopupLayout *layout);
|
||||
|
||||
static gboolean gdk_wayland_surface_is_exported (GdkWaylandSurface *impl);
|
||||
static gboolean gdk_wayland_toplevel_is_exported (GdkWaylandToplevel *wayland_toplevel);
|
||||
|
||||
static void configure_toplevel_geometry (GdkSurface *surface);
|
||||
|
||||
@@ -988,9 +989,6 @@ gdk_wayland_surface_finalize (GObject *object)
|
||||
|
||||
impl = GDK_WAYLAND_SURFACE (object);
|
||||
|
||||
if (gdk_wayland_surface_is_exported (impl))
|
||||
gdk_wayland_toplevel_unexport_handle (GDK_TOPLEVEL (impl));
|
||||
|
||||
g_free (impl->title);
|
||||
|
||||
g_free (impl->application.application_id);
|
||||
@@ -1028,8 +1026,7 @@ is_realized_popup (GdkWaylandSurface *impl)
|
||||
impl->display_server.zxdg_popup_v6);
|
||||
}
|
||||
|
||||
static void gdk_wayland_surface_show (GdkSurface *surface,
|
||||
gboolean already_mapped);
|
||||
static void gdk_wayland_surface_show (GdkSurface *surface);
|
||||
static void gdk_wayland_surface_hide (GdkSurface *surface);
|
||||
|
||||
static void
|
||||
@@ -1062,7 +1059,7 @@ gdk_wayland_surface_maybe_resize (GdkSurface *surface,
|
||||
gdk_wayland_surface_update_size (surface, width, height, scale);
|
||||
|
||||
if (is_xdg_popup && is_visible && !impl->initial_configure_received)
|
||||
gdk_wayland_surface_show (surface, FALSE);
|
||||
gdk_wayland_surface_show (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2238,57 +2235,62 @@ void
|
||||
gdk_wayland_toplevel_announce_csd (GdkToplevel *toplevel)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (toplevel)));
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (toplevel);
|
||||
GdkWaylandToplevel *toplevel_wayland;
|
||||
|
||||
g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel));
|
||||
toplevel_wayland = GDK_WAYLAND_TOPLEVEL (toplevel);
|
||||
|
||||
if (!display_wayland->server_decoration_manager)
|
||||
return;
|
||||
impl->display_server.server_decoration =
|
||||
org_kde_kwin_server_decoration_manager_create (display_wayland->server_decoration_manager,
|
||||
impl->display_server.wl_surface);
|
||||
if (impl->display_server.server_decoration)
|
||||
org_kde_kwin_server_decoration_request_mode (impl->display_server.server_decoration,
|
||||
ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT);
|
||||
toplevel_wayland->server_decoration =
|
||||
org_kde_kwin_server_decoration_manager_create (display_wayland->server_decoration_manager,
|
||||
gdk_wayland_surface_get_wl_surface (GDK_SURFACE (toplevel_wayland)));
|
||||
if (toplevel_wayland->server_decoration)
|
||||
org_kde_kwin_server_decoration_request_mode (toplevel_wayland->server_decoration,
|
||||
ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_wayland_toplevel_announce_ssd (GdkToplevel *toplevel)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (toplevel)));
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (toplevel);
|
||||
GdkWaylandToplevel *toplevel_wayland;
|
||||
|
||||
g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel));
|
||||
toplevel_wayland = GDK_WAYLAND_TOPLEVEL (toplevel);
|
||||
|
||||
if (!display_wayland->server_decoration_manager)
|
||||
return;
|
||||
impl->display_server.server_decoration =
|
||||
org_kde_kwin_server_decoration_manager_create (display_wayland->server_decoration_manager,
|
||||
impl->display_server.wl_surface);
|
||||
if (impl->display_server.server_decoration)
|
||||
org_kde_kwin_server_decoration_request_mode (impl->display_server.server_decoration,
|
||||
ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER);
|
||||
toplevel_wayland->server_decoration =
|
||||
org_kde_kwin_server_decoration_manager_create (display_wayland->server_decoration_manager,
|
||||
gdk_wayland_surface_get_wl_surface (GDK_SURFACE (toplevel_wayland)));
|
||||
if (toplevel_wayland->server_decoration)
|
||||
org_kde_kwin_server_decoration_request_mode (toplevel_wayland->server_decoration,
|
||||
ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_wayland_toplevel_inhibit_idle (GdkToplevel *toplevel)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (toplevel)));
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (toplevel);
|
||||
GdkWaylandToplevel *wayland_toplevel;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel), FALSE);
|
||||
wayland_toplevel = GDK_WAYLAND_TOPLEVEL (toplevel);
|
||||
|
||||
if (!display_wayland->idle_inhibit_manager)
|
||||
return FALSE;
|
||||
|
||||
if (!impl->idle_inhibitor)
|
||||
if (!wayland_toplevel->idle_inhibitor)
|
||||
{
|
||||
g_assert (impl->idle_inhibitor_refcount == 0);
|
||||
impl->idle_inhibitor =
|
||||
zwp_idle_inhibit_manager_v1_create_inhibitor (display_wayland->idle_inhibit_manager,
|
||||
impl->display_server.wl_surface);
|
||||
g_assert (wayland_toplevel->idle_inhibitor &&
|
||||
wayland_toplevel->idle_inhibitor_refcount > 0);
|
||||
|
||||
wayland_toplevel->idle_inhibitor =
|
||||
zwp_idle_inhibit_manager_v1_create_inhibitor (display_wayland->idle_inhibit_manager,
|
||||
gdk_wayland_surface_get_wl_surface (GDK_SURFACE (wayland_toplevel)));
|
||||
}
|
||||
++impl->idle_inhibitor_refcount;
|
||||
++wayland_toplevel->idle_inhibitor_refcount;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2296,14 +2298,19 @@ gdk_wayland_toplevel_inhibit_idle (GdkToplevel *toplevel)
|
||||
void
|
||||
gdk_wayland_toplevel_uninhibit_idle (GdkToplevel *toplevel)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (toplevel);
|
||||
GdkWaylandToplevel *wayland_toplevel;
|
||||
|
||||
g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel));
|
||||
wayland_toplevel = GDK_WAYLAND_TOPLEVEL (toplevel);
|
||||
|
||||
g_assert (impl->idle_inhibitor && impl->idle_inhibitor_refcount > 0);
|
||||
g_assert (wayland_toplevel->idle_inhibitor &&
|
||||
wayland_toplevel->idle_inhibitor_refcount > 0);
|
||||
|
||||
if (--impl->idle_inhibitor_refcount == 0)
|
||||
g_clear_pointer (&impl->idle_inhibitor, zwp_idle_inhibitor_v1_destroy);
|
||||
if (--wayland_toplevel->idle_inhibitor_refcount == 0)
|
||||
{
|
||||
g_clear_pointer (&wayland_toplevel->idle_inhibitor,
|
||||
zwp_idle_inhibitor_v1_destroy);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2850,8 +2857,7 @@ gdk_wayland_surface_map_toplevel (GdkSurface *surface)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_surface_show (GdkSurface *surface,
|
||||
gboolean already_mapped)
|
||||
gdk_wayland_surface_show (GdkSurface *surface)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
|
||||
@@ -4420,13 +4426,13 @@ xdg_exported_handle (void *data,
|
||||
const char *handle)
|
||||
{
|
||||
GdkToplevel *toplevel = data;
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (toplevel);
|
||||
GdkWaylandToplevel *wayland_toplevel = GDK_WAYLAND_TOPLEVEL (toplevel);
|
||||
|
||||
impl->exported.callback (toplevel, handle, impl->exported.user_data);
|
||||
if (impl->exported.destroy_func)
|
||||
wayland_toplevel->exported.callback (toplevel, handle, wayland_toplevel->exported.user_data);
|
||||
if (wayland_toplevel->exported.destroy_func)
|
||||
{
|
||||
g_clear_pointer (&impl->exported.user_data,
|
||||
impl->exported.destroy_func);
|
||||
g_clear_pointer (&wayland_toplevel->exported.user_data,
|
||||
wayland_toplevel->exported.destroy_func);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4450,9 +4456,9 @@ static const struct zxdg_exported_v1_listener xdg_exported_listener = {
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
gdk_wayland_surface_is_exported (GdkWaylandSurface *impl)
|
||||
gdk_wayland_toplevel_is_exported (GdkWaylandToplevel *wayland_toplevel)
|
||||
{
|
||||
return !!impl->display_server.xdg_exported;
|
||||
return !!wayland_toplevel->xdg_exported;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4489,7 +4495,8 @@ gdk_wayland_toplevel_export_handle (GdkToplevel *toplevel,
|
||||
gpointer user_data,
|
||||
GDestroyNotify destroy_func)
|
||||
{
|
||||
GdkWaylandSurface *impl;
|
||||
GdkWaylandToplevel *wayland_toplevel;
|
||||
GdkSurface *surface;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (toplevel));
|
||||
struct zxdg_exported_v1 *xdg_exported;
|
||||
@@ -4497,10 +4504,11 @@ gdk_wayland_toplevel_export_handle (GdkToplevel *toplevel,
|
||||
g_return_val_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel), FALSE);
|
||||
g_return_val_if_fail (GDK_IS_WAYLAND_DISPLAY (display), FALSE);
|
||||
|
||||
impl = GDK_WAYLAND_SURFACE (toplevel);
|
||||
wayland_toplevel = GDK_WAYLAND_TOPLEVEL (toplevel);
|
||||
surface = GDK_SURFACE (toplevel);
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
g_return_val_if_fail (!impl->display_server.xdg_exported, FALSE);
|
||||
g_return_val_if_fail (!wayland_toplevel->xdg_exported, FALSE);
|
||||
|
||||
if (!display_wayland->xdg_exporter)
|
||||
{
|
||||
@@ -4508,14 +4516,16 @@ gdk_wayland_toplevel_export_handle (GdkToplevel *toplevel,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xdg_exported = zxdg_exporter_v1_export (display_wayland->xdg_exporter,
|
||||
impl->display_server.wl_surface);
|
||||
zxdg_exported_v1_add_listener (xdg_exported, &xdg_exported_listener, impl);
|
||||
xdg_exported =
|
||||
zxdg_exporter_v1_export (display_wayland->xdg_exporter,
|
||||
gdk_wayland_surface_get_wl_surface (surface));
|
||||
zxdg_exported_v1_add_listener (xdg_exported, &xdg_exported_listener,
|
||||
wayland_toplevel);
|
||||
|
||||
impl->display_server.xdg_exported = xdg_exported;
|
||||
impl->exported.callback = callback;
|
||||
impl->exported.user_data = user_data;
|
||||
impl->exported.destroy_func = destroy_func;
|
||||
wayland_toplevel->xdg_exported = xdg_exported;
|
||||
wayland_toplevel->exported.callback = callback;
|
||||
wayland_toplevel->exported.user_data = user_data;
|
||||
wayland_toplevel->exported.destroy_func = destroy_func;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -4536,20 +4546,20 @@ gdk_wayland_toplevel_export_handle (GdkToplevel *toplevel,
|
||||
void
|
||||
gdk_wayland_toplevel_unexport_handle (GdkToplevel *toplevel)
|
||||
{
|
||||
GdkWaylandSurface *impl;
|
||||
GdkWaylandToplevel *wayland_toplevel;
|
||||
|
||||
g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel));
|
||||
|
||||
impl = GDK_WAYLAND_SURFACE (toplevel);
|
||||
wayland_toplevel = GDK_WAYLAND_TOPLEVEL (toplevel);
|
||||
|
||||
g_return_if_fail (impl->display_server.xdg_exported);
|
||||
g_return_if_fail (wayland_toplevel->xdg_exported);
|
||||
|
||||
g_clear_pointer (&impl->display_server.xdg_exported,
|
||||
g_clear_pointer (&wayland_toplevel->xdg_exported,
|
||||
zxdg_exported_v1_destroy);
|
||||
if (impl->exported.destroy_func)
|
||||
if (wayland_toplevel->exported.destroy_func)
|
||||
{
|
||||
g_clear_pointer (&impl->exported.user_data,
|
||||
impl->exported.destroy_func);
|
||||
g_clear_pointer (&wayland_toplevel->exported.user_data,
|
||||
wayland_toplevel->exported.destroy_func);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4925,6 +4935,21 @@ gdk_wayland_toplevel_get_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_toplevel_finalize (GObject *object)
|
||||
{
|
||||
GdkWaylandToplevel *wayland_toplevel;
|
||||
|
||||
g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (object));
|
||||
|
||||
wayland_toplevel = GDK_WAYLAND_TOPLEVEL (object);
|
||||
|
||||
if (gdk_wayland_toplevel_is_exported (wayland_toplevel))
|
||||
gdk_wayland_toplevel_unexport_handle (GDK_TOPLEVEL (wayland_toplevel));
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_toplevel_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_toplevel_class_init (GdkWaylandToplevelClass *class)
|
||||
{
|
||||
@@ -4932,6 +4957,7 @@ gdk_wayland_toplevel_class_init (GdkWaylandToplevelClass *class)
|
||||
|
||||
object_class->get_property = gdk_wayland_toplevel_get_property;
|
||||
object_class->set_property = gdk_wayland_toplevel_set_property;
|
||||
object_class->finalize = gdk_wayland_toplevel_finalize;
|
||||
|
||||
gdk_toplevel_install_properties (object_class, 1);
|
||||
}
|
||||
@@ -4977,7 +5003,7 @@ gdk_wayland_toplevel_present (GdkToplevel *toplevel,
|
||||
g_clear_pointer (&impl->toplevel.layout, gdk_toplevel_layout_unref);
|
||||
impl->toplevel.layout = gdk_toplevel_layout_copy (layout);
|
||||
|
||||
gdk_wayland_surface_show (surface, FALSE);
|
||||
gdk_wayland_surface_show (surface);
|
||||
|
||||
if (!pending_configure)
|
||||
{
|
||||
@@ -5125,7 +5151,7 @@ gdk_wayland_drag_surface_present (GdkDragSurface *drag_surface,
|
||||
GdkSurface *surface = GDK_SURFACE (drag_surface);
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
|
||||
gdk_wayland_surface_show (surface, FALSE);
|
||||
gdk_wayland_surface_show (surface);
|
||||
|
||||
impl->next_layout.configured_width = width;
|
||||
impl->next_layout.configured_height = height;
|
||||
|
||||
@@ -100,15 +100,6 @@ gdk_device_win32_query_state (GdkDevice *device,
|
||||
if (win_y)
|
||||
*win_y = point.y / scale;
|
||||
|
||||
if (window)
|
||||
{
|
||||
if (win_x)
|
||||
*win_x += _gdk_offset_x;
|
||||
|
||||
if (win_y)
|
||||
*win_y += _gdk_offset_y;
|
||||
}
|
||||
|
||||
if (hwnd && child_window)
|
||||
{
|
||||
hwndc = ChildWindowFromPoint (hwnd, point);
|
||||
|
||||
@@ -91,15 +91,6 @@ gdk_device_winpointer_query_state (GdkDevice *device,
|
||||
if (win_y)
|
||||
*win_y = point.y / scale;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
if (win_x)
|
||||
*win_x += _gdk_offset_x;
|
||||
|
||||
if (win_y)
|
||||
*win_y += _gdk_offset_y;
|
||||
}
|
||||
|
||||
if (hwnd && child_window)
|
||||
{
|
||||
hwndc = ChildWindowFromPoint (hwnd, point);
|
||||
|
||||
@@ -99,15 +99,6 @@ gdk_device_wintab_query_state (GdkDevice *device,
|
||||
if (win_y)
|
||||
*win_y = point.y / scale;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
if (win_x)
|
||||
*win_x += _gdk_offset_x;
|
||||
|
||||
if (win_y)
|
||||
*win_y += _gdk_offset_y;
|
||||
}
|
||||
|
||||
if (hwnd && child_window)
|
||||
{
|
||||
hwndc = ChildWindowFromPoint (hwnd, point);
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <dwmapi.h>
|
||||
|
||||
#include "gdkwin32langnotification.h"
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
#ifdef HAVE_EGL
|
||||
# include <epoxy/egl.h>
|
||||
#endif
|
||||
|
||||
@@ -645,14 +645,6 @@ gdk_win32_display_dispose (GObject *object)
|
||||
{
|
||||
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (object);
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
if (display_win32->egl_disp != EGL_NO_DISPLAY)
|
||||
{
|
||||
eglTerminate (display_win32->egl_disp);
|
||||
display_win32->egl_disp = EGL_NO_DISPLAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (display_win32->hwnd != NULL)
|
||||
{
|
||||
if (display_win32->dummy_context_wgl.hglrc != NULL)
|
||||
@@ -1146,23 +1138,54 @@ gdk_win32_display_get_setting (GdkDisplay *display,
|
||||
return _gdk_win32_get_setting (name, value);
|
||||
}
|
||||
|
||||
#ifndef EGL_PLATFORM_ANGLE_ANGLE
|
||||
#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
gdk_win32_display_init_gl_backend (GdkDisplay *display,
|
||||
GError **error)
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
|
||||
|
||||
/* No env vars set, do the regular GL initialization, first WGL and then EGL,
|
||||
if (display_win32->dummy_context_wgl.hdc == NULL)
|
||||
display_win32->dummy_context_wgl.hdc = GetDC (display_win32->hwnd);
|
||||
|
||||
/*
|
||||
* No env vars set, do the regular GL initialization, first WGL and then EGL,
|
||||
* as WGL is the more tried-and-tested configuration.
|
||||
*/
|
||||
|
||||
result = gdk_win32_display_init_wgl (display, error);
|
||||
#ifdef HAVE_EGL
|
||||
/*
|
||||
* Disable defaulting to EGL for now, since shaders need to be fixed for
|
||||
* usage against libANGLE EGL. EGL is used more as a compatibility layer
|
||||
* on Windows rather than being a native citizen on Windows
|
||||
*/
|
||||
if (_gdk_debug_flags & GDK_DEBUG_GL_EGL)
|
||||
result = gdk_display_init_egl (display,
|
||||
EGL_PLATFORM_ANGLE_ANGLE,
|
||||
display_win32->dummy_context_wgl.hdc,
|
||||
FALSE,
|
||||
error);
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
if (!result)
|
||||
{
|
||||
g_clear_error (error);
|
||||
result = gdk_win32_display_init_egl (display, error);
|
||||
result = gdk_win32_display_init_wgl (display, error);
|
||||
}
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
if (!result)
|
||||
{
|
||||
g_clear_error (error);
|
||||
result = gdk_display_init_egl (display,
|
||||
EGL_PLATFORM_ANGLE_ANGLE,
|
||||
display_win32->dummy_context_wgl.hdc,
|
||||
TRUE,
|
||||
error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1179,13 +1202,12 @@ gdk_win32_display_init_gl (GdkDisplay *display,
|
||||
if (!gdk_win32_display_init_gl_backend (display, error))
|
||||
return NULL;
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
if (display_win32->egl_disp)
|
||||
gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, "display", display, NULL);
|
||||
else
|
||||
#endif
|
||||
if (display_win32->wgl_pixel_format != 0)
|
||||
gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_WGL, "display", display, NULL);
|
||||
#ifdef HAVE_EGL
|
||||
else if (gdk_display_get_egl_display (display))
|
||||
gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, "display", display, NULL);
|
||||
#endif
|
||||
|
||||
g_return_val_if_fail (gl_context != NULL, NULL);
|
||||
|
||||
@@ -1203,23 +1225,9 @@ gdk_win32_display_init_gl (GdkDisplay *display,
|
||||
gpointer
|
||||
gdk_win32_display_get_egl_display (GdkDisplay *display)
|
||||
{
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
GdkWin32Display *display_win32;
|
||||
#endif
|
||||
|
||||
g_return_val_if_fail (GDK_IS_WIN32_DISPLAY (display), NULL);
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
display_win32 = GDK_WIN32_DISPLAY (display);
|
||||
|
||||
if (display_win32->wgl_pixel_format != 0)
|
||||
return NULL;
|
||||
|
||||
return display_win32->egl_disp;
|
||||
#else
|
||||
/* no EGL support */
|
||||
return NULL;
|
||||
#endif
|
||||
return gdk_display_get_egl_display (display);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "gdkwin32screen.h"
|
||||
#include "gdkwin32cursor.h"
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
#ifdef HAVE_EGL
|
||||
# include <epoxy/egl.h>
|
||||
#endif
|
||||
|
||||
@@ -135,14 +135,6 @@ struct _GdkWin32Display
|
||||
int wgl_pixel_format;
|
||||
guint gl_version;
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
/* EGL (Angle) Items */
|
||||
guint egl_version;
|
||||
EGLDisplay egl_disp;
|
||||
EGLConfig egl_config;
|
||||
HDC hdc_egl_temp;
|
||||
#endif
|
||||
|
||||
GListModel *monitors;
|
||||
|
||||
guint hasWglARBCreateContext : 1;
|
||||
@@ -151,7 +143,7 @@ struct _GdkWin32Display
|
||||
guint hasWglARBPixelFormat : 1;
|
||||
guint hasWglARBmultisample : 1;
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
#ifdef HAVE_EGL
|
||||
guint hasEglKHRCreateContext : 1;
|
||||
guint hasEglSurfacelessContext : 1;
|
||||
EGLint egl_min_swap_interval;
|
||||
|
||||
@@ -2082,8 +2082,8 @@ gdk_dnd_handle_motion_event (GdkDrag *drag,
|
||||
API_CALL (PostThreadMessage, (clipdrop->dnd_thread_id,
|
||||
WM_MOUSEMOVE,
|
||||
key_state,
|
||||
MAKELPARAM (x_root * drag_win32->scale - _gdk_offset_x,
|
||||
y_root * drag_win32->scale - _gdk_offset_y)));
|
||||
MAKELPARAM (x_root * drag_win32->scale,
|
||||
y_root * drag_win32->scale)));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -425,14 +425,9 @@ set_source_actions_helper (GdkDrop *drop,
|
||||
return actions;
|
||||
}
|
||||
|
||||
/* Utility function to translate win32 screen coordinates to
|
||||
* client coordinates (i.e. relative to the surface origin)
|
||||
*
|
||||
* Note that input is expected to be:
|
||||
* a) NOT scaled by dpi_scale
|
||||
* b) NOT translated by the GDK screen offset (gdk_offset_x / y)
|
||||
*
|
||||
* This utility function preserves subpixel precision
|
||||
/* Utility function to translate screen coordinates to surface-relative
|
||||
* coordinates. This routine only works with pixel values that aren't
|
||||
* scaled by any GDK DPI scale factor.
|
||||
*/
|
||||
static void
|
||||
unscaled_screen_to_client (GdkSurface* surface,
|
||||
@@ -514,8 +509,8 @@ idroptarget_dragenter (LPDROPTARGET This,
|
||||
grfKeyState);
|
||||
|
||||
set_data_object (&ctx->data_object, pDataObj);
|
||||
pt_x = pt.x / drop_win32->scale + _gdk_offset_x;
|
||||
pt_y = pt.y / drop_win32->scale + _gdk_offset_y;
|
||||
pt_x = pt.x / drop_win32->scale;
|
||||
pt_y = pt.y / drop_win32->scale;
|
||||
|
||||
unscaled_screen_to_client (ctx->surface, pt.x, pt.y, &x, &y);
|
||||
x /= drop_win32->scale;
|
||||
@@ -554,8 +549,8 @@ idroptarget_dragover (LPDROPTARGET This,
|
||||
{
|
||||
drop_target_context *ctx = (drop_target_context *) This;
|
||||
GdkWin32Drop *drop_win32 = GDK_WIN32_DROP (ctx->drop);
|
||||
int pt_x = pt.x / drop_win32->scale + _gdk_offset_x;
|
||||
int pt_y = pt.y / drop_win32->scale + _gdk_offset_y;
|
||||
int pt_x = pt.x / drop_win32->scale;
|
||||
int pt_y = pt.y / drop_win32->scale;
|
||||
GdkDragAction source_actions;
|
||||
GdkDragAction dest_actions;
|
||||
|
||||
@@ -624,8 +619,6 @@ idroptarget_drop (LPDROPTARGET This,
|
||||
{
|
||||
drop_target_context *ctx = (drop_target_context *) This;
|
||||
GdkWin32Drop *drop_win32 = GDK_WIN32_DROP (ctx->drop);
|
||||
int pt_x = pt.x / drop_win32->scale + _gdk_offset_x;
|
||||
int pt_y = pt.y / drop_win32->scale + _gdk_offset_y;
|
||||
double x = 0.0;
|
||||
double y = 0.0;
|
||||
GdkDragAction dest_action;
|
||||
|
||||
@@ -1291,13 +1291,12 @@ make_crossing_event (GdkDevice *physical_device,
|
||||
}
|
||||
|
||||
/* Acquires actual client area size of the underlying native window.
|
||||
* Rectangle is in GDK screen coordinates (_gdk_offset_* is added).
|
||||
* Returns FALSE if configure events should be inhibited,
|
||||
* TRUE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
_gdk_win32_get_window_rect (GdkSurface *window,
|
||||
RECT *rect)
|
||||
RECT *rect)
|
||||
{
|
||||
RECT client_rect;
|
||||
POINT point;
|
||||
@@ -1312,11 +1311,7 @@ _gdk_win32_get_window_rect (GdkSurface *window,
|
||||
|
||||
/* top level windows need screen coords */
|
||||
if (GDK_IS_TOPLEVEL (window))
|
||||
{
|
||||
ClientToScreen (hwnd, &point);
|
||||
point.x += _gdk_offset_x * impl->surface_scale;
|
||||
point.y += _gdk_offset_y * impl->surface_scale;
|
||||
}
|
||||
ClientToScreen (hwnd, &point);
|
||||
|
||||
rect->left = point.x;
|
||||
rect->top = point.y;
|
||||
@@ -2410,15 +2405,15 @@ gdk_event_translate (MSG *msg,
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
|
||||
/* If we haven't moved, don't create any GDK event. Windows
|
||||
* sends WM_MOUSEMOVE messages after a new window is shows under
|
||||
* sends WM_MOUSEMOVE messages after a new window is shown under
|
||||
* the mouse, even if the mouse hasn't moved. This disturbs gtk.
|
||||
*/
|
||||
if ((msg->pt.x + _gdk_offset_x) / impl->surface_scale == current_root_x &&
|
||||
(msg->pt.y + _gdk_offset_y) / impl->surface_scale == current_root_y)
|
||||
break;
|
||||
if (msg->pt.x / impl->surface_scale == current_root_x &&
|
||||
msg->pt.y / impl->surface_scale == current_root_y)
|
||||
break;
|
||||
|
||||
current_root_x = (msg->pt.x + _gdk_offset_x) / impl->surface_scale;
|
||||
current_root_y = (msg->pt.y + _gdk_offset_y) / impl->surface_scale;
|
||||
current_root_x = msg->pt.x / impl->surface_scale;
|
||||
current_root_y = msg->pt.y / impl->surface_scale;
|
||||
|
||||
if (impl->drag_move_resize_context.op != GDK_WIN32_DRAGOP_NONE)
|
||||
gdk_win32_surface_do_move_resize_drag (window, current_root_x, current_root_y);
|
||||
|
||||
@@ -53,30 +53,6 @@ typedef struct _GdkWin32GLContextClass GdkWin32GLContextEGLClass;
|
||||
|
||||
G_DEFINE_TYPE (GdkWin32GLContextEGL, gdk_win32_gl_context_egl, GDK_TYPE_WIN32_GL_CONTEXT)
|
||||
|
||||
static void
|
||||
gdk_win32_gl_context_egl_dispose (GObject *gobject)
|
||||
{
|
||||
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
|
||||
GdkWin32GLContextEGL *context_egl = GDK_WIN32_GL_CONTEXT_EGL (gobject);
|
||||
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (gdk_gl_context_get_display (context));
|
||||
GdkSurface *surface = gdk_gl_context_get_surface (context);
|
||||
|
||||
if (display_win32 != NULL)
|
||||
{
|
||||
if (eglGetCurrentContext () == context_egl->egl_context)
|
||||
eglMakeCurrent(display_win32->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
|
||||
GDK_NOTE (OPENGL, g_message ("Destroying EGL (ANGLE) context"));
|
||||
|
||||
eglDestroyContext (display_win32->egl_disp,
|
||||
context_egl->egl_context);
|
||||
context_egl->egl_context = EGL_NO_CONTEXT;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gdk_win32_gl_context_egl_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_egl_force_redraw (GdkSurface *surface)
|
||||
{
|
||||
@@ -109,7 +85,7 @@ gdk_win32_gl_context_egl_end_frame (GdkDrawContext *draw_context,
|
||||
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
|
||||
GdkWin32GLContextEGL *context_egl = GDK_WIN32_GL_CONTEXT_EGL (context);
|
||||
GdkSurface *surface = gdk_gl_context_get_surface (context);
|
||||
GdkWin32Display *display_win32 = (GDK_WIN32_DISPLAY (gdk_gl_context_get_display (context)));
|
||||
GdkDisplay *display = gdk_gl_context_get_display (context);
|
||||
cairo_rectangle_int_t whole_window;
|
||||
EGLSurface egl_surface;
|
||||
|
||||
@@ -122,7 +98,7 @@ gdk_win32_gl_context_egl_end_frame (GdkDrawContext *draw_context,
|
||||
gdk_surface_get_height (surface)
|
||||
};
|
||||
|
||||
egl_surface = gdk_win32_surface_get_egl_surface (surface, display_win32->egl_config, FALSE);
|
||||
egl_surface = gdk_surface_get_egl_surface (surface);
|
||||
|
||||
if (is_egl_force_redraw (surface))
|
||||
{
|
||||
@@ -135,338 +111,7 @@ gdk_win32_gl_context_egl_end_frame (GdkDrawContext *draw_context,
|
||||
reset_egl_force_redraw (surface);
|
||||
}
|
||||
|
||||
eglSwapBuffers (display_win32->egl_disp, egl_surface);
|
||||
}
|
||||
|
||||
#ifndef EGL_PLATFORM_ANGLE_ANGLE
|
||||
#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
|
||||
#endif
|
||||
|
||||
#ifndef EGL_PLATFORM_ANGLE_TYPE_ANGLE
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
|
||||
#endif
|
||||
|
||||
#ifndef EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
|
||||
#endif
|
||||
|
||||
static EGLDisplay
|
||||
gdk_win32_get_egl_display (GdkWin32Display *display)
|
||||
{
|
||||
EGLDisplay disp;
|
||||
|
||||
if (epoxy_has_egl_extension (NULL, "EGL_EXT_platform_base"))
|
||||
{
|
||||
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay = (void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
|
||||
if (getPlatformDisplay)
|
||||
{
|
||||
EGLint disp_attr[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_NONE};
|
||||
|
||||
disp = getPlatformDisplay (EGL_PLATFORM_ANGLE_ANGLE, display->hdc_egl_temp, disp_attr);
|
||||
|
||||
if (disp != EGL_NO_DISPLAY)
|
||||
return disp;
|
||||
}
|
||||
}
|
||||
|
||||
return eglGetDisplay (display->hdc_egl_temp);
|
||||
}
|
||||
|
||||
#define MAX_EGL_ATTRS 30
|
||||
|
||||
static gboolean
|
||||
find_eglconfig_for_window (GdkWin32Display *display,
|
||||
EGLConfig *egl_config_out,
|
||||
EGLint *min_swap_interval_out,
|
||||
GError **error)
|
||||
{
|
||||
EGLint attrs[MAX_EGL_ATTRS];
|
||||
EGLint count;
|
||||
EGLConfig *configs, chosen_config;
|
||||
|
||||
int i = 0;
|
||||
|
||||
EGLDisplay egl_disp = display->egl_disp;
|
||||
|
||||
attrs[i++] = EGL_CONFORMANT;
|
||||
attrs[i++] = EGL_OPENGL_ES2_BIT;
|
||||
attrs[i++] = EGL_SURFACE_TYPE;
|
||||
attrs[i++] = EGL_WINDOW_BIT;
|
||||
|
||||
attrs[i++] = EGL_COLOR_BUFFER_TYPE;
|
||||
attrs[i++] = EGL_RGB_BUFFER;
|
||||
|
||||
attrs[i++] = EGL_RED_SIZE;
|
||||
attrs[i++] = 1;
|
||||
attrs[i++] = EGL_GREEN_SIZE;
|
||||
attrs[i++] = 1;
|
||||
attrs[i++] = EGL_BLUE_SIZE;
|
||||
attrs[i++] = 1;
|
||||
attrs[i++] = EGL_ALPHA_SIZE;
|
||||
attrs[i++] = 1;
|
||||
|
||||
attrs[i++] = EGL_NONE;
|
||||
g_assert (i < MAX_EGL_ATTRS);
|
||||
|
||||
if (!eglChooseConfig (display->egl_disp, attrs, NULL, 0, &count) || count < 1)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
|
||||
_("No available configurations for the given pixel format"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
configs = g_new (EGLConfig, count);
|
||||
|
||||
if (!eglChooseConfig (display->egl_disp, attrs, configs, count, &count) || count < 1)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
|
||||
_("No available configurations for the given pixel format"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Pick first valid configuration i guess? */
|
||||
chosen_config = configs[0];
|
||||
|
||||
if (!eglGetConfigAttrib (display->egl_disp, chosen_config,
|
||||
EGL_MIN_SWAP_INTERVAL, min_swap_interval_out))
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
"Could not retrieve the minimum swap interval");
|
||||
g_free (configs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (egl_config_out != NULL)
|
||||
*egl_config_out = chosen_config;
|
||||
|
||||
g_free (configs);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_win32_display_init_egl (GdkDisplay *display,
|
||||
GError **error)
|
||||
{
|
||||
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
|
||||
int best_idx = 0;
|
||||
EGLDisplay egl_disp;
|
||||
|
||||
if (!gdk_gl_backend_can_be_used (GDK_GL_EGL, error))
|
||||
return FALSE;
|
||||
|
||||
if (display_win32->egl_disp != EGL_NO_DISPLAY)
|
||||
return TRUE;
|
||||
|
||||
egl_disp = gdk_win32_get_egl_display (display_win32);
|
||||
|
||||
if (egl_disp == EGL_NO_DISPLAY)
|
||||
return FALSE;
|
||||
|
||||
if (!eglInitialize (egl_disp, NULL, NULL))
|
||||
{
|
||||
eglTerminate (egl_disp);
|
||||
egl_disp = EGL_NO_DISPLAY;
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("No GL implementation is available"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
display_win32->egl_disp = egl_disp;
|
||||
display_win32->egl_version = epoxy_egl_version (egl_disp);
|
||||
|
||||
eglBindAPI (EGL_OPENGL_ES_API);
|
||||
|
||||
display_win32->hasEglSurfacelessContext =
|
||||
epoxy_has_egl_extension (egl_disp, "EGL_KHR_surfaceless_context");
|
||||
|
||||
GDK_NOTE (OPENGL,
|
||||
g_print ("EGL API version %d.%d found\n"
|
||||
" - Vendor: %s\n"
|
||||
" - Checked extensions:\n"
|
||||
"\t* EGL_KHR_surfaceless_context: %s\n",
|
||||
display_win32->egl_version / 10,
|
||||
display_win32->egl_version % 10,
|
||||
eglQueryString (display_win32->egl_disp, EGL_VENDOR),
|
||||
display_win32->hasEglSurfacelessContext ? "yes" : "no"));
|
||||
|
||||
return find_eglconfig_for_window (display_win32, &display_win32->egl_config,
|
||||
&display_win32->egl_min_swap_interval, error);
|
||||
}
|
||||
|
||||
#define N_EGL_ATTRS 16
|
||||
|
||||
static EGLContext
|
||||
create_egl_context (EGLDisplay display,
|
||||
EGLConfig config,
|
||||
GdkGLContext *share,
|
||||
int flags,
|
||||
int major,
|
||||
int minor,
|
||||
gboolean *is_legacy)
|
||||
{
|
||||
EGLContext ctx;
|
||||
EGLint context_attribs[N_EGL_ATTRS];
|
||||
int i = 0;
|
||||
|
||||
/* ANGLE does not support the GL_OES_vertex_array_object extension, so we need to use ES3 directly */
|
||||
context_attribs[i++] = EGL_CONTEXT_CLIENT_VERSION;
|
||||
context_attribs[i++] = 3;
|
||||
|
||||
/* Specify the flags */
|
||||
context_attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
|
||||
context_attribs[i++] = flags;
|
||||
|
||||
context_attribs[i++] = EGL_NONE;
|
||||
g_assert (i < N_EGL_ATTRS);
|
||||
|
||||
ctx = eglCreateContext (display,
|
||||
config,
|
||||
share != NULL ? GDK_WIN32_GL_CONTEXT_EGL (share)->egl_context
|
||||
: EGL_NO_CONTEXT,
|
||||
context_attribs);
|
||||
|
||||
if (ctx != EGL_NO_CONTEXT)
|
||||
GDK_NOTE (OPENGL, g_message ("Created EGL context[%p]", ctx));
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_win32_gl_context_egl_realize (GdkGLContext *context,
|
||||
GError **error)
|
||||
{
|
||||
GdkWin32GLContextEGL *context_egl = GDK_WIN32_GL_CONTEXT_EGL (context);
|
||||
|
||||
gboolean debug_bit, compat_bit, legacy_bit;
|
||||
gboolean use_es = FALSE;
|
||||
EGLContext egl_context;
|
||||
EGLContext ctx;
|
||||
|
||||
/* request flags and specific versions for core (3.2+) WGL context */
|
||||
int flags = 0;
|
||||
int major = 0;
|
||||
int minor = 0;
|
||||
|
||||
GdkSurface *surface = gdk_gl_context_get_surface (context);
|
||||
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
|
||||
GdkDisplay *display = gdk_gl_context_get_display (context);
|
||||
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
|
||||
GdkGLContext *share = gdk_display_get_gl_context (display);
|
||||
|
||||
gdk_gl_context_get_required_version (context, &major, &minor);
|
||||
debug_bit = gdk_gl_context_get_debug_enabled (context);
|
||||
compat_bit = gdk_gl_context_get_forward_compatible (context);
|
||||
|
||||
/*
|
||||
* A legacy context cannot be shared with core profile ones, so this means we
|
||||
* must stick to a legacy context if the shared context is a legacy context
|
||||
*/
|
||||
|
||||
/* if GDK_GL_LEGACY is set, we default to a legacy context */
|
||||
legacy_bit = GDK_DISPLAY_DEBUG_CHECK (display, GL_LEGACY) ?
|
||||
TRUE :
|
||||
share != NULL && gdk_gl_context_is_legacy (share);
|
||||
|
||||
use_es = GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES) ||
|
||||
(share != NULL && gdk_gl_context_get_use_es (share));
|
||||
|
||||
if (debug_bit)
|
||||
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
|
||||
if (compat_bit)
|
||||
flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
|
||||
|
||||
GDK_NOTE (OPENGL, g_message ("Creating EGL context version %d.%d (debug:%s, forward:%s, legacy:%s)",
|
||||
major, minor,
|
||||
debug_bit ? "yes" : "no",
|
||||
compat_bit ? "yes" : "no",
|
||||
legacy_bit ? "yes" : "no"));
|
||||
|
||||
ctx = create_egl_context (display_win32->egl_disp,
|
||||
display_win32->egl_config,
|
||||
share,
|
||||
flags,
|
||||
major,
|
||||
minor,
|
||||
&legacy_bit);
|
||||
|
||||
if (ctx == EGL_NO_CONTEXT)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("Unable to create a GL context"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GDK_NOTE (OPENGL, g_print ("Created EGL context[%p]\n", ctx));
|
||||
|
||||
context_egl->egl_context = ctx;
|
||||
|
||||
/* We are using GLES here */
|
||||
gdk_gl_context_set_use_es (context, TRUE);
|
||||
|
||||
/* Ensure that any other context is created with a legacy bit set */
|
||||
gdk_gl_context_set_is_legacy (context, legacy_bit);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_win32_gl_context_egl_clear_current (GdkGLContext *context)
|
||||
{
|
||||
GdkDisplay *display = gdk_gl_context_get_display (context);
|
||||
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
|
||||
|
||||
if (display_win32->egl_disp != EGL_NO_DISPLAY)
|
||||
return eglMakeCurrent (display_win32->egl_disp,
|
||||
EGL_NO_SURFACE,
|
||||
EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_win32_gl_context_egl_make_current (GdkGLContext *context,
|
||||
gboolean surfaceless)
|
||||
{
|
||||
GdkWin32GLContextEGL *context_egl = GDK_WIN32_GL_CONTEXT_EGL (context);
|
||||
GdkDisplay *display = gdk_gl_context_get_display (context);
|
||||
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
|
||||
GdkSurface *surface;
|
||||
|
||||
gboolean do_frame_sync = FALSE;
|
||||
|
||||
EGLSurface egl_surface;
|
||||
|
||||
surface = gdk_gl_context_get_surface (context);
|
||||
|
||||
if (!surfaceless)
|
||||
egl_surface = gdk_win32_surface_get_egl_surface (surface, display_win32->egl_config, FALSE);
|
||||
else
|
||||
{
|
||||
if (display_win32->hasEglSurfacelessContext)
|
||||
egl_surface = EGL_NO_SURFACE;
|
||||
else
|
||||
egl_surface = gdk_win32_surface_get_egl_surface (surface, display_win32->egl_config, TRUE);
|
||||
}
|
||||
|
||||
if (!eglMakeCurrent (display_win32->egl_disp,
|
||||
egl_surface,
|
||||
egl_surface,
|
||||
context_egl->egl_context))
|
||||
return FALSE;
|
||||
|
||||
if (display_win32->egl_min_swap_interval == 0)
|
||||
eglSwapInterval (display_win32->egl_disp, 0);
|
||||
else
|
||||
g_debug ("Can't disable GL swap interval");
|
||||
|
||||
return TRUE;
|
||||
eglSwapBuffers (gdk_display_get_egl_display (display), egl_surface);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -484,18 +129,11 @@ gdk_win32_gl_context_egl_class_init (GdkWin32GLContextClass *klass)
|
||||
{
|
||||
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS(klass);
|
||||
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS(klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
context_class->backend_type = GDK_GL_EGL;
|
||||
|
||||
context_class->realize = gdk_win32_gl_context_egl_realize;
|
||||
context_class->make_current = gdk_win32_gl_context_egl_make_current;
|
||||
context_class->clear_current = gdk_win32_gl_context_egl_clear_current;
|
||||
|
||||
draw_context_class->begin_frame = gdk_win32_gl_context_egl_begin_frame;
|
||||
draw_context_class->end_frame = gdk_win32_gl_context_egl_end_frame;
|
||||
|
||||
gobject_class->dispose = gdk_win32_gl_context_egl_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -226,9 +226,6 @@ gdk_init_dummy_wgl_context (GdkWin32Display *display_win32)
|
||||
gboolean set_pixel_format_result = FALSE;
|
||||
int best_idx = 0;
|
||||
|
||||
if (display_win32->dummy_context_wgl.hdc == NULL)
|
||||
display_win32->dummy_context_wgl.hdc = GetDC (display_win32->hwnd);
|
||||
|
||||
memset (&pfd, 0, sizeof (PIXELFORMATDESCRIPTOR));
|
||||
|
||||
best_idx = get_wgl_pfd (display_win32->dummy_context_wgl.hdc, &pfd, NULL);
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <cairo.h>
|
||||
#include <epoxy/wgl.h>
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
#ifdef HAVE_EGL
|
||||
# include <epoxy/egl.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <epoxy/gl.h>
|
||||
#include <epoxy/wgl.h>
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
#ifdef HAVE_EGL
|
||||
# include <epoxy/egl.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
GdkDisplay *_gdk_display = NULL;
|
||||
GdkDeviceManagerWin32 *_gdk_device_manager = NULL;
|
||||
|
||||
int _gdk_offset_x, _gdk_offset_y;
|
||||
|
||||
HDC _gdk_display_hdc;
|
||||
HINSTANCE _gdk_dll_hinstance;
|
||||
HINSTANCE _gdk_app_hmodule;
|
||||
|
||||
@@ -563,7 +563,7 @@ enum_monitor (HMONITOR hmonitor,
|
||||
GdkWin32Monitor *w32mon;
|
||||
GdkMonitor *mon;
|
||||
GdkRectangle rect;
|
||||
guint scale;
|
||||
int scale;
|
||||
|
||||
memset (&dd_monitor, 0, sizeof (dd_monitor));
|
||||
dd_monitor.cb = sizeof (dd_monitor);
|
||||
@@ -673,9 +673,6 @@ enum_monitor (HMONITOR hmonitor,
|
||||
HMONITOR hmonitor;
|
||||
POINT pt;
|
||||
|
||||
/* Not subtracting _gdk_offset_x and _gdk_offset_y because they will only
|
||||
* be added later on, in _gdk_win32_display_get_monitor_list().
|
||||
*/
|
||||
pt.x = w32mon->work_rect.x + w32mon->work_rect.width / 2;
|
||||
pt.y = w32mon->work_rect.y + w32mon->work_rect.height / 2;
|
||||
hmonitor = MonitorFromPoint (pt, MONITOR_DEFAULTTONEAREST);
|
||||
@@ -772,45 +769,6 @@ _gdk_win32_display_get_monitor_list (GdkWin32Display *win32_display)
|
||||
prune_monitors (&data);
|
||||
}
|
||||
|
||||
_gdk_offset_x = G_MININT;
|
||||
_gdk_offset_y = G_MININT;
|
||||
|
||||
for (i = 0; i < data.monitors->len; i++)
|
||||
{
|
||||
GdkWin32Monitor *m;
|
||||
GdkRectangle rect;
|
||||
|
||||
m = g_ptr_array_index (data.monitors, i);
|
||||
|
||||
/* Calculate offset */
|
||||
gdk_monitor_get_geometry (GDK_MONITOR (m), &rect);
|
||||
_gdk_offset_x = MAX (_gdk_offset_x, -rect.x);
|
||||
_gdk_offset_y = MAX (_gdk_offset_y, -rect.y);
|
||||
}
|
||||
|
||||
GDK_NOTE (MISC, g_print ("Multi-monitor offset: (%d,%d)\n",
|
||||
_gdk_offset_x, _gdk_offset_y));
|
||||
|
||||
/* Translate monitor coords into GDK coordinate space */
|
||||
for (i = 0; i < data.monitors->len; i++)
|
||||
{
|
||||
GdkWin32Monitor *m;
|
||||
GdkRectangle rect;
|
||||
|
||||
m = g_ptr_array_index (data.monitors, i);
|
||||
|
||||
gdk_monitor_get_geometry (GDK_MONITOR (m), &rect);
|
||||
rect.x += _gdk_offset_x;
|
||||
rect.y += _gdk_offset_y;
|
||||
gdk_monitor_set_geometry (GDK_MONITOR (m), &rect);
|
||||
|
||||
m->work_rect.x += _gdk_offset_x;
|
||||
m->work_rect.y += _gdk_offset_y;
|
||||
|
||||
GDK_NOTE (MISC, g_print ("Monitor %d: %dx%d@%+d%+d\n", i,
|
||||
rect.width, rect.height, rect.x, rect.y));
|
||||
}
|
||||
|
||||
return data.monitors;
|
||||
}
|
||||
|
||||
|
||||
@@ -258,13 +258,6 @@ extern GdkDisplay *_gdk_display;
|
||||
|
||||
extern GdkDeviceManagerWin32 *_gdk_device_manager;
|
||||
|
||||
/* Offsets to add to Windows coordinates (which are relative to the
|
||||
* primary monitor's origin, and thus might be negative for monitors
|
||||
* to the left and/or above the primary monitor) to get GDK
|
||||
* coordinates, which should be non-negative on the whole screen.
|
||||
*/
|
||||
extern int _gdk_offset_x, _gdk_offset_y;
|
||||
|
||||
extern HDC _gdk_display_hdc;
|
||||
extern HINSTANCE _gdk_dll_hinstance;
|
||||
extern HINSTANCE _gdk_app_hmodule;
|
||||
|
||||
+55
-135
@@ -473,7 +473,6 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
|
||||
wchar_t *wtitle;
|
||||
int window_width, window_height;
|
||||
int window_x, window_y;
|
||||
int offset_x = 0, offset_y = 0;
|
||||
int real_x = 0, real_y = 0;
|
||||
GdkFrameClock *frame_clock;
|
||||
|
||||
@@ -528,8 +527,6 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
|
||||
dwExStyle = 0;
|
||||
owner = NULL;
|
||||
|
||||
offset_x = _gdk_offset_x;
|
||||
offset_y = _gdk_offset_y;
|
||||
/* MSDN: We need WS_CLIPCHILDREN and WS_CLIPSIBLINGS for GL Context Creation */
|
||||
dwStyle = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
|
||||
|
||||
@@ -561,8 +558,8 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
|
||||
|
||||
AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
|
||||
|
||||
real_x = (x - offset_x) * impl->surface_scale;
|
||||
real_y = (y - offset_y) * impl->surface_scale;
|
||||
real_x = x * impl->surface_scale;
|
||||
real_y = y * impl->surface_scale;
|
||||
|
||||
if (surface_type == GDK_SURFACE_TOPLEVEL)
|
||||
{
|
||||
@@ -627,8 +624,8 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
|
||||
GDK_NOTE (MISC, g_print ("... \"%s\" %dx%d@%+d%+d %p = %p\n",
|
||||
title,
|
||||
window_width, window_height,
|
||||
surface->x - offset_x,
|
||||
surface->y - offset_y,
|
||||
surface->x,
|
||||
surface->y,
|
||||
owner,
|
||||
hwndNew));
|
||||
|
||||
@@ -641,6 +638,7 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gdk_surface_set_egl_native_window (surface, (void *) impl->handle);
|
||||
if (display_win32->tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER)
|
||||
gdk_winpointer_initialize_surface (surface);
|
||||
|
||||
@@ -688,22 +686,6 @@ gdk_win32_surface_destroy (GdkSurface *window,
|
||||
gdk_win32_surface_set_transient_for (child, NULL);
|
||||
}
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
GdkWin32Display *display = GDK_WIN32_DISPLAY (gdk_surface_get_display (window));
|
||||
|
||||
/* Get rid of any EGLSurfaces that we might have created */
|
||||
if (surface->egl_surface != EGL_NO_SURFACE)
|
||||
{
|
||||
eglDestroySurface (display->egl_disp, surface->egl_surface);
|
||||
surface->egl_surface = EGL_NO_SURFACE;
|
||||
}
|
||||
if (surface->egl_dummy_surface != EGL_NO_SURFACE)
|
||||
{
|
||||
eglDestroySurface (display->egl_disp, surface->egl_dummy_surface);
|
||||
surface->egl_dummy_surface = EGL_NO_SURFACE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Remove ourself from our transient owner */
|
||||
if (surface->transient_owner != NULL)
|
||||
{
|
||||
@@ -712,6 +694,7 @@ gdk_win32_surface_destroy (GdkSurface *window,
|
||||
|
||||
if (!foreign_destroy)
|
||||
{
|
||||
gdk_surface_set_egl_native_window (window, NULL);
|
||||
window->destroyed = TRUE;
|
||||
DestroyWindow (GDK_SURFACE_HWND (window));
|
||||
}
|
||||
@@ -864,8 +847,8 @@ show_window_internal (GdkSurface *window,
|
||||
{
|
||||
GdkSurface *owner = surface->transient_owner;
|
||||
/* Center on transient parent */
|
||||
center_on_rect.left = (owner->x - _gdk_offset_x) * surface->surface_scale;
|
||||
center_on_rect.top = (owner->y - _gdk_offset_y) * surface->surface_scale;
|
||||
center_on_rect.left = owner->x * surface->surface_scale;
|
||||
center_on_rect.top = owner->y * surface->surface_scale;
|
||||
center_on_rect.right = center_on_rect.left + owner->width * surface->surface_scale;
|
||||
center_on_rect.bottom = center_on_rect.top + owner->height * surface->surface_scale;
|
||||
|
||||
@@ -1047,13 +1030,13 @@ gdk_win32_surface_do_move (GdkSurface *window,
|
||||
GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,0,0,"
|
||||
"NOACTIVATE|NOSIZE|NOZORDER)\n",
|
||||
GDK_SURFACE_HWND (window),
|
||||
(x - _gdk_offset_x) * impl->surface_scale,
|
||||
(y - _gdk_offset_y) * impl->surface_scale));
|
||||
x * impl->surface_scale,
|
||||
y * impl->surface_scale));
|
||||
|
||||
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
|
||||
SWP_NOZORDER_SPECIFIED,
|
||||
(x - _gdk_offset_x) * impl->surface_scale,
|
||||
(y - _gdk_offset_y) * impl->surface_scale,
|
||||
x * impl->surface_scale,
|
||||
y * impl->surface_scale,
|
||||
0, 0,
|
||||
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER));
|
||||
}
|
||||
@@ -1133,15 +1116,15 @@ gdk_win32_surface_do_move_resize (GdkSurface *window,
|
||||
GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%ld,%ld,"
|
||||
"NOACTIVATE|NOZORDER)\n",
|
||||
GDK_SURFACE_HWND (window),
|
||||
(x - _gdk_offset_x) * impl->surface_scale,
|
||||
(y - _gdk_offset_y) * impl->surface_scale,
|
||||
x * impl->surface_scale,
|
||||
y * impl->surface_scale,
|
||||
outer_rect.right - outer_rect.left,
|
||||
outer_rect.bottom - outer_rect.top));
|
||||
|
||||
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
|
||||
SWP_NOZORDER_SPECIFIED,
|
||||
(x - _gdk_offset_x) * impl->surface_scale,
|
||||
(y - _gdk_offset_y) * impl->surface_scale,
|
||||
x * impl->surface_scale,
|
||||
y * impl->surface_scale,
|
||||
outer_rect.right - outer_rect.left,
|
||||
outer_rect.bottom - outer_rect.top,
|
||||
SWP_NOACTIVATE | SWP_NOZORDER));
|
||||
@@ -1681,14 +1664,6 @@ gdk_win32_surface_get_geometry (GdkSurface *window,
|
||||
|
||||
rect.right = pt.x;
|
||||
rect.bottom = pt.y;
|
||||
|
||||
if (parent == NULL)
|
||||
{
|
||||
rect.left += _gdk_offset_x * impl->surface_scale;
|
||||
rect.top += _gdk_offset_y * impl->surface_scale;
|
||||
rect.right += _gdk_offset_x * impl->surface_scale;
|
||||
rect.bottom += _gdk_offset_y * impl->surface_scale;
|
||||
}
|
||||
}
|
||||
|
||||
if (x)
|
||||
@@ -1727,16 +1702,16 @@ gdk_win32_surface_get_root_coords (GdkSurface *window,
|
||||
ty = pt.y;
|
||||
|
||||
if (root_x)
|
||||
*root_x = (tx + _gdk_offset_x) / impl->surface_scale;
|
||||
*root_x = tx / impl->surface_scale;
|
||||
if (root_y)
|
||||
*root_y = (ty + _gdk_offset_y) / impl->surface_scale;
|
||||
*root_y = ty / impl->surface_scale;
|
||||
|
||||
GDK_NOTE (MISC, g_print ("gdk_win32_surface_get_root_coords: %p: %+d%+d %+d%+d\n",
|
||||
GDK_SURFACE_HWND (window),
|
||||
x * impl->surface_scale,
|
||||
y * impl->surface_scale,
|
||||
(tx + _gdk_offset_x) / impl->surface_scale,
|
||||
(ty + _gdk_offset_y) / impl->surface_scale));
|
||||
tx / impl->surface_scale,
|
||||
ty / impl->surface_scale));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -2302,95 +2277,87 @@ stash_window (GdkSurface *window,
|
||||
}
|
||||
|
||||
static void
|
||||
snap_up (GdkSurface *window)
|
||||
snap_up (GdkSurface *surface)
|
||||
{
|
||||
SHORT maxysize;
|
||||
int x, y;
|
||||
int width, height;
|
||||
GdkWin32Surface *impl;
|
||||
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
impl = GDK_WIN32_SURFACE (surface);
|
||||
|
||||
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_FULLUP;
|
||||
|
||||
stash_window (window, impl);
|
||||
stash_window (surface, impl);
|
||||
|
||||
maxysize = GetSystemMetrics (SM_CYVIRTUALSCREEN) / impl->surface_scale;
|
||||
x = y = 0;
|
||||
width = gdk_surface_get_width (window);
|
||||
width = gdk_surface_get_width (surface);
|
||||
|
||||
y = 0;
|
||||
height = maxysize;
|
||||
|
||||
x = x - impl->shadow.left;
|
||||
y = y - impl->shadow.top;
|
||||
x = surface->x - impl->shadow.left / impl->surface_scale;
|
||||
y = y - impl->shadow.top / impl->surface_scale;
|
||||
width += impl->shadow_x;
|
||||
height += impl->shadow_y;
|
||||
|
||||
/* XXX: FIXME, AeroSnap snap_up() not really working well,
|
||||
*
|
||||
* * The snap_up() puts the window at the top left corner.
|
||||
* * Without the following call, the height maximizes but we see a spew of
|
||||
* "GdkToplevelSize: geometry size (x,y) exceeds bounds" warnings
|
||||
*/
|
||||
compute_toplevel_size (window, TRUE, &width, &height);
|
||||
|
||||
gdk_win32_surface_move_resize (window, x, y, width, height);
|
||||
gdk_win32_surface_move_resize (surface, x, y, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
snap_left (GdkSurface *window,
|
||||
snap_left (GdkSurface *surface,
|
||||
GdkMonitor *monitor,
|
||||
GdkMonitor *snap_monitor)
|
||||
{
|
||||
GdkRectangle rect;
|
||||
GdkWin32Surface *impl;
|
||||
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
impl = GDK_WIN32_SURFACE (surface);
|
||||
|
||||
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_HALFLEFT;
|
||||
|
||||
gdk_win32_monitor_get_workarea (snap_monitor, &rect);
|
||||
|
||||
stash_window (window, impl);
|
||||
stash_window (surface, impl);
|
||||
|
||||
rect.width = rect.width / 2;
|
||||
|
||||
rect.x = rect.x - impl->shadow.left;
|
||||
rect.y = rect.y - impl->shadow.top;
|
||||
rect.x = rect.x - impl->shadow.left / impl->surface_scale;
|
||||
rect.y = rect.y - impl->shadow.top / impl->surface_scale;
|
||||
rect.width = rect.width + impl->shadow_x;
|
||||
rect.height = rect.height + impl->shadow_y;
|
||||
|
||||
gdk_win32_surface_move_resize (window,
|
||||
gdk_win32_surface_move_resize (surface,
|
||||
rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
}
|
||||
|
||||
static void
|
||||
snap_right (GdkSurface *window,
|
||||
snap_right (GdkSurface *surface,
|
||||
GdkMonitor *monitor,
|
||||
GdkMonitor *snap_monitor)
|
||||
{
|
||||
GdkRectangle rect;
|
||||
GdkWin32Surface *impl;
|
||||
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
impl = GDK_WIN32_SURFACE (surface);
|
||||
|
||||
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_HALFRIGHT;
|
||||
|
||||
gdk_win32_monitor_get_workarea (snap_monitor, &rect);
|
||||
|
||||
stash_window (window, impl);
|
||||
stash_window (surface, impl);
|
||||
|
||||
rect.width = rect.width / 2;
|
||||
rect.x += rect.width;
|
||||
|
||||
rect.x = rect.x - impl->shadow.left;
|
||||
rect.y = rect.y - impl->shadow.top;
|
||||
rect.x = rect.x - impl->shadow.left / impl->surface_scale;
|
||||
rect.y = rect.y - impl->shadow.top / impl->surface_scale;
|
||||
rect.width = rect.width + impl->shadow_x;
|
||||
rect.height = rect.height + impl->shadow_y;
|
||||
|
||||
gdk_win32_surface_move_resize (window,
|
||||
gdk_win32_surface_move_resize (surface,
|
||||
rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
}
|
||||
@@ -2883,8 +2850,8 @@ redraw_indicator (gpointer user_data)
|
||||
|
||||
last_draw = draw_indicator (context, context->draw_timestamp);
|
||||
|
||||
window_position.x = (context->indicator_window_rect.x - _gdk_offset_x) * impl->surface_scale;
|
||||
window_position.y = (context->indicator_window_rect.y - _gdk_offset_y) * impl->surface_scale;
|
||||
window_position.x = context->indicator_window_rect.x * impl->surface_scale;
|
||||
window_position.y = context->indicator_window_rect.y * impl->surface_scale;
|
||||
window_size.cx = context->indicator_window_rect.width * impl->surface_scale;
|
||||
window_size.cy = context->indicator_window_rect.height * impl->surface_scale;
|
||||
|
||||
@@ -3021,6 +2988,7 @@ update_fullup_indicator (GdkSurface *window,
|
||||
to.height = gdk_surface_get_height (window);
|
||||
|
||||
to.y = 0;
|
||||
to.x = window->x;
|
||||
to.height = maxysize;
|
||||
from = context->indicator_target;
|
||||
|
||||
@@ -3173,6 +3141,7 @@ start_indicator (GdkSurface *window,
|
||||
end_size.height = workarea.height;
|
||||
break;
|
||||
case GDK_WIN32_AEROSNAP_STATE_FULLUP:
|
||||
start_size.x = end_size.x = window->x;
|
||||
end_size.y = 0;
|
||||
end_size.height = maxysize;
|
||||
break;
|
||||
@@ -3575,8 +3544,8 @@ setup_drag_move_resize_context (GdkSurface *window,
|
||||
GDK_NOTE (MISC, g_print ("W32 WM unmaximized window placement is %ld x %ld @ %ld : %ld\n",
|
||||
placement.rcNormalPosition.right - placement.rcNormalPosition.left,
|
||||
placement.rcNormalPosition.bottom - placement.rcNormalPosition.top,
|
||||
placement.rcNormalPosition.left + _gdk_offset_x * impl->surface_scale,
|
||||
placement.rcNormalPosition.top + _gdk_offset_y * impl->surface_scale));
|
||||
placement.rcNormalPosition.left,
|
||||
placement.rcNormalPosition.top));
|
||||
|
||||
unmax_width = placement.rcNormalPosition.right - placement.rcNormalPosition.left;
|
||||
unmax_height = placement.rcNormalPosition.bottom - placement.rcNormalPosition.top;
|
||||
@@ -3587,40 +3556,36 @@ setup_drag_move_resize_context (GdkSurface *window,
|
||||
if (offsetx * impl->surface_scale < (shadow_unmax_width / 2) &&
|
||||
offsety * impl->surface_scale < (shadow_unmax_height / 2))
|
||||
{
|
||||
placement.rcNormalPosition.top = (root_y - offsety + impl->shadow.top - _gdk_offset_y) * impl->surface_scale;
|
||||
placement.rcNormalPosition.top = (root_y - offsety + impl->shadow.top) * impl->surface_scale;
|
||||
placement.rcNormalPosition.bottom = placement.rcNormalPosition.top + unmax_height;
|
||||
|
||||
if (left_half)
|
||||
{
|
||||
placement.rcNormalPosition.left = (root_x - offsetx + impl->shadow.left - _gdk_offset_x) * impl->surface_scale;
|
||||
placement.rcNormalPosition.left = (root_x - offsetx + impl->shadow.left) * impl->surface_scale;
|
||||
placement.rcNormalPosition.right = placement.rcNormalPosition.left + unmax_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
placement.rcNormalPosition.right = (root_x + offsetx + impl->shadow.right - _gdk_offset_x) * impl->surface_scale;
|
||||
placement.rcNormalPosition.right = (root_x + offsetx + impl->shadow.right) * impl->surface_scale;
|
||||
placement.rcNormalPosition.left = placement.rcNormalPosition.right - unmax_width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
placement.rcNormalPosition.left = (root_x * impl->surface_scale) -
|
||||
(unmax_width / 2) -
|
||||
(_gdk_offset_x * impl->surface_scale);
|
||||
placement.rcNormalPosition.left = root_x * impl->surface_scale - unmax_width / 2;
|
||||
|
||||
if (offsety * impl->surface_scale < shadow_unmax_height / 2)
|
||||
placement.rcNormalPosition.top = (root_y - offsety + impl->shadow.top - _gdk_offset_y) * impl->surface_scale;
|
||||
placement.rcNormalPosition.top = (root_y - offsety + impl->shadow.top) * impl->surface_scale;
|
||||
else
|
||||
placement.rcNormalPosition.top = (root_y * impl->surface_scale) -
|
||||
(unmax_height / 2) -
|
||||
(_gdk_offset_y * impl->surface_scale);
|
||||
placement.rcNormalPosition.top = root_y * impl->surface_scale - unmax_height / 2;
|
||||
|
||||
placement.rcNormalPosition.right = placement.rcNormalPosition.left + unmax_width;
|
||||
placement.rcNormalPosition.bottom = placement.rcNormalPosition.top + unmax_height;
|
||||
}
|
||||
|
||||
GDK_NOTE (MISC, g_print ("Unmaximized window will be at %ld : %ld\n",
|
||||
placement.rcNormalPosition.left + _gdk_offset_x * impl->surface_scale,
|
||||
placement.rcNormalPosition.top + _gdk_offset_y * impl->surface_scale));
|
||||
placement.rcNormalPosition.left,
|
||||
placement.rcNormalPosition.top));
|
||||
|
||||
API_CALL (SetWindowPlacement, (GDK_SURFACE_HWND (window), &placement));
|
||||
}
|
||||
@@ -3678,7 +3643,7 @@ setup_drag_move_resize_context (GdkSurface *window,
|
||||
* the titlebar is, if any.
|
||||
*/
|
||||
root_y = wy + wheight / 2;
|
||||
SetCursorPos (root_x - _gdk_offset_x, root_y - _gdk_offset_y);
|
||||
SetCursorPos (root_x, root_y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3799,12 +3764,6 @@ gdk_win32_get_window_size_and_position_from_client_rect (GdkSurface *window,
|
||||
/* Turn client area into window area */
|
||||
_gdk_win32_adjust_client_rect (window, window_rect);
|
||||
|
||||
/* Convert GDK screen coordinates to W32 desktop coordinates */
|
||||
window_rect->left -= _gdk_offset_x * impl->surface_scale;
|
||||
window_rect->right -= _gdk_offset_x * impl->surface_scale;
|
||||
window_rect->top -= _gdk_offset_y * impl->surface_scale;
|
||||
window_rect->bottom -= _gdk_offset_y * impl->surface_scale;
|
||||
|
||||
window_position->x = window_rect->left;
|
||||
window_position->y = window_rect->top;
|
||||
window_size->cx = window_rect->right - window_rect->left;
|
||||
@@ -5053,39 +5012,6 @@ gdk_win32_drag_surface_iface_init (GdkDragSurfaceInterface *iface)
|
||||
iface->present = gdk_win32_drag_surface_present;
|
||||
}
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
EGLSurface
|
||||
gdk_win32_surface_get_egl_surface (GdkSurface *surface,
|
||||
EGLConfig config,
|
||||
gboolean is_dummy)
|
||||
{
|
||||
GdkWin32Display *display = GDK_WIN32_DISPLAY (gdk_surface_get_display (surface));
|
||||
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
|
||||
|
||||
if (is_dummy)
|
||||
{
|
||||
if (impl->egl_dummy_surface == EGL_NO_SURFACE)
|
||||
{
|
||||
EGLint attribs[] = {EGL_WIDTH, 1, EGL_WIDTH, 1, EGL_NONE};
|
||||
impl->egl_dummy_surface = eglCreatePbufferSurface (display->egl_disp,
|
||||
config,
|
||||
attribs);
|
||||
}
|
||||
return impl->egl_dummy_surface;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (impl->egl_surface == EGL_NO_SURFACE)
|
||||
impl->egl_surface = eglCreateWindowSurface (display->egl_disp,
|
||||
config,
|
||||
GDK_SURFACE_HWND (surface),
|
||||
NULL);
|
||||
|
||||
return impl->egl_surface;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gdk_win32_surface_get_queued_window_rect (GdkSurface *surface,
|
||||
@@ -5100,12 +5026,6 @@ gdk_win32_surface_get_queued_window_rect (GdkSurface *surface,
|
||||
/* Turn client area into window area */
|
||||
_gdk_win32_adjust_client_rect (surface, &window_rect);
|
||||
|
||||
/* Convert GDK screen coordinates to W32 desktop coordinates */
|
||||
window_rect.left -= _gdk_offset_x * impl->surface_scale;
|
||||
window_rect.right -= _gdk_offset_x * impl->surface_scale;
|
||||
window_rect.top -= _gdk_offset_y * impl->surface_scale;
|
||||
window_rect.bottom -= _gdk_offset_y * impl->surface_scale;
|
||||
|
||||
*return_window_rect = window_rect;
|
||||
}
|
||||
|
||||
@@ -5170,7 +5090,7 @@ _gdk_win32_surface_invalidate_egl_framebuffer (GdkSurface *surface)
|
||||
* as we need to re-acquire the EGL surfaces that we rendered to upload to Cairo explicitly,
|
||||
* using gdk_window_invalidate_rect (), when we maximize or restore or use aerosnap
|
||||
*/
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
#ifdef HAVE_EGL
|
||||
if (surface->gl_paint_context != NULL && gdk_gl_context_get_use_es (surface->gl_paint_context))
|
||||
{
|
||||
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
#ifdef HAVE_EGL
|
||||
# include <epoxy/egl.h>
|
||||
#endif
|
||||
|
||||
@@ -338,9 +338,7 @@ struct _GdkWin32Surface
|
||||
RECT configured_rect;
|
||||
} next_layout;
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
EGLSurface egl_surface;
|
||||
EGLSurface egl_dummy_surface;
|
||||
#ifdef HAVE_EGL
|
||||
guint egl_force_redraw_all : 1;
|
||||
#endif
|
||||
};
|
||||
@@ -373,7 +371,7 @@ void gdk_win32_surface_move_resize (GdkSurface *window,
|
||||
RECT
|
||||
gdk_win32_surface_handle_queued_move_resize (GdkDrawContext *draw_context);
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
#ifdef HAVE_EGL
|
||||
EGLSurface gdk_win32_surface_get_egl_surface (GdkSurface *surface,
|
||||
EGLConfig config,
|
||||
gboolean is_dummy);
|
||||
|
||||
@@ -46,10 +46,7 @@ gdk_win32_public_headers = files([
|
||||
|
||||
install_headers(gdk_win32_public_headers, 'gdkwin32.h', subdir: 'gtk-4.0/gdk/win32/')
|
||||
|
||||
GDK_WIN32_EGL_CFLAGS = []
|
||||
|
||||
if have_egl
|
||||
GDK_WIN32_EGL_CFLAGS = ['-DGDK_WIN32_ENABLE_EGL']
|
||||
gdk_win32_sources += ['gdkglcontext-win32-egl.c']
|
||||
endif
|
||||
|
||||
@@ -67,6 +64,6 @@ libgdk_win32 = static_library('gdk-win32',
|
||||
'-DINSIDE_GDK_WIN32',
|
||||
'-D_WIN32_WINNT=0x0601',
|
||||
'-DWINVER=0x0601',
|
||||
] + GDK_WIN32_EGL_CFLAGS,
|
||||
],
|
||||
dependencies: [ gdk_deps, gdk_win32_deps ],
|
||||
)
|
||||
|
||||
@@ -59,16 +59,6 @@ gdk_x11_display_get_egl_display (GdkDisplay *display)
|
||||
return gdk_display_get_egl_display (display);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_gl_context_egl_begin_frame (GdkDrawContext *draw_context,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_x11_gl_context_egl_parent_class)->begin_frame (draw_context, prefers_high_depth, region);
|
||||
|
||||
glDrawBuffers (1, (GLenum[1]) { GL_BACK });
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_x11_gl_context_egl_make_current (GdkGLContext *context,
|
||||
gboolean surfaceless)
|
||||
@@ -107,13 +97,10 @@ static void
|
||||
gdk_x11_gl_context_egl_class_init (GdkX11GLContextEGLClass *klass)
|
||||
{
|
||||
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass);
|
||||
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass);
|
||||
|
||||
context_class->backend_type = GDK_GL_EGL;
|
||||
|
||||
context_class->make_current = gdk_x11_gl_context_egl_make_current;
|
||||
|
||||
draw_context_class->begin_frame = gdk_x11_gl_context_egl_begin_frame;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+10
-1
@@ -492,9 +492,18 @@ init_randr15 (GdkX11Screen *x11_screen)
|
||||
|
||||
if (output_info->crtc)
|
||||
{
|
||||
XRRCrtcInfo *crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
|
||||
XRRCrtcInfo *crtc;
|
||||
int j;
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources,
|
||||
output_info->crtc);
|
||||
if (gdk_x11_display_error_trap_pop (display))
|
||||
{
|
||||
XRRFreeOutputInfo (output_info);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < resources->nmode; j++)
|
||||
{
|
||||
XRRModeInfo *xmode = &resources->modes[j];
|
||||
|
||||
@@ -269,6 +269,8 @@ collect_reused_child_nodes (GskRenderer *renderer,
|
||||
case GSK_BLEND_NODE:
|
||||
case GSK_CROSS_FADE_NODE:
|
||||
case GSK_BLUR_NODE:
|
||||
case GSK_FILL_NODE:
|
||||
case GSK_STROKE_NODE:
|
||||
|
||||
default:
|
||||
|
||||
@@ -855,6 +857,8 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
|
||||
case GSK_CROSS_FADE_NODE:
|
||||
case GSK_BLUR_NODE:
|
||||
case GSK_GL_SHADER_NODE:
|
||||
case GSK_FILL_NODE:
|
||||
case GSK_STROKE_NODE:
|
||||
default:
|
||||
break; /* Fallback */
|
||||
}
|
||||
|
||||
+20
-9
@@ -28,10 +28,11 @@
|
||||
#include "gskglcompilerprivate.h"
|
||||
#include "gskglprogramprivate.h"
|
||||
|
||||
#define SHADER_VERSION_GLES 100
|
||||
#define SHADER_VERSION_GL2_LEGACY 110
|
||||
#define SHADER_VERSION_GL3_LEGACY 130
|
||||
#define SHADER_VERSION_GL3 150
|
||||
#define SHADER_VERSION_GLES "100"
|
||||
#define SHADER_VERSION_GLES3 "300 es"
|
||||
#define SHADER_VERSION_GL2_LEGACY "110"
|
||||
#define SHADER_VERSION_GL3_LEGACY "130"
|
||||
#define SHADER_VERSION_GL3 "150"
|
||||
|
||||
struct _GskGLCompiler
|
||||
{
|
||||
@@ -49,7 +50,7 @@ struct _GskGLCompiler
|
||||
|
||||
GArray *attrib_locations;
|
||||
|
||||
int glsl_version;
|
||||
const char *glsl_version;
|
||||
|
||||
guint gl3 : 1;
|
||||
guint gles : 1;
|
||||
@@ -98,7 +99,7 @@ gsk_gl_compiler_class_init (GskGLCompilerClass *klass)
|
||||
static void
|
||||
gsk_gl_compiler_init (GskGLCompiler *self)
|
||||
{
|
||||
self->glsl_version = 150;
|
||||
self->glsl_version = "150";
|
||||
self->attrib_locations = g_array_new (FALSE, FALSE, sizeof (GskGLProgramAttrib));
|
||||
self->all_preamble = g_bytes_ref (empty_bytes);
|
||||
self->vertex_preamble = g_bytes_ref (empty_bytes);
|
||||
@@ -127,8 +128,18 @@ gsk_gl_compiler_new (GskGLDriver *driver,
|
||||
|
||||
if (gdk_gl_context_get_use_es (context))
|
||||
{
|
||||
self->glsl_version = SHADER_VERSION_GLES;
|
||||
self->gles = TRUE;
|
||||
int maj, min;
|
||||
|
||||
/* for OpenGL/ES 3.0+, use "300 es" as our shader version */
|
||||
gdk_gl_context_get_version (context, &maj, &min);
|
||||
|
||||
if (maj >= 3)
|
||||
self->glsl_version = SHADER_VERSION_GLES3;
|
||||
else
|
||||
{
|
||||
self->glsl_version = SHADER_VERSION_GLES;
|
||||
self->gles = TRUE;
|
||||
}
|
||||
}
|
||||
else if (gdk_gl_context_is_legacy (context))
|
||||
{
|
||||
@@ -546,7 +557,7 @@ gsk_gl_compiler_compile (GskGLCompiler *self,
|
||||
|
||||
gsk_gl_command_queue_make_current (self->driver->command_queue);
|
||||
|
||||
g_snprintf (version, sizeof version, "#version %d\n", self->glsl_version);
|
||||
g_snprintf (version, sizeof version, "#version %s\n", self->glsl_version);
|
||||
|
||||
if (self->debug_shaders)
|
||||
debug = "#define GSK_DEBUG 1\n";
|
||||
|
||||
+11
-15
@@ -161,25 +161,27 @@ gsk_gl_glyph_library_create_surface (GskGLGlyphLibrary *self,
|
||||
|
||||
static void
|
||||
render_glyph (cairo_surface_t *surface,
|
||||
const cairo_scaled_font_t *scaled_font,
|
||||
const GskGLGlyphKey *key,
|
||||
const GskGLGlyphValue *value)
|
||||
{
|
||||
cairo_t *cr;
|
||||
cairo_glyph_t glyph;
|
||||
PangoGlyphString glyph_string;
|
||||
PangoGlyphInfo glyph_info;
|
||||
|
||||
g_assert (surface != NULL);
|
||||
g_assert (scaled_font != NULL);
|
||||
|
||||
cr = cairo_create (surface);
|
||||
cairo_set_scaled_font (cr, scaled_font);
|
||||
cairo_set_source_rgba (cr, 1, 1, 1, 1);
|
||||
|
||||
glyph.index = key->glyph;
|
||||
glyph.x = 0.25 * key->xshift - value->ink_rect.x;
|
||||
glyph.y = 0.25 * key->yshift - value->ink_rect.y;
|
||||
glyph_info.glyph = key->glyph;
|
||||
glyph_info.geometry.width = value->ink_rect.width * 1024;
|
||||
glyph_info.geometry.x_offset = 0.25 * key->xshift - value->ink_rect.x * 1024;
|
||||
glyph_info.geometry.y_offset = 0.25 * key->yshift - value->ink_rect.y * 1024;
|
||||
|
||||
cairo_show_glyphs (cr, &glyph, 1);
|
||||
glyph_string.num_glyphs = 1;
|
||||
glyph_string.glyphs = &glyph_info;
|
||||
|
||||
pango_cairo_show_glyph_string (cr, key->font, &glyph_string);
|
||||
cairo_destroy (cr);
|
||||
|
||||
cairo_surface_flush (surface);
|
||||
@@ -198,7 +200,6 @@ gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary *self,
|
||||
{
|
||||
GskGLTextureLibrary *tl = (GskGLTextureLibrary *)self;
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
cairo_scaled_font_t *scaled_font;
|
||||
cairo_surface_t *surface;
|
||||
guchar *pixel_data;
|
||||
guchar *free_data = NULL;
|
||||
@@ -211,11 +212,6 @@ gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary *self,
|
||||
g_assert (key != NULL);
|
||||
g_assert (value != NULL);
|
||||
|
||||
scaled_font = pango_cairo_font_get_scaled_font ((PangoCairoFont *)key->font);
|
||||
if G_UNLIKELY (scaled_font == NULL ||
|
||||
cairo_scaled_font_status (scaled_font) != CAIRO_STATUS_SUCCESS)
|
||||
return;
|
||||
|
||||
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
|
||||
|
||||
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
|
||||
@@ -223,7 +219,7 @@ gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary *self,
|
||||
key->glyph);
|
||||
|
||||
surface = gsk_gl_glyph_library_create_surface (self, stride, width, height, uwidth, uheight);
|
||||
render_glyph (surface, scaled_font, key, value);
|
||||
render_glyph (surface, key, value);
|
||||
|
||||
texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (value);
|
||||
|
||||
|
||||
@@ -3767,6 +3767,11 @@ gsk_gl_render_job_visit_node (GskGLRenderJob *job,
|
||||
gsk_gl_render_job_visit_as_fallback (job, node);
|
||||
break;
|
||||
|
||||
case GSK_FILL_NODE:
|
||||
case GSK_STROKE_NODE:
|
||||
gsk_gl_render_job_visit_as_fallback (job, node);
|
||||
break;
|
||||
|
||||
case GSK_NOT_A_RENDER_NODE:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
@@ -4073,7 +4078,7 @@ get_framebuffer_format (guint framebuffer)
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, framebuffer);
|
||||
glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
|
||||
framebuffer ? GL_COLOR_ATTACHMENT0
|
||||
: GL_BACK,
|
||||
: GL_BACK_LEFT,
|
||||
GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, &size);
|
||||
|
||||
if (size > 16)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
uniform vec4 u_geometry;
|
||||
|
||||
_NOPERSPECTIVE_ _OUT_ vec2 coord;
|
||||
_OUT_ vec2 coord;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
|
||||
@@ -29,7 +29,7 @@ uniform highp int u_num_color_stops; // Why? Because it works like this.
|
||||
uniform vec4 u_geometry;
|
||||
uniform float u_color_stops[MAX_COLOR_STOPS * 5];
|
||||
|
||||
_NOPERSPECTIVE_ _IN_ vec2 coord;
|
||||
_IN_ vec2 coord;
|
||||
|
||||
float get_offset(int index) {
|
||||
// u_color_stops[5 * index] makes Intel Windows driver crash.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// linear_gradient.glsl
|
||||
uniform vec4 u_points;
|
||||
|
||||
_NOPERSPECTIVE_ _OUT_ vec4 info;
|
||||
_OUT_ vec4 info;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
|
||||
@@ -53,7 +53,7 @@ uniform highp int u_num_color_stops; // Why? Because it works like this.
|
||||
uniform float u_color_stops[MAX_COLOR_STOPS * 5];
|
||||
uniform bool u_repeat;
|
||||
|
||||
_NOPERSPECTIVE_ _IN_ vec4 info;
|
||||
_IN_ vec4 info;
|
||||
|
||||
float get_offset(int index) {
|
||||
// u_color_stops[5 * index] makes Intel Windows driver crash.
|
||||
|
||||
@@ -5,12 +5,10 @@ precision highp float;
|
||||
#if defined(GSK_GLES) || defined(GSK_LEGACY)
|
||||
#define _OUT_ varying
|
||||
#define _IN_ varying
|
||||
#define _NOPERSPECTIVE_
|
||||
#define _GSK_ROUNDED_RECT_UNIFORM_ vec4[3]
|
||||
#else
|
||||
#define _OUT_ out
|
||||
#define _IN_ in
|
||||
#define _NOPERSPECTIVE_ noperspective
|
||||
#define _GSK_ROUNDED_RECT_UNIFORM_ GskRoundedRect
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
uniform vec4 u_geometry;
|
||||
|
||||
_NOPERSPECTIVE_ _OUT_ vec2 coord;
|
||||
_OUT_ vec2 coord;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
|
||||
@@ -32,7 +32,7 @@ uniform bool u_repeat;
|
||||
uniform vec2 u_range;
|
||||
uniform float u_color_stops[MAX_COLOR_STOPS * 5];
|
||||
|
||||
_NOPERSPECTIVE_ _IN_ vec2 coord;
|
||||
_IN_ vec2 coord;
|
||||
|
||||
float get_offset(int index) {
|
||||
// u_color_stops[5 * index] makes Intel Windows driver crash.
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#ifndef __GI_SCANNER__
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskPath, gsk_path_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskPathMeasure, gsk_path_measure_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskRenderer, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskRenderNode, gsk_render_node_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskTransform, gsk_transform_unref)
|
||||
|
||||
@@ -21,11 +21,15 @@
|
||||
#define __GSK_H_INSIDE__
|
||||
|
||||
#include <gsk/gskenums.h>
|
||||
#include <gsk/gskglshader.h>
|
||||
#include <gsk/gskpath.h>
|
||||
#include <gsk/gskpathbuilder.h>
|
||||
#include <gsk/gskpathmeasure.h>
|
||||
#include <gsk/gskrenderer.h>
|
||||
#include <gsk/gskrendernode.h>
|
||||
#include <gsk/gskroundedrect.h>
|
||||
#include <gsk/gskstroke.h>
|
||||
#include <gsk/gsktransform.h>
|
||||
#include <gsk/gskglshader.h>
|
||||
|
||||
#include <gsk/gskcairorenderer.h>
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gskboundingboxprivate.h"
|
||||
|
||||
GskBoundingBox *
|
||||
gsk_bounding_box_init (GskBoundingBox *self,
|
||||
const graphene_point_t *a,
|
||||
const graphene_point_t *b)
|
||||
{
|
||||
self->min.x = MIN (a->x, b->x);
|
||||
self->min.y = MIN (a->y, b->y);
|
||||
self->max.x = MAX (a->x, b->x);
|
||||
self->max.y = MAX (a->y, b->y);
|
||||
return self;
|
||||
}
|
||||
|
||||
GskBoundingBox *
|
||||
gsk_bounding_box_init_copy (GskBoundingBox *self,
|
||||
const GskBoundingBox *src)
|
||||
{
|
||||
self->min = src->min;
|
||||
self->max = src->max;
|
||||
return self;
|
||||
}
|
||||
|
||||
GskBoundingBox *
|
||||
gsk_bounding_box_init_from_rect (GskBoundingBox *self,
|
||||
const graphene_rect_t *bounds)
|
||||
{
|
||||
self->min = bounds->origin;
|
||||
self->max.x = bounds->origin.x + bounds->size.width;
|
||||
self->max.y = bounds->origin.y + bounds->size.height;
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_bounding_box_expand (GskBoundingBox *self,
|
||||
const graphene_point_t *p)
|
||||
{
|
||||
self->min.x = MIN (self->min.x, p->x);
|
||||
self->min.y = MIN (self->min.y, p->y);
|
||||
self->max.x = MAX (self->max.x, p->x);
|
||||
self->max.y = MAX (self->max.y, p->y);
|
||||
}
|
||||
|
||||
graphene_rect_t *
|
||||
gsk_bounding_box_to_rect (const GskBoundingBox *self,
|
||||
graphene_rect_t *rect)
|
||||
{
|
||||
rect->origin = self->min;
|
||||
rect->size.width = self->max.x - self->min.x;
|
||||
rect->size.height = self->max.y - self->min.y;
|
||||
return rect;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_bounding_box_contains_point (const GskBoundingBox *self,
|
||||
const graphene_point_t *p)
|
||||
{
|
||||
return self->min.x <= p->x && p->x <= self->max.x &&
|
||||
self->min.y <= p->y && p->y <= self->max.y;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_bounding_box_intersection (const GskBoundingBox *a,
|
||||
const GskBoundingBox *b,
|
||||
GskBoundingBox *res)
|
||||
{
|
||||
graphene_point_t min, max;
|
||||
|
||||
min.x = MAX (a->min.x, b->min.x);
|
||||
min.y = MAX (a->min.y, b->min.y);
|
||||
max.x = MIN (a->max.x, b->max.x);
|
||||
max.y = MIN (a->max.y, b->max.y);
|
||||
|
||||
if (res)
|
||||
gsk_bounding_box_init (res, &min, &max);
|
||||
|
||||
return min.x <= max.x && min.y <= max.y;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <gsk/gsktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskBoundingBox GskBoundingBox;
|
||||
|
||||
struct _GskBoundingBox {
|
||||
graphene_point_t min;
|
||||
graphene_point_t max;
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskBoundingBox * gsk_bounding_box_init (GskBoundingBox *self,
|
||||
const graphene_point_t *a,
|
||||
const graphene_point_t *b);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskBoundingBox * gsk_bounding_box_init_copy (GskBoundingBox *self,
|
||||
const GskBoundingBox *src);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskBoundingBox * gsk_bounding_box_init_from_rect (GskBoundingBox *self,
|
||||
const graphene_rect_t *bounds);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gsk_bounding_box_expand (GskBoundingBox *self,
|
||||
const graphene_point_t *p);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
graphene_rect_t *gsk_bounding_box_to_rect (const GskBoundingBox *self,
|
||||
graphene_rect_t *rect);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gsk_bounding_box_contains_point (const GskBoundingBox *self,
|
||||
const graphene_point_t *p);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gsk_bounding_box_intersection (const GskBoundingBox *a,
|
||||
const GskBoundingBox *b,
|
||||
GskBoundingBox *res);
|
||||
|
||||
G_END_DECLS
|
||||
+2099
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright © 2020 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 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/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GSK_CONTOUR_PRIVATE_H__
|
||||
#define __GSK_CONTOUR_PRIVATE_H__
|
||||
|
||||
#include <gskpath.h>
|
||||
|
||||
#include "gskpathopprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* A path is flat if it contains no cubic or conic segments.
|
||||
* A path is closed if all its contours end with a GSK_PATH_CLOSE
|
||||
* operation.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GSK_PATH_FLAT,
|
||||
GSK_PATH_CLOSED
|
||||
} GskPathFlags;
|
||||
|
||||
typedef struct _GskContour GskContour;
|
||||
|
||||
GskContour * gsk_rect_contour_new (const graphene_rect_t *rect);
|
||||
GskContour * gsk_circle_contour_new (const graphene_point_t *center,
|
||||
float radius,
|
||||
float start_angle,
|
||||
float end_angle);
|
||||
GskContour * gsk_standard_contour_new (GskPathFlags flags,
|
||||
const graphene_point_t *points,
|
||||
gsize n_points,
|
||||
const gskpathop *ops,
|
||||
gsize n_ops,
|
||||
gssize offset);
|
||||
|
||||
void gsk_contour_copy (GskContour * dest,
|
||||
const GskContour *src);
|
||||
GskContour * gsk_contour_dup (const GskContour *src);
|
||||
|
||||
GskContour * gsk_contour_reverse (const GskContour *src);
|
||||
|
||||
gsize gsk_contour_get_size (const GskContour *self);
|
||||
GskPathFlags gsk_contour_get_flags (const GskContour *self);
|
||||
void gsk_contour_print (const GskContour *self,
|
||||
GString *string);
|
||||
gboolean gsk_contour_get_bounds (const GskContour *self,
|
||||
graphene_rect_t *bounds);
|
||||
gpointer gsk_contour_init_measure (const GskContour *self,
|
||||
float tolerance,
|
||||
float *out_length);
|
||||
void gsk_contour_free_measure (const GskContour *self,
|
||||
gpointer data);
|
||||
gboolean gsk_contour_foreach (const GskContour *self,
|
||||
float tolerance,
|
||||
GskPathForeachFunc func,
|
||||
gpointer user_data);
|
||||
void gsk_contour_get_start_end (const GskContour *self,
|
||||
graphene_point_t *start,
|
||||
graphene_point_t *end);
|
||||
void gsk_contour_get_point (const GskContour *self,
|
||||
gpointer measure_data,
|
||||
float distance,
|
||||
graphene_point_t *pos,
|
||||
graphene_vec2_t *tangent);
|
||||
float gsk_contour_get_curvature (const GskContour *self,
|
||||
gpointer measure_data,
|
||||
float distance,
|
||||
graphene_point_t *center);
|
||||
gboolean gsk_contour_get_closest_point (const GskContour *self,
|
||||
gpointer measure_data,
|
||||
float tolerance,
|
||||
const graphene_point_t *point,
|
||||
float threshold,
|
||||
float *out_distance,
|
||||
graphene_point_t *out_pos,
|
||||
float *out_offset,
|
||||
graphene_vec2_t *out_tangent);
|
||||
int gsk_contour_get_winding (const GskContour *self,
|
||||
gpointer measure_data,
|
||||
const graphene_point_t *point,
|
||||
gboolean *on_edge);
|
||||
void gsk_contour_add_segment (const GskContour *self,
|
||||
GskPathBuilder *builder,
|
||||
gpointer measure_data,
|
||||
gboolean emit_move_to,
|
||||
float start,
|
||||
float end);
|
||||
gboolean gsk_contour_get_stroke_bounds (const GskContour *self,
|
||||
const GskStroke *stroke,
|
||||
graphene_rect_t *bounds);
|
||||
void gsk_contour_add_stroke (const GskContour *contour,
|
||||
GskPathBuilder *builder,
|
||||
GskStroke *stroke);
|
||||
void gsk_contour_default_add_stroke (const GskContour *contour,
|
||||
GskPathBuilder *builder,
|
||||
GskStroke *stroke);
|
||||
|
||||
void gsk_contour_offset (const GskContour *contour,
|
||||
GskPathBuilder *builder,
|
||||
float distance,
|
||||
GskLineJoin line_join,
|
||||
float miter_limit);
|
||||
void gsk_contour_default_offset (const GskContour *contour,
|
||||
GskPathBuilder *builder,
|
||||
float distance,
|
||||
GskLineJoin line_join,
|
||||
float miter_limit);
|
||||
|
||||
gboolean gsk_contour_is_convex (const GskContour *contour);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_CONTOUR_PRIVATE_H__ */
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gskconvexityprivate.h"
|
||||
#include "gskcontourprivate.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GSK_DIR_CHANGE_UNKNOWN,
|
||||
GSK_DIR_CHANGE_LEFT,
|
||||
GSK_DIR_CHANGE_RIGHT,
|
||||
GSK_DIR_CHANGE_STRAIGHT,
|
||||
GSK_DIR_CHANGE_REVERSE,
|
||||
GSK_DIR_CHANGE_INVALID,
|
||||
} GskDirChange;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GSK_PATH_DIRECTION_UNKNOWN,
|
||||
GSK_PATH_DIRECTION_CLOCKWISE,
|
||||
GSK_PATH_DIRECTION_COUNTERCLOCKWISE,
|
||||
} GskPathDirection;
|
||||
|
||||
typedef struct _GskConvexityChecker GskConvexityChecker;
|
||||
struct _GskConvexityChecker
|
||||
{
|
||||
graphene_point_t first_point;
|
||||
graphene_vec2_t first_vec;
|
||||
graphene_point_t last_point;
|
||||
graphene_vec2_t last_vec;
|
||||
GskDirChange expected_direction;
|
||||
GskPathDirection first_direction;
|
||||
int reversals;
|
||||
gboolean finite;
|
||||
GskConvexity convexity;
|
||||
int xsign;
|
||||
int ysign;
|
||||
int dx;
|
||||
int dy;
|
||||
};
|
||||
|
||||
static float
|
||||
cross_product (graphene_vec2_t *a,
|
||||
graphene_vec2_t *b)
|
||||
{
|
||||
float fa[2];
|
||||
float fb[2];
|
||||
graphene_vec2_to_float (a, fa);
|
||||
graphene_vec2_to_float (b, fb);
|
||||
return fa[0] * fb[1] - fa[1] * fb[0];
|
||||
}
|
||||
|
||||
static GskDirChange
|
||||
direction_change (GskConvexityChecker *c,
|
||||
graphene_vec2_t *v)
|
||||
{
|
||||
float cross = cross_product (&(c->last_vec), v);
|
||||
if (!finite (cross))
|
||||
return GSK_DIR_CHANGE_UNKNOWN;
|
||||
|
||||
if (cross == 0)
|
||||
return graphene_vec2_dot (&(c->last_vec), v) < 0
|
||||
? GSK_DIR_CHANGE_REVERSE
|
||||
: GSK_DIR_CHANGE_STRAIGHT;
|
||||
|
||||
return cross > 0
|
||||
? GSK_DIR_CHANGE_RIGHT
|
||||
: GSK_DIR_CHANGE_LEFT;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
add_vec (GskConvexityChecker *c,
|
||||
graphene_vec2_t *v)
|
||||
{
|
||||
GskDirChange dir;
|
||||
int sign;
|
||||
|
||||
dir = direction_change (c, v);
|
||||
switch (dir)
|
||||
{
|
||||
case GSK_DIR_CHANGE_LEFT:
|
||||
case GSK_DIR_CHANGE_RIGHT:
|
||||
if (c->expected_direction == GSK_DIR_CHANGE_INVALID)
|
||||
{
|
||||
c->expected_direction = dir;
|
||||
c->first_direction = (dir == GSK_DIR_CHANGE_RIGHT)
|
||||
? GSK_PATH_DIRECTION_CLOCKWISE
|
||||
: GSK_PATH_DIRECTION_COUNTERCLOCKWISE;
|
||||
}
|
||||
else if (c->expected_direction != dir)
|
||||
{
|
||||
c->first_direction = GSK_PATH_DIRECTION_UNKNOWN;
|
||||
c->convexity = GSK_CONVEXITY_CONCAVE;
|
||||
return FALSE;
|
||||
}
|
||||
graphene_vec2_init_from_vec2 (&c->last_vec, v);
|
||||
break;
|
||||
|
||||
case GSK_DIR_CHANGE_STRAIGHT:
|
||||
break;
|
||||
|
||||
case GSK_DIR_CHANGE_REVERSE:
|
||||
graphene_vec2_init_from_vec2 (&c->last_vec, v);
|
||||
c->reversals++;
|
||||
if (c->reversals > 2)
|
||||
c->convexity = GSK_CONVEXITY_CONCAVE;
|
||||
return c->reversals < 3;
|
||||
|
||||
case GSK_DIR_CHANGE_UNKNOWN:
|
||||
c->finite = FALSE;
|
||||
return FALSE;
|
||||
|
||||
case GSK_DIR_CHANGE_INVALID:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if (graphene_vec2_get_x (v) > 0)
|
||||
sign = 1;
|
||||
else if (graphene_vec2_get_x (v) < 0)
|
||||
sign = -1;
|
||||
else
|
||||
sign = 0;
|
||||
|
||||
if (sign != 0)
|
||||
{
|
||||
if (c->xsign != 42)
|
||||
{
|
||||
if (c->xsign != sign)
|
||||
c->dx++;
|
||||
|
||||
if (c->dx > 2)
|
||||
{
|
||||
c->convexity = GSK_CONVEXITY_CONCAVE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
c->xsign = sign;
|
||||
}
|
||||
|
||||
if (graphene_vec2_get_y (v) > 0)
|
||||
sign = 1;
|
||||
else if (graphene_vec2_get_y (v) < 0)
|
||||
sign = -1;
|
||||
else
|
||||
sign = 0;
|
||||
|
||||
if (sign != 0)
|
||||
{
|
||||
if (c->ysign != 42)
|
||||
{
|
||||
if (c->ysign != sign)
|
||||
c->dy++;
|
||||
|
||||
if (c->dy > 2)
|
||||
{
|
||||
c->convexity = GSK_CONVEXITY_CONCAVE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
c->ysign = sign;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_convexity_checker_init (GskConvexityChecker *c)
|
||||
{
|
||||
c->first_point = GRAPHENE_POINT_INIT(0,0);
|
||||
c->last_point = GRAPHENE_POINT_INIT(0,0);
|
||||
graphene_vec2_init (&c->first_vec, 0, 0);
|
||||
graphene_vec2_init (&c->last_vec, 0, 0);
|
||||
c->expected_direction = GSK_DIR_CHANGE_INVALID;
|
||||
c->first_direction = GSK_PATH_DIRECTION_UNKNOWN;
|
||||
c->reversals = 0;
|
||||
c->finite = TRUE;
|
||||
c->convexity = GSK_CONVEXITY_UNKNOWN;
|
||||
c->xsign = 42;
|
||||
c->ysign = 42;
|
||||
c->dx = 0;
|
||||
c->dy = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_convexity_checker_move (GskConvexityChecker *c,
|
||||
const graphene_point_t *p)
|
||||
{
|
||||
c->first_point = c->last_point = *p;
|
||||
c->expected_direction = GSK_DIR_CHANGE_INVALID;
|
||||
c->convexity = GSK_CONVEXITY_CONVEX;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_convexity_checker_add_point (GskConvexityChecker *c,
|
||||
const graphene_point_t *p)
|
||||
{
|
||||
graphene_vec2_t v;
|
||||
|
||||
if (graphene_point_equal (&c->last_point, p))
|
||||
return TRUE;
|
||||
|
||||
graphene_vec2_init (&v,
|
||||
p->x - c->last_point.x,
|
||||
p->y - c->last_point.y);
|
||||
|
||||
if (graphene_point_equal (&c->first_point, &c->last_point) &&
|
||||
c->expected_direction == GSK_DIR_CHANGE_INVALID)
|
||||
{
|
||||
graphene_vec2_init_from_vec2 (&c->last_vec, &v);
|
||||
graphene_vec2_init_from_vec2 (&c->first_vec, &v);
|
||||
}
|
||||
else if (!add_vec (c, &v))
|
||||
{
|
||||
c->convexity = GSK_CONVEXITY_CONCAVE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
c->last_point = *p;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_convexity_checker_close (GskConvexityChecker *c)
|
||||
{
|
||||
if (!(gsk_convexity_checker_add_point (c, &c->first_point) &&
|
||||
add_vec (c, &c->first_vec)))
|
||||
{
|
||||
c->convexity = GSK_CONVEXITY_CONCAVE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
convex_cb (GskPathOperation op,
|
||||
const graphene_point_t *pts,
|
||||
gsize n_pts,
|
||||
float weight,
|
||||
gpointer user_data)
|
||||
{
|
||||
GskConvexityChecker *c = user_data;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case GSK_PATH_MOVE:
|
||||
gsk_convexity_checker_move (c, &pts[0]);
|
||||
break;
|
||||
case GSK_PATH_CLOSE:
|
||||
if (!gsk_convexity_checker_close (c))
|
||||
return FALSE;
|
||||
break;
|
||||
case GSK_PATH_LINE:
|
||||
if (!gsk_convexity_checker_add_point (c, &pts[1]))
|
||||
return FALSE;
|
||||
break;
|
||||
case GSK_PATH_CURVE:
|
||||
if (!gsk_convexity_checker_add_point (c, &pts[1]) ||
|
||||
!gsk_convexity_checker_add_point (c, &pts[2]) ||
|
||||
!gsk_convexity_checker_add_point (c, &pts[3]))
|
||||
return FALSE;
|
||||
break;
|
||||
case GSK_PATH_CONIC:
|
||||
if (!gsk_convexity_checker_add_point (c, &pts[1]) ||
|
||||
!gsk_convexity_checker_add_point (c, &pts[3]))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GskConvexity
|
||||
gsk_contour_compute_convexity (const GskContour *contour)
|
||||
{
|
||||
GskConvexityChecker c;
|
||||
|
||||
gsk_convexity_checker_init (&c);
|
||||
gsk_contour_foreach (contour, 0.001, convex_cb, &c);
|
||||
|
||||
g_assert (c.convexity != GSK_CONVEXITY_UNKNOWN);
|
||||
|
||||
return c.convexity;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "gskcontourprivate.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GSK_CONVEXITY_UNKNOWN,
|
||||
GSK_CONVEXITY_CONVEX,
|
||||
GSK_CONVEXITY_CONCAVE,
|
||||
} GskConvexity;
|
||||
|
||||
GskConvexity gsk_contour_compute_convexity (const GskContour *contour);
|
||||
|
||||
|
||||
+2003
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user