Compare commits
599 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8a14144658 | |||
| 0ff6176525 | |||
| c30befed1e | |||
| 9d38806ced | |||
| 3cdde3fc4b | |||
| 05b9a99661 | |||
| a16e1cbf18 | |||
| c7ea83cd82 | |||
| 352c9ba42a | |||
| 30b37dd7c5 | |||
| 2e256986c3 | |||
| 77e0d360ed | |||
| 942a93250a | |||
| 7ccd6597c3 | |||
| 355a417dba | |||
| 36e3f4d902 | |||
| 69fe705d0d | |||
| f62535affc | |||
| 1a56a10fc1 | |||
| 4287f0def4 | |||
| 7bebc3e2b2 | |||
| b4e2df8fca | |||
| 0df0de0b5d | |||
| 53c22bf833 | |||
| d8144ec497 | |||
| 3d9e3390f1 | |||
| 03595f9567 | |||
| 64e026d0a9 | |||
| 0623b00512 | |||
| ac902e697e | |||
| f1ff69963e | |||
| 731ae8f39e | |||
| 7da6fdc30e | |||
| a297129685 | |||
| 1eec7362b9 | |||
| a105256611 | |||
| 2ee04ee8ed | |||
| 6e358e2a49 | |||
| 71ee4df357 | |||
| 2bc6e1b875 | |||
| 4e58541d52 | |||
| 53bc1d60c4 | |||
| 5b6b4f5075 | |||
| 16654eeef4 | |||
| 871959c88c | |||
| 55d08d8400 | |||
| 5dcce0c0bd | |||
| 975fe76a0e | |||
| 00be314feb | |||
| da5d524324 | |||
| 8e41fa2778 | |||
| f80a341b4f | |||
| 77f8245c0c | |||
| 8afdbd6ee3 | |||
| ac4e98f16a | |||
| ab0869ecbc | |||
| cff8304133 | |||
| 962e38c5c9 | |||
| 7855a98fd1 | |||
| aea27b86c1 | |||
| d4caf3d679 | |||
| d9652675ef | |||
| 685288216f | |||
| c8fa1f19db | |||
| 7e4feb092b | |||
| 9eadcd8d55 | |||
| 86aa011587 | |||
| f9e613f8fd | |||
| e13692c52f | |||
| cbed409f52 | |||
| 0351f27af2 | |||
| f84ecf9cd2 | |||
| 5e9d186c26 | |||
| de9f0c5505 | |||
| f5865b125e | |||
| 3483c1a45b | |||
| 5cc088128f | |||
| c4548e9c7b | |||
| 5d6aeb4bf7 | |||
| 560e03f962 | |||
| c3f1ff7db4 | |||
| 88d26b7549 | |||
| 4ac8011126 | |||
| 9b29da93b6 | |||
| 0fe9643728 | |||
| 73a214d1a9 | |||
| 59a31e05bc | |||
| 527b67af3d | |||
| 3c03d7970a | |||
| 278762f00a | |||
| 1565f597c8 | |||
| fea42def61 | |||
| 56b8d1dfbe | |||
| 3120fb29e1 | |||
| 119457279b | |||
| dfea9bf0e8 | |||
| 36cb812ad8 | |||
| 95ed9de706 | |||
| a0448e2c7f | |||
| a6b05a19f1 | |||
| 672d7f679a | |||
| feecfcab27 | |||
| 24fa0f8e28 | |||
| 878f35515d | |||
| 68fd796125 | |||
| 5014b2a7fe | |||
| 8cb375de11 | |||
| 7927bcf6c5 | |||
| d24d0e9667 | |||
| e9e4bd423a | |||
| 81ddf4b946 | |||
| c8485af819 | |||
| 704a659438 | |||
| d32b0d3118 | |||
| 23426b0f39 | |||
| 417edd28fb | |||
| ea17728ee5 | |||
| a6f300cefd | |||
| 05b98c3834 | |||
| 820c9403e3 | |||
| 509531349d | |||
| 2a5a52dd4b | |||
| f42e18507f | |||
| e6a0a2f587 | |||
| 631ea5caac | |||
| d59784f7c7 | |||
| 193eb5b0dd | |||
| 6a1adf6f1a | |||
| 563ad2db1b | |||
| c85d9a3259 | |||
| b9c81b1b94 | |||
| b52bcf7e0a | |||
| a38ba91e35 | |||
| a350c2452a | |||
| 025902b9fb | |||
| 7e2e92a87e | |||
| be4d42507c | |||
| 6e88ccf7fb | |||
| cec4c15f05 | |||
| ce1f1f7dec | |||
| 95f00c6071 | |||
| 55cfeccfd2 | |||
| 2301916fa4 | |||
| bb4efe18b7 | |||
| a463dccd81 | |||
| eff129323f | |||
| a5530caec3 | |||
| 92cfc03821 | |||
| 46bb1a9b6a | |||
| 19280db075 | |||
| 7210c5484e | |||
| 433c8307b2 | |||
| 26506b0a15 | |||
| f8fa946989 | |||
| 119ebe1d70 | |||
| dda54b2b8f | |||
| 821efcb725 | |||
| 85793fe6b6 | |||
| dc8dedce07 | |||
| f5182f1c35 | |||
| 1efa39672b | |||
| 3f38a1c94c | |||
| d861dd5df8 | |||
| 8c98fd2e46 | |||
| 3091679ffa | |||
| 2e89c5360a | |||
| e448fc41f3 | |||
| c9e972eecb | |||
| 45455f1bdb | |||
| a3769eb0e5 | |||
| 7c75ea376f | |||
| 96143548ac | |||
| 0b2a6e34c4 | |||
| 24d8c0a7dc | |||
| ba08f5e67d | |||
| 31aa5a0e53 | |||
| 7aa17afe7a | |||
| 8c678ac756 | |||
| 7d1f915a61 | |||
| afa991752c | |||
| fc2d05ee38 | |||
| 00aa4f0597 | |||
| 3401150cca | |||
| 67991ed0f4 | |||
| 741e12012d | |||
| 91aa60b210 | |||
| e31c0898e5 | |||
| 1f2f2777e1 | |||
| 9cb2fe5cac | |||
| 8d15efba8f | |||
| 1200fe2daf | |||
| 515a527b27 | |||
| 06dbde22a0 | |||
| c21280e455 | |||
| 0d9a7fe089 | |||
| 03883b8b1a | |||
| f28cd6cea9 | |||
| b8b90fefd8 | |||
| b4a9cf2bfb | |||
| 2a919a4d4f | |||
| b2775d9bdd | |||
| d0a8a717ef | |||
| 7d72703d54 | |||
| 8ecd4e87e3 | |||
| 9de31929d6 | |||
| b41bba07fa | |||
| 0f694b8beb | |||
| 7b1ab8fb8b | |||
| d9b1a1ebb1 | |||
| d4f3979896 | |||
| 2e7cb6019f | |||
| f1fce5253e | |||
| 81b65eadcb | |||
| 1e7705c08e | |||
| cc3cf581ab | |||
| 6e09c5cee8 | |||
| 69fb3648b2 | |||
| 23f84e3a3d | |||
| 1a9b1f38a4 | |||
| 00a488a5b5 | |||
| 26c4c28068 | |||
| da2e184639 | |||
| 9576222b47 | |||
| 7738a05bd2 | |||
| 93b5b487ae | |||
| 7588655a42 | |||
| 007713c0ba | |||
| f0c1c3349f | |||
| 0dba6e5759 | |||
| 60cd7cd96c | |||
| 2b504201e3 | |||
| 3fcbe8d5f3 | |||
| 105acfe908 | |||
| 1caf197a0d | |||
| 0a49726c73 | |||
| dd0cc9df9f | |||
| 789f6f3941 | |||
| 2c231f4336 | |||
| 3c50e5324f | |||
| 3182063ffe | |||
| 5910e5ac6d | |||
| b2b89f6c57 | |||
| 5ac24db049 | |||
| 192a24fa1f | |||
| 2426b9e23a | |||
| 64848aebf4 | |||
| fcceac6d11 | |||
| 975f6529b1 | |||
| 357e215fb8 | |||
| 4716c9ae2f | |||
| 5aad3d7d0e | |||
| fe36c24b07 | |||
| 682068f887 | |||
| e8eb1df29f | |||
| 82dc7b903c | |||
| b020a3fcf9 | |||
| cb88de5938 | |||
| 94b1e72aa3 | |||
| 20b92638ec | |||
| dccb83c9ec | |||
| d668d2fa25 | |||
| 34f1ae8fad | |||
| 042537cf0d | |||
| d03f38470e | |||
| a7d72cf69b | |||
| 256139baab | |||
| a935aae6f1 | |||
| 9955d686ee | |||
| a9da41c66a | |||
| 4d8691b762 | |||
| 806e159b8b | |||
| 794ee0b8c0 | |||
| 2b7de841a9 | |||
| 45309811c5 | |||
| 2b695ac8d1 | |||
| cb03969c5f | |||
| 57e71a6a69 | |||
| 15b5a404b8 | |||
| 4056a40d2d | |||
| c1e9523f0e | |||
| 4c1ccfd7be | |||
| 823e00dec9 | |||
| 3e51966ea9 | |||
| e292767a01 | |||
| 75c433fb5f | |||
| 83867f9cbf | |||
| ea9f0df67b | |||
| 15c7980ba6 | |||
| de5fde1e12 | |||
| a83b360224 | |||
| 4d55d23c1a | |||
| 2b6162116d | |||
| b2ca947934 | |||
| 3eaf88b84c | |||
| 9e9eae3ad4 | |||
| 903afcbddd | |||
| d37612a476 | |||
| f5daecf353 | |||
| b76940bab5 | |||
| ec255f9bb1 | |||
| 9dc6be4fb0 | |||
| 186b783f9d | |||
| 2f3518c80d | |||
| 4a7f68e79e | |||
| 65af983ddb | |||
| f0dc5e0be5 | |||
| f0cbd175cd | |||
| 99aa47185e | |||
| 898e29c989 | |||
| cf1700fd13 | |||
| 112aed590f | |||
| 6763443c5d | |||
| 7d99339c39 | |||
| f33fe6daed | |||
| c7dc17d837 | |||
| a51ee20ed9 | |||
| 8d3e1eb314 | |||
| c941a2d9c6 | |||
| 1c03bbeb9c | |||
| a4059cd02d | |||
| eab6df31ac | |||
| 8a085fcc5a | |||
| 7668669d56 | |||
| 5e57b3d07a | |||
| 187a701a99 | |||
| d5f4579384 | |||
| 0297039b38 | |||
| 5206a92522 | |||
| 233ec1a5d6 | |||
| 579d8e427b | |||
| 9c11c60530 | |||
| 66c8da4750 | |||
| 05a9b72fc8 | |||
| 4fe5710456 | |||
| ac5b4a6307 | |||
| 5ce7bfbbd8 | |||
| 7646d1b22c | |||
| 61db81ab8e | |||
| 24d7586163 | |||
| b150625105 | |||
| 5787146238 | |||
| 8a72031e99 | |||
| 201a791076 | |||
| 359003670a | |||
| 6b7c5174ed | |||
| 8a521accbc | |||
| d116bbf0c8 | |||
| 42e440a111 | |||
| 13adb2591c | |||
| 7b73824dfe | |||
| 403aba82a9 | |||
| a053d7ddb1 | |||
| c878f650ce | |||
| 2d2cdeae88 | |||
| 009228471c | |||
| 379166e1ff | |||
| a59a20c1d4 | |||
| fb4b5c666b | |||
| b59c70aaeb | |||
| 6fcae42dde | |||
| 2ee087f25f | |||
| 9cc29efa25 | |||
| a04d314910 | |||
| f83f7a2b4d | |||
| edb175cf75 | |||
| 1eefaf8b41 | |||
| 0224517806 | |||
| 27c521cce8 | |||
| 62b87182c5 | |||
| c95659bf32 | |||
| 865fc9c925 | |||
| a1f4f52fcb | |||
| bdb4bf00c5 | |||
| aca252837d | |||
| 8b058572f0 | |||
| df050c51bb | |||
| bd20ae4fa5 | |||
| 818b456f9f | |||
| c1c8abf275 | |||
| c1029535ca | |||
| a5ca5eb865 | |||
| 2227d2a2b5 | |||
| 61559e38f4 | |||
| 134fca47e3 | |||
| 4630dd8d68 | |||
| d2f7d1b1d7 | |||
| cfa9e6da4a | |||
| ceca2f9202 | |||
| bf98ebcb12 | |||
| 1a5dece09c | |||
| 8e8254feae | |||
| 90cda9e307 | |||
| fdfa371d90 | |||
| deb16c1a00 | |||
| 8c3736709e | |||
| f459164f8a | |||
| 00169a06bf | |||
| e09f2b8b56 | |||
| 092c115ff0 | |||
| 5144d15168 | |||
| 5a6ab8cbd3 | |||
| 8c73f882af | |||
| 78832c65b5 | |||
| e8b830a3dd | |||
| 38974d7d2b | |||
| f6f331efe3 | |||
| dbb3727b03 | |||
| 508570864d | |||
| 96c77b61c1 | |||
| 2b819c830b | |||
| f3be49838f | |||
| e9067ae2db | |||
| f898bee032 | |||
| 6a7f39e6d2 | |||
| dfb2cbdfdb | |||
| f960eb6ab4 | |||
| 60fc2c6a7a | |||
| 3080592234 | |||
| 532fdde720 | |||
| f8399588e9 | |||
| ad019be75b | |||
| e505dab487 | |||
| 1262184269 | |||
| 46f42fc53d | |||
| cb26cd7391 | |||
| 1a3eeb1233 | |||
| e1f74c8f69 | |||
| 58106af54d | |||
| 1e000c3dac | |||
| 19ee9b4c57 | |||
| 1075607528 | |||
| d2bd9b0850 | |||
| 74d445636c | |||
| 7048790931 | |||
| b9034015d7 | |||
| c7b70b122a | |||
| 6e01a49d10 | |||
| c290bd6367 | |||
| 853063bea7 | |||
| 69e3fee5e2 | |||
| aa276a181e | |||
| 583705b4ae | |||
| cd7303d47c | |||
| 0f9cbf49ac | |||
| a309e74be7 | |||
| ccaf70e1b7 | |||
| 2fd9431f23 | |||
| 3f33a0ed27 | |||
| 4ea18a22e6 | |||
| 746dc5c3a2 | |||
| 17131f1137 | |||
| 07c889c5ea | |||
| b0d9a6ff20 | |||
| 802c7975e2 | |||
| 6e602e052b | |||
| 025eee112c | |||
| 70cdd4e951 | |||
| 75b789f20f | |||
| ac09500d74 | |||
| a76b187a5b | |||
| 45679d7bc3 | |||
| 6dc8fc3a4d | |||
| e53e0f461e | |||
| 37b849b808 | |||
| e03bdbe307 | |||
| 9b01d9a784 | |||
| b4c689ecd6 | |||
| 78a0913f0f | |||
| 74722fb10e | |||
| 3891ce36fe | |||
| 5a940408fe | |||
| efce8c2899 | |||
| ea9f2abcc4 | |||
| 993d6388ee | |||
| 5ad4b75ae2 | |||
| 24ef9df0f1 | |||
| 5d49b11ffd | |||
| 8e3db48482 | |||
| fdcfe0e80a | |||
| 8137dea8c1 | |||
| b15c31a3f7 | |||
| a52757874e | |||
| e9203eeef7 | |||
| 337057eb35 | |||
| 2803a15a51 | |||
| d145032cb6 | |||
| 2612331282 | |||
| d3fd071809 | |||
| 303c9becf8 | |||
| 6bf46c8f30 | |||
| 1e2c03beee | |||
| b24e10fa30 | |||
| 173952cbc8 | |||
| b31f4f2bae | |||
| df9d9c1f8a | |||
| 7dcb25bd46 | |||
| d131c8d0e7 | |||
| 0582a4ef1b | |||
| a9b1d4a389 | |||
| ea810f176b | |||
| 262ac4247a | |||
| 8e4f0b9484 | |||
| 7669e6e42e | |||
| a3f14a3395 | |||
| 73b8212bf3 | |||
| 6ba6f361be | |||
| 726909d735 | |||
| 04899e3707 | |||
| 7a27122dab | |||
| 73ce437459 | |||
| ca4ae81170 | |||
| 21a7dfae96 | |||
| 6c188f7c93 | |||
| c30e0f78ad | |||
| 76795ffba9 | |||
| c38c5c4ce1 | |||
| 108aac9ee3 | |||
| c427c2b22a | |||
| 59111d100f | |||
| cee8f78c6e | |||
| 0fc35b2124 | |||
| eebe67cf0a | |||
| b9726901a5 | |||
| df1d2b8417 | |||
| 8b1af398a0 | |||
| 982d73df0b | |||
| 1e55e01692 | |||
| 412fcb0330 | |||
| b8d1c3ab55 | |||
| 4fb519f04d | |||
| 054d69aaf9 | |||
| 1dea6d4fc7 | |||
| 022d19a4c6 | |||
| ef7276c398 | |||
| 0a8ca49b5e | |||
| 74f18f71d3 | |||
| c0d4a6fc81 | |||
| 1dd31d58fb | |||
| 766d4dff76 | |||
| e62f135c6a | |||
| 4788f88840 | |||
| 587bc82c37 | |||
| 750dc8dbe2 | |||
| d490d8f1f3 | |||
| cb2f523994 | |||
| 075a0ccb5e | |||
| db91b6dc61 | |||
| 44ac2d5abb | |||
| d7df56b6cb | |||
| 6a9bc5daef | |||
| b8aa51d522 | |||
| f79c807645 | |||
| d0d2ad9f5b | |||
| 0b8298038a | |||
| 6ef0bb8bea | |||
| 91472b2ecd | |||
| 80ddcf38d4 | |||
| 1477882b31 | |||
| 73f2167fe4 | |||
| 2079c898e7 | |||
| c79c18f39c | |||
| cef7f7f87d | |||
| fdce30d3f8 | |||
| f07397f4dd | |||
| f1751f514c | |||
| 2cbfb0e980 | |||
| 8dd7f5aefe | |||
| 398f49ad31 | |||
| 3d260a950e | |||
| f31667f437 | |||
| 219493c818 | |||
| 06f63764fb | |||
| 1243174e53 | |||
| cc909b160f | |||
| d12dde07c3 | |||
| 5191b6fccd | |||
| 2e6e6c1779 | |||
| a29b8fbef4 | |||
| 5b072e716c | |||
| 49845795d9 | |||
| ab04c74ec9 | |||
| 4744bb9099 | |||
| 91522dda63 | |||
| 095a378dbc | |||
| 0956c30ee5 | |||
| f85448ffbf | |||
| d3852ca33a | |||
| 9d9a730659 | |||
| 3f4cd4190f | |||
| 448a402353 | |||
| 2ee9752822 | |||
| f8a1f796b5 | |||
| 3b5a4cf215 | |||
| 759d53cfa0 | |||
| 814d20d61a | |||
| 6cef520804 | |||
| 8c77491150 | |||
| 709ebcedd4 | |||
| 47e6b88555 |
+2
-1
@@ -13,7 +13,7 @@ stages:
|
||||
- subprojects/pango/
|
||||
|
||||
fedora-x86_64: &fedora-x86_64-defaults
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/master:v8
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/master:v9
|
||||
stage: build
|
||||
script:
|
||||
- bash -x ./.gitlab-ci/test-docker.sh
|
||||
@@ -29,6 +29,7 @@ fedora-x86_64: &fedora-x86_64-defaults
|
||||
- "${CI_PROJECT_DIR}/_build/report.html"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*.png"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*.png"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*.syscap"
|
||||
cache:
|
||||
key: "$CI_JOB_NAME"
|
||||
<<: *cache-paths
|
||||
|
||||
@@ -67,6 +67,7 @@ RUN dnf -y install \
|
||||
python3-wheel \
|
||||
redhat-rpm-config \
|
||||
sassc \
|
||||
sysprof-devel \
|
||||
systemtap-sdt-devel \
|
||||
vulkan-devel \
|
||||
wayland-devel \
|
||||
|
||||
@@ -16,6 +16,7 @@ meson \
|
||||
-Dwayland-backend=true \
|
||||
-Dbroadway-backend=true \
|
||||
-Dvulkan=yes \
|
||||
-Dprofiler=true \
|
||||
--werror \
|
||||
${EXTRA_MESON_FLAGS:-} \
|
||||
_build $srcdir
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ maintainers review your contribution.
|
||||
|
||||
Each contribution is reviewed by the core developers of the GTK project.
|
||||
|
||||
The [CODE-OWNERS](./docs/CODE-OWNERS) document contains the list of core
|
||||
The [CODEOWNERS](./docs/CODEOWNERS) document contains the list of core
|
||||
contributors to GTK and the areas for which they are responsible; you
|
||||
should ensure to receive their review and signoff on your changes.
|
||||
|
||||
|
||||
+75
-50
@@ -119,48 +119,76 @@ get_image_paintable (GtkImage *image)
|
||||
}
|
||||
|
||||
static void
|
||||
drag_begin (GtkWidget *widget,
|
||||
GdkDrag *drag,
|
||||
gpointer data)
|
||||
drag_begin (GtkDragSource *source,
|
||||
GdkDrag *drag,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GdkPaintable *paintable;
|
||||
|
||||
paintable = get_image_paintable (GTK_IMAGE (widget));
|
||||
if (paintable)
|
||||
{
|
||||
gtk_drag_set_icon_paintable (drag, paintable, -2, -2);
|
||||
gtk_drag_source_set_icon (source, paintable, -2, -2);
|
||||
g_object_unref (paintable);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
drag_data_get (GtkWidget *widget,
|
||||
GdkDrag *drag,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
gpointer data)
|
||||
static void
|
||||
get_texture (GValue *value,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPaintable *paintable;
|
||||
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (data));
|
||||
|
||||
paintable = get_image_paintable (GTK_IMAGE (widget));
|
||||
if (GDK_IS_TEXTURE (paintable))
|
||||
gtk_selection_data_set_texture (selection_data, GDK_TEXTURE (paintable));
|
||||
g_value_set_object (value, paintable);
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
prepare_drag (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
GtkWidget *image)
|
||||
{
|
||||
return gdk_content_provider_new_with_callback (GDK_TYPE_TEXTURE, get_texture, image);
|
||||
}
|
||||
|
||||
static void
|
||||
drag_data_received (GtkWidget *widget,
|
||||
GdkDrop *drop,
|
||||
GtkSelectionData *selection_data,
|
||||
gpointer data)
|
||||
got_texture (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
if (gtk_selection_data_get_length (selection_data) > 0)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
GdkDrop *drop = GDK_DROP (source);
|
||||
GtkWidget *image = data;
|
||||
const GValue *value;
|
||||
GError *error = NULL;
|
||||
|
||||
texture = gtk_selection_data_get_texture (selection_data);
|
||||
gtk_image_set_from_paintable (GTK_IMAGE (data), GDK_PAINTABLE (texture));
|
||||
g_object_unref (texture);
|
||||
value = gdk_drop_read_value_finish (drop, result, &error);
|
||||
if (value)
|
||||
{
|
||||
GdkTexture *texture = g_value_get_object (value);
|
||||
gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (texture));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_print ("Failed to get data: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
drag_drop (GtkDropTarget *dest,
|
||||
GdkDrop *drop,
|
||||
int x,
|
||||
int y,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
if (gdk_drop_has_value (drop, GDK_TYPE_TEXTURE))
|
||||
{
|
||||
gdk_drop_read_value_async (drop, GDK_TYPE_TEXTURE, G_PRIORITY_DEFAULT, NULL, got_texture, widget);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -171,12 +199,8 @@ copy_image (GSimpleAction *action,
|
||||
GdkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET (data));
|
||||
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (data));
|
||||
|
||||
g_print ("copy image\n");
|
||||
if (GDK_IS_TEXTURE (paintable))
|
||||
{
|
||||
g_print ("set clipboard\n");
|
||||
gdk_clipboard_set_texture (clipboard, GDK_TEXTURE (paintable));
|
||||
}
|
||||
gdk_clipboard_set_texture (clipboard, GDK_TEXTURE (paintable));
|
||||
|
||||
if (paintable)
|
||||
g_object_unref (paintable);
|
||||
@@ -247,6 +271,9 @@ do_clipboard (GtkWidget *do_widget)
|
||||
{ "paste", paste_image, NULL, NULL, NULL },
|
||||
};
|
||||
GActionGroup *actions;
|
||||
GtkDragSource *source;
|
||||
GtkDropTarget *dest;
|
||||
GdkContentFormats *formats;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
@@ -305,22 +332,21 @@ do_clipboard (GtkWidget *do_widget)
|
||||
|
||||
/* Create the first image */
|
||||
image = gtk_image_new_from_icon_name ("dialog-warning");
|
||||
gtk_image_set_pixel_size (GTK_IMAGE (image), 48);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), image);
|
||||
|
||||
/* make image a drag source */
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_source_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-begin",
|
||||
G_CALLBACK (drag_begin), image);
|
||||
g_signal_connect (image, "drag-data-get",
|
||||
G_CALLBACK (drag_data_get), image);
|
||||
source = gtk_drag_source_new ();
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (prepare_drag), NULL);
|
||||
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
|
||||
|
||||
/* accept drops on image */
|
||||
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
|
||||
NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_dest_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-data-received",
|
||||
G_CALLBACK (drag_data_received), image);
|
||||
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE);
|
||||
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
|
||||
gdk_content_formats_unref (formats);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
/* context menu on image */
|
||||
gesture = gtk_gesture_click_new ();
|
||||
@@ -337,22 +363,21 @@ do_clipboard (GtkWidget *do_widget)
|
||||
|
||||
/* Create the second image */
|
||||
image = gtk_image_new_from_icon_name ("process-stop");
|
||||
gtk_image_set_pixel_size (GTK_IMAGE (image), 48);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), image);
|
||||
|
||||
/* make image a drag source */
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_source_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-begin",
|
||||
G_CALLBACK (drag_begin), image);
|
||||
g_signal_connect (image, "drag-data-get",
|
||||
G_CALLBACK (drag_data_get), image);
|
||||
source = gtk_drag_source_new ();
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (prepare_drag), NULL);
|
||||
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
|
||||
|
||||
/* accept drops on image */
|
||||
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
|
||||
NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_dest_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-data-received",
|
||||
G_CALLBACK (drag_data_received), image);
|
||||
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE);
|
||||
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
|
||||
gdk_content_formats_unref (formats);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
/* context menu on image */
|
||||
gesture = gtk_gesture_click_new ();
|
||||
|
||||
@@ -262,7 +262,7 @@ draw_menu (GtkWidget *widget,
|
||||
gint toggle_x, toggle_y, toggle_width, toggle_height;
|
||||
|
||||
/* This information is taken from the GtkMenu docs, see "CSS nodes" */
|
||||
menu_context = get_style (gtk_widget_get_style_context(widget), "menu");
|
||||
menu_context = get_style (NULL, "menu");
|
||||
hovermenuitem_context = get_style (menu_context, "menuitem:hover");
|
||||
hoveredarrowmenuitem_context = get_style (hovermenuitem_context, "arrow.right:dir(ltr)");
|
||||
menuitem_context = get_style (menu_context, "menuitem");
|
||||
|
||||
@@ -94,9 +94,12 @@ drawing_area_draw (GtkDrawingArea *area,
|
||||
cairo_pattern_t *pat;
|
||||
cairo_matrix_t matrix;
|
||||
gdouble angle, scale;
|
||||
gdouble x_center, y_center;
|
||||
|
||||
gtk_gesture_get_bounding_box_center (GTK_GESTURE (zoom), &x_center, &y_center);
|
||||
|
||||
cairo_get_matrix (cr, &matrix);
|
||||
cairo_matrix_translate (&matrix, width / 2, height / 2);
|
||||
cairo_matrix_translate (&matrix, x_center, y_center);
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ do_infobar (GtkWidget *do_widget)
|
||||
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
|
||||
gtk_info_bar_set_default_response (GTK_INFO_BAR (bar), GTK_RESPONSE_OK);
|
||||
|
||||
button = gtk_toggle_button_new_with_label ("Question");
|
||||
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/* Drag 'n Drop */
|
||||
static const char *target_table[] = {
|
||||
"text/uri-list"
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -76,30 +73,11 @@ search_text_changed (GtkEntry *entry, IconBrowserWindow *win)
|
||||
gtk_tree_model_filter_refilter (win->filter_model);
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
get_icon (GtkWidget *image, const gchar *name, gint size)
|
||||
{
|
||||
GtkIconInfo *info;
|
||||
GtkStyleContext *context;
|
||||
GdkTexture *texture;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
context = gtk_widget_get_style_context (image);
|
||||
info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), name, size, 0);
|
||||
texture = GDK_TEXTURE (gtk_icon_info_load_symbolic_for_context (info, context, NULL, NULL));
|
||||
pixbuf = gdk_pixbuf_get_from_texture (texture);
|
||||
g_object_unref (texture);
|
||||
g_object_unref (info);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
static void
|
||||
set_image (GtkWidget *image, const gchar *name, gint size)
|
||||
{
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (image), name);
|
||||
gtk_image_set_pixel_size (GTK_IMAGE (image), size);
|
||||
gtk_drag_source_set_icon_name (image, name);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -365,78 +343,107 @@ search_mode_toggled (GObject *searchbar, GParamSpec *pspec, IconBrowserWindow *w
|
||||
gtk_list_box_unselect_all (GTK_LIST_BOX (win->context_list));
|
||||
}
|
||||
|
||||
static void
|
||||
get_image_data (GtkWidget *widget,
|
||||
GdkDrag *drag,
|
||||
GtkSelectionData *selection,
|
||||
guint target_info,
|
||||
gpointer data)
|
||||
static GdkPaintable *
|
||||
get_image_paintable (GtkImage *image)
|
||||
{
|
||||
GtkWidget *image;
|
||||
const gchar *name;
|
||||
gint size;
|
||||
GdkPixbuf *pixbuf;
|
||||
const gchar *icon_name;
|
||||
GtkIconTheme *icon_theme;
|
||||
GtkIconInfo *icon_info;
|
||||
int size;
|
||||
|
||||
image = gtk_bin_get_child (GTK_BIN (widget));
|
||||
|
||||
name = gtk_image_get_icon_name (GTK_IMAGE (image));
|
||||
size = gtk_image_get_pixel_size (GTK_IMAGE (image));
|
||||
|
||||
pixbuf = get_icon (image, name, size);
|
||||
gtk_selection_data_set_pixbuf (selection, pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
switch (gtk_image_get_storage_type (image))
|
||||
{
|
||||
case GTK_IMAGE_PAINTABLE:
|
||||
return g_object_ref (gtk_image_get_paintable (image));
|
||||
case GTK_IMAGE_ICON_NAME:
|
||||
icon_name = gtk_image_get_icon_name (image);
|
||||
size = gtk_image_get_pixel_size (image);
|
||||
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
|
||||
icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, size,
|
||||
GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
|
||||
if (icon_info == NULL)
|
||||
return NULL;
|
||||
return gtk_icon_info_load_icon (icon_info, NULL);
|
||||
default:
|
||||
g_warning ("Image storage type %d not handled",
|
||||
gtk_image_get_storage_type (image));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_scalable_image_data (GtkWidget *widget,
|
||||
GdkDrag *drag,
|
||||
GtkSelectionData *selection,
|
||||
guint target_info,
|
||||
gpointer data)
|
||||
drag_begin (GtkDragSource *source,
|
||||
GdkDrag *drag,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
gchar *uris[2];
|
||||
GtkIconInfo *info;
|
||||
GtkWidget *image;
|
||||
GFile *file;
|
||||
const gchar *name;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
image = gtk_bin_get_child (GTK_BIN (widget));
|
||||
name = gtk_image_get_icon_name (GTK_IMAGE (image));
|
||||
paintable = get_image_paintable (GTK_IMAGE (widget));
|
||||
if (paintable)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
w = gdk_paintable_get_intrinsic_width (paintable);
|
||||
h = gdk_paintable_get_intrinsic_height (paintable);
|
||||
gtk_drag_source_set_icon (source, paintable, w, h);
|
||||
g_object_unref (paintable);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_texture (GValue *value,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (data));
|
||||
|
||||
if (GDK_IS_TEXTURE (paintable))
|
||||
g_value_set_object (value, paintable);
|
||||
}
|
||||
|
||||
static void
|
||||
get_file (GValue *value,
|
||||
gpointer data)
|
||||
{
|
||||
const char *name;
|
||||
GtkIconInfo *info;
|
||||
GFile *file;
|
||||
|
||||
name = gtk_image_get_icon_name (GTK_IMAGE (data));
|
||||
|
||||
info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), name, -1, 0);
|
||||
file = g_file_new_for_path (gtk_icon_info_get_filename (info));
|
||||
uris[0] = g_file_get_uri (file);
|
||||
uris[1] = NULL;
|
||||
|
||||
gtk_selection_data_set_uris (selection, uris);
|
||||
|
||||
g_free (uris[0]);
|
||||
g_object_unref (info);
|
||||
g_value_set_object (value, file);
|
||||
g_object_unref (file);
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_image_dnd (GtkWidget *image)
|
||||
{
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_source_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-data-get", G_CALLBACK (get_image_data), NULL);
|
||||
GdkContentProvider *content;
|
||||
GtkDragSource *source;
|
||||
|
||||
source = gtk_drag_source_new ();
|
||||
content = gdk_content_provider_new_with_callback (GDK_TYPE_TEXTURE, get_texture, image);
|
||||
gtk_drag_source_set_content (source, content);
|
||||
g_object_unref (content);
|
||||
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
|
||||
}
|
||||
|
||||
static void
|
||||
setup_scalable_image_dnd (GtkWidget *image)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
GdkContentFormats *targets;
|
||||
GdkContentProvider *content;
|
||||
GtkDragSource *source;
|
||||
|
||||
parent = gtk_widget_get_parent (image);
|
||||
targets = gdk_content_formats_new (target_table, G_N_ELEMENTS (target_table));
|
||||
gtk_drag_source_set (parent, GDK_BUTTON1_MASK,
|
||||
targets,
|
||||
GDK_ACTION_COPY);
|
||||
gdk_content_formats_unref (targets);
|
||||
source = gtk_drag_source_new ();
|
||||
content = gdk_content_provider_new_with_callback (G_TYPE_FILE, get_file, image);
|
||||
gtk_drag_source_set_content (source, content);
|
||||
g_object_unref (content);
|
||||
|
||||
g_signal_connect (parent, "drag-data-get", G_CALLBACK (get_scalable_image_data), NULL);
|
||||
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -446,8 +453,7 @@ icon_browser_window_init (IconBrowserWindow *win)
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
|
||||
list = gdk_content_formats_new (NULL, 0);
|
||||
list = gtk_content_formats_add_text_targets (list);
|
||||
list = gdk_content_formats_new_for_gtype (G_TYPE_STRING);
|
||||
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (win->list),
|
||||
GDK_BUTTON1_MASK,
|
||||
list,
|
||||
@@ -459,7 +465,6 @@ icon_browser_window_init (IconBrowserWindow *win)
|
||||
setup_image_dnd (win->image3);
|
||||
setup_image_dnd (win->image4);
|
||||
setup_image_dnd (win->image5);
|
||||
setup_image_dnd (win->image6);
|
||||
setup_scalable_image_dnd (win->image6);
|
||||
|
||||
win->contexts = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, context_free);
|
||||
|
||||
@@ -2000,6 +2000,13 @@ toggle_action (GSimpleAction *action,
|
||||
g_variant_new_boolean (!g_variant_get_boolean (state)));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
quit_timeout (gpointer data)
|
||||
{
|
||||
exit (0);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -2065,6 +2072,9 @@ main (int argc, char *argv[])
|
||||
|
||||
g_application_add_main_option (G_APPLICATION (app), "version", 0, 0, G_OPTION_ARG_NONE, "Show program version", NULL);
|
||||
|
||||
if (g_getenv ("GTK_DEBUG_AUTO_QUIT"))
|
||||
g_timeout_add (500, quit_timeout, NULL);
|
||||
|
||||
g_signal_connect (app, "handle-local-options", G_CALLBACK (local_options), NULL);
|
||||
status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||
g_object_unref (app);
|
||||
|
||||
@@ -30,6 +30,7 @@ GskRenderNodeType
|
||||
gsk_render_node_get_node_type
|
||||
gsk_render_node_draw
|
||||
GskSerializationError
|
||||
GskParseErrorFunc
|
||||
gsk_render_node_serialize
|
||||
gsk_render_node_deserialize
|
||||
gsk_render_node_write_to_file
|
||||
@@ -182,6 +183,7 @@ gsk_transform_perspective
|
||||
gsk_transform_equal
|
||||
<SUBSECTION>
|
||||
gsk_transform_transform_bounds
|
||||
gsk_transform_transform_point
|
||||
<SUBSECTION Private>
|
||||
GSK_TYPE_TRANSFORM
|
||||
gsk_transform_get_type
|
||||
|
||||
@@ -344,6 +344,13 @@
|
||||
<xi:include href="xml/gtkpadcontroller.xml" />
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>Data exchange, clipboards and Drag-and-Drop</title>
|
||||
<xi:include href="xml/gtkdragsource.xml"/>
|
||||
<xi:include href="xml/gtkdragicon.xml"/>
|
||||
<xi:include href="xml/gtkdroptarget.xml"/>
|
||||
</chapter>
|
||||
|
||||
</part>
|
||||
|
||||
<part id="gtkbase">
|
||||
@@ -352,7 +359,6 @@
|
||||
<xi:include href="xml/gtkfeatures.xml" />
|
||||
<xi:include href="xml/gtkaccelgroup.xml" />
|
||||
<xi:include href="xml/gtkaccelmap.xml" />
|
||||
<xi:include href="xml/gtkdnd.xml" />
|
||||
<xi:include href="xml/gtksettings.xml" />
|
||||
<xi:include href="xml/gtkbindings.xml" />
|
||||
<xi:include href="xml/gtkenums.xml" />
|
||||
|
||||
@@ -775,7 +775,6 @@ gtk_container_add
|
||||
gtk_container_remove
|
||||
gtk_container_foreach
|
||||
gtk_container_get_children
|
||||
gtk_container_get_path_for_child
|
||||
gtk_container_get_focus_vadjustment
|
||||
gtk_container_set_focus_vadjustment
|
||||
gtk_container_get_focus_hadjustment
|
||||
@@ -4412,7 +4411,6 @@ gtk_widget_get_layout_manager
|
||||
gtk_widget_should_layout
|
||||
|
||||
<SUBSECTION>
|
||||
gtk_widget_get_path
|
||||
gtk_widget_get_style_context
|
||||
gtk_widget_reset_style
|
||||
gtk_widget_class_get_css_name
|
||||
@@ -4897,7 +4895,6 @@ gtk_border_free
|
||||
<SUBSECTION>
|
||||
gtk_render_arrow
|
||||
gtk_render_background
|
||||
gtk_render_background_get_clip
|
||||
gtk_render_check
|
||||
gtk_render_expander
|
||||
gtk_render_focus
|
||||
@@ -5001,49 +4998,6 @@ GTK_TYPE_SELECTION_DATA
|
||||
gtk_selection_data_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkdnd</FILE>
|
||||
<TITLE>Drag and Drop</TITLE>
|
||||
GtkDestDefaults
|
||||
GtkDragResult
|
||||
|
||||
<SUBSECTION Destination Side>
|
||||
gtk_drag_dest_set
|
||||
gtk_drag_dest_unset
|
||||
gtk_drag_dest_find_target
|
||||
gtk_drag_dest_get_target_list
|
||||
gtk_drag_dest_set_target_list
|
||||
gtk_drag_dest_add_text_targets
|
||||
gtk_drag_dest_add_image_targets
|
||||
gtk_drag_dest_add_uri_targets
|
||||
gtk_drag_dest_set_track_motion
|
||||
gtk_drag_dest_get_track_motion
|
||||
gtk_drag_get_data
|
||||
gtk_drag_get_source_widget
|
||||
gtk_drag_highlight
|
||||
gtk_drag_unhighlight
|
||||
|
||||
<SUBSECTION Source Side>
|
||||
gtk_drag_begin
|
||||
gtk_drag_cancel
|
||||
gtk_drag_set_icon_widget
|
||||
gtk_drag_set_icon_paintable
|
||||
gtk_drag_set_icon_name
|
||||
gtk_drag_set_icon_gicon
|
||||
gtk_drag_set_icon_default
|
||||
gtk_drag_check_threshold
|
||||
gtk_drag_source_set
|
||||
gtk_drag_source_set_icon_name
|
||||
gtk_drag_source_set_icon_gicon
|
||||
gtk_drag_source_set_icon_paintable
|
||||
gtk_drag_source_unset
|
||||
gtk_drag_source_set_target_list
|
||||
gtk_drag_source_get_target_list
|
||||
gtk_drag_source_add_text_targets
|
||||
gtk_drag_source_add_image_targets
|
||||
gtk_drag_source_add_uri_targets
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkbindings</FILE>
|
||||
<TITLE>Bindings</TITLE>
|
||||
@@ -7191,3 +7145,69 @@ gtk_constraint_guide_get_max_size
|
||||
GTK_TYPE_CONSTRAINT_GUIDE
|
||||
gtk_constraint_guide_get_tyoe
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkdragsource</FILE>
|
||||
GtkDragSource
|
||||
gtk_drag_source_new
|
||||
gtk_drag_source_set_content
|
||||
gtk_drag_source_get_content
|
||||
gtk_drag_source_set_actions
|
||||
gtk_drag_source_get_actions
|
||||
gtk_drag_source_set_icon
|
||||
gtk_drag_source_drag_cancel
|
||||
gtk_drag_source_get_drag
|
||||
gtk_drag_check_threshold
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_DRAG_SOURCE
|
||||
GTK_DRAG_SOURCE
|
||||
GTK_DRAG_SOURCE_CLASS
|
||||
GTK_IS_DRAG_SOURCE
|
||||
GTK_IS_DRAG_SOURCE_CLASS
|
||||
GTK_DRAG_SOURCE_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_drag_source_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkdroptarget</FILE>
|
||||
GtkDropTarget
|
||||
gtk_drop_target_new
|
||||
gtk_drop_target_set_formats
|
||||
gtk_drop_target_get_formats
|
||||
gtk_drop_target_set_actions
|
||||
gtk_drop_target_get_actions
|
||||
gtk_drop_target_get_drop
|
||||
gtk_drop_target_find_mimetype
|
||||
gtk_drop_target_read_selection
|
||||
gtk_drop_target_read_selection_finish
|
||||
gtk_drag_highlight
|
||||
gtk_drag_unhighlight
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_DROP_TARGET
|
||||
GTK_DROP_TARGET
|
||||
GTK_DROP_TARGET_CLASS
|
||||
GTK_IS_DROP_TARGET
|
||||
GTK_IS_DROP_TARGET_CLASS
|
||||
GTK_DROP_TARGET_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_drop_target_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkdragicon</FILE>
|
||||
GtkDragIcon
|
||||
gtk_drag_icon_new_for_drag
|
||||
gtk_drag_icon_set_from_paintable
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_DRAG_ICON
|
||||
GTK_DRAG_ICON
|
||||
GTK_DRAG_ICON_CLASS
|
||||
GTK_IS_DRAG_ICON
|
||||
GTK_IS_DRAG_ICON_CLASS
|
||||
GTK_DRAG_ICON_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_drag_icon_get_type
|
||||
</SECTION>
|
||||
|
||||
@@ -57,7 +57,10 @@ gtk_constraint_target_get_type
|
||||
gtk_container_get_type
|
||||
gtk_css_provider_get_type
|
||||
gtk_dialog_get_type
|
||||
gtk_drag_icon_get_type
|
||||
gtk_drag_source_get_type
|
||||
gtk_drawing_area_get_type
|
||||
gtk_drop_target_get_type
|
||||
gtk_editable_get_type
|
||||
gtk_entry_buffer_get_type
|
||||
gtk_entry_completion_get_type
|
||||
|
||||
@@ -48,7 +48,6 @@ private_headers = [
|
||||
'gtkcssfontfeaturesvalueprivate.h',
|
||||
'gtkcssfontvariationsvalueprivate.h',
|
||||
'gtkcssiconthemevalueprivate.h',
|
||||
'gtkcssimagebuiltinprivate.h',
|
||||
'gtkcssimagecrossfadeprivate.h',
|
||||
'gtkcssimagefallbackprivate.h',
|
||||
'gtkcssimageiconthemeprivate.h',
|
||||
@@ -97,7 +96,6 @@ private_headers = [
|
||||
'gtkcsswidgetnodeprivate.h',
|
||||
'gtkcsswin32sizevalueprivate.h',
|
||||
'gtkdialogprivate.h',
|
||||
'gtkdndprivate.h',
|
||||
'gtkentryprivate.h',
|
||||
'gtkeventcontrollerlegacyprivate.h',
|
||||
'gtkeventcontrollerprivate.h',
|
||||
|
||||
@@ -903,6 +903,37 @@
|
||||
gtk_tooltip_set_custom().
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Switch to the new DND api</title>
|
||||
<para>
|
||||
The source-side DND apis in GTK 4 have been changed to use an event controller, #GtkDragSource.
|
||||
</para>
|
||||
<para>
|
||||
Instead of calling gtk_drag_source_set() and connecting to #GtkWidget signals, you create
|
||||
a #GtkDragSource object, attach it to the widget with gtk_widget_add_controller(), and connect
|
||||
to #GtkDragSource signals. Instead of calling gtk_drag_begin() on a widget to start a drag
|
||||
manually, call gdk_drag_begin().
|
||||
</para>
|
||||
<para>
|
||||
The ::drag-data-get signal has been replaced by the #GtkDragSource::prepare signal, which
|
||||
returns a #GdkContentProvider for the drag operation.
|
||||
</para>
|
||||
<para>
|
||||
The destination-side DND apis in GTK 4 have also been changed to use and event controller,
|
||||
#GTkDropTarget.
|
||||
</para>
|
||||
<para>
|
||||
Instead of calling gtk_drag_dest_set() and connecting to #GtkWidget signals, you create
|
||||
a #GtkDropTarget object, attach it to the widget with gtk_widget_add_controller(), and
|
||||
connect to #GtkDropTarget signals.
|
||||
</para>
|
||||
<para>
|
||||
The ::drag-motion signal has been renamed to #GtkDragSource::accept, and instead of
|
||||
::drag-data-received, you need to use async read methods on the #GdkDrop object, such
|
||||
as gdk_drop_read_value_async() or gdk_drop_read_text_async().
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
</chapter>
|
||||
|
||||
+239
-62
@@ -23,6 +23,10 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "gdkcontentformats.h"
|
||||
#include "gdkcontentserializer.h"
|
||||
#include "gdkcontentdeserializer.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
@@ -43,58 +47,6 @@
|
||||
|
||||
static GDBusProxy *file_transfer_proxy = NULL;
|
||||
|
||||
static GDBusProxy *
|
||||
ensure_file_transfer_portal (void)
|
||||
{
|
||||
if (file_transfer_proxy == NULL)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
file_transfer_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
|
||||
| G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS
|
||||
| G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
||||
NULL,
|
||||
"org.freedesktop.portal.Documents",
|
||||
"/org/freedesktop/portal/documents",
|
||||
"org.freedesktop.portal.FileTransfer",
|
||||
NULL, &error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_debug ("Failed to get proxy: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
if (file_transfer_proxy)
|
||||
{
|
||||
char *owner = g_dbus_proxy_get_name_owner (file_transfer_proxy);
|
||||
|
||||
if (owner)
|
||||
{
|
||||
g_free (owner);
|
||||
return file_transfer_proxy;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
file_transfer_portal_available (void)
|
||||
{
|
||||
gboolean available;
|
||||
|
||||
ensure_file_transfer_portal ();
|
||||
|
||||
available = file_transfer_proxy != NULL;
|
||||
|
||||
g_clear_object (&file_transfer_proxy);
|
||||
|
||||
return available;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GTask *task;
|
||||
const char **files;
|
||||
@@ -241,15 +193,12 @@ file_transfer_portal_register_files (const char **files,
|
||||
gpointer data)
|
||||
{
|
||||
GTask *task;
|
||||
GDBusProxy *proxy;
|
||||
AddFileData *afd;
|
||||
GVariantBuilder options;
|
||||
|
||||
task = g_task_new (NULL, NULL, callback, data);
|
||||
|
||||
proxy = ensure_file_transfer_portal ();
|
||||
|
||||
if (proxy == NULL)
|
||||
if (file_transfer_proxy == NULL)
|
||||
{
|
||||
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"No portal found");
|
||||
@@ -267,7 +216,7 @@ file_transfer_portal_register_files (const char **files,
|
||||
g_variant_builder_add (&options, "{sv}", "writable", g_variant_new_boolean (writable));
|
||||
g_variant_builder_add (&options, "{sv}", "autostop", g_variant_new_boolean (TRUE));
|
||||
|
||||
g_dbus_proxy_call (proxy, "StartTransfer",
|
||||
g_dbus_proxy_call (file_transfer_proxy, "StartTransfer",
|
||||
g_variant_new ("(a{sv})", &options),
|
||||
0, -1, NULL, start_session_done, afd);
|
||||
}
|
||||
@@ -319,15 +268,12 @@ file_transfer_portal_retrieve_files (const char *key,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
GDBusProxy *proxy;
|
||||
GTask *task;
|
||||
GVariantBuilder options;
|
||||
|
||||
task = g_task_new (NULL, NULL, callback, data);
|
||||
|
||||
proxy = ensure_file_transfer_portal ();
|
||||
|
||||
if (proxy == NULL)
|
||||
if (file_transfer_proxy == NULL)
|
||||
{
|
||||
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"No portal found");
|
||||
@@ -336,7 +282,7 @@ file_transfer_portal_retrieve_files (const char *key,
|
||||
}
|
||||
|
||||
g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT);
|
||||
g_dbus_proxy_call (proxy,
|
||||
g_dbus_proxy_call (file_transfer_proxy,
|
||||
"RetrieveFiles",
|
||||
g_variant_new ("(sa{sv})", key, &options),
|
||||
0, -1, NULL,
|
||||
@@ -357,4 +303,235 @@ file_transfer_portal_retrieve_files_finish (GAsyncResult *result,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* serializer */
|
||||
|
||||
static void
|
||||
file_serializer_finish (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer serializer)
|
||||
{
|
||||
GOutputStream *stream = G_OUTPUT_STREAM (source);
|
||||
GError *error = NULL;
|
||||
|
||||
if (!g_output_stream_write_all_finish (stream, result, NULL, &error))
|
||||
gdk_content_serializer_return_error (serializer, error);
|
||||
else
|
||||
gdk_content_serializer_return_success (serializer);
|
||||
}
|
||||
|
||||
static void
|
||||
portal_ready (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer serializer)
|
||||
{
|
||||
GError *error = NULL;
|
||||
char *key;
|
||||
|
||||
if (!file_transfer_portal_register_files_finish (result, &key, &error))
|
||||
{
|
||||
gdk_content_serializer_return_error (serializer, error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_output_stream_write_all_async (gdk_content_serializer_get_output_stream (serializer),
|
||||
key,
|
||||
strlen (key) + 1,
|
||||
gdk_content_serializer_get_priority (serializer),
|
||||
gdk_content_serializer_get_cancellable (serializer),
|
||||
file_serializer_finish,
|
||||
serializer);
|
||||
gdk_content_serializer_set_task_data (serializer, key, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
portal_file_serializer (GdkContentSerializer *serializer)
|
||||
{
|
||||
GFile *file;
|
||||
const GValue *value;
|
||||
GPtrArray *files;
|
||||
|
||||
files = g_ptr_array_new_with_free_func (g_free);
|
||||
|
||||
value = gdk_content_serializer_get_value (serializer);
|
||||
|
||||
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
|
||||
{
|
||||
file = g_value_get_object (gdk_content_serializer_get_value (serializer));
|
||||
if (file)
|
||||
g_ptr_array_add (files, g_file_get_path (file));
|
||||
g_ptr_array_add (files, NULL);
|
||||
}
|
||||
else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST))
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = g_value_get_boxed (value); l; l = l->next)
|
||||
g_ptr_array_add (files, g_file_get_path (l->data));
|
||||
|
||||
g_ptr_array_add (files, NULL);
|
||||
}
|
||||
|
||||
/* this call doesn't copy the strings, so keep the array around until the registration is done */
|
||||
file_transfer_portal_register_files ((const char **)files->pdata, TRUE, portal_ready, serializer);
|
||||
gdk_content_serializer_set_task_data (serializer, files, (GDestroyNotify)g_ptr_array_unref);
|
||||
}
|
||||
|
||||
/* deserializer */
|
||||
|
||||
static void
|
||||
portal_finish (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer deserializer)
|
||||
{
|
||||
char **files = NULL;
|
||||
GError *error = NULL;
|
||||
GValue *value;
|
||||
|
||||
if (!file_transfer_portal_retrieve_files_finish (result, &files, &error))
|
||||
{
|
||||
gdk_content_deserializer_return_error (deserializer, error);
|
||||
return;
|
||||
}
|
||||
|
||||
value = gdk_content_deserializer_get_value (deserializer);
|
||||
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
|
||||
{
|
||||
if (files[0] != NULL)
|
||||
g_value_take_object (value, g_file_new_for_path (files[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
GSList *l = NULL;
|
||||
gsize i;
|
||||
|
||||
for (i = 0; files[i] != NULL; i++)
|
||||
l = g_slist_prepend (l, g_file_new_for_path (files[i]));
|
||||
g_value_take_boxed (value, g_slist_reverse (l));
|
||||
}
|
||||
g_strfreev (files);
|
||||
|
||||
gdk_content_deserializer_return_success (deserializer);
|
||||
}
|
||||
|
||||
static void
|
||||
portal_file_deserializer_finish (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer deserializer)
|
||||
{
|
||||
GOutputStream *stream = G_OUTPUT_STREAM (source);
|
||||
GError *error = NULL;
|
||||
gssize written;
|
||||
char *key;
|
||||
|
||||
written = g_output_stream_splice_finish (stream, result, &error);
|
||||
if (written < 0)
|
||||
{
|
||||
gdk_content_deserializer_return_error (deserializer, error);
|
||||
return;
|
||||
}
|
||||
|
||||
/* write terminating NULL */
|
||||
if (!g_output_stream_write (stream, "", 1, NULL, &error))
|
||||
{
|
||||
gdk_content_deserializer_return_error (deserializer, error);
|
||||
return;
|
||||
}
|
||||
|
||||
key = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (stream));
|
||||
if (key == NULL)
|
||||
{
|
||||
GError *gerror = g_error_new (G_IO_ERROR,
|
||||
G_IO_ERROR_NOT_FOUND,
|
||||
"Could not convert data from %s to %s",
|
||||
gdk_content_deserializer_get_mime_type (deserializer),
|
||||
g_type_name (gdk_content_deserializer_get_gtype (deserializer)));
|
||||
gdk_content_deserializer_return_error (deserializer, gerror);
|
||||
return;
|
||||
}
|
||||
|
||||
file_transfer_portal_retrieve_files (key, portal_finish, deserializer);
|
||||
gdk_content_deserializer_set_task_data (deserializer, key, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
portal_file_deserializer (GdkContentDeserializer *deserializer)
|
||||
{
|
||||
GOutputStream *output;
|
||||
|
||||
output = g_memory_output_stream_new_resizable ();
|
||||
|
||||
g_output_stream_splice_async (output,
|
||||
gdk_content_deserializer_get_input_stream (deserializer),
|
||||
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
|
||||
gdk_content_deserializer_get_priority (deserializer),
|
||||
gdk_content_deserializer_get_cancellable (deserializer),
|
||||
portal_file_deserializer_finish,
|
||||
deserializer);
|
||||
g_object_unref (output);
|
||||
}
|
||||
|
||||
static void
|
||||
got_proxy (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
file_transfer_proxy = g_dbus_proxy_new_for_bus_finish (result, &error);
|
||||
if (!file_transfer_proxy)
|
||||
{
|
||||
g_message ("Failed to get file transfer portal: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
gdk_content_register_serializer (G_TYPE_FILE,
|
||||
"application/vnd.portal.files",
|
||||
portal_file_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
gdk_content_register_serializer (GDK_TYPE_FILE_LIST,
|
||||
"application/vnd.portal.files",
|
||||
portal_file_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
gdk_content_register_deserializer ("application/vnd.portal.files",
|
||||
GDK_TYPE_FILE_LIST,
|
||||
portal_file_deserializer,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
gdk_content_register_deserializer ("application/vnd.portal.files",
|
||||
G_TYPE_FILE,
|
||||
portal_file_deserializer,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
file_transfer_portal_register (void)
|
||||
{
|
||||
static gboolean called;
|
||||
|
||||
if (!called)
|
||||
{
|
||||
called = TRUE;
|
||||
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
|
||||
| G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS
|
||||
| G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
||||
NULL,
|
||||
"org.freedesktop.portal.Documents",
|
||||
"/org/freedesktop/portal/documents",
|
||||
"org.freedesktop.portal.FileTransfer",
|
||||
NULL,
|
||||
got_proxy,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* G_OS_UNIX */
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
#define __FILE_TRANSFER_PROTOCOL_H__
|
||||
|
||||
|
||||
gboolean file_transfer_portal_available (void);
|
||||
void file_transfer_portal_register (void);
|
||||
|
||||
void file_transfer_portal_register_files (const char **files,
|
||||
gboolean writable,
|
||||
GAsyncReadyCallback callback,
|
||||
|
||||
@@ -212,14 +212,14 @@ gdk_pre_parse (void)
|
||||
_gdk_debug_flags = g_parse_debug_string (debug_string,
|
||||
(GDebugKey *) gdk_debug_keys,
|
||||
G_N_ELEMENTS (gdk_debug_keys));
|
||||
|
||||
if (g_getenv ("GTK_TRACE_FD"))
|
||||
gdk_profiler_start (atoi (g_getenv ("GTK_TRACE_FD")));
|
||||
else if (g_getenv ("GTK_TRACE"))
|
||||
gdk_profiler_start (-1);
|
||||
}
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
|
||||
if (g_getenv ("GTK_TRACE_FD"))
|
||||
gdk_profiler_start (atoi (g_getenv ("GTK_TRACE_FD")));
|
||||
else if (g_getenv ("GTK_TRACE"))
|
||||
gdk_profiler_start (-1);
|
||||
|
||||
#ifndef G_HAS_CONSTRUCTORS
|
||||
stash_desktop_startup_notification_id ();
|
||||
#endif
|
||||
|
||||
+65
-105
@@ -24,6 +24,7 @@
|
||||
#include "gdkcontentformats.h"
|
||||
#include "filetransferportalprivate.h"
|
||||
#include "gdktexture.h"
|
||||
#include "gdkrgbaprivate.h"
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
@@ -691,95 +692,6 @@ string_deserializer (GdkContentDeserializer *deserializer)
|
||||
g_object_unref (filter);
|
||||
}
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
static void
|
||||
portal_finish (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer deserializer)
|
||||
{
|
||||
char **files = NULL;
|
||||
GError *error = NULL;
|
||||
GValue *value;
|
||||
|
||||
if (!file_transfer_portal_retrieve_files_finish (result, &files, &error))
|
||||
{
|
||||
gdk_content_deserializer_return_error (deserializer, error);
|
||||
return;
|
||||
}
|
||||
|
||||
value = gdk_content_deserializer_get_value (deserializer);
|
||||
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
|
||||
{
|
||||
if (files[0] != NULL)
|
||||
g_value_take_object (value, g_file_new_for_path (files[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
GSList *l = NULL;
|
||||
gsize i;
|
||||
|
||||
for (i = 0; files[i] != NULL; i++)
|
||||
l = g_slist_prepend (l, g_file_new_for_path (files[i]));
|
||||
g_value_take_boxed (value, g_slist_reverse (l));
|
||||
}
|
||||
g_strfreev (files);
|
||||
|
||||
gdk_content_deserializer_return_success (deserializer);
|
||||
}
|
||||
|
||||
static void
|
||||
portal_file_deserializer_finish (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer deserializer)
|
||||
{
|
||||
GOutputStream *stream = G_OUTPUT_STREAM (source);
|
||||
GError *error = NULL;
|
||||
gssize written;
|
||||
char *key;
|
||||
|
||||
written = g_output_stream_splice_finish (stream, result, &error);
|
||||
if (written < 0)
|
||||
{
|
||||
gdk_content_deserializer_return_error (deserializer, error);
|
||||
return;
|
||||
}
|
||||
|
||||
/* write terminating NULL */
|
||||
if (!g_output_stream_write (stream, "", 1, NULL, &error))
|
||||
{
|
||||
gdk_content_deserializer_return_error (deserializer, error);
|
||||
return;
|
||||
}
|
||||
|
||||
key = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (stream));
|
||||
if (key == NULL)
|
||||
{
|
||||
deserialize_not_found (deserializer);
|
||||
return;
|
||||
}
|
||||
|
||||
file_transfer_portal_retrieve_files (key, portal_finish, deserializer);
|
||||
gdk_content_deserializer_set_task_data (deserializer, key, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
portal_file_deserializer (GdkContentDeserializer *deserializer)
|
||||
{
|
||||
GOutputStream *output;
|
||||
|
||||
output = g_memory_output_stream_new_resizable ();
|
||||
|
||||
g_output_stream_splice_async (output,
|
||||
gdk_content_deserializer_get_input_stream (deserializer),
|
||||
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
|
||||
gdk_content_deserializer_get_priority (deserializer),
|
||||
gdk_content_deserializer_get_cancellable (deserializer),
|
||||
portal_file_deserializer_finish,
|
||||
deserializer);
|
||||
g_object_unref (output);
|
||||
}
|
||||
#endif /* G_OS_UNIX */
|
||||
|
||||
static void
|
||||
file_uri_deserializer_finish (GObject *source,
|
||||
GAsyncResult *result,
|
||||
@@ -848,6 +760,63 @@ file_uri_deserializer (GdkContentDeserializer *deserializer)
|
||||
g_object_unref (output);
|
||||
}
|
||||
|
||||
static void
|
||||
color_deserializer_finish (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer deserializer)
|
||||
{
|
||||
GOutputStream *stream = G_OUTPUT_STREAM (source);
|
||||
GError *error = NULL;
|
||||
gssize written;
|
||||
|
||||
written = g_output_stream_splice_finish (stream, result, &error);
|
||||
if (written < 0)
|
||||
{
|
||||
gdk_content_deserializer_return_error (deserializer, error);
|
||||
return;
|
||||
}
|
||||
else if (written == 0)
|
||||
{
|
||||
GdkRGBA black = GDK_RGBA ("000");
|
||||
|
||||
/* Never return NULL, we only return that on error */
|
||||
g_value_set_boxed (gdk_content_deserializer_get_value (deserializer), &black);
|
||||
}
|
||||
else
|
||||
{
|
||||
guint16 *data;
|
||||
GdkRGBA rgba;
|
||||
|
||||
data = (guint16 *)g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (stream));
|
||||
rgba.red = data[0] / 65535.0;
|
||||
rgba.green = data[1] / 65535.0;
|
||||
rgba.blue = data[2] / 65535.0;
|
||||
rgba.alpha = data[3] / 65535.0;
|
||||
|
||||
g_value_set_boxed (gdk_content_deserializer_get_value (deserializer), &rgba);
|
||||
}
|
||||
gdk_content_deserializer_return_success (deserializer);
|
||||
}
|
||||
|
||||
static void
|
||||
color_deserializer (GdkContentDeserializer *deserializer)
|
||||
{
|
||||
GOutputStream *output;
|
||||
guint16 *data;
|
||||
|
||||
data = g_new0 (guint16, 4);
|
||||
output = g_memory_output_stream_new (data, 4 * sizeof (guint16), NULL, g_free);
|
||||
|
||||
g_output_stream_splice_async (output,
|
||||
gdk_content_deserializer_get_input_stream (deserializer),
|
||||
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
|
||||
gdk_content_deserializer_get_priority (deserializer),
|
||||
gdk_content_deserializer_get_cancellable (deserializer),
|
||||
color_deserializer_finish,
|
||||
deserializer);
|
||||
g_object_unref (output);
|
||||
}
|
||||
|
||||
static void
|
||||
init (void)
|
||||
{
|
||||
@@ -907,13 +876,7 @@ init (void)
|
||||
g_slist_free (formats);
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
gboolean has_portal = file_transfer_portal_available ();
|
||||
if (has_portal)
|
||||
gdk_content_register_deserializer ("application/vnd.portal.files",
|
||||
GDK_TYPE_FILE_LIST,
|
||||
portal_file_deserializer,
|
||||
NULL,
|
||||
NULL);
|
||||
file_transfer_portal_register ();
|
||||
#endif
|
||||
|
||||
gdk_content_register_deserializer ("text/uri-list",
|
||||
@@ -922,15 +885,6 @@ init (void)
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
if (has_portal)
|
||||
gdk_content_register_deserializer ("application/vnd.portal.files",
|
||||
G_TYPE_FILE,
|
||||
portal_file_deserializer,
|
||||
NULL,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
gdk_content_register_deserializer ("text/uri-list",
|
||||
G_TYPE_FILE,
|
||||
file_uri_deserializer,
|
||||
@@ -956,5 +910,11 @@ init (void)
|
||||
string_deserializer,
|
||||
(gpointer) "ASCII",
|
||||
NULL);
|
||||
|
||||
gdk_content_register_deserializer ("application/x-color",
|
||||
GDK_TYPE_RGBA,
|
||||
color_deserializer,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "gdkcontentprovider.h"
|
||||
|
||||
#include "gdkcontentformats.h"
|
||||
#include "gdkcontentserializer.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdkcontentproviderimpl.h"
|
||||
|
||||
@@ -280,3 +281,232 @@ gdk_content_provider_new_for_bytes (const char *mime_type,
|
||||
|
||||
return GDK_CONTENT_PROVIDER (content);
|
||||
}
|
||||
|
||||
#define GDK_TYPE_CONTENT_PROVIDER_CALLBACK (gdk_content_provider_callback_get_type ())
|
||||
#define GDK_CONTENT_PROVIDER_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_CONTENT_PROVIDER_CALLBACK, GdkContentProviderCallback))
|
||||
|
||||
typedef struct _GdkContentProviderCallback GdkContentProviderCallback;
|
||||
typedef struct _GdkContentProviderCallbackClass GdkContentProviderCallbackClass;
|
||||
|
||||
struct _GdkContentProviderCallback
|
||||
{
|
||||
GdkContentProvider parent;
|
||||
|
||||
GType type;
|
||||
GdkContentProviderGetValueFunc func;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
struct _GdkContentProviderCallbackClass
|
||||
{
|
||||
GdkContentProviderClass parent_class;
|
||||
};
|
||||
|
||||
GType gdk_content_provider_callback_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_DEFINE_TYPE (GdkContentProviderCallback, gdk_content_provider_callback, GDK_TYPE_CONTENT_PROVIDER)
|
||||
|
||||
static GdkContentFormats *
|
||||
gdk_content_provider_callback_ref_formats (GdkContentProvider *provider)
|
||||
{
|
||||
GdkContentProviderCallback *callback = GDK_CONTENT_PROVIDER_CALLBACK (provider);
|
||||
|
||||
return gdk_content_formats_new_for_gtype (callback->type);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_content_provider_callback_get_value (GdkContentProvider *provider,
|
||||
GValue *value,
|
||||
GError **error)
|
||||
{
|
||||
GdkContentProviderCallback *callback = GDK_CONTENT_PROVIDER_CALLBACK (provider);
|
||||
|
||||
if (G_VALUE_HOLDS (value, callback->type) && callback->func != NULL)
|
||||
{
|
||||
callback->func (value, callback->data);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return GDK_CONTENT_PROVIDER_CLASS (gdk_content_provider_callback_parent_class)->get_value (provider, value, error);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_content_provider_callback_class_init (GdkContentProviderCallbackClass *class)
|
||||
{
|
||||
GdkContentProviderClass *provider_class = GDK_CONTENT_PROVIDER_CLASS (class);
|
||||
|
||||
provider_class->ref_formats = gdk_content_provider_callback_ref_formats;
|
||||
provider_class->get_value = gdk_content_provider_callback_get_value;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_content_provider_callback_init (GdkContentProviderCallback *content)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_content_provider_new_for_callback:
|
||||
* @type: the type that the callback provides
|
||||
* @func: callback to populate a #GValue
|
||||
* @data: (closure): data that gets passed to @func
|
||||
*
|
||||
* Create a content provider that provides data that is provided via a callback.
|
||||
*
|
||||
* Returns: a new #GdkContentProvider
|
||||
**/
|
||||
GdkContentProvider *
|
||||
gdk_content_provider_new_with_callback (GType type,
|
||||
GdkContentProviderGetValueFunc func,
|
||||
gpointer data)
|
||||
{
|
||||
GdkContentProviderCallback *content;
|
||||
|
||||
content = g_object_new (GDK_TYPE_CONTENT_PROVIDER_CALLBACK, NULL);
|
||||
content->type = type;
|
||||
content->func = func;
|
||||
content->data = data;
|
||||
|
||||
return GDK_CONTENT_PROVIDER (content);
|
||||
}
|
||||
|
||||
#define GDK_TYPE_CONTENT_PROVIDER_CALLBACK2 (gdk_content_provider_callback2_get_type ())
|
||||
#define GDK_CONTENT_PROVIDER_CALLBACK2(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_CONTENT_PROVIDER_CALLBACK2, GdkContentProviderCallback2))
|
||||
|
||||
typedef struct _GdkContentProviderCallback2 GdkContentProviderCallback2;
|
||||
typedef struct _GdkContentProviderCallback2Class GdkContentProviderCallback2Class;
|
||||
|
||||
struct _GdkContentProviderCallback2
|
||||
{
|
||||
GdkContentProvider parent;
|
||||
|
||||
GdkContentFormats *formats;
|
||||
GdkContentProviderGetBytesFunc func;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
struct _GdkContentProviderCallback2Class
|
||||
{
|
||||
GdkContentProviderClass parent_class;
|
||||
};
|
||||
|
||||
GType gdk_content_provider_callback2_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_DEFINE_TYPE (GdkContentProviderCallback2, gdk_content_provider_callback2, GDK_TYPE_CONTENT_PROVIDER)
|
||||
|
||||
static GdkContentFormats *
|
||||
gdk_content_provider_callback2_ref_formats (GdkContentProvider *provider)
|
||||
{
|
||||
GdkContentProviderCallback2 *callback = GDK_CONTENT_PROVIDER_CALLBACK2 (provider);
|
||||
|
||||
return gdk_content_formats_ref (callback->formats);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_content_provider_callback2_write_mime_type_done (GObject *stream,
|
||||
GAsyncResult *result,
|
||||
gpointer task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!g_output_stream_write_all_finish (G_OUTPUT_STREAM (stream), result, NULL, &error))
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_task_return_boolean (task, TRUE);
|
||||
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_content_provider_callback2_write_mime_type_async (GdkContentProvider *provider,
|
||||
const char *mime_type,
|
||||
GOutputStream *stream,
|
||||
int io_priority,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkContentProviderCallback2 *content = GDK_CONTENT_PROVIDER_CALLBACK2 (provider);
|
||||
GTask *task;
|
||||
GBytes *bytes;
|
||||
|
||||
task = g_task_new (content, cancellable, callback, user_data);
|
||||
g_task_set_priority (task, io_priority);
|
||||
g_task_set_source_tag (task, gdk_content_provider_callback2_write_mime_type_async);
|
||||
|
||||
if (!gdk_content_formats_contain_mime_type (content->formats, mime_type))
|
||||
{
|
||||
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("Cannot provide contents as “%s”"), mime_type);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
bytes = content->func (mime_type, content->data);
|
||||
if (!bytes)
|
||||
{
|
||||
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("Failed to get contents as “%s”"), mime_type);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
g_object_set_data_full (G_OBJECT (task), "bytes", bytes, (GDestroyNotify)g_bytes_unref);
|
||||
|
||||
g_output_stream_write_all_async (stream,
|
||||
g_bytes_get_data (bytes, NULL),
|
||||
g_bytes_get_size (bytes),
|
||||
io_priority,
|
||||
cancellable,
|
||||
gdk_content_provider_callback2_write_mime_type_done,
|
||||
task);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_content_provider_callback2_write_mime_type_finish (GdkContentProvider *provider,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (result, provider), FALSE);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gdk_content_provider_callback2_write_mime_type_async, FALSE);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_content_provider_callback2_class_init (GdkContentProviderCallback2Class *class)
|
||||
{
|
||||
GdkContentProviderClass *provider_class = GDK_CONTENT_PROVIDER_CLASS (class);
|
||||
|
||||
provider_class->ref_formats = gdk_content_provider_callback2_ref_formats;
|
||||
provider_class->write_mime_type_async = gdk_content_provider_callback2_write_mime_type_async;
|
||||
provider_class->write_mime_type_finish = gdk_content_provider_callback2_write_mime_type_finish;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_content_provider_callback2_init (GdkContentProviderCallback2 *content)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_content_provider_new_with_formats:
|
||||
* @formats: formats to advertise
|
||||
* @func: callback to populate a #GValue
|
||||
* @data: data that gets passed to @func
|
||||
*
|
||||
* Create a content provider that provides data that is provided via a callback.
|
||||
*
|
||||
* Returns: a new #GdkContentProvider
|
||||
**/
|
||||
GdkContentProvider *
|
||||
gdk_content_provider_new_with_formats (GdkContentFormats *formats,
|
||||
GdkContentProviderGetBytesFunc func,
|
||||
gpointer data)
|
||||
{
|
||||
GdkContentProviderCallback2 *content;
|
||||
content = g_object_new (GDK_TYPE_CONTENT_PROVIDER_CALLBACK2, NULL);
|
||||
content->formats = gdk_content_formats_union_serialize_mime_types (gdk_content_formats_ref (formats));
|
||||
content->func = func;
|
||||
content->data = data;
|
||||
|
||||
return GDK_CONTENT_PROVIDER (content);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,21 @@ GDK_AVAILABLE_IN_ALL
|
||||
GdkContentProvider * gdk_content_provider_new_for_bytes (const char *mime_type,
|
||||
GBytes *bytes);
|
||||
|
||||
typedef void (*GdkContentProviderGetValueFunc) (GValue *value,
|
||||
gpointer data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkContentProvider * gdk_content_provider_new_with_callback (GType type,
|
||||
GdkContentProviderGetValueFunc func,
|
||||
gpointer data);
|
||||
|
||||
typedef GBytes * (*GdkContentProviderGetBytesFunc) (const char *mime_type,
|
||||
gpointer data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkContentProvider * gdk_content_provider_new_with_formats (GdkContentFormats *formats,
|
||||
GdkContentProviderGetBytesFunc func,
|
||||
gpointer data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+50
-76
@@ -25,6 +25,7 @@
|
||||
#include "gdkpixbuf.h"
|
||||
#include "filetransferportalprivate.h"
|
||||
#include "gdktextureprivate.h"
|
||||
#include "gdkrgba.h"
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <string.h>
|
||||
@@ -702,65 +703,6 @@ file_serializer_finish (GObject *source,
|
||||
gdk_content_serializer_return_success (serializer);
|
||||
}
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
static void
|
||||
portal_ready (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer serializer)
|
||||
{
|
||||
GError *error = NULL;
|
||||
char *key;
|
||||
|
||||
if (!file_transfer_portal_register_files_finish (result, &key, &error))
|
||||
{
|
||||
gdk_content_serializer_return_error (serializer, error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_output_stream_write_all_async (gdk_content_serializer_get_output_stream (serializer),
|
||||
key,
|
||||
strlen (key) + 1,
|
||||
gdk_content_serializer_get_priority (serializer),
|
||||
gdk_content_serializer_get_cancellable (serializer),
|
||||
file_serializer_finish,
|
||||
serializer);
|
||||
gdk_content_serializer_set_task_data (serializer, key, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
portal_file_serializer (GdkContentSerializer *serializer)
|
||||
{
|
||||
GFile *file;
|
||||
const GValue *value;
|
||||
GPtrArray *files;
|
||||
|
||||
files = g_ptr_array_new_with_free_func (g_free);
|
||||
|
||||
value = gdk_content_serializer_get_value (serializer);
|
||||
|
||||
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
|
||||
{
|
||||
file = g_value_get_object (gdk_content_serializer_get_value (serializer));
|
||||
if (file)
|
||||
g_ptr_array_add (files, g_file_get_path (file));
|
||||
g_ptr_array_add (files, NULL);
|
||||
}
|
||||
else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST))
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = g_value_get_boxed (value); l; l = l->next)
|
||||
g_ptr_array_add (files, g_file_get_path (l->data));
|
||||
|
||||
g_ptr_array_add (files, NULL);
|
||||
}
|
||||
|
||||
/* this call doesn't copy the strings, so keep the array around until the registration is done */
|
||||
file_transfer_portal_register_files ((const char **)files->pdata, TRUE, portal_ready, serializer);
|
||||
gdk_content_serializer_set_task_data (serializer, files, (GDestroyNotify)g_ptr_array_unref);
|
||||
}
|
||||
#endif /* G_OS_UNIX */
|
||||
|
||||
static void
|
||||
file_uri_serializer (GdkContentSerializer *serializer)
|
||||
{
|
||||
@@ -862,6 +804,48 @@ file_text_serializer (GdkContentSerializer *serializer)
|
||||
gdk_content_serializer_set_task_data (serializer, path, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
color_serializer_finish (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer serializer)
|
||||
{
|
||||
GOutputStream *stream = G_OUTPUT_STREAM (source);
|
||||
GError *error = NULL;
|
||||
|
||||
if (!g_output_stream_write_all_finish (stream, result, NULL, &error))
|
||||
gdk_content_serializer_return_error (serializer, error);
|
||||
else
|
||||
gdk_content_serializer_return_success (serializer);
|
||||
}
|
||||
|
||||
static void
|
||||
color_serializer (GdkContentSerializer *serializer)
|
||||
{
|
||||
const GValue *value;
|
||||
GdkRGBA *rgba;
|
||||
guint16 *data;
|
||||
|
||||
value = gdk_content_serializer_get_value (serializer);
|
||||
rgba = g_value_get_boxed (value);
|
||||
data = g_new0 (guint16, 4);
|
||||
if (rgba)
|
||||
{
|
||||
data[0] = (guint16) (rgba->red * 65535);
|
||||
data[1] = (guint16) (rgba->green * 65535);
|
||||
data[2] = (guint16) (rgba->blue * 65535);
|
||||
data[3] = (guint16) (rgba->alpha * 65535);
|
||||
}
|
||||
|
||||
g_output_stream_write_all_async (gdk_content_serializer_get_output_stream (serializer),
|
||||
data,
|
||||
4 * sizeof (guint16),
|
||||
gdk_content_serializer_get_priority (serializer),
|
||||
gdk_content_serializer_get_cancellable (serializer),
|
||||
color_serializer_finish,
|
||||
serializer);
|
||||
gdk_content_serializer_set_task_data (serializer, data, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
init (void)
|
||||
{
|
||||
@@ -924,14 +908,7 @@ init (void)
|
||||
g_slist_free (formats);
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
gboolean has_portal = file_transfer_portal_available ();
|
||||
|
||||
if (has_portal)
|
||||
gdk_content_register_serializer (G_TYPE_FILE,
|
||||
"application/vnd.portal.files",
|
||||
portal_file_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
file_transfer_portal_register ();
|
||||
#endif
|
||||
|
||||
gdk_content_register_serializer (G_TYPE_FILE,
|
||||
@@ -945,15 +922,6 @@ init (void)
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
if (has_portal)
|
||||
gdk_content_register_serializer (GDK_TYPE_FILE_LIST,
|
||||
"application/vnd.portal.files",
|
||||
portal_file_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
gdk_content_register_serializer (GDK_TYPE_FILE_LIST,
|
||||
"text/uri-list",
|
||||
file_uri_serializer,
|
||||
@@ -984,5 +952,11 @@ init (void)
|
||||
string_serializer,
|
||||
(gpointer) "ASCII",
|
||||
NULL);
|
||||
|
||||
gdk_content_register_serializer (GDK_TYPE_RGBA,
|
||||
"application/x-color",
|
||||
color_serializer,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
+17
-7
@@ -90,20 +90,30 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrag, gdk_drag, G_TYPE_OBJECT)
|
||||
|
||||
/**
|
||||
* SECTION:dnd
|
||||
* @title: Drag And Drop
|
||||
* @short_description: Functions for controlling drag and drop handling
|
||||
* @Title: Drag And Drop
|
||||
* @Short_description: Functions for controlling drag and drop handling
|
||||
*
|
||||
* These functions provide a low level interface for drag and drop.
|
||||
* These functions provide a low-level interface for drag and drop.
|
||||
*
|
||||
* The GdkDrag object represents the source side of an ongoing DND operation.
|
||||
* It is created when a drag is started, and stays alive for duration of
|
||||
* the DND operation.
|
||||
* the DND operation. After a drag has been started with gdk_drag_begin(),
|
||||
* the caller gets informed about the status of the ongoing drag operation
|
||||
* with signals on the #GtkDrag object.
|
||||
*
|
||||
* The GdkDrop object represents the target side of an ongoing DND operation.
|
||||
* Possible drop sites get informed about the status of the ongoing drag operation
|
||||
* with events of type %GDK_DRAG_ENTER, %GDK_DRAG_LEAVE, %GDK_DRAG_MOTION and
|
||||
* %GDK_DROP_START. The #GdkDrop object can be obtained from these #GdkEvents
|
||||
* using gdk_event_get_drop().
|
||||
*
|
||||
* The actual data transfer is initiated from the target side via an async
|
||||
* read, using one of the GdkDrop functions for this purpose: gdk_drop_read_async(),
|
||||
* gdk_drop_read_value_async() or gdk_drop_read_text_async().
|
||||
*
|
||||
* GTK+ provides a higher level abstraction based on top of these functions,
|
||||
* and so they are not normally needed in GTK+ applications. See the
|
||||
* [Drag and Drop][gtk4-Drag-and-Drop] section of the GTK+ documentation
|
||||
* GTK provides a higher level abstraction based on top of these functions,
|
||||
* and so they are not normally needed in GTK applications. See the
|
||||
* [Drag and Drop][gtk4-Drag-and-Drop] section of the GTK documentation
|
||||
* for more information.
|
||||
*/
|
||||
|
||||
|
||||
+31
-1
@@ -448,7 +448,10 @@ gdk_drop_get_surface (GdkDrop *self)
|
||||
* Returns the possible actions for this #GdkDrop. If this value
|
||||
* contains multiple actions - ie gdk_drag_action_is_unique()
|
||||
* returns %FALSE for the result - gdk_drag_finish() must choose
|
||||
* the action to use when accepting the drop.
|
||||
* the action to use when accepting the drop. This will only
|
||||
* happen if you passed %GDK_ACTION_ASK as one of the possible
|
||||
* actions in gdk_drag_status(). %GDK_ACTION_ASK itself will not
|
||||
* be included in the actions returned by this function.
|
||||
*
|
||||
* This value may change over the lifetime of the #GdkDrop both
|
||||
* as a response to source side actions as well as to calls to
|
||||
@@ -998,3 +1001,30 @@ gdk_drop_emit_drop_event (GdkDrop *self,
|
||||
gdk_drop_do_emit_event (event, dont_queue);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drop_has_value:
|
||||
* @self: a #GdkDrop
|
||||
* @type: the type to check
|
||||
*
|
||||
* Returns whether calling gdk_drop_read_value_async() for @type
|
||||
* can succeed.
|
||||
*
|
||||
* Returns: %TRUE if the data can be deserialized to the given type
|
||||
*/
|
||||
gboolean
|
||||
gdk_drop_has_value (GdkDrop *self,
|
||||
GType type)
|
||||
{
|
||||
GdkContentFormats *formats;
|
||||
gboolean ret;
|
||||
|
||||
formats = gdk_content_formats_ref (gdk_drop_get_formats (self));
|
||||
formats = gdk_content_formats_union_deserialize_gtypes (formats);
|
||||
|
||||
ret = gdk_content_formats_contain_gtype (formats, type);
|
||||
|
||||
gdk_content_formats_unref (formats);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,9 @@ char * gdk_drop_read_text_finish (GdkDrop
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_drop_has_value (GdkDrop *self,
|
||||
GType type);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -1013,6 +1013,13 @@ gdk_event_set_coords (GdkEvent *event,
|
||||
event->touchpad_pinch.x = x;
|
||||
event->touchpad_pinch.y = y;
|
||||
break;
|
||||
case GDK_DRAG_ENTER:
|
||||
case GDK_DRAG_LEAVE:
|
||||
case GDK_DRAG_MOTION:
|
||||
case GDK_DROP_START:
|
||||
event->dnd.x = x;
|
||||
event->dnd.y = y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
+50
-19
@@ -649,46 +649,94 @@ gdk_frame_clock_get_refresh_info (GdkFrameClock *frame_clock,
|
||||
void
|
||||
_gdk_frame_clock_emit_flush_events (GdkFrameClock *frame_clock)
|
||||
{
|
||||
guint64 before = g_get_monotonic_time ();
|
||||
|
||||
g_signal_emit (frame_clock, signals[FLUSH_EVENTS], 0);
|
||||
|
||||
if (gdk_profiler_is_running ())
|
||||
gdk_profiler_add_mark (before * 1000,
|
||||
(g_get_monotonic_time () - before) * 1000,
|
||||
"frameclock ::flush-events", "");
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_frame_clock_emit_before_paint (GdkFrameClock *frame_clock)
|
||||
{
|
||||
guint64 before = g_get_monotonic_time ();
|
||||
|
||||
g_signal_emit (frame_clock, signals[BEFORE_PAINT], 0);
|
||||
|
||||
if (gdk_profiler_is_running ())
|
||||
gdk_profiler_add_mark (before * 1000,
|
||||
(g_get_monotonic_time () - before) * 1000,
|
||||
"frameclock ::before-paint", "");
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_frame_clock_emit_update (GdkFrameClock *frame_clock)
|
||||
{
|
||||
guint64 before = g_get_monotonic_time ();
|
||||
|
||||
g_signal_emit (frame_clock, signals[UPDATE], 0);
|
||||
|
||||
if (gdk_profiler_is_running ())
|
||||
gdk_profiler_add_mark (before * 1000,
|
||||
(g_get_monotonic_time () - before) * 1000,
|
||||
"frameclock ::update", "");
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_frame_clock_emit_layout (GdkFrameClock *frame_clock)
|
||||
{
|
||||
guint64 before = g_get_monotonic_time ();
|
||||
|
||||
g_signal_emit (frame_clock, signals[LAYOUT], 0);
|
||||
|
||||
if (gdk_profiler_is_running ())
|
||||
gdk_profiler_add_mark (before * 1000,
|
||||
(g_get_monotonic_time () - before) * 1000,
|
||||
"frameclock ::layout", "");
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_frame_clock_emit_paint (GdkFrameClock *frame_clock)
|
||||
{
|
||||
guint64 before = g_get_monotonic_time ();
|
||||
|
||||
g_signal_emit (frame_clock, signals[PAINT], 0);
|
||||
|
||||
if (gdk_profiler_is_running ())
|
||||
gdk_profiler_add_mark (before * 1000,
|
||||
(g_get_monotonic_time () - before) * 1000,
|
||||
"frameclock ::paint", "");
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_frame_clock_emit_after_paint (GdkFrameClock *frame_clock)
|
||||
{
|
||||
guint64 before = g_get_monotonic_time ();
|
||||
|
||||
g_signal_emit (frame_clock, signals[AFTER_PAINT], 0);
|
||||
|
||||
if (gdk_profiler_is_running ())
|
||||
gdk_profiler_add_mark (before * 1000,
|
||||
(g_get_monotonic_time () - before) * 1000,
|
||||
"frameclock ::after-paint", "");
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_frame_clock_emit_resume_events (GdkFrameClock *frame_clock)
|
||||
{
|
||||
guint64 before = g_get_monotonic_time ();
|
||||
|
||||
g_signal_emit (frame_clock, signals[RESUME_EVENTS], 0);
|
||||
|
||||
if (gdk_profiler_is_running ())
|
||||
gdk_profiler_add_mark (before * 1000,
|
||||
(g_get_monotonic_time () - before) * 1000,
|
||||
"frameclock ::resume-events", "");
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
static gint64
|
||||
guess_refresh_interval (GdkFrameClock *frame_clock)
|
||||
{
|
||||
@@ -758,34 +806,17 @@ frame_clock_get_fps (GdkFrameClock *frame_clock)
|
||||
|
||||
return ((double) end_counter - start_counter) * G_USEC_PER_SEC / (end_timestamp - start_timestamp);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
_gdk_frame_clock_add_timings_to_profiler (GdkFrameClock *clock,
|
||||
GdkFrameTimings *timings)
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
gdk_profiler_add_mark (timings->frame_time * 1000,
|
||||
(timings->frame_end_time - timings->frame_time) * 1000,
|
||||
"frame", "");
|
||||
|
||||
if (timings->layout_start_time != 0)
|
||||
gdk_profiler_add_mark (timings->layout_start_time * 1000,
|
||||
(timings->paint_start_time - timings->layout_start_time) * 1000,
|
||||
"layout", "");
|
||||
|
||||
if (timings->paint_start_time != 0)
|
||||
gdk_profiler_add_mark (timings->paint_start_time * 1000,
|
||||
(timings->frame_end_time - timings->paint_start_time) * 1000,
|
||||
"paint", "");
|
||||
|
||||
if (timings->presentation_time != 0)
|
||||
gdk_profiler_add_mark (timings->presentation_time * 1000,
|
||||
0,
|
||||
"presentation", "");
|
||||
|
||||
gdk_profiler_set_counter (fps_counter,
|
||||
timings->frame_end_time * 1000,
|
||||
timings->presentation_time * 1000,
|
||||
frame_clock_get_fps (clock));
|
||||
#endif
|
||||
}
|
||||
|
||||
+10
-12
@@ -42,9 +42,7 @@ struct _GdkFrameClockIdlePrivate
|
||||
gint64 frame_time;
|
||||
gint64 min_next_frame_time;
|
||||
gint64 sleep_serial;
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
gint64 freeze_time;
|
||||
#endif
|
||||
|
||||
guint flush_idle_id;
|
||||
guint paint_idle_id;
|
||||
@@ -319,6 +317,7 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
GdkFrameClockIdlePrivate *priv = clock_idle->priv;
|
||||
gboolean skip_to_resume_events;
|
||||
GdkFrameTimings *timings = NULL;
|
||||
gint64 before = g_get_monotonic_time ();
|
||||
|
||||
priv->paint_idle_id = 0;
|
||||
priv->in_paint_idle = TRUE;
|
||||
@@ -409,13 +408,13 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
{
|
||||
int iter;
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DEBUG_CHECK (FRAMES) || gdk_profiler_is_running ())
|
||||
if (GDK_DEBUG_CHECK (FRAMES))
|
||||
{
|
||||
if (priv->phase != GDK_FRAME_CLOCK_PHASE_LAYOUT &&
|
||||
(priv->requested & GDK_FRAME_CLOCK_PHASE_LAYOUT))
|
||||
timings->layout_start_time = g_get_monotonic_time ();
|
||||
}
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
#endif
|
||||
|
||||
priv->phase = GDK_FRAME_CLOCK_PHASE_LAYOUT;
|
||||
/* We loop in the layout phase, because we don't want to progress
|
||||
@@ -439,13 +438,13 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
if (priv->freeze_count == 0)
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DEBUG_CHECK (FRAMES) || gdk_profiler_is_running ())
|
||||
if (GDK_DEBUG_CHECK (FRAMES))
|
||||
{
|
||||
if (priv->phase != GDK_FRAME_CLOCK_PHASE_PAINT &&
|
||||
(priv->requested & GDK_FRAME_CLOCK_PHASE_PAINT))
|
||||
timings->paint_start_time = g_get_monotonic_time ();
|
||||
}
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
#endif
|
||||
|
||||
priv->phase = GDK_FRAME_CLOCK_PHASE_PAINT;
|
||||
if (priv->requested & GDK_FRAME_CLOCK_PHASE_PAINT)
|
||||
@@ -466,7 +465,7 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
priv->phase = GDK_FRAME_CLOCK_PHASE_NONE;
|
||||
}
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DEBUG_CHECK (FRAMES) || gdk_profiler_is_running ())
|
||||
if (GDK_DEBUG_CHECK (FRAMES))
|
||||
timings->frame_end_time = g_get_monotonic_time ();
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
G_GNUC_FALLTHROUGH;
|
||||
@@ -502,6 +501,9 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
if (priv->freeze_count == 0)
|
||||
priv->sleep_serial = get_sleep_serial ();
|
||||
|
||||
if (gdk_profiler_is_running ())
|
||||
gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "frameclock", "paint_idle");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -561,13 +563,11 @@ gdk_frame_clock_idle_freeze (GdkFrameClock *clock)
|
||||
GdkFrameClockIdle *clock_idle = GDK_FRAME_CLOCK_IDLE (clock);
|
||||
GdkFrameClockIdlePrivate *priv = clock_idle->priv;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (priv->freeze_count == 0)
|
||||
{
|
||||
if (gdk_profiler_is_running ())
|
||||
priv->freeze_time = g_get_monotonic_time ();
|
||||
}
|
||||
#endif
|
||||
|
||||
priv->freeze_count++;
|
||||
maybe_stop_idle (clock_idle);
|
||||
@@ -594,7 +594,6 @@ gdk_frame_clock_idle_thaw (GdkFrameClock *clock)
|
||||
|
||||
priv->sleep_serial = get_sleep_serial ();
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (gdk_profiler_is_running ())
|
||||
{
|
||||
if (priv->freeze_time != 0)
|
||||
@@ -602,11 +601,10 @@ gdk_frame_clock_idle_thaw (GdkFrameClock *clock)
|
||||
gint64 thaw_time = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (priv->freeze_time * 1000,
|
||||
(thaw_time - priv->freeze_time) * 1000,
|
||||
"freeze", "");
|
||||
"frameclock freeze", "");
|
||||
priv->freeze_time = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -955,7 +955,8 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
||||
if (priv->use_es < 0)
|
||||
priv->use_es = !epoxy_is_desktop_gl ();
|
||||
|
||||
priv->has_debug_output = epoxy_has_gl_extension ("GL_ARB_debug_output");
|
||||
priv->has_debug_output = epoxy_has_gl_extension ("GL_ARB_debug_output") ||
|
||||
epoxy_has_gl_extension ("GL_KHR_debug");
|
||||
|
||||
#ifdef G_ENABLE_CONSISTENCY_CHECKS
|
||||
if (priv->has_debug_output)
|
||||
|
||||
+12
-9
@@ -100,7 +100,7 @@ gdk_rgba_free (GdkRGBA *rgba)
|
||||
gboolean
|
||||
gdk_rgba_is_clear (const GdkRGBA *rgba)
|
||||
{
|
||||
return rgba->alpha < ((double) 0x00ff / (double) 0xffff);
|
||||
return rgba->alpha < ((float) 0x00ff / (float) 0xffff);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ gdk_rgba_is_clear (const GdkRGBA *rgba)
|
||||
gboolean
|
||||
gdk_rgba_is_opaque (const GdkRGBA *rgba)
|
||||
{
|
||||
return rgba->alpha > ((double)0xff00 / (double)0xffff);
|
||||
return rgba->alpha > ((float)0xff00 / (float)0xffff);
|
||||
}
|
||||
|
||||
#define SKIP_WHITESPACES(s) while (*(s) == ' ') (s)++;
|
||||
@@ -398,23 +398,25 @@ gdk_rgba_to_string (const GdkRGBA *rgba)
|
||||
|
||||
static gboolean
|
||||
parse_color_channel_value (GtkCssParser *parser,
|
||||
double *value,
|
||||
float *value,
|
||||
gboolean is_percentage)
|
||||
{
|
||||
double dvalue;
|
||||
|
||||
if (is_percentage)
|
||||
{
|
||||
if (!gtk_css_parser_consume_percentage (parser, value))
|
||||
if (!gtk_css_parser_consume_percentage (parser, &dvalue))
|
||||
return FALSE;
|
||||
|
||||
*value = CLAMP (*value, 0.0, 100.0) / 100.0;
|
||||
*value = CLAMP (dvalue, 0.0, 100.0) / 100.0;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gtk_css_parser_consume_number (parser, value))
|
||||
if (!gtk_css_parser_consume_number (parser, &dvalue))
|
||||
return FALSE;
|
||||
|
||||
*value = CLAMP (*value, 0.0, 255.0) / 255.0;
|
||||
*value = CLAMP (dvalue, 0.0, 255.0) / 255.0;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -425,6 +427,7 @@ parse_color_channel (GtkCssParser *parser,
|
||||
gpointer data)
|
||||
{
|
||||
GdkRGBA *rgba = data;
|
||||
double dvalue;
|
||||
|
||||
switch (arg)
|
||||
{
|
||||
@@ -450,10 +453,10 @@ parse_color_channel (GtkCssParser *parser,
|
||||
return 1;
|
||||
|
||||
case 3:
|
||||
if (!gtk_css_parser_consume_number (parser, &rgba->alpha))
|
||||
if (!gtk_css_parser_consume_number (parser, &dvalue))
|
||||
return 0;
|
||||
|
||||
rgba->alpha = CLAMP (rgba->alpha, 0.0, 1.0);
|
||||
rgba->alpha = CLAMP (dvalue, 0.0, 1.0);
|
||||
return 1;
|
||||
|
||||
default:
|
||||
|
||||
+8
-8
@@ -36,10 +36,10 @@ G_BEGIN_DECLS
|
||||
|
||||
struct _GdkRGBA
|
||||
{
|
||||
gdouble red;
|
||||
gdouble green;
|
||||
gdouble blue;
|
||||
gdouble alpha;
|
||||
float red;
|
||||
float green;
|
||||
float blue;
|
||||
float alpha;
|
||||
};
|
||||
|
||||
#define GDK_TYPE_RGBA (gdk_rgba_get_type ())
|
||||
@@ -53,15 +53,15 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gdk_rgba_free (GdkRGBA *rgba);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_rgba_is_clear (const GdkRGBA *rgba);
|
||||
gboolean gdk_rgba_is_clear (const GdkRGBA *rgba) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_rgba_is_opaque (const GdkRGBA *rgba);
|
||||
gboolean gdk_rgba_is_opaque (const GdkRGBA *rgba) G_GNUC_PURE;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gdk_rgba_hash (gconstpointer p);
|
||||
guint gdk_rgba_hash (gconstpointer p) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_rgba_equal (gconstpointer p1,
|
||||
gconstpointer p2);
|
||||
gconstpointer p2) G_GNUC_PURE;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_rgba_parse (GdkRGBA *rgba,
|
||||
|
||||
+2
-2
@@ -248,10 +248,10 @@ gdk_seat_get_capabilities (GdkSeat *seat)
|
||||
* elsewhere.
|
||||
* @event: (nullable): the event that is triggering the grab, or %NULL if none
|
||||
* is available.
|
||||
* @prepare_func: (nullable) (scope call) (closure prepare_func_data): function to
|
||||
* @prepare_func: (nullable) (scope call): function to
|
||||
* prepare the surface to be grabbed, it can be %NULL if @surface is
|
||||
* visible before this call.
|
||||
* @prepare_func_data: user data to pass to @prepare_func
|
||||
* @prepare_func_data: (closure): user data to pass to @prepare_func
|
||||
*
|
||||
* Grabs the seat so that all events corresponding to the given @capabilities
|
||||
* are passed to this application until the seat is ungrabbed with gdk_seat_ungrab(),
|
||||
|
||||
+10
-7
@@ -3583,7 +3583,13 @@ gdk_surface_register_dnd (GdkSurface *surface)
|
||||
*
|
||||
* Starts a drag and creates a new drag context for it.
|
||||
*
|
||||
* This function is called by the drag source.
|
||||
* This function is called by the drag source. After this call, you
|
||||
* probably want to set up the drag icon using the surface returned
|
||||
* by gdk_drag_get_drag_surface().
|
||||
*
|
||||
* Note: if @actions include %GDK_ACTION_MOVE, you need to listen for
|
||||
* the #GdkDrag::dnd-finished signal and delete the data at the source
|
||||
* if gdk_drag_get_selected_action() returns %GDK_ACTION_MOVE.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): a newly created #GdkDrag or
|
||||
* %NULL on error.
|
||||
@@ -3999,7 +4005,6 @@ rewrite_event_for_toplevel (GdkEvent *event)
|
||||
g_set_object (&event->any.surface, surface);
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
static void
|
||||
add_event_mark (GdkEvent *event,
|
||||
gint64 time,
|
||||
@@ -4066,6 +4071,9 @@ add_event_mark (GdkEvent *event,
|
||||
|
||||
case GDK_ENTER_NOTIFY:
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
message = g_strdup ("");
|
||||
break;
|
||||
|
||||
case GDK_TOUCHPAD_SWIPE:
|
||||
case GDK_TOUCHPAD_PINCH:
|
||||
case GDK_SCROLL:
|
||||
@@ -4107,14 +4115,11 @@ add_event_mark (GdkEvent *event,
|
||||
|
||||
g_free (message);
|
||||
}
|
||||
#endif
|
||||
|
||||
gboolean
|
||||
gdk_surface_handle_event (GdkEvent *event)
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
gint64 begin_time = g_get_monotonic_time ();
|
||||
#endif
|
||||
gboolean handled = FALSE;
|
||||
|
||||
if (check_autohide (event))
|
||||
@@ -4133,10 +4138,8 @@ gdk_surface_handle_event (GdkEvent *event)
|
||||
g_signal_emit (gdk_event_get_surface (event), signals[EVENT], 0, event, &handled);
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (gdk_profiler_is_running ())
|
||||
add_event_mark (event, begin_time, g_get_monotonic_time () - begin_time);
|
||||
#endif
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
+2
-2
@@ -51,9 +51,9 @@ GdkTexture * gdk_texture_new_from_file (GFile
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
int gdk_texture_get_width (GdkTexture *texture);
|
||||
int gdk_texture_get_width (GdkTexture *texture) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
int gdk_texture_get_height (GdkTexture *texture);
|
||||
int gdk_texture_get_height (GdkTexture *texture) G_GNUC_PURE;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_texture_download (GdkTexture *texture,
|
||||
|
||||
+4
-3
@@ -568,11 +568,12 @@ typedef enum
|
||||
* @GDK_ACTION_MOVE: Move the data, i.e. first copy it, then delete
|
||||
* it from the source using the DELETE target of the X selection protocol.
|
||||
* @GDK_ACTION_LINK: Add a link to the data. Note that this is only
|
||||
* useful if source and destination agree on what it means.
|
||||
* useful if source and destination agree on what it means, and is not
|
||||
* supported on all platforms.
|
||||
* @GDK_ACTION_ASK: Ask the user what to do with the data.
|
||||
*
|
||||
* Used in #GdkDrag to indicate what the destination
|
||||
* should do with the dropped data.
|
||||
* Used in #GdkDrop and #GdkDrag to indicate the actions that the
|
||||
* destination can and should do with the dropped data.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
|
||||
@@ -55,9 +55,6 @@ _gdk_quartz_display_open (const gchar *display_name)
|
||||
if (_gdk_display != NULL)
|
||||
return NULL;
|
||||
|
||||
/* Initialize application */
|
||||
[NSApplication sharedApplication];
|
||||
|
||||
_gdk_display = g_object_new (gdk_quartz_display_get_type (), NULL);
|
||||
_gdk_device_manager = _gdk_device_manager_new (_gdk_display);
|
||||
|
||||
@@ -67,6 +64,8 @@ _gdk_quartz_display_open (const gchar *display_name)
|
||||
|
||||
_gdk_quartz_events_init ();
|
||||
|
||||
/* Initialize application */
|
||||
[NSApplication sharedApplication];
|
||||
#if 0
|
||||
/* FIXME: Remove the #if 0 when we have these functions */
|
||||
_gdk_quartz_dnd_init ();
|
||||
|
||||
+14
-16
@@ -680,7 +680,6 @@ gdk_quartz_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
||||
{
|
||||
guint tmp_keyval;
|
||||
GdkModifierType bit;
|
||||
guint tmp_modifiers = 0;
|
||||
|
||||
if (keyval)
|
||||
*keyval = 0;
|
||||
@@ -694,24 +693,23 @@ gdk_quartz_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
||||
if (hardware_keycode < 0 || hardware_keycode >= NUM_KEYCODES)
|
||||
return FALSE;
|
||||
|
||||
/* Check if modifiers modify the keyval */
|
||||
for (bit = GDK_SHIFT_MASK; bit < GDK_BUTTON1_MASK; bit <<= 1)
|
||||
{
|
||||
if (translate_keysym (hardware_keycode,
|
||||
(bit == GDK_MOD1_MASK) ? 0 : group,
|
||||
state & ~bit,
|
||||
NULL, NULL) !=
|
||||
translate_keysym (hardware_keycode,
|
||||
(bit == GDK_MOD1_MASK) ? 1 : group,
|
||||
state | bit,
|
||||
NULL, NULL))
|
||||
tmp_modifiers |= bit;
|
||||
}
|
||||
|
||||
tmp_keyval = translate_keysym (hardware_keycode, group, state, level, effective_group);
|
||||
|
||||
/* Check if modifiers modify the keyval */
|
||||
if (consumed_modifiers)
|
||||
*consumed_modifiers = tmp_modifiers;
|
||||
{
|
||||
guint tmp_modifiers = (state & GDK_MODIFIER_MASK);
|
||||
|
||||
for (bit = 1; bit <= tmp_modifiers; bit <<= 1)
|
||||
{
|
||||
if ((bit & tmp_modifiers) &&
|
||||
translate_keysym (hardware_keycode, group, state & ~bit,
|
||||
NULL, NULL) == tmp_keyval)
|
||||
tmp_modifiers &= ~bit;
|
||||
}
|
||||
|
||||
*consumed_modifiers = tmp_modifiers;
|
||||
}
|
||||
|
||||
if (keyval)
|
||||
*keyval = tmp_keyval;
|
||||
|
||||
@@ -2710,7 +2710,6 @@ gdk_surface_impl_quartz_class_init (GdkSurfaceImplQuartzClass *klass)
|
||||
impl_class->set_decorations = gdk_quartz_surface_set_decorations;
|
||||
impl_class->get_decorations = gdk_quartz_surface_get_decorations;
|
||||
impl_class->set_functions = gdk_quartz_surface_set_functions;
|
||||
impl_class->set_functions = gdk_quartz_surface_set_functions;
|
||||
impl_class->begin_resize_drag = gdk_quartz_surface_begin_resize_drag;
|
||||
impl_class->begin_move_drag = gdk_quartz_surface_begin_move_drag;
|
||||
impl_class->set_opacity = gdk_quartz_surface_set_opacity;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
wayland_cursor_sources = files([
|
||||
'wayland-cursor.c',
|
||||
'xcursor.c',
|
||||
'os-compatibility.c'
|
||||
])
|
||||
|
||||
libwayland_cursor = static_library('wayland+cursor',
|
||||
sources: wayland_cursor_sources,
|
||||
include_directories: [ confinc, ],
|
||||
dependencies: [ glib_dep, ],
|
||||
c_args: common_cflags,
|
||||
link_args: common_ldflags)
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright © 2012 Collabora, Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define HAVE_MEMFD_CREATE
|
||||
#ifdef HAVE_MEMFD_CREATE
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#include "os-compatibility.h"
|
||||
|
||||
#ifndef HAVE_MKOSTEMP
|
||||
static int
|
||||
set_cloexec_or_close(int fd)
|
||||
{
|
||||
long flags;
|
||||
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
|
||||
flags = fcntl(fd, F_GETFD);
|
||||
if (flags == -1)
|
||||
goto err;
|
||||
|
||||
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
|
||||
goto err;
|
||||
|
||||
return fd;
|
||||
|
||||
err:
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
create_tmpfile_cloexec(char *tmpname)
|
||||
{
|
||||
int fd;
|
||||
|
||||
#ifdef HAVE_MKOSTEMP
|
||||
fd = mkostemp(tmpname, O_CLOEXEC);
|
||||
if (fd >= 0)
|
||||
unlink(tmpname);
|
||||
#else
|
||||
fd = mkstemp(tmpname);
|
||||
if (fd >= 0) {
|
||||
fd = set_cloexec_or_close(fd);
|
||||
unlink(tmpname);
|
||||
}
|
||||
#endif
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a new, unique, anonymous file of the given size, and
|
||||
* return the file descriptor for it. The file descriptor is set
|
||||
* CLOEXEC. The file is immediately suitable for mmap()'ing
|
||||
* the given size at offset zero.
|
||||
*
|
||||
* The file should not have a permanent backing store like a disk,
|
||||
* but may have if XDG_RUNTIME_DIR is not properly implemented in OS.
|
||||
*
|
||||
* The file name is deleted from the file system.
|
||||
*
|
||||
* The file is suitable for buffer sharing between processes by
|
||||
* transmitting the file descriptor over Unix sockets using the
|
||||
* SCM_RIGHTS methods.
|
||||
*
|
||||
* If the C library implements posix_fallocate(), it is used to
|
||||
* guarantee that disk space is available for the file at the
|
||||
* given size. If disk space is insufficent, errno is set to ENOSPC.
|
||||
* If posix_fallocate() is not supported, program may receive
|
||||
* SIGBUS on accessing mmap()'ed file contents instead.
|
||||
*
|
||||
* If the C library implements memfd_create(), it is used to create the
|
||||
* file purely in memory, without any backing file name on the file
|
||||
* system, and then sealing off the possibility of shrinking it. This
|
||||
* can then be checked before accessing mmap()'ed file contents, to
|
||||
* make sure SIGBUS can't happen. It also avoids requiring
|
||||
* XDG_RUNTIME_DIR.
|
||||
*/
|
||||
int
|
||||
os_create_anonymous_file(off_t size)
|
||||
{
|
||||
static const char template[] = "/wayland-cursor-shared-XXXXXX";
|
||||
const char *path;
|
||||
char *name;
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_MEMFD_CREATE
|
||||
fd = memfd_create("wayland-cursor", MFD_CLOEXEC | MFD_ALLOW_SEALING);
|
||||
if (fd >= 0) {
|
||||
/* We can add this seal before calling posix_fallocate(), as
|
||||
* the file is currently zero-sized anyway.
|
||||
*
|
||||
* There is also no need to check for the return value, we
|
||||
* couldn't do anything with it anyway.
|
||||
*/
|
||||
fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
path = getenv("XDG_RUNTIME_DIR");
|
||||
if (!path) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
name = malloc(strlen(path) + sizeof(template));
|
||||
if (!name)
|
||||
return -1;
|
||||
|
||||
strcpy(name, path);
|
||||
strcat(name, template);
|
||||
|
||||
fd = create_tmpfile_cloexec(name);
|
||||
|
||||
free(name);
|
||||
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef HAVE_POSIX_FALLOCATE
|
||||
ret = posix_fallocate(fd, 0, size);
|
||||
if (ret != 0) {
|
||||
close(fd);
|
||||
errno = ret;
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
ret = ftruncate(fd, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return fd;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright © 2012 Collabora, Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef OS_COMPATIBILITY_H
|
||||
#define OS_COMPATIBILITY_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
int
|
||||
os_create_anonymous_file(off_t size);
|
||||
|
||||
#endif /* OS_COMPATIBILITY_H */
|
||||
@@ -0,0 +1,385 @@
|
||||
/*
|
||||
* Copyright © 2012 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "xcursor.h"
|
||||
#include "wayland-cursor.h"
|
||||
#include "wayland-client.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <os-compatibility.h>
|
||||
#include <glib.h>
|
||||
|
||||
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
|
||||
|
||||
struct shm_pool {
|
||||
struct wl_shm_pool *pool;
|
||||
int fd;
|
||||
unsigned int size;
|
||||
unsigned int used;
|
||||
char *data;
|
||||
};
|
||||
|
||||
static struct shm_pool *
|
||||
shm_pool_create(struct wl_shm *shm, int size)
|
||||
{
|
||||
struct shm_pool *pool;
|
||||
|
||||
pool = malloc(sizeof *pool);
|
||||
if (!pool)
|
||||
return NULL;
|
||||
|
||||
pool->fd = os_create_anonymous_file (size);
|
||||
if (pool->fd < 0)
|
||||
goto err_free;
|
||||
|
||||
pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
pool->fd, 0);
|
||||
|
||||
if (pool->data == MAP_FAILED)
|
||||
goto err_close;
|
||||
|
||||
pool->pool = wl_shm_create_pool(shm, pool->fd, size);
|
||||
pool->size = size;
|
||||
pool->used = 0;
|
||||
|
||||
return pool;
|
||||
|
||||
err_close:
|
||||
close(pool->fd);
|
||||
err_free:
|
||||
free(pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
shm_pool_resize(struct shm_pool *pool, int size)
|
||||
{
|
||||
if (ftruncate(pool->fd, size) < 0)
|
||||
return 0;
|
||||
|
||||
#ifdef HAVE_POSIX_FALLOCATE
|
||||
errno = posix_fallocate(pool->fd, 0, size);
|
||||
if (errno != 0)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
wl_shm_pool_resize(pool->pool, size);
|
||||
|
||||
munmap(pool->data, pool->size);
|
||||
|
||||
pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
pool->fd, 0);
|
||||
if (pool->data == (void *)-1)
|
||||
return 0;
|
||||
pool->size = size;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
shm_pool_allocate(struct shm_pool *pool, int size)
|
||||
{
|
||||
int offset;
|
||||
|
||||
if (pool->used + size > pool->size)
|
||||
if (!shm_pool_resize(pool, 2 * pool->size + size))
|
||||
return -1;
|
||||
|
||||
offset = pool->used;
|
||||
pool->used += size;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
static void
|
||||
shm_pool_destroy(struct shm_pool *pool)
|
||||
{
|
||||
munmap(pool->data, pool->size);
|
||||
wl_shm_pool_destroy(pool->pool);
|
||||
close(pool->fd);
|
||||
free(pool);
|
||||
}
|
||||
|
||||
|
||||
struct wl_cursor_theme {
|
||||
unsigned int cursor_count;
|
||||
struct wl_cursor **cursors;
|
||||
struct wl_shm *shm;
|
||||
struct shm_pool *pool;
|
||||
int size;
|
||||
char *path;
|
||||
};
|
||||
|
||||
struct cursor_image {
|
||||
struct wl_cursor_image image;
|
||||
struct wl_cursor_theme *theme;
|
||||
struct wl_buffer *buffer;
|
||||
int offset; /* data offset of this image in the shm pool */
|
||||
};
|
||||
|
||||
struct cursor {
|
||||
struct wl_cursor cursor;
|
||||
uint32_t total_delay; /* length of the animation in ms */
|
||||
};
|
||||
|
||||
/** Get an shm buffer for a cursor image
|
||||
*
|
||||
* \param image The cursor image
|
||||
* \return An shm buffer for the cursor image. The user should not destroy
|
||||
* the returned buffer.
|
||||
*/
|
||||
struct wl_buffer *
|
||||
wl_cursor_image_get_buffer(struct wl_cursor_image *_img)
|
||||
{
|
||||
struct cursor_image *image = (struct cursor_image *) _img;
|
||||
struct wl_cursor_theme *theme = image->theme;
|
||||
|
||||
if (!image->buffer) {
|
||||
image->buffer =
|
||||
wl_shm_pool_create_buffer(theme->pool->pool,
|
||||
image->offset,
|
||||
_img->width, _img->height,
|
||||
_img->width * 4,
|
||||
WL_SHM_FORMAT_ARGB8888);
|
||||
};
|
||||
|
||||
return image->buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
wl_cursor_image_destroy(struct wl_cursor_image *_img)
|
||||
{
|
||||
struct cursor_image *image = (struct cursor_image *) _img;
|
||||
|
||||
if (image->buffer)
|
||||
wl_buffer_destroy(image->buffer);
|
||||
|
||||
free(image);
|
||||
}
|
||||
|
||||
static void
|
||||
wl_cursor_destroy(struct wl_cursor *cursor)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < cursor->image_count; i++)
|
||||
wl_cursor_image_destroy(cursor->images[i]);
|
||||
|
||||
free(cursor->images);
|
||||
free(cursor->name);
|
||||
free(cursor);
|
||||
}
|
||||
|
||||
static struct wl_cursor *
|
||||
wl_cursor_create_from_xcursor_images(XcursorImages *images,
|
||||
struct wl_cursor_theme *theme,
|
||||
const char *name,
|
||||
unsigned int load_size)
|
||||
{
|
||||
struct cursor *cursor;
|
||||
struct cursor_image *image;
|
||||
int i, size;
|
||||
|
||||
cursor = malloc(sizeof *cursor);
|
||||
if (!cursor)
|
||||
return NULL;
|
||||
|
||||
cursor->cursor.images =
|
||||
malloc(images->nimage * sizeof cursor->cursor.images[0]);
|
||||
if (!cursor->cursor.images) {
|
||||
free(cursor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor->cursor.name = strdup(name);
|
||||
cursor->cursor.size = load_size;
|
||||
cursor->total_delay = 0;
|
||||
|
||||
for (i = 0; i < images->nimage; i++) {
|
||||
image = malloc(sizeof *image);
|
||||
if (image == NULL)
|
||||
break;
|
||||
|
||||
image->theme = theme;
|
||||
image->buffer = NULL;
|
||||
|
||||
image->image.width = images->images[i]->width;
|
||||
image->image.height = images->images[i]->height;
|
||||
image->image.hotspot_x = images->images[i]->xhot;
|
||||
image->image.hotspot_y = images->images[i]->yhot;
|
||||
image->image.delay = images->images[i]->delay;
|
||||
|
||||
size = image->image.width * image->image.height * 4;
|
||||
image->offset = shm_pool_allocate(theme->pool, size);
|
||||
if (image->offset < 0) {
|
||||
free(image);
|
||||
break;
|
||||
}
|
||||
|
||||
/* copy pixels to shm pool */
|
||||
memcpy(theme->pool->data + image->offset,
|
||||
images->images[i]->pixels, size);
|
||||
cursor->total_delay += image->image.delay;
|
||||
cursor->cursor.images[i] = (struct wl_cursor_image *) image;
|
||||
}
|
||||
cursor->cursor.image_count = i;
|
||||
|
||||
if (cursor->cursor.image_count == 0) {
|
||||
free(cursor->cursor.name);
|
||||
free(cursor->cursor.images);
|
||||
free(cursor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &cursor->cursor;
|
||||
}
|
||||
|
||||
static void
|
||||
load_cursor(struct wl_cursor_theme *theme, const char *name, unsigned int size)
|
||||
{
|
||||
XcursorImages *images;
|
||||
struct wl_cursor *cursor;
|
||||
char *path;
|
||||
|
||||
path = g_strconcat (theme->path, "/", name, NULL);
|
||||
images = xcursor_load_images (path, size);
|
||||
g_free (path);
|
||||
|
||||
if (!images)
|
||||
return;
|
||||
|
||||
cursor = wl_cursor_create_from_xcursor_images(images, theme, name, size);
|
||||
|
||||
if (cursor) {
|
||||
theme->cursor_count++;
|
||||
theme->cursors =
|
||||
realloc(theme->cursors,
|
||||
theme->cursor_count * sizeof theme->cursors[0]);
|
||||
|
||||
if (theme->cursors == NULL) {
|
||||
theme->cursor_count--;
|
||||
free(cursor);
|
||||
} else {
|
||||
theme->cursors[theme->cursor_count - 1] = cursor;
|
||||
}
|
||||
}
|
||||
|
||||
xcursor_images_destroy (images);
|
||||
}
|
||||
|
||||
/** Load a cursor theme to memory shared with the compositor
|
||||
*
|
||||
* \param name The name of the cursor theme to load. If %NULL, the default
|
||||
* theme will be loaded.
|
||||
* \param size Desired size of the cursor images.
|
||||
* \param shm The compositor's shm interface.
|
||||
*
|
||||
* \return An object representing the theme that should be destroyed with
|
||||
* wl_cursor_theme_destroy() or %NULL on error. If no theme with the given
|
||||
* name exists, a default theme will be loaded.
|
||||
*/
|
||||
struct wl_cursor_theme *
|
||||
wl_cursor_theme_create(const char *path, int size, struct wl_shm *shm)
|
||||
{
|
||||
struct wl_cursor_theme *theme;
|
||||
|
||||
theme = malloc(sizeof *theme);
|
||||
if (!theme)
|
||||
return NULL;
|
||||
|
||||
theme->path = strdup (path);
|
||||
theme->size = size;
|
||||
theme->cursor_count = 0;
|
||||
theme->cursors = NULL;
|
||||
|
||||
theme->pool = shm_pool_create(shm, size * size * 4);
|
||||
if (!theme->pool) {
|
||||
free (theme->path);
|
||||
free (theme);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
/** Destroys a cursor theme object
|
||||
*
|
||||
* \param theme The cursor theme to be destroyed
|
||||
*/
|
||||
void
|
||||
wl_cursor_theme_destroy(struct wl_cursor_theme *theme)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < theme->cursor_count; i++)
|
||||
wl_cursor_destroy(theme->cursors[i]);
|
||||
|
||||
shm_pool_destroy(theme->pool);
|
||||
|
||||
free(theme->cursors);
|
||||
free(theme->path);
|
||||
free(theme);
|
||||
}
|
||||
|
||||
/** Get the cursor for a given name from a cursor theme
|
||||
*
|
||||
* \param theme The cursor theme
|
||||
* \param name Name of the desired cursor
|
||||
* \return The theme's cursor of the given name or %NULL if there is no
|
||||
* such cursor
|
||||
*/
|
||||
struct wl_cursor *
|
||||
wl_cursor_theme_get_cursor(struct wl_cursor_theme *theme,
|
||||
const char *name,
|
||||
unsigned int scale)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int size;
|
||||
|
||||
size = theme->size * scale;
|
||||
|
||||
for (i = 0; i < theme->cursor_count; i++) {
|
||||
if (size == theme->cursors[i]->size &&
|
||||
strcmp(name, theme->cursors[i]->name) == 0)
|
||||
return theme->cursors[i];
|
||||
}
|
||||
|
||||
load_cursor (theme, name, size);
|
||||
|
||||
if (i < theme->cursor_count) {
|
||||
if (size == theme->cursors[i]->size &&
|
||||
strcmp (name, theme->cursors[theme->cursor_count - 1]->name) == 0)
|
||||
return theme->cursors[theme->cursor_count - 1];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright © 2012 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WAYLAND_CURSOR_H
|
||||
#define WAYLAND_CURSOR_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wl_cursor_theme;
|
||||
struct wl_buffer;
|
||||
struct wl_shm;
|
||||
|
||||
struct wl_cursor_image {
|
||||
uint32_t width; /* actual width */
|
||||
uint32_t height; /* actual height */
|
||||
uint32_t hotspot_x; /* hot spot x (must be inside image) */
|
||||
uint32_t hotspot_y; /* hot spot y (must be inside image) */
|
||||
uint32_t delay; /* animation delay to next frame (ms) */
|
||||
};
|
||||
|
||||
struct wl_cursor {
|
||||
unsigned int image_count;
|
||||
struct wl_cursor_image **images;
|
||||
char *name;
|
||||
unsigned int size;
|
||||
};
|
||||
|
||||
struct wl_cursor_theme *
|
||||
wl_cursor_theme_create(const char *name, int size, struct wl_shm *shm);
|
||||
|
||||
void
|
||||
wl_cursor_theme_destroy(struct wl_cursor_theme *theme);
|
||||
|
||||
struct wl_cursor *
|
||||
wl_cursor_theme_get_cursor(struct wl_cursor_theme *theme,
|
||||
const char *name,
|
||||
unsigned int scale);
|
||||
|
||||
struct wl_buffer *
|
||||
wl_cursor_image_get_buffer(struct wl_cursor_image *image);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,612 @@
|
||||
/*
|
||||
* Copyright © 2002 Keith Packard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "xcursor.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
|
||||
/*
|
||||
* From libXcursor/include/X11/extensions/Xcursor.h
|
||||
*/
|
||||
|
||||
#define XcursorTrue 1
|
||||
#define XcursorFalse 0
|
||||
|
||||
/*
|
||||
* Cursor files start with a header. The header
|
||||
* contains a magic number, a version number and a
|
||||
* table of contents which has type and offset information
|
||||
* for the remaining tables in the file.
|
||||
*
|
||||
* File minor versions increment for compatible changes
|
||||
* File major versions increment for incompatible changes (never, we hope)
|
||||
*
|
||||
* Chunks of the same type are always upward compatible. Incompatible
|
||||
* changes are made with new chunk types; the old data can remain under
|
||||
* the old type. Upward compatible changes can add header data as the
|
||||
* header lengths are specified in the file.
|
||||
*
|
||||
* File:
|
||||
* FileHeader
|
||||
* LISTofChunk
|
||||
*
|
||||
* FileHeader:
|
||||
* CARD32 magic magic number
|
||||
* CARD32 header bytes in file header
|
||||
* CARD32 version file version
|
||||
* CARD32 ntoc number of toc entries
|
||||
* LISTofFileToc toc table of contents
|
||||
*
|
||||
* FileToc:
|
||||
* CARD32 type entry type
|
||||
* CARD32 subtype entry subtype (size for images)
|
||||
* CARD32 position absolute file position
|
||||
*/
|
||||
|
||||
#define XCURSOR_MAGIC 0x72756358 /* "Xcur" LSBFirst */
|
||||
|
||||
/*
|
||||
* Current Xcursor version number. Will be substituted by configure
|
||||
* from the version in the libXcursor configure.ac file.
|
||||
*/
|
||||
|
||||
#define XCURSOR_LIB_MAJOR 1
|
||||
#define XCURSOR_LIB_MINOR 1
|
||||
#define XCURSOR_LIB_REVISION 13
|
||||
#define XCURSOR_LIB_VERSION ((XCURSOR_LIB_MAJOR * 10000) + \
|
||||
(XCURSOR_LIB_MINOR * 100) + \
|
||||
(XCURSOR_LIB_REVISION))
|
||||
|
||||
/*
|
||||
* This version number is stored in cursor files; changes to the
|
||||
* file format require updating this version number
|
||||
*/
|
||||
#define XCURSOR_FILE_MAJOR 1
|
||||
#define XCURSOR_FILE_MINOR 0
|
||||
#define XCURSOR_FILE_VERSION ((XCURSOR_FILE_MAJOR << 16) | (XCURSOR_FILE_MINOR))
|
||||
#define XCURSOR_FILE_HEADER_LEN (4 * 4)
|
||||
#define XCURSOR_FILE_TOC_LEN (3 * 4)
|
||||
|
||||
typedef struct _XcursorFileToc {
|
||||
XcursorUInt type; /* chunk type */
|
||||
XcursorUInt subtype; /* subtype (size for images) */
|
||||
XcursorUInt position; /* absolute position in file */
|
||||
} XcursorFileToc;
|
||||
|
||||
typedef struct _XcursorFileHeader {
|
||||
XcursorUInt magic; /* magic number */
|
||||
XcursorUInt header; /* byte length of header */
|
||||
XcursorUInt version; /* file version number */
|
||||
XcursorUInt ntoc; /* number of toc entries */
|
||||
XcursorFileToc *tocs; /* table of contents */
|
||||
} XcursorFileHeader;
|
||||
|
||||
/*
|
||||
* The rest of the file is a list of chunks, each tagged by type
|
||||
* and version.
|
||||
*
|
||||
* Chunk:
|
||||
* ChunkHeader
|
||||
* <extra type-specific header fields>
|
||||
* <type-specific data>
|
||||
*
|
||||
* ChunkHeader:
|
||||
* CARD32 header bytes in chunk header + type header
|
||||
* CARD32 type chunk type
|
||||
* CARD32 subtype chunk subtype
|
||||
* CARD32 version chunk type version
|
||||
*/
|
||||
|
||||
#define XCURSOR_CHUNK_HEADER_LEN (4 * 4)
|
||||
|
||||
typedef struct _XcursorChunkHeader {
|
||||
XcursorUInt header; /* bytes in chunk header */
|
||||
XcursorUInt type; /* chunk type */
|
||||
XcursorUInt subtype; /* chunk subtype (size for images) */
|
||||
XcursorUInt version; /* version of this type */
|
||||
} XcursorChunkHeader;
|
||||
|
||||
/*
|
||||
* Here's a list of the known chunk types
|
||||
*/
|
||||
|
||||
/*
|
||||
* Comments consist of a 4-byte length field followed by
|
||||
* UTF-8 encoded text
|
||||
*
|
||||
* Comment:
|
||||
* ChunkHeader header chunk header
|
||||
* CARD32 length bytes in text
|
||||
* LISTofCARD8 text UTF-8 encoded text
|
||||
*/
|
||||
|
||||
#define XCURSOR_COMMENT_TYPE 0xfffe0001
|
||||
#define XCURSOR_COMMENT_VERSION 1
|
||||
#define XCURSOR_COMMENT_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (1 *4))
|
||||
#define XCURSOR_COMMENT_COPYRIGHT 1
|
||||
#define XCURSOR_COMMENT_LICENSE 2
|
||||
#define XCURSOR_COMMENT_OTHER 3
|
||||
#define XCURSOR_COMMENT_MAX_LEN 0x100000
|
||||
|
||||
typedef struct _XcursorComment {
|
||||
XcursorUInt version;
|
||||
XcursorUInt comment_type;
|
||||
char *comment;
|
||||
} XcursorComment;
|
||||
|
||||
/*
|
||||
* Each cursor image occupies a separate image chunk.
|
||||
* The length of the image header follows the chunk header
|
||||
* so that future versions can extend the header without
|
||||
* breaking older applications
|
||||
*
|
||||
* Image:
|
||||
* ChunkHeader header chunk header
|
||||
* CARD32 width actual width
|
||||
* CARD32 height actual height
|
||||
* CARD32 xhot hot spot x
|
||||
* CARD32 yhot hot spot y
|
||||
* CARD32 delay animation delay
|
||||
* LISTofCARD32 pixels ARGB pixels
|
||||
*/
|
||||
|
||||
#define XCURSOR_IMAGE_TYPE 0xfffd0002
|
||||
#define XCURSOR_IMAGE_VERSION 1
|
||||
#define XCURSOR_IMAGE_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (5*4))
|
||||
#define XCURSOR_IMAGE_MAX_SIZE 0x7fff /* 32767x32767 max cursor size */
|
||||
|
||||
typedef struct _XcursorFile XcursorFile;
|
||||
|
||||
struct _XcursorFile {
|
||||
void *closure;
|
||||
int (*read) (XcursorFile *file, unsigned char *buf, int len);
|
||||
int (*write) (XcursorFile *file, unsigned char *buf, int len);
|
||||
int (*seek) (XcursorFile *file, long offset, int whence);
|
||||
};
|
||||
|
||||
typedef struct _XcursorComments {
|
||||
int ncomment; /* number of comments */
|
||||
XcursorComment **comments; /* array of XcursorComment pointers */
|
||||
} XcursorComments;
|
||||
|
||||
/*
|
||||
* From libXcursor/src/file.c
|
||||
*/
|
||||
|
||||
static XcursorImage *
|
||||
XcursorImageCreate (int width, int height)
|
||||
{
|
||||
XcursorImage *image;
|
||||
|
||||
if (width < 0 || height < 0)
|
||||
return NULL;
|
||||
if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE)
|
||||
return NULL;
|
||||
|
||||
image = malloc (sizeof (XcursorImage) +
|
||||
width * height * sizeof (XcursorPixel));
|
||||
if (!image)
|
||||
return NULL;
|
||||
image->version = XCURSOR_IMAGE_VERSION;
|
||||
image->pixels = (XcursorPixel *) (image + 1);
|
||||
image->size = width > height ? width : height;
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
image->delay = 0;
|
||||
return image;
|
||||
}
|
||||
|
||||
static void
|
||||
XcursorImageDestroy (XcursorImage *image)
|
||||
{
|
||||
free (image);
|
||||
}
|
||||
|
||||
static XcursorImages *
|
||||
XcursorImagesCreate (int size)
|
||||
{
|
||||
XcursorImages *images;
|
||||
|
||||
images = malloc (sizeof (XcursorImages) +
|
||||
size * sizeof (XcursorImage *));
|
||||
if (!images)
|
||||
return NULL;
|
||||
images->nimage = 0;
|
||||
images->images = (XcursorImage **) (images + 1);
|
||||
images->name = NULL;
|
||||
return images;
|
||||
}
|
||||
|
||||
static void
|
||||
XcursorImagesDestroy (XcursorImages *images)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (!images)
|
||||
return;
|
||||
|
||||
for (n = 0; n < images->nimage; n++)
|
||||
XcursorImageDestroy (images->images[n]);
|
||||
if (images->name)
|
||||
free (images->name);
|
||||
free (images);
|
||||
}
|
||||
|
||||
static XcursorBool
|
||||
_XcursorReadUInt (XcursorFile *file, XcursorUInt *u)
|
||||
{
|
||||
unsigned char bytes[4];
|
||||
|
||||
if (!file || !u)
|
||||
return XcursorFalse;
|
||||
|
||||
if ((*file->read) (file, bytes, 4) != 4)
|
||||
return XcursorFalse;
|
||||
*u = ((bytes[0] << 0) |
|
||||
(bytes[1] << 8) |
|
||||
(bytes[2] << 16) |
|
||||
(bytes[3] << 24));
|
||||
return XcursorTrue;
|
||||
}
|
||||
|
||||
static void
|
||||
_XcursorFileHeaderDestroy (XcursorFileHeader *fileHeader)
|
||||
{
|
||||
free (fileHeader);
|
||||
}
|
||||
|
||||
static XcursorFileHeader *
|
||||
_XcursorFileHeaderCreate (int ntoc)
|
||||
{
|
||||
XcursorFileHeader *fileHeader;
|
||||
|
||||
if (ntoc > 0x10000)
|
||||
return NULL;
|
||||
fileHeader = malloc (sizeof (XcursorFileHeader) +
|
||||
ntoc * sizeof (XcursorFileToc));
|
||||
if (!fileHeader)
|
||||
return NULL;
|
||||
fileHeader->magic = XCURSOR_MAGIC;
|
||||
fileHeader->header = XCURSOR_FILE_HEADER_LEN;
|
||||
fileHeader->version = XCURSOR_FILE_VERSION;
|
||||
fileHeader->ntoc = ntoc;
|
||||
fileHeader->tocs = (XcursorFileToc *) (fileHeader + 1);
|
||||
return fileHeader;
|
||||
}
|
||||
|
||||
static XcursorFileHeader *
|
||||
_XcursorReadFileHeader (XcursorFile *file)
|
||||
{
|
||||
XcursorFileHeader head, *fileHeader;
|
||||
XcursorUInt skip;
|
||||
unsigned int n;
|
||||
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
if (!_XcursorReadUInt (file, &head.magic))
|
||||
return NULL;
|
||||
if (head.magic != XCURSOR_MAGIC)
|
||||
return NULL;
|
||||
if (!_XcursorReadUInt (file, &head.header))
|
||||
return NULL;
|
||||
if (!_XcursorReadUInt (file, &head.version))
|
||||
return NULL;
|
||||
if (!_XcursorReadUInt (file, &head.ntoc))
|
||||
return NULL;
|
||||
skip = head.header - XCURSOR_FILE_HEADER_LEN;
|
||||
if (skip)
|
||||
if ((*file->seek) (file, skip, SEEK_CUR) == EOF)
|
||||
return NULL;
|
||||
fileHeader = _XcursorFileHeaderCreate (head.ntoc);
|
||||
if (!fileHeader)
|
||||
return NULL;
|
||||
fileHeader->magic = head.magic;
|
||||
fileHeader->header = head.header;
|
||||
fileHeader->version = head.version;
|
||||
fileHeader->ntoc = head.ntoc;
|
||||
for (n = 0; n < fileHeader->ntoc; n++)
|
||||
{
|
||||
if (!_XcursorReadUInt (file, &fileHeader->tocs[n].type))
|
||||
break;
|
||||
if (!_XcursorReadUInt (file, &fileHeader->tocs[n].subtype))
|
||||
break;
|
||||
if (!_XcursorReadUInt (file, &fileHeader->tocs[n].position))
|
||||
break;
|
||||
}
|
||||
if (n != fileHeader->ntoc)
|
||||
{
|
||||
_XcursorFileHeaderDestroy (fileHeader);
|
||||
return NULL;
|
||||
}
|
||||
return fileHeader;
|
||||
}
|
||||
|
||||
static XcursorBool
|
||||
_XcursorSeekToToc (XcursorFile *file,
|
||||
XcursorFileHeader *fileHeader,
|
||||
int toc)
|
||||
{
|
||||
if (!file || !fileHeader || \
|
||||
(*file->seek) (file, fileHeader->tocs[toc].position, SEEK_SET) == EOF)
|
||||
return XcursorFalse;
|
||||
return XcursorTrue;
|
||||
}
|
||||
|
||||
static XcursorBool
|
||||
_XcursorFileReadChunkHeader (XcursorFile *file,
|
||||
XcursorFileHeader *fileHeader,
|
||||
int toc,
|
||||
XcursorChunkHeader *chunkHeader)
|
||||
{
|
||||
if (!file || !fileHeader || !chunkHeader)
|
||||
return XcursorFalse;
|
||||
if (!_XcursorSeekToToc (file, fileHeader, toc))
|
||||
return XcursorFalse;
|
||||
if (!_XcursorReadUInt (file, &chunkHeader->header))
|
||||
return XcursorFalse;
|
||||
if (!_XcursorReadUInt (file, &chunkHeader->type))
|
||||
return XcursorFalse;
|
||||
if (!_XcursorReadUInt (file, &chunkHeader->subtype))
|
||||
return XcursorFalse;
|
||||
if (!_XcursorReadUInt (file, &chunkHeader->version))
|
||||
return XcursorFalse;
|
||||
/* sanity check */
|
||||
if (chunkHeader->type != fileHeader->tocs[toc].type ||
|
||||
chunkHeader->subtype != fileHeader->tocs[toc].subtype)
|
||||
return XcursorFalse;
|
||||
return XcursorTrue;
|
||||
}
|
||||
|
||||
#define dist(a,b) ((a) > (b) ? (a) - (b) : (b) - (a))
|
||||
|
||||
static XcursorDim
|
||||
_XcursorFindBestSize (XcursorFileHeader *fileHeader,
|
||||
XcursorDim size,
|
||||
int *nsizesp)
|
||||
{
|
||||
unsigned int n;
|
||||
int nsizes = 0;
|
||||
XcursorDim bestSize = 0;
|
||||
XcursorDim thisSize;
|
||||
|
||||
if (!fileHeader || !nsizesp)
|
||||
return 0;
|
||||
|
||||
for (n = 0; n < fileHeader->ntoc; n++)
|
||||
{
|
||||
if (fileHeader->tocs[n].type != XCURSOR_IMAGE_TYPE)
|
||||
continue;
|
||||
thisSize = fileHeader->tocs[n].subtype;
|
||||
if (!bestSize || dist (thisSize, size) < dist (bestSize, size))
|
||||
{
|
||||
bestSize = thisSize;
|
||||
nsizes = 1;
|
||||
}
|
||||
else if (thisSize == bestSize)
|
||||
nsizes++;
|
||||
}
|
||||
*nsizesp = nsizes;
|
||||
return bestSize;
|
||||
}
|
||||
|
||||
static int
|
||||
_XcursorFindImageToc (XcursorFileHeader *fileHeader,
|
||||
XcursorDim size,
|
||||
int count)
|
||||
{
|
||||
unsigned int toc;
|
||||
XcursorDim thisSize;
|
||||
|
||||
if (!fileHeader)
|
||||
return 0;
|
||||
|
||||
for (toc = 0; toc < fileHeader->ntoc; toc++)
|
||||
{
|
||||
if (fileHeader->tocs[toc].type != XCURSOR_IMAGE_TYPE)
|
||||
continue;
|
||||
thisSize = fileHeader->tocs[toc].subtype;
|
||||
if (thisSize != size)
|
||||
continue;
|
||||
if (!count)
|
||||
break;
|
||||
count--;
|
||||
}
|
||||
if (toc == fileHeader->ntoc)
|
||||
return -1;
|
||||
return toc;
|
||||
}
|
||||
|
||||
static XcursorImage *
|
||||
_XcursorReadImage (XcursorFile *file,
|
||||
XcursorFileHeader *fileHeader,
|
||||
int toc)
|
||||
{
|
||||
XcursorChunkHeader chunkHeader;
|
||||
XcursorImage head;
|
||||
XcursorImage *image;
|
||||
int n;
|
||||
XcursorPixel *p;
|
||||
|
||||
if (!file || !fileHeader)
|
||||
return NULL;
|
||||
|
||||
if (!_XcursorFileReadChunkHeader (file, fileHeader, toc, &chunkHeader))
|
||||
return NULL;
|
||||
if (!_XcursorReadUInt (file, &head.width))
|
||||
return NULL;
|
||||
if (!_XcursorReadUInt (file, &head.height))
|
||||
return NULL;
|
||||
if (!_XcursorReadUInt (file, &head.xhot))
|
||||
return NULL;
|
||||
if (!_XcursorReadUInt (file, &head.yhot))
|
||||
return NULL;
|
||||
if (!_XcursorReadUInt (file, &head.delay))
|
||||
return NULL;
|
||||
/* sanity check data */
|
||||
if (head.width > XCURSOR_IMAGE_MAX_SIZE ||
|
||||
head.height > XCURSOR_IMAGE_MAX_SIZE)
|
||||
return NULL;
|
||||
if (head.width == 0 || head.height == 0)
|
||||
return NULL;
|
||||
if (head.xhot > head.width || head.yhot > head.height)
|
||||
return NULL;
|
||||
|
||||
/* Create the image and initialize it */
|
||||
image = XcursorImageCreate (head.width, head.height);
|
||||
if (image == NULL)
|
||||
return NULL;
|
||||
if (chunkHeader.version < image->version)
|
||||
image->version = chunkHeader.version;
|
||||
image->size = chunkHeader.subtype;
|
||||
image->xhot = head.xhot;
|
||||
image->yhot = head.yhot;
|
||||
image->delay = head.delay;
|
||||
n = image->width * image->height;
|
||||
p = image->pixels;
|
||||
while (n--)
|
||||
{
|
||||
if (!_XcursorReadUInt (file, p))
|
||||
{
|
||||
XcursorImageDestroy (image);
|
||||
return NULL;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
static XcursorImages *
|
||||
XcursorXcFileLoadImages (XcursorFile *file, int size)
|
||||
{
|
||||
XcursorFileHeader *fileHeader;
|
||||
XcursorDim bestSize;
|
||||
int nsize;
|
||||
XcursorImages *images;
|
||||
int n;
|
||||
int toc;
|
||||
|
||||
if (!file || size < 0)
|
||||
return NULL;
|
||||
fileHeader = _XcursorReadFileHeader (file);
|
||||
if (!fileHeader)
|
||||
return NULL;
|
||||
bestSize = _XcursorFindBestSize (fileHeader, (XcursorDim) size, &nsize);
|
||||
if (!bestSize)
|
||||
{
|
||||
_XcursorFileHeaderDestroy (fileHeader);
|
||||
return NULL;
|
||||
}
|
||||
images = XcursorImagesCreate (nsize);
|
||||
if (!images)
|
||||
{
|
||||
_XcursorFileHeaderDestroy (fileHeader);
|
||||
return NULL;
|
||||
}
|
||||
for (n = 0; n < nsize; n++)
|
||||
{
|
||||
toc = _XcursorFindImageToc (fileHeader, bestSize, n);
|
||||
if (toc < 0)
|
||||
break;
|
||||
images->images[images->nimage] = _XcursorReadImage (file, fileHeader,
|
||||
toc);
|
||||
if (!images->images[images->nimage])
|
||||
break;
|
||||
images->nimage++;
|
||||
}
|
||||
_XcursorFileHeaderDestroy (fileHeader);
|
||||
if (images->nimage != nsize)
|
||||
{
|
||||
XcursorImagesDestroy (images);
|
||||
images = NULL;
|
||||
}
|
||||
return images;
|
||||
}
|
||||
|
||||
static int
|
||||
_XcursorStdioFileRead (XcursorFile *file, unsigned char *buf, int len)
|
||||
{
|
||||
FILE *f = file->closure;
|
||||
return fread (buf, 1, len, f);
|
||||
}
|
||||
|
||||
static int
|
||||
_XcursorStdioFileWrite (XcursorFile *file, unsigned char *buf, int len)
|
||||
{
|
||||
FILE *f = file->closure;
|
||||
return fwrite (buf, 1, len, f);
|
||||
}
|
||||
|
||||
static int
|
||||
_XcursorStdioFileSeek (XcursorFile *file, long offset, int whence)
|
||||
{
|
||||
FILE *f = file->closure;
|
||||
return fseek (f, offset, whence);
|
||||
}
|
||||
|
||||
static void
|
||||
_XcursorStdioFileInitialize (FILE *stdfile, XcursorFile *file)
|
||||
{
|
||||
file->closure = stdfile;
|
||||
file->read = _XcursorStdioFileRead;
|
||||
file->write = _XcursorStdioFileWrite;
|
||||
file->seek = _XcursorStdioFileSeek;
|
||||
}
|
||||
|
||||
static XcursorImages *
|
||||
XcursorFileLoadImages (FILE *file, int size)
|
||||
{
|
||||
XcursorFile f;
|
||||
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
_XcursorStdioFileInitialize (file, &f);
|
||||
return XcursorXcFileLoadImages (&f, size);
|
||||
}
|
||||
|
||||
XcursorImages *
|
||||
xcursor_load_images (const char *path, int size)
|
||||
{
|
||||
FILE *f;
|
||||
XcursorImages *images;
|
||||
|
||||
f = fopen (path, "r");
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
images = XcursorFileLoadImages (f, size);
|
||||
fclose (f);
|
||||
|
||||
return images;
|
||||
}
|
||||
|
||||
void
|
||||
xcursor_images_destroy (XcursorImages *images)
|
||||
{
|
||||
XcursorImagesDestroy (images);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright © 2002 Keith Packard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef XCURSOR_H
|
||||
#define XCURSOR_H
|
||||
|
||||
typedef int XcursorBool;
|
||||
typedef unsigned int XcursorUInt;
|
||||
|
||||
typedef XcursorUInt XcursorDim;
|
||||
typedef XcursorUInt XcursorPixel;
|
||||
|
||||
typedef struct _XcursorImage {
|
||||
XcursorUInt version; /* version of the image data */
|
||||
XcursorDim size; /* nominal size for matching */
|
||||
XcursorDim width; /* actual width */
|
||||
XcursorDim height; /* actual height */
|
||||
XcursorDim xhot; /* hot spot x (must be inside image) */
|
||||
XcursorDim yhot; /* hot spot y (must be inside image) */
|
||||
XcursorUInt delay; /* animation delay to next frame (ms) */
|
||||
XcursorPixel *pixels; /* pointer to pixels */
|
||||
} XcursorImage;
|
||||
|
||||
/*
|
||||
* Other data structures exposed by the library API
|
||||
*/
|
||||
typedef struct _XcursorImages {
|
||||
int nimage; /* number of images */
|
||||
XcursorImage **images; /* array of XcursorImage pointers */
|
||||
char *name; /* name used to load images */
|
||||
} XcursorImages;
|
||||
|
||||
void
|
||||
xcursor_images_destroy (XcursorImages *images);
|
||||
|
||||
XcursorImages *
|
||||
xcursor_load_images (const char *path, int size);
|
||||
|
||||
#endif
|
||||
@@ -33,8 +33,7 @@
|
||||
#include "gdkdisplay-wayland.h"
|
||||
#include "gdkwayland.h"
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#include <wayland-cursor.h>
|
||||
#include "cursor/wayland-cursor.h"
|
||||
|
||||
static void
|
||||
gdk_wayland_cursor_remove_from_cache (gpointer data, GObject *cursor)
|
||||
@@ -119,11 +118,12 @@ name_fallback (const gchar *name)
|
||||
static struct wl_cursor *
|
||||
gdk_wayland_cursor_load_for_name (GdkWaylandDisplay *display_wayland,
|
||||
struct wl_cursor_theme *theme,
|
||||
int scale,
|
||||
const char *name)
|
||||
{
|
||||
struct wl_cursor *c;
|
||||
|
||||
c = wl_cursor_theme_get_cursor (theme, name);
|
||||
c = wl_cursor_theme_get_cursor (theme, name, scale);
|
||||
if (!c)
|
||||
{
|
||||
const char *fallback;
|
||||
@@ -131,7 +131,7 @@ gdk_wayland_cursor_load_for_name (GdkWaylandDisplay *display_wayland,
|
||||
fallback = name_fallback (name);
|
||||
if (fallback)
|
||||
{
|
||||
c = wl_cursor_theme_get_cursor (theme, fallback);
|
||||
c = wl_cursor_theme_get_cursor (theme, fallback, scale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,8 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
goto none;
|
||||
|
||||
c = gdk_wayland_cursor_load_for_name (display,
|
||||
_gdk_wayland_display_get_scaled_cursor_theme (display, desired_scale),
|
||||
_gdk_wayland_display_get_cursor_theme (display),
|
||||
desired_scale,
|
||||
gdk_cursor_get_name (cursor));
|
||||
if (c)
|
||||
{
|
||||
@@ -270,7 +271,8 @@ _gdk_wayland_cursor_get_next_image_index (GdkWaylandDisplay *display,
|
||||
}
|
||||
|
||||
c = gdk_wayland_cursor_load_for_name (display,
|
||||
_gdk_wayland_display_get_scaled_cursor_theme (display, scale),
|
||||
_gdk_wayland_display_get_cursor_theme (display),
|
||||
scale,
|
||||
gdk_cursor_get_name (cursor));
|
||||
|
||||
if (c)
|
||||
|
||||
+73
-100
@@ -56,6 +56,8 @@
|
||||
#define BTN_STYLUS3 0x149 /* Linux 4.15 */
|
||||
#endif
|
||||
|
||||
#define GDK_SEAT_NOTE(seat,type,action) GDK_DISPLAY_NOTE(gdk_seat_get_display (GDK_SEAT (seat)),type,action)
|
||||
|
||||
typedef struct _GdkWaylandDevicePad GdkWaylandDevicePad;
|
||||
typedef struct _GdkWaylandDevicePadClass GdkWaylandDevicePadClass;
|
||||
|
||||
@@ -1119,7 +1121,7 @@ data_offer_offer (void *data,
|
||||
|
||||
if (seat->pending_offer != offer)
|
||||
{
|
||||
GDK_DISPLAY_NOTE (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("%p: offer for unknown offer %p of %s",
|
||||
seat, offer, type));
|
||||
return;
|
||||
@@ -1191,7 +1193,7 @@ data_device_data_offer (void *data,
|
||||
{
|
||||
GdkWaylandSeat *seat = data;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("data device data offer, data device %p, offer %p",
|
||||
data_device, offer));
|
||||
|
||||
@@ -1228,13 +1230,13 @@ data_device_enter (void *data,
|
||||
|
||||
if (offer != seat->pending_offer)
|
||||
{
|
||||
GDK_DISPLAY_NOTE (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("%p: enter event for unknown offer %p, expected %p",
|
||||
seat, offer, seat->pending_offer));
|
||||
return;
|
||||
}
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("data device enter, data device %p serial %u, surface %p, x %f y %f, offer %p",
|
||||
data_device, serial, surface, wl_fixed_to_double (x), wl_fixed_to_double (y), offer));
|
||||
|
||||
@@ -1258,6 +1260,8 @@ data_device_enter (void *data,
|
||||
seat->pending_offer = NULL;
|
||||
|
||||
seat->drop = gdk_wayland_drop_new (device, seat->drag, formats, dest_surface, offer, serial);
|
||||
gdk_wayland_drop_set_source_actions (seat->drop, seat->pending_source_actions);
|
||||
gdk_wayland_drop_set_action (seat->drop, seat->pending_action);
|
||||
|
||||
gdk_wayland_seat_discard_pending_offer (seat);
|
||||
|
||||
@@ -1272,7 +1276,7 @@ data_device_leave (void *data,
|
||||
{
|
||||
GdkWaylandSeat *seat = data;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("data device leave, data device %p", data_device));
|
||||
|
||||
if (seat->drop == NULL)
|
||||
@@ -1298,7 +1302,7 @@ data_device_motion (void *data,
|
||||
GdkWaylandSeat *seat = data;
|
||||
int origin_x, origin_y;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("data device motion, data_device = %p, time = %d, x = %f, y = %f",
|
||||
data_device, time, wl_fixed_to_double (x), wl_fixed_to_double (y)));
|
||||
|
||||
@@ -1325,7 +1329,7 @@ data_device_drop (void *data,
|
||||
GdkWaylandSeat *seat = data;
|
||||
int origin_x, origin_y;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("data device drop, data device %p", data_device));
|
||||
|
||||
gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y);
|
||||
@@ -1571,7 +1575,7 @@ pointer_handle_enter (void *data,
|
||||
&event->crossing.x_root,
|
||||
&event->crossing.y_root);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("enter, seat %p surface %p",
|
||||
seat, seat->pointer_info.focus));
|
||||
|
||||
@@ -1619,7 +1623,7 @@ pointer_handle_leave (void *data,
|
||||
&event->crossing.x_root,
|
||||
&event->crossing.y_root);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("leave, seat %p surface %p",
|
||||
seat, seat->pointer_info.focus));
|
||||
|
||||
@@ -1665,7 +1669,7 @@ pointer_handle_motion (void *data,
|
||||
&event->motion.x_root,
|
||||
&event->motion.y_root);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("motion %f %f, seat %p state %d",
|
||||
wl_fixed_to_double (sx), wl_fixed_to_double (sy),
|
||||
seat, event->motion.state));
|
||||
@@ -1738,7 +1742,7 @@ pointer_handle_button (void *data,
|
||||
else
|
||||
seat->pointer_info.button_modifiers &= ~modifier;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("button %d %s, seat %p state %d",
|
||||
event->button.button,
|
||||
state ? "press" : "release",
|
||||
@@ -1796,7 +1800,7 @@ pointer_handle_axis (void *data,
|
||||
|
||||
seat->pointer_info.time = time;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("scroll, axis %s, value %f, seat %p",
|
||||
get_axis_name (axis), wl_fixed_to_double (value) / 10.0,
|
||||
seat));
|
||||
@@ -1811,7 +1815,7 @@ pointer_handle_frame (void *data,
|
||||
{
|
||||
GdkWaylandSeat *seat = data;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("frame, seat %p", seat));
|
||||
|
||||
gdk_wayland_seat_flush_frame_event (seat);
|
||||
@@ -1852,7 +1856,7 @@ pointer_handle_axis_source (void *data,
|
||||
|
||||
pointer_frame->source = source;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("axis source %s, seat %p", get_axis_source_name (source), seat));
|
||||
}
|
||||
|
||||
@@ -1884,7 +1888,7 @@ pointer_handle_axis_stop (void *data,
|
||||
|
||||
pointer_frame->is_scroll_stop = TRUE;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("axis %s stop, seat %p", get_axis_name (axis), seat));
|
||||
}
|
||||
|
||||
@@ -1912,7 +1916,7 @@ pointer_handle_axis_discrete (void *data,
|
||||
g_return_if_reached ();
|
||||
}
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("discrete scroll, axis %s, value %d, seat %p",
|
||||
get_axis_name (axis), value, seat));
|
||||
}
|
||||
@@ -1968,7 +1972,7 @@ keyboard_handle_enter (void *data,
|
||||
gdk_event_set_device (event, seat->master_keyboard);
|
||||
gdk_event_set_source_device (event, seat->keyboard);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("focus in, seat %p surface %p",
|
||||
seat, seat->keyboard_focus));
|
||||
|
||||
@@ -2009,7 +2013,7 @@ keyboard_handle_leave (void *data,
|
||||
seat->keyboard_focus = NULL;
|
||||
seat->repeat_key = 0;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("focus out, seat %p surface %p",
|
||||
seat, event->any.surface));
|
||||
|
||||
@@ -2104,7 +2108,7 @@ deliver_key_event (GdkWaylandSeat *seat,
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("keyboard %s event%s, surface %p, code %d, sym %d, "
|
||||
"mods 0x%x",
|
||||
(state ? "press" : "release"),
|
||||
@@ -2392,7 +2396,7 @@ touch_handle_down (void *data,
|
||||
mimic_pointer_emulating_touch_info (seat->touch_master, touch);
|
||||
}
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("touch begin %f %f", event->touch.x, event->touch.y));
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
@@ -2415,7 +2419,7 @@ touch_handle_up (void *data,
|
||||
touch = gdk_wayland_seat_get_touch (seat, id);
|
||||
event = _create_touch_event (seat, touch, GDK_TOUCH_END, time);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("touch end %f %f", event->touch.x, event->touch.y));
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
@@ -2447,7 +2451,7 @@ touch_handle_motion (void *data,
|
||||
|
||||
event = _create_touch_event (seat, touch, GDK_TOUCH_UPDATE, time);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("touch update %f %f", event->touch.x, event->touch.y));
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
@@ -2484,7 +2488,7 @@ touch_handle_cancel (void *data,
|
||||
g_hash_table_iter_remove (&iter);
|
||||
}
|
||||
|
||||
GDK_DISPLAY_NOTE (wayland_seat->display, EVENTS, g_message ("touch cancel"));
|
||||
GDK_SEAT_NOTE (wayland_seat, EVENTS, g_message ("touch cancel"));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2520,7 +2524,7 @@ emit_gesture_swipe_event (GdkWaylandSeat *seat,
|
||||
&event->touchpad_swipe.x_root,
|
||||
&event->touchpad_swipe.y_root);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("swipe event %d, coords: %f %f, seat %p state %d",
|
||||
event->any.type, event->touchpad_swipe.x,
|
||||
event->touchpad_swipe.y, seat,
|
||||
@@ -2623,7 +2627,7 @@ emit_gesture_pinch_event (GdkWaylandSeat *seat,
|
||||
&event->touchpad_pinch.x_root,
|
||||
&event->touchpad_pinch.y_root);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("pinch event %d, coords: %f %f, seat %p state %d",
|
||||
event->any.type, event->touchpad_pinch.x,
|
||||
event->touchpad_pinch.y, seat,
|
||||
@@ -2949,7 +2953,7 @@ seat_handle_capabilities (void *data,
|
||||
GdkWaylandSeat *seat = data;
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, MISC,
|
||||
GDK_SEAT_NOTE (seat, MISC,
|
||||
g_message ("seat %p with %s%s%s", wl_seat,
|
||||
(caps & WL_SEAT_CAPABILITY_POINTER) ? " pointer, " : "",
|
||||
(caps & WL_SEAT_CAPABILITY_KEYBOARD) ? " keyboard, " : "",
|
||||
@@ -3172,7 +3176,7 @@ seat_handle_name (void *data,
|
||||
const char *name)
|
||||
{
|
||||
/* We don't care about the name. */
|
||||
GDK_DISPLAY_NOTE (GDK_WAYLAND_SEAT (data)->display, MISC,
|
||||
GDK_SEAT_NOTE (GDK_WAYLAND_SEAT (data), MISC,
|
||||
g_message ("seat %p name %s", seat, name));
|
||||
}
|
||||
|
||||
@@ -3486,7 +3490,7 @@ tablet_tool_handle_proximity_in (void *data,
|
||||
gdk_wayland_surface_get_wl_output (surface));
|
||||
pointer_surface_update_scale (tablet->master);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("proximity in, seat %p surface %p tool %d",
|
||||
seat, tablet->pointer_info.focus,
|
||||
gdk_device_tool_get_tool_type (tool->tool)));
|
||||
@@ -3498,11 +3502,10 @@ tablet_tool_handle_proximity_out (void *data,
|
||||
{
|
||||
GdkWaylandTabletToolData *tool = data;
|
||||
GdkWaylandTabletData *tablet = tool->current_tablet;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tool->seat);
|
||||
GdkEvent *event;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
g_message ("proximity out, seat %p, tool %d", seat,
|
||||
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
||||
g_message ("proximity out, seat %p, tool %d", tool->seat,
|
||||
gdk_device_tool_get_tool_type (tool->tool)));
|
||||
|
||||
event = gdk_wayland_tablet_get_frame_event (tablet, GDK_PROXIMITY_OUT);
|
||||
@@ -3598,7 +3601,7 @@ tablet_tool_handle_motion (void *data,
|
||||
tablet->pointer_info.surface_x = wl_fixed_to_double (sx);
|
||||
tablet->pointer_info.surface_y = wl_fixed_to_double (sy);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("tablet motion %f %f",
|
||||
tablet->pointer_info.surface_x,
|
||||
tablet->pointer_info.surface_y));
|
||||
@@ -3631,7 +3634,7 @@ tablet_tool_handle_pressure (void *data,
|
||||
_gdk_device_translate_axis (tablet->current_device, axis_index,
|
||||
pressure, &tablet->axes[axis_index]);
|
||||
|
||||
GDK_DISPLAY_NOTE (GDK_WAYLAND_SEAT (tool->seat)->display, EVENTS,
|
||||
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
||||
g_message ("tablet tool %d pressure %d",
|
||||
gdk_device_tool_get_tool_type (tool->tool), pressure));
|
||||
}
|
||||
@@ -3648,7 +3651,7 @@ tablet_tool_handle_distance (void *data,
|
||||
_gdk_device_translate_axis (tablet->current_device, axis_index,
|
||||
distance, &tablet->axes[axis_index]);
|
||||
|
||||
GDK_DISPLAY_NOTE (GDK_WAYLAND_SEAT (tool->seat)->display, EVENTS,
|
||||
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
||||
g_message ("tablet tool %d distance %d",
|
||||
gdk_device_tool_get_tool_type (tool->tool), distance));
|
||||
}
|
||||
@@ -3671,7 +3674,7 @@ tablet_tool_handle_tilt (void *data,
|
||||
wl_fixed_to_double (ytilt),
|
||||
&tablet->axes[ytilt_axis_index]);
|
||||
|
||||
GDK_DISPLAY_NOTE (GDK_WAYLAND_SEAT (tool->seat)->display, EVENTS,
|
||||
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
||||
g_message ("tablet tool %d tilt %f/%f",
|
||||
gdk_device_tool_get_tool_type (tool->tool),
|
||||
wl_fixed_to_double (xtilt), wl_fixed_to_double (ytilt)));
|
||||
@@ -3726,7 +3729,7 @@ tablet_tool_handle_rotation (void *data,
|
||||
wl_fixed_to_double (degrees),
|
||||
&tablet->axes[axis_index]);
|
||||
|
||||
GDK_DISPLAY_NOTE (GDK_WAYLAND_SEAT (tool->seat)->display, EVENTS,
|
||||
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
||||
g_message ("tablet tool %d rotation %f",
|
||||
gdk_device_tool_get_tool_type (tool->tool),
|
||||
wl_fixed_to_double (degrees)));
|
||||
@@ -3744,7 +3747,7 @@ tablet_tool_handle_slider (void *data,
|
||||
_gdk_device_translate_axis (tablet->current_device, axis_index,
|
||||
position, &tablet->axes[axis_index]);
|
||||
|
||||
GDK_DISPLAY_NOTE (GDK_WAYLAND_SEAT (tool->seat)->display, EVENTS,
|
||||
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
||||
g_message ("tablet tool %d slider %d",
|
||||
gdk_device_tool_get_tool_type (tool->tool), position));
|
||||
}
|
||||
@@ -3760,7 +3763,7 @@ tablet_tool_handle_wheel (void *data,
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
|
||||
GdkEvent *event;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("tablet tool %d wheel %d/%d",
|
||||
gdk_device_tool_get_tool_type (tool->tool), degrees, clicks));
|
||||
|
||||
@@ -3790,10 +3793,9 @@ tablet_tool_handle_frame (void *data,
|
||||
{
|
||||
GdkWaylandTabletToolData *tool = data;
|
||||
GdkWaylandTabletData *tablet = tool->current_tablet;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
|
||||
GdkEvent *frame_event;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (tablet->seat, EVENTS,
|
||||
g_message ("tablet frame, time %d", time));
|
||||
|
||||
frame_event = tablet->pointer_info.frame.event;
|
||||
@@ -3836,10 +3838,8 @@ tablet_pad_ring_handle_source (void *data,
|
||||
uint32_t source)
|
||||
{
|
||||
GdkWaylandTabletPadGroupData *group = data;
|
||||
GdkWaylandTabletPadData *pad = group->pad;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
||||
g_message ("tablet pad ring handle source, ring = %p source = %d",
|
||||
wp_tablet_pad_ring, source));
|
||||
|
||||
@@ -3852,10 +3852,8 @@ tablet_pad_ring_handle_angle (void *data,
|
||||
wl_fixed_t angle)
|
||||
{
|
||||
GdkWaylandTabletPadGroupData *group = data;
|
||||
GdkWaylandTabletPadData *pad = group->pad;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
||||
g_message ("tablet pad ring handle angle, ring = %p angle = %f",
|
||||
wp_tablet_pad_ring, wl_fixed_to_double (angle)));
|
||||
|
||||
@@ -3867,10 +3865,8 @@ tablet_pad_ring_handle_stop (void *data,
|
||||
struct zwp_tablet_pad_ring_v2 *wp_tablet_pad_ring)
|
||||
{
|
||||
GdkWaylandTabletPadGroupData *group = data;
|
||||
GdkWaylandTabletPadData *pad = group->pad;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
||||
g_message ("tablet pad ring handle stop, ring = %p", wp_tablet_pad_ring));
|
||||
|
||||
group->axis_tmp_info.is_stop = TRUE;
|
||||
@@ -3886,7 +3882,7 @@ tablet_pad_ring_handle_frame (void *data,
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
GdkEvent *event;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("tablet pad ring handle frame, ring = %p", wp_tablet_pad_ring));
|
||||
|
||||
event = gdk_event_new (GDK_PAD_RING);
|
||||
@@ -3916,10 +3912,8 @@ tablet_pad_strip_handle_source (void *data,
|
||||
uint32_t source)
|
||||
{
|
||||
GdkWaylandTabletPadGroupData *group = data;
|
||||
GdkWaylandTabletPadData *pad = group->pad;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
||||
g_message ("tablet pad strip handle source, strip = %p source = %d",
|
||||
wp_tablet_pad_strip, source));
|
||||
|
||||
@@ -3932,10 +3926,8 @@ tablet_pad_strip_handle_position (void *data,
|
||||
uint32_t position)
|
||||
{
|
||||
GdkWaylandTabletPadGroupData *group = data;
|
||||
GdkWaylandTabletPadData *pad = group->pad;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
||||
g_message ("tablet pad strip handle position, strip = %p position = %d",
|
||||
wp_tablet_pad_strip, position));
|
||||
|
||||
@@ -3947,10 +3939,8 @@ tablet_pad_strip_handle_stop (void *data,
|
||||
struct zwp_tablet_pad_strip_v2 *wp_tablet_pad_strip)
|
||||
{
|
||||
GdkWaylandTabletPadGroupData *group = data;
|
||||
GdkWaylandTabletPadData *pad = group->pad;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
||||
g_message ("tablet pad strip handle stop, strip = %p",
|
||||
wp_tablet_pad_strip));
|
||||
|
||||
@@ -3967,7 +3957,7 @@ tablet_pad_strip_handle_frame (void *data,
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
GdkEvent *event;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("tablet pad strip handle frame, strip = %p",
|
||||
wp_tablet_pad_strip));
|
||||
|
||||
@@ -3999,11 +3989,9 @@ tablet_pad_group_handle_buttons (void *data,
|
||||
struct wl_array *buttons)
|
||||
{
|
||||
GdkWaylandTabletPadGroupData *group = data;
|
||||
GdkWaylandTabletPadData *pad = group->pad;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
uint32_t *p;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
||||
g_message ("tablet pad group handle buttons, pad group = %p, n_buttons = %" G_GSIZE_FORMAT,
|
||||
wp_tablet_pad_group, buttons->size));
|
||||
|
||||
@@ -4021,10 +4009,8 @@ tablet_pad_group_handle_ring (void *data,
|
||||
struct zwp_tablet_pad_ring_v2 *wp_tablet_pad_ring)
|
||||
{
|
||||
GdkWaylandTabletPadGroupData *group = data;
|
||||
GdkWaylandTabletPadData *pad = group->pad;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
||||
g_message ("tablet pad group handle ring, pad group = %p, ring = %p",
|
||||
wp_tablet_pad_group, wp_tablet_pad_ring));
|
||||
|
||||
@@ -4042,10 +4028,8 @@ tablet_pad_group_handle_strip (void *data,
|
||||
struct zwp_tablet_pad_strip_v2 *wp_tablet_pad_strip)
|
||||
{
|
||||
GdkWaylandTabletPadGroupData *group = data;
|
||||
GdkWaylandTabletPadData *pad = group->pad;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
||||
g_message ("tablet pad group handle strip, pad group = %p, strip = %p",
|
||||
wp_tablet_pad_group, wp_tablet_pad_strip));
|
||||
|
||||
@@ -4063,10 +4047,8 @@ tablet_pad_group_handle_modes (void *data,
|
||||
uint32_t modes)
|
||||
{
|
||||
GdkWaylandTabletPadGroupData *group = data;
|
||||
GdkWaylandTabletPadData *pad = group->pad;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
||||
g_message ("tablet pad group handle modes, pad group = %p, n_modes = %d",
|
||||
wp_tablet_pad_group, modes));
|
||||
|
||||
@@ -4077,11 +4059,11 @@ static void
|
||||
tablet_pad_group_handle_done (void *data,
|
||||
struct zwp_tablet_pad_group_v2 *wp_tablet_pad_group)
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
GdkWaylandTabletPadGroupData *group = data;
|
||||
GdkWaylandTabletPadData *pad = group->pad;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
#endif
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
||||
g_message ("tablet pad group handle done, pad group = %p",
|
||||
wp_tablet_pad_group));
|
||||
}
|
||||
@@ -4099,7 +4081,7 @@ tablet_pad_group_handle_mode (void *data,
|
||||
GdkEvent *event;
|
||||
guint n_group;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("tablet pad group handle mode, pad group = %p, mode = %d",
|
||||
wp_tablet_pad_group, mode));
|
||||
|
||||
@@ -4135,9 +4117,8 @@ tablet_pad_handle_group (void *data,
|
||||
{
|
||||
GdkWaylandTabletPadData *pad = data;
|
||||
GdkWaylandTabletPadGroupData *group;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
||||
g_message ("tablet pad handle group, pad group = %p, group = %p",
|
||||
wp_tablet_pad_group, wp_tablet_pad_group));
|
||||
|
||||
@@ -4157,9 +4138,8 @@ tablet_pad_handle_path (void *data,
|
||||
const char *path)
|
||||
{
|
||||
GdkWaylandTabletPadData *pad = data;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
||||
g_message ("tablet pad handle path, pad = %p, path = %s",
|
||||
wp_tablet_pad, path));
|
||||
|
||||
@@ -4172,9 +4152,8 @@ tablet_pad_handle_buttons (void *data,
|
||||
uint32_t buttons)
|
||||
{
|
||||
GdkWaylandTabletPadData *pad = data;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
||||
g_message ("tablet pad handle buttons, pad = %p, n_buttons = %d",
|
||||
wp_tablet_pad, buttons));
|
||||
|
||||
@@ -4186,9 +4165,8 @@ tablet_pad_handle_done (void *data,
|
||||
struct zwp_tablet_pad_v2 *wp_tablet_pad)
|
||||
{
|
||||
GdkWaylandTabletPadData *pad = data;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
||||
g_message ("tablet pad handle done, pad = %p", wp_tablet_pad));
|
||||
|
||||
pad->device =
|
||||
@@ -4198,11 +4176,11 @@ tablet_pad_handle_done (void *data,
|
||||
"input-source", GDK_SOURCE_TABLET_PAD,
|
||||
"input-mode", GDK_MODE_SCREEN,
|
||||
"display", gdk_seat_get_display (pad->seat),
|
||||
"seat", seat,
|
||||
"seat", pad->seat,
|
||||
NULL);
|
||||
|
||||
_gdk_device_set_associated_device (pad->device, seat->master_keyboard);
|
||||
gdk_seat_device_added (GDK_SEAT (seat), pad->device);
|
||||
_gdk_device_set_associated_device (pad->device, GDK_WAYLAND_SEAT (pad->seat)->master_keyboard);
|
||||
gdk_seat_device_added (GDK_SEAT (pad->seat), pad->device);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -4214,11 +4192,10 @@ tablet_pad_handle_button (void *data,
|
||||
{
|
||||
GdkWaylandTabletPadData *pad = data;
|
||||
GdkWaylandTabletPadGroupData *group;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
GdkEvent *event;
|
||||
gint n_group;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
||||
g_message ("tablet pad handle button, pad = %p, button = %d, state = %d",
|
||||
wp_tablet_pad, button, state));
|
||||
|
||||
@@ -4228,7 +4205,7 @@ tablet_pad_handle_button (void *data,
|
||||
event = gdk_event_new (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ?
|
||||
GDK_PAD_BUTTON_PRESS :
|
||||
GDK_PAD_BUTTON_RELEASE);
|
||||
g_set_object (&event->any.surface, seat->keyboard_focus);
|
||||
g_set_object (&event->any.surface, GDK_WAYLAND_SEAT (pad->seat)->keyboard_focus);
|
||||
event->pad_button.button = button;
|
||||
event->pad_button.group = n_group;
|
||||
event->pad_button.mode = group->current_mode;
|
||||
@@ -4236,8 +4213,7 @@ tablet_pad_handle_button (void *data,
|
||||
gdk_event_set_device (event, pad->device);
|
||||
gdk_event_set_source_device (event, pad->device);
|
||||
|
||||
_gdk_wayland_display_deliver_event (gdk_seat_get_display (pad->seat),
|
||||
event);
|
||||
_gdk_wayland_display_deliver_event (gdk_seat_get_display (pad->seat), event);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -4248,10 +4224,9 @@ tablet_pad_handle_enter (void *data,
|
||||
struct wl_surface *surface)
|
||||
{
|
||||
GdkWaylandTabletPadData *pad = data;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
GdkWaylandTabletData *tablet = zwp_tablet_v2_get_user_data (wp_tablet);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
||||
g_message ("tablet pad handle enter, pad = %p, tablet = %p surface = %p",
|
||||
wp_tablet_pad, wp_tablet, surface));
|
||||
|
||||
@@ -4267,9 +4242,8 @@ tablet_pad_handle_leave (void *data,
|
||||
struct wl_surface *surface)
|
||||
{
|
||||
GdkWaylandTabletPadData *pad = data;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
||||
g_message ("tablet pad handle leave, pad = %p, surface = %p",
|
||||
wp_tablet_pad, surface));
|
||||
|
||||
@@ -4285,9 +4259,8 @@ tablet_pad_handle_removed (void *data,
|
||||
struct zwp_tablet_pad_v2 *wp_tablet_pad)
|
||||
{
|
||||
GdkWaylandTabletPadData *pad = data;
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
||||
g_message ("tablet pad handle removed, pad = %p", wp_tablet_pad));
|
||||
|
||||
/* Remove from the current tablet */
|
||||
@@ -4459,7 +4432,7 @@ pointer_surface_enter (void *data,
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
||||
GdkWaylandTabletData *tablet;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("pointer surface of seat %p entered output %p",
|
||||
seat, output));
|
||||
|
||||
@@ -4488,7 +4461,7 @@ pointer_surface_leave (void *data,
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
||||
GdkWaylandTabletData *tablet;
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("pointer surface of seat %p left output %p",
|
||||
seat, output));
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "gdkglcontext-wayland.h"
|
||||
#include "gdkvulkancontext-wayland.h"
|
||||
#include "gdkwaylandmonitor.h"
|
||||
#include "gdkprofilerprivate.h"
|
||||
#include <wayland/pointer-gestures-unstable-v1-client-protocol.h>
|
||||
#include "tablet-unstable-v2-client-protocol.h"
|
||||
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
|
||||
@@ -725,7 +726,6 @@ static void
|
||||
gdk_wayland_display_finalize (GObject *object)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (object);
|
||||
guint i;
|
||||
|
||||
_gdk_wayland_display_finalize_cursors (display_wayland);
|
||||
|
||||
@@ -733,13 +733,10 @@ gdk_wayland_display_finalize (GObject *object)
|
||||
g_free (display_wayland->cursor_theme_name);
|
||||
xkb_context_unref (display_wayland->xkb_context);
|
||||
|
||||
for (i = 0; i < GDK_WAYLAND_THEME_SCALES_COUNT; i++)
|
||||
if (display_wayland->cursor_theme)
|
||||
{
|
||||
if (display_wayland->scaled_cursor_themes[i])
|
||||
{
|
||||
wl_cursor_theme_destroy (display_wayland->scaled_cursor_themes[i]);
|
||||
display_wayland->scaled_cursor_themes[i] = NULL;
|
||||
}
|
||||
wl_cursor_theme_destroy (display_wayland->cursor_theme);
|
||||
display_wayland->cursor_theme = NULL;
|
||||
}
|
||||
|
||||
g_ptr_array_free (display_wayland->monitors, TRUE);
|
||||
@@ -1059,6 +1056,33 @@ gdk_wayland_display_get_toplevel_surfaces (GdkDisplay *display)
|
||||
return GDK_WAYLAND_DISPLAY (display)->toplevels;
|
||||
}
|
||||
|
||||
static struct wl_cursor_theme *
|
||||
get_cursor_theme (GdkWaylandDisplay *display_wayland,
|
||||
const char *name,
|
||||
int size)
|
||||
{
|
||||
const char * const *xdg_data_dirs;
|
||||
struct wl_cursor_theme *theme = NULL;
|
||||
int i;
|
||||
|
||||
xdg_data_dirs = g_get_system_data_dirs ();
|
||||
for (i = 0; xdg_data_dirs[i]; i++)
|
||||
{
|
||||
char *path = g_build_filename (xdg_data_dirs[i], "icons", name, "cursors", NULL);
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_IS_DIR))
|
||||
theme = wl_cursor_theme_create (path, size, display_wayland->shm);
|
||||
|
||||
g_free (path);
|
||||
|
||||
if (theme)
|
||||
return theme;
|
||||
}
|
||||
|
||||
/* This may fall back to builtin cursors */
|
||||
return wl_cursor_theme_create ("/usr/share/icons/default/cursors", size, display_wayland->shm);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
|
||||
const gchar *name,
|
||||
@@ -1066,7 +1090,6 @@ gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY(display);
|
||||
struct wl_cursor_theme *theme;
|
||||
int i;
|
||||
|
||||
g_assert (display_wayland);
|
||||
g_assert (display_wayland->shm);
|
||||
@@ -1075,22 +1098,20 @@ gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
|
||||
display_wayland->cursor_theme_size == size)
|
||||
return;
|
||||
|
||||
theme = wl_cursor_theme_load (name, size, display_wayland->shm);
|
||||
theme = get_cursor_theme (display_wayland, name, size);
|
||||
|
||||
if (theme == NULL)
|
||||
{
|
||||
g_warning ("Failed to load cursor theme %s", name);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < GDK_WAYLAND_THEME_SCALES_COUNT; i++)
|
||||
if (display_wayland->cursor_theme)
|
||||
{
|
||||
if (display_wayland->scaled_cursor_themes[i])
|
||||
{
|
||||
wl_cursor_theme_destroy (display_wayland->scaled_cursor_themes[i]);
|
||||
display_wayland->scaled_cursor_themes[i] = NULL;
|
||||
}
|
||||
wl_cursor_theme_destroy (display_wayland->cursor_theme);
|
||||
display_wayland->cursor_theme = NULL;
|
||||
}
|
||||
display_wayland->scaled_cursor_themes[0] = theme;
|
||||
display_wayland->cursor_theme = theme;
|
||||
if (display_wayland->cursor_theme_name != NULL)
|
||||
g_free (display_wayland->cursor_theme_name);
|
||||
display_wayland->cursor_theme_name = g_strdup (name);
|
||||
@@ -1098,31 +1119,11 @@ gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
|
||||
}
|
||||
|
||||
struct wl_cursor_theme *
|
||||
_gdk_wayland_display_get_scaled_cursor_theme (GdkWaylandDisplay *display_wayland,
|
||||
guint scale)
|
||||
_gdk_wayland_display_get_cursor_theme (GdkWaylandDisplay *display_wayland)
|
||||
{
|
||||
struct wl_cursor_theme *theme;
|
||||
|
||||
g_assert (display_wayland->cursor_theme_name);
|
||||
g_assert (scale <= GDK_WAYLAND_MAX_THEME_SCALE);
|
||||
g_assert (scale >= 1);
|
||||
|
||||
theme = display_wayland->scaled_cursor_themes[scale - 1];
|
||||
if (!theme)
|
||||
{
|
||||
theme = wl_cursor_theme_load (display_wayland->cursor_theme_name,
|
||||
display_wayland->cursor_theme_size * scale,
|
||||
display_wayland->shm);
|
||||
if (theme == NULL)
|
||||
{
|
||||
g_warning ("Failed to load cursor theme %s with scale %u",
|
||||
display_wayland->cursor_theme_name, scale);
|
||||
return NULL;
|
||||
}
|
||||
display_wayland->scaled_cursor_themes[scale - 1] = theme;
|
||||
}
|
||||
|
||||
return theme;
|
||||
return display_wayland->cursor_theme;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1131,6 +1132,7 @@ _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland)
|
||||
guint size;
|
||||
const gchar *name;
|
||||
GValue v = G_VALUE_INIT;
|
||||
gint64 before = g_get_monotonic_time ();
|
||||
|
||||
g_assert (display_wayland);
|
||||
g_assert (display_wayland->shm);
|
||||
@@ -1150,6 +1152,12 @@ _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland)
|
||||
|
||||
gdk_wayland_display_set_cursor_theme (GDK_DISPLAY (display_wayland), name, size);
|
||||
g_value_unset (&v);
|
||||
|
||||
if (gdk_profiler_is_running ())
|
||||
{
|
||||
gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "wayland", "load cursor theme");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
guint32
|
||||
@@ -2307,10 +2315,11 @@ xdg_output_handle_description (void *data,
|
||||
struct zxdg_output_v1 *xdg_output,
|
||||
const char *description)
|
||||
{
|
||||
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *) data;
|
||||
|
||||
GDK_NOTE (MISC,
|
||||
g_message ("handle description xdg-output %d", monitor->id));
|
||||
{
|
||||
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *) data;
|
||||
g_message ("handle description xdg-output %d", monitor->id);
|
||||
});
|
||||
}
|
||||
|
||||
static const struct zxdg_output_v1_listener xdg_output_listener = {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <wayland-client.h>
|
||||
#include <wayland-cursor.h>
|
||||
#include <wayland-egl.h>
|
||||
#include <gdk/wayland/tablet-unstable-v2-client-protocol.h>
|
||||
#include <gdk/wayland/gtk-shell-client-protocol.h>
|
||||
@@ -45,6 +44,7 @@
|
||||
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkwaylanddevice.h"
|
||||
#include "cursor/wayland-cursor.h"
|
||||
|
||||
#include <epoxy/egl.h>
|
||||
|
||||
@@ -126,7 +126,7 @@ struct _GdkWaylandDisplay
|
||||
|
||||
GList *current_popups;
|
||||
|
||||
struct wl_cursor_theme *scaled_cursor_themes[GDK_WAYLAND_THEME_SCALES_COUNT];
|
||||
struct wl_cursor_theme *cursor_theme;
|
||||
gchar *cursor_theme_name;
|
||||
int cursor_theme_size;
|
||||
GHashTable *cursor_surface_cache;
|
||||
|
||||
@@ -173,7 +173,7 @@ gdk_wayland_drag_drop_done (GdkDrag *drag,
|
||||
GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag);
|
||||
GdkDevice *device = gdk_drag_get_device (drag);
|
||||
|
||||
gdk_wayland_seat_set_drag (gdk_device_get_seat (device), drag);
|
||||
gdk_wayland_seat_set_drag (gdk_device_get_seat (device), NULL);
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
||||
@@ -51,7 +51,6 @@ struct _GdkWaylandDrop
|
||||
struct wl_data_offer *offer;
|
||||
uint32_t source_actions;
|
||||
uint32_t action;
|
||||
GdkDragAction selected_action;
|
||||
uint32_t serial;
|
||||
};
|
||||
|
||||
@@ -116,43 +115,43 @@ gdk_wayland_drop_drop_set_status (GdkWaylandDrop *drop_wayland,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drop_commit_status (GdkWaylandDrop *wayland_drop)
|
||||
gdk_wayland_drop_commit_status (GdkWaylandDrop *wayland_drop,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
uint32_t dnd_actions;
|
||||
|
||||
display = gdk_drop_get_display (GDK_DROP (wayland_drop));
|
||||
|
||||
dnd_actions = gdk_to_wl_actions (wayland_drop->selected_action);
|
||||
|
||||
if (GDK_WAYLAND_DISPLAY (display)->data_device_manager_version >=
|
||||
WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION)
|
||||
{
|
||||
if (gdk_drag_action_is_unique (wayland_drop->selected_action))
|
||||
{
|
||||
wl_data_offer_set_actions (wayland_drop->offer, dnd_actions, dnd_actions);
|
||||
}
|
||||
uint32_t dnd_actions;
|
||||
uint32_t preferred_action;
|
||||
|
||||
dnd_actions = gdk_to_wl_actions (actions);
|
||||
|
||||
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
|
||||
preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
|
||||
else if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
|
||||
preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
|
||||
else if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
||||
preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
|
||||
else
|
||||
{
|
||||
wl_data_offer_set_actions (wayland_drop->offer,
|
||||
dnd_actions | WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK,
|
||||
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK);
|
||||
}
|
||||
preferred_action = 0;
|
||||
|
||||
wl_data_offer_set_actions (wayland_drop->offer, dnd_actions, preferred_action);
|
||||
}
|
||||
|
||||
gdk_wayland_drop_drop_set_status (wayland_drop, wayland_drop->selected_action != 0);
|
||||
gdk_wayland_drop_drop_set_status (wayland_drop, actions != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drop_status (GdkDrop *drop,
|
||||
GdkDragAction action)
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GdkWaylandDrop *wayland_drop;
|
||||
GdkWaylandDrop *wayland_drop = GDK_WAYLAND_DROP (drop);
|
||||
|
||||
wayland_drop = GDK_WAYLAND_DROP (drop);
|
||||
wayland_drop->selected_action = action;
|
||||
|
||||
gdk_wayland_drop_commit_status (wayland_drop);
|
||||
gdk_wayland_drop_commit_status (wayland_drop, actions);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -163,11 +162,9 @@ gdk_wayland_drop_finish (GdkDrop *drop,
|
||||
GdkDisplay *display = gdk_drop_get_display (drop);
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
wayland_drop->selected_action = action;
|
||||
|
||||
if (action)
|
||||
{
|
||||
gdk_wayland_drop_commit_status (wayland_drop);
|
||||
gdk_wayland_drop_commit_status (wayland_drop, action);
|
||||
|
||||
if (display_wayland->data_device_manager_version >=
|
||||
WL_DATA_OFFER_FINISH_SINCE_VERSION)
|
||||
@@ -184,19 +181,17 @@ gdk_wayland_drop_read_async (GdkDrop *drop,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkWaylandDrop *wayland_drop = GDK_WAYLAND_DROP (drop);
|
||||
GdkDisplay *display;
|
||||
GInputStream *stream;
|
||||
const char *mime_type;
|
||||
int pipe_fd[2];
|
||||
GError *error = NULL;
|
||||
GTask *task;
|
||||
|
||||
display = gdk_drop_get_display (drop),
|
||||
task = g_task_new (drop, cancellable, callback, user_data);
|
||||
g_task_set_priority (task, io_priority);
|
||||
g_task_set_source_tag (task, gdk_wayland_drop_read_async);
|
||||
|
||||
GDK_DISPLAY_NOTE (display, DND, char *s = gdk_content_formats_to_string (formats);
|
||||
GDK_DISPLAY_NOTE (gdk_drop_get_display (drop), DND, char *s = gdk_content_formats_to_string (formats);
|
||||
g_message ("%p: read for %s", drop, s);
|
||||
g_free (s); );
|
||||
mime_type = gdk_content_formats_match_mime_type (formats,
|
||||
@@ -288,7 +283,8 @@ gdk_wayland_drop_update_actions (GdkWaylandDrop *drop)
|
||||
GdkDragAction gdk_actions = 0;
|
||||
uint32_t wl_actions;
|
||||
|
||||
if (drop->action & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
||||
if (drop->action == 0 ||
|
||||
drop->action & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
||||
wl_actions = drop->source_actions;
|
||||
else
|
||||
wl_actions = drop->action;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "gdkinternals.h"
|
||||
#include "gdksurfaceprivate.h"
|
||||
#include "gdkprofilerprivate.h"
|
||||
|
||||
#include "gdkintl.h"
|
||||
|
||||
@@ -238,6 +239,7 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
|
||||
gdk_wayland_surface_sync (surface);
|
||||
gdk_wayland_surface_request_frame (surface);
|
||||
|
||||
gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "swap buffers");
|
||||
if (display_wayland->have_egl_swap_buffers_with_damage)
|
||||
{
|
||||
int i, j, n_rects = cairo_region_num_rectangles (painted);
|
||||
|
||||
@@ -57,8 +57,7 @@ gboolean _gdk_wayland_keymap_key_is_modifier (GdkKeymap *keymap,
|
||||
void _gdk_wayland_display_init_cursors (GdkWaylandDisplay *display);
|
||||
void _gdk_wayland_display_finalize_cursors (GdkWaylandDisplay *display);
|
||||
|
||||
struct wl_cursor_theme * _gdk_wayland_display_get_scaled_cursor_theme (GdkWaylandDisplay *display_wayland,
|
||||
guint scale);
|
||||
struct wl_cursor_theme * _gdk_wayland_display_get_cursor_theme (GdkWaylandDisplay *display_wayland);
|
||||
|
||||
void _gdk_wayland_display_get_default_cursor_size (GdkDisplay *display,
|
||||
guint *width,
|
||||
|
||||
@@ -357,6 +357,7 @@ frame_callback (void *data,
|
||||
GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
|
||||
GdkFrameTimings *timings;
|
||||
|
||||
gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "frame event");
|
||||
GDK_DISPLAY_NOTE (GDK_DISPLAY (display_wayland), EVENTS, g_message ("frame %p", surface));
|
||||
|
||||
wl_callback_destroy (callback);
|
||||
@@ -395,10 +396,10 @@ frame_callback (void *data,
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if ((_gdk_debug_flags & GDK_DEBUG_FRAMES) != 0)
|
||||
_gdk_frame_clock_debug_print_timings (clock, timings);
|
||||
#endif
|
||||
|
||||
if (gdk_profiler_is_running ())
|
||||
_gdk_frame_clock_add_timings_to_profiler (clock, timings);
|
||||
#endif
|
||||
}
|
||||
|
||||
static const struct wl_callback_listener frame_listener = {
|
||||
@@ -477,6 +478,7 @@ on_frame_clock_after_paint (GdkFrameClock *clock,
|
||||
* before we need to stage any changes, then we can take it back and
|
||||
* use it again.
|
||||
*/
|
||||
gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "surface commit");
|
||||
wl_surface_commit (impl->display_server.wl_surface);
|
||||
|
||||
impl->pending_commit = FALSE;
|
||||
@@ -1508,6 +1510,7 @@ gdk_wayland_surface_create_xdg_toplevel (GdkSurface *surface)
|
||||
if (impl->hint == GDK_SURFACE_TYPE_HINT_DIALOG)
|
||||
_gdk_wayland_screen_add_orphan_dialog (surface);
|
||||
|
||||
gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "surface commit");
|
||||
wl_surface_commit (impl->display_server.wl_surface);
|
||||
}
|
||||
|
||||
@@ -2302,6 +2305,7 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
|
||||
}
|
||||
}
|
||||
|
||||
gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "surface commit");
|
||||
wl_surface_commit (impl->display_server.wl_surface);
|
||||
|
||||
impl->popup_parent = parent;
|
||||
@@ -4109,7 +4113,7 @@ gdk_wayland_surface_is_exported (GdkSurface *surface)
|
||||
* gdk_wayland_surface_export_handle:
|
||||
* @surface: the #GdkSurface to obtain a handle for
|
||||
* @callback: callback to call with the handle
|
||||
* @user_data: user data for @callback
|
||||
* @user_data: (closure): user data for @callback
|
||||
* @destroy_func: destroy notify for @user_data
|
||||
*
|
||||
* Asynchronously obtains a handle for a surface that can be passed
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
subdir('cursor')
|
||||
|
||||
gdk_wayland_sources = files([
|
||||
'gdkapplaunchcontext-wayland.c',
|
||||
'gdkcairocontext-wayland.c',
|
||||
@@ -33,7 +35,6 @@ gdk_wayland_deps = [
|
||||
xkbdep,
|
||||
wlclientdep,
|
||||
wlprotocolsdep,
|
||||
wlcursordep,
|
||||
wlegldep,
|
||||
]
|
||||
|
||||
@@ -105,4 +106,5 @@ libgdk_wayland = static_library('gdk-wayland',
|
||||
'-DG_LOG_DOMAIN="Gdk"',
|
||||
] + common_cflags,
|
||||
link_args: common_ldflags,
|
||||
dependencies: [ gdk_deps, gdk_wayland_deps, ])
|
||||
link_with: [libwayland_cursor, ],
|
||||
dependencies: [ gdk_deps, gdk_wayland_deps])
|
||||
|
||||
@@ -65,16 +65,15 @@ print_atoms (GdkX11Clipboard *cb,
|
||||
const Atom *atoms,
|
||||
gsize n_atoms)
|
||||
{
|
||||
GdkDisplay *display = gdk_clipboard_get_display (GDK_CLIPBOARD (cb));
|
||||
|
||||
GDK_DISPLAY_NOTE (display, CLIPBOARD,
|
||||
GDK_DISPLAY_NOTE (gdk_clipboard_get_display (GDK_CLIPBOARD (cb)), CLIPBOARD, {
|
||||
gsize i;
|
||||
GdkDisplay *display = gdk_clipboard_get_display (GDK_CLIPBOARD (cb));
|
||||
|
||||
g_printerr ("%s: %s [ ", cb->selection, prefix);
|
||||
for (i = 0; i < n_atoms; i++)
|
||||
g_printerr ("%s%s", i > 0 ? ", " : "", gdk_x11_get_xatom_name_for_display (display , atoms[i]));
|
||||
g_printerr (" ]\n");
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -86,9 +85,7 @@ gdk_x11_clipboard_default_output_done (GObject *clipboard,
|
||||
|
||||
if (!gdk_clipboard_write_finish (GDK_CLIPBOARD (clipboard), result, &error))
|
||||
{
|
||||
GdkDisplay *display = gdk_clipboard_get_display (GDK_CLIPBOARD (clipboard));
|
||||
|
||||
GDK_DISPLAY_NOTE (display, CLIPBOARD,
|
||||
GDK_DISPLAY_NOTE (gdk_clipboard_get_display (GDK_CLIPBOARD (clipboard)), CLIPBOARD,
|
||||
g_printerr ("%s: failed to write stream: %s\n",
|
||||
GDK_X11_CLIPBOARD (clipboard)->selection, error->message));
|
||||
g_error_free (error);
|
||||
@@ -440,16 +437,20 @@ gdk_x11_clipboard_xevent (GdkDisplay *display,
|
||||
|
||||
case SelectionRequest:
|
||||
{
|
||||
const char *target, *property;
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
const char *target, *property;
|
||||
#endif
|
||||
|
||||
if (xevent->xselectionrequest.selection != cb->xselection)
|
||||
return FALSE;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
target = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.target);
|
||||
if (xevent->xselectionrequest.property == None)
|
||||
property = target;
|
||||
else
|
||||
property = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.property);
|
||||
#endif
|
||||
|
||||
if (!gdk_clipboard_is_local (GDK_CLIPBOARD (cb)))
|
||||
{
|
||||
|
||||
+30
-21
@@ -1061,6 +1061,7 @@ xdnd_send_enter (GdkX11Drag *drag_x11)
|
||||
{
|
||||
GdkDrag *drag = GDK_DRAG (drag_x11);
|
||||
GdkDisplay *display = gdk_drag_get_display (drag);
|
||||
GdkContentFormats *formats;
|
||||
const char * const *atoms;
|
||||
gsize i, n_atoms;
|
||||
XEvent xev;
|
||||
@@ -1080,7 +1081,10 @@ xdnd_send_enter (GdkX11Drag *drag_x11)
|
||||
GDK_DISPLAY_NOTE (display, DND,
|
||||
g_message ("Sending enter source window %#lx XDND protocol version %d\n",
|
||||
GDK_SURFACE_XID (drag_x11->ipc_surface), drag_x11->version));
|
||||
atoms = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_atoms);
|
||||
formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
|
||||
formats = gdk_content_formats_union_serialize_mime_types (formats);
|
||||
|
||||
atoms = gdk_content_formats_get_mime_types (formats, &n_atoms);
|
||||
|
||||
if (n_atoms > 3)
|
||||
{
|
||||
@@ -1300,8 +1304,7 @@ xdnd_precache_atoms (GdkDisplay *display)
|
||||
/* Source side */
|
||||
|
||||
static void
|
||||
gdk_drag_do_leave (GdkX11Drag *drag_x11,
|
||||
guint32 time)
|
||||
gdk_drag_do_leave (GdkX11Drag *drag_x11)
|
||||
{
|
||||
if (drag_x11->proxy_xid)
|
||||
{
|
||||
@@ -1502,27 +1505,10 @@ gdk_x11_drag_drag_motion (GdkDrag *drag,
|
||||
}
|
||||
}
|
||||
|
||||
/* When we have a Xdnd target, make sure our XdndActionList
|
||||
* matches the current actions;
|
||||
*/
|
||||
if (protocol == GDK_DRAG_PROTO_XDND && drag_x11->xdnd_actions != gdk_drag_get_actions (drag))
|
||||
{
|
||||
if (proxy_xid)
|
||||
{
|
||||
GdkDisplay *display = gdk_drag_get_display (drag);
|
||||
GdkDrop *drop = GDK_X11_DISPLAY (display)->current_drop;
|
||||
|
||||
if (drop && GDK_SURFACE_XID (gdk_drop_get_surface (drop)) == proxy_xid)
|
||||
gdk_x11_drop_read_actions (drop);
|
||||
else
|
||||
xdnd_set_actions (drag_x11);
|
||||
}
|
||||
}
|
||||
|
||||
if (drag_x11->proxy_xid != proxy_xid)
|
||||
{
|
||||
/* Send a leave to the last destination */
|
||||
gdk_drag_do_leave (drag_x11, time);
|
||||
gdk_drag_do_leave (drag_x11);
|
||||
drag_x11->drag_status = GDK_DRAG_STATUS_DRAG;
|
||||
|
||||
/* Check if new destination accepts drags, and which protocol */
|
||||
@@ -1558,6 +1544,23 @@ gdk_x11_drag_drag_motion (GdkDrag *drag,
|
||||
drag_x11->current_action = gdk_drag_get_selected_action (drag);
|
||||
}
|
||||
|
||||
/* When we have a Xdnd target, make sure our XdndActionList
|
||||
* matches the current actions;
|
||||
*/
|
||||
if (protocol == GDK_DRAG_PROTO_XDND && drag_x11->xdnd_actions != gdk_drag_get_actions (drag))
|
||||
{
|
||||
if (proxy_xid)
|
||||
{
|
||||
GdkDisplay *display = gdk_drag_get_display (drag);
|
||||
GdkDrop *drop = GDK_X11_DISPLAY (display)->current_drop;
|
||||
|
||||
if (drop && GDK_SURFACE_XID (gdk_drop_get_surface (drop)) == proxy_xid)
|
||||
gdk_x11_drop_read_actions (drop);
|
||||
else
|
||||
xdnd_set_actions (drag_x11);
|
||||
}
|
||||
}
|
||||
|
||||
/* Send a drag-motion event */
|
||||
|
||||
drag_x11->last_x = x_root;
|
||||
@@ -1746,16 +1749,20 @@ gdk_x11_drag_xevent (GdkDisplay *display,
|
||||
|
||||
case SelectionRequest:
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
const char *target, *property;
|
||||
#endif
|
||||
|
||||
if (xevent->xselectionrequest.selection != xselection)
|
||||
return FALSE;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
target = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.target);
|
||||
if (xevent->xselectionrequest.property == None)
|
||||
property = target;
|
||||
else
|
||||
property = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.property);
|
||||
#endif
|
||||
|
||||
if (xevent->xselectionrequest.requestor == None)
|
||||
{
|
||||
@@ -1814,6 +1821,7 @@ struct _GdkDragAnim {
|
||||
static void
|
||||
gdk_drag_anim_destroy (GdkDragAnim *anim)
|
||||
{
|
||||
gdk_surface_hide (anim->drag->drag_surface);
|
||||
g_object_unref (anim->drag);
|
||||
g_slice_free (GdkDragAnim, anim);
|
||||
}
|
||||
@@ -2137,6 +2145,7 @@ static void
|
||||
gdk_x11_drag_cancel (GdkDrag *drag,
|
||||
GdkDragCancelReason reason)
|
||||
{
|
||||
gdk_drag_do_leave (GDK_X11_DRAG (drag));
|
||||
drag_ungrab (drag);
|
||||
gdk_drag_drop_done (drag, FALSE);
|
||||
}
|
||||
|
||||
+18
-7
@@ -145,9 +145,9 @@ gdk_x11_drop_read_got_stream (GObject *source,
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *mime_type = ((GSList *) g_task_get_task_data (task))->data;
|
||||
#if 0
|
||||
gsize i;
|
||||
const char *mime_type = ((GSList *) g_task_get_task_data (task))->data;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (special_targets); i++)
|
||||
{
|
||||
@@ -166,7 +166,7 @@ gdk_x11_drop_read_got_stream (GObject *source,
|
||||
#endif
|
||||
|
||||
GDK_NOTE (DND, g_printerr ("reading DND as %s now\n",
|
||||
mime_type));
|
||||
(const char *)((GSList *) g_task_get_task_data (task))->data));
|
||||
g_task_return_pointer (task, stream, g_object_unref);
|
||||
}
|
||||
|
||||
@@ -732,14 +732,14 @@ gdk_x11_drop_do_nothing (Window window,
|
||||
gboolean success,
|
||||
gpointer data)
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
GdkDisplay *display = data;
|
||||
|
||||
if (!success)
|
||||
{
|
||||
GDK_DISPLAY_NOTE (display, DND,
|
||||
g_message ("Send event to %lx failed",
|
||||
window));
|
||||
GDK_DISPLAY_NOTE (display, DND, g_message ("Send event to %lx failed", window));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -747,7 +747,7 @@ gdk_x11_drop_status (GdkDrop *drop,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GdkX11Drop *drop_x11 = GDK_X11_DROP (drop);
|
||||
GdkDragAction possible_actions;
|
||||
GdkDragAction possible_actions, suggested_action;
|
||||
XEvent xev;
|
||||
GdkDisplay *display;
|
||||
|
||||
@@ -755,6 +755,17 @@ gdk_x11_drop_status (GdkDrop *drop,
|
||||
|
||||
possible_actions = actions & gdk_drop_get_actions (drop);
|
||||
|
||||
if (drop_x11->suggested_action != 0)
|
||||
suggested_action = drop_x11->suggested_action;
|
||||
else if (possible_actions & GDK_ACTION_COPY)
|
||||
suggested_action = GDK_ACTION_COPY;
|
||||
else if (possible_actions & GDK_ACTION_MOVE)
|
||||
suggested_action = GDK_ACTION_MOVE;
|
||||
else if (possible_actions & GDK_ACTION_ASK)
|
||||
suggested_action = GDK_ACTION_ASK;
|
||||
else
|
||||
suggested_action = 0;
|
||||
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndStatus");
|
||||
xev.xclient.format = 32;
|
||||
@@ -764,7 +775,7 @@ gdk_x11_drop_status (GdkDrop *drop,
|
||||
xev.xclient.data.l[1] = (possible_actions != 0) ? (2 | 1) : 0;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
xev.xclient.data.l[3] = 0;
|
||||
xev.xclient.data.l[4] = xdnd_action_to_atom (display, possible_actions);
|
||||
xev.xclient.data.l[4] = xdnd_action_to_atom (display, suggested_action);
|
||||
|
||||
if (gdk_drop_get_drag (drop))
|
||||
{
|
||||
|
||||
+20
-38
@@ -590,29 +590,27 @@ gsk_gl_driver_create_texture (GskGLDriver *self,
|
||||
return t->texture_id;
|
||||
}
|
||||
|
||||
static int
|
||||
create_render_target (GskGLDriver *self,
|
||||
int texture_id,
|
||||
gboolean add_depth_buffer,
|
||||
gboolean add_stencil_buffer)
|
||||
void
|
||||
gsk_gl_driver_create_render_target (GskGLDriver *self,
|
||||
int width,
|
||||
int height,
|
||||
int *out_texture_id,
|
||||
int *out_render_target_id)
|
||||
{
|
||||
GLuint fbo_id, depth_stencil_buffer_id;
|
||||
Texture *t;
|
||||
GLuint fbo_id;
|
||||
Texture *texture;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_GL_DRIVER (self), -1);
|
||||
g_return_val_if_fail (self->in_frame, -1);
|
||||
g_return_if_fail (self->in_frame);
|
||||
|
||||
t = gsk_gl_driver_get_texture (self, texture_id);
|
||||
if (t == NULL)
|
||||
return -1;
|
||||
|
||||
if (t->fbo.fbo_id != 0)
|
||||
fbo_clear (&t->fbo);
|
||||
texture = create_texture (self, width, height);
|
||||
gsk_gl_driver_bind_source_texture (self, texture->texture_id);
|
||||
gsk_gl_driver_init_texture_empty (self, texture->texture_id, GL_NEAREST, GL_NEAREST);
|
||||
|
||||
glGenFramebuffers (1, &fbo_id);
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, fbo_id);
|
||||
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, t->texture_id, 0);
|
||||
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->texture_id, 0);
|
||||
|
||||
#if 0
|
||||
if (add_depth_buffer || add_stencil_buffer)
|
||||
{
|
||||
glGenRenderbuffersEXT (1, &depth_stencil_buffer_id);
|
||||
@@ -638,34 +636,18 @@ create_render_target (GskGLDriver *self,
|
||||
if (add_stencil_buffer)
|
||||
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER, depth_stencil_buffer_id);
|
||||
texture->fbo.depth_stencil_id = depth_stencil_buffer_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
t->fbo.fbo_id = fbo_id;
|
||||
t->fbo.depth_stencil_id = depth_stencil_buffer_id;
|
||||
texture->fbo.fbo_id = fbo_id;
|
||||
|
||||
g_assert_cmphex (glCheckFramebufferStatus (GL_FRAMEBUFFER), ==, GL_FRAMEBUFFER_COMPLETE);
|
||||
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, self->default_fbo.fbo_id);
|
||||
|
||||
return fbo_id;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_driver_create_render_target (GskGLDriver *self,
|
||||
int width,
|
||||
int height,
|
||||
int *out_texture_id,
|
||||
int *out_render_target_id)
|
||||
{
|
||||
int texture_id, render_target;
|
||||
|
||||
texture_id = gsk_gl_driver_create_texture (self, width, height);
|
||||
gsk_gl_driver_bind_source_texture (self, texture_id);
|
||||
gsk_gl_driver_init_texture_empty (self, texture_id, GL_NEAREST, GL_NEAREST);
|
||||
|
||||
render_target = create_render_target (self, texture_id, FALSE, FALSE);
|
||||
|
||||
*out_texture_id = texture_id;
|
||||
*out_render_target_id = render_target;
|
||||
*out_texture_id = texture->texture_id;
|
||||
*out_render_target_id = fbo_id;
|
||||
}
|
||||
|
||||
/* Mark the texture permanent, meaning it won'e be reused by the GLDriver.
|
||||
|
||||
@@ -195,10 +195,15 @@ upload_glyph (GlyphCacheKey *key,
|
||||
{
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, r.stride / 4);
|
||||
glBindTexture (GL_TEXTURE_2D, value->texture_id);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
r.x, r.y, r.width, r.height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
r.data);
|
||||
|
||||
if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, r.x, r.y, r.width, r.height,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
r.data);
|
||||
else
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, r.x, r.y, r.width, r.height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
r.data);
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
|
||||
g_free (r.data);
|
||||
}
|
||||
|
||||
+19
-12
@@ -83,7 +83,7 @@ gsk_gl_icon_cache_begin_frame (GskGLIconCache *self,
|
||||
}
|
||||
|
||||
if (self->timestamp % MAX_FRAME_AGE == 0)
|
||||
{
|
||||
{
|
||||
g_hash_table_iter_init (&iter, self->icons);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *)&texture, (gpointer *)&icon_data))
|
||||
{
|
||||
@@ -134,6 +134,7 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
|
||||
int packed_y = 0;
|
||||
cairo_surface_t *surface;
|
||||
unsigned char *surface_data;
|
||||
guint gl_format;
|
||||
|
||||
gsk_gl_texture_atlases_pack (self->atlases, width + 2, height + 2, &atlas, &packed_x, &packed_y);
|
||||
|
||||
@@ -155,30 +156,37 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
|
||||
surface_data = cairo_image_surface_get_data (surface);
|
||||
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
|
||||
"Uploading texture");
|
||||
|
||||
if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
|
||||
gl_format = GL_RGBA;
|
||||
else
|
||||
gl_format = GL_BGRA;
|
||||
|
||||
glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
|
||||
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + 1, packed_y + 1,
|
||||
width, height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format,
|
||||
GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding top */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + 1, packed_y,
|
||||
width, 1,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding left */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x, packed_y + 1,
|
||||
1, height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding top left */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x, packed_y,
|
||||
1, 1,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
|
||||
/* Padding right */
|
||||
@@ -187,13 +195,13 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + width + 1, packed_y + 1,
|
||||
1, height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding top right */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + width + 1, packed_y,
|
||||
1, 1,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding bottom */
|
||||
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
|
||||
@@ -202,13 +210,13 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + 1, packed_y + 1 + height,
|
||||
width, 1,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding bottom left */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x, packed_y + 1 + height,
|
||||
1, 1,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding bottom right */
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, width);
|
||||
@@ -216,9 +224,8 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + 1 + width, packed_y + 1 + height,
|
||||
1, 1,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
|
||||
/* Reset this */
|
||||
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
|
||||
@@ -239,7 +246,7 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
|
||||
char *filename = g_strdup_printf ("atlas_%u_%d.png", atlas->texture_id, k++);
|
||||
|
||||
glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
|
||||
glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
|
||||
glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, data);
|
||||
s = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32, atlas->width, atlas->height, stride);
|
||||
cairo_surface_write_to_png (s, filename);
|
||||
|
||||
|
||||
+383
-587
File diff suppressed because it is too large
Load Diff
+81
-55
@@ -8,6 +8,46 @@ rect_equal (const graphene_rect_t *a,
|
||||
return memcmp (a, b, sizeof (graphene_rect_t)) == 0;
|
||||
}
|
||||
|
||||
static inline gboolean G_GNUC_PURE
|
||||
rounded_rect_equal (const GskRoundedRect *r1,
|
||||
const GskRoundedRect *r2)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!r1)
|
||||
return FALSE;
|
||||
|
||||
if (r1->bounds.origin.x != r2->bounds.origin.x ||
|
||||
r1->bounds.origin.y != r2->bounds.origin.y ||
|
||||
r1->bounds.size.width != r2->bounds.size.width ||
|
||||
r1->bounds.size.height != r2->bounds.size.height)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < 4; i ++)
|
||||
if (r1->corner[i].width != r2->corner[i].width ||
|
||||
r1->corner[i].height != r2->corner[i].height)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline gboolean G_GNUC_PURE
|
||||
rounded_rect_corners_equal (const GskRoundedRect *r1,
|
||||
const GskRoundedRect *r2)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!r1)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < 4; i ++)
|
||||
if (r1->corner[i].width != r2->corner[i].width ||
|
||||
r1->corner[i].height != r2->corner[i].height)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline ProgramState *
|
||||
get_current_program_state (RenderOpBuilder *builder)
|
||||
{
|
||||
@@ -41,16 +81,6 @@ ops_finish (RenderOpBuilder *builder)
|
||||
builder->current_viewport = GRAPHENE_RECT_INIT (0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
rgba_to_float (const GdkRGBA *c,
|
||||
float *f)
|
||||
{
|
||||
f[0] = c->red;
|
||||
f[1] = c->green;
|
||||
f[2] = c->blue;
|
||||
f[3] = c->alpha;
|
||||
}
|
||||
|
||||
/* Debugging only! */
|
||||
void
|
||||
ops_dump_framebuffer (RenderOpBuilder *builder,
|
||||
@@ -97,15 +127,12 @@ static void
|
||||
extract_matrix_metadata (GskTransform *transform,
|
||||
OpsMatrixMetadata *md)
|
||||
{
|
||||
float dummy;
|
||||
|
||||
switch (gsk_transform_get_category (transform))
|
||||
{
|
||||
case GSK_TRANSFORM_CATEGORY_IDENTITY:
|
||||
md->scale_x = 1;
|
||||
md->scale_y = 1;
|
||||
break;
|
||||
|
||||
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
|
||||
gsk_transform_to_translate (transform, &md->translate_x, &md->translate_y);
|
||||
md->scale_x = 1;
|
||||
md->scale_y = 1;
|
||||
break;
|
||||
@@ -113,7 +140,7 @@ extract_matrix_metadata (GskTransform *transform,
|
||||
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
|
||||
gsk_transform_to_affine (transform,
|
||||
&md->scale_x, &md->scale_y,
|
||||
&md->translate_x, &md->translate_y);
|
||||
&dummy, &dummy);
|
||||
break;
|
||||
|
||||
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
|
||||
@@ -129,9 +156,6 @@ extract_matrix_metadata (GskTransform *transform,
|
||||
|
||||
/* TODO: 90% sure this is incorrect. But we should never hit this code
|
||||
* path anyway. */
|
||||
md->translate_x = graphene_matrix_get_value (&m, 3, 0);
|
||||
md->translate_y = graphene_matrix_get_value (&m, 3, 1);
|
||||
|
||||
graphene_vec3_init (&col1,
|
||||
graphene_matrix_get_value (&m, 0, 0),
|
||||
graphene_matrix_get_value (&m, 1, 0),
|
||||
@@ -156,17 +180,15 @@ ops_transform_bounds_modelview (const RenderOpBuilder *builder,
|
||||
const graphene_rect_t *src,
|
||||
graphene_rect_t *dst)
|
||||
{
|
||||
const MatrixStackEntry *head;
|
||||
graphene_rect_t r = *src;
|
||||
|
||||
g_assert (builder->mv_stack != NULL);
|
||||
g_assert (builder->mv_stack->len >= 1);
|
||||
|
||||
head = &g_array_index (builder->mv_stack, MatrixStackEntry, builder->mv_stack->len - 1);
|
||||
r.origin.x += builder->dx;
|
||||
r.origin.y += builder->dy;
|
||||
|
||||
gsk_transform_transform_bounds (builder->current_modelview, src, dst);
|
||||
|
||||
dst->origin.x += builder->dx * head->metadata.scale_x;
|
||||
dst->origin.y += builder->dy * head->metadata.scale_y;
|
||||
gsk_transform_transform_bounds (builder->current_modelview, &r, dst);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -205,11 +227,6 @@ void
|
||||
ops_set_program (RenderOpBuilder *builder,
|
||||
const Program *program)
|
||||
{
|
||||
/* The tricky part about this is that we want to initialize all uniforms of a program
|
||||
* to the current value from the builder, but only once. */
|
||||
static const GskRoundedRect empty_clip;
|
||||
static const graphene_matrix_t empty_matrix;
|
||||
static const graphene_rect_t empty_rect;
|
||||
OpProgram *op;
|
||||
ProgramState *program_state;
|
||||
|
||||
@@ -223,9 +240,7 @@ ops_set_program (RenderOpBuilder *builder,
|
||||
|
||||
program_state = &builder->program_state[program->index];
|
||||
|
||||
/* If the projection is not yet set for this program, we use the current one. */
|
||||
if (memcmp (&empty_matrix, &program_state->projection, sizeof (graphene_matrix_t)) == 0 ||
|
||||
memcmp (&builder->current_projection, &program_state->projection, sizeof (graphene_matrix_t)) != 0)
|
||||
if (memcmp (&builder->current_projection, &program_state->projection, sizeof (graphene_matrix_t)) != 0)
|
||||
{
|
||||
OpMatrix *opm;
|
||||
|
||||
@@ -245,8 +260,7 @@ ops_set_program (RenderOpBuilder *builder,
|
||||
program_state->modelview = gsk_transform_ref (builder->current_modelview);
|
||||
}
|
||||
|
||||
if (rect_equal (&empty_rect, &program_state->viewport) ||
|
||||
!rect_equal (&builder->current_viewport, &program_state->viewport))
|
||||
if (!rect_equal (&builder->current_viewport, &program_state->viewport))
|
||||
{
|
||||
OpViewport *opv;
|
||||
|
||||
@@ -255,13 +269,13 @@ ops_set_program (RenderOpBuilder *builder,
|
||||
program_state->viewport = builder->current_viewport;
|
||||
}
|
||||
|
||||
if (memcmp (&empty_clip, &program_state->clip, sizeof (GskRoundedRect)) == 0 ||
|
||||
memcmp (&builder->current_clip, &program_state->clip, sizeof (GskRoundedRect)) != 0)
|
||||
if (!rounded_rect_equal (builder->current_clip, &program_state->clip))
|
||||
{
|
||||
OpClip *opc;
|
||||
|
||||
opc = ops_begin (builder, OP_CHANGE_CLIP);
|
||||
opc->clip = *builder->current_clip;
|
||||
opc->send_corners = !rounded_rect_corners_equal (builder->current_clip, &program_state->clip);
|
||||
program_state->clip = *builder->current_clip;
|
||||
}
|
||||
|
||||
@@ -283,15 +297,25 @@ ops_set_clip (RenderOpBuilder *builder,
|
||||
OpClip *op;
|
||||
|
||||
if (current_program_state &&
|
||||
memcmp (¤t_program_state->clip, clip,sizeof (GskRoundedRect)) == 0)
|
||||
rounded_rect_equal (¤t_program_state->clip, clip))
|
||||
return;
|
||||
|
||||
if (!(op = op_buffer_peek_tail_checked (&builder->render_ops, OP_CHANGE_CLIP)))
|
||||
op = op_buffer_add (&builder->render_ops, OP_CHANGE_CLIP);
|
||||
{
|
||||
op = op_buffer_add (&builder->render_ops, OP_CHANGE_CLIP);
|
||||
op->send_corners = !current_program_state ||
|
||||
!rounded_rect_corners_equal (¤t_program_state->clip, clip);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If the op before sent the corners, this one needs, too */
|
||||
op->send_corners |= !current_program_state ||
|
||||
!rounded_rect_corners_equal (¤t_program_state->clip, clip);
|
||||
}
|
||||
|
||||
op->clip = *clip;
|
||||
|
||||
if (builder->current_program != NULL)
|
||||
if (current_program_state)
|
||||
current_program_state->clip = *clip;
|
||||
}
|
||||
|
||||
@@ -343,7 +367,6 @@ ops_set_modelview_internal (RenderOpBuilder *builder,
|
||||
GskTransform *transform)
|
||||
{
|
||||
ProgramState *current_program_state = get_current_program_state (builder);
|
||||
graphene_matrix_t matrix;
|
||||
OpMatrix *op;
|
||||
|
||||
#if 0
|
||||
@@ -353,12 +376,10 @@ ops_set_modelview_internal (RenderOpBuilder *builder,
|
||||
return;
|
||||
#endif
|
||||
|
||||
gsk_transform_to_matrix (transform, &matrix);
|
||||
|
||||
if (!(op = op_buffer_peek_tail_checked (&builder->render_ops, OP_CHANGE_MODELVIEW)))
|
||||
op = op_buffer_add (&builder->render_ops, OP_CHANGE_MODELVIEW);
|
||||
|
||||
op->matrix = matrix;
|
||||
gsk_transform_to_matrix (transform, &op->matrix);
|
||||
|
||||
if (builder->current_program != NULL)
|
||||
{
|
||||
@@ -597,7 +618,7 @@ ops_set_color (RenderOpBuilder *builder,
|
||||
current_program_state->color = *color;
|
||||
|
||||
op = ops_begin (builder, OP_CHANGE_COLOR);
|
||||
op->rgba = *color;
|
||||
op->rgba = color;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -620,8 +641,8 @@ ops_set_color_matrix (RenderOpBuilder *builder,
|
||||
current_program_state->color_matrix.offset = *offset;
|
||||
|
||||
op = ops_begin (builder, OP_CHANGE_COLOR_MATRIX);
|
||||
op->matrix = *matrix;
|
||||
op->offset = *offset;
|
||||
op->matrix = matrix;
|
||||
op->offset = offset;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -668,19 +689,17 @@ ops_set_border_color (RenderOpBuilder *builder,
|
||||
{
|
||||
ProgramState *current_program_state = get_current_program_state (builder);
|
||||
OpBorder *op;
|
||||
float fcolor[4];
|
||||
|
||||
rgba_to_float (color, fcolor);
|
||||
|
||||
if (memcmp (fcolor, ¤t_program_state->border.color, sizeof fcolor) == 0)
|
||||
if (gdk_rgba_equal (color, ¤t_program_state->border.color))
|
||||
return;
|
||||
|
||||
op = op_buffer_add (&builder->render_ops, OP_CHANGE_BORDER_COLOR);
|
||||
memcpy (op->color, fcolor, sizeof (float[4]));
|
||||
memcpy (current_program_state->border.color, fcolor, sizeof (float[4]));
|
||||
op->color = color;
|
||||
|
||||
current_program_state->border.color = *color;
|
||||
}
|
||||
|
||||
void
|
||||
GskQuadVertex *
|
||||
ops_draw (RenderOpBuilder *builder,
|
||||
const GskQuadVertex vertex_data[GL_N_VERTICES])
|
||||
{
|
||||
@@ -697,7 +716,14 @@ ops_draw (RenderOpBuilder *builder,
|
||||
op->vao_size = GL_N_VERTICES;
|
||||
}
|
||||
|
||||
g_array_append_vals (builder->vertices, vertex_data, GL_N_VERTICES);
|
||||
if (vertex_data)
|
||||
{
|
||||
g_array_append_vals (builder->vertices, vertex_data, GL_N_VERTICES);
|
||||
return NULL; /* Better not use this on the caller side */
|
||||
}
|
||||
|
||||
g_array_set_size (builder->vertices, builder->vertices->len + GL_N_VERTICES);
|
||||
return &g_array_index (builder->vertices, GskQuadVertex, builder->vertices->len - GL_N_VERTICES);
|
||||
}
|
||||
|
||||
/* The offset is only valid for the current modelview.
|
||||
|
||||
@@ -15,12 +15,8 @@
|
||||
#define GL_N_VERTICES 6
|
||||
#define GL_N_PROGRAMS 13
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float translate_x;
|
||||
float translate_y;
|
||||
float scale_x;
|
||||
float scale_y;
|
||||
|
||||
@@ -44,14 +40,10 @@ struct _Program
|
||||
int position_location;
|
||||
int uv_location;
|
||||
int alpha_location;
|
||||
int blend_mode_location;
|
||||
int viewport_location;
|
||||
int projection_location;
|
||||
int modelview_location;
|
||||
int clip_location;
|
||||
int clip_corner_widths_location;
|
||||
int clip_corner_heights_location;
|
||||
|
||||
int clip_rect_location;
|
||||
union {
|
||||
struct {
|
||||
int color_location;
|
||||
@@ -66,7 +58,6 @@ struct _Program
|
||||
struct {
|
||||
int num_color_stops_location;
|
||||
int color_stops_location;
|
||||
int color_offsets_location;
|
||||
int start_point_location;
|
||||
int end_point_location;
|
||||
} linear_gradient;
|
||||
@@ -79,19 +70,14 @@ struct _Program
|
||||
int color_location;
|
||||
int spread_location;
|
||||
int offset_location;
|
||||
int outline_location;
|
||||
int corner_widths_location;
|
||||
int corner_heights_location;
|
||||
int outline_rect_location;
|
||||
} inset_shadow;
|
||||
struct {
|
||||
int outline_location;
|
||||
int corner_widths_location;
|
||||
int corner_heights_location;
|
||||
int color_location;
|
||||
int outline_rect_location;
|
||||
} outset_shadow;
|
||||
struct {
|
||||
int outline_location;
|
||||
int corner_widths_location;
|
||||
int corner_heights_location;
|
||||
int outline_rect_location;
|
||||
int color_location;
|
||||
int spread_location;
|
||||
int offset_location;
|
||||
@@ -99,9 +85,7 @@ struct _Program
|
||||
struct {
|
||||
int color_location;
|
||||
int widths_location;
|
||||
int outline_location;
|
||||
int corner_widths_location;
|
||||
int corner_heights_location;
|
||||
int outline_rect_location;
|
||||
} border;
|
||||
struct {
|
||||
int source2_location;
|
||||
@@ -135,7 +119,7 @@ typedef struct
|
||||
} color_matrix;
|
||||
struct {
|
||||
float widths[4];
|
||||
float color[4];
|
||||
GdkRGBA color;
|
||||
GskRoundedRect outline;
|
||||
} border;
|
||||
};
|
||||
@@ -230,7 +214,7 @@ void ops_set_border_width (RenderOpBuilder *builder,
|
||||
void ops_set_border_color (RenderOpBuilder *builder,
|
||||
const GdkRGBA *color);
|
||||
|
||||
void ops_draw (RenderOpBuilder *builder,
|
||||
GskQuadVertex * ops_draw (RenderOpBuilder *builder,
|
||||
const GskQuadVertex vertex_data[GL_N_VERTICES]);
|
||||
|
||||
void ops_offset (RenderOpBuilder *builder,
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gskglshaderbuilderprivate.h"
|
||||
|
||||
#include "gskdebugprivate.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <epoxy/gl.h>
|
||||
|
||||
void
|
||||
gsk_gl_shader_builder_init (GskGLShaderBuilder *self,
|
||||
const char *common_preamble_resource_path,
|
||||
const char *vs_preamble_resource_path,
|
||||
const char *fs_preamble_resource_path)
|
||||
{
|
||||
memset (self, 0, sizeof (*self));
|
||||
|
||||
self->preamble = g_resources_lookup_data (common_preamble_resource_path, 0, NULL);
|
||||
self->vs_preamble = g_resources_lookup_data (vs_preamble_resource_path, 0, NULL);
|
||||
self->fs_preamble = g_resources_lookup_data (fs_preamble_resource_path, 0, NULL);
|
||||
|
||||
g_assert (self->preamble);
|
||||
g_assert (self->vs_preamble);
|
||||
g_assert (self->fs_preamble);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_shader_builder_finish (GskGLShaderBuilder *self)
|
||||
{
|
||||
g_bytes_unref (self->preamble);
|
||||
g_bytes_unref (self->vs_preamble);
|
||||
g_bytes_unref (self->fs_preamble);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_shader_builder_set_glsl_version (GskGLShaderBuilder *self,
|
||||
int version)
|
||||
{
|
||||
self->version = version;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_shader_error (int shader_id,
|
||||
GError **error)
|
||||
{
|
||||
int status;
|
||||
int log_len;
|
||||
char *buffer;
|
||||
int code_len;
|
||||
char *code;
|
||||
|
||||
glGetShaderiv (shader_id, GL_COMPILE_STATUS, &status);
|
||||
|
||||
if (G_LIKELY (status == GL_TRUE))
|
||||
return TRUE;
|
||||
|
||||
glGetShaderiv (shader_id, GL_INFO_LOG_LENGTH, &log_len);
|
||||
buffer = g_malloc0 (log_len + 1);
|
||||
glGetShaderInfoLog (shader_id, log_len, NULL, buffer);
|
||||
|
||||
glGetShaderiv (shader_id, GL_SHADER_SOURCE_LENGTH, &code_len);
|
||||
code = g_malloc0 (code_len + 1);
|
||||
glGetShaderSource (shader_id, code_len, NULL, code);
|
||||
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_COMPILATION_FAILED,
|
||||
"Compilation failure in shader.\nError message: %s\n\nSource code:\n%s\n\n",
|
||||
buffer,
|
||||
code);
|
||||
|
||||
g_free (buffer);
|
||||
g_free (code);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
gsk_gl_shader_builder_create_program (GskGLShaderBuilder *self,
|
||||
const char *resource_path,
|
||||
GError **error)
|
||||
{
|
||||
|
||||
GBytes *source_bytes = g_resources_lookup_data (resource_path, 0, NULL);
|
||||
char version_buffer[64];
|
||||
const char *source;
|
||||
const char *vertex_shader_start;
|
||||
const char *fragment_shader_start;
|
||||
int vertex_id;
|
||||
int fragment_id;
|
||||
int program_id = -1;
|
||||
int status;
|
||||
|
||||
g_assert (source_bytes);
|
||||
|
||||
source = g_bytes_get_data (source_bytes, NULL);
|
||||
vertex_shader_start = strstr (source, "VERTEX_SHADER");
|
||||
fragment_shader_start = strstr (source, "FRAGMENT_SHADER");
|
||||
|
||||
g_assert (vertex_shader_start);
|
||||
g_assert (fragment_shader_start);
|
||||
|
||||
/* They both start at the next newline */
|
||||
vertex_shader_start = strstr (vertex_shader_start, "\n");
|
||||
fragment_shader_start = strstr (fragment_shader_start, "\n");
|
||||
|
||||
g_snprintf (version_buffer, sizeof (version_buffer),
|
||||
"#version %d\n", self->version);
|
||||
|
||||
vertex_id = glCreateShader (GL_VERTEX_SHADER);
|
||||
glShaderSource (vertex_id, 8,
|
||||
(const char *[]) {
|
||||
version_buffer,
|
||||
self->debugging ? "#define GSK_DEBUG 1\n" : "",
|
||||
self->legacy ? "#define GSK_LEGACY 1\n" : "",
|
||||
self->gl3 ? "#define GSK_GL3 1\n" : "",
|
||||
self->gles ? "#define GSK_GLES 1\n" : "",
|
||||
g_bytes_get_data (self->preamble, NULL),
|
||||
g_bytes_get_data (self->vs_preamble, NULL),
|
||||
vertex_shader_start
|
||||
},
|
||||
(int[]) {
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
fragment_shader_start - vertex_shader_start
|
||||
});
|
||||
glCompileShader (vertex_id);
|
||||
|
||||
if (!check_shader_error (vertex_id, error))
|
||||
{
|
||||
glDeleteShader (vertex_id);
|
||||
goto out;
|
||||
}
|
||||
|
||||
fragment_id = glCreateShader (GL_FRAGMENT_SHADER);
|
||||
glShaderSource (fragment_id, 8,
|
||||
(const char *[]) {
|
||||
version_buffer,
|
||||
self->debugging ? "#define GSK_DEBUG 1\n" : "",
|
||||
self->legacy ? "#define GSK_LEGACY 1\n" : "",
|
||||
self->gl3 ? "#define GSK_GL3 1\n" : "",
|
||||
self->gles ? "#define GSK_GLES 1\n" : "",
|
||||
g_bytes_get_data (self->preamble, NULL),
|
||||
g_bytes_get_data (self->fs_preamble, NULL),
|
||||
fragment_shader_start
|
||||
},
|
||||
(int[]) {
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
});
|
||||
glCompileShader (fragment_id);
|
||||
|
||||
if (!check_shader_error (fragment_id, error))
|
||||
{
|
||||
glDeleteShader (fragment_id);
|
||||
goto out;
|
||||
}
|
||||
|
||||
program_id = glCreateProgram ();
|
||||
glAttachShader (program_id, vertex_id);
|
||||
glAttachShader (program_id, fragment_id);
|
||||
glLinkProgram (program_id);
|
||||
|
||||
glGetProgramiv (program_id, GL_LINK_STATUS, &status);
|
||||
if (status == GL_FALSE)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
int log_len = 0;
|
||||
|
||||
glGetProgramiv (program_id, GL_INFO_LOG_LENGTH, &log_len);
|
||||
|
||||
buffer = g_malloc0 (log_len + 1);
|
||||
glGetProgramInfoLog (program_id, log_len, NULL, buffer);
|
||||
|
||||
g_warning ("Linking failure in shader:\n%s", buffer);
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_LINK_FAILED,
|
||||
"Linking failure in shader: %s", buffer);
|
||||
|
||||
g_free (buffer);
|
||||
|
||||
glDeleteProgram (program_id);
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
glDetachShader (program_id, vertex_id);
|
||||
glDeleteShader (vertex_id);
|
||||
|
||||
glDetachShader (program_id, fragment_id);
|
||||
glDeleteShader (fragment_id);
|
||||
|
||||
out:
|
||||
g_bytes_unref (source_bytes);
|
||||
|
||||
return program_id;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef __GSK_SHADER_BUILDER_PRIVATE_H__
|
||||
#define __GSK_SHADER_BUILDER_PRIVATE_H__
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <graphene.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GBytes *preamble;
|
||||
GBytes *vs_preamble;
|
||||
GBytes *fs_preamble;
|
||||
|
||||
int version;
|
||||
|
||||
guint debugging: 1;
|
||||
guint gles: 1;
|
||||
guint gl3: 1;
|
||||
guint legacy: 1;
|
||||
|
||||
} GskGLShaderBuilder;
|
||||
|
||||
|
||||
void gsk_gl_shader_builder_init (GskGLShaderBuilder *self,
|
||||
const char *common_preamble_resource_path,
|
||||
const char *vs_preamble_resource_path,
|
||||
const char *fs_preamble_resource_path);
|
||||
void gsk_gl_shader_builder_finish (GskGLShaderBuilder *self);
|
||||
|
||||
void gsk_gl_shader_builder_set_glsl_version (GskGLShaderBuilder *self,
|
||||
int version);
|
||||
|
||||
int gsk_gl_shader_builder_create_program (GskGLShaderBuilder *self,
|
||||
const char *resource_path,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_SHADER_BUILDER_PRIVATE_H__ */
|
||||
@@ -25,12 +25,12 @@ key_equal (const void *x,
|
||||
const CacheKey *a = x;
|
||||
const CacheKey *b = y;
|
||||
|
||||
return graphene_size_equal (&a->outline.corner[0], &b->outline.corner[0]) &&
|
||||
return a->blur_radius == b->blur_radius &&
|
||||
graphene_size_equal (&a->outline.corner[0], &b->outline.corner[0]) &&
|
||||
graphene_size_equal (&a->outline.corner[1], &b->outline.corner[1]) &&
|
||||
graphene_size_equal (&a->outline.corner[2], &b->outline.corner[2]) &&
|
||||
graphene_size_equal (&a->outline.corner[3], &b->outline.corner[3]) &&
|
||||
graphene_rect_equal (&a->outline.bounds, &b->outline.bounds) &&
|
||||
a->blur_radius == b->blur_radius;
|
||||
graphene_rect_equal (&a->outline.bounds, &b->outline.bounds);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -166,7 +166,8 @@ gsk_gl_texture_atlases_pack (GskGLTextureAtlases *self,
|
||||
g_ptr_array_add (self->atlases, atlas);
|
||||
|
||||
/* Pack it onto that one, which surely has enough space... */
|
||||
gsk_gl_texture_atlas_pack (atlas, width, height, &x, &y);
|
||||
if (!gsk_gl_texture_atlas_pack (atlas, width, height, &x, &y))
|
||||
g_assert_not_reached ();
|
||||
|
||||
GSK_NOTE(GLYPH_CACHE, g_message ("adding new atlas"));
|
||||
}
|
||||
@@ -304,5 +305,5 @@ gsk_gl_texture_atlas_realize (GskGLTextureAtlas *atlas)
|
||||
atlas->texture_id = create_shared_texture (atlas->width, atlas->height);
|
||||
gdk_gl_context_label_object_printf (gdk_gl_context_get_current (),
|
||||
GL_TEXTURE, atlas->texture_id,
|
||||
"Glyph atlas %d", atlas->texture_id);
|
||||
"Texture atlas %d", atlas->texture_id);
|
||||
}
|
||||
|
||||
@@ -1,332 +0,0 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gskshaderbuilderprivate.h"
|
||||
|
||||
#include "gskdebugprivate.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <epoxy/gl.h>
|
||||
|
||||
struct _GskShaderBuilder
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
char *resource_base_path;
|
||||
char *vertex_preamble;
|
||||
char *fragment_preamble;
|
||||
|
||||
|
||||
int common_vertex_shader_id;
|
||||
|
||||
int version;
|
||||
|
||||
GPtrArray *defines;
|
||||
|
||||
/* We reuse this one for all the shaders */
|
||||
GString *shader_code;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskShaderBuilder, gsk_shader_builder, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gsk_shader_builder_finalize (GObject *gobject)
|
||||
{
|
||||
GskShaderBuilder *self = GSK_SHADER_BUILDER (gobject);
|
||||
|
||||
g_free (self->resource_base_path);
|
||||
g_free (self->vertex_preamble);
|
||||
g_free (self->fragment_preamble);
|
||||
g_string_free (self->shader_code, TRUE);
|
||||
|
||||
g_clear_pointer (&self->defines, g_ptr_array_unref);
|
||||
|
||||
if (self->common_vertex_shader_id > 0)
|
||||
glDeleteShader (self->common_vertex_shader_id);
|
||||
|
||||
G_OBJECT_CLASS (gsk_shader_builder_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_shader_builder_class_init (GskShaderBuilderClass *klass)
|
||||
{
|
||||
G_OBJECT_CLASS (klass)->finalize = gsk_shader_builder_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_shader_builder_init (GskShaderBuilder *self)
|
||||
{
|
||||
self->defines = g_ptr_array_new_with_free_func (g_free);
|
||||
self->shader_code = g_string_new (NULL);
|
||||
}
|
||||
|
||||
GskShaderBuilder *
|
||||
gsk_shader_builder_new (void)
|
||||
{
|
||||
return g_object_new (GSK_TYPE_SHADER_BUILDER, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_shader_builder_set_resource_base_path (GskShaderBuilder *builder,
|
||||
const char *base_path)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
|
||||
|
||||
g_free (builder->resource_base_path);
|
||||
builder->resource_base_path = g_strdup (base_path);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_shader_builder_set_vertex_preamble (GskShaderBuilder *builder,
|
||||
const char *vertex_preamble)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
|
||||
|
||||
g_free (builder->vertex_preamble);
|
||||
builder->vertex_preamble = g_strdup (vertex_preamble);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_shader_builder_set_fragment_preamble (GskShaderBuilder *builder,
|
||||
const char *fragment_preamble)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
|
||||
|
||||
g_free (builder->fragment_preamble);
|
||||
builder->fragment_preamble = g_strdup (fragment_preamble);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_shader_builder_set_version (GskShaderBuilder *builder,
|
||||
int version)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
|
||||
|
||||
builder->version = version;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_shader_builder_add_define (GskShaderBuilder *builder,
|
||||
const char *define_name,
|
||||
const char *define_value)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
|
||||
g_return_if_fail (define_name != NULL && *define_name != '\0');
|
||||
g_return_if_fail (define_value != NULL && *define_value != '\0');
|
||||
|
||||
g_ptr_array_add (builder->defines, g_strdup (define_name));
|
||||
g_ptr_array_add (builder->defines, g_strdup (define_value));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
lookup_shader_code (GString *code,
|
||||
const char *base_path,
|
||||
const char *shader_file,
|
||||
GError **error)
|
||||
{
|
||||
GBytes *source;
|
||||
char *path;
|
||||
|
||||
if (base_path != NULL)
|
||||
path = g_build_filename (base_path, shader_file, NULL);
|
||||
else
|
||||
path = g_strdup (shader_file);
|
||||
|
||||
source = g_resources_lookup_data (path, 0, error);
|
||||
g_free (path);
|
||||
|
||||
if (source == NULL)
|
||||
return FALSE;
|
||||
|
||||
g_string_append (code, g_bytes_get_data (source, NULL));
|
||||
|
||||
g_bytes_unref (source);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
gsk_shader_builder_compile_shader (GskShaderBuilder *builder,
|
||||
int shader_type,
|
||||
const char *shader_preamble,
|
||||
const char *shader_source,
|
||||
GError **error)
|
||||
{
|
||||
GString *code;
|
||||
const char *source;
|
||||
int shader_id;
|
||||
int status;
|
||||
int i;
|
||||
|
||||
/* Clear possibly previously set shader code */
|
||||
g_string_erase (builder->shader_code, 0, -1);
|
||||
code = builder->shader_code;
|
||||
|
||||
if (builder->version > 0)
|
||||
{
|
||||
g_string_append_printf (code, "#version %d\n", builder->version);
|
||||
g_string_append_c (code, '\n');
|
||||
}
|
||||
|
||||
for (i = 0; i < builder->defines->len; i += 2)
|
||||
{
|
||||
const char *name = g_ptr_array_index (builder->defines, i);
|
||||
const char *value = g_ptr_array_index (builder->defines, i + 1);
|
||||
|
||||
g_string_append (code, "#define");
|
||||
g_string_append_c (code, ' ');
|
||||
g_string_append (code, name);
|
||||
g_string_append_c (code, ' ');
|
||||
g_string_append (code, value);
|
||||
g_string_append_c (code, '\n');
|
||||
}
|
||||
|
||||
g_string_append_c (code, '\n');
|
||||
|
||||
if (!lookup_shader_code (code, builder->resource_base_path, shader_preamble, error))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_string_append_c (code, '\n');
|
||||
|
||||
if (!lookup_shader_code (code, builder->resource_base_path, shader_source, error))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
source = code->str;
|
||||
|
||||
shader_id = glCreateShader (shader_type);
|
||||
glShaderSource (shader_id, 1, (const GLchar **) &source, NULL);
|
||||
glCompileShader (shader_id);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_DEBUG_CHECK (SHADERS))
|
||||
{
|
||||
g_print ("*** Compiling %s shader from '%s' + '%s' ***\n"
|
||||
"%s\n",
|
||||
shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
|
||||
shader_preamble, shader_source,
|
||||
source);
|
||||
}
|
||||
#endif
|
||||
|
||||
glGetShaderiv (shader_id, GL_COMPILE_STATUS, &status);
|
||||
if (status == GL_FALSE)
|
||||
{
|
||||
int log_len;
|
||||
char *buffer;
|
||||
|
||||
glGetShaderiv (shader_id, GL_INFO_LOG_LENGTH, &log_len);
|
||||
|
||||
buffer = g_malloc0 (log_len + 1);
|
||||
glGetShaderInfoLog (shader_id, log_len, NULL, buffer);
|
||||
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_COMPILATION_FAILED,
|
||||
"Compilation failure in %s shader:\n%s",
|
||||
shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
|
||||
buffer);
|
||||
g_free (buffer);
|
||||
|
||||
glDeleteShader (shader_id);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return shader_id;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_shader_builder_set_common_vertex_shader (GskShaderBuilder *self,
|
||||
const char *vertex_shader,
|
||||
GError **error)
|
||||
{
|
||||
int shader_id;
|
||||
|
||||
|
||||
shader_id = gsk_shader_builder_compile_shader (self,
|
||||
GL_VERTEX_SHADER,
|
||||
self->vertex_preamble,
|
||||
vertex_shader,
|
||||
error);
|
||||
|
||||
g_assert (shader_id > 0);
|
||||
self->common_vertex_shader_id = shader_id;
|
||||
}
|
||||
|
||||
int
|
||||
gsk_shader_builder_create_program (GskShaderBuilder *builder,
|
||||
const char *fragment_shader,
|
||||
const char *vertex_shader,
|
||||
GError **error)
|
||||
{
|
||||
int vertex_id;
|
||||
int fragment_id;
|
||||
int program_id;
|
||||
int status;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_SHADER_BUILDER (builder), -1);
|
||||
g_return_val_if_fail (fragment_shader != NULL, -1);
|
||||
g_return_val_if_fail (builder->common_vertex_shader_id != 0, -1);
|
||||
|
||||
if (vertex_shader == NULL)
|
||||
vertex_id = builder->common_vertex_shader_id;
|
||||
else
|
||||
vertex_id = gsk_shader_builder_compile_shader (builder, GL_VERTEX_SHADER,
|
||||
builder->vertex_preamble,
|
||||
vertex_shader,
|
||||
error);
|
||||
if (vertex_id < 0)
|
||||
return -1;
|
||||
|
||||
fragment_id = gsk_shader_builder_compile_shader (builder, GL_FRAGMENT_SHADER,
|
||||
builder->fragment_preamble,
|
||||
fragment_shader,
|
||||
error);
|
||||
if (fragment_id < 0)
|
||||
{
|
||||
glDeleteShader (vertex_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
program_id = glCreateProgram ();
|
||||
glAttachShader (program_id, vertex_id);
|
||||
glAttachShader (program_id, fragment_id);
|
||||
glLinkProgram (program_id);
|
||||
|
||||
glGetProgramiv (program_id, GL_LINK_STATUS, &status);
|
||||
if (status == GL_FALSE)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
int log_len = 0;
|
||||
|
||||
glGetProgramiv (program_id, GL_INFO_LOG_LENGTH, &log_len);
|
||||
|
||||
buffer = g_malloc0 (log_len + 1);
|
||||
glGetProgramInfoLog (program_id, log_len, NULL, buffer);
|
||||
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_LINK_FAILED,
|
||||
"Linking failure in shader:\n%s", buffer);
|
||||
g_free (buffer);
|
||||
|
||||
glDeleteProgram (program_id);
|
||||
program_id = -1;
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
if (vertex_id > 0)
|
||||
{
|
||||
/* We delete the common vertex shader when destroying the shader builder */
|
||||
glDetachShader (program_id, vertex_id);
|
||||
}
|
||||
|
||||
if (fragment_id > 0)
|
||||
{
|
||||
glDetachShader (program_id, fragment_id);
|
||||
glDeleteShader (fragment_id);
|
||||
}
|
||||
|
||||
return program_id;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
#ifndef __GSK_SHADER_BUILDER_PRIVATE_H__
|
||||
#define __GSK_SHADER_BUILDER_PRIVATE_H__
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <graphene.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_SHADER_BUILDER (gsk_shader_builder_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskShaderBuilder, gsk_shader_builder, GSK, SHADER_BUILDER, GObject)
|
||||
|
||||
GskShaderBuilder * gsk_shader_builder_new (void);
|
||||
|
||||
void gsk_shader_builder_set_version (GskShaderBuilder *builder,
|
||||
int version);
|
||||
void gsk_shader_builder_set_resource_base_path (GskShaderBuilder *builder,
|
||||
const char *base_path);
|
||||
void gsk_shader_builder_set_vertex_preamble (GskShaderBuilder *builder,
|
||||
const char *shader_preamble);
|
||||
void gsk_shader_builder_set_fragment_preamble (GskShaderBuilder *builder,
|
||||
const char *shader_preamble);
|
||||
|
||||
void gsk_shader_builder_add_define (GskShaderBuilder *builder,
|
||||
const char *define_name,
|
||||
const char *define_value);
|
||||
|
||||
void gsk_shader_builder_set_common_vertex_shader (GskShaderBuilder *self,
|
||||
const char *vertex_shader,
|
||||
GError **error);
|
||||
|
||||
int gsk_shader_builder_create_program (GskShaderBuilder *builder,
|
||||
const char *fragment_shader,
|
||||
const char *vertex_shader,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_SHADER_BUILDER_PRIVATE_H__ */
|
||||
+8
-10
@@ -77,7 +77,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
const GdkRGBA *rgba;
|
||||
} OpColor;
|
||||
|
||||
typedef struct
|
||||
@@ -88,6 +88,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
GskRoundedRect clip;
|
||||
guint send_corners: 1;
|
||||
} OpClip;
|
||||
|
||||
typedef struct
|
||||
@@ -108,8 +109,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float color_offsets[8];
|
||||
float color_stops[4 * 8];
|
||||
const GskColorStop *color_stops;
|
||||
graphene_point_t start_point;
|
||||
graphene_point_t end_point;
|
||||
int n_color_stops;
|
||||
@@ -117,8 +117,8 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
graphene_matrix_t matrix;
|
||||
graphene_vec4_t offset;
|
||||
const graphene_matrix_t *matrix;
|
||||
const graphene_vec4_t *offset;
|
||||
} OpColorMatrix;
|
||||
|
||||
typedef struct
|
||||
@@ -130,18 +130,16 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float outline[4];
|
||||
float corner_widths[4];
|
||||
float corner_heights[4];
|
||||
GskRoundedRect outline;
|
||||
float spread;
|
||||
float offset[2];
|
||||
float color[4];
|
||||
const GdkRGBA *color;
|
||||
} OpShadow;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float widths[4];
|
||||
float color[4];
|
||||
const GdkRGBA *color;
|
||||
GskRoundedRect outline;
|
||||
} OpBorder;
|
||||
|
||||
|
||||
+4
-7
@@ -145,9 +145,9 @@ gsk_render_node_get_node_type (GskRenderNode *node)
|
||||
return node->node_class->node_type;
|
||||
}
|
||||
|
||||
static inline
|
||||
G_GNUC_PURE static inline
|
||||
GskRenderNodeType
|
||||
_gsk_render_node_get_node_type (GskRenderNode *node)
|
||||
_gsk_render_node_get_node_type (const GskRenderNode *node)
|
||||
{
|
||||
return node->node_class->node_type;
|
||||
}
|
||||
@@ -248,8 +248,8 @@ gsk_render_node_draw (GskRenderNode *node,
|
||||
* Returns: %TRUE if @node1 and @node2 can be expected to be compared
|
||||
**/
|
||||
gboolean
|
||||
gsk_render_node_can_diff (GskRenderNode *node1,
|
||||
GskRenderNode *node2)
|
||||
gsk_render_node_can_diff (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2)
|
||||
{
|
||||
if (node1 == node2)
|
||||
return TRUE;
|
||||
@@ -314,9 +314,6 @@ gsk_render_node_diff (GskRenderNode *node1,
|
||||
return node1->node_class->diff (node1, node2, region);
|
||||
}
|
||||
|
||||
#define GSK_RENDER_NODE_SERIALIZATION_VERSION 0
|
||||
#define GSK_RENDER_NODE_SERIALIZATION_ID "GskRenderNode"
|
||||
|
||||
/**
|
||||
* gsk_render_node_write_to_file:
|
||||
* @node: a #GskRenderNode
|
||||
|
||||
+7
-7
@@ -41,7 +41,7 @@ typedef struct _GskShadow GskShadow;
|
||||
|
||||
struct _GskColorStop
|
||||
{
|
||||
double offset;
|
||||
float offset;
|
||||
GdkRGBA color;
|
||||
};
|
||||
|
||||
@@ -210,11 +210,11 @@ GskTransform * gsk_transform_node_get_transform (GskRenderNode
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_opacity_node_new (GskRenderNode *child,
|
||||
double opacity);
|
||||
float opacity);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_opacity_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
double gsk_opacity_node_get_opacity (GskRenderNode *node);
|
||||
float gsk_opacity_node_get_opacity (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_color_matrix_node_new (GskRenderNode *child,
|
||||
@@ -280,13 +280,13 @@ GskBlendMode gsk_blend_node_get_blend_mode (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_cross_fade_node_new (GskRenderNode *start,
|
||||
GskRenderNode *end,
|
||||
double progress);
|
||||
float progress);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_cross_fade_node_get_start_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_cross_fade_node_get_end_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
double gsk_cross_fade_node_get_progress (GskRenderNode *node);
|
||||
float gsk_cross_fade_node_get_progress (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_text_node_new (PangoFont *font,
|
||||
@@ -307,11 +307,11 @@ const graphene_point_t *gsk_text_node_get_offset (GskRenderNode
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_blur_node_new (GskRenderNode *child,
|
||||
double radius);
|
||||
float radius);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_blur_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
double gsk_blur_node_get_radius (GskRenderNode *node);
|
||||
float gsk_blur_node_get_radius (GskRenderNode *node);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+18
-18
@@ -41,8 +41,8 @@ rectangle_init_from_graphene (cairo_rectangle_int_t *cairo,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_render_node_can_diff_true (GskRenderNode *node1,
|
||||
GskRenderNode *node2)
|
||||
gsk_render_node_can_diff_true (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1707,8 +1707,8 @@ gsk_container_node_draw (GskRenderNode *node,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_container_node_can_diff (GskRenderNode *node1,
|
||||
GskRenderNode *node2)
|
||||
gsk_container_node_can_diff (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1726,7 +1726,7 @@ gsk_render_node_add_to_region (GskRenderNode *node,
|
||||
static int
|
||||
gsk_container_node_compare_func (gconstpointer elem1, gconstpointer elem2, gpointer data)
|
||||
{
|
||||
return gsk_render_node_can_diff ((GskRenderNode *) elem1, (GskRenderNode *) elem2) ? 0 : 1;
|
||||
return gsk_render_node_can_diff ((const GskRenderNode *) elem1, (const GskRenderNode *) elem2) ? 0 : 1;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1918,8 +1918,8 @@ gsk_transform_node_draw (GskRenderNode *node,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_transform_node_can_diff (GskRenderNode *node1,
|
||||
GskRenderNode *node2)
|
||||
gsk_transform_node_can_diff (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2)
|
||||
{
|
||||
GskTransformNode *self1 = (GskTransformNode *) node1;
|
||||
GskTransformNode *self2 = (GskTransformNode *) node2;
|
||||
@@ -2092,8 +2092,8 @@ gsk_debug_node_draw (GskRenderNode *node,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_debug_node_can_diff (GskRenderNode *node1,
|
||||
GskRenderNode *node2)
|
||||
gsk_debug_node_can_diff (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2)
|
||||
{
|
||||
GskDebugNode *self1 = (GskDebugNode *) node1;
|
||||
GskDebugNode *self2 = (GskDebugNode *) node2;
|
||||
@@ -2197,7 +2197,7 @@ struct _GskOpacityNode
|
||||
GskRenderNode render_node;
|
||||
|
||||
GskRenderNode *child;
|
||||
double opacity;
|
||||
float opacity;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -2267,7 +2267,7 @@ static const GskRenderNodeClass GSK_OPACITY_NODE_CLASS = {
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_opacity_node_new (GskRenderNode *child,
|
||||
double opacity)
|
||||
float opacity)
|
||||
{
|
||||
GskOpacityNode *self;
|
||||
|
||||
@@ -2301,7 +2301,7 @@ gsk_opacity_node_get_child (GskRenderNode *node)
|
||||
return self->child;
|
||||
}
|
||||
|
||||
double
|
||||
float
|
||||
gsk_opacity_node_get_opacity (GskRenderNode *node)
|
||||
{
|
||||
GskOpacityNode *self = (GskOpacityNode *) node;
|
||||
@@ -3278,7 +3278,7 @@ struct _GskCrossFadeNode
|
||||
|
||||
GskRenderNode *start;
|
||||
GskRenderNode *end;
|
||||
double progress;
|
||||
float progress;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -3352,7 +3352,7 @@ static const GskRenderNodeClass GSK_CROSS_FADE_NODE_CLASS = {
|
||||
GskRenderNode *
|
||||
gsk_cross_fade_node_new (GskRenderNode *start,
|
||||
GskRenderNode *end,
|
||||
double progress)
|
||||
float progress)
|
||||
{
|
||||
GskCrossFadeNode *self;
|
||||
|
||||
@@ -3390,7 +3390,7 @@ gsk_cross_fade_node_get_end_child (GskRenderNode *node)
|
||||
return self->end;
|
||||
}
|
||||
|
||||
double
|
||||
float
|
||||
gsk_cross_fade_node_get_progress (GskRenderNode *node)
|
||||
{
|
||||
GskCrossFadeNode *self = (GskCrossFadeNode *) node;
|
||||
@@ -3634,7 +3634,7 @@ struct _GskBlurNode
|
||||
GskRenderNode render_node;
|
||||
|
||||
GskRenderNode *child;
|
||||
double radius;
|
||||
float radius;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -3882,7 +3882,7 @@ static const GskRenderNodeClass GSK_BLUR_NODE_CLASS = {
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_blur_node_new (GskRenderNode *child,
|
||||
double radius)
|
||||
float radius)
|
||||
{
|
||||
GskBlurNode *self;
|
||||
float clip_radius = gsk_cairo_blur_compute_pixels (radius);
|
||||
@@ -3911,7 +3911,7 @@ gsk_blur_node_get_child (GskRenderNode *node)
|
||||
return self->child;
|
||||
}
|
||||
|
||||
double
|
||||
float
|
||||
gsk_blur_node_get_radius (GskRenderNode *node)
|
||||
{
|
||||
GskBlurNode *self = (GskBlurNode *) node;
|
||||
|
||||
@@ -433,9 +433,13 @@ parse_stops (GtkCssParser *parser,
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (!gtk_css_parser_consume_number (parser, &stop.offset))
|
||||
double dval;
|
||||
|
||||
if (!gtk_css_parser_consume_number (parser, &dval))
|
||||
goto error;
|
||||
|
||||
stop.offset = dval;
|
||||
|
||||
if (!gdk_rgba_parser_parse (parser, &stop.color))
|
||||
goto error;
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ struct _GskRenderNodeClass
|
||||
void (* finalize) (GskRenderNode *node);
|
||||
void (* draw) (GskRenderNode *node,
|
||||
cairo_t *cr);
|
||||
gboolean (* can_diff) (GskRenderNode *node1,
|
||||
GskRenderNode *node2);
|
||||
gboolean (* can_diff) (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2);
|
||||
void (* diff) (GskRenderNode *node1,
|
||||
GskRenderNode *node2,
|
||||
cairo_region_t *region);
|
||||
@@ -38,8 +38,8 @@ struct _GskRenderNodeClass
|
||||
GskRenderNode * gsk_render_node_new (const GskRenderNodeClass *node_class,
|
||||
gsize extra_size);
|
||||
|
||||
gboolean gsk_render_node_can_diff (GskRenderNode *node1,
|
||||
GskRenderNode *node2);
|
||||
gboolean gsk_render_node_can_diff (const GskRenderNode *node1,
|
||||
const GskRenderNode *node2) G_GNUC_PURE;
|
||||
void gsk_render_node_diff (GskRenderNode *node1,
|
||||
GskRenderNode *node2,
|
||||
cairo_region_t *region);
|
||||
|
||||
@@ -98,16 +98,16 @@ GskRoundedRect * gsk_rounded_rect_shrink (GskRoundedRect
|
||||
float left);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self);
|
||||
gboolean gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gsk_rounded_rect_contains_point (const GskRoundedRect *self,
|
||||
const graphene_point_t *point);
|
||||
const graphene_point_t *point) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gsk_rounded_rect_contains_rect (const GskRoundedRect *self,
|
||||
const graphene_rect_t *rect);
|
||||
const graphene_rect_t *rect) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gsk_rounded_rect_intersects_rect (const GskRoundedRect *self,
|
||||
const graphene_rect_t *rect);
|
||||
const graphene_rect_t *rect) G_GNUC_PURE;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ void gsk_rounded_rect_to_float (const GskRounde
|
||||
float rect[12]);
|
||||
|
||||
gboolean gsk_rounded_rect_equal (gconstpointer rect1,
|
||||
gconstpointer rect2);
|
||||
gconstpointer rect2) G_GNUC_PURE;
|
||||
char * gsk_rounded_rect_to_string (const GskRoundedRect *self);
|
||||
|
||||
|
||||
|
||||
+131
-23
@@ -685,16 +685,54 @@ gsk_rotate_transform_finalize (GskTransform *self)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void
|
||||
_sincos (float deg,
|
||||
float *out_s,
|
||||
float *out_c)
|
||||
{
|
||||
if (deg == 90.0)
|
||||
{
|
||||
*out_c = 0.0;
|
||||
*out_s = 1.0;
|
||||
}
|
||||
else if (deg == 180.0)
|
||||
{
|
||||
*out_c = -1.0;
|
||||
*out_s = 0.0;
|
||||
}
|
||||
else if (deg == 270.0)
|
||||
{
|
||||
*out_c = 0.0;
|
||||
*out_s = -1.0;
|
||||
}
|
||||
else if (deg == 0.0)
|
||||
{
|
||||
*out_c = 1.0;
|
||||
*out_s = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float angle = deg * M_PI / 180.0;
|
||||
|
||||
#ifdef HAVE_SINCOSF
|
||||
sincosf (angle, out_s, out_c);
|
||||
#else
|
||||
*out_s = sinf (angle);
|
||||
*out_c = cosf (angle);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_rotate_transform_to_matrix (GskTransform *transform,
|
||||
graphene_matrix_t *out_matrix)
|
||||
{
|
||||
GskRotateTransform *self = (GskRotateTransform *) transform;
|
||||
float rad, c, s;
|
||||
float c, s;
|
||||
|
||||
_sincos (self->angle, &s, &c);
|
||||
|
||||
rad = self->angle * M_PI / 180.f;
|
||||
c = cosf (rad);
|
||||
s = sinf (rad);
|
||||
graphene_matrix_init_from_2d (out_matrix,
|
||||
c, s,
|
||||
-s, c,
|
||||
@@ -711,14 +749,12 @@ gsk_rotate_transform_apply_2d (GskTransform *transform,
|
||||
float *out_dy)
|
||||
{
|
||||
GskRotateTransform *self = (GskRotateTransform *) transform;
|
||||
float s, c, rad, xx, xy, yx, yy;
|
||||
float s, c, xx, xy, yx, yy;
|
||||
|
||||
if (fmodf (self->angle, 360.0f) == 0.0)
|
||||
return;
|
||||
|
||||
rad = self->angle * G_PI / 180.0f;
|
||||
s = sinf (rad);
|
||||
c = cosf (rad);
|
||||
_sincos (self->angle, &s, &c);
|
||||
|
||||
xx = c * *out_xx + s * *out_xy;
|
||||
yx = c * *out_yx + s * *out_yy;
|
||||
@@ -785,6 +821,22 @@ static const GskTransformClass GSK_ROTATE_TRANSFORM_CLASS =
|
||||
gsk_rotate_transform_equal,
|
||||
};
|
||||
|
||||
static inline float
|
||||
normalize_angle (float angle)
|
||||
{
|
||||
float f;
|
||||
|
||||
if (angle >= 0 && angle < 360)
|
||||
return angle;
|
||||
|
||||
f = angle - (360 * ((int)(angle / 360.0)));
|
||||
|
||||
if (f < 0)
|
||||
f = 360 + f;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_transform_rotate:
|
||||
* @next: (allow-none) (transfer full): the next transform
|
||||
@@ -815,7 +867,7 @@ gsk_transform_rotate (GskTransform *next,
|
||||
GSK_TRANSFORM_CATEGORY_2D,
|
||||
next);
|
||||
|
||||
result->angle = angle;
|
||||
result->angle = normalize_angle (angle);
|
||||
|
||||
return &result->parent;
|
||||
}
|
||||
@@ -938,7 +990,7 @@ gsk_transform_rotate_3d (GskTransform *next,
|
||||
GSK_TRANSFORM_CATEGORY_3D,
|
||||
next);
|
||||
|
||||
result->angle = angle;
|
||||
result->angle = normalize_angle (angle);
|
||||
graphene_vec3_init_from_vec3 (&result->axis, axis);
|
||||
|
||||
return &result->parent;
|
||||
@@ -1033,9 +1085,9 @@ gsk_scale_transform_equal (GskTransform *first_transform,
|
||||
GskScaleTransform *first = (GskScaleTransform *) first_transform;
|
||||
GskScaleTransform *second = (GskScaleTransform *) second_transform;
|
||||
|
||||
return G_APPROX_VALUE (first->factor_x, second->factor_x, 0.01f) &&
|
||||
G_APPROX_VALUE (first->factor_y, second->factor_y, 0.01f) &&
|
||||
G_APPROX_VALUE (first->factor_z, second->factor_z, 0.01f);
|
||||
return G_APPROX_VALUE (first->factor_x, second->factor_x, FLT_EPSILON) &&
|
||||
G_APPROX_VALUE (first->factor_y, second->factor_y, FLT_EPSILON) &&
|
||||
G_APPROX_VALUE (first->factor_z, second->factor_z, FLT_EPSILON);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1620,10 +1672,10 @@ gsk_transform_equal (GskTransform *first,
|
||||
if (first == NULL || second == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!gsk_transform_equal (first->next, second->next))
|
||||
if (first->transform_class != second->transform_class)
|
||||
return FALSE;
|
||||
|
||||
if (first->transform_class != second->transform_class)
|
||||
if (!gsk_transform_equal (first->next, second->next))
|
||||
return FALSE;
|
||||
|
||||
return first->transform_class->equal (first, second);
|
||||
@@ -1686,7 +1738,10 @@ gsk_transform_transform_bounds (GskTransform *self,
|
||||
float dx, dy;
|
||||
|
||||
gsk_transform_to_translate (self, &dx, &dy);
|
||||
graphene_rect_offset_r (rect, dx, dy, out_rect);
|
||||
out_rect->origin.x = rect->origin.x + dx;
|
||||
out_rect->origin.y = rect->origin.y + dy;
|
||||
out_rect->size.width = rect->size.width;
|
||||
out_rect->size.height = rect->size.height;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1696,13 +1751,10 @@ gsk_transform_transform_bounds (GskTransform *self,
|
||||
|
||||
gsk_transform_to_affine (self, &scale_x, &scale_y, &dx, &dy);
|
||||
|
||||
*out_rect = *rect;
|
||||
out_rect->origin.x *= scale_x;
|
||||
out_rect->origin.y *= scale_y;
|
||||
out_rect->size.width *= scale_x;
|
||||
out_rect->size.height *= scale_y;
|
||||
out_rect->origin.x += dx;
|
||||
out_rect->origin.y += dy;
|
||||
out_rect->origin.x = (rect->origin.x * scale_x) + dx;
|
||||
out_rect->origin.y = (rect->origin.y * scale_y) + dy;
|
||||
out_rect->size.width = rect->size.width * scale_x;
|
||||
out_rect->size.height = rect->size.height * scale_y;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1721,6 +1773,62 @@ gsk_transform_transform_bounds (GskTransform *self,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_transform_transform_point:
|
||||
* @self: a #GskTransform
|
||||
* @point: a #graphene_point_t
|
||||
* @out_point: (out caller-allocates): return location for
|
||||
* the transformed point
|
||||
*
|
||||
* Transforms a #graphene_point_t using the given transform @self.
|
||||
*/
|
||||
void
|
||||
gsk_transform_transform_point (GskTransform *self,
|
||||
const graphene_point_t *point,
|
||||
graphene_point_t *out_point)
|
||||
{
|
||||
switch (gsk_transform_get_category (self))
|
||||
{
|
||||
case GSK_TRANSFORM_CATEGORY_IDENTITY:
|
||||
*out_point = *point;
|
||||
break;
|
||||
|
||||
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
|
||||
{
|
||||
float dx, dy;
|
||||
|
||||
gsk_transform_to_translate (self, &dx, &dy);
|
||||
out_point->x = point->x + dx;
|
||||
out_point->y = point->y + dy;
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
|
||||
{
|
||||
float dx, dy, scale_x, scale_y;
|
||||
|
||||
gsk_transform_to_affine (self, &scale_x, &scale_y, &dx, &dy);
|
||||
|
||||
out_point->x = (point->x * scale_x) + dx;
|
||||
out_point->y = (point->y * scale_y) + dy;
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
|
||||
case GSK_TRANSFORM_CATEGORY_ANY:
|
||||
case GSK_TRANSFORM_CATEGORY_3D:
|
||||
case GSK_TRANSFORM_CATEGORY_2D:
|
||||
default:
|
||||
{
|
||||
graphene_matrix_t mat;
|
||||
|
||||
gsk_transform_to_matrix (self, &mat);
|
||||
graphene_matrix_transform_point (&mat, point, out_point);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static guint
|
||||
gsk_transform_parse_float (GtkCssParser *parser,
|
||||
guint n,
|
||||
|
||||
@@ -116,6 +116,11 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gsk_transform_transform_bounds (GskTransform *self,
|
||||
const graphene_rect_t *rect,
|
||||
graphene_rect_t *out_rect);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gsk_transform_transform_point (GskTransform *self,
|
||||
const graphene_point_t *point,
|
||||
graphene_point_t *out_point);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+17
-21
@@ -1,24 +1,20 @@
|
||||
gsk_private_gl_shaders = [
|
||||
'resources/glsl/blit.fs.glsl',
|
||||
'resources/glsl/blit.vs.glsl',
|
||||
'resources/glsl/color.fs.glsl',
|
||||
'resources/glsl/coloring.fs.glsl',
|
||||
'resources/glsl/color_matrix.fs.glsl',
|
||||
'resources/glsl/linear_gradient.fs.glsl',
|
||||
'resources/glsl/blur.fs.glsl',
|
||||
'resources/glsl/inset_shadow.fs.glsl',
|
||||
'resources/glsl/outset_shadow.fs.glsl',
|
||||
'resources/glsl/unblurred_outset_shadow.fs.glsl',
|
||||
'resources/glsl/border.fs.glsl',
|
||||
'resources/glsl/cross_fade.fs.glsl',
|
||||
'resources/glsl/blend.fs.glsl',
|
||||
'resources/glsl/repeat.fs.glsl',
|
||||
'resources/glsl/es2_common.fs.glsl',
|
||||
'resources/glsl/es2_common.vs.glsl',
|
||||
'resources/glsl/gl3_common.fs.glsl',
|
||||
'resources/glsl/gl3_common.vs.glsl',
|
||||
'resources/glsl/gl_common.fs.glsl',
|
||||
'resources/glsl/gl_common.vs.glsl',
|
||||
'resources/glsl/preamble.glsl',
|
||||
'resources/glsl/preamble.fs.glsl',
|
||||
'resources/glsl/preamble.vs.glsl',
|
||||
'resources/glsl/border.glsl',
|
||||
'resources/glsl/blit.glsl',
|
||||
'resources/glsl/coloring.glsl',
|
||||
'resources/glsl/color.glsl',
|
||||
'resources/glsl/linear_gradient.glsl',
|
||||
'resources/glsl/color_matrix.glsl',
|
||||
'resources/glsl/blur.glsl',
|
||||
'resources/glsl/inset_shadow.glsl',
|
||||
'resources/glsl/outset_shadow.glsl',
|
||||
'resources/glsl/unblurred_outset_shadow.glsl',
|
||||
'resources/glsl/cross_fade.glsl',
|
||||
'resources/glsl/blend.glsl',
|
||||
'resources/glsl/repeat.glsl',
|
||||
]
|
||||
|
||||
gsk_public_sources = files([
|
||||
@@ -38,7 +34,7 @@ gsk_private_sources = files([
|
||||
'gskdebug.c',
|
||||
'gskprivate.c',
|
||||
'gskprofiler.c',
|
||||
'gl/gskshaderbuilder.c',
|
||||
'gl/gskglshaderbuilder.c',
|
||||
'gl/gskglprofiler.c',
|
||||
'gl/gskglglyphcache.c',
|
||||
'gl/gskglimage.c',
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
// VERTEX_SHADER:
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform int u_mode;
|
||||
uniform sampler2D u_source2;
|
||||
|
||||
@@ -264,73 +272,39 @@ void main() {
|
||||
|
||||
vec4 result;
|
||||
if (u_mode == 0)
|
||||
{
|
||||
result = normal(top_color, bottom_color);
|
||||
}
|
||||
result = normal(top_color, bottom_color);
|
||||
else if (u_mode == 1)
|
||||
{
|
||||
result = multiply(top_color, bottom_color);
|
||||
}
|
||||
result = multiply(top_color, bottom_color);
|
||||
else if (u_mode == 2)
|
||||
{
|
||||
result = screen(top_color, bottom_color);
|
||||
}
|
||||
result = screen(top_color, bottom_color);
|
||||
else if (u_mode == 3)
|
||||
{
|
||||
result = overlay(top_color, bottom_color);
|
||||
}
|
||||
result = overlay(top_color, bottom_color);
|
||||
else if (u_mode == 4)
|
||||
{
|
||||
result = darken(top_color, bottom_color);
|
||||
}
|
||||
result = darken(top_color, bottom_color);
|
||||
else if (u_mode == 5)
|
||||
{
|
||||
result = lighten(top_color, bottom_color);
|
||||
}
|
||||
result = lighten(top_color, bottom_color);
|
||||
else if (u_mode == 6)
|
||||
{
|
||||
result = color_dodge(top_color, bottom_color);
|
||||
}
|
||||
result = color_dodge(top_color, bottom_color);
|
||||
else if (u_mode == 7)
|
||||
{
|
||||
result = color_burn(top_color, bottom_color);
|
||||
}
|
||||
result = color_burn(top_color, bottom_color);
|
||||
else if (u_mode == 8)
|
||||
{
|
||||
result = hard_light(top_color, bottom_color);
|
||||
}
|
||||
result = hard_light(top_color, bottom_color);
|
||||
else if (u_mode == 9)
|
||||
{
|
||||
result = soft_light(top_color, bottom_color);
|
||||
}
|
||||
result = soft_light(top_color, bottom_color);
|
||||
else if (u_mode == 10)
|
||||
{
|
||||
result = difference(top_color, bottom_color);
|
||||
}
|
||||
result = difference(top_color, bottom_color);
|
||||
else if (u_mode == 11)
|
||||
{
|
||||
result = exclusion(top_color, bottom_color);
|
||||
}
|
||||
result = exclusion(top_color, bottom_color);
|
||||
else if (u_mode == 12)
|
||||
{
|
||||
result = color(top_color, bottom_color);
|
||||
}
|
||||
result = color(top_color, bottom_color);
|
||||
else if (u_mode == 13)
|
||||
{
|
||||
result = hue(top_color, bottom_color);
|
||||
}
|
||||
result = hue(top_color, bottom_color);
|
||||
else if (u_mode == 14)
|
||||
{
|
||||
result = saturation(top_color, bottom_color);
|
||||
}
|
||||
result = saturation(top_color, bottom_color);
|
||||
else if (u_mode == 15)
|
||||
{
|
||||
result = luminosity(top_color, bottom_color);
|
||||
}
|
||||
result = luminosity(top_color, bottom_color);
|
||||
else
|
||||
{
|
||||
discard;
|
||||
}
|
||||
discard;
|
||||
|
||||
setOutputColor(result * u_alpha);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
void main() {
|
||||
vec4 diffuse = Texture(u_source, vUv);
|
||||
|
||||
setOutputColor(diffuse * u_alpha);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// VERTEX_SHADER:
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
void main() {
|
||||
vec4 diffuse = Texture(u_source, vUv);
|
||||
|
||||
setOutputColor(diffuse * u_alpha);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
uniform float u_blur_radius;
|
||||
uniform vec2 u_blur_size;
|
||||
uniform vec2 u_blur_dir;
|
||||
|
||||
const float PI = 3.14159265;
|
||||
const float RADIUS_MULTIPLIER = 3.0;
|
||||
|
||||
// blur_radius 0 is NOT supported and MUST be caught before.
|
||||
|
||||
// Partially from http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html
|
||||
void main() {
|
||||
float sigma = u_blur_radius; // *shrug*
|
||||
float blur_radius = u_blur_radius * RADIUS_MULTIPLIER;
|
||||
vec3 incrementalGaussian;
|
||||
incrementalGaussian.x = 1.0 / (sqrt(2.0 * PI) * sigma);
|
||||
incrementalGaussian.y = exp(-0.5 / (sigma * sigma));
|
||||
incrementalGaussian.z = incrementalGaussian.y * incrementalGaussian.y;
|
||||
|
||||
vec2 pixel_step = vec2(1.0) / u_blur_size;
|
||||
|
||||
float coefficientSum = 0;
|
||||
vec4 sum = Texture(u_source, vUv) * incrementalGaussian.x;
|
||||
coefficientSum += incrementalGaussian.x;
|
||||
incrementalGaussian.xy *= incrementalGaussian.yz;
|
||||
|
||||
int pixels_per_side = int(floor(blur_radius / 2.0));
|
||||
for (int i = 1; i <= pixels_per_side; i++) {
|
||||
vec2 p = i * pixel_step * u_blur_dir;
|
||||
|
||||
sum += Texture(u_source, vUv - p) * incrementalGaussian.x;
|
||||
sum += Texture(u_source, vUv + p) * incrementalGaussian.x;
|
||||
|
||||
coefficientSum += 2.0 * incrementalGaussian.x;
|
||||
incrementalGaussian.xy *= incrementalGaussian.yz;
|
||||
}
|
||||
|
||||
setOutputColor(sum / coefficientSum);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// VERTEX_SHADER:
|
||||
uniform float u_blur_radius;
|
||||
uniform vec2 u_blur_size;
|
||||
uniform vec2 u_blur_dir;
|
||||
|
||||
_OUT_ vec2 pixel_step;
|
||||
_OUT_ float pixels_per_side;
|
||||
_OUT_ vec3 initial_gaussian;
|
||||
|
||||
const float PI = 3.14159265;
|
||||
const float RADIUS_MULTIPLIER = 3.0;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
|
||||
pixel_step = (vec2(1.0) / u_blur_size) * u_blur_dir;
|
||||
pixels_per_side = floor(u_blur_radius * RADIUS_MULTIPLIER / 2.0);
|
||||
|
||||
float sigma = u_blur_radius; // *shrug*
|
||||
initial_gaussian.x = 1.0 / (sqrt(2.0 * PI) * sigma);
|
||||
initial_gaussian.y = exp(-0.5 / (sigma * sigma));
|
||||
initial_gaussian.z = initial_gaussian.y * initial_gaussian.y;
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform float u_blur_radius;
|
||||
uniform vec2 u_blur_size;
|
||||
|
||||
_IN_ vec2 pixel_step;
|
||||
_IN_ float pixels_per_side;
|
||||
_IN_ vec3 initial_gaussian;
|
||||
|
||||
// blur_radius 0 is NOT supported and MUST be caught before.
|
||||
|
||||
// Partially from http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html
|
||||
void main() {
|
||||
vec3 incrementalGaussian = initial_gaussian;
|
||||
|
||||
float coefficientSum = 0.0;
|
||||
vec4 sum = Texture(u_source, vUv) * incrementalGaussian.x;
|
||||
coefficientSum += incrementalGaussian.x;
|
||||
incrementalGaussian.xy *= incrementalGaussian.yz;
|
||||
|
||||
vec2 p = pixel_step;
|
||||
for (int i = 1; i <= int(pixels_per_side); i++) {
|
||||
sum += Texture(u_source, vUv - p) * incrementalGaussian.x;
|
||||
sum += Texture(u_source, vUv + p) * incrementalGaussian.x;
|
||||
|
||||
coefficientSum += 2.0 * incrementalGaussian.x;
|
||||
incrementalGaussian.xy *= incrementalGaussian.yz;
|
||||
|
||||
p += pixel_step;
|
||||
}
|
||||
|
||||
setOutputColor(sum / coefficientSum);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
uniform vec4 u_color;
|
||||
uniform vec4 u_widths;
|
||||
|
||||
uniform vec4 u_outline;
|
||||
uniform vec4 u_corner_widths;
|
||||
uniform vec4 u_corner_heights;
|
||||
|
||||
void main() {
|
||||
vec4 bounds = u_outline;
|
||||
|
||||
bounds.z = bounds.x + bounds.z;
|
||||
bounds.w = bounds.y + bounds.w;
|
||||
|
||||
vec4 f = gl_FragCoord;
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
RoundedRect routside = RoundedRect (bounds, u_corner_widths, u_corner_heights);
|
||||
RoundedRect rinside = rounded_rect_shrink (routside, u_widths);
|
||||
|
||||
float alpha = clamp (rounded_rect_coverage (routside, f.xy) -
|
||||
rounded_rect_coverage (rinside, f.xy),
|
||||
0.0, 1.0);
|
||||
|
||||
/* Pre-multiply */
|
||||
vec4 color = u_color;
|
||||
color.rgb *= color.a;
|
||||
|
||||
setOutputColor (color * alpha * u_alpha);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// VERTEX_SHADER:
|
||||
uniform vec4 u_color;
|
||||
uniform vec4 u_widths;
|
||||
uniform vec4[3] u_outline_rect;
|
||||
|
||||
_OUT_ vec4 final_color;
|
||||
_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
|
||||
_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
final_color = u_color;
|
||||
final_color.rgb *= final_color.a; // pre-multiply
|
||||
final_color *= u_alpha;
|
||||
|
||||
RoundedRect outside = create_rect(u_outline_rect);
|
||||
RoundedRect inside = rounded_rect_shrink (outside, u_widths);
|
||||
|
||||
rounded_rect_transform(outside, u_modelview);
|
||||
rounded_rect_transform(inside, u_modelview);
|
||||
|
||||
rounded_rect_encode(outside, transformed_outside_outline);
|
||||
rounded_rect_encode(inside, transformed_inside_outline);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform vec4[3] u_outline_rect;
|
||||
|
||||
_IN_ vec4 final_color;
|
||||
_IN_ _ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
|
||||
_IN_ _ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
|
||||
|
||||
void main() {
|
||||
vec4 f = gl_FragCoord;
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
float alpha = clamp(rounded_rect_coverage(decode_rect(transformed_outside_outline), f.xy) -
|
||||
rounded_rect_coverage(decode_rect(transformed_inside_outline), f.xy),
|
||||
0.0, 1.0);
|
||||
|
||||
setOutputColor(final_color * alpha);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
uniform vec4 u_color;
|
||||
|
||||
void main() {
|
||||
vec4 color = u_color;
|
||||
|
||||
// Pre-multiply alpha
|
||||
color.rgb *= color.a;
|
||||
setOutputColor(color * u_alpha);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// VERTEX_SHADER:
|
||||
uniform vec4 u_color;
|
||||
|
||||
_OUT_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
final_color = u_color;
|
||||
// Pre-multiply alpha
|
||||
final_color.rgb *= final_color.a;
|
||||
final_color *= u_alpha;
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
_IN_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
setOutputColor(final_color);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
// VERTEX_SHADER:
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform mat4 u_color_matrix;
|
||||
uniform vec4 u_color_offset;
|
||||
|
||||
void main() {
|
||||
vec4 diffuse = Texture(u_source, vUv);
|
||||
vec4 color;
|
||||
|
||||
color = diffuse;
|
||||
vec4 color = Texture(u_source, vUv);
|
||||
|
||||
// Un-premultilpy
|
||||
if (color.a != 0.0)
|
||||
color.rgb /= color.a;
|
||||
|
||||
color = u_color_matrix * color + u_color_offset;
|
||||
color = clamp(color, 0.0f, 1.0f);
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
|
||||
color.rgb *= color.a;
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
uniform vec4 u_color;
|
||||
|
||||
void main() {
|
||||
vec4 diffuse = Texture(u_source, vUv);
|
||||
vec4 color = u_color;
|
||||
|
||||
// pre-multiply
|
||||
color.rgb *= color.a;
|
||||
|
||||
// u_source is drawn using cairo, so already pre-multiplied.
|
||||
color = vec4(color.rgb * diffuse.a * u_alpha,
|
||||
color.a * diffuse.a * u_alpha);
|
||||
|
||||
setOutputColor(color);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// VERTEX_SHADER:
|
||||
uniform vec4 u_color;
|
||||
|
||||
_OUT_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
|
||||
final_color = u_color;
|
||||
// pre-multiply
|
||||
final_color.rgb *= final_color.a;
|
||||
final_color *= u_alpha;
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
|
||||
_IN_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
vec4 diffuse = Texture(u_source, vUv);
|
||||
|
||||
setOutputColor(final_color * diffuse.a);
|
||||
}
|
||||
@@ -1,4 +1,11 @@
|
||||
// VERTEX_SHADER:
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform float u_progress;
|
||||
uniform sampler2D u_source2;
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
precision mediump float;
|
||||
|
||||
uniform sampler2D u_source;
|
||||
uniform sampler2D u_mask;
|
||||
uniform mat4 u_projection;
|
||||
uniform mat4 u_modelview;
|
||||
uniform float u_alpha;
|
||||
uniform int uBlendMode;
|
||||
uniform vec4 u_viewport;
|
||||
|
||||
// In GtkSnapshot coordinates
|
||||
uniform vec4 u_clip;
|
||||
uniform vec4 u_clip_corner_widths;
|
||||
uniform vec4 u_clip_corner_heights;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
|
||||
struct RoundedRect
|
||||
{
|
||||
vec4 bounds;
|
||||
vec4 corner_widths;
|
||||
vec4 corner_heights;
|
||||
};
|
||||
|
||||
float
|
||||
ellipsis_dist (vec2 p, vec2 radius)
|
||||
{
|
||||
if (radius == vec2(0, 0))
|
||||
return 0.0;
|
||||
|
||||
vec2 p0 = p / radius;
|
||||
vec2 p1 = 2.0 * p0 / radius;
|
||||
|
||||
return (dot(p0, p0) - 1.0) / length (p1);
|
||||
}
|
||||
|
||||
float
|
||||
ellipsis_coverage (vec2 point, vec2 center, vec2 radius)
|
||||
{
|
||||
float d = ellipsis_dist (point - center, radius);
|
||||
return clamp (0.5 - d, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float
|
||||
rounded_rect_coverage (RoundedRect r, vec2 p)
|
||||
{
|
||||
if (p.x < r.bounds.x || p.y < r.bounds.y ||
|
||||
p.x >= r.bounds.z || p.y >= r.bounds.w)
|
||||
return 0.0;
|
||||
|
||||
vec2 rad_tl = vec2(r.corner_widths.x, r.corner_heights.x);
|
||||
vec2 rad_tr = vec2(r.corner_widths.y, r.corner_heights.y);
|
||||
vec2 rad_br = vec2(r.corner_widths.z, r.corner_heights.z);
|
||||
vec2 rad_bl = vec2(r.corner_widths.w, r.corner_heights.w);
|
||||
|
||||
vec2 ref_tl = r.bounds.xy + vec2( r.corner_widths.x, r.corner_heights.x);
|
||||
vec2 ref_tr = r.bounds.zy + vec2(-r.corner_widths.y, r.corner_heights.y);
|
||||
vec2 ref_br = r.bounds.zw + vec2(-r.corner_widths.z, -r.corner_heights.z);
|
||||
vec2 ref_bl = r.bounds.xw + vec2( r.corner_widths.w, -r.corner_heights.w);
|
||||
|
||||
float d_tl = ellipsis_coverage(p, ref_tl, rad_tl);
|
||||
float d_tr = ellipsis_coverage(p, ref_tr, rad_tr);
|
||||
float d_br = ellipsis_coverage(p, ref_br, rad_br);
|
||||
float d_bl = ellipsis_coverage(p, ref_bl, rad_bl);
|
||||
|
||||
vec4 corner_coverages = 1.0 - vec4(d_tl, d_tr, d_br, d_bl);
|
||||
|
||||
bvec4 is_out = bvec4(p.x < ref_tl.x && p.y < ref_tl.y,
|
||||
p.x > ref_tr.x && p.y < ref_tr.y,
|
||||
p.x > ref_br.x && p.y > ref_br.y,
|
||||
p.x < ref_bl.x && p.y > ref_bl.y);
|
||||
|
||||
return 1.0 - dot(vec4(is_out), corner_coverages);
|
||||
}
|
||||
|
||||
RoundedRect
|
||||
rounded_rect_shrink (RoundedRect r, vec4 amount)
|
||||
{
|
||||
vec4 new_bounds = r.bounds + vec4(1.0,1.0,-1.0,-1.0) * amount.wxyz;
|
||||
vec4 new_widths = max (r.corner_widths - amount.wyyw, 0.0);
|
||||
vec4 new_heights = max (r.corner_heights - amount.xxzz, 0.0);
|
||||
|
||||
return RoundedRect (new_bounds, new_widths, new_heights);
|
||||
}
|
||||
|
||||
vec4 Texture(sampler2D sampler, vec2 texCoords) {
|
||||
return texture2D(sampler, texCoords);
|
||||
}
|
||||
|
||||
void setOutputColor(vec4 color) {
|
||||
vec4 clipBounds = u_clip;
|
||||
vec4 f = gl_FragCoord;
|
||||
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
clipBounds.z = clipBounds.x + clipBounds.z;
|
||||
clipBounds.w = clipBounds.y + clipBounds.w;
|
||||
|
||||
RoundedRect r = RoundedRect(clipBounds, u_clip_corner_widths, u_clip_corner_heights);
|
||||
|
||||
gl_FragColor = color * rounded_rect_coverage(r, f.xy);
|
||||
/*gl_FragColor = color;*/
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
precision mediump float;
|
||||
|
||||
uniform mat4 u_projection;
|
||||
uniform mat4 u_modelview;
|
||||
|
||||
attribute vec2 aPosition;
|
||||
attribute vec2 aUv;
|
||||
|
||||
varying vec2 vUv;
|
||||
@@ -1,123 +0,0 @@
|
||||
precision highp float;
|
||||
|
||||
uniform sampler2D u_source;
|
||||
uniform sampler2D u_mask;
|
||||
uniform mat4 u_projection = mat4(1.0);
|
||||
uniform mat4 u_modelview = mat4(1.0);
|
||||
uniform float u_alpha = 1.0;
|
||||
uniform int uBlendMode;
|
||||
uniform vec4 u_viewport;
|
||||
|
||||
// In GtkSnapshot coordinates
|
||||
uniform vec4 u_clip;
|
||||
uniform vec4 u_clip_corner_widths = vec4(0, 0, 0, 0);
|
||||
uniform vec4 u_clip_corner_heights = vec4(0, 0, 0, 0);
|
||||
|
||||
in vec2 vUv;
|
||||
|
||||
out vec4 outputColor;
|
||||
|
||||
|
||||
struct RoundedRect
|
||||
{
|
||||
vec4 bounds;
|
||||
vec4 corner_widths;
|
||||
vec4 corner_heights;
|
||||
};
|
||||
|
||||
float
|
||||
ellipsis_dist (vec2 p, vec2 radius)
|
||||
{
|
||||
if (radius == vec2(0, 0))
|
||||
return 0.0;
|
||||
|
||||
vec2 p0 = p / radius;
|
||||
vec2 p1 = 2.0 * p0 / radius;
|
||||
|
||||
return (dot(p0, p0) - 1.0) / length (p1);
|
||||
}
|
||||
|
||||
float
|
||||
ellipsis_coverage (vec2 point, vec2 center, vec2 radius)
|
||||
{
|
||||
float d = ellipsis_dist (point - center, radius);
|
||||
return clamp (0.5 - d, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float
|
||||
rounded_rect_coverage (RoundedRect r, vec2 p)
|
||||
{
|
||||
if (p.x < r.bounds.x || p.y < r.bounds.y ||
|
||||
p.x >= r.bounds.z || p.y >= r.bounds.w)
|
||||
return 0.0;
|
||||
|
||||
vec2 rad_tl = vec2(r.corner_widths.x, r.corner_heights.x);
|
||||
vec2 rad_tr = vec2(r.corner_widths.y, r.corner_heights.y);
|
||||
vec2 rad_br = vec2(r.corner_widths.z, r.corner_heights.z);
|
||||
vec2 rad_bl = vec2(r.corner_widths.w, r.corner_heights.w);
|
||||
|
||||
vec2 ref_tl = r.bounds.xy + vec2( r.corner_widths.x, r.corner_heights.x);
|
||||
vec2 ref_tr = r.bounds.zy + vec2(-r.corner_widths.y, r.corner_heights.y);
|
||||
vec2 ref_br = r.bounds.zw + vec2(-r.corner_widths.z, -r.corner_heights.z);
|
||||
vec2 ref_bl = r.bounds.xw + vec2( r.corner_widths.w, -r.corner_heights.w);
|
||||
|
||||
float d_tl = ellipsis_coverage(p, ref_tl, rad_tl);
|
||||
float d_tr = ellipsis_coverage(p, ref_tr, rad_tr);
|
||||
float d_br = ellipsis_coverage(p, ref_br, rad_br);
|
||||
float d_bl = ellipsis_coverage(p, ref_bl, rad_bl);
|
||||
|
||||
vec4 corner_coverages = 1.0 - vec4(d_tl, d_tr, d_br, d_bl);
|
||||
|
||||
bvec4 is_out = bvec4(p.x < ref_tl.x && p.y < ref_tl.y,
|
||||
p.x > ref_tr.x && p.y < ref_tr.y,
|
||||
p.x > ref_br.x && p.y > ref_br.y,
|
||||
p.x < ref_bl.x && p.y > ref_bl.y);
|
||||
|
||||
return 1.0 - dot(vec4(is_out), corner_coverages);
|
||||
}
|
||||
|
||||
RoundedRect
|
||||
rounded_rect_shrink (RoundedRect r, vec4 amount)
|
||||
{
|
||||
vec4 new_bounds = r.bounds + vec4(1.0,1.0,-1.0,-1.0) * amount.wxyz;
|
||||
vec4 new_widths = vec4(0);
|
||||
vec4 new_heights = vec4(0);
|
||||
|
||||
// Left top
|
||||
if (r.corner_widths.x > 0) new_widths.x = r.corner_widths.x - amount.w;
|
||||
if (r.corner_heights.x > 0) new_heights.x = r.corner_heights.x - amount.x;
|
||||
|
||||
// Top right
|
||||
if (r.corner_widths.y > 0) new_widths.y = r.corner_widths.y - amount.y;
|
||||
if (r.corner_heights.y > 0) new_heights.y = r.corner_heights.y - amount.x;
|
||||
|
||||
// Bottom right
|
||||
if (r.corner_widths.z > 0) new_widths.z = r.corner_widths.z - amount.y;
|
||||
if (r.corner_heights.z > 0) new_heights.z = r.corner_heights.z - amount.z;
|
||||
|
||||
// Bottom left
|
||||
if (r.corner_widths.w > 0) new_widths.w = r.corner_widths.w - amount.w;
|
||||
if (r.corner_heights.w > 0) new_heights.w = r.corner_heights.w - amount.z;
|
||||
|
||||
return RoundedRect (new_bounds, new_widths, new_heights);
|
||||
}
|
||||
|
||||
vec4 Texture(sampler2D sampler, vec2 texCoords) {
|
||||
return texture(sampler, texCoords);
|
||||
}
|
||||
|
||||
void setOutputColor(vec4 color) {
|
||||
vec4 clipBounds = u_clip;
|
||||
vec4 f = gl_FragCoord;
|
||||
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
clipBounds.z = clipBounds.x + clipBounds.z;
|
||||
clipBounds.w = clipBounds.y + clipBounds.w;
|
||||
|
||||
RoundedRect r = RoundedRect(clipBounds, u_clip_corner_widths, u_clip_corner_heights);
|
||||
|
||||
outputColor = color * rounded_rect_coverage(r, f.xy);
|
||||
/*outputColor = color;*/
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user