Compare commits
577 Commits
wip/otte/s
...
rounded-re
Author | SHA1 | Date | |
---|---|---|---|
|
f2e45bbc87 | ||
|
9965cfbc3b | ||
|
951b448e90 | ||
|
51ad2a55a8 | ||
|
e50209a535 | ||
|
d6430995ad | ||
|
cea15fc63e | ||
|
f99fbab24f | ||
|
6acd4361ab | ||
|
05f488011a | ||
|
ef7679235a | ||
|
d65f9b298c | ||
|
5c9de08159 | ||
|
f2a297f56d | ||
|
a1d9cb8ad6 | ||
|
8da911db81 | ||
|
78f68d7992 | ||
|
8a190b200b | ||
|
e72b4ae6e2 | ||
|
9f1f4850fe | ||
|
0b9e5e6db4 | ||
|
2cd5b4df1b | ||
|
57a070fc8d | ||
|
ccc6b7165e | ||
|
ff330668cf | ||
|
63f9e5453d | ||
|
f849823a07 | ||
|
9a2d6d6d88 | ||
|
72c37d566c | ||
|
01c0d5e04b | ||
|
57dd88ee53 | ||
|
8c92c619de | ||
|
78d2002965 | ||
|
25c4acb6d2 | ||
|
0a3dac10c6 | ||
|
c9afcd31c2 | ||
|
3565facdaf | ||
|
494cff94d6 | ||
|
17644b12a5 | ||
|
54ff5d8edd | ||
|
b18320fe05 | ||
|
0ce60ad214 | ||
|
76642f2bf9 | ||
|
fcac150641 | ||
|
4d13c61aaf | ||
|
09bab2b2df | ||
|
b44f43e996 | ||
|
52fa641dff | ||
|
a3ebc0329d | ||
|
8dc04d3fc8 | ||
|
ba64e5588d | ||
|
fcdcdb7e78 | ||
|
3d5789a66e | ||
|
59343e4efb | ||
|
41219ae489 | ||
|
7055250692 | ||
|
98f63d09c0 | ||
|
85b9a6f1b0 | ||
|
3353eac289 | ||
|
cdc135f11d | ||
|
069ce48ac5 | ||
|
625c7c3d26 | ||
|
4ea2aac561 | ||
|
e88e31dde2 | ||
|
fb2e67638d | ||
|
f11dd83ab5 | ||
|
92804b5b55 | ||
|
87e7ea6080 | ||
|
b1945b38e8 | ||
|
13ca3187f2 | ||
|
18fd506360 | ||
|
9faf1a0377 | ||
|
1a9c03449e | ||
|
aee214b09d | ||
|
dc3003bc4d | ||
|
845f4b1536 | ||
|
abbb3a2da6 | ||
|
1a93efecf3 | ||
|
440d56a44f | ||
|
f10603e97d | ||
|
9a9257d7be | ||
|
5c10f2b4cd | ||
|
ba6a618d44 | ||
|
5fbeea3870 | ||
|
27368a418a | ||
|
676cd1e673 | ||
|
d6a4c65bfa | ||
|
4695f583c1 | ||
|
fa88d738dc | ||
|
7841248c1d | ||
|
ef5f34c985 | ||
|
1dfa54c117 | ||
|
ff920d98ec | ||
|
91ca6d0851 | ||
|
cdeeb3275a | ||
|
9d68bebdd1 | ||
|
526ddfa866 | ||
|
d7b9d35c02 | ||
|
383c404792 | ||
|
33d0cfd4f8 | ||
|
43311f3a80 | ||
|
265bc90524 | ||
|
197d921347 | ||
|
3d5529760a | ||
|
3a2c4be44b | ||
|
e216f469a1 | ||
|
5ae25519a7 | ||
|
4d1f7a476d | ||
|
a959fba18a | ||
|
c88ac79437 | ||
|
ddefbfa8b5 | ||
|
435a405c55 | ||
|
e1ed9f10c6 | ||
|
46adfbef4f | ||
|
53bfcf7f0a | ||
|
76d601631d | ||
|
38844fef4d | ||
|
03ac6611c1 | ||
|
0ff88346cd | ||
|
a73256e5c9 | ||
|
5d2605a151 | ||
|
40a7ec73a9 | ||
|
ccbe762103 | ||
|
88d5c9a5e1 | ||
|
6df8eafc3a | ||
|
8e69c5c89c | ||
|
8bf6498265 | ||
|
e680abc723 | ||
|
cecaede610 | ||
|
81e7e67cef | ||
|
35543f60d9 | ||
|
7856c52882 | ||
|
568023e6e6 | ||
|
cabb2625f5 | ||
|
5f64f1c8df | ||
|
41faddea40 | ||
|
a09146df5a | ||
|
bd7ee3f3e1 | ||
|
ff6c5ad710 | ||
|
bd999c72c9 | ||
|
45c9e7aff4 | ||
|
d24291db98 | ||
|
661022f2eb | ||
|
168eb941a1 | ||
|
961a6c12ec | ||
|
c227493c65 | ||
|
30acf00bf8 | ||
|
02e2a6f311 | ||
|
fa42e02a76 | ||
|
c85b3a8d35 | ||
|
285685044f | ||
|
97bc4f77c6 | ||
|
0073ee29da | ||
|
e9ed5e21ef | ||
|
c37786af36 | ||
|
a7b09e19f1 | ||
|
50ef36d387 | ||
|
347561fa68 | ||
|
d02ae09124 | ||
|
f3996a1a66 | ||
|
1181ecbf0e | ||
|
d948ac62e4 | ||
|
507e346ff1 | ||
|
98e6ed474f | ||
|
ade316eaee | ||
|
1e48843616 | ||
|
58a5de6f5d | ||
|
a9ca72695f | ||
|
082ba6d7c8 | ||
|
61ff647f71 | ||
|
823f56d263 | ||
|
87332920d5 | ||
|
d2a358206c | ||
|
51ea08aa9c | ||
|
380b63fede | ||
|
df93875c0c | ||
|
5a156e6b5f | ||
|
0e488b3dfe | ||
|
8495e0e412 | ||
|
c9b0ca0de7 | ||
|
2a950dec71 | ||
|
d6c80d4f35 | ||
|
e41cc99474 | ||
|
61fe5ac684 | ||
|
1cf3f492b8 | ||
|
54fed96f8c | ||
|
e2d659d5c2 | ||
|
8ad1189b0b | ||
|
b5b7e1f2b4 | ||
|
e56a539363 | ||
|
5f91bb81ed | ||
|
1fba59f1d1 | ||
|
68a2ca7e85 | ||
|
93ccf08c81 | ||
|
e9f5a3e9e2 | ||
|
2b85c49fb1 | ||
|
d7c3235cd0 | ||
|
ea94bac79e | ||
|
63713c3b68 | ||
|
81fd9741ff | ||
|
c7523cecf1 | ||
|
ce6569d1a6 | ||
|
852f46df19 | ||
|
d82f603fcb | ||
|
5e8e4130a5 | ||
|
f81aa14d93 | ||
|
81db6e9e61 | ||
|
ac0311b621 | ||
|
f41e58d179 | ||
|
d288931b45 | ||
|
03adeecfa3 | ||
|
5439f4596c | ||
|
f98d1a6474 | ||
|
57e6aae80a | ||
|
f23eaafc85 | ||
|
926b26e9fc | ||
|
88f27c423c | ||
|
30342896d0 | ||
|
be8e203edc | ||
|
623c93ccc8 | ||
|
34d8beaf4f | ||
|
983b6ce341 | ||
|
771df47820 | ||
|
3c218687e3 | ||
|
37fb370a5d | ||
|
1cc9413383 | ||
|
bfea39ab2f | ||
|
84d6f023b5 | ||
|
7fe04a7122 | ||
|
19cea99007 | ||
|
1c4ad78d52 | ||
|
955a7e643e | ||
|
b85a137a68 | ||
|
d17ca6b451 | ||
|
da7040874e | ||
|
6f9c4c894d | ||
|
cc7a35cd30 | ||
|
f841621348 | ||
|
f99ecd3739 | ||
|
5eb7e550d1 | ||
|
8d33f2a511 | ||
|
27b0321dec | ||
|
538605eccb | ||
|
81f5967587 | ||
|
771437acf9 | ||
|
a3da58133e | ||
|
9b558b50b8 | ||
|
7ce2eeac47 | ||
|
182dccb8f0 | ||
|
17d2ba94d6 | ||
|
5bac4f13a0 | ||
|
97aff588d5 | ||
|
e4040adbe7 | ||
|
6506a3bc9c | ||
|
64f9d82506 | ||
|
b83f3d871f | ||
|
a235b59089 | ||
|
1883035d34 | ||
|
0ca6471df4 | ||
|
98dde97f20 | ||
|
9bd9847b3f | ||
|
b79d4a3a22 | ||
|
33ab588d4e | ||
|
7200a93a88 | ||
|
319762b908 | ||
|
e453a989df | ||
|
f56328a6cc | ||
|
f29b24517e | ||
|
552df197c4 | ||
|
f6e47b7eb0 | ||
|
4214067d52 | ||
|
d9a2b74b4a | ||
|
21df62f428 | ||
|
4e501d2d44 | ||
|
5afd5cfec7 | ||
|
ad65db901a | ||
|
406b1e2e03 | ||
|
f1729affa8 | ||
|
3b2ba8ed99 | ||
|
386c3ac34f | ||
|
d92c6406d1 | ||
|
d666f4ab7f | ||
|
5df360f436 | ||
|
0197149ba3 | ||
|
b310ab7304 | ||
|
062e3da57d | ||
|
cdbd931dba | ||
|
2f96a08b3f | ||
|
c1fc6c35cf | ||
|
060992aeba | ||
|
2c15d563e2 | ||
|
2dd7ab2a50 | ||
|
0736fef585 | ||
|
0442fc2b55 | ||
|
27c621695e | ||
|
1a237ef6a8 | ||
|
e7ba8e7e9a | ||
|
14279785e6 | ||
|
5b6f8d7002 | ||
|
71a752490a | ||
|
3f4f37661c | ||
|
5bc5a6f2cd | ||
|
1a90724de9 | ||
|
f8f91095a3 | ||
|
6cc1548c5f | ||
|
30b12ff890 | ||
|
b9931e9573 | ||
|
cab8981c57 | ||
|
b6786b8a49 | ||
|
2d9ae241d5 | ||
|
a24a924a6b | ||
|
825eb93509 | ||
|
a8a0850b64 | ||
|
03f388d099 | ||
|
92205744d2 | ||
|
f6f3a78dd9 | ||
|
76698e5de8 | ||
|
21260e8ed4 | ||
|
24302315fb | ||
|
fc9642ce2a | ||
|
c542351a73 | ||
|
3198330188 | ||
|
11aaa29a69 | ||
|
d1a25178fd | ||
|
092745161c | ||
|
0da4a92298 | ||
|
8b816d3b03 | ||
|
63b50f48a9 | ||
|
8b91762c42 | ||
|
01f39d8522 | ||
|
e94416054c | ||
|
b4c859c011 | ||
|
45216e1c88 | ||
|
7bea2685e1 | ||
|
b7d1774c56 | ||
|
3afd91ea06 | ||
|
d7dd6ca552 | ||
|
9c40e8b873 | ||
|
b201d66981 | ||
|
3ea289751d | ||
|
8205c7032a | ||
|
ba379c928b | ||
|
5306ef12f4 | ||
|
be62147dee | ||
|
627ce3d447 | ||
|
79119e64f9 | ||
|
37b2b3cb83 | ||
|
731c1be9e0 | ||
|
76777cdd18 | ||
|
bdec7782b4 | ||
|
55f5edffd1 | ||
|
bb961d062a | ||
|
38ffd099eb | ||
|
12af75df9b | ||
|
d648a7721e | ||
|
e187587643 | ||
|
3766f1da8b | ||
|
92a9f8cd7e | ||
|
b9a7e5fa85 | ||
|
bec0afa61b | ||
|
bedc3dba7e | ||
|
7c4acac135 | ||
|
0bb6988c0e | ||
|
df3622b295 | ||
|
df9f3fc694 | ||
|
39b3b2444b | ||
|
c237643b24 | ||
|
cc682a96d9 | ||
|
051b463c9a | ||
|
8292b846d5 | ||
|
6efaa79e3c | ||
|
92eb845482 | ||
|
5071e6154c | ||
|
18a4b2475e | ||
|
76e5fd0ece | ||
|
fa44d258d0 | ||
|
778979cf0e | ||
|
053a4d2e9d | ||
|
aae7b2c8a8 | ||
|
e37fbaf13a | ||
|
e4f4cfaf14 | ||
|
9ae0a3865c | ||
|
3b5a2d60c7 | ||
|
9254ab8503 | ||
|
d6afcee1e4 | ||
|
c71ca481c1 | ||
|
8ef38c46b5 | ||
|
4333d754b8 | ||
|
9f82d537b0 | ||
|
7c7a3d67ca | ||
|
d33b82249b | ||
|
5f833f1d31 | ||
|
b8958419e6 | ||
|
919c90182f | ||
|
ab2a548479 | ||
|
34662fc4b0 | ||
|
5b376cedcf | ||
|
3aefed39b1 | ||
|
f86429177a | ||
|
dacfed3e11 | ||
|
8fb2ee7d67 | ||
|
29e7186829 | ||
|
951e3b3d6b | ||
|
3c76f3fb58 | ||
|
8766a6fab2 | ||
|
f52975c220 | ||
|
abd4a57031 | ||
|
9d0448756f | ||
|
03d7ce3287 | ||
|
f2083d36a1 | ||
|
cb642bec25 | ||
|
8c530264f7 | ||
|
d99042dd91 | ||
|
486196c979 | ||
|
83faacabe3 | ||
|
31aae62f9a | ||
|
726be8e2b2 | ||
|
ab0fa08d8e | ||
|
42cea18f3e | ||
|
44e54e1b4c | ||
|
a79ae95e7e | ||
|
77fe9116af | ||
|
808cde74be | ||
|
13120ccf9d | ||
|
a306401023 | ||
|
7e18a1cea7 | ||
|
9a6e6be785 | ||
|
093a4e83d5 | ||
|
428798b53f | ||
|
4fa81cf70f | ||
|
9ac31fe0a0 | ||
|
69fabb3ce9 | ||
|
f59c230a96 | ||
|
80d99b893e | ||
|
cbe89b955a | ||
|
2d827978a6 | ||
|
b2e304189e | ||
|
35c2d85468 | ||
|
7ef5f6ef1a | ||
|
9364da673f | ||
|
c87b193d2a | ||
|
045ab0f107 | ||
|
27d9023ac8 | ||
|
8a82e1b8b4 | ||
|
8e695f7c56 | ||
|
1f886668ce | ||
|
a678e9fdd9 | ||
|
74c0171edf | ||
|
248d13d8dc | ||
|
2d11d3f8d3 | ||
|
ff9cd989c6 | ||
|
5b69df96fe | ||
|
d8ead56b9c | ||
|
0e2d7111eb | ||
|
2263db6259 | ||
|
ec318e911c | ||
|
ed69435a1b | ||
|
e111f688c2 | ||
|
26e3824d1d | ||
|
e20a5e1bc1 | ||
|
66cfeb3ad1 | ||
|
63d7756658 | ||
|
e28676869e | ||
|
fabfc1eefa | ||
|
72016341c6 | ||
|
104b5ef157 | ||
|
893862a51a | ||
|
823eb4c6d9 | ||
|
be0ed15b40 | ||
|
040af44b00 | ||
|
4154f87418 | ||
|
27e3ac5fc5 | ||
|
eaaddd2647 | ||
|
6d0659a83a | ||
|
0ce6bc677e | ||
|
b579a39a47 | ||
|
aeaaead2bd | ||
|
056237fc04 | ||
|
1a7e808c27 | ||
|
3de47fa5c6 | ||
|
9f7c8f7d42 | ||
|
feb3254a6a | ||
|
03b71a9759 | ||
|
f393f70ee2 | ||
|
75c47755e3 | ||
|
e47c076048 | ||
|
6ecd57eba8 | ||
|
8b3831d43a | ||
|
39583e40ef | ||
|
be5f225022 | ||
|
427ed50759 | ||
|
9892243df6 | ||
|
83091c4f15 | ||
|
503a5de7d1 | ||
|
d7d75f0b26 | ||
|
40ac37245d | ||
|
250414d6b3 | ||
|
d69cdf6c05 | ||
|
9532657fa2 | ||
|
3cb2115212 | ||
|
dd7c85adc3 | ||
|
8965d6c7f8 | ||
|
d7309a009c | ||
|
bd9b117517 | ||
|
a309a56acf | ||
|
b6fac448d7 | ||
|
765f55dfbe | ||
|
bebaad3e1f | ||
|
db6a116d49 | ||
|
a299656c60 | ||
|
27fd0b907d | ||
|
62951c7277 | ||
|
8e00f6e5e5 | ||
|
ff141a1ed4 | ||
|
25a10f502e | ||
|
585fb497c1 | ||
|
c57e5811f1 | ||
|
940a2b6923 | ||
|
3277e2ee3e | ||
|
3e8489fea5 | ||
|
1035640020 | ||
|
6cee73d100 | ||
|
e4c43901c1 | ||
|
c7f30ecdfd | ||
|
b64f7050ba | ||
|
d37b9619e2 | ||
|
4a22e681b3 | ||
|
189aced844 | ||
|
d90cb02570 | ||
|
4246c7bafd | ||
|
d67101d46e | ||
|
60f3cc398a | ||
|
e010cd242c | ||
|
41454b63b4 | ||
|
f458951745 | ||
|
ef3793ec37 | ||
|
94b1a78378 | ||
|
584fd36a5f | ||
|
4ea818fee6 | ||
|
c271cd1a3f | ||
|
64a1969293 | ||
|
2baab9732c | ||
|
8134daf843 | ||
|
9c013d40c1 | ||
|
d798372a53 | ||
|
cfaf1b3e71 | ||
|
9763d83a9d | ||
|
5f82a496cb | ||
|
0c35015c44 | ||
|
3da0572078 | ||
|
c649d8a4ec | ||
|
75bea01a86 | ||
|
5d3cec5441 | ||
|
891242920e | ||
|
b375f17f09 | ||
|
ec69990126 | ||
|
aec5a5739e | ||
|
ac9e0039b8 | ||
|
4574b21fd6 | ||
|
31c5961c4f | ||
|
8fc3f06155 | ||
|
5327203201 | ||
|
8442fce962 | ||
|
d8b46c16cc | ||
|
4df7273266 | ||
|
2b8fd89fd5 | ||
|
5b9a7863cf | ||
|
d625ff8106 | ||
|
5ecd8a1c10 | ||
|
e12669e230 | ||
|
7f906bef06 | ||
|
5970a14217 | ||
|
5f4a6210c2 | ||
|
c0fa9e80aa | ||
|
33e5d2c307 | ||
![]() |
f23c124af2 | ||
|
b4b185d53d |
@@ -24,9 +24,9 @@ stages:
|
||||
variables:
|
||||
COMMON_MESON_FLAGS: "-Dwerror=true -Dcairo:werror=false -Dgi-docgen:werror=false -Dgraphene:werror=false -Dlibepoxy:werror=false -Dlibsass:werror=false -Dpango:werror=false -Dsassc:werror=false -Dgdk-pixbuf:werror=false -Dglib:werror=false -Dlibcloudproviders:werror=false -Dlibpng:werror=false -Dlibtiff:werror=false -Dsysprof:werror=false -Dwayland-protocols:werror=false -Dharfbuzz:werror=false -Dfreetype2:werror=false -Dfontconfig:werror=false -Dfribidi:werror=false -Dlibffi:werror=false -Dlibjpeg-turbo:werror=false -Dmutest:werror=false -Dpixman:werror=false -Dproxy-libintl:werror=false"
|
||||
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
|
||||
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Ddemos=false -Dbuild-examples=false -Dbuild-tests=false -Dbuild-testsuite=true"
|
||||
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-demos=false -Dbuild-examples=false -Dbuild-tests=false -Dbuild-testsuite=true"
|
||||
MESON_TEST_TIMEOUT_MULTIPLIER: 3
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v42"
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v46"
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
@@ -57,15 +57,9 @@ style-check-diff:
|
||||
reports:
|
||||
junit:
|
||||
- "${CI_PROJECT_DIR}/_build/report-x11.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-x11_unstable.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland_unstable.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland_gles.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland_gles_unstable.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland_smalltexture.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland_smalltexture_unstable.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-broadway.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-broadway_unstable.xml"
|
||||
name: "gtk-${CI_COMMIT_REF_NAME}"
|
||||
paths:
|
||||
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
||||
@@ -76,6 +70,7 @@ style-check-diff:
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/tools/output/*/*"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*/*.png"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*/*.syscap"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/headless/*/*.log"
|
||||
- "${CI_PROJECT_DIR}/_build_hello/meson-logs"
|
||||
cache:
|
||||
key: "$CI_JOB_NAME"
|
||||
@@ -91,7 +86,27 @@ fedora-x86_64:
|
||||
script:
|
||||
- .gitlab-ci/show-info-linux.sh
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- pip3 install --user meson~=0.64
|
||||
- meson subprojects download
|
||||
- meson subprojects update --reset
|
||||
- meson setup
|
||||
${COMMON_MESON_FLAGS}
|
||||
${EXTRA_MESON_FLAGS}
|
||||
${BACKEND_FLAGS}
|
||||
${FEATURE_FLAGS}
|
||||
_build
|
||||
- meson compile -C _build
|
||||
- .gitlab-ci/run-tests.sh _build wayland
|
||||
- .gitlab-ci/run-tests.sh _build wayland_gles
|
||||
|
||||
release-build:
|
||||
extends: .build-fedora-default
|
||||
stage: build
|
||||
needs: []
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||
script:
|
||||
- .gitlab-ci/show-info-linux.sh
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- meson subprojects download
|
||||
- meson subprojects update --reset
|
||||
- mkdir _install
|
||||
@@ -107,31 +122,6 @@ fedora-x86_64:
|
||||
- PKG_CONFIG_PATH=${CI_PROJECT_DIR}/_install/lib64/pkgconfig:${CI_PROJECT_DIR}/_install/share/pkgconfig meson setup _build_hello examples/hello
|
||||
- LD_LIBRARY_PATH=${CI_PROJECT_DIR}/_install/lib64 meson compile -C _build_hello
|
||||
- .gitlab-ci/run-tests.sh _build x11
|
||||
- .gitlab-ci/run-tests.sh _build wayland
|
||||
- .gitlab-ci/run-tests.sh _build wayland_gles
|
||||
- .gitlab-ci/run-tests.sh _build wayland_smalltexture
|
||||
- .gitlab-ci/run-tests.sh _build broadway
|
||||
|
||||
release-build:
|
||||
extends: .build-fedora-default
|
||||
stage: build
|
||||
needs: []
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||
script:
|
||||
- .gitlab-ci/show-info-linux.sh
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- pip3 install --user meson~=0.64
|
||||
- meson subprojects download
|
||||
- meson subprojects update --reset
|
||||
- meson setup
|
||||
${COMMON_MESON_FLAGS}
|
||||
${EXTRA_MESON_FLAGS}
|
||||
${BACKEND_FLAGS}
|
||||
${FEATURE_FLAGS}
|
||||
_build
|
||||
- meson compile -C _build
|
||||
- .gitlab-ci/run-tests.sh _build x11
|
||||
|
||||
fedora-mingw64:
|
||||
extends: .build-fedora-default
|
||||
@@ -152,23 +142,11 @@ fedora-mingw64:
|
||||
script:
|
||||
- .gitlab-ci/show-info-linux.sh
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- pip3 install --user meson~=0.64
|
||||
- pip3 install --user meson~=1.0
|
||||
- meson subprojects download
|
||||
- meson subprojects update --reset
|
||||
# Test that mingw64-meson still fails. If it has stopped failing, the CI
|
||||
# will fail and now you should remove the hack that follows this.
|
||||
- FAILED=false
|
||||
- mingw64-meson --version || FAILED=true
|
||||
- test $FAILED = false && echo "mingw64-meson works now, remove the hack" && exit 1
|
||||
# HACK: Running mingw64-meson directly fails on the CI with:
|
||||
# /usr/bin/mingw64-meson: line 92: fg: no job control
|
||||
# Because rpm is not evaluating %__meson and it gets interpreted as a job
|
||||
# specifier. So we fix that and run it ourselves.
|
||||
- rpm --eval "%{mingw64_meson}" > mingw64-meson.sh
|
||||
- sed -i -e 's/%__meson/meson/' mingw64-meson.sh
|
||||
- chmod +x mingw64-meson.sh
|
||||
- ./mingw64-meson.sh -Dintrospection=disabled -Dgraphene:introspection=disabled _build
|
||||
- ninja -C _build
|
||||
- meson -Dintrospection=disabled -Dgraphene:introspection=disabled _build
|
||||
- meson compile -C _build
|
||||
|
||||
.mingw-defaults:
|
||||
stage: build
|
||||
@@ -210,7 +188,7 @@ macos:
|
||||
needs: []
|
||||
before_script:
|
||||
- bash .gitlab-ci/show-info-osx.sh
|
||||
- pip3 install --user meson~=0.64
|
||||
- pip3 install --user meson~=1.0
|
||||
- pip3 install --user ninja
|
||||
- export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH
|
||||
- export MESON_FORCE_BACKTRACE=1
|
||||
@@ -368,10 +346,11 @@ static-scan:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=debug"
|
||||
script:
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- pip3 install --user meson~=0.64
|
||||
- meson setup
|
||||
${COMMON_MESON_FLAGS}
|
||||
${EXTRA_MESON_FLAGS}
|
||||
${BACKEND_FLAGS}
|
||||
${FEATURE_FLAGS}
|
||||
_scan_build
|
||||
- ninja -C _scan_build scan-build
|
||||
artifacts:
|
||||
@@ -390,7 +369,6 @@ asan-build:
|
||||
variables:
|
||||
script:
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- pip3 install --user meson~=0.64
|
||||
- CC=clang meson setup --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=disabled -Df16c=disabled _build
|
||||
- ninja -C _build
|
||||
- .gitlab-ci/run-tests.sh _build wayland
|
||||
@@ -405,7 +383,6 @@ reference:
|
||||
needs: []
|
||||
script:
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- pip3 install --user meson~=0.64
|
||||
- meson setup
|
||||
${COMMON_MESON_FLAGS}
|
||||
--buildtype=release
|
||||
|
@@ -32,7 +32,6 @@ RUN dnf -y install \
|
||||
glib2-static \
|
||||
glibc-devel \
|
||||
glibc-headers \
|
||||
gnome-desktop-testing \
|
||||
gnupg2 \
|
||||
gobject-introspection-devel \
|
||||
graphene-devel \
|
||||
@@ -73,10 +72,14 @@ RUN dnf -y install \
|
||||
mesa-dri-drivers \
|
||||
mesa-libEGL-devel \
|
||||
mesa-libGLES-devel \
|
||||
meson \
|
||||
mutter \
|
||||
ninja-build \
|
||||
pango-devel \
|
||||
pcre-devel \
|
||||
pcre-static \
|
||||
pipewire \
|
||||
pipewire-gstreamer \
|
||||
python3 \
|
||||
python3-docutils \
|
||||
python3-gobject \
|
||||
@@ -84,6 +87,7 @@ RUN dnf -y install \
|
||||
python3-markdown \
|
||||
python3-packaging \
|
||||
python3-pip \
|
||||
python3-pydbus \
|
||||
python3-pygments \
|
||||
python3-typogrify \
|
||||
python3-wheel \
|
||||
@@ -95,6 +99,7 @@ RUN dnf -y install \
|
||||
weston \
|
||||
weston-libs \
|
||||
which \
|
||||
wireplumber \
|
||||
xorg-x11-server-Xvfb \
|
||||
&& dnf clean all
|
||||
|
||||
|
@@ -138,7 +138,8 @@ if [ $run == 1 ]; then
|
||||
echo -e "\e[1;32mRUNNING\e[0m: ${base} as ${TAG}"
|
||||
${CMD} run \
|
||||
--rm \
|
||||
--volume "$(pwd)/..:/home/user/app" \
|
||||
--userns=keep-id \
|
||||
--volume "$(pwd)/..:/home/user/app:rw,z" \
|
||||
--workdir "/home/user/app" \
|
||||
--tty \
|
||||
--interactive "${TAG}" \
|
||||
|
@@ -6,6 +6,7 @@ set +e
|
||||
srcdir=$( pwd )
|
||||
builddir=$1
|
||||
backend=$2
|
||||
multiplier=${MESON_TEST_TIMEOUT_MULTIPLIER:-1}
|
||||
|
||||
# Ignore memory leaks lower in dependencies
|
||||
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:verbosity=1:log_threads=1
|
||||
@@ -15,7 +16,8 @@ case "${backend}" in
|
||||
x11)
|
||||
xvfb-run -a -s "-screen 0 1024x768x24 -noreset" \
|
||||
meson test -C ${builddir} \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--quiet \
|
||||
--timeout-multiplier "${multiplier}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
@@ -26,14 +28,6 @@ case "${backend}" in
|
||||
# Store the exit code for the CI run, but always
|
||||
# generate the reports
|
||||
exit_code=$?
|
||||
|
||||
xvfb-run -a -s "-screen 0 1024x768x24 -noreset" \
|
||||
meson test -C ${builddir} \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend}_unstable \
|
||||
--suite=flaky \
|
||||
--suite=failing || true
|
||||
;;
|
||||
|
||||
wayland*)
|
||||
@@ -44,22 +38,17 @@ case "${backend}" in
|
||||
export WAYLAND_DISPLAY=wayland-5
|
||||
|
||||
meson test -C ${builddir} \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--quiet \
|
||||
--timeout-multiplier "${multiplier}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
--no-suite=failing \
|
||||
--no-suite=flaky \
|
||||
--no-suite=${backend}_failing \
|
||||
--no-suite=gsk-compare-broadway
|
||||
exit_code=$?
|
||||
|
||||
meson test -C ${builddir} \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend}_unstable \
|
||||
--suite=flaky \
|
||||
--suite=failing || true
|
||||
|
||||
kill ${compositor}
|
||||
;;
|
||||
|
||||
@@ -71,7 +60,8 @@ case "${backend}" in
|
||||
export BROADWAY_DISPLAY=:5
|
||||
|
||||
meson test -C ${builddir} \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--quiet \
|
||||
--timeout-multiplier "${multiplier}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
@@ -79,16 +69,6 @@ case "${backend}" in
|
||||
--no-suite=flaky \
|
||||
--no-suite=gsk-compare-opengl
|
||||
|
||||
# don't let Broadway failures fail the run, for now
|
||||
exit_code=0
|
||||
|
||||
meson test -C ${builddir} \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend}_unstable \
|
||||
--suite=flaky \
|
||||
--suite=failing || true
|
||||
|
||||
kill ${server}
|
||||
;;
|
||||
|
||||
@@ -101,20 +81,19 @@ esac
|
||||
|
||||
cd ${builddir}
|
||||
|
||||
for suffix in "" "_unstable"; do
|
||||
$srcdir/.gitlab-ci/meson-junit-report.py \
|
||||
$srcdir/.gitlab-ci/meson-junit-report.py \
|
||||
--project-name=gtk \
|
||||
--backend="${backend}${suffix}" \
|
||||
--backend="${backend}" \
|
||||
--job-id="${CI_JOB_NAME}" \
|
||||
--output="report-${backend}${suffix}.xml" \
|
||||
"meson-logs/testlog-${backend}${suffix}.json"
|
||||
$srcdir/.gitlab-ci/meson-html-report.py \
|
||||
--output="report-${backend}.xml" \
|
||||
"meson-logs/testlog-${backend}.json"
|
||||
|
||||
$srcdir/.gitlab-ci/meson-html-report.py \
|
||||
--project-name=gtk \
|
||||
--backend="${backend}${suffix}" \
|
||||
--backend="${backend}" \
|
||||
--job-id="${CI_JOB_NAME}" \
|
||||
--reftest-output-dir="testsuite/reftests/output/${backend}${suffix}" \
|
||||
--output="report-${backend}${suffix}.html" \
|
||||
"meson-logs/testlog-${backend}${suffix}.json"
|
||||
done
|
||||
--reftest-output-dir="testsuite/reftests/output/${backend}" \
|
||||
--output="report-${backend}.html" \
|
||||
"meson-logs/testlog-${backend}.json"
|
||||
|
||||
exit $exit_code
|
||||
|
106
NEWS
106
NEWS
@@ -1,6 +1,110 @@
|
||||
Overview of Changes in 4.11.2, xx-xx-xxxx
|
||||
Overview of Changes in 4.11.3, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
Overview of Changes in 4.11.2, 09-05-2023
|
||||
=========================================
|
||||
|
||||
* GtkGLArea:
|
||||
- Add an allowed-apis property
|
||||
|
||||
* GtkListBox:
|
||||
- Fix a problem with gtk_list_box_remove_all
|
||||
|
||||
* Add the GtkSectionModel interface, and implement it in most
|
||||
of our list models
|
||||
|
||||
* GtkListView:
|
||||
- Support displaying sections
|
||||
|
||||
* GtkCenterBox:
|
||||
- Add a shrink-center-last property
|
||||
|
||||
* GtkButton, GtkMenuButton:
|
||||
- Add a can-shrink property
|
||||
|
||||
* GtkPopover:
|
||||
- Fix problems with grabs
|
||||
|
||||
* GtkFileChooser:
|
||||
- Fix a problem with removing files
|
||||
- Make the date, time and location columns work
|
||||
- Fix filtering in the save entry popup
|
||||
- A few memory leak fixes
|
||||
- Handle webdav in the pathbar
|
||||
|
||||
* GtkBox:
|
||||
- Support baselines in vertical orientation with GtkBox:baseline-child
|
||||
|
||||
* Dialogs:
|
||||
- Destroy windows promptly when the async callback finishes
|
||||
- Detect absence of the OpenURI portal and fall back
|
||||
|
||||
* Theme:
|
||||
- Add explicit style classes to a number of widgets
|
||||
- Fix some contrast issues in the dark theme
|
||||
|
||||
* Accessibility:
|
||||
- Fix alert dialogs in the a11y tree
|
||||
- Improve accessibility of GtkShortcutsWindow
|
||||
|
||||
* Layout:
|
||||
- Some fixes to baseline alignment
|
||||
- Separate GTK_ALIGN_BASELINE_CENTER and _FILL
|
||||
|
||||
* CSS:
|
||||
- Fix a crash with color transitions
|
||||
|
||||
* GSK:
|
||||
- Fix problems with negative scales
|
||||
- Improve scaling of offscreens for (cross-fades, masks, blends)
|
||||
|
||||
* GL:
|
||||
- Add GdkGLTextureBuilder, a more flexible api for creating textures
|
||||
- Support setting update regions for GL textures
|
||||
- Ensure that we work with GLES 2
|
||||
|
||||
* Vulkan:
|
||||
- More fixes to the experimental Vulkan renderer
|
||||
- Rework glyph caching
|
||||
|
||||
* Wayland:
|
||||
- Don't destroy wl_surfaces on hide
|
||||
- Plug leaks of compositor-side resources
|
||||
|
||||
* X11:
|
||||
- Fix artifacts in gnome-shell frame decorations
|
||||
|
||||
* Windows:
|
||||
- Fix GL context initialization
|
||||
|
||||
* Inspector:
|
||||
- Improve the action list
|
||||
- Improve the accessibility pane
|
||||
- Fix a crash
|
||||
|
||||
* Tools:
|
||||
- gtk4-node-editor: Improve scaling
|
||||
- gtk4-node-editor: Preserve aspect ratio of textures
|
||||
- gtk4-node-editor: Add some smarter editing
|
||||
- gtk4-demo: Make the stylus demo work with mice
|
||||
|
||||
* Deprecations:
|
||||
- gtk_widget_get_allocated_width/height/baseline
|
||||
- GTK_ALIGN_BASELINE
|
||||
|
||||
* Translation updates
|
||||
Bulgarian
|
||||
Chinese (China)
|
||||
Friulian
|
||||
Galician
|
||||
Hebrew
|
||||
Persian
|
||||
Polish
|
||||
Portuguese
|
||||
`Russian
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.11.1, 03-04-2023
|
||||
=========================================
|
||||
|
||||
|
17
README.md
17
README.md
@@ -116,19 +116,12 @@ docs/reference/gtk/html/gtk-building.html
|
||||
|
||||
Or [online](https://docs.gtk.org/gtk4/building.html)
|
||||
|
||||
Default branch renamed to `main`
|
||||
--------------------------------
|
||||
Building from git
|
||||
-----------------
|
||||
|
||||
The default development branch of GTK has been renamed to `main`.
|
||||
To update your local checkout, use:
|
||||
```sh
|
||||
git checkout master
|
||||
git branch -m master main
|
||||
git fetch
|
||||
git branch --unset-upstream
|
||||
git branch -u origin/main
|
||||
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
|
||||
```
|
||||
The GTK sources are hosted on [gitlab.gnome.org](http://gitlab.gnome.org). The main
|
||||
development branch is called `main`, and stable branches are named after their minor
|
||||
version, for example `gtk-4-10`.
|
||||
|
||||
How to report bugs
|
||||
------------------
|
||||
|
@@ -187,7 +187,7 @@
|
||||
"--libdir=/app/lib",
|
||||
"-Dvulkan=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Dprofile=devel"
|
||||
"-Ddemo-profile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
@@ -116,7 +116,7 @@
|
||||
"--libdir=/app/lib",
|
||||
"-Dvulkan=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Dprofile=devel"
|
||||
"-Ddemo-profile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
@@ -116,7 +116,7 @@
|
||||
"--libdir=/app/lib",
|
||||
"-Dvulkan=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Dprofile=devel"
|
||||
"-Ddemo-profile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
@@ -116,7 +116,7 @@
|
||||
"--libdir=/app/lib",
|
||||
"-Dvulkan=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Dprofile=devel"
|
||||
"-Ddemo-profile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
201
build-aux/meson/gen-visibility-macros.py
Executable file
201
build-aux/meson/gen-visibility-macros.py
Executable file
@@ -0,0 +1,201 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2022 Collabora Inc.
|
||||
# 2023 Emmanuele Bassi
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
#
|
||||
# Original author: Xavier Claessens <xclaesse@gmail.com>
|
||||
|
||||
import argparse
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# Disable line length warnings as wrapping the C code templates would be hard
|
||||
# flake8: noqa: E501
|
||||
|
||||
|
||||
def gen_versions_macros(args, current_major_version, current_minor_version, current_micro_version):
|
||||
with args.out_path.open("w", encoding="utf-8") as ofile, args.in_path.open(
|
||||
"r", encoding="utf-8"
|
||||
) as ifile:
|
||||
for line in ifile.readlines():
|
||||
if "@GDK_VERSIONS@" in line:
|
||||
ofile.write(
|
||||
textwrap.dedent(
|
||||
f"""\
|
||||
/**
|
||||
* GDK_MAJOR_VERSION:
|
||||
*
|
||||
* The major version component of the library's version, e.g. "1" for "1.2.3".
|
||||
*/
|
||||
#define GDK_MAJOR_VERSION ({current_major_version})
|
||||
|
||||
/**
|
||||
* GDK_MINOR_VERSION:
|
||||
*
|
||||
* The minor version component of the library's version, e.g. "2" for "1.2.3".
|
||||
*/
|
||||
#define GDK_MINOR_VERSION ({current_minor_version})
|
||||
|
||||
/**
|
||||
* GDK_MICRO_VERSION:
|
||||
*
|
||||
* The micro version component of the library's version, e.g. "3" for "1.2.3".
|
||||
*/
|
||||
#define GDK_MICRO_VERSION ({current_micro_version})
|
||||
"""
|
||||
)
|
||||
)
|
||||
for minor in range(0, current_minor_version + 2, 2):
|
||||
ofile.write(
|
||||
textwrap.dedent(
|
||||
f"""\
|
||||
/**
|
||||
* GDK_VERSION_{current_major_version}_{minor}:
|
||||
*
|
||||
* A macro that evaluates to the {current_major_version}.{minor} version of GTK, in a format
|
||||
* that can be used by the C pre-processor.
|
||||
*
|
||||
* Since: {current_major_version}.{minor}
|
||||
*/
|
||||
#define GDK_VERSION_{current_major_version}_{minor} (G_ENCODE_VERSION ({current_major_version}, {minor}))
|
||||
"""
|
||||
)
|
||||
)
|
||||
else:
|
||||
ofile.write(line)
|
||||
|
||||
|
||||
def gen_visibility_macros(args, current_major_version, current_minor_version, current_micro_version):
|
||||
"""
|
||||
Generates a set of macros for each minor stable version of GTK
|
||||
|
||||
- GDK_DEPRECATED
|
||||
- GDK_DEPRECATED_IN_…
|
||||
- GDK_DEPRECATED_MACRO_IN_…
|
||||
- GDK_DEPRECATED_ENUMERATOR_IN_…
|
||||
- GDK_DEPRECATED_TYPE_IN_…
|
||||
|
||||
- GDK_AVAILABLE_IN_ALL
|
||||
- GDK_AVAILABLE_IN_…
|
||||
- GDK_AVAILABLE_STATIC_INLINE_IN_…
|
||||
- GDK_AVAILABLE_MACRO_IN_…
|
||||
- GDK_AVAILABLE_ENUMERATOR_IN_…
|
||||
- GDK_AVAILABLE_TYPE_IN_…
|
||||
|
||||
- GDK_UNAVAILABLE(maj,min)
|
||||
- GDK_UNAVAILABLE_STATIC_INLINE(maj,min)
|
||||
"""
|
||||
|
||||
ns = args.namespace
|
||||
with args.out_path.open("w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
textwrap.dedent(
|
||||
f"""\
|
||||
#pragma once
|
||||
|
||||
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined({ns}_STATIC_COMPILATION)
|
||||
# define _{ns}_EXPORT __declspec(dllexport)
|
||||
# define _{ns}_IMPORT __declspec(dllimport)
|
||||
#elif __GNUC__ >= 4
|
||||
# define _{ns}_EXPORT __attribute__((visibility("default")))
|
||||
# define _{ns}_IMPORT
|
||||
#else
|
||||
# define _{ns}_EXPORT
|
||||
# define _{ns}_IMPORT
|
||||
#endif
|
||||
#ifdef GTK_COMPILATION
|
||||
# define _{ns}_API _{ns}_EXPORT
|
||||
#else
|
||||
# define _{ns}_API _{ns}_IMPORT
|
||||
#endif
|
||||
|
||||
#define _{ns}_EXTERN _{ns}_API extern
|
||||
|
||||
#define {ns}_VAR _{ns}_EXTERN
|
||||
#define {ns}_AVAILABLE_IN_ALL _{ns}_EXTERN
|
||||
|
||||
#ifdef GDK_DISABLE_DEPRECATION_WARNINGS
|
||||
#define {ns}_DEPRECATED _{ns}_EXTERN
|
||||
#define {ns}_DEPRECATED_FOR(f) _{ns}_EXTERN
|
||||
#define {ns}_UNAVAILABLE(maj,min) _{ns}_EXTERN
|
||||
#define {ns}_UNAVAILABLE_STATIC_INLINE(maj,min)
|
||||
#else
|
||||
#define {ns}_DEPRECATED G_DEPRECATED _{ns}_EXTERN
|
||||
#define {ns}_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _{ns}_EXTERN
|
||||
#define {ns}_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _{ns}_EXTERN
|
||||
#define {ns}_UNAVAILABLE_STATIC_INLINE(maj,min) G_UNAVAILABLE(maj,min)
|
||||
#endif
|
||||
"""
|
||||
)
|
||||
)
|
||||
for minor in range(0, current_minor_version + 2, 2):
|
||||
f.write(
|
||||
textwrap.dedent(
|
||||
f"""
|
||||
#if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_4_{minor}
|
||||
#define {ns}_DEPRECATED_IN_{current_major_version}_{minor} {ns}_DEPRECATED
|
||||
#define {ns}_DEPRECATED_IN_{current_major_version}_{minor}_FOR(f) {ns}_DEPRECATED_FOR (f)
|
||||
#define {ns}_DEPRECATED_MACRO_IN_{current_major_version}_{minor} GDK_DEPRECATED_MACRO
|
||||
#define {ns}_DEPRECATED_MACRO_IN_{current_major_version}_{minor}_FOR(f) GDK_DEPRECATED_MACRO_FOR (f)
|
||||
#define {ns}_DEPRECATED_ENUMERATOR_IN_{current_major_version}_{minor} GDK_DEPRECATED_ENUMERATOR
|
||||
#define {ns}_DEPRECATED_ENUMERATOR_IN_{current_major_version}_{minor}_FOR(f) GDK_DEPRECATED_ENUMERATOR_FOR (f)
|
||||
#define {ns}_DEPRECATED_TYPE_IN_{current_major_version}_{minor} GDK_DEPRECATED_TYPE
|
||||
#define {ns}_DEPRECATED_TYPE_IN_{current_major_version}_{minor}_FOR(f) GDK_DEPRECATED_TYPE_FOR (f)
|
||||
#else
|
||||
#define {ns}_DEPRECATED_IN_{current_major_version}_{minor} _{ns}_EXTERN
|
||||
#define {ns}_DEPRECATED_IN_{current_major_version}_{minor}_FOR(f) _{ns}_EXTERN
|
||||
#define {ns}_DEPRECATED_MACRO_IN_{current_major_version}_{minor}
|
||||
#define {ns}_DEPRECATED_MACRO_IN_{current_major_version}_{minor}_FOR(f)
|
||||
#define {ns}_DEPRECATED_ENUMERATOR_IN_{current_major_version}_{minor}
|
||||
#define {ns}_DEPRECATED_ENUMERATOR_IN_{current_major_version}_{minor}_FOR(f)
|
||||
#define {ns}_DEPRECATED_TYPE_IN_{current_major_version}_{minor}
|
||||
#define {ns}_DEPRECATED_TYPE_IN_{current_major_version}_{minor}_FOR(f)
|
||||
#endif
|
||||
|
||||
#if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_{current_major_version}_{minor}
|
||||
#define {ns}_AVAILABLE_IN_{current_major_version}_{minor} {ns}_UNAVAILABLE ({current_major_version}, {minor})
|
||||
#define {ns}_AVAILABLE_STATIC_INLINE_IN_{current_major_version}_{minor} GDK_UNAVAILABLE_STATIC_INLINE ({current_major_version}, {minor})
|
||||
#define {ns}_AVAILABLE_MACRO_IN_{current_major_version}_{minor} GDK_UNAVAILABLE_MACRO ({current_major_version}, {minor})
|
||||
#define {ns}_AVAILABLE_ENUMERATOR_IN_{current_major_version}_{minor} GDK_UNAVAILABLE_ENUMERATOR ({current_major_version}, {minor})
|
||||
#define {ns}_AVAILABLE_TYPE_IN_{current_major_version}_{minor} GDK_UNAVAILABLE_TYPE ({current_major_version}, {minor})
|
||||
#else
|
||||
#define {ns}_AVAILABLE_IN_{current_major_version}_{minor} _{ns}_EXTERN
|
||||
#define {ns}_AVAILABLE_STATIC_INLINE_IN_{current_major_version}_{minor}
|
||||
#define {ns}_AVAILABLE_MACRO_IN_{current_major_version}_{minor}
|
||||
#define {ns}_AVAILABLE_ENUMERATOR_IN_{current_major_version}_{minor}
|
||||
#define {ns}_AVAILABLE_TYPE_IN_{current_major_version}_{minor}
|
||||
#endif
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("gtk_version", help="Current GLib version")
|
||||
subparsers = parser.add_subparsers()
|
||||
|
||||
versions_parser = subparsers.add_parser(
|
||||
"versions-macros", help="Generate versions macros"
|
||||
)
|
||||
versions_parser.add_argument("in_path", help="input file", type=Path)
|
||||
versions_parser.add_argument("out_path", help="output file", type=Path)
|
||||
versions_parser.set_defaults(func=gen_versions_macros)
|
||||
|
||||
visibility_parser = subparsers.add_parser(
|
||||
"visibility-macros", help="Generate visibility macros"
|
||||
)
|
||||
visibility_parser.add_argument("namespace", help="Macro namespace")
|
||||
visibility_parser.add_argument("out_path", help="output file", type=Path)
|
||||
visibility_parser.set_defaults(func=gen_visibility_macros)
|
||||
|
||||
args = parser.parse_args()
|
||||
version = [int(i) for i in args.gtk_version.split(".")]
|
||||
args.func(args, version[0], version[1], version[2])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@@ -116,7 +116,8 @@ effective_align (GtkAlign align,
|
||||
return direction == GTK_TEXT_DIR_RTL ? GTK_ALIGN_START : GTK_ALIGN_END;
|
||||
case GTK_ALIGN_FILL:
|
||||
case GTK_ALIGN_CENTER:
|
||||
case GTK_ALIGN_BASELINE:
|
||||
case GTK_ALIGN_BASELINE_FILL:
|
||||
case GTK_ALIGN_BASELINE_CENTER:
|
||||
default:
|
||||
return align;
|
||||
}
|
||||
@@ -258,7 +259,8 @@ blur_overlay_get_child_position (BlurOverlay *overlay,
|
||||
case GTK_ALIGN_END:
|
||||
alloc->x += width - alloc->width;
|
||||
break;
|
||||
case GTK_ALIGN_BASELINE:
|
||||
case GTK_ALIGN_BASELINE_FILL:
|
||||
case GTK_ALIGN_BASELINE_CENTER:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
@@ -281,7 +283,8 @@ blur_overlay_get_child_position (BlurOverlay *overlay,
|
||||
case GTK_ALIGN_END:
|
||||
alloc->y += height - alloc->height;
|
||||
break;
|
||||
case GTK_ALIGN_BASELINE:
|
||||
case GTK_ALIGN_BASELINE_FILL:
|
||||
case GTK_ALIGN_BASELINE_CENTER:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
|
@@ -51,15 +51,11 @@ struct _BlurOverlayClass
|
||||
GtkAllocation *allocation);
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType blur_overlay_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget *blur_overlay_new (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void blur_overlay_add_overlay (BlurOverlay *overlay,
|
||||
GtkWidget *widget,
|
||||
double blur);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void blur_overlay_set_child (BlurOverlay *overlay,
|
||||
GtkWidget *widget);
|
||||
|
||||
|
@@ -50,7 +50,7 @@ update_css_for_blend_mode (GtkCssProvider *provider,
|
||||
blend_mode,
|
||||
blend_mode);
|
||||
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_css_provider_load_from_string (provider, css);
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
g_free (css);
|
||||
|
@@ -195,6 +195,9 @@
|
||||
<gresource prefix="/listview_settings">
|
||||
<file>listview_settings.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/listview_settings2">
|
||||
<file>listview_settings2.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/listview_ucd_data/">
|
||||
<file>ucdnames.data</file>
|
||||
</gresource>
|
||||
@@ -312,6 +315,7 @@
|
||||
<file>listview_minesweeper.c</file>
|
||||
<file>listview_selections.c</file>
|
||||
<file>listview_settings.c</file>
|
||||
<file>listview_settings2.c</file>
|
||||
<file>listview_ucd.c</file>
|
||||
<file>listview_weather.c</file>
|
||||
<file>listview_words.c</file>
|
||||
|
@@ -70,7 +70,7 @@ set_color (CanvasItem *item,
|
||||
css = g_strdup_printf ("#%s { background: %s; }", name, str);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_css_provider_load_from_string (provider, css);
|
||||
gtk_style_context_add_provider_for_display (gtk_widget_get_display (item->label), GTK_STYLE_PROVIDER (provider), 700);
|
||||
item->provider = GTK_STYLE_PROVIDER (provider);
|
||||
|
||||
@@ -109,15 +109,21 @@ static void
|
||||
apply_transform (CanvasItem *item)
|
||||
{
|
||||
GskTransform *transform;
|
||||
graphene_rect_t bounds;
|
||||
double x, y;
|
||||
|
||||
x = gtk_widget_get_allocated_width (item->label) / 2.0;
|
||||
y = gtk_widget_get_allocated_height (item->label) / 2.0;
|
||||
item->r = sqrt (x*x + y*y);
|
||||
/* Add css padding and margin */
|
||||
if (!gtk_widget_compute_bounds (item->label, item->label, &bounds))
|
||||
return;
|
||||
|
||||
x = bounds.size.width / 2.;
|
||||
y = bounds.size.height / 2.;
|
||||
|
||||
item->r = sqrt (x * x + y * y);
|
||||
|
||||
transform = gsk_transform_translate (NULL, &(graphene_point_t) { item->r, item->r });
|
||||
transform = gsk_transform_rotate (transform, item->angle + item->delta);
|
||||
transform = gsk_transform_translate (transform, &(graphene_point_t) { -x, -y });
|
||||
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (-x, -y));
|
||||
|
||||
gtk_fixed_set_child_transform (GTK_FIXED (item->fixed), item->label, transform);
|
||||
gsk_transform_unref (transform);
|
||||
@@ -759,7 +765,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_string_append_printf (css, ".canvasitem.%s { background: %s; }\n", colors[i], colors[i]);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css->str, css->len);
|
||||
gtk_css_provider_load_from_string (provider, css->str);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
|
@@ -301,7 +301,7 @@ do_fishbowl (GtkWidget *do_widget)
|
||||
if (provider == NULL)
|
||||
{
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_css_provider_load_from_string (provider, css);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
@@ -1294,18 +1294,18 @@ add_axis (hb_face_t *hb_face,
|
||||
|
||||
axis_label = gtk_label_new (name);
|
||||
gtk_widget_set_halign (axis_label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (axis_label, GTK_ALIGN_BASELINE);
|
||||
gtk_widget_set_valign (axis_label, GTK_ALIGN_BASELINE_FILL);
|
||||
gtk_grid_attach (GTK_GRID (demo->variations_grid), axis_label, 0, i, 1, 1);
|
||||
adjustment = gtk_adjustment_new (value, ax->min_value, ax->max_value,
|
||||
1.0, 10.0, 0.0);
|
||||
axis_scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adjustment);
|
||||
gtk_scale_add_mark (GTK_SCALE (axis_scale), ax->default_value, GTK_POS_TOP, NULL);
|
||||
gtk_widget_set_valign (axis_scale, GTK_ALIGN_BASELINE);
|
||||
gtk_widget_set_valign (axis_scale, GTK_ALIGN_BASELINE_FILL);
|
||||
gtk_widget_set_hexpand (axis_scale, TRUE);
|
||||
gtk_widget_set_size_request (axis_scale, 100, -1);
|
||||
gtk_grid_attach (GTK_GRID (demo->variations_grid), axis_scale, 1, i, 1, 1);
|
||||
axis_entry = gtk_entry_new ();
|
||||
gtk_widget_set_valign (axis_entry, GTK_ALIGN_BASELINE);
|
||||
gtk_widget_set_valign (axis_entry, GTK_ALIGN_BASELINE_FILL);
|
||||
gtk_editable_set_width_chars (GTK_EDITABLE (axis_entry), 4);
|
||||
gtk_editable_set_max_width_chars (GTK_EDITABLE (axis_entry), 4);
|
||||
gtk_widget_set_hexpand (axis_entry, FALSE);
|
||||
@@ -1562,14 +1562,14 @@ update_font_variations (void)
|
||||
label = gtk_label_new ("Instance");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE_FILL);
|
||||
gtk_grid_attach (GTK_GRID (demo->variations_grid), label, 0, -1, 1, 1);
|
||||
|
||||
strings = gtk_string_list_new (NULL);
|
||||
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
|
||||
|
||||
gtk_widget_set_halign (combo, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (combo, GTK_ALIGN_BASELINE);
|
||||
gtk_widget_set_valign (combo, GTK_ALIGN_BASELINE_FILL);
|
||||
|
||||
gtk_string_list_append (strings, "");
|
||||
|
||||
|
@@ -42,8 +42,8 @@ val_to_xy (GtkFontPlane *plane,
|
||||
double u, v;
|
||||
int width, height;
|
||||
|
||||
width = gtk_widget_get_allocated_width (GTK_WIDGET (plane));
|
||||
height = gtk_widget_get_allocated_height (GTK_WIDGET (plane));
|
||||
width = gtk_widget_get_width (GTK_WIDGET (plane));
|
||||
height = gtk_widget_get_height (GTK_WIDGET (plane));
|
||||
|
||||
u = adjustment_get_normalized_value (plane->width_adj);
|
||||
v = adjustment_get_normalized_value (plane->weight_adj);
|
||||
@@ -62,8 +62,8 @@ plane_snapshot (GtkWidget *widget,
|
||||
cairo_t *cr;
|
||||
|
||||
val_to_xy (plane, &x, &y);
|
||||
width = gtk_widget_get_allocated_width (widget);
|
||||
height = gtk_widget_get_allocated_height (widget);
|
||||
width = gtk_widget_get_width (widget);
|
||||
height = gtk_widget_get_height (widget);
|
||||
|
||||
cr = gtk_snapshot_append_cairo (snapshot,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
@@ -131,8 +131,8 @@ update_value (GtkFontPlane *plane,
|
||||
GtkWidget *widget = GTK_WIDGET (plane);
|
||||
double u, v;
|
||||
|
||||
u = CLAMP (x * (1.0 / gtk_widget_get_allocated_width (widget)), 0, 1);
|
||||
v = CLAMP (1 - y * (1.0 / gtk_widget_get_allocated_height (widget)), 0, 1);
|
||||
u = CLAMP (x * (1.0 / gtk_widget_get_width (widget)), 0, 1);
|
||||
v = CLAMP (1 - y * (1.0 / gtk_widget_get_height (widget)), 0, 1);
|
||||
|
||||
adjustment_set_normalized_value (plane->width_adj, u);
|
||||
adjustment_set_normalized_value (plane->weight_adj, v);
|
||||
|
@@ -337,7 +337,7 @@ create_gltransition_window (GtkWidget *do_widget)
|
||||
1, 1, 1, 1);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
|
||||
gtk_css_provider_load_from_string (provider, "button.small { padding: 0; }");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
@@ -27,24 +27,17 @@ G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_SHADER_PAINTABLE (gsk_shader_paintable_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GskShaderPaintable, gsk_shader_paintable, GSK, SHADER_PAINTABLE, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkPaintable * gsk_shader_paintable_new (GskGLShader *shader,
|
||||
GBytes *data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskGLShader * gsk_shader_paintable_get_shader (GskShaderPaintable *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gsk_shader_paintable_set_shader (GskShaderPaintable *self,
|
||||
GskGLShader *shader);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GBytes * gsk_shader_paintable_get_args (GskShaderPaintable *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gsk_shader_paintable_set_args (GskShaderPaintable *self,
|
||||
GBytes *data);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gsk_shader_paintable_update_time (GskShaderPaintable *self,
|
||||
int time_idx,
|
||||
gint64 frame_time);
|
||||
|
@@ -370,7 +370,7 @@ do_iconscroll (GtkWidget *do_widget)
|
||||
set_widget_type (0);
|
||||
|
||||
label = GTK_WIDGET (gtk_builder_get_object (builder, "fps_label"));
|
||||
id = g_timeout_add (500, update_fps, label);
|
||||
id = g_timeout_add_full (G_PRIORITY_HIGH, 500, update_fps, label, NULL);
|
||||
g_object_set_data_full (G_OBJECT (label), "timeout",
|
||||
GUINT_TO_POINTER (id), remove_timeout);
|
||||
|
||||
|
@@ -64,6 +64,8 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="short_time_label">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="label" translatable="yes">38m</property>
|
||||
<style>
|
||||
|
@@ -14,138 +14,7 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Create an object that wraps GSettingsSchemaKey because that's a boxed type */
|
||||
typedef struct _SettingsKey SettingsKey;
|
||||
struct _SettingsKey
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GSettings *settings;
|
||||
GSettingsSchemaKey *key;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_NAME,
|
||||
PROP_SUMMARY,
|
||||
PROP_DESCRIPTION,
|
||||
PROP_VALUE,
|
||||
PROP_TYPE,
|
||||
PROP_DEFAULT_VALUE,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
#define SETTINGS_TYPE_KEY (settings_key_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (SettingsKey, settings_key, SETTINGS, KEY, GObject);
|
||||
|
||||
G_DEFINE_TYPE (SettingsKey, settings_key, G_TYPE_OBJECT);
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
static void
|
||||
settings_key_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SettingsKey *self = SETTINGS_KEY (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_DESCRIPTION:
|
||||
g_value_set_string (value, g_settings_schema_key_get_description (self->key));
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, g_settings_schema_key_get_name (self->key));
|
||||
break;
|
||||
|
||||
case PROP_SUMMARY:
|
||||
g_value_set_string (value, g_settings_schema_key_get_summary (self->key));
|
||||
break;
|
||||
|
||||
case PROP_VALUE:
|
||||
{
|
||||
GVariant *variant = g_settings_get_value (self->settings, g_settings_schema_key_get_name (self->key));
|
||||
g_value_take_string (value, g_variant_print (variant, FALSE));
|
||||
g_variant_unref (variant);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_TYPE:
|
||||
{
|
||||
const GVariantType *type = g_settings_schema_key_get_value_type (self->key);
|
||||
g_value_set_string (value, g_variant_type_peek_string (type));
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_DEFAULT_VALUE:
|
||||
{
|
||||
GVariant *variant = g_settings_schema_key_get_default_value (self->key);
|
||||
g_value_take_string (value, g_variant_print (variant, FALSE));
|
||||
g_variant_unref (variant);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
settings_key_finalize (GObject *object)
|
||||
{
|
||||
SettingsKey *self = SETTINGS_KEY (object);
|
||||
|
||||
g_object_unref (self->settings);
|
||||
g_settings_schema_key_unref (self->key);
|
||||
|
||||
G_OBJECT_CLASS (settings_key_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_key_class_init (SettingsKeyClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->finalize = settings_key_finalize;
|
||||
gobject_class->get_property = settings_key_get_property;
|
||||
|
||||
properties[PROP_DESCRIPTION] =
|
||||
g_param_spec_string ("description", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_NAME] =
|
||||
g_param_spec_string ("name", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_SUMMARY] =
|
||||
g_param_spec_string ("summary", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_VALUE] =
|
||||
g_param_spec_string ("value", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_TYPE] =
|
||||
g_param_spec_string ("type", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_DEFAULT_VALUE] =
|
||||
g_param_spec_string ("default-value", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_key_init (SettingsKey *self)
|
||||
{
|
||||
}
|
||||
|
||||
static SettingsKey *
|
||||
settings_key_new (GSettings *settings,
|
||||
GSettingsSchemaKey *key)
|
||||
{
|
||||
SettingsKey *result = g_object_new (SETTINGS_TYPE_KEY, NULL);
|
||||
|
||||
result->settings = g_object_ref (settings);
|
||||
result->key = g_settings_schema_key_ref (key);
|
||||
|
||||
return result;
|
||||
}
|
||||
#include "settings-key.h"
|
||||
|
||||
static void
|
||||
item_value_changed (GtkEditableLabel *label,
|
||||
@@ -153,6 +22,7 @@ item_value_changed (GtkEditableLabel *label,
|
||||
GtkColumnViewCell *cell)
|
||||
{
|
||||
SettingsKey *self;
|
||||
GSettingsSchemaKey *key;
|
||||
const char *text;
|
||||
const GVariantType *type;
|
||||
GVariant *variant;
|
||||
@@ -163,9 +33,10 @@ item_value_changed (GtkEditableLabel *label,
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (label));
|
||||
|
||||
self = gtk_column_view_cell_get_item (cell);
|
||||
key = settings_key_get_key (self);
|
||||
|
||||
type = g_settings_schema_key_get_value_type (self->key);
|
||||
name = g_settings_schema_key_get_name (self->key);
|
||||
type = g_settings_schema_key_get_value_type (key);
|
||||
name = g_settings_schema_key_get_name (key);
|
||||
|
||||
variant = g_variant_parse (type, text, NULL, NULL, &error);
|
||||
if (!variant)
|
||||
@@ -175,13 +46,13 @@ item_value_changed (GtkEditableLabel *label,
|
||||
goto revert;
|
||||
}
|
||||
|
||||
if (!g_settings_schema_key_range_check (self->key, variant))
|
||||
if (!g_settings_schema_key_range_check (key, variant))
|
||||
{
|
||||
g_warning ("Not a valid value for %s", name);
|
||||
goto revert;
|
||||
}
|
||||
|
||||
g_settings_set_value (self->settings, name, variant);
|
||||
g_settings_set_value (settings_key_get_settings (self), name, variant);
|
||||
g_variant_unref (variant);
|
||||
return;
|
||||
|
||||
|
230
demos/gtk-demo/listview_settings2.c
Normal file
230
demos/gtk-demo/listview_settings2.c
Normal file
@@ -0,0 +1,230 @@
|
||||
/* Lists/Alternative Settings
|
||||
* #Keywords: GtkListHeaderFactory, GtkSectionModel
|
||||
*
|
||||
* This demo shows an alternative settings viewer for GSettings.
|
||||
*
|
||||
* It demonstrates how to implement support for sections with GtkListView.
|
||||
*
|
||||
* It also shows how to quickly flatten a large tree of items into a list
|
||||
* that can be filtered to find the items one is looking for.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "settings-key.h"
|
||||
|
||||
static void
|
||||
item_value_changed (GtkEditableLabel *label,
|
||||
GParamSpec *pspec,
|
||||
GtkColumnViewCell *cell)
|
||||
{
|
||||
SettingsKey *self;
|
||||
GSettingsSchemaKey *key;
|
||||
const char *text;
|
||||
const GVariantType *type;
|
||||
GVariant *variant;
|
||||
GError *error = NULL;
|
||||
const char *name;
|
||||
char *value;
|
||||
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (label));
|
||||
|
||||
self = gtk_column_view_cell_get_item (cell);
|
||||
key = settings_key_get_key (self);
|
||||
|
||||
type = g_settings_schema_key_get_value_type (key);
|
||||
name = g_settings_schema_key_get_name (key);
|
||||
|
||||
variant = g_variant_parse (type, text, NULL, NULL, &error);
|
||||
if (!variant)
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
goto revert;
|
||||
}
|
||||
|
||||
if (!g_settings_schema_key_range_check (key, variant))
|
||||
{
|
||||
g_warning ("Not a valid value for %s", name);
|
||||
goto revert;
|
||||
}
|
||||
|
||||
g_settings_set_value (settings_key_get_settings (self), name, variant);
|
||||
g_variant_unref (variant);
|
||||
return;
|
||||
|
||||
revert:
|
||||
gtk_widget_error_bell (GTK_WIDGET (label));
|
||||
|
||||
g_object_get (self, "value", &value, NULL);
|
||||
gtk_editable_set_text (GTK_EDITABLE (label), value);
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
static int
|
||||
strvcmp (gconstpointer p1,
|
||||
gconstpointer p2)
|
||||
{
|
||||
const char * const *s1 = p1;
|
||||
const char * const *s2 = p2;
|
||||
|
||||
return strcmp (*s1, *s2);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
map_settings_to_keys (gpointer item,
|
||||
gpointer unused)
|
||||
{
|
||||
GSettings *settings = item;
|
||||
GSettingsSchema *schema;
|
||||
GListStore *store;
|
||||
char **keys;
|
||||
guint i;
|
||||
|
||||
g_object_get (settings, "settings-schema", &schema, NULL);
|
||||
|
||||
store = g_list_store_new (SETTINGS_TYPE_KEY);
|
||||
|
||||
keys = g_settings_schema_list_keys (schema);
|
||||
|
||||
for (i = 0; keys[i] != NULL; i++)
|
||||
{
|
||||
GSettingsSchemaKey *almost_there = g_settings_schema_get_key (schema, keys[i]);
|
||||
SettingsKey *finally = settings_key_new (settings, almost_there);
|
||||
g_list_store_append (store, finally);
|
||||
g_object_unref (finally);
|
||||
g_settings_schema_key_unref (almost_there);
|
||||
}
|
||||
|
||||
g_strfreev (keys);
|
||||
g_settings_schema_unref (schema);
|
||||
g_object_unref (settings);
|
||||
|
||||
return store;
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
create_settings_model (gpointer item,
|
||||
gpointer unused)
|
||||
{
|
||||
GSettings *settings = item;
|
||||
char **schemas;
|
||||
GListStore *result;
|
||||
guint i;
|
||||
|
||||
if (settings == NULL)
|
||||
{
|
||||
g_settings_schema_source_list_schemas (g_settings_schema_source_get_default (),
|
||||
TRUE,
|
||||
&schemas,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
schemas = g_settings_list_children (settings);
|
||||
}
|
||||
|
||||
if (schemas == NULL || schemas[0] == NULL)
|
||||
{
|
||||
g_free (schemas);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
qsort (schemas, g_strv_length (schemas), sizeof (char *), strvcmp);
|
||||
|
||||
result = g_list_store_new (G_TYPE_SETTINGS);
|
||||
for (i = 0; schemas[i] != NULL; i++)
|
||||
{
|
||||
GSettings *child;
|
||||
|
||||
if (settings == NULL)
|
||||
child = g_settings_new (schemas[i]);
|
||||
else
|
||||
child = g_settings_get_child (settings, schemas[i]);
|
||||
|
||||
g_list_store_append (result, child);
|
||||
g_object_unref (child);
|
||||
}
|
||||
|
||||
g_strfreev (schemas);
|
||||
|
||||
return G_LIST_MODEL (result);
|
||||
}
|
||||
|
||||
static void
|
||||
search_enabled (GtkSearchEntry *entry)
|
||||
{
|
||||
gtk_editable_set_text (GTK_EDITABLE (entry), "");
|
||||
}
|
||||
|
||||
static void
|
||||
stop_search (GtkSearchEntry *entry,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_editable_set_text (GTK_EDITABLE (entry), "");
|
||||
}
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
GtkWidget *
|
||||
do_listview_settings2 (GtkWidget *do_widget)
|
||||
{
|
||||
if (window == NULL)
|
||||
{
|
||||
GtkListView *listview;
|
||||
GListModel *model;
|
||||
GtkTreeListModel *treemodel;
|
||||
GtkNoSelection *selection;
|
||||
GtkBuilderScope *scope;
|
||||
GtkBuilder *builder;
|
||||
GError *error = NULL;
|
||||
GtkFilter *filter;
|
||||
|
||||
g_type_ensure (SETTINGS_TYPE_KEY);
|
||||
|
||||
scope = gtk_builder_cscope_new ();
|
||||
gtk_builder_cscope_add_callback (scope, search_enabled);
|
||||
gtk_builder_cscope_add_callback (scope, stop_search);
|
||||
gtk_builder_cscope_add_callback (scope, settings_key_get_search_string);
|
||||
gtk_builder_cscope_add_callback (scope, item_value_changed);
|
||||
|
||||
builder = gtk_builder_new ();
|
||||
gtk_builder_set_scope (builder, scope);
|
||||
g_object_unref (scope);
|
||||
|
||||
gtk_builder_add_from_resource (builder, "/listview_settings2/listview_settings2.ui", &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
|
||||
|
||||
listview = GTK_LIST_VIEW (gtk_builder_get_object (builder, "listview"));
|
||||
filter = GTK_FILTER (gtk_builder_get_object (builder, "filter"));
|
||||
|
||||
model = create_settings_model (NULL, NULL);
|
||||
treemodel = gtk_tree_list_model_new (model,
|
||||
TRUE,
|
||||
TRUE,
|
||||
create_settings_model,
|
||||
NULL,
|
||||
NULL);
|
||||
model = G_LIST_MODEL (gtk_map_list_model_new (G_LIST_MODEL (treemodel), map_settings_to_keys, NULL, NULL));
|
||||
model = G_LIST_MODEL (gtk_flatten_list_model_new (model));
|
||||
model = G_LIST_MODEL (gtk_filter_list_model_new (model, g_object_ref (filter)));
|
||||
selection = gtk_no_selection_new (model);
|
||||
|
||||
gtk_list_view_set_model (GTK_LIST_VIEW (listview), GTK_SELECTION_MODEL (selection));
|
||||
g_object_unref (selection);
|
||||
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
130
demos/gtk-demo/listview_settings2.ui
Normal file
130
demos/gtk-demo/listview_settings2.ui
Normal file
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkStringFilter" id="filter">
|
||||
<property name="expression">
|
||||
<closure type="gchararray" function="settings_key_get_search_string" />
|
||||
</property>
|
||||
<property name="search" bind-source="entry" bind-property="text" />
|
||||
</object>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="title" translatable="yes">Settings</property>
|
||||
<property name="default-width">640</property>
|
||||
<property name="default-height">480</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<child type="end">
|
||||
<object class="GtkToggleButton" id="search_button">
|
||||
<property name="icon-name">system-search-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkSearchBar">
|
||||
<property name="search-mode-enabled" bind-source="search_button" bind-property="active" bind-flags="bidirectional"/>
|
||||
<signal name="notify::search-mode-enabled" handler="search_enabled" object="entry"/>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="entry">
|
||||
<signal name="stop-search" handler="stop_search"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<child>
|
||||
<object class="GtkListView" id="listview">
|
||||
<property name="vexpand">1</property>
|
||||
<style>
|
||||
<class name="rich-list"/>
|
||||
</style>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="name" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
<property name="xalign">0</property>
|
||||
<property name="ellipsize">end</property>
|
||||
<binding name="label">
|
||||
<lookup name="summary" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="halign">end</property>
|
||||
<binding name="text">
|
||||
<lookup name="value" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
<signal name="notify::label" handler="item_value_changed"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="header-factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListHeader">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="schema" type="GSettings">
|
||||
<lookup name="settings" type="SettingsKey">
|
||||
<lookup name="item">GtkListHeader</lookup>
|
||||
</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
@@ -367,7 +367,7 @@ do_listview_ucd (GtkWidget *do_widget)
|
||||
gtk_label_set_width_chars (GTK_LABEL (label), 2);
|
||||
gtk_widget_add_css_class (label, "enormous");
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, "label.enormous { font-size: 80px; }", -1);
|
||||
gtk_css_provider_load_from_string (provider, "label.enormous { font-size: 80px; }");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_box_append (GTK_BOX (box), label);
|
||||
|
@@ -57,6 +57,7 @@ demos = files([
|
||||
'listview_minesweeper.c',
|
||||
'listview_selections.c',
|
||||
'listview_settings.c',
|
||||
'listview_settings2.c',
|
||||
'listview_ucd.c',
|
||||
'listview_weather.c',
|
||||
'listview_words.c',
|
||||
@@ -131,6 +132,7 @@ extra_demo_sources = files([
|
||||
'demo4widget.c',
|
||||
'pixbufpaintable.c',
|
||||
'script-names.c',
|
||||
'settings-key.c',
|
||||
'unicode-names.c',
|
||||
'suggestionentry.c',
|
||||
'language-names.c',
|
||||
@@ -233,8 +235,7 @@ endif
|
||||
demo_cflags = []
|
||||
foreach flag: common_cflags
|
||||
if flag not in ['-Werror=missing-prototypes', '-Wmissing-prototypes',
|
||||
'-Werror=missing-declarations', '-Wmissing-declarations',
|
||||
'-fvisibility=hidden']
|
||||
'-Werror=missing-declarations', '-Wmissing-declarations']
|
||||
demo_cflags += flag
|
||||
endif
|
||||
endforeach
|
||||
|
@@ -24,6 +24,7 @@ typedef struct
|
||||
GdkRGBA draw_color;
|
||||
GtkPadController *pad_controller;
|
||||
double brush_size;
|
||||
GtkGesture *gesture;
|
||||
} DrawingArea;
|
||||
|
||||
typedef struct
|
||||
@@ -260,7 +261,7 @@ drawing_area_apply_stroke (DrawingArea *area,
|
||||
double y,
|
||||
double pressure)
|
||||
{
|
||||
if (gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER)
|
||||
if (tool && gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER)
|
||||
{
|
||||
cairo_set_line_width (area->cr, 10 * pressure * area->brush_size);
|
||||
cairo_set_operator (area->cr, CAIRO_OPERATOR_DEST_OUT);
|
||||
@@ -311,7 +312,9 @@ stylus_gesture_motion (GtkGestureStylus *gesture,
|
||||
drawing_area_apply_stroke (area, tool,
|
||||
backlog[i].axes[GDK_AXIS_X],
|
||||
backlog[i].axes[GDK_AXIS_Y],
|
||||
backlog[i].axes[GDK_AXIS_PRESSURE]);
|
||||
backlog[i].flags & GDK_AXIS_FLAG_PRESSURE
|
||||
? backlog[i].axes[GDK_AXIS_PRESSURE]
|
||||
: 1);
|
||||
}
|
||||
|
||||
g_free (backlog);
|
||||
@@ -341,6 +344,8 @@ drawing_area_init (DrawingArea *area)
|
||||
|
||||
area->draw_color = (GdkRGBA) { 0, 0, 0, 1 };
|
||||
area->brush_size = 1;
|
||||
|
||||
area->gesture = gesture;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
@@ -379,6 +384,12 @@ drawing_area_color_set (DrawingArea *area,
|
||||
gtk_color_dialog_button_set_rgba (button, color);
|
||||
}
|
||||
|
||||
static GtkGesture *
|
||||
drawing_area_get_gesture (DrawingArea *area)
|
||||
{
|
||||
return area->gesture;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_paint (GtkWidget *toplevel)
|
||||
{
|
||||
@@ -386,7 +397,7 @@ do_paint (GtkWidget *toplevel)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *draw_area, *headerbar, *colorbutton;
|
||||
GtkWidget *draw_area, *headerbar, *button;
|
||||
|
||||
window = gtk_window_new ();
|
||||
|
||||
@@ -395,15 +406,22 @@ do_paint (GtkWidget *toplevel)
|
||||
|
||||
headerbar = gtk_header_bar_new ();
|
||||
|
||||
colorbutton = gtk_color_dialog_button_new (gtk_color_dialog_new ());
|
||||
g_signal_connect (colorbutton, "notify::rgba",
|
||||
button = gtk_color_dialog_button_new (gtk_color_dialog_new ());
|
||||
g_signal_connect (button, "notify::rgba",
|
||||
G_CALLBACK (color_button_color_set), draw_area);
|
||||
g_signal_connect (draw_area, "color-set",
|
||||
G_CALLBACK (drawing_area_color_set), colorbutton);
|
||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (colorbutton),
|
||||
G_CALLBACK (drawing_area_color_set), button);
|
||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (button),
|
||||
&(GdkRGBA) { 0, 0, 0, 1 });
|
||||
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), colorbutton);
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), button);
|
||||
|
||||
button = gtk_check_button_new_with_label ("Stylus only");
|
||||
g_object_bind_property (button, "active",
|
||||
drawing_area_get_gesture ((DrawingArea *)draw_area), "stylus-only",
|
||||
G_BINDING_SYNC_CREATE);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (headerbar), button);
|
||||
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Paint");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
@@ -384,7 +384,7 @@ create_board (GtkWidget *window)
|
||||
"}";
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_css_provider_load_from_string (provider, css);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
|
165
demos/gtk-demo/settings-key.c
Normal file
165
demos/gtk-demo/settings-key.c
Normal file
@@ -0,0 +1,165 @@
|
||||
#include "settings-key.h"
|
||||
|
||||
/* Create an object that wraps GSettingsSchemaKey because that's a boxed type */
|
||||
struct _SettingsKey
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GSettings *settings;
|
||||
GSettingsSchemaKey *key;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_NAME,
|
||||
PROP_SETTINGS,
|
||||
PROP_SUMMARY,
|
||||
PROP_DESCRIPTION,
|
||||
PROP_VALUE,
|
||||
PROP_TYPE,
|
||||
PROP_DEFAULT_VALUE,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (SettingsKey, settings_key, G_TYPE_OBJECT);
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
static void
|
||||
settings_key_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SettingsKey *self = SETTINGS_KEY (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_DESCRIPTION:
|
||||
g_value_set_string (value, g_settings_schema_key_get_description (self->key));
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, g_settings_schema_key_get_name (self->key));
|
||||
break;
|
||||
|
||||
case PROP_SUMMARY:
|
||||
g_value_set_string (value, g_settings_schema_key_get_summary (self->key));
|
||||
break;
|
||||
|
||||
case PROP_VALUE:
|
||||
{
|
||||
GVariant *variant = g_settings_get_value (self->settings, g_settings_schema_key_get_name (self->key));
|
||||
g_value_take_string (value, g_variant_print (variant, FALSE));
|
||||
g_variant_unref (variant);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_TYPE:
|
||||
{
|
||||
const GVariantType *type = g_settings_schema_key_get_value_type (self->key);
|
||||
g_value_set_string (value, g_variant_type_peek_string (type));
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_DEFAULT_VALUE:
|
||||
{
|
||||
GVariant *variant = g_settings_schema_key_get_default_value (self->key);
|
||||
g_value_take_string (value, g_variant_print (variant, FALSE));
|
||||
g_variant_unref (variant);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_SETTINGS:
|
||||
g_value_set_object (value, self->settings);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
settings_key_finalize (GObject *object)
|
||||
{
|
||||
SettingsKey *self = SETTINGS_KEY (object);
|
||||
|
||||
g_object_unref (self->settings);
|
||||
g_settings_schema_key_unref (self->key);
|
||||
|
||||
G_OBJECT_CLASS (settings_key_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_key_class_init (SettingsKeyClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->finalize = settings_key_finalize;
|
||||
gobject_class->get_property = settings_key_get_property;
|
||||
|
||||
properties[PROP_DESCRIPTION] =
|
||||
g_param_spec_string ("description", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_NAME] =
|
||||
g_param_spec_string ("name", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_SETTINGS] =
|
||||
g_param_spec_object ("settings", NULL, NULL, G_TYPE_SETTINGS, G_PARAM_READABLE);
|
||||
properties[PROP_SUMMARY] =
|
||||
g_param_spec_string ("summary", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_VALUE] =
|
||||
g_param_spec_string ("value", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_TYPE] =
|
||||
g_param_spec_string ("type", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_DEFAULT_VALUE] =
|
||||
g_param_spec_string ("default-value", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_key_init (SettingsKey *self)
|
||||
{
|
||||
}
|
||||
|
||||
SettingsKey *
|
||||
settings_key_new (GSettings *settings,
|
||||
GSettingsSchemaKey *key)
|
||||
{
|
||||
SettingsKey *result = g_object_new (SETTINGS_TYPE_KEY, NULL);
|
||||
|
||||
result->settings = g_object_ref (settings);
|
||||
result->key = g_settings_schema_key_ref (key);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GSettingsSchemaKey *
|
||||
settings_key_get_key (SettingsKey *self)
|
||||
{
|
||||
return self->key;
|
||||
}
|
||||
|
||||
GSettings *
|
||||
settings_key_get_settings (SettingsKey *self)
|
||||
{
|
||||
return self->settings;
|
||||
}
|
||||
|
||||
char *
|
||||
settings_key_get_search_string (SettingsKey *self)
|
||||
{
|
||||
char *schema, *result;
|
||||
|
||||
g_object_get (self->settings, "schema-id", &schema, NULL);
|
||||
|
||||
result = g_strconcat (g_settings_schema_key_get_name (self->key), " ",
|
||||
g_settings_schema_key_get_summary (self->key), " ",
|
||||
schema,
|
||||
NULL);
|
||||
|
||||
g_free (schema);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
17
demos/gtk-demo/settings-key.h
Normal file
17
demos/gtk-demo/settings-key.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Create an object that wraps GSettingsSchemaKey because that's a boxed type */
|
||||
typedef struct _SettingsKey SettingsKey;
|
||||
#define SETTINGS_TYPE_KEY (settings_key_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (SettingsKey, settings_key, SETTINGS, KEY, GObject);
|
||||
|
||||
SettingsKey * settings_key_new (GSettings *settings,
|
||||
GSettingsSchemaKey *key);
|
||||
|
||||
GSettingsSchemaKey * settings_key_get_key (SettingsKey *self);
|
||||
GSettings * settings_key_get_settings (SettingsKey *self);
|
||||
char * settings_key_get_search_string (SettingsKey *self);
|
@@ -28,14 +28,14 @@ add_row (GtkGrid *table,
|
||||
|
||||
label = gtk_label_new_with_mnemonic (label_text);
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE_FILL);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_grid_attach (table, label, 0, row, 1, 1);
|
||||
|
||||
dropdown = gtk_drop_down_new_from_strings (options);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), dropdown);
|
||||
gtk_widget_set_halign (dropdown, GTK_ALIGN_END);
|
||||
gtk_widget_set_valign (dropdown, GTK_ALIGN_BASELINE);
|
||||
gtk_widget_set_valign (dropdown, GTK_ALIGN_BASELINE_FILL);
|
||||
gtk_size_group_add_widget (size_group, dropdown);
|
||||
gtk_grid_attach (table, dropdown, 1, row, 1, 1);
|
||||
}
|
||||
|
@@ -471,7 +471,7 @@ suggestion_entry_size_allocate (GtkWidget *widget,
|
||||
&(GtkAllocation) { width - arrow_nat, 0, arrow_nat, height },
|
||||
baseline);
|
||||
|
||||
gtk_widget_set_size_request (self->popup, gtk_widget_get_allocated_width (GTK_WIDGET (self)), -1);
|
||||
gtk_widget_set_size_request (self->popup, gtk_widget_get_width (GTK_WIDGET (self)), -1);
|
||||
gtk_widget_queue_resize (self->popup);
|
||||
|
||||
gtk_popover_present (GTK_POPOVER (self->popup));
|
||||
|
@@ -1,5 +1,5 @@
|
||||
gen_demo_header = find_program('../build-aux/meson/gen-demo-header.py')
|
||||
demo_profile = get_option('profile')
|
||||
demo_profile = get_option('demo-profile')
|
||||
|
||||
demo_conf_h = declare_dependency(
|
||||
sources: custom_target('demo-header',
|
||||
|
@@ -78,6 +78,8 @@ gtk_renderer_paintable_paintable_snapshot (GdkPaintable *paintable,
|
||||
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (texture), snapshot, width, height);
|
||||
g_object_unref (texture);
|
||||
|
||||
gsk_render_node_unref (node);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@@ -201,7 +201,7 @@ node_editor_application_startup (GApplication *app)
|
||||
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_css_provider_load_from_string (provider, css);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
@@ -64,6 +64,7 @@ struct _NodeEditorWindow
|
||||
GListStore *renderers;
|
||||
GskRenderNode *node;
|
||||
|
||||
GFile *file;
|
||||
GFileMonitor *file_monitor;
|
||||
|
||||
GArray *errors;
|
||||
@@ -544,12 +545,14 @@ node_editor_window_load (NodeEditorWindow *self,
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
g_clear_object (&self->file);
|
||||
g_clear_object (&self->file_monitor);
|
||||
|
||||
if (!load_file_contents (self, file))
|
||||
return FALSE;
|
||||
|
||||
self->file_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error);
|
||||
self->file = g_object_ref (file);
|
||||
self->file_monitor = g_file_monitor_file (self->file, G_FILE_MONITOR_NONE, NULL, &error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
@@ -586,13 +589,21 @@ static void
|
||||
show_open_filechooser (NodeEditorWindow *self)
|
||||
{
|
||||
GtkFileDialog *dialog;
|
||||
GFile *cwd;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Open node file");
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_initial_folder (dialog, cwd);
|
||||
g_object_unref (cwd);
|
||||
if (self->file)
|
||||
{
|
||||
gtk_file_dialog_set_initial_file (dialog, self->file);
|
||||
}
|
||||
else
|
||||
{
|
||||
GFile *cwd;
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_initial_folder (dialog, cwd);
|
||||
g_object_unref (cwd);
|
||||
}
|
||||
|
||||
gtk_file_dialog_open (dialog, GTK_WINDOW (self),
|
||||
NULL, open_response_cb, self);
|
||||
g_object_unref (dialog);
|
||||
@@ -650,14 +661,21 @@ save_cb (GtkWidget *button,
|
||||
NodeEditorWindow *self)
|
||||
{
|
||||
GtkFileDialog *dialog;
|
||||
GFile *cwd;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Save node");
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_initial_folder (dialog, cwd);
|
||||
gtk_file_dialog_set_initial_name (dialog, "demo.node");
|
||||
g_object_unref (cwd);
|
||||
if (self->file)
|
||||
{
|
||||
gtk_file_dialog_set_initial_file (dialog, self->file);
|
||||
}
|
||||
else
|
||||
{
|
||||
GFile *cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_initial_folder (dialog, cwd);
|
||||
gtk_file_dialog_set_initial_name (dialog, "demo.node");
|
||||
g_object_unref (cwd);
|
||||
}
|
||||
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
NULL,
|
||||
@@ -1091,6 +1109,8 @@ node_editor_window_finalize (GObject *object)
|
||||
|
||||
g_clear_pointer (&self->node, gsk_render_node_unref);
|
||||
g_clear_object (&self->renderers);
|
||||
g_clear_object (&self->file_monitor);
|
||||
g_clear_object (&self->file);
|
||||
|
||||
G_OBJECT_CLASS (node_editor_window_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -1170,11 +1190,362 @@ node_editor_window_unrealize (GtkWidget *widget)
|
||||
GTK_WIDGET_CLASS (node_editor_window_parent_class)->unrealize (widget);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
NodeEditorWindow *self;
|
||||
GtkTextIter start, end;
|
||||
} Selection;
|
||||
|
||||
static void
|
||||
color_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GtkColorDialog *dialog = GTK_COLOR_DIALOG (source);
|
||||
Selection *selection = data;
|
||||
NodeEditorWindow *self = selection->self;
|
||||
GdkRGBA *color;
|
||||
char *text;
|
||||
GError *error = NULL;
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
color = gtk_color_dialog_choose_rgba_finish (dialog, result, &error);
|
||||
if (!color)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
g_free (selection);
|
||||
return;
|
||||
}
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->text_view));
|
||||
|
||||
text = gdk_rgba_to_string (color);
|
||||
gtk_text_buffer_delete (buffer, &selection->start, &selection->end);
|
||||
gtk_text_buffer_insert (buffer, &selection->start, text, -1);
|
||||
|
||||
g_free (text);
|
||||
gdk_rgba_free (color);
|
||||
g_free (selection);
|
||||
}
|
||||
|
||||
static void
|
||||
font_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFontDialog *dialog = GTK_FONT_DIALOG (source);
|
||||
Selection *selection = data;
|
||||
NodeEditorWindow *self = selection->self;
|
||||
GError *error = NULL;
|
||||
PangoFontDescription *desc;
|
||||
GtkTextBuffer *buffer;
|
||||
char *text;
|
||||
|
||||
desc = gtk_font_dialog_choose_font_finish (dialog, result, &error);
|
||||
if (!desc)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
g_free (selection);
|
||||
return;
|
||||
}
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->text_view));
|
||||
|
||||
text = pango_font_description_to_string (desc);
|
||||
gtk_text_buffer_delete (buffer, &selection->start, &selection->end);
|
||||
gtk_text_buffer_insert (buffer, &selection->start, text, -1);
|
||||
|
||||
g_free (text);
|
||||
pango_font_description_free (desc);
|
||||
g_free (selection);
|
||||
}
|
||||
|
||||
static void
|
||||
file_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
Selection *selection = data;
|
||||
NodeEditorWindow *self = selection->self;
|
||||
GError *error = NULL;
|
||||
GFile *file;
|
||||
GtkTextBuffer *buffer;
|
||||
char *text;
|
||||
|
||||
file = gtk_file_dialog_open_finish (dialog, result, &error);
|
||||
if (!file)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
g_free (selection);
|
||||
return;
|
||||
}
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->text_view));
|
||||
|
||||
text = g_file_get_uri (file);
|
||||
gtk_text_buffer_delete (buffer, &selection->start, &selection->end);
|
||||
gtk_text_buffer_insert (buffer, &selection->start, text, -1);
|
||||
|
||||
g_free (text);
|
||||
g_object_unref (file);
|
||||
g_free (selection);
|
||||
}
|
||||
|
||||
static void
|
||||
key_pressed (GtkEventControllerKey *controller,
|
||||
unsigned int keyval,
|
||||
unsigned int keycode,
|
||||
GdkModifierType state,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *dd = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (controller));
|
||||
Selection *selection = data;
|
||||
NodeEditorWindow *self = selection->self;
|
||||
unsigned int selected;
|
||||
GtkStringList *strings;
|
||||
GtkTextBuffer *buffer;
|
||||
const char *text;
|
||||
|
||||
if (keyval != GDK_KEY_Escape)
|
||||
return;
|
||||
|
||||
strings = GTK_STRING_LIST (gtk_drop_down_get_model (GTK_DROP_DOWN (dd)));
|
||||
selected = gtk_drop_down_get_selected (GTK_DROP_DOWN (dd));
|
||||
text = gtk_string_list_get_string (strings, selected);
|
||||
|
||||
gtk_text_view_remove (GTK_TEXT_VIEW (self->text_view), dd);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->text_view));
|
||||
gtk_text_iter_backward_search (&selection->start, "mode:", 0, NULL, &selection->start, NULL);
|
||||
gtk_text_iter_forward_search (&selection->start, ";", 0, &selection->end, NULL, NULL);
|
||||
gtk_text_buffer_delete (buffer, &selection->start, &selection->end);
|
||||
gtk_text_buffer_insert (buffer, &selection->start, " ", -1);
|
||||
gtk_text_buffer_insert (buffer, &selection->start, text, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
node_editor_window_edit (NodeEditorWindow *self,
|
||||
GtkTextIter *iter)
|
||||
{
|
||||
GtkTextIter start, end;
|
||||
GtkTextBuffer *buffer;
|
||||
Selection *selection;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->text_view));
|
||||
|
||||
gtk_text_iter_set_line_offset (iter, 0);
|
||||
|
||||
if (gtk_text_iter_forward_search (iter, ";", 0, &end, NULL, NULL) &&
|
||||
gtk_text_iter_forward_search (iter, "color:", 0, NULL, &start, &end))
|
||||
{
|
||||
GtkColorDialog *dialog;
|
||||
GdkRGBA color;
|
||||
char *text;
|
||||
|
||||
while (g_unichar_isspace (gtk_text_iter_get_char (&start)))
|
||||
gtk_text_iter_forward_char (&start);
|
||||
|
||||
gtk_text_buffer_select_range (buffer, &start, &end);
|
||||
text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
|
||||
gdk_rgba_parse (&color, text);
|
||||
g_free (text);
|
||||
|
||||
selection = g_new0 (Selection, 1);
|
||||
selection->self = self;
|
||||
selection->start = start;
|
||||
selection->end = end;
|
||||
|
||||
dialog = gtk_color_dialog_new ();
|
||||
gtk_color_dialog_choose_rgba (dialog, GTK_WINDOW (self), &color, NULL, color_cb, selection);
|
||||
}
|
||||
else if (gtk_text_iter_forward_search (iter, ";", 0, &end, NULL, NULL) &&
|
||||
gtk_text_iter_forward_search (iter, "font:", 0, NULL, &start, &end))
|
||||
{
|
||||
GtkFontDialog *dialog;
|
||||
PangoFontDescription *desc;
|
||||
char *text;
|
||||
|
||||
while (g_unichar_isspace (gtk_text_iter_get_char (&start)))
|
||||
gtk_text_iter_forward_char (&start);
|
||||
|
||||
/* Skip the quotes */
|
||||
gtk_text_iter_forward_char (&start);
|
||||
gtk_text_iter_backward_char (&end);
|
||||
|
||||
gtk_text_buffer_select_range (buffer, &start, &end);
|
||||
|
||||
text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
|
||||
desc = pango_font_description_from_string (text);
|
||||
g_free (text);
|
||||
|
||||
selection = g_new0 (Selection, 1);
|
||||
selection->self = self;
|
||||
selection->start = start;
|
||||
selection->end = end;
|
||||
|
||||
dialog = gtk_font_dialog_new ();
|
||||
gtk_font_dialog_choose_font (dialog, GTK_WINDOW (self), desc, NULL, font_cb, selection);
|
||||
pango_font_description_free (desc);
|
||||
}
|
||||
else if (gtk_text_iter_forward_search (iter, ";", 0, &end, NULL, NULL) &&
|
||||
gtk_text_iter_forward_search (iter, "mode:", 0, NULL, &start, &end))
|
||||
{
|
||||
/* Assume we have a blend node, for now */
|
||||
GEnumClass *class;
|
||||
GtkStringList *strings;
|
||||
GtkWidget *dd;
|
||||
GtkTextChildAnchor *anchor;
|
||||
unsigned int selected = 0;
|
||||
GtkEventController *key_controller;
|
||||
gboolean is_blend_mode = FALSE;
|
||||
char *text;
|
||||
|
||||
while (g_unichar_isspace (gtk_text_iter_get_char (&start)))
|
||||
gtk_text_iter_forward_char (&start);
|
||||
|
||||
text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
|
||||
|
||||
strings = gtk_string_list_new (NULL);
|
||||
class = g_type_class_ref (GSK_TYPE_BLEND_MODE);
|
||||
for (unsigned int i = 0; i < class->n_values; i++)
|
||||
{
|
||||
if (strcmp (class->values[i].value_nick, text) == 0)
|
||||
is_blend_mode = TRUE;
|
||||
}
|
||||
g_type_class_unref (class);
|
||||
|
||||
if (is_blend_mode)
|
||||
class = g_type_class_ref (GSK_TYPE_BLEND_MODE);
|
||||
else
|
||||
class = g_type_class_ref (GSK_TYPE_MASK_MODE);
|
||||
|
||||
for (unsigned int i = 0; i < class->n_values; i++)
|
||||
{
|
||||
if (i == 0 && is_blend_mode)
|
||||
gtk_string_list_append (strings, "normal");
|
||||
else
|
||||
gtk_string_list_append (strings, class->values[i].value_nick);
|
||||
|
||||
if (strcmp (class->values[i].value_nick, text) == 0)
|
||||
selected = i;
|
||||
}
|
||||
g_type_class_unref (class);
|
||||
|
||||
gtk_text_buffer_delete (buffer, &start, &end);
|
||||
|
||||
anchor = gtk_text_buffer_create_child_anchor (buffer, &start);
|
||||
dd = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (dd), selected);
|
||||
gtk_text_view_add_child_at_anchor (GTK_TEXT_VIEW (self->text_view), dd, anchor);
|
||||
|
||||
selection = g_new0 (Selection, 1);
|
||||
selection->self = self;
|
||||
selection->start = start;
|
||||
selection->end = end;
|
||||
|
||||
key_controller = gtk_event_controller_key_new ();
|
||||
g_signal_connect (key_controller, "key-pressed", G_CALLBACK (key_pressed), selection);
|
||||
gtk_widget_add_controller (dd, key_controller);
|
||||
}
|
||||
else if (gtk_text_iter_forward_search (iter, ";", 0, &end, NULL, NULL) &&
|
||||
gtk_text_iter_forward_search (iter, "texture:", 0, NULL, &start, &end))
|
||||
{
|
||||
GtkFileDialog *dialog;
|
||||
GtkTextIter skip;
|
||||
char *text;
|
||||
GFile *file;
|
||||
|
||||
while (g_unichar_isspace (gtk_text_iter_get_char (&start)))
|
||||
gtk_text_iter_forward_char (&start);
|
||||
|
||||
skip = start;
|
||||
gtk_text_iter_forward_chars (&skip, strlen ("url(\""));
|
||||
text = gtk_text_iter_get_text (&start, &skip);
|
||||
if (strcmp (text, "url(\"") != 0)
|
||||
{
|
||||
g_free (text);
|
||||
return;
|
||||
}
|
||||
g_free (text);
|
||||
start = skip;
|
||||
|
||||
skip = end;
|
||||
gtk_text_iter_backward_chars (&skip, strlen ("\")"));
|
||||
text = gtk_text_iter_get_text (&skip, &end);
|
||||
if (strcmp (text, "\")") != 0)
|
||||
{
|
||||
g_free (text);
|
||||
return;
|
||||
}
|
||||
g_free (text);
|
||||
end = skip;
|
||||
|
||||
gtk_text_buffer_select_range (buffer, &start, &end);
|
||||
|
||||
text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
|
||||
file = g_file_new_for_uri (text);
|
||||
g_free (text);
|
||||
|
||||
selection = g_new0 (Selection, 1);
|
||||
selection->self = self;
|
||||
selection->start = start;
|
||||
selection->end = end;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_initial_file (dialog, file);
|
||||
gtk_file_dialog_open (dialog, GTK_WINDOW (self), NULL, file_cb, selection);
|
||||
g_object_unref (file);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
click_gesture_pressed (GtkGestureClick *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
double y,
|
||||
NodeEditorWindow *self)
|
||||
{
|
||||
GtkTextIter iter;
|
||||
int bx, by, trailing;
|
||||
GdkModifierType state;
|
||||
|
||||
state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (gesture));
|
||||
if ((state & GDK_CONTROL_MASK) == 0)
|
||||
return;
|
||||
|
||||
gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (self->text_view), GTK_TEXT_WINDOW_TEXT, x, y, &bx, &by);
|
||||
gtk_text_view_get_iter_at_position (GTK_TEXT_VIEW (self->text_view), &iter, &trailing, bx, by);
|
||||
|
||||
node_editor_window_edit (self, &iter);
|
||||
}
|
||||
|
||||
static void
|
||||
edit_action_cb (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameter)
|
||||
{
|
||||
NodeEditorWindow *self = NODE_EDITOR_WINDOW (widget);
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter start, end;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->text_view));
|
||||
gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
|
||||
|
||||
node_editor_window_edit (self, &start);
|
||||
}
|
||||
|
||||
static void
|
||||
node_editor_window_class_init (NodeEditorWindowClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
GtkShortcutTrigger *trigger;
|
||||
GtkShortcutAction *action;
|
||||
GtkShortcut *shortcut;
|
||||
|
||||
object_class->dispose = node_editor_window_dispose;
|
||||
object_class->finalize = node_editor_window_finalize;
|
||||
@@ -1205,6 +1576,14 @@ node_editor_window_class_init (NodeEditorWindowClass *class)
|
||||
gtk_widget_class_bind_template_callback (widget_class, dark_mode_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_picture_drag_prepare_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_picture_drop_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, click_gesture_pressed);
|
||||
|
||||
gtk_widget_class_install_action (widget_class, "smart-edit", NULL, edit_action_cb);
|
||||
|
||||
trigger = gtk_keyval_trigger_new (GDK_KEY_e, GDK_CONTROL_MASK);
|
||||
action = gtk_named_action_new ("smart-edit");
|
||||
shortcut = gtk_shortcut_new (trigger, action);
|
||||
gtk_widget_class_add_shortcut (widget_class, shortcut);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
|
@@ -16,6 +16,14 @@
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<menu id="extra_menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Assisted _Edit</attribute>
|
||||
<attribute name="action">smart-edit</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
|
||||
<object class="GtkPopover" id="testcase_popover">
|
||||
<child>
|
||||
@@ -195,10 +203,17 @@
|
||||
<property name="right-margin">6</property>
|
||||
<property name="bottom-margin">6</property>
|
||||
<property name="has-tooltip">1</property>
|
||||
<property name="extra-menu">extra_menu</property>
|
||||
<signal name="query-tooltip" handler="text_view_query_tooltip_cb"/>
|
||||
<style>
|
||||
<class name="editor" />
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkGestureClick">
|
||||
<property name="button">1</property>
|
||||
<signal name="pressed" handler="click_gesture_pressed"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@@ -193,7 +193,7 @@ Creates a node like `gsk_linear_gradient_node_new()` with the given properties.
|
||||
| property | syntax | default | printed |
|
||||
| -------- | ---------------- | ---------------------- | ----------- |
|
||||
| source | `<node>` | color { } | always |
|
||||
| mode | `<blend-mode>` | alpha | non-default |
|
||||
| mode | `<mask-mode>` | alpha | non-default |
|
||||
| mask | `<node>` | color { } | always |
|
||||
|
||||
Creates a node like `gsk_mask_node_new()` with the given properties.
|
||||
|
@@ -288,7 +288,7 @@ support.
|
||||
If you want to run the testsuite to ensure that your GTK build
|
||||
works, you should enable it with this option.
|
||||
|
||||
### `build-tests`, `build-examples`, `demos`
|
||||
### `build-tests`, `build-examples`, `build-demos`
|
||||
|
||||
By default, GTK will build quite a few tests, examples and demos.
|
||||
While these are useful on a developer system, they are not
|
||||
|
@@ -44,6 +44,10 @@ widgets (although most of the time, the transformation will be a simple 2D trans
|
||||
The transform to go from one widgets coordinate system to another one can be obtained
|
||||
with [method@Gtk.Widget.compute_transform].
|
||||
|
||||
In addition to a size, widgets can optionally have a **_baseline_** to position text on.
|
||||
Containers such as [class@Gtk.Box] may position their children to match up their baselines.
|
||||
[method@Gtk.Widget.get_baseline] returns the y position of the baseline in widget coordinates.
|
||||
|
||||
When widget APIs expect positions or areas, they need to be expressed in this coordinate
|
||||
system, typically called **_widget coordinates_**. GTK provides a number of APIs to translate
|
||||
between different widgets' coordinate systems, such as [method@Gtk.Widget.compute_point]
|
||||
|
@@ -68,6 +68,7 @@ ui_files = [
|
||||
'stackswitcher.ui',
|
||||
'statusbar.ui',
|
||||
'switch.ui',
|
||||
'switch-state.ui',
|
||||
'toggle-button.ui',
|
||||
'video.ui',
|
||||
'volumebutton.ui',
|
||||
|
BIN
docs/reference/gtk/images/switch-state.png
Normal file
BIN
docs/reference/gtk/images/switch-state.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
43
docs/reference/gtk/images/switch-state.ui
Normal file
43
docs/reference/gtk/images/switch-state.ui
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow">
|
||||
<property name="decorated">0</property>
|
||||
<property name="resizable">0</property>
|
||||
<property name="default-width">280</property>
|
||||
<property name="default-height">120</property>
|
||||
<style>
|
||||
<class name="nobackground"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<style>
|
||||
<class name="shadow"/>
|
||||
<class name="background"/>
|
||||
<class name="frame"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">3</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkSwitch">
|
||||
<property name="active">1</property>
|
||||
<property name="state">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSwitch">
|
||||
<property name="active">0</property>
|
||||
<property name="state">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
@@ -258,7 +258,7 @@ Instead of implementing GtkWidget.destroy, you can implement GObject.dispose.
|
||||
GTK 4 removes `gtk_container_add()` and `gtk_container_remove()`. While there
|
||||
is not always a replacement for `gtk_container_remove()` in GTK 3, you can
|
||||
replace many uses of `gtk_container_add()` with equivalent container-specific
|
||||
APIs such as `gtk_box_pack_start()` or `gtk_grid_attach()`, and thereby reduce
|
||||
APIs such as `gtk_grid_attach()`, and thereby reduce
|
||||
the amount of work you have to do at the time of the switch.
|
||||
|
||||
### Review your use of icon resources
|
||||
@@ -402,9 +402,9 @@ is open, use the [property@Gtk.Window:modal] property of the dialog.
|
||||
|
||||
### Adapt to coordinate API changes
|
||||
|
||||
A number of coordinate APIs in GTK 3 had `double` variants:
|
||||
A number of coordinate APIs in GTK 3 had variants taking `int` arguments:
|
||||
`gdk_device_get_surface_at_position()`, `gdk_surface_get_device_position()`.
|
||||
These have been changed to use doubles, and the `double` variants
|
||||
These have been changed to use `double` arguments, and the `int` variants
|
||||
have been removed. Update your code accordingly.
|
||||
|
||||
Any APIs that deal with global (or root) coordinates have been
|
||||
@@ -875,10 +875,10 @@ reference.
|
||||
### Adapt to coordinate API changes
|
||||
|
||||
A number of APIs that are accepting or returning coordinates have
|
||||
been changed from ints to doubles: `gtk_widget_translate_coordinates()`,
|
||||
been changed from `int`s to `double`s: `gtk_widget_translate_coordinates()`,
|
||||
`gtk_fixed_put()`, `gtk_fixed_move()`. This change is mostly transparent,
|
||||
except for cases where out parameters are involved: you need to
|
||||
pass double* now, instead of int*.
|
||||
pass `double*` now, instead of `int*`.
|
||||
|
||||
### Adapt to GtkStyleContext API changes
|
||||
|
||||
|
@@ -119,3 +119,17 @@ it no longer has a resize handle for the window.
|
||||
|
||||
These are very specialized widgets that should better live with the application
|
||||
where they are used.
|
||||
|
||||
## Widget size api changes
|
||||
|
||||
The functions gtk_widget_get_allocated_width() and gtk_widget_get_allocated_height()
|
||||
are going away. In most cases, [method@Gtk.Widget.get_width] and [method@Gtk.Widget.get_height]
|
||||
are suitable replacements. Note that the semantics are slightly different though:
|
||||
the old functions return the size of the CSS border area, while the new functions return
|
||||
the size of the widgets content area. In places where this difference matters, you can
|
||||
use `gtk_widget_compute_bounds (widget, widget, &bounds)` instead.
|
||||
|
||||
The function gtk_widget_get_allocation() is also going away. It does not have a direct
|
||||
replacement, but the previously mentioned alternatives can be used for it too.
|
||||
|
||||
The function gtk_widget_get_allocated_baseline() has been renamed to [method@Gtk.Widget.get_baseline].
|
||||
|
7
examples/hello/README.md
Normal file
7
examples/hello/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
A trivial example
|
||||
=================
|
||||
|
||||
This is a very minimal example of an app that can be built against GTK.
|
||||
We use this in CI to test that building against the installed GTK works.
|
||||
|
||||
That is why there is a standalone meson.build in this subdirectory.
|
@@ -477,6 +477,8 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
|
||||
object_class->dispose = gdk_broadway_display_dispose;
|
||||
object_class->finalize = gdk_broadway_display_finalize;
|
||||
|
||||
display_class->toplevel_type = GDK_TYPE_BROADWAY_TOPLEVEL;
|
||||
display_class->popup_type = GDK_TYPE_BROADWAY_POPUP;
|
||||
display_class->cairo_context_type = GDK_TYPE_BROADWAY_CAIRO_CONTEXT;
|
||||
|
||||
display_class->get_name = gdk_broadway_display_get_name;
|
||||
@@ -488,7 +490,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
|
||||
|
||||
display_class->get_next_serial = gdk_broadway_display_get_next_serial;
|
||||
display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete;
|
||||
display_class->create_surface = _gdk_broadway_display_create_surface;
|
||||
display_class->get_keymap = _gdk_broadway_display_get_keymap;
|
||||
|
||||
display_class->get_monitors = gdk_broadway_display_get_monitors;
|
||||
|
@@ -103,13 +103,6 @@ void _gdk_broadway_display_get_default_cursor_size (GdkDisplay *display,
|
||||
void _gdk_broadway_display_get_maximal_cursor_size (GdkDisplay *display,
|
||||
guint *width,
|
||||
guint *height);
|
||||
GdkSurface * _gdk_broadway_display_create_surface (GdkDisplay *display,
|
||||
GdkSurfaceType surface_type,
|
||||
GdkSurface *parent,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height);
|
||||
GdkKeymap* _gdk_broadway_display_get_keymap (GdkDisplay *display);
|
||||
void _gdk_broadway_display_consume_all_input (GdkDisplay *display);
|
||||
BroadwayInputMsg * _gdk_broadway_display_block_for_input (GdkDisplay *display,
|
||||
|
@@ -47,19 +47,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Forward declarations */
|
||||
static void gdk_broadway_surface_finalize (GObject *object);
|
||||
|
||||
G_DEFINE_TYPE (GdkBroadwaySurface, gdk_broadway_surface, GDK_TYPE_SURFACE)
|
||||
|
||||
GType gdk_broadway_toplevel_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_broadway_popup_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_broadway_drag_surface_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#define GDK_TYPE_BROADWAY_TOPLEVEL (gdk_broadway_toplevel_get_type ())
|
||||
#define GDK_TYPE_BROADWAY_POPUP (gdk_broadway_popup_get_type ())
|
||||
#define GDK_TYPE_BROADWAY_DRAG_SURFACE (gdk_broadway_drag_surface_get_type ())
|
||||
|
||||
/* We need to flush in an idle rather than AFTER_PAINT, as the clock
|
||||
is frozen during e.g. surface resizes so the paint will not happen
|
||||
and the surface resize request is never flushed. */
|
||||
@@ -74,6 +63,93 @@ gdk_broadway_surface_init (GdkBroadwaySurface *impl)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
on_frame_clock_after_paint (GdkFrameClock *clock,
|
||||
GdkSurface *surface)
|
||||
{
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
|
||||
GdkBroadwayDisplay *broadway_display;
|
||||
|
||||
impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
|
||||
gdk_surface_freeze_updates (surface);
|
||||
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
||||
|
||||
_gdk_broadway_server_roundtrip (broadway_display->server, impl->id, _gdk_display_get_next_serial (display));
|
||||
|
||||
gdk_display_flush (display);
|
||||
}
|
||||
|
||||
static void
|
||||
on_frame_clock_before_paint (GdkFrameClock *clock,
|
||||
GdkSurface *surface)
|
||||
{
|
||||
GdkFrameTimings *timings = gdk_frame_clock_get_current_timings (clock);
|
||||
gint64 presentation_time;
|
||||
gint64 refresh_interval;
|
||||
|
||||
if (surface->update_freeze_count > 0)
|
||||
return;
|
||||
|
||||
gdk_frame_clock_get_refresh_info (clock,
|
||||
timings->frame_time,
|
||||
&refresh_interval, &presentation_time);
|
||||
if (presentation_time != 0)
|
||||
{
|
||||
timings->predicted_presentation_time = presentation_time + refresh_interval;
|
||||
}
|
||||
else
|
||||
{
|
||||
timings->predicted_presentation_time = timings->frame_time + refresh_interval / 2 + refresh_interval;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connect_frame_clock (GdkSurface *surface)
|
||||
{
|
||||
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
|
||||
|
||||
g_signal_connect (frame_clock, "before-paint",
|
||||
G_CALLBACK (on_frame_clock_before_paint), surface);
|
||||
g_signal_connect (frame_clock, "after-paint",
|
||||
G_CALLBACK (on_frame_clock_after_paint), surface);
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_frame_clock (GdkSurface *surface)
|
||||
{
|
||||
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (frame_clock,
|
||||
on_frame_clock_before_paint, surface);
|
||||
g_signal_handlers_disconnect_by_func (frame_clock,
|
||||
on_frame_clock_after_paint, surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_surface_constructed (GObject *object)
|
||||
{
|
||||
GdkBroadwaySurface *self = GDK_BROADWAY_SURFACE (object);
|
||||
GdkSurface *surface = GDK_SURFACE (object);
|
||||
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
||||
|
||||
if (!surface->parent)
|
||||
broadway_display->toplevels = g_list_prepend (broadway_display->toplevels, self);
|
||||
|
||||
self->id = _gdk_broadway_server_new_surface (broadway_display->server,
|
||||
self->root_x,
|
||||
self->root_y,
|
||||
1, 1);
|
||||
g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER (self->id), surface);
|
||||
|
||||
g_object_ref (self);
|
||||
|
||||
G_OBJECT_CLASS (gdk_broadway_surface_parent_class)->constructed (object);
|
||||
|
||||
connect_frame_clock (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_surface_finalize (GObject *object)
|
||||
{
|
||||
@@ -143,164 +219,6 @@ _gdk_broadway_roundtrip_notify (GdkSurface *surface,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_frame_clock_after_paint (GdkFrameClock *clock,
|
||||
GdkSurface *surface)
|
||||
{
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
|
||||
GdkBroadwayDisplay *broadway_display;
|
||||
|
||||
impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
|
||||
gdk_surface_freeze_updates (surface);
|
||||
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
||||
|
||||
_gdk_broadway_server_roundtrip (broadway_display->server, impl->id, _gdk_display_get_next_serial (display));
|
||||
|
||||
gdk_display_flush (display);
|
||||
}
|
||||
|
||||
static void
|
||||
on_frame_clock_before_paint (GdkFrameClock *clock,
|
||||
GdkSurface *surface)
|
||||
{
|
||||
GdkFrameTimings *timings = gdk_frame_clock_get_current_timings (clock);
|
||||
gint64 presentation_time;
|
||||
gint64 refresh_interval;
|
||||
|
||||
if (surface->update_freeze_count > 0)
|
||||
return;
|
||||
|
||||
gdk_frame_clock_get_refresh_info (clock,
|
||||
timings->frame_time,
|
||||
&refresh_interval, &presentation_time);
|
||||
if (presentation_time != 0)
|
||||
{
|
||||
timings->predicted_presentation_time = presentation_time + refresh_interval;
|
||||
}
|
||||
else
|
||||
{
|
||||
timings->predicted_presentation_time = timings->frame_time + refresh_interval / 2 + refresh_interval;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connect_frame_clock (GdkSurface *surface)
|
||||
{
|
||||
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
|
||||
|
||||
g_signal_connect (frame_clock, "before-paint",
|
||||
G_CALLBACK (on_frame_clock_before_paint), surface);
|
||||
g_signal_connect (frame_clock, "after-paint",
|
||||
G_CALLBACK (on_frame_clock_after_paint), surface);
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_frame_clock (GdkSurface *surface)
|
||||
{
|
||||
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (frame_clock,
|
||||
on_frame_clock_before_paint, surface);
|
||||
g_signal_handlers_disconnect_by_func (frame_clock,
|
||||
on_frame_clock_after_paint, surface);
|
||||
}
|
||||
|
||||
GdkSurface *
|
||||
_gdk_broadway_display_create_surface (GdkDisplay *display,
|
||||
GdkSurfaceType surface_type,
|
||||
GdkSurface *parent,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
GdkBroadwayDisplay *broadway_display;
|
||||
GdkFrameClock *frame_clock;
|
||||
GdkSurface *surface;
|
||||
GdkBroadwaySurface *impl;
|
||||
GType type;
|
||||
|
||||
if (parent)
|
||||
frame_clock = g_object_ref (gdk_surface_get_frame_clock (parent));
|
||||
else
|
||||
frame_clock = _gdk_frame_clock_idle_new ();
|
||||
|
||||
switch (surface_type)
|
||||
{
|
||||
case GDK_SURFACE_TOPLEVEL:
|
||||
type = GDK_TYPE_BROADWAY_TOPLEVEL;
|
||||
break;
|
||||
case GDK_SURFACE_POPUP:
|
||||
type = GDK_TYPE_BROADWAY_POPUP;
|
||||
break;
|
||||
case GDK_SURFACE_DRAG:
|
||||
type = GDK_TYPE_BROADWAY_DRAG_SURFACE;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
surface = g_object_new (type,
|
||||
"display", display,
|
||||
"frame-clock", frame_clock,
|
||||
NULL);
|
||||
|
||||
g_object_unref (frame_clock);
|
||||
|
||||
surface->parent = parent;
|
||||
surface->x = x;
|
||||
surface->y = y;
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
||||
|
||||
impl = GDK_BROADWAY_SURFACE (surface);
|
||||
impl->root_x = x;
|
||||
impl->root_y = y;
|
||||
if (parent)
|
||||
{
|
||||
impl->root_x += GDK_BROADWAY_SURFACE (parent)->root_x;
|
||||
impl->root_y += GDK_BROADWAY_SURFACE (parent)->root_y;
|
||||
}
|
||||
|
||||
impl->id = _gdk_broadway_server_new_surface (broadway_display->server,
|
||||
impl->root_x,
|
||||
impl->root_y,
|
||||
surface->width,
|
||||
surface->height);
|
||||
g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER(impl->id), surface);
|
||||
|
||||
g_object_ref (surface);
|
||||
|
||||
if (!surface->parent)
|
||||
broadway_display->toplevels = g_list_prepend (broadway_display->toplevels, impl);
|
||||
|
||||
connect_frame_clock (surface);
|
||||
|
||||
/* We treat the real parent as a default transient for to get stacking right */
|
||||
if (parent)
|
||||
{
|
||||
impl->transient_for = GDK_BROADWAY_SURFACE (parent)->id;
|
||||
_gdk_broadway_server_surface_set_transient_for (broadway_display->server, impl->id, impl->transient_for);
|
||||
}
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_broadway_surface_ref_cairo_surface (GdkSurface *surface)
|
||||
{
|
||||
if (GDK_IS_BROADWAY_SURFACE (surface) &&
|
||||
GDK_SURFACE_DESTROYED (surface))
|
||||
return NULL;
|
||||
|
||||
return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_broadway_surface_destroy (GdkSurface *surface,
|
||||
gboolean foreign_destroy)
|
||||
@@ -1107,6 +1025,14 @@ _gdk_broadway_moveresize_configure_done (GdkDisplay *display,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GdkSurface *
|
||||
gdk_broadway_drag_surface_new (GdkDisplay *display)
|
||||
{
|
||||
return g_object_new (GDK_TYPE_BROADWAY_DRAG_SURFACE,
|
||||
"display", display,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
create_moveresize_surface (MoveResizeData *mv_resize,
|
||||
guint32 timestamp)
|
||||
@@ -1118,11 +1044,9 @@ create_moveresize_surface (MoveResizeData *mv_resize,
|
||||
g_assert (mv_resize->moveresize_emulation_surface == NULL);
|
||||
|
||||
mv_resize->moveresize_emulation_surface =
|
||||
_gdk_broadway_display_create_surface (mv_resize->display,
|
||||
GDK_SURFACE_DRAG,
|
||||
NULL,
|
||||
-100, -100, 1, 1);
|
||||
gdk_broadway_drag_surface_new (mv_resize->display);
|
||||
|
||||
gdk_broadway_surface_move_resize_internal (mv_resize->moveresize_emulation_surface, TRUE, -100, -100, 1, 1);
|
||||
gdk_broadway_surface_show (mv_resize->moveresize_emulation_surface, FALSE);
|
||||
|
||||
seat = gdk_display_get_default_seat (mv_resize->display);
|
||||
@@ -1252,9 +1176,9 @@ gdk_broadway_surface_class_init (GdkBroadwaySurfaceClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GdkSurfaceClass *impl_class = GDK_SURFACE_CLASS (klass);
|
||||
|
||||
object_class->constructed = gdk_broadway_surface_constructed;
|
||||
object_class->finalize = gdk_broadway_surface_finalize;
|
||||
|
||||
impl_class->ref_cairo_surface = gdk_broadway_surface_ref_cairo_surface;
|
||||
impl_class->hide = gdk_broadway_surface_hide;
|
||||
impl_class->get_geometry = gdk_broadway_surface_get_geometry;
|
||||
impl_class->get_root_coords = gdk_broadway_surface_get_root_coords;
|
||||
@@ -1290,6 +1214,25 @@ gdk_broadway_popup_init (GdkBroadwayPopup *popup)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_popup_constructed (GObject *object)
|
||||
{
|
||||
GdkBroadwaySurface *self = GDK_BROADWAY_SURFACE (object);
|
||||
GdkSurface *surface = GDK_SURFACE (self);
|
||||
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
||||
|
||||
self->root_x = GDK_BROADWAY_SURFACE (surface->parent)->root_x;
|
||||
self->root_y = GDK_BROADWAY_SURFACE (surface->parent)->root_y;
|
||||
|
||||
gdk_surface_set_frame_clock (surface, gdk_surface_get_frame_clock (surface->parent));
|
||||
|
||||
G_OBJECT_CLASS (gdk_broadway_popup_parent_class)->constructed (object);
|
||||
|
||||
/* We treat the real parent as a default transient for to get stacking right */
|
||||
self->transient_for = GDK_BROADWAY_SURFACE (surface->parent)->id;
|
||||
_gdk_broadway_server_surface_set_transient_for (broadway_display->server, self->id, self->transient_for);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_popup_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
@@ -1345,6 +1288,7 @@ gdk_broadway_popup_class_init (GdkBroadwayPopupClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->constructed = gdk_broadway_popup_constructed;
|
||||
object_class->get_property = gdk_broadway_popup_get_property;
|
||||
object_class->set_property = gdk_broadway_popup_set_property;
|
||||
|
||||
@@ -1415,6 +1359,19 @@ gdk_broadway_toplevel_init (GdkBroadwayToplevel *toplevel)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_toplevel_constructed (GObject *object)
|
||||
{
|
||||
GdkSurface *surface = GDK_SURFACE (object);
|
||||
GdkFrameClock *frame_clock;
|
||||
|
||||
frame_clock = _gdk_frame_clock_idle_new ();
|
||||
gdk_surface_set_frame_clock (surface, frame_clock);
|
||||
g_object_unref (frame_clock);
|
||||
|
||||
G_OBJECT_CLASS (gdk_broadway_toplevel_parent_class)->constructed (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_toplevel_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@@ -1518,6 +1475,7 @@ gdk_broadway_toplevel_class_init (GdkBroadwayToplevelClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->constructed = gdk_broadway_toplevel_constructed;
|
||||
object_class->get_property = gdk_broadway_toplevel_get_property;
|
||||
object_class->set_property = gdk_broadway_toplevel_set_property;
|
||||
|
||||
@@ -1678,9 +1636,25 @@ gdk_broadway_drag_surface_init (GdkBroadwayDragSurface *surface)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_surface_constructed (GObject *object)
|
||||
{
|
||||
GdkSurface *surface = GDK_SURFACE (object);
|
||||
GdkFrameClock *frame_clock;
|
||||
|
||||
frame_clock = _gdk_frame_clock_idle_new ();
|
||||
gdk_surface_set_frame_clock (surface, frame_clock);
|
||||
g_object_unref (frame_clock);
|
||||
|
||||
G_OBJECT_CLASS (gdk_broadway_drag_surface_parent_class)->constructed (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_surface_class_init (GdkBroadwayDragSurfaceClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->constructed = gdk_broadway_drag_surface_constructed;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@@ -32,6 +32,14 @@ G_BEGIN_DECLS
|
||||
/* Surface implementation for Broadway
|
||||
*/
|
||||
|
||||
GType gdk_broadway_toplevel_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_broadway_popup_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_broadway_drag_surface_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#define GDK_TYPE_BROADWAY_TOPLEVEL (gdk_broadway_toplevel_get_type ())
|
||||
#define GDK_TYPE_BROADWAY_POPUP (gdk_broadway_popup_get_type ())
|
||||
#define GDK_TYPE_BROADWAY_DRAG_SURFACE (gdk_broadway_drag_surface_get_type ())
|
||||
|
||||
struct _GdkBroadwaySurface
|
||||
{
|
||||
GdkSurface parent_instance;
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkversionmacros.h"
|
||||
#include "version/gdkversionmacros.h"
|
||||
|
||||
#include "gdkresources.h"
|
||||
|
||||
@@ -132,6 +132,7 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
||||
{ "vulkan-validate", GDK_DEBUG_VULKAN_VALIDATE, "Load the Vulkan validation layer", TRUE },
|
||||
{ "default-settings",GDK_DEBUG_DEFAULT_SETTINGS, "Force default values for xsettings", TRUE },
|
||||
{ "high-depth", GDK_DEBUG_HIGH_DEPTH, "Use high bit depth rendering if possible", TRUE },
|
||||
{ "no-vsync", GDK_DEBUG_NO_VSYNC, "Repaint instantly (uses 100% CPU with animations)", TRUE },
|
||||
};
|
||||
|
||||
|
||||
|
@@ -54,6 +54,7 @@
|
||||
#include <gdk/gdkframetimings.h>
|
||||
#include <gdk/gdkglcontext.h>
|
||||
#include <gdk/gdkgltexture.h>
|
||||
#include <gdk/gdkgltexturebuilder.h>
|
||||
#include <gdk/gdkkeys.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gdk/gdkmemorytexture.h>
|
||||
@@ -74,7 +75,7 @@
|
||||
#include <gdk/gdktoplevellayout.h>
|
||||
#include <gdk/gdktoplevelsize.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/version/gdkversionmacros.h>
|
||||
#include <gdk/gdkvulkancontext.h>
|
||||
|
||||
#undef __GDK_H_INSIDE__
|
||||
|
@@ -24,7 +24,6 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 2005 Red Hat, Inc.
|
||||
* Copyright (C) 2005 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -19,6 +19,9 @@
|
||||
|
||||
#include "gdkcairoprivate.h"
|
||||
|
||||
#include "gdkrgba.h"
|
||||
#include "gdktexture.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/**
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 2005 Red Hat, Inc.
|
||||
* Copyright (C) 2005 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -21,8 +21,7 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdkrgba.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkpixbuf.h>
|
||||
#include <pango/pangocairo.h>
|
||||
|
||||
|
@@ -24,11 +24,8 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_CAIRO_CONTEXT (gdk_cairo_context_get_type ())
|
||||
|
@@ -22,10 +22,7 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -21,8 +21,6 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@@ -21,8 +21,6 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@@ -22,10 +22,8 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_CONTENT_PROVIDER (gdk_content_provider_get_type ())
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@@ -21,8 +21,6 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@@ -28,7 +28,6 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@@ -52,6 +52,7 @@ typedef enum {
|
||||
GDK_DEBUG_VULKAN_VALIDATE = 1 << 23,
|
||||
GDK_DEBUG_DEFAULT_SETTINGS= 1 << 24,
|
||||
GDK_DEBUG_HIGH_DEPTH = 1 << 25,
|
||||
GDK_DEBUG_NO_VSYNC = 1 << 26,
|
||||
} GdkDebugFlags;
|
||||
|
||||
extern guint _gdk_debug_flags;
|
||||
|
@@ -21,12 +21,10 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkdevicetool.h>
|
||||
#include <gdk/gdkenums.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_DEVICE (gdk_device_get_type ())
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@@ -21,10 +21,7 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkenums.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* gdkdisplay.c
|
||||
*
|
||||
* Copyright 2001 Sun Microsystems Inc.
|
||||
*
|
||||
* Copyright 2001 Sun Microsystems Inc.
|
||||
*
|
||||
* Erwann Chenede <erwann.chenede@sun.com>
|
||||
*
|
||||
@@ -31,10 +31,11 @@
|
||||
#include "gdkclipboardprivate.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkdisplaymanagerprivate.h"
|
||||
#include "gdkframeclockidleprivate.h"
|
||||
#include "gdkeventsprivate.h"
|
||||
#include "gdkframeclockidleprivate.h"
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdkmonitorprivate.h"
|
||||
#include "gdkrectangle.h"
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
#include <epoxy/egl.h>
|
||||
@@ -175,7 +176,7 @@ gdk_display_default_rate_egl_config (GdkDisplay *display,
|
||||
|
||||
return distance;
|
||||
}
|
||||
|
||||
|
||||
static GdkSeat *
|
||||
gdk_display_real_get_default_seat (GdkDisplay *display)
|
||||
{
|
||||
@@ -418,10 +419,10 @@ gdk_display_close (GdkDisplay *display)
|
||||
if (!display->closed)
|
||||
{
|
||||
display->closed = TRUE;
|
||||
|
||||
|
||||
g_signal_emit (display, signals[CLOSED], 0, FALSE);
|
||||
g_object_run_dispose (G_OBJECT (display));
|
||||
|
||||
|
||||
g_object_unref (display);
|
||||
}
|
||||
}
|
||||
@@ -808,7 +809,7 @@ _gdk_display_end_device_grab (GdkDisplay *display,
|
||||
grab->implicit_ungrab = implicit;
|
||||
return l->next == NULL;
|
||||
}
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1196,21 +1197,6 @@ _gdk_display_unpause_events (GdkDisplay *display)
|
||||
display->event_pause_count--;
|
||||
}
|
||||
|
||||
GdkSurface *
|
||||
gdk_display_create_surface (GdkDisplay *display,
|
||||
GdkSurfaceType surface_type,
|
||||
GdkSurface *parent,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
return GDK_DISPLAY_GET_CLASS (display)->create_surface (display,
|
||||
surface_type,
|
||||
parent,
|
||||
x, y, width, height);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_display_get_keymap:
|
||||
* @display: the `GdkDisplay`
|
||||
@@ -1283,7 +1269,7 @@ gdk_display_init_gl (GdkDisplay *self)
|
||||
* Note that even if this function succeeds, creating a `GdkGLContext`
|
||||
* may still fail.
|
||||
*
|
||||
* This function is idempotent. Calling it multiple times will just
|
||||
* This function is idempotent. Calling it multiple times will just
|
||||
* return the same value or error.
|
||||
*
|
||||
* You never need to call this function, GDK will call it automatically
|
||||
@@ -1723,8 +1709,6 @@ gdk_display_init_egl (GdkDisplay *self,
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_KHR_no_config_context");
|
||||
self->have_egl_pixel_format_float =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_pixel_format_float");
|
||||
self->have_egl_win32_libangle =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_ANGLE_d3d_share_handle_client_buffer");
|
||||
|
||||
if (self->have_egl_no_config_context)
|
||||
priv->egl_config_high_depth = gdk_display_create_egl_config (self,
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
#include <gdk/gdkseat.h>
|
||||
|
@@ -369,7 +369,7 @@ gdk_display_manager_list_displays (GdkDisplayManager *manager)
|
||||
/**
|
||||
* gdk_display_manager_open_display:
|
||||
* @manager: a `GdkDisplayManager`
|
||||
* @name: the name of the display to open
|
||||
* @name: (nullable): the name of the display to open
|
||||
*
|
||||
* Opens a display.
|
||||
*
|
||||
@@ -437,7 +437,7 @@ gdk_display_manager_open_display (GdkDisplayManager *manager,
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && !display)
|
||||
if (!found && !any && !display)
|
||||
g_warning ("No such backend: %s", backend);
|
||||
}
|
||||
|
||||
|
@@ -108,13 +108,14 @@ struct _GdkDisplay
|
||||
guint have_egl_buffer_age : 1;
|
||||
guint have_egl_no_config_context : 1;
|
||||
guint have_egl_pixel_format_float : 1;
|
||||
guint have_egl_win32_libangle : 1;
|
||||
};
|
||||
|
||||
struct _GdkDisplayClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
GType toplevel_type; /* Type for GdkToplevel, must be set */
|
||||
GType popup_type; /* Type for GdkPopup, must be set */
|
||||
GType cairo_context_type; /* type for GdkCairoContext, must be set */
|
||||
GType vk_context_type; /* type for GdkVulkanContext, must be set if vk_extension_name != NULL */
|
||||
const char *vk_extension_name; /* Name of required windowing vulkan extension or %NULL (default) if Vulkan isn't supported */
|
||||
@@ -135,15 +136,7 @@ struct _GdkDisplayClass
|
||||
const char *startup_id);
|
||||
const char * (*get_startup_notification_id) (GdkDisplay *display);
|
||||
|
||||
GdkSurface * (*create_surface) (GdkDisplay *display,
|
||||
GdkSurfaceType surface_type,
|
||||
GdkSurface *parent,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
GdkKeymap * (*get_keymap) (GdkDisplay *display);
|
||||
GdkKeymap * (*get_keymap) (GdkDisplay *display);
|
||||
|
||||
GdkGLContext * (* init_gl) (GdkDisplay *display,
|
||||
GError **error);
|
||||
@@ -208,13 +201,6 @@ void _gdk_display_pointer_info_foreach (GdkDisplay *display
|
||||
gulong _gdk_display_get_next_serial (GdkDisplay *display);
|
||||
void _gdk_display_pause_events (GdkDisplay *display);
|
||||
void _gdk_display_unpause_events (GdkDisplay *display);
|
||||
GdkSurface * gdk_display_create_surface (GdkDisplay *display,
|
||||
GdkSurfaceType surface_type,
|
||||
GdkSurface *parent,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
GdkGLContext * gdk_display_get_gl_context (GdkDisplay *display);
|
||||
|
||||
|
@@ -28,10 +28,9 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkdevice.h>
|
||||
#include <gdk/gdkenums.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkdevice.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#endif
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -24,7 +24,6 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@@ -24,9 +24,7 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkenums.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -32,6 +32,20 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GdkGLAPI:
|
||||
* @GDK_GL_API_GL: The OpenGL API
|
||||
* @GDK_GL_API_GLES: The OpenGL ES API
|
||||
*
|
||||
* The list of the different APIs that GdkGLContext can potentially support.
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
typedef enum { /*< underscore_name=GDK_GL_API >*/
|
||||
GDK_GL_API_GL = 1 << 0,
|
||||
GDK_GL_API_GLES = 1 << 1
|
||||
} GdkGLAPI;
|
||||
|
||||
/* Currently, these are the same values numerically as in the
|
||||
* X protocol. If you change that, gdksurface-x11.c/gdk_surface_set_geometry_hints()
|
||||
* will need fixing.
|
||||
@@ -331,4 +345,3 @@ typedef enum {
|
||||
} GdkMemoryFormat;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@@ -28,12 +28,10 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkdevice.h>
|
||||
#include <gdk/gdkdevicetool.h>
|
||||
#include <gdk/gdkdrag.h>
|
||||
#include <gdk/gdkenums.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -79,7 +79,7 @@ static guint signals[LAST_SIGNAL];
|
||||
|
||||
static guint fps_counter;
|
||||
|
||||
#define FRAME_HISTORY_MAX_LENGTH 16
|
||||
#define FRAME_HISTORY_MAX_LENGTH 128
|
||||
|
||||
struct _GdkFrameClockPrivate
|
||||
{
|
||||
|
@@ -275,58 +275,80 @@ gdk_frame_clock_idle_get_frame_time (GdkFrameClock *clock)
|
||||
return new_smoothed_time;
|
||||
}
|
||||
|
||||
#define RUN_FLUSH_IDLE(priv) \
|
||||
((priv)->freeze_count == 0 && \
|
||||
((priv)->requested & GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS) != 0)
|
||||
static inline gboolean
|
||||
gdk_frame_clock_idle_is_frozen (GdkFrameClockIdle *self)
|
||||
{
|
||||
GdkFrameClockIdlePrivate *priv = self->priv;
|
||||
|
||||
if (GDK_DEBUG_CHECK (NO_VSYNC))
|
||||
return FALSE;
|
||||
|
||||
return priv->freeze_count > 0;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
should_run_flush_idle (GdkFrameClockIdle *self)
|
||||
{
|
||||
GdkFrameClockIdlePrivate *priv = self->priv;
|
||||
|
||||
return !gdk_frame_clock_idle_is_frozen (self) &&
|
||||
(priv->requested & GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS) != 0;
|
||||
}
|
||||
|
||||
/* The reason why we track updating_count separately here and don't
|
||||
* just add GDK_FRAME_CLOCK_PHASE_UPDATE into ->request on every frame
|
||||
* is so that we can avoid doing one more frame when an animation
|
||||
* is cancelled.
|
||||
*/
|
||||
#define RUN_PAINT_IDLE(priv) \
|
||||
((priv)->freeze_count == 0 && \
|
||||
(((priv)->requested & ~GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS) != 0 || \
|
||||
(priv)->updating_count > 0))
|
||||
static inline gboolean
|
||||
should_run_paint_idle (GdkFrameClockIdle *self)
|
||||
{
|
||||
GdkFrameClockIdlePrivate *priv = self->priv;
|
||||
|
||||
return !gdk_frame_clock_idle_is_frozen (self) &&
|
||||
((priv->requested & ~GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS) != 0 ||
|
||||
priv->updating_count > 0);
|
||||
}
|
||||
|
||||
static void
|
||||
maybe_start_idle (GdkFrameClockIdle *clock_idle,
|
||||
gboolean caused_by_thaw)
|
||||
maybe_start_idle (GdkFrameClockIdle *self,
|
||||
gboolean caused_by_thaw)
|
||||
{
|
||||
GdkFrameClockIdlePrivate *priv = clock_idle->priv;
|
||||
GdkFrameClockIdlePrivate *priv = self->priv;
|
||||
|
||||
if (RUN_FLUSH_IDLE (priv) || RUN_PAINT_IDLE (priv))
|
||||
if (should_run_flush_idle (self) || should_run_paint_idle (self))
|
||||
{
|
||||
guint min_interval = 0;
|
||||
|
||||
if (priv->min_next_frame_time != 0)
|
||||
if (priv->min_next_frame_time != 0 &&
|
||||
!GDK_DEBUG_CHECK (NO_VSYNC))
|
||||
{
|
||||
gint64 now = g_get_monotonic_time ();
|
||||
gint64 min_interval_us = MAX (priv->min_next_frame_time, now) - now;
|
||||
min_interval = (min_interval_us + 500) / 1000;
|
||||
}
|
||||
|
||||
if (priv->flush_idle_id == 0 && RUN_FLUSH_IDLE (priv))
|
||||
if (priv->flush_idle_id == 0 && should_run_flush_idle (self))
|
||||
{
|
||||
GSource *source;
|
||||
|
||||
priv->flush_idle_id = g_timeout_add_full (GDK_PRIORITY_EVENTS + 1,
|
||||
min_interval,
|
||||
gdk_frame_clock_flush_idle,
|
||||
g_object_ref (clock_idle),
|
||||
g_object_ref (self),
|
||||
(GDestroyNotify) g_object_unref);
|
||||
source = g_main_context_find_source_by_id (NULL, priv->flush_idle_id);
|
||||
g_source_set_static_name (source, "[gtk] gdk_frame_clock_flush_idle");
|
||||
}
|
||||
|
||||
if (!priv->in_paint_idle &&
|
||||
priv->paint_idle_id == 0 && RUN_PAINT_IDLE (priv))
|
||||
priv->paint_idle_id == 0 && should_run_paint_idle (self))
|
||||
{
|
||||
priv->paint_is_thaw = caused_by_thaw;
|
||||
priv->paint_idle_id = g_timeout_add_full (GDK_PRIORITY_REDRAW,
|
||||
min_interval,
|
||||
gdk_frame_clock_paint_idle,
|
||||
g_object_ref (clock_idle),
|
||||
g_object_ref (self),
|
||||
(GDestroyNotify) g_object_unref);
|
||||
gdk_source_set_static_name_by_id (priv->paint_idle_id, "[gtk] gdk_frame_clock_paint_idle");
|
||||
}
|
||||
@@ -334,17 +356,17 @@ maybe_start_idle (GdkFrameClockIdle *clock_idle,
|
||||
}
|
||||
|
||||
static void
|
||||
maybe_stop_idle (GdkFrameClockIdle *clock_idle)
|
||||
maybe_stop_idle (GdkFrameClockIdle *self)
|
||||
{
|
||||
GdkFrameClockIdlePrivate *priv = clock_idle->priv;
|
||||
GdkFrameClockIdlePrivate *priv = self->priv;
|
||||
|
||||
if (priv->flush_idle_id != 0 && !RUN_FLUSH_IDLE (priv))
|
||||
if (priv->flush_idle_id != 0 && !should_run_flush_idle (self))
|
||||
{
|
||||
g_source_remove (priv->flush_idle_id);
|
||||
priv->flush_idle_id = 0;
|
||||
}
|
||||
|
||||
if (priv->paint_idle_id != 0 && !RUN_PAINT_IDLE (priv))
|
||||
if (priv->paint_idle_id != 0 && !should_run_paint_idle (self))
|
||||
{
|
||||
g_source_remove (priv->paint_idle_id);
|
||||
priv->paint_idle_id = 0;
|
||||
@@ -432,7 +454,7 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
break;
|
||||
case GDK_FRAME_CLOCK_PHASE_NONE:
|
||||
case GDK_FRAME_CLOCK_PHASE_BEFORE_PAINT:
|
||||
if (priv->freeze_count == 0)
|
||||
if (!gdk_frame_clock_idle_is_frozen (clock_idle))
|
||||
{
|
||||
gint64 frame_interval = FRAME_INTERVAL;
|
||||
GdkFrameTimings *prev_timings = gdk_frame_clock_get_current_timings (clock);
|
||||
@@ -548,7 +570,7 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
G_GNUC_FALLTHROUGH;
|
||||
|
||||
case GDK_FRAME_CLOCK_PHASE_UPDATE:
|
||||
if (priv->freeze_count == 0)
|
||||
if (!gdk_frame_clock_idle_is_frozen (clock_idle))
|
||||
{
|
||||
if ((priv->requested & GDK_FRAME_CLOCK_PHASE_UPDATE) != 0 ||
|
||||
priv->updating_count > 0)
|
||||
@@ -560,7 +582,7 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
G_GNUC_FALLTHROUGH;
|
||||
|
||||
case GDK_FRAME_CLOCK_PHASE_LAYOUT:
|
||||
if (priv->freeze_count == 0)
|
||||
if (!gdk_frame_clock_idle_is_frozen (clock_idle))
|
||||
{
|
||||
int iter;
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
@@ -580,7 +602,8 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
*/
|
||||
iter = 0;
|
||||
while ((priv->requested & GDK_FRAME_CLOCK_PHASE_LAYOUT) &&
|
||||
priv->freeze_count == 0 && iter++ < 4)
|
||||
!gdk_frame_clock_idle_is_frozen (clock_idle) &&
|
||||
iter++ < 4)
|
||||
{
|
||||
priv->requested &= ~GDK_FRAME_CLOCK_PHASE_LAYOUT;
|
||||
_gdk_frame_clock_emit_layout (clock);
|
||||
@@ -591,7 +614,7 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
G_GNUC_FALLTHROUGH;
|
||||
|
||||
case GDK_FRAME_CLOCK_PHASE_PAINT:
|
||||
if (priv->freeze_count == 0)
|
||||
if (!gdk_frame_clock_idle_is_frozen (clock_idle))
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DEBUG_CHECK (FRAMES))
|
||||
@@ -612,7 +635,7 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
G_GNUC_FALLTHROUGH;
|
||||
|
||||
case GDK_FRAME_CLOCK_PHASE_AFTER_PAINT:
|
||||
if (priv->freeze_count == 0)
|
||||
if (!gdk_frame_clock_idle_is_frozen (clock_idle))
|
||||
{
|
||||
priv->requested &= ~GDK_FRAME_CLOCK_PHASE_AFTER_PAINT;
|
||||
_gdk_frame_clock_emit_after_paint (clock);
|
||||
@@ -641,7 +664,7 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
_gdk_frame_clock_emit_resume_events (clock);
|
||||
}
|
||||
|
||||
if (priv->freeze_count == 0)
|
||||
if (!gdk_frame_clock_idle_is_frozen (clock_idle))
|
||||
priv->phase = GDK_FRAME_CLOCK_PHASE_NONE;
|
||||
|
||||
priv->in_paint_idle = FALSE;
|
||||
@@ -650,7 +673,7 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
* update as soon as the backend unthrottles (if there is work to do),
|
||||
* otherwise we need to figure when the next frame should be.
|
||||
*/
|
||||
if (priv->freeze_count == 0)
|
||||
if (!gdk_frame_clock_idle_is_frozen (clock_idle))
|
||||
{
|
||||
/*
|
||||
* If we don't receive "frame drawn" events, smooth_cycle_start will simply be advanced in constant increments of
|
||||
@@ -668,7 +691,7 @@ gdk_frame_clock_paint_idle (void *data)
|
||||
maybe_start_idle (clock_idle, FALSE);
|
||||
}
|
||||
|
||||
if (priv->freeze_count == 0)
|
||||
if (!gdk_frame_clock_idle_is_frozen (clock_idle))
|
||||
priv->sleep_serial = get_sleep_serial ();
|
||||
|
||||
gdk_profiler_end_mark (before, "frameclock cycle", NULL);
|
||||
@@ -742,7 +765,7 @@ gdk_frame_clock_idle_freeze (GdkFrameClock *clock)
|
||||
GdkFrameClockIdle *clock_idle = GDK_FRAME_CLOCK_IDLE (clock);
|
||||
GdkFrameClockIdlePrivate *priv = clock_idle->priv;
|
||||
|
||||
if (priv->freeze_count == 0)
|
||||
if (!gdk_frame_clock_idle_is_frozen (clock_idle))
|
||||
{
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
priv->freeze_time = g_get_monotonic_time ();
|
||||
@@ -761,7 +784,7 @@ gdk_frame_clock_idle_thaw (GdkFrameClock *clock)
|
||||
g_return_if_fail (priv->freeze_count > 0);
|
||||
|
||||
priv->freeze_count--;
|
||||
if (priv->freeze_count == 0)
|
||||
if (!gdk_frame_clock_idle_is_frozen (clock_idle))
|
||||
{
|
||||
maybe_start_idle (clock_idle, TRUE);
|
||||
/* If nothing is requested so we didn't start an idle, we need
|
||||
@@ -775,7 +798,7 @@ gdk_frame_clock_idle_thaw (GdkFrameClock *clock)
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
{
|
||||
if (priv->freeze_time != 0)
|
||||
if (gdk_frame_clock_idle_is_frozen (clock_idle))
|
||||
{
|
||||
gdk_profiler_end_mark (priv->freeze_time * 1000, "frameclock frozen", NULL);
|
||||
priv->freeze_time = 0;
|
||||
|
@@ -21,8 +21,7 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -82,6 +82,7 @@
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
#include "gdkmemorytextureprivate.h"
|
||||
#include "gdkprofilerprivate.h"
|
||||
#include "gdkglversionprivate.h"
|
||||
|
||||
#include "gdkprivate.h"
|
||||
|
||||
@@ -99,13 +100,13 @@
|
||||
#define DEFAULT_ALLOWED_APIS GDK_GL_API_GL | GDK_GL_API_GLES
|
||||
|
||||
typedef struct {
|
||||
int major;
|
||||
int minor;
|
||||
int gl_version;
|
||||
GdkGLVersion required;
|
||||
GdkGLVersion gl_version;
|
||||
|
||||
guint has_khr_debug : 1;
|
||||
guint use_khr_debug : 1;
|
||||
guint has_half_float : 1;
|
||||
guint has_sync : 1;
|
||||
guint has_unpack_subimage : 1;
|
||||
guint has_debug_output : 1;
|
||||
guint extensions_checked : 1;
|
||||
@@ -287,8 +288,11 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
|
||||
EGLConfig egl_config;
|
||||
EGLContext ctx;
|
||||
EGLint context_attribs[N_EGL_ATTRS], i = 0, flags = 0;
|
||||
gsize major_idx, minor_idx;
|
||||
gboolean debug_bit, forward_bit;
|
||||
int min_major, min_minor, major = 0, minor = 0;
|
||||
GdkGLVersion version;
|
||||
const GdkGLVersion* supported_versions;
|
||||
gsize j;
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
|
||||
if (!gdk_gl_context_is_api_allowed (context, api, NULL))
|
||||
@@ -296,12 +300,7 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
|
||||
|
||||
/* We will use the default version matching the context status
|
||||
* unless the user requested a version which makes sense */
|
||||
gdk_gl_context_get_matching_version (api, legacy,
|
||||
display->have_egl_win32_libangle,
|
||||
&min_major, &min_minor);
|
||||
gdk_gl_context_get_clipped_version (context,
|
||||
min_major, min_minor,
|
||||
&major, &minor);
|
||||
gdk_gl_context_get_matching_version (context, api, legacy, &version);
|
||||
|
||||
if (!eglBindAPI (gdk_api_to_egl_api (api)))
|
||||
return 0;
|
||||
@@ -332,9 +331,9 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
|
||||
flags &= ~EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
|
||||
|
||||
context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION;
|
||||
context_attribs[i++] = major;
|
||||
major_idx = i++;
|
||||
context_attribs[i++] = EGL_CONTEXT_MINOR_VERSION;
|
||||
context_attribs[i++] = minor;
|
||||
minor_idx = i++;
|
||||
context_attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
|
||||
context_attribs[i++] = flags;
|
||||
|
||||
@@ -343,23 +342,33 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
|
||||
|
||||
GDK_DISPLAY_DEBUG (display, OPENGL,
|
||||
"Creating EGL context version %d.%d (debug:%s, forward:%s, legacy:%s, es:%s)",
|
||||
major, minor,
|
||||
gdk_gl_version_get_major (&version), gdk_gl_version_get_minor (&version),
|
||||
debug_bit ? "yes" : "no",
|
||||
forward_bit ? "yes" : "no",
|
||||
legacy ? "yes" : "no",
|
||||
api == GDK_GL_API_GLES ? "yes" : "no");
|
||||
|
||||
ctx = eglCreateContext (egl_display,
|
||||
egl_config,
|
||||
share ? share_priv->egl_context : EGL_NO_CONTEXT,
|
||||
context_attribs);
|
||||
supported_versions = gdk_gl_versions_get_for_api (api);
|
||||
for (j = 0; gdk_gl_version_greater_equal (&supported_versions[j], &version); j++)
|
||||
{
|
||||
context_attribs [major_idx] = gdk_gl_version_get_major (&supported_versions[j]);
|
||||
context_attribs [minor_idx] = gdk_gl_version_get_minor (&supported_versions[j]);
|
||||
|
||||
ctx = eglCreateContext (egl_display,
|
||||
egl_config,
|
||||
share ? share_priv->egl_context : EGL_NO_CONTEXT,
|
||||
context_attribs);
|
||||
if (ctx != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ctx == NULL)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
GDK_DISPLAY_DEBUG (display, OPENGL, "Created EGL context[%p]", ctx);
|
||||
|
||||
priv->egl_context = ctx;
|
||||
gdk_gl_context_set_version (context, &supported_versions[j]);
|
||||
gdk_gl_context_set_is_legacy (context, legacy);
|
||||
|
||||
if (epoxy_has_egl_extension (egl_display, "EGL_KHR_swap_buffers_with_damage"))
|
||||
@@ -621,7 +630,7 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
|
||||
glViewport (0, 0, ww, wh);
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
if (priv->egl_context && gdk_gl_context_check_version (context, 0, 0, 3, 0))
|
||||
if (priv->egl_context && gdk_gl_context_check_version (context, NULL, "3.0"))
|
||||
glDrawBuffers (1, (GLenum[1]) { gdk_gl_context_get_use_es (context) ? GL_BACK : GL_BACK_LEFT });
|
||||
#endif
|
||||
}
|
||||
@@ -987,45 +996,33 @@ gdk_gl_context_get_forward_compatible (GdkGLContext *context)
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gl_context_get_matching_version (GdkGLAPI api,
|
||||
gboolean legacy,
|
||||
gboolean win32_libangle,
|
||||
int *major,
|
||||
int *minor)
|
||||
gdk_gl_context_get_matching_version (GdkGLContext *context,
|
||||
GdkGLAPI api,
|
||||
gboolean legacy,
|
||||
GdkGLVersion *out_version)
|
||||
{
|
||||
int maj, min;
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
GdkGLVersion min_version;
|
||||
|
||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||
|
||||
if (api == GDK_GL_API_GL)
|
||||
{
|
||||
if (legacy)
|
||||
{
|
||||
maj = GDK_GL_MIN_GL_LEGACY_VERSION_MAJOR;
|
||||
min = GDK_GL_MIN_GL_LEGACY_VERSION_MINOR;
|
||||
}
|
||||
min_version = GDK_GL_MIN_GL_LEGACY_VERSION;
|
||||
else
|
||||
{
|
||||
maj = GDK_GL_MIN_GL_VERSION_MAJOR;
|
||||
min = GDK_GL_MIN_GL_VERSION_MINOR;
|
||||
}
|
||||
min_version = GDK_GL_MIN_GL_VERSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (win32_libangle)
|
||||
{
|
||||
maj = GDK_GL_MIN_GLES_WIN32_ANGLE_VERSION_MAJOR;
|
||||
min = GDK_GL_MIN_GLES_WIN32_ANGLE_VERSION_MINOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
maj = GDK_GL_MIN_GLES_VERSION_MAJOR;
|
||||
min = GDK_GL_MIN_GLES_VERSION_MINOR;
|
||||
}
|
||||
min_version = GDK_GL_MIN_GLES_VERSION;
|
||||
}
|
||||
|
||||
if (major != NULL)
|
||||
*major = maj;
|
||||
if (minor != NULL)
|
||||
*minor = min;
|
||||
if (gdk_gl_version_greater_equal (&priv->required, &min_version))
|
||||
*out_version = priv->required;
|
||||
else
|
||||
*out_version = min_version;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1054,22 +1051,17 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
|
||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||
g_return_if_fail (!gdk_gl_context_is_realized (context));
|
||||
|
||||
priv->major = major;
|
||||
priv->minor = minor;
|
||||
priv->required = GDK_GL_VERSION_INIT (major, minor);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_gl_context_check_version (GdkGLContext *self,
|
||||
int required_gl_major,
|
||||
int required_gl_minor,
|
||||
int required_gles_major,
|
||||
int required_gles_minor)
|
||||
gdk_gl_context_check_gl_version (GdkGLContext *self,
|
||||
const GdkGLVersion *required_gl,
|
||||
const GdkGLVersion *required_gles)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_GL_CONTEXT (self), FALSE);
|
||||
g_return_val_if_fail (required_gl_minor < 10, FALSE);
|
||||
g_return_val_if_fail (required_gles_minor < 10, FALSE);
|
||||
|
||||
if (!gdk_gl_context_is_realized (self))
|
||||
return FALSE;
|
||||
@@ -1077,10 +1069,10 @@ gdk_gl_context_check_version (GdkGLContext *self,
|
||||
switch (priv->api)
|
||||
{
|
||||
case GDK_GL_API_GL:
|
||||
return priv->gl_version >= required_gl_major * 10 + required_gl_minor;
|
||||
return required_gl == NULL || gdk_gl_version_greater_equal (&priv->gl_version, required_gl);
|
||||
|
||||
case GDK_GL_API_GLES:
|
||||
return priv->gl_version >= required_gles_major * 10 + required_gles_minor;
|
||||
return required_gles == NULL || gdk_gl_version_greater_equal (&priv->gl_version, required_gles);
|
||||
|
||||
default:
|
||||
g_return_val_if_reached (FALSE);
|
||||
@@ -1111,33 +1103,9 @@ gdk_gl_context_get_required_version (GdkGLContext *context,
|
||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||
|
||||
if (major != NULL)
|
||||
*major = priv->major;
|
||||
*major = gdk_gl_version_get_major (&priv->required);
|
||||
if (minor != NULL)
|
||||
*minor = priv->minor;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gl_context_get_clipped_version (GdkGLContext *context,
|
||||
int min_major,
|
||||
int min_minor,
|
||||
int *major,
|
||||
int *minor)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
int maj = min_major, min = min_minor;
|
||||
|
||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||
|
||||
if (priv->major > maj || (priv->major == maj && priv->minor > min))
|
||||
{
|
||||
maj = priv->major;
|
||||
min = priv->minor;
|
||||
}
|
||||
|
||||
if (major != NULL)
|
||||
*major = maj;
|
||||
if (minor != NULL)
|
||||
*minor = min;
|
||||
*minor = gdk_gl_version_get_minor (&priv->required);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1174,6 +1142,15 @@ gdk_gl_context_is_legacy (GdkGLContext *context)
|
||||
return priv->is_legacy;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gl_context_set_version (GdkGLContext *context,
|
||||
const GdkGLVersion *version)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
|
||||
priv->gl_version = *version;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gl_context_set_is_legacy (GdkGLContext *context,
|
||||
gboolean is_legacy)
|
||||
@@ -1509,11 +1486,23 @@ gdk_gl_context_realize (GdkGLContext *context,
|
||||
priv->api = GDK_GL_CONTEXT_GET_CLASS (context)->realize (context, error);
|
||||
|
||||
if (priv->api)
|
||||
g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_API]);
|
||||
{
|
||||
g_assert (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (0, 0)));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_API]);
|
||||
}
|
||||
|
||||
return priv->api;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gl_version_init_epoxy (GdkGLVersion *version)
|
||||
{
|
||||
int epoxy_version = epoxy_gl_version ();
|
||||
|
||||
*version = GDK_GL_VERSION_INIT (epoxy_version / 10, epoxy_version % 10);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_context_check_extensions (GdkGLContext *context)
|
||||
{
|
||||
@@ -1527,8 +1516,6 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
||||
if (priv->extensions_checked)
|
||||
return;
|
||||
|
||||
priv->gl_version = epoxy_gl_version ();
|
||||
|
||||
priv->has_debug_output = epoxy_has_gl_extension ("GL_ARB_debug_output") ||
|
||||
epoxy_has_gl_extension ("GL_KHR_debug");
|
||||
|
||||
@@ -1554,7 +1541,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
||||
priv->has_khr_debug = epoxy_has_gl_extension ("GL_KHR_debug");
|
||||
|
||||
/* We asked for a core profile, but we didn't get one, so we're in legacy mode */
|
||||
if (priv->gl_version < 32)
|
||||
if (!gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 2)))
|
||||
priv->is_legacy = TRUE;
|
||||
}
|
||||
|
||||
@@ -1564,9 +1551,13 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
||||
glGetIntegerv (GL_MAX_LABEL_LENGTH, &priv->max_debug_label_length);
|
||||
}
|
||||
|
||||
priv->has_half_float = gdk_gl_context_check_version (context, 3, 0, 3, 0) ||
|
||||
priv->has_half_float = gdk_gl_context_check_version (context, "3.0", "3.0") ||
|
||||
epoxy_has_gl_extension ("OES_vertex_half_float");
|
||||
|
||||
priv->has_sync = gdk_gl_context_check_version (context, "3.2", "3.0") ||
|
||||
epoxy_has_gl_extension ("GL_ARB_sync") ||
|
||||
epoxy_has_gl_extension ("GK_APPLE_sync");
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
{
|
||||
int max_texture_size;
|
||||
@@ -1578,15 +1569,17 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
||||
"* Extensions checked:\n"
|
||||
" - GL_KHR_debug: %s\n"
|
||||
" - GL_EXT_unpack_subimage: %s\n"
|
||||
" - OES_vertex_half_float: %s",
|
||||
" - half float: %s\n"
|
||||
" - sync: %s",
|
||||
gdk_gl_context_get_use_es (context) ? "OpenGL ES" : "OpenGL",
|
||||
priv->gl_version / 10, priv->gl_version % 10,
|
||||
gdk_gl_version_get_major (&priv->gl_version), gdk_gl_version_get_minor (&priv->gl_version),
|
||||
priv->is_legacy ? "legacy" : "core",
|
||||
glGetString (GL_SHADING_LANGUAGE_VERSION),
|
||||
max_texture_size,
|
||||
priv->has_khr_debug ? "yes" : "no",
|
||||
priv->has_unpack_subimage ? "yes" : "no",
|
||||
priv->has_half_float ? "yes" : "no");
|
||||
priv->has_half_float ? "yes" : "no",
|
||||
priv->has_sync ? "yes" : "no");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1708,10 +1701,6 @@ gdk_gl_context_get_shared_context (GdkGLContext *context)
|
||||
* Retrieves the OpenGL version of the @context.
|
||||
*
|
||||
* The @context must be realized prior to calling this function.
|
||||
*
|
||||
* If the @context has never been made current, the version cannot
|
||||
* be known and it will return 0 for both @major and @minor.
|
||||
*
|
||||
*/
|
||||
void
|
||||
gdk_gl_context_get_version (GdkGLContext *context,
|
||||
@@ -1724,9 +1713,9 @@ gdk_gl_context_get_version (GdkGLContext *context,
|
||||
g_return_if_fail (gdk_gl_context_is_realized (context));
|
||||
|
||||
if (major != NULL)
|
||||
*major = priv->gl_version / 10;
|
||||
*major = gdk_gl_version_get_major (&priv->gl_version);
|
||||
if (minor != NULL)
|
||||
*minor = priv->gl_version % 10;
|
||||
*minor = gdk_gl_version_get_minor (&priv->gl_version);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1818,6 +1807,14 @@ gdk_gl_context_has_vertex_half_float (GdkGLContext *self)
|
||||
return priv->has_half_float;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_gl_context_has_sync (GdkGLContext *self)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
|
||||
|
||||
return priv->has_sync;
|
||||
}
|
||||
|
||||
/* This is currently private! */
|
||||
/* When using GL/ES, don't flip the 'R' and 'B' bits on Windows/ANGLE for glReadPixels() */
|
||||
gboolean
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
*
|
||||
* gdkglcontext.h: GL context abstraction
|
||||
*
|
||||
*
|
||||
* Copyright © 2014 Emmanuele Bassi
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@@ -24,25 +24,10 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GdkGLAPI:
|
||||
* @GDK_GL_API_GL: The OpenGL API
|
||||
* @GDK_GL_API_GLES: The OpenGL ES API
|
||||
*
|
||||
* The list of the different APIs that GdkGLContext can potentially support.
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
typedef enum { /*< underscore_name=GDK_GL_API >*/
|
||||
GDK_GL_API_GL = 1 << 0,
|
||||
GDK_GL_API_GLES = 1 << 1
|
||||
} GdkGLAPI;
|
||||
|
||||
#define GDK_TYPE_GL_CONTEXT (gdk_gl_context_get_type ())
|
||||
#define GDK_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_GL_CONTEXT, GdkGLContext))
|
||||
#define GDK_IS_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_GL_CONTEXT))
|
||||
|
@@ -22,32 +22,10 @@
|
||||
|
||||
#include "gdkglcontext.h"
|
||||
#include "gdkdrawcontextprivate.h"
|
||||
#include "gdkglversionprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Version requirements for EGL contexts.
|
||||
*
|
||||
* If you add support for EGL to your backend, please require this.
|
||||
*/
|
||||
#define GDK_EGL_MIN_VERSION_MAJOR (1)
|
||||
#define GDK_EGL_MIN_VERSION_MINOR (4)
|
||||
|
||||
/* Minimum OpenGL versions supported by GTK.
|
||||
* Backends should make sure to never create a context of a previous version.
|
||||
*
|
||||
* The macros refer to OpenGL; OpenGL with OPENGL_COMPATIBILITY_PROFILE_BIT as
|
||||
* OPENGL_PROFILE_MASK; OpenGL ES; and OpenGL ES win32 Angle implementation,
|
||||
* respectively
|
||||
*/
|
||||
#define GDK_GL_MIN_GL_VERSION_MAJOR (3)
|
||||
#define GDK_GL_MIN_GL_VERSION_MINOR (2)
|
||||
#define GDK_GL_MIN_GL_LEGACY_VERSION_MAJOR (3)
|
||||
#define GDK_GL_MIN_GL_LEGACY_VERSION_MINOR (0)
|
||||
#define GDK_GL_MIN_GLES_VERSION_MAJOR (2)
|
||||
#define GDK_GL_MIN_GLES_VERSION_MINOR (0)
|
||||
#define GDK_GL_MIN_GLES_WIN32_ANGLE_VERSION_MAJOR (3)
|
||||
#define GDK_GL_MIN_GLES_WIN32_ANGLE_VERSION_MINOR (0)
|
||||
|
||||
typedef enum {
|
||||
GDK_GL_NONE = 0,
|
||||
GDK_GL_EGL,
|
||||
@@ -100,7 +78,6 @@ typedef struct {
|
||||
} GdkGLContextProgram;
|
||||
|
||||
typedef struct {
|
||||
guint vertex_array_object;
|
||||
guint tmp_framebuffer;
|
||||
guint tmp_vertex_buffer;
|
||||
|
||||
@@ -122,27 +99,31 @@ void gdk_gl_context_clear_current_if_surface (GdkSurface
|
||||
GdkGLContext * gdk_gl_context_new (GdkDisplay *display,
|
||||
GdkSurface *surface);
|
||||
|
||||
gboolean gdk_gl_context_is_api_allowed (GdkGLContext *self,
|
||||
GdkGLAPI api,
|
||||
GError **error);
|
||||
void gdk_gl_context_set_is_legacy (GdkGLContext *context,
|
||||
gboolean is_legacy);
|
||||
gboolean gdk_gl_context_is_api_allowed (GdkGLContext *self,
|
||||
GdkGLAPI api,
|
||||
GError **error);
|
||||
void gdk_gl_context_set_version (GdkGLContext *context,
|
||||
const GdkGLVersion *version);
|
||||
void gdk_gl_context_set_is_legacy (GdkGLContext *context,
|
||||
gboolean is_legacy);
|
||||
gboolean gdk_gl_context_check_gl_version (GdkGLContext *context,
|
||||
const GdkGLVersion *gl_version,
|
||||
const GdkGLVersion *gles_version);
|
||||
|
||||
gboolean gdk_gl_context_check_version (GdkGLContext *context,
|
||||
int required_gl_major,
|
||||
int required_gl_minor,
|
||||
int required_gles_major,
|
||||
int required_gles_minor);
|
||||
void gdk_gl_context_get_clipped_version (GdkGLContext *context,
|
||||
int min_major,
|
||||
int min_minor,
|
||||
int *major,
|
||||
int *minor);
|
||||
void gdk_gl_context_get_matching_version (GdkGLAPI api,
|
||||
gboolean legacy,
|
||||
gboolean win32_libangle,
|
||||
int *major,
|
||||
int *minor);
|
||||
static inline gboolean
|
||||
gdk_gl_context_check_version (GdkGLContext *context,
|
||||
const char *gl_version,
|
||||
const char *gles_version)
|
||||
{
|
||||
return gdk_gl_context_check_gl_version (context,
|
||||
gl_version ? &GDK_GL_VERSION_STRING (gl_version) : NULL,
|
||||
gles_version ? &GDK_GL_VERSION_STRING (gles_version) : NULL);
|
||||
}
|
||||
|
||||
void gdk_gl_context_get_matching_version (GdkGLContext *context,
|
||||
GdkGLAPI api,
|
||||
gboolean legacy,
|
||||
GdkGLVersion *out_version);
|
||||
|
||||
gboolean gdk_gl_context_has_unpack_subimage (GdkGLContext *context);
|
||||
void gdk_gl_context_push_debug_group (GdkGLContext *context,
|
||||
@@ -167,6 +148,8 @@ gboolean gdk_gl_context_use_es_bgra (GdkGLContext
|
||||
|
||||
gboolean gdk_gl_context_has_vertex_half_float (GdkGLContext *self) G_GNUC_PURE;
|
||||
|
||||
gboolean gdk_gl_context_has_sync (GdkGLContext *self) G_GNUC_PURE;
|
||||
|
||||
double gdk_gl_context_get_scale (GdkGLContext *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -39,6 +39,7 @@ struct _GdkGLTexture {
|
||||
GdkGLContext *context;
|
||||
guint id;
|
||||
gboolean has_mipmap;
|
||||
gpointer sync;
|
||||
|
||||
GdkTexture *saved;
|
||||
|
||||
@@ -99,6 +100,10 @@ gdk_gl_texture_invoke_callback (gpointer data)
|
||||
context = gdk_display_get_gl_context (gdk_gl_context_get_display (invoke->self->context));
|
||||
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
if (invoke->self->sync && context != invoke->self->context)
|
||||
glWaitSync (invoke->self->sync, 0, GL_TIMEOUT_IGNORED);
|
||||
|
||||
glBindTexture (GL_TEXTURE_2D, invoke->self->id);
|
||||
|
||||
invoke->func (invoke->self, context, invoke->data);
|
||||
@@ -131,6 +136,8 @@ struct _Download
|
||||
|
||||
static gboolean
|
||||
gdk_gl_texture_find_format (gboolean use_es,
|
||||
guint gl_major,
|
||||
guint gl_minor,
|
||||
GLint gl_format,
|
||||
GLint gl_type,
|
||||
GdkMemoryFormat *out_format)
|
||||
@@ -141,7 +148,7 @@ gdk_gl_texture_find_format (gboolean use_es,
|
||||
{
|
||||
GLenum q_internal_format, q_format, q_type;
|
||||
|
||||
if (!gdk_memory_format_gl_format (format, use_es, &q_internal_format, &q_format, &q_type))
|
||||
if (!gdk_memory_format_gl_format (format, use_es, gl_major, gl_minor, &q_internal_format, &q_format, &q_type))
|
||||
continue;
|
||||
|
||||
if (q_format != gl_format || q_type != gl_type)
|
||||
@@ -163,12 +170,14 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
||||
gsize expected_stride;
|
||||
Download *download = download_;
|
||||
GLenum gl_internal_format, gl_format, gl_type;
|
||||
int major, minor;
|
||||
|
||||
expected_stride = texture->width * gdk_memory_format_bytes_per_pixel (download->format);
|
||||
gdk_gl_context_get_version (context, &major, &minor);
|
||||
|
||||
if (download->stride == expected_stride &&
|
||||
!gdk_gl_context_get_use_es (context) &&
|
||||
gdk_memory_format_gl_format (download->format, TRUE, &gl_internal_format, &gl_format, &gl_type))
|
||||
gdk_memory_format_gl_format (download->format, TRUE, major, minor, &gl_internal_format, &gl_format, &gl_type))
|
||||
{
|
||||
glGetTexImage (GL_TEXTURE_2D,
|
||||
0,
|
||||
@@ -185,11 +194,12 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
||||
glGenFramebuffers (1, &fbo);
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, fbo);
|
||||
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0);
|
||||
if (gdk_gl_context_check_version (context, 4, 3, 3, 1))
|
||||
if (gdk_gl_context_check_version (context, "4.3", "3.1"))
|
||||
{
|
||||
gdk_gl_context_get_version (context, &major, &minor);
|
||||
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
|
||||
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type);
|
||||
if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (context), gl_read_format, gl_read_type, &actual_format))
|
||||
if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (context), major, minor, gl_read_format, gl_read_type, &actual_format))
|
||||
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
|
||||
}
|
||||
else
|
||||
@@ -291,6 +301,12 @@ gdk_gl_texture_has_mipmap (GdkGLTexture *self)
|
||||
return self->has_mipmap;
|
||||
}
|
||||
|
||||
gpointer
|
||||
gdk_gl_texture_get_sync (GdkGLTexture *self)
|
||||
{
|
||||
return self->sync;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_release:
|
||||
* @self: a `GdkTexture` wrapping a GL texture
|
||||
@@ -316,6 +332,47 @@ gdk_gl_texture_release (GdkGLTexture *self)
|
||||
drop_gl_resources (self);
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
gdk_gl_texture_new_from_builder (GdkGLTextureBuilder *builder,
|
||||
GDestroyNotify destroy,
|
||||
gpointer data)
|
||||
{
|
||||
GdkGLTexture *self;
|
||||
GdkTexture *update_texture;
|
||||
|
||||
self = g_object_new (GDK_TYPE_GL_TEXTURE,
|
||||
"width", gdk_gl_texture_builder_get_width (builder),
|
||||
"height", gdk_gl_texture_builder_get_height (builder),
|
||||
NULL);
|
||||
|
||||
self->context = g_object_ref (gdk_gl_texture_builder_get_context (builder));
|
||||
self->id = gdk_gl_texture_builder_get_id (builder);
|
||||
GDK_TEXTURE (self)->format = gdk_gl_texture_builder_get_format (builder);
|
||||
self->has_mipmap = gdk_gl_texture_builder_get_has_mipmap (builder);
|
||||
if (gdk_gl_context_has_sync (self->context))
|
||||
self->sync = gdk_gl_texture_builder_get_sync (builder);
|
||||
self->destroy = destroy;
|
||||
self->data = data;
|
||||
|
||||
update_texture = gdk_gl_texture_builder_get_update_texture (builder);
|
||||
if (update_texture)
|
||||
{
|
||||
cairo_region_t *update_region = gdk_gl_texture_builder_get_update_region (builder);
|
||||
if (update_region)
|
||||
{
|
||||
update_region = cairo_region_copy (update_region);
|
||||
cairo_region_intersect_rectangle (update_region,
|
||||
&(cairo_rectangle_int_t) {
|
||||
0, 0,
|
||||
update_texture->width, update_texture->height
|
||||
});
|
||||
gdk_texture_set_diff (GDK_TEXTURE (self), update_texture, update_region);
|
||||
}
|
||||
}
|
||||
|
||||
return GDK_TEXTURE (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_texture_determine_format (GdkGLTexture *self)
|
||||
{
|
||||
@@ -330,7 +387,7 @@ gdk_gl_texture_determine_format (GdkGLTexture *self)
|
||||
if (context == NULL ||
|
||||
!gdk_gl_context_is_shared (self->context, context) ||
|
||||
/* ... or glGetTexLevelParameter() isn't supported */
|
||||
!gdk_gl_context_check_version (context, 0, 0, 3, 1))
|
||||
!gdk_gl_context_check_version (context, NULL, "3.1"))
|
||||
{
|
||||
texture->format = GDK_MEMORY_DEFAULT;
|
||||
self->has_mipmap = FALSE;
|
||||
@@ -458,6 +515,9 @@ gdk_gl_texture_determine_format (GdkGLTexture *self)
|
||||
*
|
||||
* Return value: (transfer full) (type GdkGLTexture): A newly-created
|
||||
* `GdkTexture`
|
||||
*
|
||||
* Deprecated: 4.12: [class@Gdk.GLTextureBuilder] supercedes this function
|
||||
* and provides extended functionality for creating GL textures.
|
||||
*/
|
||||
GdkTexture *
|
||||
gdk_gl_texture_new (GdkGLContext *context,
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkglcontext.h>
|
||||
#include <gdk/gdktexture.h>
|
||||
|
||||
@@ -38,7 +39,7 @@ typedef struct _GdkGLTextureClass GdkGLTextureClass;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_gl_texture_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_12_FOR(GdkGLTextureBuilder)
|
||||
GdkTexture * gdk_gl_texture_new (GdkGLContext *context,
|
||||
guint id,
|
||||
int width,
|
||||
|
802
gdk/gdkgltexturebuilder.c
Normal file
802
gdk/gdkgltexturebuilder.c
Normal file
@@ -0,0 +1,802 @@
|
||||
/*
|
||||
* Copyright © 2023 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkgltexturebuilder.h"
|
||||
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdkglcontext.h"
|
||||
#include "gdkgltextureprivate.h"
|
||||
|
||||
#include <cairo-gobject.h>
|
||||
|
||||
struct _GdkGLTextureBuilder
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GdkGLContext *context;
|
||||
guint id;
|
||||
int width;
|
||||
int height;
|
||||
GdkMemoryFormat format;
|
||||
gboolean has_mipmap;
|
||||
gpointer sync;
|
||||
|
||||
GdkTexture *update_texture;
|
||||
cairo_region_t *update_region;
|
||||
};
|
||||
|
||||
struct _GdkGLTextureBuilderClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:
|
||||
*
|
||||
* `GdkGLTextureBuilder` is a buider used to construct [class@Gdk.Texture] objects from
|
||||
* GL textures.
|
||||
*
|
||||
* The operation is quite simple: Create a texture builder, set all the necessary
|
||||
* properties - keep in mind that the properties [property@Gdk.GLTextureBuilder:context],
|
||||
* [property@Gdk.GLTextureBuilder:id], [property@Gdk.GLTextureBuilder:width], and
|
||||
* [property@Gdk.GLTextureBuilder:height] are mandatory - and then call
|
||||
* [method@Gdk.GLTextureBuilder.build] to create the new texture.
|
||||
*
|
||||
* `GdkGLTextureBuilder` can be used for quick one-shot construction of
|
||||
* textures as well as kept around and reused to construct multiple textures.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_CONTEXT,
|
||||
PROP_FORMAT,
|
||||
PROP_HAS_MIPMAP,
|
||||
PROP_HEIGHT,
|
||||
PROP_ID,
|
||||
PROP_SYNC,
|
||||
PROP_UPDATE_REGION,
|
||||
PROP_UPDATE_TEXTURE,
|
||||
PROP_WIDTH,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GdkGLTextureBuilder, gdk_gl_texture_builder, G_TYPE_OBJECT)
|
||||
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
static void
|
||||
gdk_gl_texture_builder_dispose (GObject *object)
|
||||
{
|
||||
GdkGLTextureBuilder *self = GDK_GL_TEXTURE_BUILDER (object);
|
||||
|
||||
g_clear_object (&self->context);
|
||||
|
||||
g_clear_object (&self->update_texture);
|
||||
g_clear_pointer (&self->update_region, cairo_region_destroy);
|
||||
|
||||
G_OBJECT_CLASS (gdk_gl_texture_builder_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_texture_builder_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkGLTextureBuilder *self = GDK_GL_TEXTURE_BUILDER (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_CONTEXT:
|
||||
g_value_set_object (value, self->context);
|
||||
break;
|
||||
|
||||
case PROP_FORMAT:
|
||||
g_value_set_enum (value, self->format);
|
||||
break;
|
||||
|
||||
case PROP_HAS_MIPMAP:
|
||||
g_value_set_boolean (value, self->has_mipmap);
|
||||
break;
|
||||
|
||||
case PROP_HEIGHT:
|
||||
g_value_set_int (value, self->height);
|
||||
break;
|
||||
|
||||
case PROP_ID:
|
||||
g_value_set_uint (value, self->id);
|
||||
break;
|
||||
|
||||
case PROP_SYNC:
|
||||
g_value_set_pointer (value, self->sync);
|
||||
break;
|
||||
|
||||
case PROP_UPDATE_REGION:
|
||||
g_value_set_boxed (value, self->update_region);
|
||||
break;
|
||||
|
||||
case PROP_UPDATE_TEXTURE:
|
||||
g_value_set_object (value, self->update_texture);
|
||||
break;
|
||||
|
||||
case PROP_WIDTH:
|
||||
g_value_set_int (value, self->width);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_texture_builder_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkGLTextureBuilder *self = GDK_GL_TEXTURE_BUILDER (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_CONTEXT:
|
||||
gdk_gl_texture_builder_set_context (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_FORMAT:
|
||||
gdk_gl_texture_builder_set_format (self, g_value_get_enum (value));
|
||||
break;
|
||||
|
||||
case PROP_HAS_MIPMAP:
|
||||
gdk_gl_texture_builder_set_has_mipmap (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_HEIGHT:
|
||||
gdk_gl_texture_builder_set_height (self, g_value_get_int (value));
|
||||
break;
|
||||
|
||||
case PROP_ID:
|
||||
gdk_gl_texture_builder_set_id (self, g_value_get_uint (value));
|
||||
break;
|
||||
|
||||
case PROP_SYNC:
|
||||
gdk_gl_texture_builder_set_sync (self, g_value_get_pointer (value));
|
||||
break;
|
||||
|
||||
case PROP_UPDATE_REGION:
|
||||
gdk_gl_texture_builder_set_update_region (self, g_value_get_boxed (value));
|
||||
break;
|
||||
|
||||
case PROP_UPDATE_TEXTURE:
|
||||
gdk_gl_texture_builder_set_update_texture (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_WIDTH:
|
||||
gdk_gl_texture_builder_set_width (self, g_value_get_int (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->dispose = gdk_gl_texture_builder_dispose;
|
||||
gobject_class->get_property = gdk_gl_texture_builder_get_property;
|
||||
gobject_class->set_property = gdk_gl_texture_builder_set_property;
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:context: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_context org.gdk.Property.set=gdk_gl_texture_builder_set_context)
|
||||
*
|
||||
* The context owning the texture.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
properties[PROP_CONTEXT] =
|
||||
g_param_spec_object ("context", NULL, NULL,
|
||||
GDK_TYPE_GL_CONTEXT,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:format: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_format org.gdk.Property.set=gdk_gl_texture_builder_set_format)
|
||||
*
|
||||
* The format when downloading the texture.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
properties[PROP_FORMAT] =
|
||||
g_param_spec_enum ("format", NULL, NULL,
|
||||
GDK_TYPE_MEMORY_FORMAT,
|
||||
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:has-mipmap: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_has_mipmap org.gdk.Property.set=gdk_gl_texture_builder_set_has_mipmap)
|
||||
*
|
||||
* If the texture has a mipmap.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
properties[PROP_HAS_MIPMAP] =
|
||||
g_param_spec_boolean ("has-mipmap", NULL, NULL,
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:height: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_height org.gdk.Property.set=gdk_gl_texture_builder_set_height)
|
||||
*
|
||||
* The height of the texture.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
properties[PROP_HEIGHT] =
|
||||
g_param_spec_int ("height", NULL, NULL,
|
||||
G_MININT, G_MAXINT, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:id: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_id org.gdk.Property.set=gdk_gl_texture_builder_set_id)
|
||||
*
|
||||
* The texture ID to use.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
properties[PROP_ID] =
|
||||
g_param_spec_uint ("id", NULL, NULL,
|
||||
0, G_MAXUINT, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:sync: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_sync org.gdk.Property.set=gdk_gl_texture_builder_set_sync)
|
||||
*
|
||||
* An optional `GLSync` object.
|
||||
*
|
||||
* If this is set, GTK will wait on it before using the texture.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
properties[PROP_SYNC] =
|
||||
g_param_spec_pointer ("sync", NULL, NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:update-region: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_update_region org.gdk.Property.set=gdk_gl_texture_builder_set_update_region)
|
||||
*
|
||||
* The update region for [property@Gdk.GLTextureBuilder:update-texture].
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
properties[PROP_UPDATE_REGION] =
|
||||
g_param_spec_boxed ("update-region", NULL, NULL,
|
||||
CAIRO_GOBJECT_TYPE_REGION,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:update-texture: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_update_texture org.gdk.Property.set=gdk_gl_texture_builder_set_update_texture)
|
||||
*
|
||||
* The texture [property@Gdk.GLTextureBuilder:update-region] is an update for.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
properties[PROP_UPDATE_TEXTURE] =
|
||||
g_param_spec_object ("update-texture", NULL, NULL,
|
||||
GDK_TYPE_TEXTURE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:width: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_width org.gdk.Property.set=gdk_gl_texture_builder_set_width)
|
||||
*
|
||||
* The width of the texture.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
properties[PROP_WIDTH] =
|
||||
g_param_spec_int ("width", NULL, NULL,
|
||||
G_MININT, G_MAXINT, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_texture_builder_init (GdkGLTextureBuilder *self)
|
||||
{
|
||||
self->format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_new: (constructor):
|
||||
*
|
||||
* Creates a new texture builder.
|
||||
*
|
||||
* Returns: the new `GdkTextureBuilder`
|
||||
*
|
||||
* Since: 4.12
|
||||
**/
|
||||
GdkGLTextureBuilder *
|
||||
gdk_gl_texture_builder_new (void)
|
||||
{
|
||||
return g_object_new (GDK_TYPE_GL_TEXTURE_BUILDER, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_context: (attributes org.gdk.Method.get_property=context)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
*
|
||||
* Gets the context previously set via gdk_gl_texture_builder_set_context() or
|
||||
* %NULL if none was set.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): The context
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
GdkGLContext *
|
||||
gdk_gl_texture_builder_get_context (GdkGLTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), NULL);
|
||||
|
||||
return self->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_set_context: (attributes org.gdk.Method.set_property=context)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
* @context: (nullable): The context the texture beongs to or %NULL to unset
|
||||
*
|
||||
* Sets the context to be used for the texture. This is the context that owns
|
||||
* the texture.
|
||||
*
|
||||
* The context must be set before calling [method@Gdk.GLTextureBuilder.build].
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
gdk_gl_texture_builder_set_context (GdkGLTextureBuilder *self,
|
||||
GdkGLContext *context)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
|
||||
g_return_if_fail (context == NULL || GDK_IS_GL_CONTEXT (context));
|
||||
|
||||
if (!g_set_object (&self->context, context))
|
||||
return;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CONTEXT]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_height: (attributes org.gdk.Method.get_property=height)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
*
|
||||
* Gets the height previously set via gdk_gl_texture_builder_set_height() or
|
||||
* 0 if the height wasn't set.
|
||||
*
|
||||
* Returns: The height
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
int
|
||||
gdk_gl_texture_builder_get_height (GdkGLTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), 0);
|
||||
|
||||
return self->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_set_height: (attributes org.gdk.Method.set_property=height)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
* @height: The texture's height or 0 to unset
|
||||
*
|
||||
* Sets the height of the texture.
|
||||
*
|
||||
* The height must be set before calling [method@Gdk.GLTextureBuilder.build].
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
gdk_gl_texture_builder_set_height (GdkGLTextureBuilder *self,
|
||||
int height)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
|
||||
|
||||
if (self->height == height)
|
||||
return;
|
||||
|
||||
self->height = height;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HEIGHT]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_id: (attributes org.gdk.Method.get_property=id)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
*
|
||||
* Gets the texture id previously set via gdk_gl_texture_builder_set_id() or
|
||||
* 0 if the id wasn't set.
|
||||
*
|
||||
* Returns: The id
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
guint
|
||||
gdk_gl_texture_builder_get_id (GdkGLTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), 0);
|
||||
|
||||
return self->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_set_id: (attributes org.gdk.Method.set_property=id)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
* @id: The texture id to be used for creating the texture
|
||||
*
|
||||
* Sets the texture id of the texture. The texture id must remain unmodified
|
||||
* until the texture was finalized. See [method@Gdk.GLTextureBuilder.build]
|
||||
* for a longer discussion.
|
||||
*
|
||||
* The id must be set before calling [method@Gdk.GLTextureBuilder.build].
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
gdk_gl_texture_builder_set_id (GdkGLTextureBuilder *self,
|
||||
guint id)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
|
||||
|
||||
if (self->id == id)
|
||||
return;
|
||||
|
||||
self->id = id;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ID]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_width: (attributes org.gdk.Method.get_property=width)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
*
|
||||
* Gets the width previously set via gdk_gl_texture_builder_set_width() or
|
||||
* 0 if the width wasn't set.
|
||||
*
|
||||
* Returns: The width
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
int
|
||||
gdk_gl_texture_builder_get_width (GdkGLTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), 0);
|
||||
|
||||
return self->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_set_width: (attributes org.gdk.Method.set_property=width)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
* @width: The texture's width or 0 to unset
|
||||
*
|
||||
* Sets the width of the texture.
|
||||
*
|
||||
* The width must be set before calling [method@Gdk.GLTextureBuilder.build].
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
gdk_gl_texture_builder_set_width (GdkGLTextureBuilder *self,
|
||||
int width)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
|
||||
|
||||
if (self->width == width)
|
||||
return;
|
||||
|
||||
self->width = width;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_WIDTH]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_has_mipmap: (attributes org.gdk.Method.get_property=has-mipmap)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
*
|
||||
* Gets whether the texture has a mipmap.
|
||||
*
|
||||
* Returns: Whether the texture has a mipmap
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
gboolean
|
||||
gdk_gl_texture_builder_get_has_mipmap (GdkGLTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), FALSE);
|
||||
|
||||
return self->has_mipmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_set_has_mipmap: (attributes org.gdk.Method.set_property=has-mipmap)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
* @has_mipmap: Whether the texture has a mipmap
|
||||
*
|
||||
* Sets whether the texture has a mipmap. This allows the renderer and other users of the
|
||||
* generated texture to use a higher quality downscaling.
|
||||
*
|
||||
* Typically, the `glGenerateMipmap` function is used to generate a mimap.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
gdk_gl_texture_builder_set_has_mipmap (GdkGLTextureBuilder *self,
|
||||
gboolean has_mipmap)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
|
||||
|
||||
if (self->has_mipmap == has_mipmap)
|
||||
return;
|
||||
|
||||
self->has_mipmap = has_mipmap;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HAS_MIPMAP]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_sync: (attributes org.gdk.Method.get_property=sync)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
*
|
||||
* Gets the `GLsync` previously set via gdk_gl_texture_builder_set_sync().
|
||||
*
|
||||
* Returns: (nullable): the `GLSync`
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
gpointer
|
||||
gdk_gl_texture_builder_get_sync (GdkGLTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), NULL);
|
||||
|
||||
return self->sync;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_set_sync: (attributes org.gdk.Method.set_property=sync)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
* @sync: (nullable): the GLSync object
|
||||
*
|
||||
* Sets the GLSync object to use for the texture.
|
||||
*
|
||||
* GTK will wait on this object before using the created `GdkTexture`.
|
||||
*
|
||||
* The `destroy` function that is passed to [method@Gdk.GLTextureBuilder.build]
|
||||
* is responsible for freeing the sync object when it is no longer needed.
|
||||
* The texture builder does not destroy it and it is the callers
|
||||
* responsibility to make sure it doesn't leak.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
gdk_gl_texture_builder_set_sync (GdkGLTextureBuilder *self,
|
||||
gpointer sync)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
|
||||
|
||||
if (self->sync == sync)
|
||||
return;
|
||||
|
||||
self->sync = sync;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SYNC]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_format: (attributes org.gdk.Method.get_property=format)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
*
|
||||
* Gets the format previously set via gdk_gl_texture_builder_set_format().
|
||||
*
|
||||
* Returns: The format
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
GdkMemoryFormat
|
||||
gdk_gl_texture_builder_get_format (GdkGLTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), GDK_MEMORY_R8G8B8A8_PREMULTIPLIED);
|
||||
|
||||
return self->format;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_set_format: (attributes org.gdk.Method.set_property=format)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
* @format: The texture's format
|
||||
*
|
||||
* Sets the format of the texture. The default is `GDK_MEMORY_R8G8B8A8_PREMULTIPLIED`.
|
||||
*
|
||||
* The format is the preferred format the texture data should be downloaded to. The
|
||||
* format must be supported by the GL version of [property@Gdk.GLTextureBuilder:context].
|
||||
*
|
||||
* Setting the right format is particularly useful when using high bit depth textures
|
||||
* to preserve the bit depth, to set the correct value for unpremultiplied textures
|
||||
* and to make sure opaque textures are treated as such.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
gdk_gl_texture_builder_set_format (GdkGLTextureBuilder *self,
|
||||
GdkMemoryFormat format)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
|
||||
|
||||
if (self->format == format)
|
||||
return;
|
||||
|
||||
self->format = format;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FORMAT]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_update_texture: (attributes org.gdk.Method.get_property=update_texture)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
*
|
||||
* Gets the texture previously set via gdk_gl_texture_builder_set_update_texture() or
|
||||
* %NULL if none was set.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): The texture
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
GdkTexture *
|
||||
gdk_gl_texture_builder_get_update_texture (GdkGLTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), NULL);
|
||||
|
||||
return self->update_texture;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_set_update_texture: (attributes org.gdk.Method.set_property=update_texture)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
* @texture: (nullable): the texture to update
|
||||
*
|
||||
* Sets the texture to be updated by this texture. See
|
||||
* [method@Gdk.GLTextureBuilder.set_update_region] for an explanation.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
gdk_gl_texture_builder_set_update_texture (GdkGLTextureBuilder *self,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
|
||||
g_return_if_fail (texture == NULL || GDK_IS_TEXTURE (texture));
|
||||
|
||||
if (!g_set_object (&self->update_texture, texture))
|
||||
return;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_UPDATE_TEXTURE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_update_region: (attributes org.gdk.Method.get_property=update_region)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
*
|
||||
* Gets the region previously set via gdk_gl_texture_builder_set_update_region() or
|
||||
* %NULL if none was set.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): The region
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
cairo_region_t *
|
||||
gdk_gl_texture_builder_get_update_region (GdkGLTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), NULL);
|
||||
|
||||
return self->update_region;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_set_update_region: (attributes org.gdk.Method.set_property=update_region)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
* @region: (nullable): the region to update
|
||||
*
|
||||
* Sets the region to be updated by this texture. Together with
|
||||
* [property@Gdk.GLTextureBuilder:update-texture] this describes an
|
||||
* update of a previous texture.
|
||||
*
|
||||
* When rendering animations of large textures, it is possible that
|
||||
* consecutive textures are only updating contents in parts of the texture.
|
||||
* It is then possible to describe this update via these two properties,
|
||||
* so that GTK can avoid rerendering parts that did not change.
|
||||
*
|
||||
* An example would be a screen recording where only the mouse pointer moves.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
gdk_gl_texture_builder_set_update_region (GdkGLTextureBuilder *self,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
|
||||
|
||||
if (self->update_region == region)
|
||||
return;
|
||||
|
||||
g_clear_pointer (&self->update_region, cairo_region_destroy);
|
||||
|
||||
if (region)
|
||||
self->update_region = cairo_region_reference (region);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_UPDATE_REGION]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_build:
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
* @destroy: (nullable): destroy function to be called when the texture is
|
||||
* released
|
||||
* @data: user data to pass to the destroy function
|
||||
*
|
||||
* Builds a new `GdkTexture` with the values set up in the builder.
|
||||
*
|
||||
* The `destroy` function gets called when the returned texture gets released;
|
||||
* either when the texture is finalized or by an explicit call to
|
||||
* [method@Gdk.GLTexture.release]. It should release all GL resources associated
|
||||
* with the texture, such as the [property@Gdk.GLTextureBuilder:id] and the
|
||||
* [property@Gdk.GLTextureBuilder:sync].
|
||||
*
|
||||
* Note that it is a programming error to call this function if any mandatory
|
||||
* property has not been set.
|
||||
*
|
||||
* It is possible to call this function multiple times to create multiple textures,
|
||||
* possibly with changing properties in between.
|
||||
*
|
||||
* Returns: (transfer full): a newly built `GdkTexture`
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
GdkTexture *
|
||||
gdk_gl_texture_builder_build (GdkGLTextureBuilder *self,
|
||||
GDestroyNotify destroy,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), NULL);
|
||||
g_return_val_if_fail (destroy == NULL || data != NULL, NULL);
|
||||
g_return_val_if_fail (self->context != NULL, NULL);
|
||||
g_return_val_if_fail (self->id != 0, NULL);
|
||||
g_return_val_if_fail (self->width > 0, NULL);
|
||||
g_return_val_if_fail (self->height > 0, NULL);
|
||||
|
||||
return gdk_gl_texture_new_from_builder (self, destroy, data);
|
||||
}
|
||||
|
97
gdk/gdkgltexturebuilder.h
Normal file
97
gdk/gdkgltexturebuilder.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright © 2023 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_GL_TEXTURE_BUILDER (gdk_gl_texture_builder_get_type ())
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
GDK_DECLARE_INTERNAL_TYPE (GdkGLTextureBuilder, gdk_gl_texture_builder, GDK, GL_TEXTURE_BUILDER, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
GdkGLTextureBuilder * gdk_gl_texture_builder_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
GdkGLContext * gdk_gl_texture_builder_get_context (GdkGLTextureBuilder *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
void gdk_gl_texture_builder_set_context (GdkGLTextureBuilder *self,
|
||||
GdkGLContext *context);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
guint gdk_gl_texture_builder_get_id (GdkGLTextureBuilder *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
void gdk_gl_texture_builder_set_id (GdkGLTextureBuilder *self,
|
||||
guint id);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
int gdk_gl_texture_builder_get_width (GdkGLTextureBuilder *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
void gdk_gl_texture_builder_set_width (GdkGLTextureBuilder *self,
|
||||
int width);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
int gdk_gl_texture_builder_get_height (GdkGLTextureBuilder *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
void gdk_gl_texture_builder_set_height (GdkGLTextureBuilder *self,
|
||||
int height);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
GdkMemoryFormat gdk_gl_texture_builder_get_format (GdkGLTextureBuilder *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
void gdk_gl_texture_builder_set_format (GdkGLTextureBuilder *self,
|
||||
GdkMemoryFormat format);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
gboolean gdk_gl_texture_builder_get_has_mipmap (GdkGLTextureBuilder *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
void gdk_gl_texture_builder_set_has_mipmap (GdkGLTextureBuilder *self,
|
||||
gboolean has_mipmap);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
gpointer gdk_gl_texture_builder_get_sync (GdkGLTextureBuilder *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
void gdk_gl_texture_builder_set_sync (GdkGLTextureBuilder *self,
|
||||
gpointer sync);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
GdkTexture * gdk_gl_texture_builder_get_update_texture (GdkGLTextureBuilder *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
void gdk_gl_texture_builder_set_update_texture (GdkGLTextureBuilder *self,
|
||||
GdkTexture *texture);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
cairo_region_t * gdk_gl_texture_builder_get_update_region (GdkGLTextureBuilder *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
void gdk_gl_texture_builder_set_update_region (GdkGLTextureBuilder *self,
|
||||
cairo_region_t *region);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
GdkTexture * gdk_gl_texture_builder_build (GdkGLTextureBuilder *self,
|
||||
GDestroyNotify destroy,
|
||||
gpointer data);
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -2,13 +2,20 @@
|
||||
|
||||
#include "gdkgltexture.h"
|
||||
|
||||
#include "gdkgltexturebuilder.h"
|
||||
#include "gdktextureprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GdkTexture * gdk_gl_texture_new_from_builder (GdkGLTextureBuilder *builder,
|
||||
GDestroyNotify destroy,
|
||||
gpointer data);
|
||||
|
||||
|
||||
GdkGLContext * gdk_gl_texture_get_context (GdkGLTexture *self);
|
||||
guint gdk_gl_texture_get_id (GdkGLTexture *self);
|
||||
gboolean gdk_gl_texture_has_mipmap (GdkGLTexture *self);
|
||||
gpointer gdk_gl_texture_get_sync (GdkGLTexture *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
138
gdk/gdkglversionprivate.h
Normal file
138
gdk/gdkglversionprivate.h
Normal file
@@ -0,0 +1,138 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
*
|
||||
* gdkglcontextprivate.h: GL context abstraction
|
||||
*
|
||||
* Copyright © 2014 Emmanuele Bassi
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gdkenums.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Version requirements for EGL contexts.
|
||||
*
|
||||
* If you add support for EGL to your backend, please require this.
|
||||
*/
|
||||
#define GDK_EGL_MIN_VERSION_MAJOR (1)
|
||||
#define GDK_EGL_MIN_VERSION_MINOR (4)
|
||||
|
||||
/* Minimum OpenGL versions supported by GTK.
|
||||
* Backends should make sure to never create a context of a previous version.
|
||||
*
|
||||
* The macros refer to OpenGL; OpenGL with OPENGL_COMPATIBILITY_PROFILE_BIT as
|
||||
* OPENGL_PROFILE_MASK; and OpenGL ES respectively
|
||||
*/
|
||||
#define GDK_GL_MIN_GL_VERSION GDK_GL_VERSION_INIT (3, 2)
|
||||
#define GDK_GL_MIN_GL_LEGACY_VERSION GDK_GL_VERSION_INIT (3, 0)
|
||||
#define GDK_GL_MIN_GLES_VERSION GDK_GL_VERSION_INIT (2, 0)
|
||||
|
||||
typedef struct _GdkGLVersion GdkGLVersion;
|
||||
|
||||
struct _GdkGLVersion
|
||||
{
|
||||
int major;
|
||||
int minor;
|
||||
};
|
||||
|
||||
#define GDK_GL_VERSION_INIT(maj,min) { maj, min }
|
||||
|
||||
static const GdkGLVersion supported_gl_versions[] = {
|
||||
GDK_GL_VERSION_INIT (4, 6),
|
||||
GDK_GL_VERSION_INIT (4, 5),
|
||||
GDK_GL_VERSION_INIT (4, 4),
|
||||
GDK_GL_VERSION_INIT (4, 3),
|
||||
GDK_GL_VERSION_INIT (4, 2),
|
||||
GDK_GL_VERSION_INIT (4, 1),
|
||||
GDK_GL_VERSION_INIT (4, 0),
|
||||
GDK_GL_VERSION_INIT (3, 3),
|
||||
GDK_GL_VERSION_INIT (3, 2),
|
||||
GDK_GL_VERSION_INIT (3, 1),
|
||||
GDK_GL_VERSION_INIT (3, 0),
|
||||
|
||||
GDK_GL_VERSION_INIT (0, 0)
|
||||
};
|
||||
|
||||
static const GdkGLVersion supported_gles_versions[] = {
|
||||
GDK_GL_VERSION_INIT (3, 2),
|
||||
GDK_GL_VERSION_INIT (3, 1),
|
||||
GDK_GL_VERSION_INIT (3, 0),
|
||||
GDK_GL_VERSION_INIT (2, 0),
|
||||
|
||||
GDK_GL_VERSION_INIT (0, 0)
|
||||
};
|
||||
|
||||
#undef GDK_GL_VERSION_INIT
|
||||
#define GDK_GL_VERSION_INIT(maj,min) (GdkGLVersion) { maj, min }
|
||||
#define GDK_GL_VERSION_STRING(str) GDK_GL_VERSION_INIT(str[0] - '0', str[2] - '0')
|
||||
|
||||
static inline const GdkGLVersion *
|
||||
gdk_gl_versions_get_for_api (GdkGLAPI api)
|
||||
{
|
||||
switch (api)
|
||||
{
|
||||
case GDK_GL_API_GL:
|
||||
return supported_gl_versions;
|
||||
case GDK_GL_API_GLES:
|
||||
return supported_gles_versions;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int
|
||||
gdk_gl_version_get_major (const GdkGLVersion *self)
|
||||
{
|
||||
return self->major;
|
||||
}
|
||||
|
||||
static inline int
|
||||
gdk_gl_version_get_minor (const GdkGLVersion *self)
|
||||
{
|
||||
return self->minor;
|
||||
}
|
||||
|
||||
static inline int
|
||||
gdk_gl_version_compare (const GdkGLVersion *a,
|
||||
const GdkGLVersion *b)
|
||||
{
|
||||
if (a->major > b->major)
|
||||
return 1;
|
||||
if (a->major < b->major)
|
||||
return -1;
|
||||
|
||||
if (a->minor > b->minor)
|
||||
return 1;
|
||||
if (a->minor < b->minor)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
gdk_gl_version_greater_equal (const GdkGLVersion *a,
|
||||
const GdkGLVersion *b)
|
||||
{
|
||||
return gdk_gl_version_compare (a, b) >= 0;
|
||||
}
|
||||
|
||||
/* in gdkglcontext.c */
|
||||
void gdk_gl_version_init_epoxy (GdkGLVersion *version);
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -28,7 +28,6 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@@ -220,7 +220,12 @@ struct _GdkMemoryFormatDescription
|
||||
gsize bytes_per_pixel;
|
||||
gsize alignment;
|
||||
gboolean prefers_high_depth;
|
||||
gboolean supports_gles;
|
||||
struct {
|
||||
guint gl_major;
|
||||
guint gl_minor;
|
||||
guint gles_major;
|
||||
guint gles_minor;
|
||||
} min_gl_version;
|
||||
struct {
|
||||
guint internal_format;
|
||||
guint format;
|
||||
@@ -245,7 +250,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
|
||||
b8g8r8a8_premultiplied_to_float,
|
||||
b8g8r8a8_premultiplied_from_float,
|
||||
@@ -255,7 +260,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
|
||||
a8r8g8b8_premultiplied_to_float,
|
||||
a8r8g8b8_premultiplied_from_float,
|
||||
@@ -265,7 +270,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
TRUE,
|
||||
{ 0, 0, 0, 0 },
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
|
||||
r8g8b8a8_premultiplied_to_float,
|
||||
r8g8b8a8_premultiplied_from_float,
|
||||
@@ -275,7 +280,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
|
||||
b8g8r8a8_to_float,
|
||||
b8g8r8a8_from_float,
|
||||
@@ -285,7 +290,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_RGBA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
|
||||
a8r8g8b8_to_float,
|
||||
a8r8g8b8_from_float,
|
||||
@@ -295,7 +300,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
TRUE,
|
||||
{ 0, 0, 0, 0 },
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
|
||||
r8g8b8a8_to_float,
|
||||
r8g8b8a8_from_float,
|
||||
@@ -305,7 +310,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
|
||||
a8b8g8r8_to_float,
|
||||
a8b8g8r8_from_float,
|
||||
@@ -315,7 +320,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
3,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
TRUE,
|
||||
{ 0, 0, 0, 0 },
|
||||
{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE },
|
||||
r8g8b8_to_float,
|
||||
r8g8b8_from_float,
|
||||
@@ -325,7 +330,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
3,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE },
|
||||
b8g8r8_to_float,
|
||||
b8g8r8_from_float,
|
||||
@@ -335,7 +340,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
6,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT },
|
||||
r16g16b16_to_float,
|
||||
r16g16b16_from_float,
|
||||
@@ -345,7 +350,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
8,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
|
||||
r16g16b16a16_to_float,
|
||||
r16g16b16a16_from_float,
|
||||
@@ -355,7 +360,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
8,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
|
||||
r16g16b16a16_to_float,
|
||||
r16g16b16a16_from_float,
|
||||
@@ -365,7 +370,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
6,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGB16F, GL_RGB, GL_HALF_FLOAT },
|
||||
r16g16b16_float_to_float,
|
||||
r16g16b16_float_from_float,
|
||||
@@ -375,7 +380,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
8,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
|
||||
r16g16b16a16_float_to_float,
|
||||
r16g16b16a16_float_from_float,
|
||||
@@ -385,7 +390,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
8,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
|
||||
r16g16b16a16_float_to_float,
|
||||
r16g16b16a16_float_from_float,
|
||||
@@ -395,7 +400,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
12,
|
||||
G_ALIGNOF (float),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGB32F, GL_RGB, GL_FLOAT },
|
||||
r32g32b32_float_to_float,
|
||||
r32g32b32_float_from_float,
|
||||
@@ -405,7 +410,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
16,
|
||||
G_ALIGNOF (float),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
|
||||
r32g32b32a32_float_to_float,
|
||||
r32g32b32a32_float_from_float,
|
||||
@@ -415,7 +420,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
16,
|
||||
G_ALIGNOF (float),
|
||||
TRUE,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
|
||||
r32g32b32a32_float_to_float,
|
||||
r32g32b32a32_float_from_float,
|
||||
@@ -463,6 +468,8 @@ gdk_memory_format_prefers_high_depth (GdkMemoryFormat format)
|
||||
gboolean
|
||||
gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
gboolean gles,
|
||||
guint gl_major,
|
||||
guint gl_minor,
|
||||
guint *out_internal_format,
|
||||
guint *out_format,
|
||||
guint *out_type)
|
||||
@@ -474,8 +481,20 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
if (memory_formats[format].alpha == GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
return FALSE;
|
||||
|
||||
if (gles && !memory_formats[format].supports_gles)
|
||||
return FALSE;
|
||||
if (gles)
|
||||
{
|
||||
if (memory_formats[format].min_gl_version.gles_major > gl_major ||
|
||||
(memory_formats[format].min_gl_version.gles_major == gl_major &&
|
||||
memory_formats[format].min_gl_version.gles_minor > gl_minor))
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (memory_formats[format].min_gl_version.gl_major > gl_major ||
|
||||
(memory_formats[format].min_gl_version.gl_major == gl_major &&
|
||||
memory_formats[format].min_gl_version.gl_minor > gl_minor))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -35,6 +35,8 @@ gsize gdk_memory_format_bytes_per_pixel (GdkMemoryFormat
|
||||
gboolean gdk_memory_format_prefers_high_depth(GdkMemoryFormat format) G_GNUC_CONST;
|
||||
gboolean gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
gboolean gles,
|
||||
guint gl_major,
|
||||
guint gl_minor,
|
||||
guint *out_internal_format,
|
||||
guint *out_format,
|
||||
guint *out_type);
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkenums.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdktexture.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include "gdkmonitorprivate.h"
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdkrectangle.h"
|
||||
|
||||
/**
|
||||
* GdkMonitor:
|
||||
|
@@ -25,8 +25,6 @@
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdkrectangle.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@@ -24,7 +24,6 @@
|
||||
#endif
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 2000 Red Hat, Inc.
|
||||
* Copyright (C) 2000 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -22,7 +22,6 @@
|
||||
#endif
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -18,14 +18,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gio/gio.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
GIOStream * gdk_pipe_io_stream_new (void);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user