Compare commits
	
		
			1 Commits
		
	
	
		
			citadel-45
			...
			wip/carlos
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | d7f799bfaf | 
							
								
								
									
										105
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										105
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,6 +1,105 @@ | ||||
| build-aux | ||||
| compile | ||||
| config.h | ||||
| config.h.in | ||||
| ltmain.sh | ||||
| missing | ||||
| 50-mutter-navigation.xml | ||||
| 50-mutter-system.xml | ||||
| 50-mutter-windows.xml | ||||
| mutter.desktop | ||||
| mutter-wayland.desktop | ||||
| *.o | ||||
| *.a | ||||
| *.lo | ||||
| *.la | ||||
| .libs | ||||
| *.swp | ||||
| *.gir | ||||
| *.typelib | ||||
| *.gmo | ||||
| *.make | ||||
| *.log | ||||
| *.trs | ||||
| *~ | ||||
| POTFILES | ||||
| Makevars.template | ||||
| po/*.header | ||||
| po/*.pot | ||||
| po/*.sed | ||||
| po/*.sin | ||||
| Rules-quot | ||||
| libmutter.pc | ||||
| mutter | ||||
| mutter-restart-helper | ||||
| mutter-test-client | ||||
| mutter-test-runner | ||||
| mutter-test-unit-tests | ||||
| mutter-test-headless-start-test | ||||
| mutter-all.test | ||||
| org.gnome.mutter.gschema.valid | ||||
| org.gnome.mutter.gschema.xml | ||||
| org.gnome.mutter.wayland.gschema.valid | ||||
| org.gnome.mutter.wayland.gschema.xml | ||||
| testasyncgetprop | ||||
| testboxes | ||||
| testgradient | ||||
| INSTALL | ||||
| meta-enum-types.[ch] | ||||
| src/stamp-meta-enum-types.h | ||||
| src/meta-dbus-display-config.[ch] | ||||
| src/meta-dbus-idle-monitor.[ch] | ||||
| src/meta-dbus-login1.[ch] | ||||
| src/meta-dbus-remote-desktop.[ch] | ||||
| src/meta-dbus-screen-cast.[ch] | ||||
| src/gtk-primary-selection-protocol.c | ||||
| src/gtk-primary-selection-server-protocol.h | ||||
| src/gtk-shell-protocol.c | ||||
| src/gtk-shell-server-protocol.h | ||||
| src/xdg-shell-unstable-v*-protocol.c | ||||
| src/xdg-shell-unstable-v*-server-protocol.h | ||||
| src/pointer-gestures-unstable-v*-protocol.c | ||||
| src/pointer-gestures-unstable-v*-server-protocol.h | ||||
| src/relative-pointer-unstable-v*-protocol.c | ||||
| src/relative-pointer-unstable-v*-server-protocol.h | ||||
| src/pointer-constraints-unstable-v*-protocol.c | ||||
| src/pointer-constraints-unstable-v*-server-protocol.h | ||||
| src/xdg-foreign-unstable-v*-protocol.c | ||||
| src/xdg-foreign-unstable-v*-server-protocol.h | ||||
| src/xdg-output-unstable-v1-protocol.c | ||||
| src/xdg-output-unstable-v1-server-protocol.h | ||||
| src/xwayland-keyboard-grab-unstable-v1-protocol.c | ||||
| src/xwayland-keyboard-grab-unstable-v1-server-protocol.h | ||||
| src/tablet-unstable-v*-protocol.c | ||||
| src/tablet-unstable-v*-server-protocol.h | ||||
| src/text-input-unstable-v*-protocol.c | ||||
| src/text-input-unstable-v*-server-protocol.h | ||||
| src/keyboard-shortcuts-inhibit-unstable-v*-protocol.c | ||||
| src/keyboard-shortcuts-inhibit-unstable-v*-server-protocol.h | ||||
| src/linux-dmabuf-unstable-v*-protocol.c | ||||
| src/linux-dmabuf-unstable-v*-server-protocol.h | ||||
| src/xdg-shell-protocol.c | ||||
| src/xdg-shell-server-protocol.h | ||||
| src/wayland-eglstream-controller-server-protocol.h | ||||
| src/meta/meta-version.h | ||||
| src/libmutter-*.pc | ||||
| doc/reference/*.args | ||||
| doc/reference/*.bak | ||||
| doc/reference/*.hierarchy | ||||
| doc/reference/*.interfaces | ||||
| doc/reference/*.prerequisites | ||||
| doc/reference/*.signals | ||||
| doc/reference/*.stamp | ||||
| doc/reference/html/ | ||||
| doc/reference/xml/ | ||||
| doc/reference/meta-decl-list.txt | ||||
| doc/reference/meta-decl.txt | ||||
| doc/reference/meta-overrides.txt | ||||
| doc/reference/meta-undeclared.txt | ||||
| doc/reference/meta-undocumented.txt | ||||
| doc/reference/meta-unused.txt | ||||
| doc/reference/meta-docs.sgml | ||||
| doc/reference/meta.types | ||||
| .dirstamp | ||||
| **/tags.* | ||||
| subprojects/sysprof/ | ||||
| __pycache__/ | ||||
| .buildconfig | ||||
| build/ | ||||
|   | ||||
							
								
								
									
										670
									
								
								.gitlab-ci.yml
									
									
									
									
									
								
							
							
						
						
									
										670
									
								
								.gitlab-ci.yml
									
									
									
									
									
								
							| @@ -1,665 +1,79 @@ | ||||
| include: | ||||
|   - remote: 'https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/28b430bd847da130d7c678772b8be260abaab5b3/templates/fedora.yml' | ||||
|   - remote: 'https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/34f4ade99434043f88e164933f570301fd18b125/templates/ci-fairy.yml' | ||||
| image: registry.gitlab.gnome.org/gnome/mutter/master:v2 | ||||
|  | ||||
| stages: | ||||
|  - review | ||||
|  - prepare | ||||
|  - code-review | ||||
|  - build | ||||
|  - test | ||||
|  - analyze | ||||
|  - docs | ||||
|  - deploy | ||||
|  | ||||
| variables: | ||||
|   FDO_UPSTREAM_REPO: GNOME/mutter | ||||
|  | ||||
| .skip-git-clone: | ||||
|   variables: | ||||
|     GIT_STRATEGY: none | ||||
|  | ||||
| .mutter.git-clone: | ||||
|   extends: | ||||
|     - .skip-git-clone | ||||
|   variables: | ||||
|     MUTTER_CLONE_PATH: $CI_BUILDS_DIR/$CI_PROJECT_PATH | ||||
|     MUTTER_CLONE_DEPTH: 1 | ||||
|   before_script: | | ||||
|     if [ -n "$MUTTER_CLONE_PATH" ]; then | ||||
|       set -x | ||||
|       uri="$CI_REPOSITORY_URL" | ||||
|       if [ -n "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ]; then | ||||
|         uri="$CI_MERGE_REQUEST_SOURCE_PROJECT_URL.git" | ||||
|         branch="$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" | ||||
|       elif [ -n "$CI_COMMIT_BRANCH" ]; then | ||||
|         branch="$CI_COMMIT_BRANCH" | ||||
|       else | ||||
|         branch="$CI_DEFAULT_BRANCH" | ||||
|       fi | ||||
|       if [ ! -d "$MUTTER_CLONE_PATH" ] || [ -z "$(ls -A "$MUTTER_CLONE_PATH")" ]; then | ||||
|         git clone --depth $MUTTER_CLONE_DEPTH "$uri" "$MUTTER_CLONE_PATH" -b "$branch" | ||||
|       elif [ ! -d "$MUTTER_CLONE_PATH/.git" ]; then | ||||
|         git clone --bare --depth $MUTTER_CLONE_DEPTH "$uri" "$MUTTER_CLONE_PATH/.git" -b "$branch" | ||||
|         if git -C "$MUTTER_CLONE_PATH" config --unset core.bare; then | ||||
|           git -C "$MUTTER_CLONE_PATH" checkout | ||||
|         else | ||||
|           # For some weird reasons sometimes the fast-path could fail with | ||||
|           # "fatal: not in a git directory" error, so handle it manually | ||||
|           tmpdir=$(mktemp --directory --tmpdir mutter-XXXXXX) | ||||
|           mkdir "$tmpdir/repo" | ||||
|           mv "$MUTTER_CLONE_PATH/.git" "$tmpdir/repo/" | ||||
|           git clone "$tmpdir/repo" "$tmpdir/src" | ||||
|           mv "$tmpdir"/src/* "$tmpdir"/src/.* "$MUTTER_CLONE_PATH" | ||||
|           rm -r "$tmpdir/repo" | ||||
|           rm -rv "$tmpdir" | ||||
|         fi | ||||
|       fi | ||||
|       set +x | ||||
|     fi | ||||
|  | ||||
| .mutter.skip-git-clone: | ||||
|   extends: | ||||
|     - .skip-git-clone | ||||
|   variables: | ||||
|     MUTTER_CLONE_PATH: '' | ||||
|  | ||||
| .mutter.run-as-user: | ||||
|   image: | ||||
|     name: ${FDO_DISTRIBUTION_IMAGE} | ||||
|     entrypoint: | ||||
|       - 'runuser' | ||||
|       - '-u' | ||||
|       - !reference [.mutter.fedora@common, variables, MUTTER_USER] | ||||
|       - '--' | ||||
|  | ||||
| .mutter.distribution-image: | ||||
|   extends: | ||||
|     - .fdo.distribution-image@fedora | ||||
|     - .mutter.run-as-user | ||||
|  | ||||
| .mutter.fedora@common: | ||||
|   extends: | ||||
|     - .skip-git-clone | ||||
|   variables: | ||||
|     FDO_DISTRIBUTION_VERSION: 39 | ||||
|     BASE_TAG: '2023-09-12.0' | ||||
|     MUTTER_USER: 'meta-user' | ||||
|     FDO_DISTRIBUTION_PACKAGES: | ||||
|       asciidoc | ||||
|       clang | ||||
|       gcovr | ||||
|       gdm | ||||
|       gnome-shell | ||||
|       sassc | ||||
|       uncrustify | ||||
|       xorg-x11-server-Xvfb | ||||
|       mesa-dri-drivers | ||||
|       xorg-x11-proto-devel | ||||
|       qemu-system-x86-core | ||||
|       busybox | ||||
|       zenity | ||||
|       gi-docgen | ||||
|       python3-dbusmock | ||||
|       pkgconfig(libgcrypt) | ||||
|       pkgconfig(libdisplay-info) | ||||
|  | ||||
|     FDO_DISTRIBUTION_EXEC: | | ||||
|       set -e | ||||
|  | ||||
|       # Create $MUTTER_USER | ||||
|       useradd -u 9999 -b /opt/mutter -ms /bin/bash $MUTTER_USER | ||||
|  | ||||
|       # Enable sudo for $MUTTER_USER | ||||
|       echo "%$MUTTER_USER ALL = (ALL) NOPASSWD: ALL" > /etc/sudoers.d/99_mutter-user | ||||
|  | ||||
|       dnf install -y 'dnf-command(builddep)' | ||||
|  | ||||
|       dnf builddep -y mutter --setopt=install_weak_deps=False | ||||
|       dnf builddep -y gnome-shell --setopt=install_weak_deps=False | ||||
|       dnf builddep -y kernel --setopt=install_weak_deps=False | ||||
|       dnf builddep -y libei --setopt=install_weak_deps=False | ||||
|  | ||||
|       ./.gitlab-ci/install-meson-project.sh \ | ||||
|         https://gitlab.gnome.org/jadahl/catch.git \ | ||||
|         main . 29ad36e2b1d28ac9d8b2bc44af46296cb1db5d66 | ||||
|  | ||||
|       ./.gitlab-ci/install-meson-project.sh \ | ||||
|         https://gitlab.gnome.org/GNOME/glib.git \ | ||||
|         main . a7c34b431bfaf3d56de64cb1cfea851ac11099d3 | ||||
|  | ||||
|       ./.gitlab-ci/install-meson-project.sh \ | ||||
|         https://gitlab.freedesktop.org/libinput/libei.git \ | ||||
|         1.0.901 . | ||||
|  | ||||
|       rpm -e --nodeps gnome-bluetooth-libs-devel \ | ||||
|                       mutter mutter-devel \ | ||||
|                       gnome-shell | ||||
|  | ||||
|       # Ensure that we mark the project clone dir as safe directory | ||||
|       git config --system --add safe.directory "$CI_PROJECT_DIR" | ||||
|  | ||||
|       if [[ x"$(uname -m )" = "xx86_64" ]] ; then | ||||
|         if [ -n "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ]; then | ||||
|           git clone --depth $MUTTER_CLONE_DEPTH \ | ||||
|             $CI_MERGE_REQUEST_SOURCE_PROJECT_URL.git mutter-src \ | ||||
|             -b "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" | ||||
|         elif [ -n "$CI_COMMIT_BRANCH" ]; then | ||||
|           git clone --depth $MUTTER_CLONE_DEPTH \ | ||||
|             $CI_REPOSITORY_URL mutter-src -b "$CI_COMMIT_BRANCH" | ||||
|         else | ||||
|           git clone --depth $MUTTER_CLONE_DEPTH $CI_REPOSITORY_URL mutter-src | ||||
|         fi | ||||
|         meson setup build mutter-src -Dkvm_tests=true | ||||
|         ninja -C build src/tests/kvm/bzImage | ||||
|         mkdir -p /opt/mutter | ||||
|         cp build/src/tests/kvm/bzImage /opt/mutter/bzImage | ||||
|  | ||||
|         dnf install -y python3-argcomplete | ||||
|  | ||||
|         git clone https://github.com/arighi/virtme-ng.git | ||||
|         cd virtme-ng | ||||
|         git fetch --tags | ||||
|         git checkout v1.8 | ||||
|         ./setup.py install --prefix=/usr | ||||
|         cd .. | ||||
|         rm -rf virtme-ng | ||||
|         rm -rf build mutter-src | ||||
|       fi | ||||
|   retry: | ||||
|     max: 2 | ||||
|     when: | ||||
|       - 'always' | ||||
|  | ||||
| default: | ||||
|   # Cancel jobs if newer commits are pushed to the branch | ||||
|   interruptible: true | ||||
|   # Auto-retry jobs in case of infra failures | ||||
|   retry: | ||||
|     max: 1 | ||||
|     when: | ||||
|       - 'runner_system_failure' | ||||
|       - 'stuck_or_timeout_failure' | ||||
|       - 'scheduler_failure' | ||||
|       - 'api_failure' | ||||
|  | ||||
| .mutter.fedora@x86_64: | ||||
|   extends: | ||||
|     - .mutter.fedora@common | ||||
|     - .mutter.git-clone | ||||
|   variables: | ||||
|     FDO_DISTRIBUTION_TAG: "x86_64-${BASE_TAG}" | ||||
|  | ||||
| .mutter.fedora@aarch64: | ||||
|   extends: | ||||
|     - .mutter.fedora@common | ||||
|     - .mutter.git-clone | ||||
|   variables: | ||||
|     FDO_DISTRIBUTION_TAG: "aarch64-${BASE_TAG}" | ||||
|   tags: | ||||
|     - aarch64 | ||||
|  | ||||
| workflow: | ||||
|   rules: | ||||
|     # Allow to switch from branch pipelines to MR pipelines seamlessly | ||||
|     # https://docs.gitlab.com/ee/ci/jobs/job_control.html#avoid-duplicate-pipelines | ||||
|     - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push" | ||||
|       when: never | ||||
|     - if: $CI_PIPELINE_SOURCE == "merge_request_event" | ||||
|     # Don't trigger a branch pipeline if there is an open MR | ||||
|     - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS | ||||
|       when: never | ||||
|     - if: '$CI_COMMIT_BRANCH' | ||||
|     - if: '$CI_COMMIT_TAG' | ||||
|  | ||||
| .pipeline-guard: | ||||
|   rules: | ||||
|     - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' | ||||
|     - if: '$CI_COMMIT_TAG' | ||||
|     - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' | ||||
|     - if: '$CI_COMMIT_BRANCH =~ /^gnome-[0-9-]+$/' | ||||
|     # Avoid catchall `when: manual` rule which might | ||||
|     # cause duplicate pipelines to be triggered. | ||||
|     # https://docs.gitlab.com/ee/ci/jobs/job_control.html#avoid-duplicate-pipelines | ||||
|     # | ||||
|     # Also make it so pipelines without MR need to be started | ||||
|     # manually, since their state will most likely be WIP | ||||
|     - if: '$CI_COMMIT_BRANCH' | ||||
|       when: 'manual' | ||||
|  | ||||
| .only-merge-requests: | ||||
|   rules: | ||||
|     - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^$/' | ||||
|       when: never | ||||
|     - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME | ||||
|       when: on_success | ||||
|  | ||||
| check-commit-log: | ||||
|   extends: | ||||
|     - .fdo.ci-fairy | ||||
|   stage: review | ||||
|   variables: | ||||
|     GIT_DEPTH: "100" | ||||
|   script: | ||||
|     ci-fairy check-commits --junit-xml=commit-message-junit-report.xml | ||||
|   artifacts: | ||||
|     expire_in: 1 week | ||||
|     paths: | ||||
|       - commit-message-junit-report.xml | ||||
|     reports: | ||||
|       junit: commit-message-junit-report.xml | ||||
|   rules: | ||||
|     - !reference [.only-merge-requests, rules] | ||||
|     - ./.gitlab-ci/check-commit-log.sh | ||||
|   only: | ||||
|     - merge_requests | ||||
|  | ||||
| check-merge-request: | ||||
|   extends: | ||||
|     - .fdo.ci-fairy | ||||
|     - .skip-git-clone | ||||
|   stage: review | ||||
|   script: | ||||
|     ci-fairy check-merge-request --require-allow-collaboration --junit-xml=check-merge-request-report.xml | ||||
|   artifacts: | ||||
|     expire_in: 1 week | ||||
|     paths: | ||||
|       - check-merge-request-report.xml | ||||
|     reports: | ||||
|       junit: check-merge-request-report.xml | ||||
|   rules: | ||||
|     - !reference [.only-merge-requests, rules] | ||||
|  | ||||
| build-fedora-container@x86_64: | ||||
|   extends: | ||||
|     - .fdo.container-build@fedora@x86_64 | ||||
|     - .mutter.fedora@x86_64 | ||||
|     - .mutter.skip-git-clone | ||||
|   stage: prepare | ||||
|   rules: | ||||
|     - !reference [.pipeline-guard, rules] | ||||
|  | ||||
| build-fedora-container@aarch64: | ||||
|   extends: | ||||
|     - .fdo.container-build@fedora@aarch64 | ||||
|     - .mutter.fedora@aarch64 | ||||
|     - .mutter.skip-git-clone | ||||
|   stage: prepare | ||||
|   rules: | ||||
|     - !reference [.pipeline-guard, rules] | ||||
|   when: manual | ||||
|  | ||||
| check-code-style: | ||||
|   extends: | ||||
|     - .mutter.distribution-image | ||||
|     - .mutter.fedora@x86_64 | ||||
|   variables: | ||||
|     MUTTER_CLONE_DEPTH: 200 | ||||
|   stage: code-review | ||||
|   needs: | ||||
|     - job: build-fedora-container@x86_64 | ||||
|       artifacts: false | ||||
|   script: | ||||
|       git remote add target $CI_MERGE_REQUEST_PROJECT_URL.git ; | ||||
|       git fetch target $CI_MERGE_REQUEST_TARGET_BRANCH_NAME ; | ||||
|       export common_parent_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "target/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME") <(git rev-list --first-parent HEAD) | head -1) ; | ||||
|       python3 -u ./check-style.py --dry-run --sha $common_parent_sha ; | ||||
|   allow_failure: true | ||||
|   rules: | ||||
|     - !reference [.only-merge-requests, rules] | ||||
|  | ||||
| .build-mutter-base: | ||||
|   variables: | ||||
|     BASE_MESON_OPTIONS: | ||||
|       -Degl_device=true | ||||
|       -Dwayland_eglstream=true | ||||
|       -Dcatch=true | ||||
|       -Dlibdisplay_info=true | ||||
|  | ||||
| .build-mutter: | ||||
|   extends: | ||||
|     - .mutter.distribution-image | ||||
|     - .build-mutter-base | ||||
| build-mutter: | ||||
|   stage: build | ||||
|   script: | ||||
|     - meson setup . build | ||||
|         --prefix /usr | ||||
|         --werror | ||||
|         --fatal-meson-warnings | ||||
|         --warnlevel 2 | ||||
|         -Dbuildtype=debugoptimized | ||||
|         -Db_coverage=true | ||||
|         $BASE_MESON_OPTIONS | ||||
|         $EXTRA_MESON_OPTIONS | ||||
|     - meson compile -C build | ||||
|     - sudo meson install --dry-run -C build | ||||
|     - meson . build -Dbuildtype=debugoptimized -Degl_device=true -Dwayland_eglstream=true --werror --prefix /usr | ||||
|     - ninja -C build | ||||
|     - ninja -C build install | ||||
|   artifacts: | ||||
|     expire_in: 1 day | ||||
|     paths: | ||||
|       - build | ||||
|   only: | ||||
|     - merge_requests | ||||
|     - /^.*$/ | ||||
|  | ||||
| build-mutter@x86_64: | ||||
|   variables: | ||||
|     EXTRA_MESON_OPTIONS: | ||||
|       -Dkvm_tests=true | ||||
|       -Dkvm_kernel_image=/opt/mutter/bzImage | ||||
|   extends: | ||||
|     - .build-mutter | ||||
|     - .mutter.fedora@x86_64 | ||||
|   needs: | ||||
|     - job: build-fedora-container@x86_64 | ||||
|       artifacts: false | ||||
|  | ||||
| build-mutter@aarch64: | ||||
|   extends: | ||||
|     - .build-mutter | ||||
|     - .mutter.fedora@aarch64 | ||||
|   needs: | ||||
|     - job: build-fedora-container@aarch64 | ||||
|       artifacts: false | ||||
|   when: manual | ||||
|  | ||||
| build-without-opengl-and-glx@x86_64: | ||||
|   extends: | ||||
|     - .mutter.distribution-image | ||||
|     - .mutter.fedora@x86_64 | ||||
| build-without-native-backend: | ||||
|   stage: build | ||||
|   needs: | ||||
|     - job: build-fedora-container@x86_64 | ||||
|       artifacts: false | ||||
|   script: | ||||
|     - meson setup . build --werror --prefix /usr | ||||
|         -Dbuildtype=debugoptimized | ||||
|         -Dopengl=false | ||||
|         -Dglx=false | ||||
|         -Degl_device=true | ||||
|         -Dwayland_eglstream=true | ||||
|         -Dintrospection=false | ||||
|     - meson compile -C build | ||||
|     - sudo meson install --no-rebuild -C build | ||||
|     - meson . build -Dbuildtype=debugoptimized -Dnative_backend=false -Dudev=false --werror --prefix /usr | ||||
|     - ninja -C build | ||||
|     - ninja -C build install | ||||
|   artifacts: | ||||
|     expire_in: 1 day | ||||
|     paths: | ||||
|       - build/meson-logs | ||||
|       - build | ||||
|   only: | ||||
|     - merge_requests | ||||
|     - /^.*$/ | ||||
|  | ||||
| build-without-native-backend-and-wayland@x86_64: | ||||
|   extends: | ||||
|     - .mutter.distribution-image | ||||
|     - .mutter.fedora@x86_64 | ||||
|   stage: build | ||||
|   needs: | ||||
|     - job: build-fedora-container@x86_64 | ||||
|       artifacts: false | ||||
|   script: | ||||
|     - meson setup . build --werror --prefix /usr | ||||
|         -Dbuildtype=debugoptimized | ||||
|         -Dnative_backend=false | ||||
|         -Dudev=false | ||||
|         -Dwayland=false | ||||
|         -Dxwayland=false | ||||
|         -Dcore_tests=false | ||||
|         -Dnative_tests=false | ||||
|         -Dintrospection=false | ||||
|     - meson compile -C build | ||||
|     - sudo meson install --no-rebuild -C build | ||||
|   artifacts: | ||||
|     paths: | ||||
|       - build/meson-logs | ||||
|  | ||||
| build-wayland-only@x86_64: | ||||
|   extends: | ||||
|     - .mutter.distribution-image | ||||
|     - .mutter.fedora@x86_64 | ||||
|   stage: build | ||||
|   needs: | ||||
|     - job: build-fedora-container@x86_64 | ||||
|       artifacts: false | ||||
|   script: | ||||
|     - meson setup . build --werror --prefix /usr | ||||
|         -Dbuildtype=debugoptimized | ||||
|         -Dwayland=true | ||||
|         -Dxwayland=false | ||||
|         -Dcore_tests=false | ||||
|         -Dnative_tests=false | ||||
|         -Dintrospection=false | ||||
|     - meson compile -C build | ||||
|     - sudo meson install --no-rebuild -C build | ||||
|   artifacts: | ||||
|     paths: | ||||
|       - build/meson-logs | ||||
|  | ||||
| .test-setup: | ||||
| test-mutter: | ||||
|   stage: test | ||||
|   dependencies: | ||||
|     - build-mutter | ||||
|   variables: | ||||
|     XDG_RUNTIME_DIR: "$CI_PROJECT_DIR/runtime-dir" | ||||
|     GSETTINGS_SCHEMA_DIR: "$CI_PROJECT_DIR/build/data" | ||||
|     MUTTER_DEBUG_DUMMY_MODE_SPECS: "800x600@10.0" | ||||
|     PIPEWIRE_DEBUG: 2 | ||||
|     PIPEWIRE_LOG: "$CI_PROJECT_DIR/build/meson-logs/pipewire.log" | ||||
|     XVFB_SERVER_ARGS: "+iglx -noreset" | ||||
|     G_SLICE: "always-malloc" | ||||
|     MALLOC_CHECK_: "3" | ||||
|     NO_AT_BRIDGE: "1" | ||||
|     GTK_A11Y: "none" | ||||
|   before_script: | ||||
|     - !reference [.mutter.git-clone, before_script] | ||||
|     # Disable e.g. audio support to not dead lock screen cast tests | ||||
|     MALLOC_PERTURB_: "123" | ||||
|   script: | ||||
|     - dconf update | ||||
|     - mkdir -m 700 $XDG_RUNTIME_DIR | ||||
|     - pipewire & sleep 2 | ||||
|  | ||||
| .test-mutter-base: | ||||
|   extends: | ||||
|     - .mutter.distribution-image | ||||
|     - .test-setup | ||||
|   stage: test | ||||
|   after_script: | ||||
|     - pushd build | ||||
|     - gcovr --root=.. | ||||
|         --filter='\.\./src/' --filter='\.\./clutter/' --filter='\.\./cogl/' | ||||
|         --exclude='\.\./build/.*\.[ch]$' --exclude='.*/tests/.*\.[ch]$' | ||||
|         --json --output=../coverage-${CI_JOB_NAME}.json | ||||
|     - popd | ||||
|   artifacts: | ||||
|     expire_in: 1 day | ||||
|     name: "mutter-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}" | ||||
|     when: always | ||||
|     paths: | ||||
|       - build | ||||
|       - coverage-*.json | ||||
|  | ||||
| .test-mutter: | ||||
|   extends: | ||||
|     - .mutter.distribution-image | ||||
|     - .test-mutter-base | ||||
|   script: | ||||
|     - glib-compile-schemas $GSETTINGS_SCHEMA_DIR | ||||
|     - xvfb-run -a -s "$XVFB_SERVER_ARGS" | ||||
|         ./src/tests/meta-dbus-runner.py | ||||
|           --launch=wireplumber | ||||
|           meson test | ||||
|             -C build | ||||
|             --setup plain | ||||
|             --no-suite 'mutter/kvm' | ||||
|             --no-rebuild | ||||
|             --timeout-multiplier 10 | ||||
|             --print-errorlogs | ||||
|   artifacts: | ||||
|     reports: | ||||
|       junit: "build/meson-logs/testlog-plain.junit.xml" | ||||
|     - > | ||||
|       dbus-run-session -- xvfb-run -s '+iglx -noreset' | ||||
|       meson test -C build --no-rebuild -t 10 --verbose --no-stdsplit --print-errorlogs --wrap catchsegv | ||||
|   only: | ||||
|     - merge_requests | ||||
|     - /^.*$/ | ||||
|  | ||||
| test-mutter@x86_64: | ||||
|   extends: | ||||
|     - .mutter.fedora@x86_64 | ||||
|     - .test-mutter | ||||
|   tags: | ||||
|     - asan | ||||
|   needs: | ||||
|     - build-mutter@x86_64 | ||||
|  | ||||
| test-mutter-kvm@x86_64: | ||||
|   extends: | ||||
|     - .mutter.fedora@x86_64 | ||||
|     - .test-mutter-base | ||||
|   tags: | ||||
|     - kvm | ||||
|   script: | ||||
|     - meson test -C build | ||||
|         --no-rebuild | ||||
|         --timeout-multiplier 10 | ||||
|         --setup plain | ||||
|         --suite 'mutter/kvm' | ||||
|         --print-errorlogs | ||||
|   needs: | ||||
|     - build-mutter@x86_64 | ||||
|   artifacts: | ||||
|     reports: | ||||
|       junit: "build/meson-logs/testlog-plain.junit.xml" | ||||
|  | ||||
| test-mutter@aarch64: | ||||
|   extends: | ||||
|     - .mutter.fedora@aarch64 | ||||
|     - .test-mutter | ||||
|   tags: | ||||
|     - asan-aarch64 | ||||
|   needs: | ||||
|     - build-mutter@aarch64 | ||||
|   when: manual | ||||
|  | ||||
| coverage: | ||||
|   extends: | ||||
|     - .mutter.distribution-image | ||||
|     - .mutter.fedora@x86_64 | ||||
|   stage: analyze | ||||
|   script: | ||||
|     - mkdir coveragereport | ||||
|     - gcovr --add-tracefile 'coverage-*.json' | ||||
|         --html-details --print-summary --output coveragereport/index.html | ||||
|     - gcovr --add-tracefile 'coverage-*.json' | ||||
|         --xml --output coveragereport/coverage.xml | ||||
|   artifacts: | ||||
|     expose_as: 'Coverage Report' | ||||
|     paths: | ||||
|       - coveragereport | ||||
|       - coveragereport/index.html | ||||
|     reports: | ||||
|       coverage_report: | ||||
|         coverage_format: cobertura | ||||
|         # TODO: we may need to split this file once it will reach the | ||||
|         # gitlab limit size of 10M, or it will stop working: | ||||
|         #  https://gitlab.com/gitlab-org/gitlab/-/issues/328772 | ||||
|         path: coveragereport/coverage.xml | ||||
|   coverage: '/^lines: (\d+\.\d+\%)/' | ||||
|   needs: | ||||
|     - test-mutter@x86_64 | ||||
| #    - test-mutter@aarch64 | ||||
|     - test-mutter-kvm@x86_64 | ||||
|  | ||||
| can-build-gnome-shell@x86_64: | ||||
|   extends: | ||||
|     - .mutter.distribution-image | ||||
|     - .mutter.fedora@x86_64 | ||||
| can-build-gnome-shell: | ||||
|   stage: test | ||||
|   needs: | ||||
|     - build-mutter@x86_64 | ||||
|   dependencies: | ||||
|     - build-mutter | ||||
|   before_script: | ||||
|     - !reference [.mutter.fedora@x86_64, before_script] | ||||
|     - sudo meson install --no-rebuild -C build | ||||
|     - meson install --no-rebuild -C build | ||||
|   script: | ||||
|     - .gitlab-ci/checkout-gnome-shell.sh | ||||
|     - meson setup gnome-shell gnome-shell/build --prefix /usr -Dman=false | ||||
|     - sudo meson install -C gnome-shell/build | ||||
|  | ||||
| test-mutter-coverity: | ||||
|   rules: | ||||
|     - if: '$CI_PIPELINE_SOURCE == "schedule" && $MUTTER_SCHEDULED_JOB == "coverity"' | ||||
|       when: on_success | ||||
|     - if: '$CI_COMMIT_BRANCH' | ||||
|       when: 'manual' | ||||
|   extends: | ||||
|     - .mutter.distribution-image | ||||
|     - .mutter.fedora@x86_64 | ||||
|   needs: | ||||
|     - job: build-fedora-container@x86_64 | ||||
|       artifacts: false | ||||
|   stage: analyze | ||||
|   allow_failure: true | ||||
|   script: | ||||
|     - .gitlab-ci/download-coverity-tarball.sh | ||||
|     - CC=clang meson setup coverity-build -Dprofiler=false | ||||
|     - ./coverity/cov-analysis-linux64-*/bin/cov-build --dir cov-int meson compile -C coverity-build | ||||
|     - tar czf cov-int.tar.gz cov-int | ||||
|     - curl https://scan.coverity.com/builds?project=mutter | ||||
|       --form token=$COVERITY_TOKEN --form email=carlosg@gnome.org | ||||
|       --form file=@cov-int.tar.gz --form version="`git describe --tags`" | ||||
|       --form description="GitLab CI build" | ||||
|   cache: | ||||
|     key: coverity-tarball | ||||
|     paths: | ||||
|       - coverity | ||||
|  | ||||
| dist-mutter: | ||||
|   extends: | ||||
|     - .fdo.distribution-image@fedora | ||||
|     - .mutter.fedora@x86_64 | ||||
|     - .build-mutter-base | ||||
|     - .test-setup | ||||
|   stage: deploy | ||||
|   needs: | ||||
|     - job: build-fedora-container@x86_64 | ||||
|       artifacts: false | ||||
|   script: | ||||
|     - meson setup . build --werror --prefix /usr | ||||
|         -Dbuildtype=debugoptimized | ||||
|     - glib-compile-schemas $GSETTINGS_SCHEMA_DIR | ||||
|     - xvfb-run -a -s "$XVFB_SERVER_ARGS" | ||||
|         ./src/tests/meta-dbus-runner.py | ||||
|           --launch=wireplumber | ||||
|           meson dist -C build | ||||
|   rules: | ||||
|     - if: '$CI_PIPELINE_SOURCE != "merge_request_event"' | ||||
|       when: manual | ||||
|     - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' | ||||
|       changes: | ||||
|         - "**/meson.build" | ||||
|         - meson/* | ||||
|       when: on_success | ||||
|     - if: '$GITLAB_USER_LOGIN == "marge-bot"' | ||||
|       when: on_success | ||||
|     - if: '$CI_MERGE_REQUEST_ASSIGNEES == "marge-bot"' | ||||
|       when: on_success | ||||
|  | ||||
| dist-mutter-tarball: | ||||
|   extends: dist-mutter | ||||
|   artifacts: | ||||
|     expose_as: 'Get tarball here' | ||||
|     paths: | ||||
|       - build/meson-dist/$CI_PROJECT_NAME-$CI_COMMIT_TAG.tar.xz | ||||
|   rules: | ||||
|     - if: '$CI_COMMIT_TAG' | ||||
|  | ||||
| reference: | ||||
|   extends: | ||||
|     - .mutter.distribution-image | ||||
|     - .mutter.fedora@x86_64 | ||||
|   stage: docs | ||||
|   needs: | ||||
|     - job: build-fedora-container@x86_64 | ||||
|       artifacts: false | ||||
|   script: | ||||
|     - meson setup . build --werror -Ddocs=true -Dtests=false | ||||
|     - ninja -C build | ||||
|     - mkdir references | ||||
|     - mv build/doc/reference/{cally/cally,clutter/clutter,cogl/cogl,cogl-pango/cogl-pango,meta/meta,mtk/mtk} references/ | ||||
|   artifacts: | ||||
|     expire_in: 1 week | ||||
|     expose_as: 'Documentation' | ||||
|     paths: | ||||
|       - references/ | ||||
|  | ||||
| pages: | ||||
|   stage: deploy | ||||
|   needs: ['reference'] | ||||
|   extends: | ||||
|     - .skip-git-clone | ||||
|   script: | ||||
|     - mv references public/ | ||||
|   artifacts: | ||||
|     paths: | ||||
|       - public | ||||
|   rules: | ||||
|     - if: ($CI_DEFAULT_BRANCH == $CI_COMMIT_BRANCH && $CI_PROJECT_NAMESPACE == "GNOME") | ||||
|     - meson gnome-shell gnome-shell/build --prefix /usr | ||||
|     - ninja -C gnome-shell/build install | ||||
|   only: | ||||
|     - merge_requests | ||||
|     - /^.*$/ | ||||
|   | ||||
							
								
								
									
										37
									
								
								.gitlab-ci/Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								.gitlab-ci/Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| # Rebuild and push with | ||||
| # | ||||
| #     cd .gitlab-ci/ | ||||
| #     docker build -t registry.gitlab.gnome.org/gnome/mutter/master:v2 . | ||||
| #     docker push registry.gitlab.gnome.org/gnome/mutter/master:v2 | ||||
| # | ||||
|  | ||||
| FROM fedora:30 | ||||
|  | ||||
| RUN dnf -y update && dnf -y upgrade && \ | ||||
|     dnf install -y 'dnf-command(builddep)' && \ | ||||
|     dnf install -y 'dnf-command(copr)' && \ | ||||
|     dnf copr enable -y fmuellner/gnome-shell-ci && \ | ||||
|     dnf copr enable -y jadahl/mutter-ci && \ | ||||
|     dnf copr enable -y hergertme/sysprof-3 && \ | ||||
|  | ||||
|     dnf builddep -y mutter && \ | ||||
|  | ||||
|     # Until Fedora catches up with meson build-deps | ||||
|     dnf install -y meson xorg-x11-server-Xorg gnome-settings-daemon-devel egl-wayland-devel xorg-x11-server-Xwayland && \ | ||||
|  | ||||
|     # Until Fedora catches up with mesa bug fixes | ||||
|     dnf upgrade -y mesa-dri-drivers mesa-libEGL && \ | ||||
|  | ||||
|     # For running unit tests | ||||
|     dnf install -y xorg-x11-server-Xvfb mesa-dri-drivers dbus dbus-x11 '*/xvfb-run' gdm-lib accountsservice-libs && \ | ||||
|  | ||||
|     dnf install -y sysprof-devel && \ | ||||
|  | ||||
|     dnf install -y intltool redhat-rpm-config make && \ | ||||
|  | ||||
|     # GNOME Shell | ||||
|     dnf builddep -y gnome-shell --setopt=install_weak_deps=False && \ | ||||
|     dnf remove -y gnome-bluetooth-libs-devel dbus-glib-devel upower-devel python3-devel && \ | ||||
|     dnf remove -y --noautoremove mutter mutter-devel && \ | ||||
|  | ||||
|     dnf clean all | ||||
							
								
								
									
										57
									
								
								.gitlab-ci/check-commit-log.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										57
									
								
								.gitlab-ci/check-commit-log.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| #!/usr/bin/env bash | ||||
|  | ||||
| if [ -z "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; then | ||||
|   echo Cannot review non-merge request | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
| git fetch $CI_MERGE_REQUEST_PROJECT_URL.git $CI_MERGE_REQUEST_TARGET_BRANCH_NAME | ||||
|  | ||||
| branch_point=$(git merge-base HEAD FETCH_HEAD) | ||||
|  | ||||
| commits=$(git log --format='format:%H' $branch_point..$CI_COMMIT_SHA) | ||||
|  | ||||
| if [ -z "$commits" ]; then | ||||
|   echo Commit range empty | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
| function commit_message_has_url() { | ||||
|   commit=$1 | ||||
|   commit_message=$(git show -s --format='format:%b' $commit) | ||||
|   echo "$commit_message" | grep -qe "\($CI_MERGE_REQUEST_PROJECT_URL/\(issues\|merge_requests\)/[0-9]\+\|https://bugzilla.gnome.org/show_bug.cgi?id=[0-9]\+\)" | ||||
|   return $? | ||||
| } | ||||
|  | ||||
| function commit_message_subject_is_compliant() { | ||||
|   commit=$1 | ||||
|   commit_message_subject=$(git show -s --format='format:%s' $commit) | ||||
|  | ||||
|   if echo "$commit_message_subject" | grep -qe "\(^meta-\|^Meta\)"; then | ||||
|     echo " - message subject should not be prefixed with 'meta-' or 'Meta'" | ||||
|     return 1 | ||||
|   fi | ||||
|  | ||||
|   if echo "$commit_message_subject" | grep -qe "\.[ch]:"; then | ||||
|     echo " - message subject prefix should not include .c, .h, etc." | ||||
|     return 1 | ||||
|   fi | ||||
|  | ||||
|   return 0 | ||||
| } | ||||
|  | ||||
| for commit in $commits; do | ||||
|   commit_short=$(echo $commit | cut -c -8) | ||||
|  | ||||
|   if ! commit_message_has_url $commit; then | ||||
|     echo "Missing merge request or issue URL on commit $commit_short" | ||||
|     exit 1 | ||||
|   fi | ||||
|  | ||||
|   errors=$(commit_message_subject_is_compliant $commit) | ||||
|   if [ $? != 0 ]; then | ||||
|     echo "Commit message for $commit_short is not compliant:" | ||||
|     echo "$errors" | ||||
|     exit 1 | ||||
|   fi | ||||
| done | ||||
| @@ -1,19 +1,12 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| fetch() { | ||||
|   local remote=$1 | ||||
|   local ref=$2 | ||||
|  | ||||
|   git fetch --quiet --depth=1 $remote $ref 2>/dev/null | ||||
| } | ||||
| #!/usr/bin/bash | ||||
|  | ||||
| mutter_branch=$(git describe --contains --all HEAD) | ||||
| gnome_shell_target= | ||||
|  | ||||
| echo -n Cloning into gnome-shell ... | ||||
| if git clone --quiet --depth=1 https://gitlab.gnome.org/GNOME/gnome-shell.git; then | ||||
|   echo \ done | ||||
| else | ||||
|   echo \ failed | ||||
| git clone https://gitlab.gnome.org/GNOME/gnome-shell.git | ||||
|  | ||||
| if [ $? -ne 0 ]; then | ||||
|   echo Checkout failed | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
| @@ -23,34 +16,20 @@ if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; then | ||||
|   merge_request_remote=${CI_MERGE_REQUEST_SOURCE_PROJECT_URL//mutter/gnome-shell} | ||||
|   merge_request_branch=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | ||||
|  | ||||
|   echo -n Looking for $merge_request_branch on remote ... | ||||
|   if fetch $merge_request_remote $merge_request_branch; then | ||||
|     echo \ found | ||||
|   echo Looking for $merge_request_branch on remote ... | ||||
|   if git fetch -q $merge_request_remote $merge_request_branch 2>/dev/null; then | ||||
|     gnome_shell_target=FETCH_HEAD | ||||
|   else | ||||
|     echo \ not found | ||||
|  | ||||
|     echo -n Looking for $CI_MERGE_REQUEST_TARGET_BRANCH_NAME instead ... | ||||
|     if fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME; then | ||||
|       echo \ found | ||||
|       gnome_shell_target=FETCH_HEAD | ||||
|     else | ||||
|       echo \ not found | ||||
|     fi | ||||
|   fi | ||||
| fi | ||||
|  | ||||
| if [ -z "$gnome_shell_target" ]; then | ||||
|   ref_remote=${CI_PROJECT_URL//mutter/gnome-shell} | ||||
|   echo -n Looking for $CI_COMMIT_REF_NAME on remote ... | ||||
|   if fetch $ref_remote $CI_COMMIT_REF_NAME; then | ||||
|     echo \ found | ||||
|     gnome_shell_target=FETCH_HEAD | ||||
|   else | ||||
|     echo \ not found | ||||
|     gnome_shell_target=HEAD | ||||
|     gnome_shell_target=origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME | ||||
|     echo Using $gnome_shell_target instead | ||||
|   fi | ||||
| fi | ||||
|  | ||||
| if [ -z "$gnome_shell_target" ]; then | ||||
|   gnome_shell_target=$(git branch -r -l origin/$mutter_branch) | ||||
|   gnome_shell_target=${gnome_shell_target:-$(git branch -r -l ${mutter_branch#remotes/})} | ||||
|   gnome_shell_target=${gnome_shell_target:-origin/master} | ||||
|   echo Using $gnome_shell_target instead | ||||
| fi | ||||
|  | ||||
| git checkout -q $gnome_shell_target | ||||
|   | ||||
| @@ -1,19 +0,0 @@ | ||||
| patterns: | ||||
|   deny: | ||||
|     - regex: '^$CI_MERGE_REQUEST_PROJECT_URL/(-/)?merge_requests/$CI_MERGE_REQUEST_IID$' | ||||
|       message: Commit message must not contain a link to its own merge request | ||||
|     - regex: '^(meta-|Meta)' | ||||
|       message: Commit message subject should not be prefixed with 'meta-' or 'Meta' | ||||
|       where: subject | ||||
|     - regex: '^(clutter-|Clutter)' | ||||
|       message: Commit message subject should not be prefixed with 'clutter-' or 'Clutter', use 'clutter/' instead | ||||
|       where: subject | ||||
|     - regex: '^(cogl-|Cogl)' | ||||
|       message: Commit message subject should not be prefixed with 'cogl-' or 'Cogl', use 'cogl/' instead | ||||
|       where: subject | ||||
|     - regex: '^[^:]+: [a-z]' | ||||
|       message: "Commit message subject should be properly Capitalized. E.g.  'window: Marginalize extradicity'" | ||||
|       where: subject | ||||
|     - regex: '^\S*\.[ch]:' | ||||
|       message: Commit message subject prefix should not include .c, .h, etc. | ||||
|       where: subject | ||||
| @@ -1,38 +0,0 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # We need a coverity token to fetch the tarball | ||||
| if [ -x $COVERITY_TOKEN ] | ||||
| then | ||||
|   echo "No coverity token. Run this job from a protected branch." | ||||
|   exit -1 | ||||
| fi | ||||
|  | ||||
| mkdir -p coverity | ||||
|  | ||||
| # Download and check MD5 first | ||||
| curl https://scan.coverity.com/download/linux64 \ | ||||
|   --data "token=$COVERITY_TOKEN&project=mutter&md5=1" \ | ||||
|   --output /tmp/coverity_tool.md5 | ||||
|  | ||||
| diff /tmp/coverity_tool.md5 coverity/coverity_tool.md5 >/dev/null 2>&1 | ||||
|  | ||||
| if [ $? -eq 0 -a -d coverity/cov-analysis* ] | ||||
| then | ||||
|   echo "Coverity tarball is up-to-date" | ||||
|   exit 0 | ||||
| fi | ||||
|  | ||||
| # Download and extract coverity tarball | ||||
| curl https://scan.coverity.com/download/linux64 \ | ||||
|   --data "token=$COVERITY_TOKEN&project=mutter" \ | ||||
|   --output /tmp/coverity_tool.tgz | ||||
|  | ||||
| rm -rf ./coverity/cov-analysis* | ||||
|  | ||||
| tar zxf /tmp/coverity_tool.tgz -C coverity/ | ||||
| if [ $? -eq 0 ] | ||||
| then | ||||
|   mv /tmp/coverity_tool.md5 coverity/ | ||||
| fi | ||||
|  | ||||
| rm /tmp/coverity_tool.tgz | ||||
| @@ -1,82 +0,0 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| set -e | ||||
|  | ||||
| usage() { | ||||
|   cat <<-EOF | ||||
| 	Usage: $(basename $0) [OPTION…] REPO_URL COMMIT | ||||
|  | ||||
| 	Check out and install a meson project | ||||
|  | ||||
| 	Options: | ||||
| 	  -Dkey=val      Option to pass on to meson | ||||
| 	  --subdir       Build subdirectory instead of whole project | ||||
| 	  --prepare      Script to run before build | ||||
|  | ||||
| 	  -h, --help     Display this help | ||||
|  | ||||
| 	EOF | ||||
| } | ||||
|  | ||||
| TEMP=$(getopt \ | ||||
|   --name=$(basename $0) \ | ||||
|   --options='D:h' \ | ||||
|   --longoptions='subdir:' \ | ||||
|   --longoptions='prepare:' \ | ||||
|   --longoptions='help' \ | ||||
|   -- "$@") | ||||
|  | ||||
| eval set -- "$TEMP" | ||||
| unset TEMP | ||||
|  | ||||
| MESON_OPTIONS=() | ||||
| SUBDIR=. | ||||
| PREPARE=: | ||||
|  | ||||
| while true; do | ||||
|   case "$1" in | ||||
|     -D) | ||||
|       MESON_OPTIONS+=( -D$2 ) | ||||
|       shift 2 | ||||
|     ;; | ||||
|  | ||||
|     --subdir) | ||||
|       SUBDIR=$2 | ||||
|       shift 2 | ||||
|     ;; | ||||
|  | ||||
|     --prepare) | ||||
|       PREPARE=$2 | ||||
|       shift 2 | ||||
|     ;; | ||||
|  | ||||
|     -h|--help) | ||||
|       usage | ||||
|       exit 0 | ||||
|     ;; | ||||
|  | ||||
|     --) | ||||
|       shift | ||||
|       break | ||||
|     ;; | ||||
|   esac | ||||
| done | ||||
|  | ||||
| if [[ $# -lt 2 ]]; then | ||||
|   usage | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
| REPO_URL="$1" | ||||
| COMMIT="$2" | ||||
|  | ||||
| CHECKOUT_DIR=$(mktemp --directory) | ||||
| trap "rm -rf $CHECKOUT_DIR" EXIT | ||||
|  | ||||
| git clone --depth 1 "$REPO_URL" -b "$COMMIT" "$CHECKOUT_DIR" | ||||
|  | ||||
| pushd "$CHECKOUT_DIR/$SUBDIR" | ||||
| sh -c "$PREPARE" | ||||
| meson setup --prefix=/usr _build "${MESON_OPTIONS[@]}" | ||||
| meson install -C _build | ||||
| popd | ||||
| @@ -1,55 +0,0 @@ | ||||
| <!--  | ||||
| Please read https://wiki.gnome.org/Community/GettingInTouch/BugReportingGuidelines | ||||
| first to ensure that you create a clear and specific issue. | ||||
| --> | ||||
|  | ||||
| ### Affected version | ||||
|  | ||||
| <!-- | ||||
| Provide at least the following information: | ||||
| * Your OS and version | ||||
| * Affected Mutter version | ||||
| * Does this issue appear in XOrg and/or Wayland | ||||
| --> | ||||
|  | ||||
| ### Bug summary | ||||
|  | ||||
| <!--  | ||||
| Provide a short summary of the bug you encountered. | ||||
| --> | ||||
|  | ||||
| ### Steps to reproduce | ||||
|  | ||||
| <!--  | ||||
| 1. Step one | ||||
| 2. Step two | ||||
| 3. ... | ||||
| --> | ||||
|  | ||||
| ### What happened | ||||
|  | ||||
| <!--  | ||||
| What did Mutter do that was unexpected? | ||||
| --> | ||||
|  | ||||
| ### What did you expect to happen | ||||
|  | ||||
| <!--  | ||||
| What did you expect Mutter to do? | ||||
| --> | ||||
|  | ||||
| ### Relevant logs, screenshots, screencasts etc. | ||||
|  | ||||
| <!--  | ||||
| If you have further information, such as technical documentation, logs, | ||||
| screenshots or screencasts related, please provide them here. | ||||
|  | ||||
| If the bug is a crash, please obtain a stack trace with installed debug | ||||
| symbols (at least for GNOME Shell and Mutter) and attach it to | ||||
| this issue following the instructions on | ||||
| https://wiki.gnome.org/Community/GettingInTouch/Bugzilla/GettingTraces. | ||||
| --> | ||||
|  | ||||
|  | ||||
| <!-- Do not remove the following line. --> | ||||
| /label ~"1. Bug" | ||||
| @@ -1,30 +0,0 @@ | ||||
| <!--  | ||||
| Please read https://wiki.gnome.org/Community/GettingInTouch/BugReportingGuidelines | ||||
| first to ensure that you create a clear and specific issue. | ||||
| --> | ||||
|  | ||||
| ### Feature summary | ||||
|  | ||||
| <!--  | ||||
| Describe what you would like to be able to do with Mutter | ||||
| that you currently cannot do. | ||||
| --> | ||||
|  | ||||
| ### How would you like it to work | ||||
|  | ||||
| <!--  | ||||
| If you can think of a way Mutter might be able to do this, | ||||
| let us know here. | ||||
| --> | ||||
|  | ||||
| ### Relevant links, screenshots, screencasts etc. | ||||
|  | ||||
| <!--  | ||||
| If you have further information, such as technical documentation, | ||||
| code, mockups or a similar feature in another window managers, | ||||
| please provide them here. | ||||
| --> | ||||
|  | ||||
|  | ||||
| <!-- Do not remove the following line. --> | ||||
| /label ~"1. Feature" | ||||
							
								
								
									
										286
									
								
								HACKING.md
									
									
									
									
									
								
							
							
						
						
									
										286
									
								
								HACKING.md
									
									
									
									
									
								
							| @@ -1,286 +0,0 @@ | ||||
| # Style | ||||
|  | ||||
| The coding style used is primarily the GNU flavor of the [GNOME coding | ||||
| style][gnome-coding-style], with some additions described below. | ||||
|  | ||||
| ## General | ||||
|  | ||||
|  * Use this code style on new code. When changing old code with a different | ||||
|    code style, feel free to also adjust it to use this code style. | ||||
|  | ||||
|  * Use regular C types and `stdint.h` types instead of GLib fundamental | ||||
|    types, except for `gboolean`, and `guint`/`gulong` for GSource IDs and | ||||
|    signal handler IDs. That means e.g. `uint64_t` instead of `guint64`, `int` | ||||
|    instead of `gint`, `unsigned int` instead of `guint` if unsignedness | ||||
|    is of importance, `uint8_t` instead of `guchar`, and so on. | ||||
|  | ||||
|  * Try to to limit line length to 80 characters, although it's not a | ||||
|    strict limit. | ||||
|  | ||||
|  * Usage of `g_autofree` and `g_autoptr` is encouraged. The style to use is | ||||
|  | ||||
|     ```c | ||||
|     g_autofree char *text = NULL; | ||||
|     g_autoptr (MetaSomeThing) thing = NULL; | ||||
|  | ||||
|     text = g_strdup_printf ("The text: %d", a_number); | ||||
|     thing = g_object_new (META_TYPE_SOME_THING, | ||||
|                           "text", text, | ||||
|                           NULL); | ||||
|     thinger_use_thing (rocket, thing); | ||||
|     ``` | ||||
|  | ||||
|  * Declare variables at the top of the block they are used, but avoid | ||||
|    non-trivial logic among variable declarations. Non-trivial logic can be | ||||
|    getting a pointer that may be `NULL`, any kind of math, or anything | ||||
|    that may have side effects. | ||||
|  | ||||
|  * Instead of boolean arguments in functions, prefer enums or flags when | ||||
|    they're more expressive. The naming convention for flags is | ||||
|  | ||||
|     ```c | ||||
|     typedef _MetaSomeThingFlags | ||||
|     { | ||||
|       META_SOME_THING_FLAG_NONE = 0, | ||||
|       META_SOME_THING_FLAG_ALTER_REALITY = 1 << 0, | ||||
|       META_SOME_THING_FLAG_MANIPULATE_PERCEPTION = 1 << 1, | ||||
|     } MetaSomeThingFlags; | ||||
|     ``` | ||||
|  | ||||
|  * Use `g_new0 ()` etc. instead of `g_slice_new0 ()`. | ||||
|  | ||||
|  * Initialize and assign floating point variables (i.e. `float` or | ||||
|    `double`) using the form `floating_point = 3.14159` or `ratio = 2.0`. | ||||
|  | ||||
| ## Header (.h) files | ||||
|  | ||||
|  * The return type and `*` are separated by a space. | ||||
|  * Function name starts one space after the last `*`. | ||||
|  * Parenthesis comes one space after the function name. | ||||
|  | ||||
| As an example, this is how functions in a header file should look like: | ||||
|  | ||||
| ```c | ||||
| gboolean meta_udev_is_drm_device (MetaUdev    *udev, | ||||
|                                   GUdevDevice *device); | ||||
|  | ||||
| GList * meta_udev_list_drm_devices (MetaUdev  *udev, | ||||
|                                     GError   **error); | ||||
|  | ||||
| MetaUdev * meta_udev_new (MetaBackendNative *backend_native); | ||||
| ``` | ||||
|  | ||||
| ## Source code | ||||
|  | ||||
| Keep functions in the following order in source files: | ||||
|  | ||||
|   1. GPL header | ||||
|   2. Enums | ||||
|   3. Structures | ||||
|   4. Function prototypes | ||||
|   5. `G_DEFINE_TYPE()` | ||||
|   6. Static variables | ||||
|   7. Auxiliary functions | ||||
|   8. Callbacks | ||||
|   9. Interface implementations | ||||
|   10. Parent vfunc overrides | ||||
|   11. class_init and init | ||||
|   12. Public API | ||||
|  | ||||
| ### Structures | ||||
|  | ||||
| Each structure field has a space after their type name. Structure fields aren't | ||||
| aligned. For example: | ||||
|  | ||||
| ```c | ||||
| struct _MetaFooBar | ||||
| { | ||||
|   MetaFoo parent; | ||||
|  | ||||
|   MetaBar *bar; | ||||
|   MetaSomething *something; | ||||
| }; | ||||
| ``` | ||||
|  | ||||
| ### Function Prototypes | ||||
|  | ||||
| Function prototypes must be formatted just like in header files. | ||||
|  | ||||
| ### Overrides | ||||
|  | ||||
| When overriding parent class vfuncs, or implementing an interface, vfunc | ||||
| overrides should be named as a composition of the current class prefix, | ||||
| followed by the vfunc name. For example: | ||||
|  | ||||
|  | ||||
| ```c | ||||
| static void | ||||
| meta_bar_spawn_unicorn (MetaParent *parent) | ||||
| { | ||||
|   /* ... */ | ||||
| } | ||||
|  | ||||
| static void | ||||
| meta_bar_dispose (GObject *object) | ||||
| { | ||||
|   /* ... */ | ||||
| } | ||||
|  | ||||
| static void | ||||
| meta_bar_finalize (GObject *object) | ||||
| { | ||||
|   /* ... */ | ||||
| } | ||||
|  | ||||
| static void | ||||
| meta_bar_class_init (MetaBarClass *klass) | ||||
| { | ||||
|   GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||||
|   MetaParentClass *parent_class = META_PARENT_CLASS (klass); | ||||
|  | ||||
|   object_class->dispose = meta_bar_dispose; | ||||
|   object_class->finalize = meta_bar_finalize; | ||||
|  | ||||
|   parent_class->spawn_unicorn = meta_bar_spawn_unicorn; | ||||
| } | ||||
| ``` | ||||
|  | ||||
| ### Interface Implementations | ||||
|  | ||||
| When implementing interfaces, two groups of functions are involved: the init | ||||
| function, and the overrides. | ||||
|  | ||||
| The interface init function is named after the interface type in snake case, | ||||
| followed by the `_iface_init` suffix. For example: | ||||
|  | ||||
|  | ||||
| ```c | ||||
| static void meta_foo_iface_init (MetaFooInterface *foo_iface); | ||||
|  | ||||
| G_DEFINE_TYPE_WITH_CODE (MetaBar, meta_bar, G_TYPE_OBJECT, | ||||
|                          G_IMPLEMENT_INTERFACE (META_TYPE_FOO, | ||||
|                                                 meta_foo_iface_init)); | ||||
| ``` | ||||
|  | ||||
| Then, when implementing each vfunc of the interface, follow the same pattern | ||||
| of the [Overrides](###Overrides) section. Here's an example: | ||||
|  | ||||
| ```c | ||||
| static void | ||||
| meta_bar_do_something (MetaFoo *foo) | ||||
| { | ||||
|   /* ... */ | ||||
| } | ||||
|  | ||||
| static void | ||||
| meta_foo_iface_init (MetaFooInterface *foo_iface) | ||||
| { | ||||
|   foo_iface->do_something = meta_bar_do_something; | ||||
| } | ||||
| ``` | ||||
|  | ||||
| ### Auxiliary Functions | ||||
|  | ||||
| Auxiliary functions are above every other functions to minimize the number of | ||||
| function prototypes in the file. These functions often grow when factoring out | ||||
| the same code between two or more functions: | ||||
|  | ||||
| ```c | ||||
| static void | ||||
| do_something_on_data (Foo *data, | ||||
|                       Bar *bar) | ||||
| { | ||||
|   /* ... */ | ||||
| } | ||||
|  | ||||
| static void | ||||
| random_function (Foo *foo) | ||||
| { | ||||
|   do_something_on_data (foo, bar); | ||||
| } | ||||
|  | ||||
| static void | ||||
| another_random_function (Foo *foo) | ||||
| { | ||||
|   do_something_on_data (foo, bar); | ||||
| } | ||||
| ``` | ||||
|  | ||||
| Sometimes, however, auxiliary functions are created to break down otherwise | ||||
| large functions - in this case, it is appropriate to keep these auxiliary | ||||
| functions close to the function they are tightly related to. | ||||
|  | ||||
| Auxiliary function names must have a verb in the imperative form, and should | ||||
| always perform an action over something. They usually don't have the class | ||||
| prefix (`meta_`, `clutter_`, or `cogl_`). For example: | ||||
|  | ||||
| ```c | ||||
| static void | ||||
| do_something_on_data (Foo *data, | ||||
|                       Bar *bar) | ||||
| { | ||||
|   /* ... */ | ||||
| } | ||||
| ``` | ||||
|  | ||||
| Exceptionally, when converting between types, auxiliary function names may | ||||
| have the class prefix to this rule. For example: | ||||
|  | ||||
| ```c | ||||
| static MetaFoo * | ||||
| meta_foo_from_bar (Bar *bar) | ||||
| { | ||||
|   /* ... */ | ||||
| } | ||||
| ``` | ||||
|  | ||||
| ### Callback Functions | ||||
|  | ||||
| Callback function names should have the name of the action in imperative | ||||
| form. They don't have any prefix, but have a `_func` suffix. For example: | ||||
|  | ||||
| ```c | ||||
| static void | ||||
| filter_something_func (Foo      *foo, | ||||
|                        Bar      *bar, | ||||
|                        gpointer  user_data) | ||||
| { | ||||
|   /* ... */ | ||||
| } | ||||
| ``` | ||||
|  | ||||
| ### Signal Callbacks | ||||
|  | ||||
| Signal callbacks generally have the signal name. They should be prefixed with | ||||
| `on_`, or suffixed with `_cb`, but not both. For example: | ||||
|  | ||||
| ```c | ||||
| static void | ||||
| on_realize (ClutterActor *actor, | ||||
|             gpointer      user_data) | ||||
| { | ||||
|   /* ... */ | ||||
| } | ||||
|  | ||||
| static void | ||||
| destroy_cb (ClutterActor *actor, | ||||
|             gpointer      user_data) | ||||
| { | ||||
|   /* ... */ | ||||
| } | ||||
| ``` | ||||
|  | ||||
| When the callback is named after the object that generated it, and the signal, | ||||
| then passive voice is used. For example: | ||||
|  | ||||
| ```c | ||||
| static void | ||||
| click_action_clicked_cb (ClutterClickAction *click_action, | ||||
|                          ClutterActor       *actor, | ||||
|                          gpointer            user_data) | ||||
| { | ||||
|   /* ... */ | ||||
| } | ||||
| ``` | ||||
|  | ||||
| [gnome-coding-style]: https://developer.gnome.org/documentation/guidelines/programming/coding-style.html | ||||
							
								
								
									
										81
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										81
									
								
								README.md
									
									
									
									
									
								
							| @@ -14,7 +14,7 @@ window compositing, focus tracking, workspace management, keybindings and | ||||
| monitor configuration. | ||||
|  | ||||
| Internally it uses a fork of Cogl, a hardware acceleration abstraction library | ||||
| used to simplify usage of OpenGL pipelines, as well as a fork of Clutter, a | ||||
| used to simplify usage of OpenGL pipelines, as well as a fork af Clutter, a | ||||
| scene graph and user interface toolkit. | ||||
|  | ||||
| Mutter is used by, for example, GNOME Shell, the GNOME core user interface, and | ||||
| @@ -26,82 +26,15 @@ debugging purposes. | ||||
|  | ||||
| To contribute, open merge requests at https://gitlab.gnome.org/GNOME/mutter. | ||||
|  | ||||
| It can be useful to look at the documentation available at the | ||||
| [Wiki](https://gitlab.gnome.org/GNOME/mutter/-/wikis/home). | ||||
|  | ||||
| The API documentation is available at: | ||||
|  | ||||
| - Meta: <https://gnome.pages.gitlab.gnome.org/mutter/meta/> | ||||
| - Clutter: <https://gnome.pages.gitlab.gnome.org/mutter/clutter/> | ||||
| - Cally: <https://gnome.pages.gitlab.gnome.org/mutter/cally/> | ||||
| - Cogl: <https://gnome.pages.gitlab.gnome.org/mutter/cogl/> | ||||
| - CoglPango: <https://gnome.pages.gitlab.gnome.org/mutter/cogl-pango/> | ||||
| - Mtk: <https://gnome.pages.gitlab.gnome.org/mutter/mtk/> | ||||
|  | ||||
| ## Coding style and conventions | ||||
|  | ||||
| See [HACKING.md](./HACKING.md). | ||||
|  | ||||
| ## Git messages | ||||
| The coding style used is primarily the GNU flavor of the [GNOME coding | ||||
| style](https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en) | ||||
| with some minor additions such as preferring `stdint.h` types over GLib | ||||
| fundamental types, and a soft 80 character line limit. However, in general, | ||||
| look at the file you're editing for inspiration. | ||||
|  | ||||
| Commit messages should follow the [GNOME commit message | ||||
| guidelines](https://wiki.gnome.org/Git/CommitMessages). We require an URL | ||||
| to either an issue or a merge request in each commit. Try to always prefix | ||||
| commit subjects with a relevant topic, such as `compositor:` or | ||||
| `clutter/actor:`, and it's always better to write too much in the commit | ||||
| message body than too little. | ||||
|  | ||||
| If a commit fixes an issue and that issue should be closed, add URL to it in | ||||
| the bottom of the commit message and prefix with `Closes:`. | ||||
|  | ||||
| Do not add any `Part-of:` line, as that will be handled automatically when | ||||
| merging. | ||||
|  | ||||
| ### The Fixes tag | ||||
|  | ||||
| If a commit fixes a regression caused by a particular commit, it can be marked | ||||
| with the `Fixes:` tag. To produce such a tag, use | ||||
|  | ||||
| ``` | ||||
| git show -s --pretty='format:Fixes: %h (\"%s\")' <COMMIT> | ||||
| ``` | ||||
|  | ||||
| or create an alias | ||||
|  | ||||
| ``` | ||||
| git config --global alias.fixes "show -s --pretty='format:Fixes: %h (\"%s\")'" | ||||
| ``` | ||||
|  | ||||
| and then use | ||||
|  | ||||
| ``` | ||||
| git fixes <COMMIT> | ||||
| ``` | ||||
|  | ||||
| ### Example | ||||
|  | ||||
| ``` | ||||
| compositor: Also consider dark matter when calculating paint volume | ||||
|  | ||||
| Ignoring dark matter when calculating the paint volume missed the case where | ||||
| compositing happens in complete vacuum. | ||||
|  | ||||
| Fixes: 123abc123ab ("compositor: Calculate paint volume ourselves") | ||||
| Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1234 | ||||
| ``` | ||||
|  | ||||
| ## Default branch | ||||
|  | ||||
| The default development branch is `main`. If you still have a local | ||||
| checkout under the old name, 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 | ||||
| ``` | ||||
| to either an issue or a merge request in each commit. | ||||
|  | ||||
| ## License | ||||
|  | ||||
|   | ||||
							
								
								
									
										164
									
								
								check-style.py
									
									
									
									
									
								
							
							
						
						
									
										164
									
								
								check-style.py
									
									
									
									
									
								
							| @@ -1,164 +0,0 @@ | ||||
| #!/bin/env python3 | ||||
|  | ||||
| import argparse | ||||
| import os | ||||
| import re | ||||
| import subprocess | ||||
| import sys | ||||
| import tempfile | ||||
|  | ||||
| # Path relative to this script | ||||
| uncrustify_cfg = 'tools/uncrustify.cfg' | ||||
|  | ||||
| def run_diff(sha): | ||||
|     proc = subprocess.run( | ||||
|         ["git", "diff", "-U0", "--function-context", sha, "HEAD"], | ||||
|         stdout=subprocess.PIPE, | ||||
|         stderr=subprocess.STDOUT, | ||||
|         encoding="utf-8", | ||||
|     ) | ||||
|     return proc.stdout.strip().splitlines() | ||||
|  | ||||
| def find_chunks(diff): | ||||
|     file_entry_re = re.compile('^\+\+\+ b/(.*)$') | ||||
|     diff_chunk_re = re.compile('^@@ -\d+,\d+ \+(\d+),(\d+)') | ||||
|     file = None | ||||
|     chunks = [] | ||||
|  | ||||
|     for line in diff: | ||||
|         match = file_entry_re.match(line) | ||||
|         if match: | ||||
|             file = match.group(1) | ||||
|  | ||||
|         match = diff_chunk_re.match(line) | ||||
|         if match: | ||||
|             start = int(match.group(1)) | ||||
|             len = int(match.group(2)) | ||||
|             end = start + len | ||||
|  | ||||
|             if len > 0 and (file.endswith('.c') or file.endswith('.h') or file.endswith('.vala')): | ||||
|                 chunks.append({ 'file': file, 'start': start, 'end': end }) | ||||
|  | ||||
|     return chunks | ||||
|  | ||||
| def reformat_chunks(chunks, rewrite): | ||||
|     # Creates temp file with INDENT-ON/OFF comments | ||||
|     def create_temp_file(file, start, end): | ||||
|         with open(file) as f: | ||||
|             tmp = tempfile.NamedTemporaryFile() | ||||
|             if start > 1: | ||||
|                 tmp.write(b'/** *INDENT-OFF* **/\n') | ||||
|             for i, line in enumerate(f, start=1): | ||||
|                 if i == start - 1: | ||||
|                     tmp.write(b'/** *INDENT-ON* **/\n') | ||||
|  | ||||
|                 tmp.write(bytes(line, 'utf-8')) | ||||
|  | ||||
|                 if i == end - 1: | ||||
|                     tmp.write(b'/** *INDENT-OFF* **/\n') | ||||
|  | ||||
|             tmp.seek(0) | ||||
|  | ||||
|         return tmp | ||||
|  | ||||
|     # Removes uncrustify INDENT-ON/OFF helper comments | ||||
|     def remove_indent_comments(output): | ||||
|         tmp = tempfile.NamedTemporaryFile() | ||||
|  | ||||
|         for line in output: | ||||
|             if line != b'/** *INDENT-OFF* **/\n' and line != b'/** *INDENT-ON* **/\n': | ||||
|                 tmp.write(line) | ||||
|  | ||||
|         tmp.seek(0) | ||||
|  | ||||
|         return tmp | ||||
|  | ||||
|     changed = None | ||||
|  | ||||
|     for chunk in chunks: | ||||
|         # Add INDENT-ON/OFF comments | ||||
|         tmp = create_temp_file(chunk['file'], chunk['start'], chunk['end']) | ||||
|  | ||||
|         # uncrustify chunk | ||||
|         proc = subprocess.run( | ||||
|             ["uncrustify", "-c", uncrustify_cfg, "-f", tmp.name], | ||||
|             stdout=subprocess.PIPE, | ||||
|         ) | ||||
|         reindented = proc.stdout.splitlines(keepends=True) | ||||
|         if proc.returncode != 0: | ||||
|             continue | ||||
|  | ||||
|         tmp.close() | ||||
|  | ||||
|         # Remove INDENT-ON/OFF comments | ||||
|         formatted = remove_indent_comments(reindented) | ||||
|  | ||||
|         if dry_run is True: | ||||
|             # Show changes | ||||
|             proc = subprocess.run( | ||||
|                 ["diff", "-up", "--color=always", chunk['file'], formatted.name], | ||||
|                 stdout=subprocess.PIPE, | ||||
|                 stderr=subprocess.STDOUT, | ||||
|                 encoding="utf-8", | ||||
|             ) | ||||
|             diff = proc.stdout | ||||
|             if diff != '': | ||||
|                 output = re.sub('\t', '↦\t', diff) | ||||
|                 print(output) | ||||
|                 changed = True | ||||
|         else: | ||||
|             # Apply changes | ||||
|             diff = subprocess.run( | ||||
|                 ["diff", "-up", chunk['file'], formatted.name], | ||||
|                 stdout=subprocess.PIPE, | ||||
|                 stderr=subprocess.STDOUT, | ||||
|             ) | ||||
|             patch = subprocess.run(["patch", chunk['file']], input=diff.stdout) | ||||
|  | ||||
|         formatted.close() | ||||
|  | ||||
|     return changed | ||||
|  | ||||
|  | ||||
| parser = argparse.ArgumentParser(description='Check code style. Needs uncrustify installed.') | ||||
| parser.add_argument('--sha', metavar='SHA', type=str, | ||||
|                     help='SHA for the commit to compare HEAD with') | ||||
| parser.add_argument('--dry-run', '-d', type=bool, | ||||
|                     action=argparse.BooleanOptionalAction, | ||||
|                     help='Only print changes to stdout, do not change code') | ||||
| parser.add_argument('--rewrite', '-r', type=bool, | ||||
|                     action=argparse.BooleanOptionalAction, | ||||
|                     help='Whether to amend the result to the last commit (e.g. \'git rebase --exec "%(prog)s -r"\')') | ||||
|  | ||||
| # Change CWD to script location, necessary for always locating the configuration file | ||||
| os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) | ||||
|  | ||||
| args = parser.parse_args() | ||||
| sha = args.sha or 'HEAD^' | ||||
| rewrite = args.rewrite | ||||
| dry_run = args.dry_run | ||||
|  | ||||
| diff = run_diff(sha) | ||||
| chunks = find_chunks(diff) | ||||
| changed = reformat_chunks(chunks, rewrite) | ||||
|  | ||||
| if dry_run is not True and rewrite is True: | ||||
|     proc = subprocess.run(["git", "add", "-p"]) | ||||
|     if proc.returncode == 0: | ||||
|         # Commit the added changes as a squash commit | ||||
|         subprocess.run( | ||||
|             ["git", "commit", "--squash", "HEAD", "-C", "HEAD"], | ||||
|             stdout=subprocess.DEVNULL) | ||||
|         # Delete the unapplied changes | ||||
|         subprocess.run(["git", "reset", "--hard"], stdout=subprocess.DEVNULL) | ||||
|     os._exit(0) | ||||
| elif dry_run is True and changed is True: | ||||
|     print(f""" | ||||
| Issue the following commands in your local tree to apply the suggested changes: | ||||
|  | ||||
|     $ git rebase {sha} --exec "./check-style.py -r" | ||||
|     $ git rebase --autosquash {sha} | ||||
| """) | ||||
|     os._exit(-1) | ||||
|  | ||||
| os._exit(0) | ||||
| @@ -27,7 +27,7 @@ that on CallyRoot: | ||||
|  | ||||
|   * CallyUtil callbacks these signals are related to key event | ||||
|     listeners (key snooper simulation). One of the main CallyUtil | ||||
|     responsibilities is managing event (connecting, emitting), so I | ||||
|     responsabilities is managing event (connecting, emitting), so I | ||||
|     would prefer to not start to add/mix more functionalities here. | ||||
|  | ||||
| Ideally it would be better to emit all CallyStage methods from | ||||
| @@ -56,7 +56,7 @@ Adding -Wshadow option and solving warnings related | ||||
|  | ||||
| 2010-06-14 Alejandro Pi<50>eiro <apinheiro@igalia.com> | ||||
|  | ||||
| Added dummy padding for future vt expansion | ||||
| Added dummy padding for future vt expasion | ||||
|  | ||||
| Added dummy padding on the different classes structures, to allow | ||||
| future expansion of virtual methods. | ||||
| @@ -393,7 +393,7 @@ Manage properly ATK_STATE_ACTIVE on CallyStage | ||||
|  | ||||
| * cally/cally-stage.c | ||||
| Added private struct | ||||
| (cally_stage_class_init),(cally_stage_init),(cally_stage_real_initialize): | ||||
| (cally_stage_class_init),(cally_stage_init),(cally_stage_real_initalize): | ||||
| Initialization stuff | ||||
| (cally_stage_activate_cb) | ||||
| (cally_stage_deactivate_cb): new ClutterStage signal callbacks, change | ||||
| @@ -975,7 +975,7 @@ Missing cail-rectangle.[ch] files, according 2009-02-23 entry at Changelog | ||||
|  | ||||
| 2009-02-18 Alejandro Pinheiro <apinheiro@igalia.com> | ||||
|  | ||||
| 	* configure.ac: added additional compile flags | ||||
| 	* configure.ac: added aditional compile flags | ||||
| 	* cail/cail-actor.[ch]: Reimplemented support for AtkAction interface | ||||
| 	* cail/cail-root.[ch]: code style review | ||||
|  | ||||
|   | ||||
| @@ -22,12 +22,13 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CALLY_ACTOR_PRIVATE_H__ | ||||
| #define __CALLY_ACTOR_PRIVATE_H__ | ||||
|  | ||||
| #include "cally/cally-actor.h" | ||||
| #include "cally-actor.h" | ||||
|  | ||||
| /* | ||||
|  * Auxiliary define, in order to get the clutter actor from the AtkObject using | ||||
|  * Auxiliar define, in order to get the clutter actor from the AtkObject using | ||||
|  * AtkGObject methods | ||||
|  * | ||||
|  */ | ||||
| @@ -37,3 +38,5 @@ | ||||
| void _cally_actor_get_top_level_origin (ClutterActor *actor, | ||||
|                                         gint         *x, | ||||
|                                         gint         *y); | ||||
|  | ||||
| #endif /* __CALLY_ACTOR_PRIVATE_H__ */ | ||||
|   | ||||
| @@ -23,11 +23,12 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * CallyActor: | ||||
|  *  | ||||
|  * Implementation of the ATK interfaces for [class@Clutter.Actor] | ||||
|  * SECTION:cally-actor | ||||
|  * @Title: CallyActor | ||||
|  * @short_description: Implementation of the ATK interfaces for #ClutterActor | ||||
|  * @see_also: #ClutterActor | ||||
|  * | ||||
|  * #CallyActor implements the required ATK interfaces of [class@Clutter.Actor] | ||||
|  * #CallyActor implements the required ATK interfaces of #ClutterActor | ||||
|  * exposing the common elements on each actor (position, extents, etc). | ||||
|  */ | ||||
|  | ||||
| @@ -41,7 +42,7 @@ | ||||
|  * has a key focus managed by the stage. Basically any actor can be focused using | ||||
|  * clutter_stage_set_key_focus. So, we will use this approach: all actors are | ||||
|  * focusable, and we get the currently focused using clutter_stage_get_key_focus | ||||
|  * This affects focus related stateset and some atk_component focus methods (like | ||||
|  * This affects focus related stateset and some atk_componenet focus methods (like | ||||
|  * grab focus). | ||||
|  * | ||||
|  * In the same way, we will manage the focus state change management | ||||
| @@ -66,17 +67,19 @@ | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include <glib.h> | ||||
| #include <clutter/clutter.h> | ||||
|  | ||||
| #include "clutter/clutter.h" | ||||
| #include "clutter/clutter-actor-private.h" | ||||
| #ifdef CLUTTER_WINDOWING_X11 | ||||
| #include <clutter/x11/clutter-x11.h> | ||||
| #endif | ||||
|  | ||||
| #include <math.h> | ||||
|  | ||||
| #include "cally/cally-actor.h" | ||||
| #include "cally/cally-actor-private.h" | ||||
| #include "cally-actor.h" | ||||
| #include "cally-actor-private.h" | ||||
|  | ||||
| typedef struct _CallyActorActionInfo CallyActorActionInfo; | ||||
|  | ||||
| @@ -193,6 +196,8 @@ G_DEFINE_TYPE_WITH_CODE (CallyActor, | ||||
|  * Creates a new #CallyActor for the given @actor | ||||
|  * | ||||
|  * Return value: the newly created #AtkObject | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| AtkObject * | ||||
| cally_actor_new (ClutterActor *actor) | ||||
| @@ -305,7 +310,11 @@ cally_actor_finalize (GObject *obj) | ||||
|  | ||||
|   _cally_actor_clean_action_list (cally_actor); | ||||
|  | ||||
|   g_clear_handle_id (&priv->action_idle_handler, g_source_remove); | ||||
|   if (priv->action_idle_handler) | ||||
|     { | ||||
|       g_source_remove (priv->action_idle_handler); | ||||
|       priv->action_idle_handler = 0; | ||||
|     } | ||||
|  | ||||
|   if (priv->action_queue) | ||||
|     { | ||||
| @@ -595,11 +604,10 @@ cally_actor_real_remove_actor (ClutterActor *container, | ||||
|   g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), 0); | ||||
|  | ||||
|   atk_parent = ATK_OBJECT (data); | ||||
|   atk_child = clutter_actor_get_accessible (actor); | ||||
|  | ||||
|   if (clutter_actor_has_accessible (actor)) | ||||
|   if (atk_child) | ||||
|     { | ||||
|       atk_child = clutter_actor_get_accessible (actor); | ||||
|  | ||||
|       g_value_init (&values.old_value, G_TYPE_POINTER); | ||||
|       g_value_set_pointer (&values.old_value, atk_parent); | ||||
|  | ||||
| @@ -649,7 +657,7 @@ cally_actor_get_extents (AtkComponent *component, | ||||
|   ClutterActor *actor      = NULL; | ||||
|   gint          top_level_x, top_level_y; | ||||
|   gfloat        f_width, f_height; | ||||
|   graphene_point3d_t verts[4]; | ||||
|   ClutterVertex verts[4]; | ||||
|   ClutterActor  *stage = NULL; | ||||
|  | ||||
|   g_return_if_fail (CALLY_IS_ACTOR (component)); | ||||
| @@ -729,7 +737,11 @@ cally_actor_grab_focus (AtkComponent    *component) | ||||
|  * | ||||
|  * This gets the top level origin, it is, the position of the stage in | ||||
|  * the global screen. You can see it as the absolute display position | ||||
|  * of the stage. This is 0,0 for a compositor. | ||||
|  * of the stage. | ||||
|  * | ||||
|  * FIXME: only the case with x11 is implemented, other backends are | ||||
|  * required | ||||
|  * | ||||
|  */ | ||||
| void | ||||
| _cally_actor_get_top_level_origin (ClutterActor *actor, | ||||
| @@ -737,11 +749,54 @@ _cally_actor_get_top_level_origin (ClutterActor *actor, | ||||
|                                    gint         *yp) | ||||
| { | ||||
|   /* default values */ | ||||
|   gint x = 0; | ||||
|   gint y = 0; | ||||
|  | ||||
| #ifdef CLUTTER_WINDOWING_X11 | ||||
|   if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11)) | ||||
|     { | ||||
|       ClutterActor *stage      = NULL; | ||||
|       Display *display    = NULL; | ||||
|       Window root_window; | ||||
|       Window stage_window; | ||||
|       Window child; | ||||
|       gint return_val = 0; | ||||
|  | ||||
|       stage = clutter_actor_get_stage (actor); | ||||
|  | ||||
|       /* FIXME: what happens if you use another display with | ||||
|          clutter_backend_x11_set_display ?*/ | ||||
|       display = clutter_x11_get_default_display (); | ||||
|       root_window = clutter_x11_get_root_window (); | ||||
|       stage_window = clutter_x11_get_stage_window (CLUTTER_STAGE (stage)); | ||||
|  | ||||
|       return_val = XTranslateCoordinates (display, stage_window, root_window, | ||||
|                                           0, 0, &x, &y, | ||||
|                                           &child); | ||||
|  | ||||
|       if (!return_val) | ||||
|         g_warning ("[x11] We were not able to get proper absolute " | ||||
|                    "position of the stage"); | ||||
|     } | ||||
|   else | ||||
| #endif | ||||
|     { | ||||
|       static gboolean yet_warned = FALSE; | ||||
|  | ||||
|       if (!yet_warned) | ||||
|         { | ||||
|           yet_warned = TRUE; | ||||
|  | ||||
|           g_warning ("The current Clutter backend does not support using " | ||||
|                      "atk_component_get_extents() with ATK_XY_SCREEN."); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   if (xp) | ||||
|     *xp = 0; | ||||
|     *xp = x; | ||||
|  | ||||
|   if (yp) | ||||
|     *yp = 0; | ||||
|     *yp = y; | ||||
| } | ||||
|  | ||||
| /* AtkAction implementation */ | ||||
| @@ -762,11 +817,10 @@ static gboolean | ||||
| cally_actor_action_do_action (AtkAction *action, | ||||
|                              gint       index) | ||||
| { | ||||
|   CallyActor *cally_actor = NULL; | ||||
|   AtkStateSet *set = NULL; | ||||
|   CallyActorPrivate *priv = NULL; | ||||
|   CallyActorActionInfo *info = NULL; | ||||
|   gboolean did_action = FALSE; | ||||
|   CallyActor           *cally_actor = NULL; | ||||
|   AtkStateSet          *set         = NULL; | ||||
|   CallyActorPrivate    *priv        = NULL; | ||||
|   CallyActorActionInfo *info        = NULL; | ||||
|  | ||||
|   cally_actor = CALLY_ACTOR (action); | ||||
|   priv = cally_actor->priv; | ||||
| @@ -774,19 +828,21 @@ cally_actor_action_do_action (AtkAction *action, | ||||
|   set = atk_object_ref_state_set (ATK_OBJECT (cally_actor)); | ||||
|  | ||||
|   if (atk_state_set_contains_state (set, ATK_STATE_DEFUNCT)) | ||||
|     goto out; | ||||
|     return FALSE; | ||||
|  | ||||
|   if (!atk_state_set_contains_state (set, ATK_STATE_SENSITIVE) || | ||||
|       !atk_state_set_contains_state (set, ATK_STATE_SHOWING)) | ||||
|     goto out; | ||||
|     return FALSE; | ||||
|  | ||||
|   g_object_unref (set); | ||||
|  | ||||
|   info = _cally_actor_get_action_info (cally_actor, index); | ||||
|  | ||||
|   if (info == NULL) | ||||
|     goto out; | ||||
|     return FALSE; | ||||
|  | ||||
|   if (info->do_action_func == NULL) | ||||
|     goto out; | ||||
|     return FALSE; | ||||
|  | ||||
|   if (!priv->action_queue) | ||||
|     priv->action_queue = g_queue_new (); | ||||
| @@ -796,12 +852,7 @@ cally_actor_action_do_action (AtkAction *action, | ||||
|   if (!priv->action_idle_handler) | ||||
|     priv->action_idle_handler = g_idle_add (idle_do_action, cally_actor); | ||||
|  | ||||
|   did_action = TRUE; | ||||
|  | ||||
| out: | ||||
|   g_clear_object (&set); | ||||
|  | ||||
|   return did_action; | ||||
|   return TRUE; | ||||
| } | ||||
|  | ||||
| static gboolean | ||||
| @@ -967,7 +1018,7 @@ cally_actor_real_notify_clutter (GObject    *obj, | ||||
|        * paint it; we don't want this to generate an ATK | ||||
|        * state change | ||||
|        */ | ||||
|       if (clutter_actor_is_painting_unmapped (actor)) | ||||
|       if (clutter_actor_is_in_clone_paint (actor)) | ||||
|         return; | ||||
|  | ||||
|       state = ATK_STATE_SHOWING; | ||||
| @@ -1032,6 +1083,8 @@ _cally_actor_get_action_info (CallyActor *cally_actor, | ||||
|  * Adds a new action to be accessed with the #AtkAction interface. | ||||
|  * | ||||
|  * Return value: added action id, or -1 if failure | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| guint | ||||
| cally_actor_add_action (CallyActor      *cally_actor, | ||||
| @@ -1061,6 +1114,8 @@ cally_actor_add_action (CallyActor      *cally_actor, | ||||
|  * Adds a new action to be accessed with the #AtkAction interface. | ||||
|  * | ||||
|  * Return value: added action id, or -1 if failure | ||||
|  * | ||||
|  * Since: 1.6 | ||||
|  */ | ||||
| guint | ||||
| cally_actor_add_action_full (CallyActor          *cally_actor, | ||||
| @@ -1079,7 +1134,7 @@ cally_actor_add_action_full (CallyActor          *cally_actor, | ||||
|  | ||||
|   priv = cally_actor->priv; | ||||
|  | ||||
|   info = g_new0 (CallyActorActionInfo, 1); | ||||
|   info = g_slice_new (CallyActorActionInfo); | ||||
|   info->name = g_strdup (action_name); | ||||
|   info->description = g_strdup (action_description); | ||||
|   info->keybinding = g_strdup (action_keybinding); | ||||
| @@ -1097,9 +1152,11 @@ cally_actor_add_action_full (CallyActor          *cally_actor, | ||||
|  * @cally_actor: a #CallyActor | ||||
|  * @action_id: the action id | ||||
|  * | ||||
|  * Removes a action, using the @action_id returned by [method@Actor.add_action] | ||||
|  * Removes a action, using the @action_id returned by cally_actor_add_action() | ||||
|  * | ||||
|  * Return value: %TRUE if the operation was successful, %FALSE otherwise | ||||
|  * Return value: %TRUE if the operation was succesful, %FALSE otherwise | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| gboolean | ||||
| cally_actor_remove_action (CallyActor *cally_actor, | ||||
| @@ -1129,9 +1186,11 @@ cally_actor_remove_action (CallyActor *cally_actor, | ||||
|  * @action_name: the name of the action to remove | ||||
|  * | ||||
|  * Removes an action, using the @action_name used when the action was added | ||||
|  * with [method@Actor.add_action] | ||||
|  * with cally_actor_add_action() | ||||
|  * | ||||
|  * Return value: %TRUE if the operation was successful, %FALSE otherwise | ||||
|  * Return value: %TRUE if the operation was succesful, %FALSE otherwise | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| gboolean | ||||
| cally_actor_remove_action_by_name (CallyActor  *cally_actor, | ||||
| @@ -1180,5 +1239,5 @@ _cally_actor_destroy_action_info (gpointer action_info, | ||||
|   if (info->notify) | ||||
|     info->notify (info->user_data); | ||||
|  | ||||
|   g_free (info); | ||||
|   g_slice_free (CallyActorActionInfo, info); | ||||
| } | ||||
|   | ||||
| @@ -22,15 +22,15 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CALLY_ACTOR_H__ | ||||
| #define __CALLY_ACTOR_H__ | ||||
|  | ||||
| #if !defined(__CALLY_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <cally/cally.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include <atk/atk.h> | ||||
|  | ||||
| #include "clutter/clutter.h" | ||||
| #include <clutter/clutter.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -51,6 +51,8 @@ typedef struct _CallyActorPrivate    CallyActorPrivate; | ||||
|  * | ||||
|  * Action function, to be used on #AtkAction implementations as a individual | ||||
|  * action | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| typedef void (* CallyActionFunc) (CallyActor *cally_actor); | ||||
|  | ||||
| @@ -60,14 +62,22 @@ typedef void (* CallyActionFunc) (CallyActor *cally_actor); | ||||
|  * @user_data: user data passed to the function | ||||
|  * | ||||
|  * Action function, to be used on #AtkAction implementations as | ||||
|  * an individual action. | ||||
|  *  | ||||
|  * Unlike #CallyActionFunc, this function uses the @user_data  | ||||
|  * argument passed to [method@Actor.add_action_full]. | ||||
|  * an individual action. Unlike #CallyActionFunc, this function | ||||
|  * uses the @user_data argument passed to cally_actor_add_action_full(). | ||||
|  * | ||||
|  * Since: 1.6 | ||||
|  */ | ||||
| typedef void (* CallyActionCallback) (CallyActor *cally_actor, | ||||
|                                       gpointer    user_data); | ||||
|  | ||||
| /** | ||||
|  * CallyActor: | ||||
|  * | ||||
|  * The <structname>CallyActor</structname> structure contains only private | ||||
|  * data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyActor | ||||
| { | ||||
|   /*< private >*/ | ||||
| @@ -79,6 +89,8 @@ struct _CallyActor | ||||
| /** | ||||
|  * CallyActorClass: | ||||
|  * @notify_clutter: Signal handler for notify signal on Clutter actor | ||||
|  * @focus_clutter: Signal handler for key-focus-in and key-focus-out | ||||
|  *   signal on Clutter actor. This virtual functions is deprecated. | ||||
|  * @add_actor: Signal handler for actor-added signal on | ||||
|  *   ClutterContainer interface | ||||
|  * @remove_actor: Signal handler for actor-added signal on | ||||
| @@ -86,6 +98,8 @@ struct _CallyActor | ||||
|  * | ||||
|  * The <structname>CallyActorClass</structname> structure contains | ||||
|  * only private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyActorClass | ||||
| { | ||||
| @@ -96,6 +110,9 @@ struct _CallyActorClass | ||||
|   void     (*notify_clutter) (GObject    *object, | ||||
|                               GParamSpec *pspec); | ||||
|  | ||||
|   gboolean (*focus_clutter)  (ClutterActor *actor, | ||||
|                               gpointer      data); | ||||
|  | ||||
|   gint     (*add_actor)      (ClutterActor *container, | ||||
|                               ClutterActor *actor, | ||||
|                               gpointer      data); | ||||
| @@ -103,6 +120,10 @@ struct _CallyActorClass | ||||
|   gint     (*remove_actor)   (ClutterActor *container, | ||||
|                               ClutterActor *actor, | ||||
|                               gpointer      data); | ||||
|  | ||||
|   /*< private >*/ | ||||
|   /* padding for future expansion */ | ||||
|   gpointer _padding_dummy[32]; | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| @@ -135,3 +156,5 @@ gboolean   cally_actor_remove_action_by_name (CallyActor          *cally_actor, | ||||
|                                               const gchar         *action_name); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CALLY_ACTOR_H__ */ | ||||
|   | ||||
| @@ -15,15 +15,18 @@ | ||||
|  * 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/>. | ||||
|  * License along with this library; if not, write to the | ||||
|  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||
|  * Boston, MA 02111-1307, USA. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * CallyClone: | ||||
|  *  | ||||
|  * Implementation of the ATK interfaces for a #ClutterClone | ||||
|  * SECTION:cally-clone | ||||
|  * @Title: CallyClone | ||||
|  * @short_description: Implementation of the ATK interfaces for a #ClutterClone | ||||
|  * @see_also: #ClutterClone | ||||
|  * | ||||
|  * #CallyClone implements the required ATK interfaces of [class@Clutter.Clone] | ||||
|  * #CallyClone implements the required ATK interfaces of #ClutterClone | ||||
|  * | ||||
|  * In particular it sets a proper role for the clone, as just a image, | ||||
|  * as it is the sanest and simplest approach. | ||||
| @@ -33,7 +36,7 @@ | ||||
|  * | ||||
|  * In the old times, it was just ClutterCloneTexture. So, from a a11y POV | ||||
|  * CallyCloneTexture was just another image, like ClutterTexture, and if | ||||
|  * it was a clone was irrelevant. So on cally-0.8, CallyCloneTexture | ||||
|  * it was a clone was irrevelant. So on cally-0.8, CallyCloneTexture | ||||
|  * expose a object with role ATK_ROLE_IMAGE. But now, ClutterClone is more | ||||
|  * general. You can clone any object, including groups, and made things | ||||
|  * like have one text entry, and a clone with different properties in the | ||||
| @@ -66,10 +69,10 @@ | ||||
|  * a11y POV should still be managed as a image (with the proper properties, | ||||
|  * position, size, etc.). | ||||
|  */ | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "cally/cally-clone.h" | ||||
| #include "cally/cally-actor-private.h" | ||||
| #include "cally-clone.h" | ||||
| #include "cally-actor-private.h" | ||||
|  | ||||
| /* AtkObject */ | ||||
| static void                  cally_clone_real_initialize (AtkObject *obj, | ||||
| @@ -97,9 +100,11 @@ cally_clone_init (CallyClone *clone) | ||||
|  * @actor: a #ClutterActor | ||||
|  * | ||||
|  * Creates a new #CallyClone for the given @actor. @actor must be a | ||||
|  * [class@Clutter.Clone]. | ||||
|  * #ClutterClone. | ||||
|  * | ||||
|  * Return value: the newly created #AtkObject | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| AtkObject* | ||||
| cally_clone_new (ClutterActor *actor) | ||||
|   | ||||
| @@ -18,14 +18,15 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CALLY_CLONE_H__ | ||||
| #define __CALLY_CLONE_H__ | ||||
|  | ||||
| #if !defined(__CALLY_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <cally/cally.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter.h" | ||||
| #include "cally/cally-actor.h" | ||||
| #include <clutter/clutter.h> | ||||
| #include <cally/cally-actor.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -40,6 +41,14 @@ typedef struct _CallyClone        CallyClone; | ||||
| typedef struct _CallyCloneClass   CallyCloneClass; | ||||
| typedef struct _CallyClonePrivate CallyClonePrivate; | ||||
|  | ||||
| /** | ||||
|  * CallyClone: | ||||
|  * | ||||
|  * The <structname>CallyClone</structname> structure contains only private | ||||
|  * data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyClone | ||||
| { | ||||
|   /*< private >*/ | ||||
| @@ -53,11 +62,16 @@ struct _CallyClone | ||||
|  * | ||||
|  * The <structname>CallyCloneClass</structname> structure contains only | ||||
|  * private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyCloneClass | ||||
| { | ||||
|   /*< private >*/ | ||||
|   CallyActorClass parent_class; | ||||
|  | ||||
|   /* padding for future expansion */ | ||||
|   gpointer _padding_dummy[8]; | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| @@ -66,3 +80,5 @@ CLUTTER_EXPORT | ||||
| AtkObject *cally_clone_new      (ClutterActor *actor); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CALLY_CLONE_H__ */ | ||||
|   | ||||
| @@ -18,10 +18,13 @@ | ||||
|  * 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/>. | ||||
|  * License along with this library; if not, write to the | ||||
|  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||
|  * Boston, MA 02111-1307, USA. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef _CALLY_FACTORY_H__ | ||||
| #define _CALLY_FACTORY_H__ | ||||
|  | ||||
| #include <glib-object.h> | ||||
| #include <atk/atkobject.h> | ||||
| @@ -39,6 +42,8 @@ | ||||
|  * It assumes that the accessibility object provides a | ||||
|  * @opt_create_accessible method in order to create the accessibility | ||||
|  * object. It returns a @type GType object. | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| #define CALLY_ACCESSIBLE_FACTORY(type, type_as_function, opt_create_accessible)	\ | ||||
| 										\ | ||||
| @@ -101,8 +106,12 @@ type_as_function ## _factory_get_type (void)					\ | ||||
|  * | ||||
|  * Sets the #AtkObjectFactory to be used in order to instantiate | ||||
|  * accessibility objects for the actor which GType is @widget_type. | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| #define CALLY_ACTOR_SET_FACTORY(widget_type, type_as_function)			\ | ||||
| 	atk_registry_set_factory_type (atk_get_default_registry (),		\ | ||||
| 				       widget_type,				\ | ||||
| 				       type_as_function ## _factory_get_type ()) | ||||
|  | ||||
| #endif /* _CALLY_FACTORY_H__ */ | ||||
|   | ||||
							
								
								
									
										147
									
								
								clutter/clutter/cally/cally-group.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								clutter/clutter/cally/cally-group.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,147 @@ | ||||
| /* CALLY - The Clutter Accessibility Implementation Library | ||||
|  * | ||||
|  * Copyright (C) 2008 Igalia, S.L. | ||||
|  * | ||||
|  * Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com> | ||||
|  * | ||||
|  * Based on GailContainer from GAIL | ||||
|  * Copyright 2001, 2002, 2003 Sun Microsystems Inc. | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the | ||||
|  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||
|  * Boston, MA 02111-1307, USA. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * SECTION:cally-group | ||||
|  * @Title: CallyGroup | ||||
|  * @short_description: Implementation of the ATK interfaces for a #ClutterGroup | ||||
|  * @see_also: #ClutterGroup | ||||
|  * | ||||
|  * #CallyGroup implements the required ATK interfaces of #ClutterGroup | ||||
|  * In particular it exposes each of the Clutter actors contained in the | ||||
|  * group. | ||||
|  */ | ||||
|  | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "cally-group.h" | ||||
| #include "cally-actor-private.h" | ||||
|  | ||||
| static gint       cally_group_get_n_children  (AtkObject *obj); | ||||
| static AtkObject* cally_group_ref_child       (AtkObject *obj, | ||||
|                                               gint       i); | ||||
| static void       cally_group_real_initialize (AtkObject *obj, | ||||
|                                               gpointer   data); | ||||
|  | ||||
| G_DEFINE_TYPE (CallyGroup, cally_group, CALLY_TYPE_ACTOR) | ||||
|  | ||||
| static void | ||||
| cally_group_class_init (CallyGroupClass *klass) | ||||
| { | ||||
| /*   GObjectClass   *gobject_class = G_OBJECT_CLASS (klass); */ | ||||
|   AtkObjectClass *class         = ATK_OBJECT_CLASS (klass); | ||||
|  | ||||
|   class->get_n_children = cally_group_get_n_children; | ||||
|   class->ref_child      = cally_group_ref_child; | ||||
|   class->initialize     = cally_group_real_initialize; | ||||
| } | ||||
|  | ||||
| static void | ||||
| cally_group_init (CallyGroup      *group) | ||||
| { | ||||
|   /* nothing to do yet */ | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * cally_group_new: | ||||
|  * @actor: a #ClutterGroup | ||||
|  * | ||||
|  * Creates a #CallyGroup for @actor | ||||
|  * | ||||
|  * Return value: the newly created #CallyGroup | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| AtkObject * | ||||
| cally_group_new (ClutterActor *actor) | ||||
| { | ||||
|   GObject   *object     = NULL; | ||||
|   AtkObject *accessible = NULL; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_GROUP (actor), NULL); | ||||
|  | ||||
|   object = g_object_new (CALLY_TYPE_GROUP, NULL); | ||||
|  | ||||
|   accessible = ATK_OBJECT (object); | ||||
|   atk_object_initialize (accessible, actor); | ||||
|  | ||||
|   return accessible; | ||||
| } | ||||
|  | ||||
| static gint | ||||
| cally_group_get_n_children (AtkObject *obj) | ||||
| { | ||||
|   ClutterActor *actor = NULL; | ||||
|   gint          count = 0; | ||||
|  | ||||
|   g_return_val_if_fail (CALLY_IS_GROUP (obj), count); | ||||
|  | ||||
|   actor = CALLY_GET_CLUTTER_ACTOR (obj); | ||||
|  | ||||
|   if (actor == NULL) /* defunct */ | ||||
|     return 0; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_GROUP(actor), count); | ||||
|  | ||||
|   count = clutter_actor_get_n_children (actor); | ||||
|  | ||||
|   return count; | ||||
| } | ||||
|  | ||||
| static AtkObject* | ||||
| cally_group_ref_child (AtkObject *obj, | ||||
|                        gint       i) | ||||
| { | ||||
|   AtkObject    *accessible = NULL; | ||||
|   ClutterActor *actor      = NULL; | ||||
|   ClutterActor *child      = NULL; | ||||
|  | ||||
|   g_return_val_if_fail (CALLY_IS_GROUP (obj), NULL); | ||||
|   g_return_val_if_fail ((i >= 0), NULL); | ||||
|  | ||||
|   actor = CALLY_GET_CLUTTER_ACTOR (obj); | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_GROUP(actor), NULL); | ||||
|   child = clutter_actor_get_child_at_index (actor, i); | ||||
|  | ||||
|   if (!child) | ||||
|     return NULL; | ||||
|  | ||||
|   accessible = clutter_actor_get_accessible (child); | ||||
|  | ||||
|   if (accessible != NULL) | ||||
|     g_object_ref (accessible); | ||||
|  | ||||
|   return accessible; | ||||
| } | ||||
|  | ||||
| static void | ||||
| cally_group_real_initialize (AtkObject *obj, | ||||
|                             gpointer   data) | ||||
| { | ||||
|   ATK_OBJECT_CLASS (cally_group_parent_class)->initialize (obj, data); | ||||
|  | ||||
|   obj->role = ATK_ROLE_PANEL; | ||||
| } | ||||
							
								
								
									
										87
									
								
								clutter/clutter/cally/cally-group.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								clutter/clutter/cally/cally-group.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,87 @@ | ||||
| /* CALLY - The Clutter Accessibility Implementation Library | ||||
|  * | ||||
|  * Copyright (C) 2008 Igalia, S.L. | ||||
|  * | ||||
|  * Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com> | ||||
|  * | ||||
|  * Based on GailContainer from GAIL | ||||
|  * Copyright 2001, 2002, 2003 Sun Microsystems Inc. | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #ifndef __CALLY_GROUP_H__ | ||||
| #define __CALLY_GROUP_H__ | ||||
|  | ||||
| #if !defined(__CALLY_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <cally/cally.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include <cally/cally-actor.h> | ||||
| #include <clutter/clutter.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| #define CALLY_TYPE_GROUP                         (cally_group_get_type ()) | ||||
| #define CALLY_GROUP(obj)                         (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_GROUP, CallyGroup)) | ||||
| #define CALLY_GROUP_CLASS(klass)                 (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_GROUP, CallyGroupClass)) | ||||
| #define CALLY_IS_GROUP(obj)                      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_GROUP)) | ||||
| #define CALLY_IS_GROUP_CLASS(klass)              (G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_GROUP)) | ||||
| #define CALLY_GROUP_GET_CLASS(obj)               (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_GROUP, CallyGroupClass)) | ||||
|  | ||||
| typedef struct _CallyGroup        CallyGroup; | ||||
| typedef struct _CallyGroupClass   CallyGroupClass; | ||||
| typedef struct _CallyGroupPrivate CallyGroupPrivate; | ||||
|  | ||||
| /** | ||||
|  * CallyGroup: | ||||
|  * | ||||
|  * The <structname>CallyGroup</structname> structure contains only | ||||
|  * private data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyGroup | ||||
| { | ||||
|   /*< private >*/ | ||||
|   CallyActor parent; | ||||
|  | ||||
|   CallyGroupPrivate *priv; | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * CallyGroupClass: | ||||
|  * | ||||
|  * The <structname>CallyGroupClass</structname> structure contains only | ||||
|  * private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyGroupClass | ||||
| { | ||||
|   /*< private >*/ | ||||
|   CallyActorClass parent_class; | ||||
|  | ||||
|   /* padding for future expansion */ | ||||
|   gpointer _padding_dummy[8]; | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| GType      cally_group_get_type (void) G_GNUC_CONST; | ||||
| CLUTTER_EXPORT | ||||
| AtkObject* cally_group_new      (ClutterActor *actor); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CALLY_GROUP_H__ */ | ||||
| @@ -22,7 +22,8 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CALLY_MAIN_H__ | ||||
| #define __CALLY_MAIN_H__ | ||||
|  | ||||
| #if !defined(__CALLY_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <cally/cally.h> can be included directly." | ||||
| @@ -39,3 +40,5 @@ CLUTTER_EXPORT | ||||
| gboolean cally_accessibility_init    (void); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CALLY_MAIN_H__ */ | ||||
|   | ||||
							
								
								
									
										98
									
								
								clutter/clutter/cally/cally-rectangle.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								clutter/clutter/cally/cally-rectangle.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,98 @@ | ||||
| /* CALLY - The Clutter Accessibility Implementation Library | ||||
|  * | ||||
|  * Copyright (C) 2009 Igalia, S.L. | ||||
|  * | ||||
|  * Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com> | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the | ||||
|  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||
|  * Boston, MA 02111-1307, USA. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * SECTION:cally-rectangle | ||||
|  * @short_description: Implementation of the ATK interfaces for a #ClutterRectangle | ||||
|  * @see_also: #ClutterRectangle | ||||
|  * | ||||
|  * #CallyRectangle implements the required ATK interfaces of #ClutterRectangle | ||||
|  * | ||||
|  * In particular it sets a proper role for the rectangle. | ||||
|  */ | ||||
|  | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #define CLUTTER_DISABLE_DEPRECATION_WARNINGS | ||||
|  | ||||
| #include "cally-rectangle.h" | ||||
| #include "cally-actor-private.h" | ||||
|  | ||||
| #include "clutter-color.h" | ||||
| #include "deprecated/clutter-rectangle.h" | ||||
|  | ||||
| /* AtkObject */ | ||||
| static void                  cally_rectangle_real_initialize (AtkObject *obj, | ||||
|                                                               gpointer   data); | ||||
|  | ||||
| G_DEFINE_TYPE (CallyRectangle, cally_rectangle, CALLY_TYPE_ACTOR) | ||||
|  | ||||
| static void | ||||
| cally_rectangle_class_init (CallyRectangleClass *klass) | ||||
| { | ||||
| /*   GObjectClass   *gobject_class = G_OBJECT_CLASS (klass); */ | ||||
|   AtkObjectClass *class         = ATK_OBJECT_CLASS (klass); | ||||
|  | ||||
|   class->initialize      = cally_rectangle_real_initialize; | ||||
| } | ||||
|  | ||||
| static void | ||||
| cally_rectangle_init (CallyRectangle *rectangle) | ||||
| { | ||||
|   /* nothing to do yet */ | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * cally_rectangle_new: | ||||
|  * @actor: a #ClutterActor | ||||
|  * | ||||
|  * Creates a new #CallyRectangle for the given @actor. @actor must be | ||||
|  * a #ClutterRectangle. | ||||
|  * | ||||
|  * Return value: the newly created #AtkObject | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| AtkObject* | ||||
| cally_rectangle_new (ClutterActor *actor) | ||||
| { | ||||
|   GObject   *object     = NULL; | ||||
|   AtkObject *accessible = NULL; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_RECTANGLE (actor), NULL); | ||||
|  | ||||
|   object = g_object_new (CALLY_TYPE_RECTANGLE, NULL); | ||||
|  | ||||
|   accessible = ATK_OBJECT (object); | ||||
|   atk_object_initialize (accessible, actor); | ||||
|  | ||||
|   return accessible; | ||||
| } | ||||
|  | ||||
| static void | ||||
| cally_rectangle_real_initialize (AtkObject *obj, | ||||
|                                  gpointer   data) | ||||
| { | ||||
|   ATK_OBJECT_CLASS (cally_rectangle_parent_class)->initialize (obj, data); | ||||
|  | ||||
|   obj->role = ATK_ROLE_IMAGE; | ||||
| } | ||||
							
								
								
									
										84
									
								
								clutter/clutter/cally/cally-rectangle.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								clutter/clutter/cally/cally-rectangle.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,84 @@ | ||||
| /* CALLY - The Clutter Accessibility Implementation Library | ||||
|  * | ||||
|  * Copyright (C) 2009 Igalia, S.L. | ||||
|  * | ||||
|  * Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com> | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #ifndef __CALLY_RECTANGLE_H__ | ||||
| #define __CALLY_RECTANGLE_H__ | ||||
|  | ||||
| #if !defined(__CALLY_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <cally/cally.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include <cally/cally-actor.h> | ||||
| #include <clutter/clutter.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| #define CALLY_TYPE_RECTANGLE            (cally_rectangle_get_type ()) | ||||
| #define CALLY_RECTANGLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_RECTANGLE, CallyRectangle)) | ||||
| #define CALLY_RECTANGLE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_RECTANGLE, CallyRectangleClass)) | ||||
| #define CALLY_IS_RECTANGLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_RECTANGLE)) | ||||
| #define CALLY_IS_RECTANGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_RECTANGLE)) | ||||
| #define CALLY_RECTANGLE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_RECTANGLE, CallyRectangleClass)) | ||||
|  | ||||
| typedef struct _CallyRectangle         CallyRectangle; | ||||
| typedef struct _CallyRectangleClass    CallyRectangleClass; | ||||
| typedef struct _CallyRectanglePrivate  CallyRectanglePrivate; | ||||
|  | ||||
| /** | ||||
|  * CallyRectangle: | ||||
|  * | ||||
|  * The <structname>CallyRectangle</structname> structure contains only private | ||||
|  * data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyRectangle | ||||
| { | ||||
|   /*< private >*/ | ||||
|   CallyActor parent; | ||||
|  | ||||
|   CallyRectanglePrivate *priv; | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * CallyRectangleClass: | ||||
|  * | ||||
|  * The <structname>CallyRectangleClass</structname> structure contains | ||||
|  * only private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyRectangleClass | ||||
| { | ||||
|   /*< private >*/ | ||||
|   CallyActorClass parent_class; | ||||
|  | ||||
|   /* padding for future expansion */ | ||||
|   gpointer _padding_dummy[8]; | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| GType      cally_rectangle_get_type (void) G_GNUC_CONST; | ||||
| CLUTTER_EXPORT | ||||
| AtkObject* cally_rectangle_new      (ClutterActor *actor); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CALLY_RECTANGLE_H__ */ | ||||
| @@ -15,31 +15,33 @@ | ||||
|  * 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/>. | ||||
|  * License along with this library; if not, write to the | ||||
|  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||
|  * Boston, MA 02111-1307, USA. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * CallyRoot: | ||||
|  *  | ||||
|  * Root object for the Cally toolkit | ||||
|  * SECTION:cally-root | ||||
|  * @short_description: Root object for the Cally toolkit | ||||
|  * @see_also: #ClutterStage | ||||
|  * | ||||
|  * #CallyRoot is the root object of the accessibility tree-like | ||||
|  * hierarchy, exposing the application level. | ||||
|  * | ||||
|  * Somewhat equivalent to #GailTopLevel. We consider that this class | ||||
|  * expose the a11y information of the [class@Clutter.StageManager], as the | ||||
|  * children of this object are the different [class@Clutter.Stage] managed (so | ||||
|  * the [class@GObject.Object] used in the atk_object_initialize() is the | ||||
|  * [class@Clutter.StageManager]). | ||||
|  * expose the a11y information of the #ClutterStageManager, as the | ||||
|  * children of this object are the different ClutterStage managed (so | ||||
|  * the #GObject used in the atk_object_initialize() is the | ||||
|  * #ClutterStageManager). | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "cally/cally-root.h" | ||||
| #include "cally-root.h" | ||||
|  | ||||
| #include "clutter/clutter-actor.h" | ||||
| #include "clutter/clutter-stage-private.h" | ||||
| #include "clutter/clutter-stage-manager.h" | ||||
| #include "clutter-actor.h" | ||||
| #include "clutter-stage-private.h" | ||||
| #include "clutter-stage-manager.h" | ||||
|  | ||||
|  | ||||
| /* GObject */ | ||||
| @@ -73,8 +75,8 @@ struct _CallyRootPrivate | ||||
|   GSList *stage_list; | ||||
|  | ||||
|   /* signals id */ | ||||
|   gulong stage_added_id; | ||||
|   gulong stage_removed_id; | ||||
|   guint stage_added_id; | ||||
|   guint stage_removed_id; | ||||
| }; | ||||
|  | ||||
| G_DEFINE_TYPE_WITH_PRIVATE (CallyRoot, cally_root,  ATK_TYPE_GOBJECT_ACCESSIBLE) | ||||
| @@ -111,6 +113,8 @@ cally_root_init (CallyRoot *root) | ||||
|  * Creates a new #CallyRoot object. | ||||
|  * | ||||
|  * Return value: the newly created #AtkObject | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| AtkObject* | ||||
| cally_root_new (void) | ||||
| @@ -145,9 +149,11 @@ cally_root_finalize (GObject *object) | ||||
|  | ||||
|   stage_manager = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (root)); | ||||
|  | ||||
|   g_clear_signal_handler (&root->priv->stage_added_id, stage_manager); | ||||
|   g_signal_handler_disconnect (stage_manager, | ||||
|                                root->priv->stage_added_id); | ||||
|  | ||||
|   g_clear_signal_handler (&root->priv->stage_removed_id, stage_manager); | ||||
|   g_signal_handler_disconnect (stage_manager, | ||||
|                                root->priv->stage_added_id); | ||||
|  | ||||
|   G_OBJECT_CLASS (cally_root_parent_class)->finalize (object); | ||||
| } | ||||
|   | ||||
| @@ -18,15 +18,15 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CALLY_ROOT_H__ | ||||
| #define __CALLY_ROOT_H__ | ||||
|  | ||||
| #if !defined(__CALLY_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <cally/cally.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include <atk/atk.h> | ||||
|  | ||||
| #include "clutter/clutter.h" | ||||
| #include <clutter/clutter.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -41,6 +41,14 @@ typedef struct _CallyRoot        CallyRoot; | ||||
| typedef struct _CallyRootClass   CallyRootClass; | ||||
| typedef struct _CallyRootPrivate CallyRootPrivate; | ||||
|  | ||||
| /** | ||||
|  * CallyRoot: | ||||
|  * | ||||
|  * The <structname>CallyRoot</structname> structure contains only private | ||||
|  * data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyRoot | ||||
| { | ||||
|   /*< private >*/ | ||||
| @@ -54,11 +62,16 @@ struct _CallyRoot | ||||
|  * | ||||
|  * The <structname>CallyRootClass</structname> structure contains only | ||||
|  * private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyRootClass | ||||
| { | ||||
|   /*< private >*/ | ||||
|   AtkGObjectAccessibleClass parent_class; | ||||
|  | ||||
|   /* padding for future expansion */ | ||||
|   gpointer _padding_dummy[16]; | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| @@ -67,3 +80,5 @@ CLUTTER_EXPORT | ||||
| AtkObject *cally_root_new      (void); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CALLY_ROOT_H__ */ | ||||
|   | ||||
| @@ -15,26 +15,29 @@ | ||||
|  * 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/>. | ||||
|  * License along with this library; if not, write to the | ||||
|  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||
|  * Boston, MA 02111-1307, USA. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * CallyStage: | ||||
|  *  | ||||
|  * Implementation of the ATK interfaces for a #ClutterStage | ||||
|  * SECTION:cally-stage | ||||
|  * @Title: CallyStage | ||||
|  * @short_description: Implementation of the ATK interfaces for a #ClutterStage | ||||
|  * @see_also: #ClutterStage | ||||
|  * | ||||
|  * #CallyStage implements the required ATK interfaces for [class@Clutter.Stage] | ||||
|  * #CallyStage implements the required ATK interfaces for #ClutterStage | ||||
|  * | ||||
|  * Some implementation details: at this moment #CallyStage is used as | ||||
|  * the most similar Window object in this toolkit (ie: emitting window | ||||
|  * related signals), although the real purpose of [class@Clutter.Stage] is | ||||
|  * related signals), although the real purpose of #ClutterStage is | ||||
|  * being a canvas. Anyway, this is required for applications using | ||||
|  * just clutter, or directly [class@Clutter.Stage] | ||||
|  * just clutter, or directly #ClutterStage | ||||
|  */ | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "cally/cally-stage.h" | ||||
| #include "cally/cally-actor-private.h" | ||||
| #include "cally-stage.h" | ||||
| #include "cally-actor-private.h" | ||||
|  | ||||
| /* AtkObject.h */ | ||||
| static void                  cally_stage_real_initialize (AtkObject *obj, | ||||
| @@ -44,7 +47,7 @@ static AtkStateSet*          cally_stage_ref_state_set   (AtkObject *obj); | ||||
| /* AtkWindow */ | ||||
| static void                  cally_stage_window_interface_init (AtkWindowIface *iface); | ||||
|  | ||||
| /* Auxiliary */ | ||||
| /* Auxiliar */ | ||||
| static void                  cally_stage_activate_cb     (ClutterStage *stage, | ||||
|                                                           gpointer      data); | ||||
| static void                  cally_stage_deactivate_cb   (ClutterStage *stage, | ||||
| @@ -60,7 +63,7 @@ struct _CallyStagePrivate | ||||
|  | ||||
| G_DEFINE_TYPE_WITH_CODE (CallyStage, | ||||
|                          cally_stage, | ||||
|                          CALLY_TYPE_ACTOR, | ||||
|                          CALLY_TYPE_GROUP, | ||||
|                          G_ADD_PRIVATE (CallyStage) | ||||
|                          G_IMPLEMENT_INTERFACE (ATK_TYPE_WINDOW, | ||||
|                                                 cally_stage_window_interface_init)); | ||||
| @@ -90,9 +93,11 @@ cally_stage_init (CallyStage *cally_stage) | ||||
|  * @actor: a #ClutterActor | ||||
|  * | ||||
|  * Creates a new #CallyStage for the given @actor. @actor should be a | ||||
|  * [class@Clutter.Stage]. | ||||
|  * #ClutterStage. | ||||
|  * | ||||
|  * Return value: the newly created #AtkObject | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| AtkObject* | ||||
| cally_stage_new (ClutterActor *actor) | ||||
| @@ -129,11 +134,8 @@ cally_stage_notify_key_focus_cb (ClutterStage *stage, | ||||
|  | ||||
|       if (self->priv->key_focus != NULL) | ||||
|         { | ||||
|           if (self->priv->key_focus != CLUTTER_ACTOR (stage)) | ||||
|             { | ||||
|               g_object_remove_weak_pointer (G_OBJECT (self->priv->key_focus), | ||||
|                                             (gpointer *) &self->priv->key_focus); | ||||
|             } | ||||
|           g_object_remove_weak_pointer (G_OBJECT (self->priv->key_focus), | ||||
|                                         (gpointer *) &self->priv->key_focus); | ||||
|           old = clutter_actor_get_accessible (self->priv->key_focus); | ||||
|         } | ||||
|       else | ||||
| @@ -158,11 +160,8 @@ cally_stage_notify_key_focus_cb (ClutterStage *stage, | ||||
|        * | ||||
|        * we remove the weak pointer above. | ||||
|        */ | ||||
|       if (key_focus != CLUTTER_ACTOR (stage)) | ||||
|         { | ||||
|           g_object_add_weak_pointer (G_OBJECT (self->priv->key_focus), | ||||
|                                      (gpointer *) &self->priv->key_focus); | ||||
|         } | ||||
|       g_object_add_weak_pointer (G_OBJECT (self->priv->key_focus), | ||||
|                                  (gpointer *) &self->priv->key_focus); | ||||
|  | ||||
|       new = clutter_actor_get_accessible (key_focus); | ||||
|     } | ||||
| @@ -223,7 +222,7 @@ cally_stage_window_interface_init (AtkWindowIface *iface) | ||||
|   /* At this moment AtkWindow is just about signals */ | ||||
| } | ||||
|  | ||||
| /* Auxiliary */ | ||||
| /* Auxiliar */ | ||||
| static void | ||||
| cally_stage_activate_cb     (ClutterStage *stage, | ||||
|                              gpointer      data) | ||||
|   | ||||
| @@ -18,14 +18,15 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CALLY_STAGE_H__ | ||||
| #define __CALLY_STAGE_H__ | ||||
|  | ||||
| #if !defined(__CALLY_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <cally/cally.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "cally/cally-actor.h" | ||||
| #include "clutter/clutter.h" | ||||
| #include <cally/cally-group.h> | ||||
| #include <clutter/clutter.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -40,10 +41,18 @@ typedef struct _CallyStage        CallyStage; | ||||
| typedef struct _CallyStageClass   CallyStageClass; | ||||
| typedef struct _CallyStagePrivate CallyStagePrivate; | ||||
|  | ||||
| /** | ||||
|  * CallyStage: | ||||
|  * | ||||
|  * The <structname>CallyStage</structname> structure contains only | ||||
|  * private data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyStage | ||||
| { | ||||
|   /*< private >*/ | ||||
|   CallyActor parent; | ||||
|   CallyGroup parent; | ||||
|  | ||||
|   CallyStagePrivate *priv; | ||||
| }; | ||||
| @@ -53,11 +62,16 @@ struct _CallyStage | ||||
|  * | ||||
|  * The <structname>CallyStageClass</structname> structure contains only | ||||
|  * private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyStageClass | ||||
| { | ||||
|   /*< private >*/ | ||||
|   CallyActorClass parent_class; | ||||
|   CallyGroupClass parent_class; | ||||
|  | ||||
|   /* padding for future expansion */ | ||||
|   gpointer _padding_dummy[16]; | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| @@ -66,3 +80,5 @@ CLUTTER_EXPORT | ||||
| AtkObject *cally_stage_new      (ClutterActor *actor); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CALLY_STAGE_H__ */ | ||||
|   | ||||
| @@ -23,26 +23,30 @@ | ||||
|  * 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/>. | ||||
|  * License along with this library; if not, write to the | ||||
|  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||
|  * Boston, MA 02111-1307, USA. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * CallyText: | ||||
|  *  | ||||
|  * Implementation of the ATK interfaces for a [class@Clutter.Text] | ||||
|  * SECTION:cally-text | ||||
|  * @short_description: Implementation of the ATK interfaces for a #ClutterText | ||||
|  * @see_also: #ClutterText | ||||
|  * | ||||
|  * #CallyText implements the required ATK interfaces of | ||||
|  * [class@Clutter.Text], #AtkText and #AtkEditableText | ||||
|  * #ClutterText, #AtkText and #AtkEditableText | ||||
|  * | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "cally/cally-text.h" | ||||
| #include "cally/cally-actor-private.h" | ||||
| #include "cally-text.h" | ||||
| #include "cally-actor-private.h" | ||||
|  | ||||
| #include "clutter/clutter-color.h" | ||||
| #include "clutter/clutter-main.h" | ||||
| #include "clutter/clutter-text.h" | ||||
| #include "clutter-color.h" | ||||
| #include "clutter-main.h" | ||||
| #include "clutter-text.h" | ||||
|  | ||||
| static void cally_text_finalize   (GObject *obj); | ||||
|  | ||||
| @@ -243,7 +247,11 @@ cally_text_finalize   (GObject *obj) | ||||
| /*   g_object_unref (cally_text->priv->textutil); */ | ||||
| /*   cally_text->priv->textutil = NULL; */ | ||||
|  | ||||
|   g_clear_handle_id (&cally_text->priv->insert_idle_handler, g_source_remove); | ||||
|   if (cally_text->priv->insert_idle_handler) | ||||
|     { | ||||
|       g_source_remove (cally_text->priv->insert_idle_handler); | ||||
|       cally_text->priv->insert_idle_handler = 0; | ||||
|     } | ||||
|  | ||||
|   G_OBJECT_CLASS (cally_text_parent_class)->finalize (obj); | ||||
| } | ||||
| @@ -253,9 +261,11 @@ cally_text_finalize   (GObject *obj) | ||||
|  * @actor: a #ClutterActor | ||||
|  * | ||||
|  * Creates a new #CallyText for the given @actor. @actor must be a | ||||
|  * [class@Clutter.Text]. | ||||
|  * #ClutterText. | ||||
|  * | ||||
|  * Return value: the newly created #AtkObject | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| AtkObject* | ||||
| cally_text_new (ClutterActor *actor) | ||||
| @@ -1428,7 +1438,7 @@ static void cally_text_get_character_extents (AtkText *text, | ||||
|   PangoLayout *layout; | ||||
|   PangoRectangle extents; | ||||
|   const gchar *text_value; | ||||
|   graphene_point3d_t verts[4]; | ||||
|   ClutterVertex verts[4]; | ||||
|  | ||||
|   actor = CALLY_GET_CLUTTER_ACTOR (text); | ||||
|   if (actor == NULL) /* State is defunct */ | ||||
| @@ -1507,7 +1517,7 @@ cally_text_get_offset_at_point (AtkText *text, | ||||
| } | ||||
|  | ||||
|  | ||||
| /******** Auxiliary private methods ******/ | ||||
| /******** Auxiliar private methods ******/ | ||||
|  | ||||
| /* ClutterText only maintains the current cursor position and a extra selection | ||||
|    bound, but this could be before or after the cursor. This method returns | ||||
| @@ -1546,7 +1556,7 @@ _cally_text_delete_text_cb (ClutterText *clutter_text, | ||||
|  | ||||
|   g_return_if_fail (CALLY_IS_TEXT (data)); | ||||
|  | ||||
|   /* Ignore zero length deletions */ | ||||
|   /* Ignore zero lengh deletions */ | ||||
|   if (end_pos - start_pos == 0) | ||||
|     return; | ||||
|  | ||||
| @@ -1647,7 +1657,7 @@ cally_text_insert_text (AtkEditableText *text, | ||||
|   clutter_text_insert_text (CLUTTER_TEXT (actor), | ||||
|                             string, *position); | ||||
|  | ||||
|   /* we suppose that the text insertion will be successful, | ||||
|   /* we suppose that the text insertion will be succesful, | ||||
|      clutter-text doesn't warn about it. A option would be search for | ||||
|      the text, but it seems not really required */ | ||||
|   *position += length; | ||||
| @@ -1860,7 +1870,7 @@ static gint | ||||
| _cally_atk_attribute_lookup_func (gconstpointer data, | ||||
|                                   gconstpointer user_data) | ||||
| { | ||||
|     AtkTextAttribute attr = (AtkTextAttribute) GPOINTER_TO_INT (user_data); | ||||
|     AtkTextAttribute attr = (AtkTextAttribute) user_data; | ||||
|     AtkAttribute *at = (AtkAttribute *) data; | ||||
|     if (!g_strcmp0 (at->name, atk_text_attribute_get_name (attr))) | ||||
|         return 0; | ||||
| @@ -2284,7 +2294,7 @@ _cally_misc_get_index_at_point (ClutterText *clutter_text, | ||||
|   gint index, x_window, y_window, x_toplevel, y_toplevel; | ||||
|   gint x_temp, y_temp; | ||||
|   gboolean ret; | ||||
|   graphene_point3d_t verts[4]; | ||||
|   ClutterVertex verts[4]; | ||||
|   PangoLayout *layout; | ||||
|   gint x_layout, y_layout; | ||||
|  | ||||
|   | ||||
| @@ -18,14 +18,15 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CALLY_TEXT_H__ | ||||
| #define __CALLY_TEXT_H__ | ||||
|  | ||||
| #if !defined(__CALLY_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <cally/cally.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter.h" | ||||
| #include "cally/cally-actor.h" | ||||
| #include <clutter/clutter.h> | ||||
| #include <cally/cally-actor.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -40,6 +41,14 @@ typedef struct _CallyText               CallyText; | ||||
| typedef struct _CallyTextClass          CallyTextClass; | ||||
| typedef struct _CallyTextPrivate        CallyTextPrivate; | ||||
|  | ||||
| /** | ||||
|  * CallyText: | ||||
|  * | ||||
|  * The <structname>CallyText</structname> structure contains only private | ||||
|  * data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyText | ||||
| { | ||||
|   /*< private >*/ | ||||
| @@ -53,11 +62,16 @@ struct _CallyText | ||||
|  * | ||||
|  * The <structname>CallyTextClass</structname> structure contains only | ||||
|  * private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyTextClass | ||||
| { | ||||
|   /*< private >*/ | ||||
|   CallyActorClass parent_class; | ||||
|  | ||||
|   /* padding for future expansion */ | ||||
|   gpointer _padding_dummy[8]; | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| @@ -66,3 +80,5 @@ CLUTTER_EXPORT | ||||
| AtkObject* cally_text_new      (ClutterActor *actor); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CALLY_TEXT_H__ */ | ||||
|   | ||||
							
								
								
									
										98
									
								
								clutter/clutter/cally/cally-texture.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								clutter/clutter/cally/cally-texture.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,98 @@ | ||||
| /* CALLY - The Clutter Accessibility Implementation Library | ||||
|  * | ||||
|  * Copyright (C) 2009 Igalia, S.L. | ||||
|  * | ||||
|  * Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com> | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the | ||||
|  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||
|  * Boston, MA 02111-1307, USA. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * SECTION:cally-texture | ||||
|  * @Title: CallyTexture | ||||
|  * @short_description: Implementation of the ATK interfaces for a #ClutterTexture | ||||
|  * @see_also: #ClutterTexture | ||||
|  * | ||||
|  * #CallyTexture implements the required ATK interfaces of #ClutterTexture | ||||
|  * | ||||
|  * In particular it sets a proper role for the texture. | ||||
|  */ | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #define CLUTTER_DISABLE_DEPRECATION_WARNINGS | ||||
|  | ||||
| #include "cally-texture.h" | ||||
| #include "cally-actor-private.h" | ||||
|  | ||||
| #include "deprecated/clutter-texture.h" | ||||
|  | ||||
| /* AtkObject */ | ||||
| static void                  cally_texture_real_initialize (AtkObject *obj, | ||||
|                                                            gpointer   data); | ||||
|  | ||||
| G_DEFINE_TYPE (CallyTexture, cally_texture, CALLY_TYPE_ACTOR) | ||||
|  | ||||
| static void | ||||
| cally_texture_class_init (CallyTextureClass *klass) | ||||
| { | ||||
| /*   GObjectClass   *gobject_class = G_OBJECT_CLASS (klass); */ | ||||
|   AtkObjectClass *class         = ATK_OBJECT_CLASS (klass); | ||||
|  | ||||
|   class->initialize      = cally_texture_real_initialize; | ||||
| } | ||||
|  | ||||
| static void | ||||
| cally_texture_init (CallyTexture *texture) | ||||
| { | ||||
|   /* nothing to do yet */ | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * cally_texture_new: | ||||
|  * @actor: a #ClutterActor | ||||
|  * | ||||
|  * Creates a new #CallyTexture for the given @actor. @actor must be | ||||
|  * a #ClutterTexture. | ||||
|  * | ||||
|  * Return value: the newly created #AtkObject | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| AtkObject* | ||||
| cally_texture_new (ClutterActor *actor) | ||||
| { | ||||
|   GObject   *object     = NULL; | ||||
|   AtkObject *accessible = NULL; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_TEXTURE (actor), NULL); | ||||
|  | ||||
|   object = g_object_new (CALLY_TYPE_TEXTURE, NULL); | ||||
|  | ||||
|   accessible = ATK_OBJECT (object); | ||||
|   atk_object_initialize (accessible, actor); | ||||
|  | ||||
|   return accessible; | ||||
| } | ||||
|  | ||||
| static void | ||||
| cally_texture_real_initialize (AtkObject *obj, | ||||
|                               gpointer   data) | ||||
| { | ||||
|   ATK_OBJECT_CLASS (cally_texture_parent_class)->initialize (obj, data); | ||||
|  | ||||
|   /* default role */ | ||||
|   obj->role = ATK_ROLE_IMAGE; | ||||
| } | ||||
							
								
								
									
										84
									
								
								clutter/clutter/cally/cally-texture.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								clutter/clutter/cally/cally-texture.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,84 @@ | ||||
| /* CALLY - The Clutter Accessibility Implementation Library | ||||
|  * | ||||
|  * Copyright (C) 2009 Igalia, S.L. | ||||
|  * | ||||
|  * Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com> | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #ifndef __CALLY_TEXTURE_H__ | ||||
| #define __CALLY_TEXTURE_H__ | ||||
|  | ||||
| #if !defined(__CALLY_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <cally/cally.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include <clutter/clutter.h> | ||||
| #include <cally/cally-actor.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| #define CALLY_TYPE_TEXTURE            (cally_texture_get_type ()) | ||||
| #define CALLY_TEXTURE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_TEXTURE, CallyTexture)) | ||||
| #define CALLY_TEXTURE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_TEXTURE, CallyTextureClass)) | ||||
| #define CALLY_IS_TEXTURE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_TEXTURE)) | ||||
| #define CALLY_IS_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_TEXTURE)) | ||||
| #define CALLY_TEXTURE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_TEXTURE, CallyTextureClass)) | ||||
|  | ||||
| typedef struct _CallyTexture        CallyTexture; | ||||
| typedef struct _CallyTextureClass   CallyTextureClass; | ||||
| typedef struct _CallyTexturePrivate CallyTexturePrivate; | ||||
|  | ||||
| /** | ||||
|  * CallyTexture: | ||||
|  * | ||||
|  * The <structname>CallyTexture</structname> structure contains only | ||||
|  * private data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyTexture | ||||
| { | ||||
|   /*< private >*/ | ||||
|   CallyActor parent; | ||||
|  | ||||
|   CallyTexturePrivate *priv; | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * CallyTextureClass: | ||||
|  * | ||||
|  * The <structname>CallyTextureClass</structname> structure contains | ||||
|  * only private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyTextureClass | ||||
| { | ||||
|   /*< private >*/ | ||||
|   CallyActorClass parent_class; | ||||
|  | ||||
|   /* padding for future expansion */ | ||||
|   gpointer _padding_dummy[8]; | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| GType      cally_texture_get_type (void) G_GNUC_CONST; | ||||
| CLUTTER_EXPORT | ||||
| AtkObject *cally_texture_new      (ClutterActor *actor); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CALLY_TEXTURE_H__ */ | ||||
| @@ -18,13 +18,16 @@ | ||||
|  * 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/>. | ||||
|  * License along with this library; if not, write to the | ||||
|  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||
|  * Boston, MA 02111-1307, USA. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * CallyUtil: | ||||
|  *  | ||||
|  * #AtkUtil implementation | ||||
|  * SECTION:cally-util | ||||
|  * @Title: CallyUtil | ||||
|  * @short_description: #AtkUtil implementation | ||||
|  * @see_also: #ClutterActor | ||||
|  * | ||||
|  * #CallyUtil implements #AtkUtil abstract methods. Although it | ||||
|  * includes the name "Util" it is in fact one of the most important | ||||
| @@ -35,15 +38,15 @@ | ||||
|  * available any accessible object. | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| #include <clutter/clutter.h> | ||||
|  | ||||
| #include "cally/cally-util.h" | ||||
| #include "cally/cally-root.h" | ||||
| #include "cally/cally-stage.h" | ||||
| #include "clutter/clutter.h" | ||||
| #include "cally-util.h" | ||||
| #include "cally-root.h" | ||||
| #include "cally-stage.h" | ||||
|  | ||||
| #define DEFAULT_PASSWORD_CHAR '*' | ||||
|  | ||||
| @@ -57,6 +60,17 @@ static const gchar *         cally_util_get_toolkit_name		    (void); | ||||
| static const gchar *         cally_util_get_toolkit_version          (void); | ||||
|  | ||||
| /* private */ | ||||
| static void                  cally_util_simulate_snooper_install     (void); | ||||
| static void                  cally_util_simulate_snooper_remove      (void); | ||||
| static gboolean              cally_key_snooper                       (ClutterActor *actor, | ||||
|                                                                       ClutterEvent *event, | ||||
|                                                                       gpointer      user_data); | ||||
| static void                  cally_util_stage_added_cb               (ClutterStageManager *stage_manager, | ||||
|                                                                       ClutterStage *stage, | ||||
|                                                                       gpointer data); | ||||
| static void                  cally_util_stage_removed_cb             (ClutterStageManager *stage_manager, | ||||
|                                                                       ClutterStage *stage, | ||||
|                                                                       gpointer data); | ||||
| static gboolean              notify_hf                               (gpointer key, | ||||
|                                                                       gpointer value, | ||||
|                                                                       gpointer data); | ||||
| @@ -139,8 +153,12 @@ cally_util_add_key_event_listener (AtkKeySnoopFunc  listener, | ||||
|   CallyKeyEventInfo *event_info = NULL; | ||||
|  | ||||
|   if (!key_listener_list) | ||||
|   { | ||||
|     key_listener_list = g_hash_table_new_full (NULL, NULL, NULL, g_free); | ||||
|  | ||||
|     cally_util_simulate_snooper_install (); | ||||
|   } | ||||
|  | ||||
|   event_info = g_new (CallyKeyEventInfo, 1); | ||||
|   event_info->listener = listener; | ||||
|   event_info->func_data = data; | ||||
| @@ -161,11 +179,75 @@ cally_util_remove_key_event_listener (guint remove_listener) | ||||
|     { | ||||
|       g_hash_table_destroy (key_listener_list); | ||||
|       key_listener_list = NULL; | ||||
|       cally_util_simulate_snooper_remove (); | ||||
|     } | ||||
| } | ||||
|  | ||||
| /* ------------------------------ PRIVATE FUNCTIONS ------------------------- */ | ||||
|  | ||||
| /* Trying to emulate gtk_key_snooper install (a kind of wrapper). This | ||||
|    could be implemented without it, but I will maintain it in this | ||||
|    way, so if in the future clutter implements it natively it would be | ||||
|    easier the transition */ | ||||
| static void | ||||
| cally_util_simulate_snooper_install (void) | ||||
| { | ||||
|   ClutterStageManager *stage_manager = NULL; | ||||
|   ClutterStage *stage = NULL; | ||||
|   GSList *stage_list = NULL; | ||||
|   GSList *iter = NULL; | ||||
|  | ||||
|   stage_manager = clutter_stage_manager_get_default (); | ||||
|   stage_list = clutter_stage_manager_list_stages (stage_manager); | ||||
|  | ||||
|   for (iter = stage_list; iter != NULL; iter = g_slist_next (iter)) | ||||
|     { | ||||
|       stage = CLUTTER_STAGE (iter->data); | ||||
|  | ||||
|       g_signal_connect (G_OBJECT (stage), "captured-event", | ||||
|                         G_CALLBACK (cally_key_snooper), NULL); | ||||
|     } | ||||
|  | ||||
|   g_signal_connect (G_OBJECT (stage_manager), "stage-added", | ||||
|                     G_CALLBACK (cally_util_stage_added_cb), cally_key_snooper); | ||||
|   g_signal_connect (G_OBJECT (stage_manager), "stage-removed", | ||||
|                     G_CALLBACK (cally_util_stage_removed_cb), cally_key_snooper); | ||||
|  | ||||
|   g_slist_free (stage_list); | ||||
| } | ||||
|  | ||||
| static void | ||||
| cally_util_simulate_snooper_remove (void) | ||||
| { | ||||
|   ClutterStageManager *stage_manager = NULL; | ||||
|   ClutterStage *stage = NULL; | ||||
|   GSList *stage_list = NULL; | ||||
|   GSList *iter = NULL; | ||||
|   gint num = 0; | ||||
|  | ||||
|   stage_manager = clutter_stage_manager_get_default (); | ||||
|   stage_list = clutter_stage_manager_list_stages (stage_manager); | ||||
|  | ||||
|   for (iter = stage_list; iter != NULL; iter = g_slist_next (iter)) | ||||
|     { | ||||
|       stage = CLUTTER_STAGE (iter->data); | ||||
|  | ||||
|       num += g_signal_handlers_disconnect_by_func (stage, cally_key_snooper, NULL); | ||||
|     } | ||||
|  | ||||
|   g_signal_handlers_disconnect_by_func (G_OBJECT (stage_manager), | ||||
|                                         G_CALLBACK (cally_util_stage_added_cb), | ||||
|                                         cally_key_snooper); | ||||
|  | ||||
|   g_signal_handlers_disconnect_by_func (G_OBJECT (stage_manager), | ||||
|                                         G_CALLBACK (cally_util_stage_removed_cb), | ||||
|                                         cally_key_snooper); | ||||
|  | ||||
| #ifdef CALLY_DEBUG | ||||
|   g_print ("Number of snooper callbacks disconnected: %i\n", num); | ||||
| #endif | ||||
| } | ||||
|  | ||||
| static AtkKeyEventStruct * | ||||
| atk_key_event_from_clutter_event_key (ClutterKeyEvent *clutter_event, | ||||
|                                       gunichar         password_char) | ||||
| @@ -173,7 +255,7 @@ atk_key_event_from_clutter_event_key (ClutterKeyEvent *clutter_event, | ||||
|   AtkKeyEventStruct *atk_event = g_new0 (AtkKeyEventStruct, 1); | ||||
|   gunichar key_unichar; | ||||
|  | ||||
|   switch (clutter_event_type ((ClutterEvent *) clutter_event)) | ||||
|   switch (clutter_event->type) | ||||
|     { | ||||
|     case CLUTTER_KEY_PRESS: | ||||
|       atk_event->type = ATK_KEY_EVENT_PRESS; | ||||
| @@ -189,7 +271,7 @@ atk_key_event_from_clutter_event_key (ClutterKeyEvent *clutter_event, | ||||
|   if (password_char) | ||||
|     atk_event->state = 0; | ||||
|   else | ||||
|     atk_event->state = clutter_event_get_state ((ClutterEvent *) clutter_event); | ||||
|     atk_event->state = clutter_event->modifier_state; | ||||
|  | ||||
|   /* We emit the clutter keyval. This is not exactly the one expected | ||||
|      by AtkKeyEventStruct, as it expects a Gdk-like event, with the | ||||
| @@ -200,7 +282,7 @@ atk_key_event_from_clutter_event_key (ClutterKeyEvent *clutter_event, | ||||
|   if (password_char) | ||||
|     atk_event->keyval = clutter_unicode_to_keysym (password_char); | ||||
|   else | ||||
|     atk_event->keyval = clutter_event_get_key_symbol ((ClutterEvent *) clutter_event); | ||||
|     atk_event->keyval = clutter_event->keyval; | ||||
|  | ||||
|   /* It is expected to store a key defining string here (ie "Space" in | ||||
|      case you press a space). Anyway, there are no function on clutter | ||||
| @@ -222,7 +304,8 @@ atk_key_event_from_clutter_event_key (ClutterKeyEvent *clutter_event, | ||||
|  | ||||
|       new = g_string_new (""); | ||||
|       new = g_string_insert_unichar (new, 0, key_unichar); | ||||
|       atk_event->string = g_string_free (new, FALSE); | ||||
|       atk_event->string = new->str; | ||||
|       g_string_free (new, FALSE); | ||||
|     } | ||||
|   else | ||||
|     atk_event->string = NULL; | ||||
| @@ -236,9 +319,9 @@ atk_key_event_from_clutter_event_key (ClutterKeyEvent *clutter_event, | ||||
|   if (password_char) | ||||
|     atk_event->keycode = 0; | ||||
|   else | ||||
|     atk_event->keycode = clutter_event_get_key_code ((ClutterEvent *) clutter_event); | ||||
|     atk_event->keycode = clutter_event->hardware_keycode; | ||||
|  | ||||
|   atk_event->timestamp = clutter_event_get_time ((ClutterEvent *) clutter_event); | ||||
|   atk_event->timestamp = clutter_event->time; | ||||
|  | ||||
| #ifdef CALLY_DEBUG | ||||
|  | ||||
| @@ -276,13 +359,10 @@ insert_hf (gpointer key, gpointer value, gpointer data) | ||||
|  * char | ||||
|  */ | ||||
| static gunichar | ||||
| check_key_visibility (ClutterStage *stage) | ||||
| check_key_visibility (ClutterEvent *event) | ||||
| { | ||||
|   AtkObject *accessible; | ||||
|   ClutterActor *focus; | ||||
|  | ||||
|   focus = clutter_stage_get_key_focus (stage); | ||||
|   accessible = clutter_actor_get_accessible (focus); | ||||
|   ClutterKeyEvent *key_event = (ClutterKeyEvent *)event; | ||||
|   AtkObject *accessible = clutter_actor_get_accessible (key_event->source); | ||||
|  | ||||
|   g_return_val_if_fail (accessible != NULL, 0); | ||||
|  | ||||
| @@ -298,44 +378,65 @@ check_key_visibility (ClutterStage *stage) | ||||
|      still better fill this with a default unichar that the original | ||||
|      one */ | ||||
|  | ||||
|   if (CLUTTER_IS_TEXT (focus)) | ||||
|     return clutter_text_get_password_char (CLUTTER_TEXT (focus)); | ||||
|   if (CLUTTER_IS_TEXT (key_event->source)) | ||||
|     return clutter_text_get_password_char (CLUTTER_TEXT (key_event->source)); | ||||
|   else | ||||
|     return DEFAULT_PASSWORD_CHAR; | ||||
| } | ||||
|  | ||||
| gboolean | ||||
| cally_snoop_key_event (ClutterStage    *stage, | ||||
|                        ClutterKeyEvent *key) | ||||
| static gboolean | ||||
| cally_key_snooper (ClutterActor *actor, | ||||
|                    ClutterEvent *event, | ||||
|                    gpointer      user_data) | ||||
| { | ||||
|   ClutterEvent *event = (ClutterEvent *) key; | ||||
|   AtkKeyEventStruct *key_event = NULL; | ||||
|   ClutterEventType event_type; | ||||
|   gboolean consumed = FALSE; | ||||
|   gint consumed = 0; | ||||
|   gunichar password_char = 0; | ||||
|  | ||||
|   event_type = clutter_event_type (event); | ||||
|  | ||||
|   /* filter key events */ | ||||
|   if ((event_type != CLUTTER_KEY_PRESS) && (event_type != CLUTTER_KEY_RELEASE)) | ||||
|     return FALSE; | ||||
|   if ((event->type != CLUTTER_KEY_PRESS) && (event->type != CLUTTER_KEY_RELEASE)) | ||||
|     { | ||||
|       return FALSE; | ||||
|     } | ||||
|  | ||||
|   password_char = check_key_visibility (event); | ||||
|  | ||||
|   if (key_listener_list) | ||||
|     { | ||||
|       GHashTable *new_hash = g_hash_table_new (NULL, NULL); | ||||
|  | ||||
|       g_hash_table_foreach (key_listener_list, insert_hf, new_hash); | ||||
|       password_char = check_key_visibility (stage); | ||||
|       key_event = atk_key_event_from_clutter_event_key (key, password_char); | ||||
|       key_event = atk_key_event_from_clutter_event_key ((ClutterKeyEvent *)event, | ||||
|                                                         password_char); | ||||
|       /* func data is inside the hash table */ | ||||
|       consumed = g_hash_table_foreach_steal (new_hash, notify_hf, key_event) > 0; | ||||
|       consumed = g_hash_table_foreach_steal (new_hash, notify_hf, key_event); | ||||
|       g_hash_table_destroy (new_hash); | ||||
|  | ||||
|       g_free (key_event->string); | ||||
|       g_free (key_event); | ||||
|     } | ||||
|  | ||||
|   return consumed; | ||||
|   return (consumed ? 1 : 0); | ||||
| } | ||||
|  | ||||
| static void | ||||
| cally_util_stage_added_cb (ClutterStageManager *stage_manager, | ||||
|                            ClutterStage *stage, | ||||
|                            gpointer data) | ||||
| { | ||||
|   GCallback cally_key_snooper_cb = G_CALLBACK (data); | ||||
|  | ||||
|   g_signal_connect (G_OBJECT (stage), "captured-event", cally_key_snooper_cb, NULL); | ||||
| } | ||||
|  | ||||
| static void | ||||
| cally_util_stage_removed_cb (ClutterStageManager *stage_manager, | ||||
|                              ClutterStage *stage, | ||||
|                              gpointer data) | ||||
| { | ||||
|   GCallback cally_key_snooper_cb = G_CALLBACK (data); | ||||
|  | ||||
|   g_signal_handlers_disconnect_by_func (stage, cally_key_snooper_cb, NULL); | ||||
| } | ||||
|  | ||||
| void | ||||
|   | ||||
| @@ -18,13 +18,14 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CALLY_UTIL_H__ | ||||
| #define __CALLY_UTIL_H__ | ||||
|  | ||||
| #if !defined(__CALLY_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <cally/cally.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter.h" | ||||
| #include <clutter/clutter.h> | ||||
| #include <atk/atk.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
| @@ -40,6 +41,14 @@ typedef struct _CallyUtil        CallyUtil; | ||||
| typedef struct _CallyUtilClass   CallyUtilClass; | ||||
| typedef struct _CallyUtilPrivate CallyUtilPrivate; | ||||
|  | ||||
| /** | ||||
|  * CallyUtil: | ||||
|  * | ||||
|  * The <structname>CallyUtil</structname> structure contains only | ||||
|  * private data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyUtil | ||||
| { | ||||
|   /*< private >*/ | ||||
| @@ -53,11 +62,16 @@ struct _CallyUtil | ||||
|  * | ||||
|  * The <structname>CallyUtilClass</structname> structure contains only | ||||
|  * private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _CallyUtilClass | ||||
| { | ||||
|   /*< private >*/ | ||||
|   AtkUtilClass parent_class; | ||||
|  | ||||
|   /* padding for future expansion */ | ||||
|   gpointer _padding_dummy[8]; | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| @@ -65,7 +79,6 @@ GType cally_util_get_type (void) G_GNUC_CONST; | ||||
|  | ||||
| void _cally_util_override_atk_util (void); | ||||
|  | ||||
| gboolean cally_snoop_key_event (ClutterStage    *stage, | ||||
|                                 ClutterKeyEvent *key); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CALLY_UTIL_H__ */ | ||||
|   | ||||
| @@ -15,7 +15,9 @@ | ||||
|  * 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/>. | ||||
|  * License along with this library; if not, write to the | ||||
|  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||
|  * Boston, MA 02111-1307, USA. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
| @@ -27,29 +29,35 @@ | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #define CLUTTER_DISABLE_DEPRECATION_WARNINGS | ||||
|  | ||||
| #include "cally/cally.h" | ||||
| #include "cally.h" | ||||
|  | ||||
| #include "cally/cally-actor.h" | ||||
| #include "cally/cally-stage.h" | ||||
| #include "cally/cally-text.h" | ||||
| #include "cally/cally-clone.h" | ||||
| #include "cally-actor.h" | ||||
| #include "cally-group.h" | ||||
| #include "cally-stage.h" | ||||
| #include "cally-text.h" | ||||
| #include "cally-texture.h" | ||||
| #include "cally-rectangle.h" | ||||
| #include "cally-clone.h" | ||||
|  | ||||
| #include "cally/cally-factory.h" | ||||
| #include "cally/cally-util.h" | ||||
| #include "cally-factory.h" | ||||
| #include "cally-util.h" | ||||
|  | ||||
| #include "clutter/clutter.h" | ||||
| #include "clutter.h" | ||||
|  | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| /* factories initialization*/ | ||||
| CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_ACTOR, cally_actor, cally_actor_new) | ||||
| CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_GROUP, cally_group, cally_group_new) | ||||
| CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_STAGE, cally_stage, cally_stage_new) | ||||
| CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_TEXT, cally_text, cally_text_new) | ||||
| CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_TEXTURE, cally_texture, cally_texture_new) | ||||
| CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_RECTANGLE, cally_rectangle, cally_rectangle_new) | ||||
| CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_CLONE, cally_clone, cally_clone_new) | ||||
|  | ||||
| /** | ||||
| @@ -59,14 +67,19 @@ CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_CLONE, cally_clone, cally_clone_new) | ||||
|  * | ||||
|  * Return value: %TRUE if accessibility support has been correctly | ||||
|  * initialized. | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| gboolean | ||||
| cally_accessibility_init (void) | ||||
| { | ||||
|   /* setting the factories */ | ||||
|   CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_ACTOR, cally_actor); | ||||
|   CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_GROUP, cally_group); | ||||
|   CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_STAGE, cally_stage); | ||||
|   CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_TEXT, cally_text); | ||||
|   CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_TEXTURE, cally_texture); | ||||
|   CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_RECTANGLE, cally_rectangle); | ||||
|   CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_CLONE, cally_clone); | ||||
|  | ||||
|   /* Initialize the CallyUtility class */ | ||||
| @@ -84,6 +97,8 @@ cally_accessibility_init (void) | ||||
|  * | ||||
|  * Return value: %TRUE if accessibility support has been correctly | ||||
|  * initialized. | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| gboolean cally_get_cally_initialized (void) | ||||
| { | ||||
|   | ||||
| @@ -18,17 +18,23 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CALLY_H__ | ||||
| #define __CALLY_H__ | ||||
|  | ||||
| #define __CALLY_H_INSIDE__ | ||||
|  | ||||
| #include "cally/cally-actor.h" | ||||
| #include "cally/cally-clone.h" | ||||
| #include "cally/cally-factory.h" | ||||
| #include "cally/cally-main.h" | ||||
| #include "cally/cally-root.h" | ||||
| #include "cally/cally-stage.h" | ||||
| #include "cally/cally-text.h" | ||||
| #include "cally/cally-util.h" | ||||
| #include "cally-actor.h" | ||||
| #include "cally-clone.h" | ||||
| #include "cally-factory.h" | ||||
| #include "cally-group.h" | ||||
| #include "cally-main.h" | ||||
| #include "cally-rectangle.h" | ||||
| #include "cally-root.h" | ||||
| #include "cally-stage.h" | ||||
| #include "cally-text.h" | ||||
| #include "cally-texture.h" | ||||
| #include "cally-util.h" | ||||
|  | ||||
| #undef __CALLY_H_INSIDE__ | ||||
|  | ||||
| #endif /* __CALLY_H__ */ | ||||
|   | ||||
| @@ -1,45 +0,0 @@ | ||||
| /* | ||||
|  * Clutter. | ||||
|  * | ||||
|  * An OpenGL based 'interactive canvas' library. | ||||
|  * | ||||
|  * Copyright (C) 2021 Red Hat Inc. | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * | ||||
|  * Author: | ||||
|  *   Carlos Garnacho <carlosg@gnome.org> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-action.h" | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| void clutter_action_set_phase (ClutterAction     *action, | ||||
|                                ClutterEventPhase  phase); | ||||
|  | ||||
| gboolean clutter_action_handle_event (ClutterAction      *action, | ||||
|                                       const ClutterEvent *event); | ||||
|  | ||||
| void clutter_action_sequence_cancelled (ClutterAction        *action, | ||||
|                                         ClutterInputDevice   *device, | ||||
|                                         ClutterEventSequence *sequence); | ||||
|  | ||||
| G_END_DECLS | ||||
| @@ -23,92 +23,39 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterAction: | ||||
|  *  | ||||
|  * Abstract class for event-related logic | ||||
|  * SECTION:clutter-action | ||||
|  * @Title: ClutterAction | ||||
|  * @Short_Description: Abstract class for event-related logic | ||||
|  * @See_Also: #ClutterConstraint | ||||
|  * | ||||
|  * #ClutterAction is an abstract base class for event-related actions that | ||||
|  * modify the user interaction of a [class@Actor], just like | ||||
|  * [class@Constraint] is an abstract class for modifiers of an actor's | ||||
|  * modify the user interaction of a #ClutterActor, just like | ||||
|  * #ClutterConstraint is an abstract class for modifiers of an actor's | ||||
|  * position or size. | ||||
|  * | ||||
|  * Implementations of #ClutterAction are associated to an actor and can | ||||
|  * provide behavioral changes when dealing with user input - for instance | ||||
|  * drag and drop capabilities, or scrolling, or panning - by using the | ||||
|  * various event-related signals provided by [class@Actor] itself. | ||||
|  * various event-related signals provided by #ClutterActor itself. | ||||
|  * | ||||
|  * #ClutterAction is available since Clutter 1.4 | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-action.h" | ||||
| #include "clutter/clutter-action-private.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-action.h" | ||||
|  | ||||
| typedef struct _ClutterActionPrivate ClutterActionPrivate; | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| struct _ClutterActionPrivate | ||||
| { | ||||
|   ClutterEventPhase phase; | ||||
| }; | ||||
|  | ||||
| G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ClutterAction, clutter_action, | ||||
|                                      CLUTTER_TYPE_ACTOR_META) | ||||
|  | ||||
| static gboolean | ||||
| clutter_action_handle_event_default (ClutterAction      *action, | ||||
|                                      const ClutterEvent *event) | ||||
| { | ||||
|   return FALSE; | ||||
| } | ||||
| G_DEFINE_ABSTRACT_TYPE (ClutterAction, clutter_action, CLUTTER_TYPE_ACTOR_META); | ||||
|  | ||||
| static void | ||||
| clutter_action_class_init (ClutterActionClass *klass) | ||||
| { | ||||
|   klass->handle_event = clutter_action_handle_event_default; | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_action_init (ClutterAction *self) | ||||
| { | ||||
| } | ||||
|  | ||||
| void | ||||
| clutter_action_set_phase (ClutterAction     *action, | ||||
|                           ClutterEventPhase  phase) | ||||
| { | ||||
|   ClutterActionPrivate *priv; | ||||
|  | ||||
|   priv = clutter_action_get_instance_private (action); | ||||
|   priv->phase = phase; | ||||
| } | ||||
|  | ||||
| ClutterEventPhase | ||||
| clutter_action_get_phase (ClutterAction *action) | ||||
| { | ||||
|   ClutterActionPrivate *priv; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_ACTION (action), CLUTTER_PHASE_CAPTURE); | ||||
|  | ||||
|   priv = clutter_action_get_instance_private (action); | ||||
|  | ||||
|   return priv->phase; | ||||
| } | ||||
|  | ||||
| gboolean | ||||
| clutter_action_handle_event (ClutterAction      *action, | ||||
|                              const ClutterEvent *event) | ||||
| { | ||||
|   return CLUTTER_ACTION_GET_CLASS (action)->handle_event (action, event); | ||||
| } | ||||
|  | ||||
| void | ||||
| clutter_action_sequence_cancelled (ClutterAction        *action, | ||||
|                                    ClutterInputDevice   *device, | ||||
|                                    ClutterEventSequence *sequence) | ||||
| { | ||||
|   ClutterActionClass *action_class = CLUTTER_ACTION_GET_CLASS (action); | ||||
|  | ||||
|   if (action_class->sequence_cancelled) | ||||
|     action_class->sequence_cancelled (action, device, sequence); | ||||
| } | ||||
|   | ||||
| @@ -22,40 +22,65 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_ACTION_H__ | ||||
| #define __CLUTTER_ACTION_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-actor-meta.h" | ||||
| #include <clutter/clutter-actor-meta.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| #define CLUTTER_TYPE_ACTION (clutter_action_get_type ()) | ||||
| #define CLUTTER_TYPE_ACTION             (clutter_action_get_type ()) | ||||
| #define CLUTTER_ACTION(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ACTION, ClutterAction)) | ||||
| #define CLUTTER_IS_ACTION(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ACTION)) | ||||
| #define CLUTTER_ACTION_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_ACTION, ClutterActionClass)) | ||||
| #define CLUTTER_IS_ACTION_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_ACTION)) | ||||
| #define CLUTTER_ACTION_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_ACTION, ClutterActionClass)) | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| G_DECLARE_DERIVABLE_TYPE (ClutterAction, clutter_action, | ||||
|                           CLUTTER, ACTION, ClutterActorMeta); | ||||
| typedef struct _ClutterActionClass      ClutterActionClass; | ||||
|  | ||||
| /** | ||||
|  * ClutterAction: | ||||
|  * | ||||
|  * The #ClutterAction structure contains only private data and | ||||
|  * should be accessed using the provided API. | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _ClutterAction | ||||
| { | ||||
|   /*< private >*/ | ||||
|   ClutterActorMeta parent_instance; | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * ClutterActionClass: | ||||
|  * | ||||
|  * The ClutterActionClass structure contains only private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _ClutterActionClass | ||||
| { | ||||
|   /*< private >*/ | ||||
|   ClutterActorMetaClass parent_class; | ||||
|  | ||||
|   gboolean (* handle_event) (ClutterAction      *action, | ||||
|                              const ClutterEvent *event); | ||||
|  | ||||
|   void (* sequence_cancelled) (ClutterAction        *action, | ||||
|                                ClutterInputDevice   *device, | ||||
|                                ClutterEventSequence *sequence); | ||||
|   void (* _clutter_action1) (void); | ||||
|   void (* _clutter_action2) (void); | ||||
|   void (* _clutter_action3) (void); | ||||
|   void (* _clutter_action4) (void); | ||||
|   void (* _clutter_action5) (void); | ||||
|   void (* _clutter_action6) (void); | ||||
|   void (* _clutter_action7) (void); | ||||
|   void (* _clutter_action8) (void); | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| GType clutter_action_get_type (void) G_GNUC_CONST; | ||||
|  | ||||
| /* ClutterActor API */ | ||||
| CLUTTER_EXPORT | ||||
| void           clutter_actor_add_action            (ClutterActor  *self, | ||||
| @@ -65,11 +90,6 @@ void           clutter_actor_add_action_with_name  (ClutterActor  *self, | ||||
|                                                     const gchar   *name, | ||||
|                                                     ClutterAction *action); | ||||
| CLUTTER_EXPORT | ||||
| void           clutter_actor_add_action_full       (ClutterActor      *self, | ||||
|                                                     const char        *name, | ||||
|                                                     ClutterEventPhase  phase, | ||||
|                                                     ClutterAction     *action); | ||||
| CLUTTER_EXPORT | ||||
| void           clutter_actor_remove_action         (ClutterActor  *self, | ||||
|                                                     ClutterAction *action); | ||||
| CLUTTER_EXPORT | ||||
| @@ -86,6 +106,6 @@ void           clutter_actor_clear_actions         (ClutterActor  *self); | ||||
| CLUTTER_EXPORT | ||||
| gboolean       clutter_actor_has_actions           (ClutterActor  *self); | ||||
|  | ||||
| ClutterEventPhase clutter_action_get_phase (ClutterAction *action); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_ACTION_H__ */ | ||||
|   | ||||
| @@ -1,9 +1,12 @@ | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_ACTOR_BOX_PRIVATE_H__ | ||||
| #define __CLUTTER_ACTOR_BOX_PRIVATE_H__ | ||||
|  | ||||
| #include "clutter/clutter-types.h" | ||||
| #include <clutter/clutter-types.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| void _clutter_actor_box_enlarge_for_effects (ClutterActorBox *box); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_ACTOR_BOX_PRIVATE_H__ */ | ||||
|   | ||||
| @@ -1,11 +1,11 @@ | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include <math.h> | ||||
|  | ||||
| #include "clutter/clutter-types.h" | ||||
| #include "clutter/clutter-interval.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter/clutter-actor-box-private.h" | ||||
| #include "clutter-types.h" | ||||
| #include "clutter-interval.h" | ||||
| #include "clutter-private.h" | ||||
| #include "clutter-actor-box-private.h" | ||||
|  | ||||
| /** | ||||
|  * clutter_actor_box_new: | ||||
| @@ -14,19 +14,21 @@ | ||||
|  * @x_2: X coordinate of the bottom right point | ||||
|  * @y_2: Y coordinate of the bottom right point | ||||
|  * | ||||
|  * Allocates a new [struct@ActorBox] using the passed coordinates | ||||
|  * Allocates a new #ClutterActorBox using the passed coordinates | ||||
|  * for the top left and bottom right points. | ||||
|  * | ||||
|  * This function is the logical equivalent of: | ||||
|  * | ||||
|  * ```c | ||||
|  * |[ | ||||
|  *   clutter_actor_box_init (clutter_actor_box_alloc (), | ||||
|  *                           x_1, y_1, | ||||
|  *                           x_2, y_2); | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * Return value: (transfer full): the newly allocated #ClutterActorBox. | ||||
|  *   Use [method@ActorBox.free] to free the resources | ||||
|  *   Use clutter_actor_box_free() to free the resources | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| ClutterActorBox * | ||||
| clutter_actor_box_new (gfloat x_1, | ||||
| @@ -42,15 +44,17 @@ clutter_actor_box_new (gfloat x_1, | ||||
| /** | ||||
|  * clutter_actor_box_alloc: | ||||
|  * | ||||
|  * Allocates a new [struct@ActorBox]. | ||||
|  * Allocates a new #ClutterActorBox. | ||||
|  * | ||||
|  * Return value: (transfer full): the newly allocated #ClutterActorBox. | ||||
|  *   Use [method@ActorBox.free] to free its resources | ||||
|  *   Use clutter_actor_box_free() to free its resources | ||||
|  * | ||||
|  * Since: 1.12 | ||||
|  */ | ||||
| ClutterActorBox * | ||||
| clutter_actor_box_alloc (void) | ||||
| { | ||||
|   return g_new0 (ClutterActorBox, 1); | ||||
|   return g_slice_new0 (ClutterActorBox); | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -64,6 +68,8 @@ clutter_actor_box_alloc (void) | ||||
|  * Initializes @box with the given coordinates. | ||||
|  * | ||||
|  * Return value: (transfer none): the initialized #ClutterActorBox | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| ClutterActorBox * | ||||
| clutter_actor_box_init (ClutterActorBox *box, | ||||
| @@ -91,6 +97,8 @@ clutter_actor_box_init (ClutterActorBox *box, | ||||
|  * @height: height of the box | ||||
|  * | ||||
|  * Initializes @box with the given origin and size. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_box_init_rect (ClutterActorBox *box, | ||||
| @@ -114,13 +122,15 @@ clutter_actor_box_init_rect (ClutterActorBox *box, | ||||
|  * Copies @box | ||||
|  * | ||||
|  * Return value: a newly allocated copy of #ClutterActorBox. Use | ||||
|  *   [method@ActorBox.free] to free the allocated resources | ||||
|  *   clutter_actor_box_free() to free the allocated resources | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| ClutterActorBox * | ||||
| clutter_actor_box_copy (const ClutterActorBox *box) | ||||
| { | ||||
|   if (G_LIKELY (box != NULL)) | ||||
|     return g_memdup2 (box, sizeof (ClutterActorBox)); | ||||
|     return g_slice_dup (ClutterActorBox, box); | ||||
|  | ||||
|   return NULL; | ||||
| } | ||||
| @@ -129,14 +139,16 @@ clutter_actor_box_copy (const ClutterActorBox *box) | ||||
|  * clutter_actor_box_free: | ||||
|  * @box: a #ClutterActorBox | ||||
|  * | ||||
|  * Frees a #ClutterActorBox allocated using [ctor@ActorBox.new] | ||||
|  * or [method@ActorBox.copy]. | ||||
|  * Frees a #ClutterActorBox allocated using clutter_actor_box_new() | ||||
|  * or clutter_actor_box_copy() | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_box_free (ClutterActorBox *box) | ||||
| { | ||||
|   if (G_LIKELY (box != NULL)) | ||||
|     g_free (box); | ||||
|     g_slice_free (ClutterActorBox, box); | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -147,6 +159,8 @@ clutter_actor_box_free (ClutterActorBox *box) | ||||
|  * Checks @box_a and @box_b for equality | ||||
|  * | ||||
|  * Return value: %TRUE if the passed #ClutterActorBox are equal | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| gboolean | ||||
| clutter_actor_box_equal (const ClutterActorBox *box_a, | ||||
| @@ -168,6 +182,8 @@ clutter_actor_box_equal (const ClutterActorBox *box_a, | ||||
|  * Retrieves the X coordinate of the origin of @box | ||||
|  * | ||||
|  * Return value: the X coordinate of the origin | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| gfloat | ||||
| clutter_actor_box_get_x (const ClutterActorBox *box) | ||||
| @@ -184,6 +200,8 @@ clutter_actor_box_get_x (const ClutterActorBox *box) | ||||
|  * Retrieves the Y coordinate of the origin of @box | ||||
|  * | ||||
|  * Return value: the Y coordinate of the origin | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| gfloat | ||||
| clutter_actor_box_get_y (const ClutterActorBox *box) | ||||
| @@ -200,6 +218,8 @@ clutter_actor_box_get_y (const ClutterActorBox *box) | ||||
|  * Retrieves the width of the @box | ||||
|  * | ||||
|  * Return value: the width of the box | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| gfloat | ||||
| clutter_actor_box_get_width (const ClutterActorBox *box) | ||||
| @@ -216,6 +236,8 @@ clutter_actor_box_get_width (const ClutterActorBox *box) | ||||
|  * Retrieves the height of the @box | ||||
|  * | ||||
|  * Return value: the height of the box | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| gfloat | ||||
| clutter_actor_box_get_height (const ClutterActorBox *box) | ||||
| @@ -232,6 +254,8 @@ clutter_actor_box_get_height (const ClutterActorBox *box) | ||||
|  * @y: (out) (allow-none): return location for the Y coordinate, or %NULL | ||||
|  * | ||||
|  * Retrieves the origin of @box | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_box_get_origin (const ClutterActorBox *box, | ||||
| @@ -254,6 +278,8 @@ clutter_actor_box_get_origin (const ClutterActorBox *box, | ||||
|  * @height: (out) (allow-none): return location for the height, or %NULL | ||||
|  * | ||||
|  * Retrieves the size of @box | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_box_get_size (const ClutterActorBox *box, | ||||
| @@ -276,6 +302,8 @@ clutter_actor_box_get_size (const ClutterActorBox *box, | ||||
|  * Retrieves the area of @box | ||||
|  * | ||||
|  * Return value: the area of a #ClutterActorBox, in pixels | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| gfloat | ||||
| clutter_actor_box_get_area (const ClutterActorBox *box) | ||||
| @@ -292,9 +320,11 @@ clutter_actor_box_get_area (const ClutterActorBox *box) | ||||
|  * @y: Y coordinate of the point | ||||
|  * | ||||
|  * Checks whether a point with @x, @y coordinates is contained | ||||
|  * within @box | ||||
|  * withing @box | ||||
|  * | ||||
|  * Return value: %TRUE if the point is contained by the #ClutterActorBox | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| gboolean | ||||
| clutter_actor_box_contains (const ClutterActorBox *box, | ||||
| @@ -310,14 +340,16 @@ clutter_actor_box_contains (const ClutterActorBox *box, | ||||
| /** | ||||
|  * clutter_actor_box_from_vertices: | ||||
|  * @box: a #ClutterActorBox | ||||
|  * @verts: (array fixed-size=4): array of four #graphene_point3d_t | ||||
|  * @verts: (array fixed-size=4): array of four #ClutterVertex | ||||
|  * | ||||
|  * Calculates the bounding box represented by the four vertices; for details | ||||
|  * of the vertex array see [method@Actor.get_abs_allocation_vertices]. | ||||
|  * of the vertex array see clutter_actor_get_abs_allocation_vertices(). | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_box_from_vertices (ClutterActorBox          *box, | ||||
|                                  const graphene_point3d_t  verts[]) | ||||
| clutter_actor_box_from_vertices (ClutterActorBox     *box, | ||||
|                                  const ClutterVertex  verts[]) | ||||
| { | ||||
|   gfloat x_1, x_2, y_1, y_2; | ||||
|  | ||||
| @@ -380,8 +412,10 @@ clutter_actor_box_from_vertices (ClutterActorBox          *box, | ||||
|  * @progress: the interpolation progress | ||||
|  * @result: (out): return location for the interpolation | ||||
|  * | ||||
|  * Interpolates between @initial and @final `ClutterActorBox`es | ||||
|  * Interpolates between @initial and @final #ClutterActorBox<!-- -->es | ||||
|  * using @progress | ||||
|  * | ||||
|  * Since: 1.2 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_box_interpolate (const ClutterActorBox *initial, | ||||
| @@ -404,6 +438,8 @@ clutter_actor_box_interpolate (const ClutterActorBox *initial, | ||||
|  * @box: (inout): the #ClutterActorBox to clamp | ||||
|  * | ||||
|  * Clamps the components of @box to the nearest integer | ||||
|  * | ||||
|  * Since: 1.2 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_box_clamp_to_pixel (ClutterActorBox *box) | ||||
| @@ -424,6 +460,8 @@ clutter_actor_box_clamp_to_pixel (ClutterActorBox *box) | ||||
|  *   of @a and @b | ||||
|  * | ||||
|  * Unions the two boxes @a and @b and stores the result in @result. | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_box_union (const ClutterActorBox *a, | ||||
| @@ -466,6 +504,8 @@ clutter_actor_box_progress (const GValue *a, | ||||
|  * @y: the Y coordinate of the new origin | ||||
|  * | ||||
|  * Changes the origin of @box, maintaining the size of the #ClutterActorBox. | ||||
|  * | ||||
|  * Since: 1.6 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_box_set_origin (ClutterActorBox *box, | ||||
| @@ -489,6 +529,8 @@ clutter_actor_box_set_origin (ClutterActorBox *box, | ||||
|  * @height: the new height | ||||
|  * | ||||
|  * Sets the size of @box, maintaining the origin of the #ClutterActorBox. | ||||
|  * | ||||
|  * Since: 1.6 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_box_set_size (ClutterActorBox *box, | ||||
| @@ -506,16 +548,13 @@ _clutter_actor_box_enlarge_for_effects (ClutterActorBox *box) | ||||
| { | ||||
|   float width, height; | ||||
|  | ||||
|   if (clutter_actor_box_get_area (box) == 0.0) | ||||
|     return; | ||||
|  | ||||
|   /* The aim here is that for a given rectangle defined with floating point | ||||
|    * coordinates we want to determine a stable quantized size in pixels | ||||
|    * that doesn't vary due to the original box's sub-pixel position. | ||||
|    * | ||||
|    * The reason this is important is because effects will use this | ||||
|    * API to determine the size of offscreen framebuffers and so for | ||||
|    * a fixed-size object that may be animated across the screen we | ||||
|    * a fixed-size object that may be animated accross the screen we | ||||
|    * want to make sure that the stage paint-box has an equally stable | ||||
|    * size so that effects aren't made to continuously re-allocate | ||||
|    * a corresponding fbo. | ||||
| @@ -544,7 +583,7 @@ _clutter_actor_box_enlarge_for_effects (ClutterActorBox *box) | ||||
|  | ||||
|   /* Now we redefine the top-left relative to the bottom right based on the | ||||
|    * rounded width/height determined above + a constant so that the overall | ||||
|    * size of the box will be stable and not dependent on the box's | ||||
|    * size of the box will be stable and not dependant on the box's | ||||
|    * position. | ||||
|    * | ||||
|    * Adding 3px to the width/height will ensure we cover the maximum of | ||||
| @@ -561,6 +600,8 @@ _clutter_actor_box_enlarge_for_effects (ClutterActorBox *box) | ||||
|  * @scale: scale factor for resizing this box | ||||
|  * | ||||
|  * Rescale the @box by provided @scale factor. | ||||
|  * | ||||
|  * Since: 1.6 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_box_scale (ClutterActorBox *box, | ||||
| @@ -574,32 +615,6 @@ clutter_actor_box_scale (ClutterActorBox *box, | ||||
|   box->y2 *= scale; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_actor_box_is_initialized: | ||||
|  * @box: a #ClutterActorBox | ||||
|  * | ||||
|  * Checks if @box has been initialized, a #ClutterActorBox is uninitialized | ||||
|  * if it has a size of -1 at an origin of 0, 0. | ||||
|  * | ||||
|  * Returns: %TRUE if the box is uninitialized, %FALSE if it isn't | ||||
|  */ | ||||
| gboolean | ||||
| clutter_actor_box_is_initialized (ClutterActorBox *box) | ||||
| { | ||||
|   gboolean x1_uninitialized, x2_uninitialized; | ||||
|   gboolean y1_uninitialized, y2_uninitialized; | ||||
|  | ||||
|   g_return_val_if_fail (box != NULL, TRUE); | ||||
|  | ||||
|   x1_uninitialized = isinf (box->x1); | ||||
|   x2_uninitialized = isinf (box->x2) && signbit (box->x2); | ||||
|   y1_uninitialized = isinf (box->y1); | ||||
|   y2_uninitialized = isinf (box->y2) && signbit (box->y2); | ||||
|  | ||||
|   return !x1_uninitialized || !x2_uninitialized || | ||||
|          !y1_uninitialized || !y2_uninitialized; | ||||
| } | ||||
|  | ||||
| G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterActorBox, clutter_actor_box, | ||||
|                                clutter_actor_box_copy, | ||||
|                                clutter_actor_box_free, | ||||
|   | ||||
| @@ -22,9 +22,10 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_ACTOR_META_PRIVATE_H__ | ||||
| #define __CLUTTER_ACTOR_META_PRIVATE_H__ | ||||
|  | ||||
| #include "clutter/clutter-actor-meta.h" | ||||
| #include <clutter/clutter-actor-meta.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -92,3 +93,5 @@ int                     _clutter_actor_meta_get_priority        (ClutterActorMet | ||||
| gboolean                _clutter_actor_meta_is_internal         (ClutterActorMeta *meta); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_ACTOR_META_PRIVATE_H__ */ | ||||
|   | ||||
| @@ -23,32 +23,35 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterActorMeta: | ||||
|  *  | ||||
|  * Base class of actor modifiers | ||||
|  * SECTION:clutter-actor-meta | ||||
|  * @Title: ClutterActorMeta | ||||
|  * @Short_Description: Base class of actor modifiers | ||||
|  * @See_Also: #ClutterAction, #ClutterConstraint | ||||
|  * | ||||
|  * #ClutterActorMeta is an abstract class providing a common API for | ||||
|  * modifiers of [class@Actor] behaviour, appearance or layout. | ||||
|  * modifiers of #ClutterActor behaviour, appearance or layout. | ||||
|  * | ||||
|  * A #ClutterActorMeta can only be owned by a single [class@Actor] at | ||||
|  * A #ClutterActorMeta can only be owned by a single #ClutterActor at | ||||
|  * any time. | ||||
|  * | ||||
|  * Every sub-class of #ClutterActorMeta should check if the | ||||
|  * [property@ActorMeta:enabled] property is set to %TRUE before applying | ||||
|  * #ClutterActorMeta:enabled property is set to %TRUE before applying | ||||
|  * any kind of modification. | ||||
|  * | ||||
|  * #ClutterActorMeta is available since Clutter 1.4 | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-actor-meta-private.h" | ||||
| #include "clutter-actor-meta-private.h" | ||||
|  | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| struct _ClutterActorMetaPrivate | ||||
| { | ||||
|   ClutterActor *actor; | ||||
|   gulong destroy_id; | ||||
|   guint destroy_id; | ||||
|  | ||||
|   gchar *name; | ||||
|  | ||||
| @@ -78,51 +81,28 @@ static void | ||||
| on_actor_destroy (ClutterActor     *actor, | ||||
|                   ClutterActorMeta *meta) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv = | ||||
|     clutter_actor_meta_get_instance_private (meta); | ||||
|  | ||||
|   priv->actor = NULL; | ||||
|   meta->priv->actor = NULL; | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_actor_meta_real_set_actor (ClutterActorMeta *meta, | ||||
|                                    ClutterActor     *actor) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv = | ||||
|     clutter_actor_meta_get_instance_private (meta); | ||||
|  | ||||
|   g_warn_if_fail (!priv->actor || | ||||
|                   !CLUTTER_ACTOR_IN_PAINT (priv->actor)); | ||||
|   g_warn_if_fail (!actor || !CLUTTER_ACTOR_IN_PAINT (actor)); | ||||
|  | ||||
|   if (priv->actor == actor) | ||||
|   if (meta->priv->actor == actor) | ||||
|     return; | ||||
|  | ||||
|   g_clear_signal_handler (&priv->destroy_id, priv->actor); | ||||
|   if (meta->priv->destroy_id != 0) | ||||
|     { | ||||
|       g_signal_handler_disconnect (meta->priv->actor, meta->priv->destroy_id); | ||||
|       meta->priv->destroy_id = 0; | ||||
|     } | ||||
|  | ||||
|   priv->actor = actor; | ||||
|   meta->priv->actor = actor; | ||||
|  | ||||
|   if (priv->actor != NULL) | ||||
|     priv->destroy_id = g_signal_connect (priv->actor, "destroy", | ||||
|                                          G_CALLBACK (on_actor_destroy), | ||||
|                                          meta); | ||||
|  | ||||
|   g_object_notify_by_pspec (G_OBJECT (meta), obj_props[PROP_ACTOR]); | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_actor_meta_real_set_enabled (ClutterActorMeta *meta, | ||||
|                                      gboolean          is_enabled) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv = | ||||
|     clutter_actor_meta_get_instance_private (meta); | ||||
|  | ||||
|   g_warn_if_fail (!priv->actor || | ||||
|                   !CLUTTER_ACTOR_IN_PAINT (priv->actor)); | ||||
|  | ||||
|   priv->is_enabled = is_enabled; | ||||
|  | ||||
|   g_object_notify_by_pspec (G_OBJECT (meta), obj_props[PROP_ENABLED]); | ||||
|   if (meta->priv->actor != NULL) | ||||
|     meta->priv->destroy_id = g_signal_connect (meta->priv->actor, "destroy", | ||||
|                                                G_CALLBACK (on_actor_destroy), | ||||
|                                                meta); | ||||
| } | ||||
|  | ||||
| static void | ||||
| @@ -155,21 +135,20 @@ clutter_actor_meta_get_property (GObject    *gobject, | ||||
|                                  GValue     *value, | ||||
|                                  GParamSpec *pspec) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv = | ||||
|     clutter_actor_meta_get_instance_private (CLUTTER_ACTOR_META (gobject)); | ||||
|   ClutterActorMeta *meta = CLUTTER_ACTOR_META (gobject); | ||||
|  | ||||
|   switch (prop_id) | ||||
|     { | ||||
|     case PROP_ACTOR: | ||||
|       g_value_set_object (value, priv->actor); | ||||
|       g_value_set_object (value, meta->priv->actor); | ||||
|       break; | ||||
|  | ||||
|     case PROP_NAME: | ||||
|       g_value_set_string (value, priv->name); | ||||
|       g_value_set_string (value, meta->priv->name); | ||||
|       break; | ||||
|  | ||||
|     case PROP_ENABLED: | ||||
|       g_value_set_boolean (value, priv->is_enabled); | ||||
|       g_value_set_boolean (value, meta->priv->is_enabled); | ||||
|       break; | ||||
|  | ||||
|     default: | ||||
| @@ -181,11 +160,10 @@ clutter_actor_meta_get_property (GObject    *gobject, | ||||
| static void | ||||
| clutter_actor_meta_finalize (GObject *gobject) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv = | ||||
|     clutter_actor_meta_get_instance_private (CLUTTER_ACTOR_META (gobject)); | ||||
|   ClutterActorMetaPrivate *priv = CLUTTER_ACTOR_META (gobject)->priv; | ||||
|  | ||||
|   if (priv->actor != NULL) | ||||
|     g_clear_signal_handler (&priv->destroy_id, priv->actor); | ||||
|   if (priv->destroy_id != 0 && priv->actor != NULL) | ||||
|     g_signal_handler_disconnect (priv->actor, priv->destroy_id); | ||||
|  | ||||
|   g_free (priv->name); | ||||
|  | ||||
| @@ -198,26 +176,32 @@ clutter_actor_meta_class_init (ClutterActorMetaClass *klass) | ||||
|   GObjectClass *gobject_class = G_OBJECT_CLASS (klass); | ||||
|  | ||||
|   klass->set_actor = clutter_actor_meta_real_set_actor; | ||||
|   klass->set_enabled = clutter_actor_meta_real_set_enabled; | ||||
|  | ||||
|   /** | ||||
|    * ClutterActorMeta:actor: | ||||
|    * | ||||
|    * The #ClutterActor attached to the #ClutterActorMeta instance | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   obj_props[PROP_ACTOR] = | ||||
|     g_param_spec_object ("actor", NULL, NULL, | ||||
|     g_param_spec_object ("actor", | ||||
|                          P_("Actor"), | ||||
|                          P_("The actor attached to the meta"), | ||||
|                          CLUTTER_TYPE_ACTOR, | ||||
|                          CLUTTER_PARAM_READABLE | | ||||
|                          G_PARAM_EXPLICIT_NOTIFY); | ||||
|                          CLUTTER_PARAM_READABLE); | ||||
|  | ||||
|   /** | ||||
|    * ClutterActorMeta:name: | ||||
|    * | ||||
|    * The unique name to access the #ClutterActorMeta | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   obj_props[PROP_NAME] = | ||||
|     g_param_spec_string ("name", NULL, NULL, | ||||
|     g_param_spec_string ("name", | ||||
|                          P_("Name"), | ||||
|                          P_("The name of the meta"), | ||||
|                          NULL, | ||||
|                          CLUTTER_PARAM_READWRITE); | ||||
|  | ||||
| @@ -225,9 +209,13 @@ clutter_actor_meta_class_init (ClutterActorMetaClass *klass) | ||||
|    * ClutterActorMeta:enabled: | ||||
|    * | ||||
|    * Whether or not the #ClutterActorMeta is enabled | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   obj_props[PROP_ENABLED] = | ||||
|     g_param_spec_boolean ("enabled", NULL, NULL, | ||||
|     g_param_spec_boolean ("enabled", | ||||
|                           P_("Enabled"), | ||||
|                           P_("Whether the meta is enabled"), | ||||
|                           TRUE, | ||||
|                           CLUTTER_PARAM_READWRITE); | ||||
|  | ||||
| @@ -242,11 +230,9 @@ clutter_actor_meta_class_init (ClutterActorMetaClass *klass) | ||||
| void | ||||
| clutter_actor_meta_init (ClutterActorMeta *self) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv = | ||||
|     clutter_actor_meta_get_instance_private (self); | ||||
|  | ||||
|   priv->is_enabled = TRUE; | ||||
|   priv->priority = CLUTTER_ACTOR_META_PRIORITY_DEFAULT; | ||||
|   self->priv = clutter_actor_meta_get_instance_private (self); | ||||
|   self->priv->is_enabled = TRUE; | ||||
|   self->priv->priority = CLUTTER_ACTOR_META_PRIORITY_DEFAULT; | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -257,22 +243,20 @@ clutter_actor_meta_init (ClutterActorMeta *self) | ||||
|  * Sets the name of @meta | ||||
|  * | ||||
|  * The name can be used to identify the #ClutterActorMeta instance | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_meta_set_name (ClutterActorMeta *meta, | ||||
|                              const gchar      *name) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv; | ||||
|  | ||||
|   g_return_if_fail (CLUTTER_IS_ACTOR_META (meta)); | ||||
|  | ||||
|   priv = clutter_actor_meta_get_instance_private (meta); | ||||
|  | ||||
|   if (g_strcmp0 (priv->name, name) == 0) | ||||
|   if (g_strcmp0 (meta->priv->name, name) == 0) | ||||
|     return; | ||||
|  | ||||
|   g_free (priv->name); | ||||
|   priv->name = g_strdup (name); | ||||
|   g_free (meta->priv->name); | ||||
|   meta->priv->name = g_strdup (name); | ||||
|  | ||||
|   g_object_notify_by_pspec (G_OBJECT (meta), obj_props[PROP_NAME]); | ||||
| } | ||||
| @@ -281,23 +265,21 @@ clutter_actor_meta_set_name (ClutterActorMeta *meta, | ||||
|  * clutter_actor_meta_get_name: | ||||
|  * @meta: a #ClutterActorMeta | ||||
|  * | ||||
|  * Retrieves the name set using [method@ActorMeta.set_name] | ||||
|  * Retrieves the name set using clutter_actor_meta_set_name() | ||||
|  * | ||||
|  * Return value: (transfer none): the name of the #ClutterActorMeta | ||||
|  *   instance, or %NULL if none was set. The returned string is owned | ||||
|  *   by the #ClutterActorMeta instance and it should not be modified | ||||
|  *   or freed | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| const gchar * | ||||
| clutter_actor_meta_get_name (ClutterActorMeta *meta) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_ACTOR_META (meta), NULL); | ||||
|  | ||||
|   priv = clutter_actor_meta_get_instance_private (meta); | ||||
|  | ||||
|   return priv->name; | ||||
|   return meta->priv->name; | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -306,22 +288,23 @@ clutter_actor_meta_get_name (ClutterActorMeta *meta) | ||||
|  * @is_enabled: whether @meta is enabled | ||||
|  * | ||||
|  * Sets whether @meta should be enabled or not | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_actor_meta_set_enabled (ClutterActorMeta *meta, | ||||
|                                 gboolean          is_enabled) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv; | ||||
|  | ||||
|   g_return_if_fail (CLUTTER_IS_ACTOR_META (meta)); | ||||
|  | ||||
|   priv = clutter_actor_meta_get_instance_private (meta); | ||||
|   is_enabled = !!is_enabled; | ||||
|  | ||||
|   if (priv->is_enabled == is_enabled) | ||||
|   if (meta->priv->is_enabled == is_enabled) | ||||
|     return; | ||||
|  | ||||
|   CLUTTER_ACTOR_META_GET_CLASS (meta)->set_enabled (meta, is_enabled); | ||||
|   meta->priv->is_enabled = is_enabled; | ||||
|  | ||||
|   g_object_notify_by_pspec (G_OBJECT (meta), obj_props[PROP_ENABLED]); | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -331,17 +314,15 @@ clutter_actor_meta_set_enabled (ClutterActorMeta *meta, | ||||
|  * Retrieves whether @meta is enabled | ||||
|  * | ||||
|  * Return value: %TRUE if the #ClutterActorMeta instance is enabled | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| gboolean | ||||
| clutter_actor_meta_get_enabled (ClutterActorMeta *meta) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_ACTOR_META (meta), FALSE); | ||||
|  | ||||
|   priv = clutter_actor_meta_get_instance_private (meta); | ||||
|  | ||||
|   return priv->is_enabled; | ||||
|   return meta->priv->is_enabled; | ||||
| } | ||||
|  | ||||
| /* | ||||
| @@ -351,6 +332,8 @@ clutter_actor_meta_get_enabled (ClutterActorMeta *meta) | ||||
|  * | ||||
|  * Sets or unsets a back pointer to the #ClutterActor that owns | ||||
|  * the @meta | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| _clutter_actor_meta_set_actor (ClutterActorMeta *meta, | ||||
| @@ -366,61 +349,49 @@ _clutter_actor_meta_set_actor (ClutterActorMeta *meta, | ||||
|  * clutter_actor_meta_get_actor: | ||||
|  * @meta: a #ClutterActorMeta | ||||
|  * | ||||
|  * Retrieves a pointer to the [class@Actor] that owns @meta | ||||
|  * Retrieves a pointer to the #ClutterActor that owns @meta | ||||
|  * | ||||
|  * Return value: (transfer none): a pointer to a #ClutterActor or %NULL | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| ClutterActor * | ||||
| clutter_actor_meta_get_actor (ClutterActorMeta *meta) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_ACTOR_META (meta), NULL); | ||||
|  | ||||
|   priv = clutter_actor_meta_get_instance_private (meta); | ||||
|  | ||||
|   return priv->actor; | ||||
|   return meta->priv->actor; | ||||
| } | ||||
|  | ||||
| void | ||||
| _clutter_actor_meta_set_priority (ClutterActorMeta *meta, | ||||
|                                   gint priority) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv; | ||||
|  | ||||
|   g_return_if_fail (CLUTTER_IS_ACTOR_META (meta)); | ||||
|  | ||||
|   priv = clutter_actor_meta_get_instance_private (meta); | ||||
|  | ||||
|   /* This property shouldn't be modified after the actor meta is in | ||||
|      use because ClutterMetaGroup doesn't resort the list when it | ||||
|      changes. If we made the priority public then we could either make | ||||
|      the priority a construct-only property or listen for | ||||
|      notifications on the property from the ClutterMetaGroup and | ||||
|      resort. */ | ||||
|   g_return_if_fail (priv->actor == NULL); | ||||
|   g_return_if_fail (meta->priv->actor == NULL); | ||||
|  | ||||
|   priv->priority = priority; | ||||
|   meta->priv->priority = priority; | ||||
| } | ||||
|  | ||||
| gint | ||||
| _clutter_actor_meta_get_priority (ClutterActorMeta *meta) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_ACTOR_META (meta), 0); | ||||
|  | ||||
|   priv = clutter_actor_meta_get_instance_private (meta); | ||||
|  | ||||
|   return priv->priority; | ||||
|   return meta->priv->priority; | ||||
| } | ||||
|  | ||||
| gboolean | ||||
| _clutter_actor_meta_is_internal (ClutterActorMeta *meta) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv = | ||||
|     clutter_actor_meta_get_instance_private (meta); | ||||
|   gint priority = priv->priority; | ||||
|   gint priority = meta->priv->priority; | ||||
|  | ||||
|   return (priority <= CLUTTER_ACTOR_META_PRIORITY_INTERNAL_LOW || | ||||
|           priority >= CLUTTER_ACTOR_META_PRIORITY_INTERNAL_HIGH); | ||||
| @@ -467,21 +438,19 @@ void | ||||
| _clutter_meta_group_add_meta (ClutterMetaGroup *group, | ||||
|                               ClutterActorMeta *meta) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv = | ||||
|     clutter_actor_meta_get_instance_private (meta); | ||||
|   GList *prev = NULL, *l; | ||||
|  | ||||
|   if (priv->actor != NULL) | ||||
|   if (meta->priv->actor != NULL) | ||||
|     { | ||||
|       g_warning ("The meta of type '%s' with name '%s' is " | ||||
|                  "already attached to actor '%s'", | ||||
|                  G_OBJECT_TYPE_NAME (meta), | ||||
|                  priv->name != NULL | ||||
|                    ? priv->name | ||||
|                  meta->priv->name != NULL | ||||
|                    ? meta->priv->name | ||||
|                    : "<unknown>", | ||||
|                  clutter_actor_get_name (priv->actor) != NULL | ||||
|                    ? clutter_actor_get_name (priv->actor) | ||||
|                    : G_OBJECT_TYPE_NAME (priv->actor)); | ||||
|                  clutter_actor_get_name (meta->priv->actor) != NULL | ||||
|                    ? clutter_actor_get_name (meta->priv->actor) | ||||
|                    : G_OBJECT_TYPE_NAME (meta->priv->actor)); | ||||
|       return; | ||||
|     } | ||||
|  | ||||
| @@ -517,16 +486,13 @@ void | ||||
| _clutter_meta_group_remove_meta (ClutterMetaGroup *group, | ||||
|                                  ClutterActorMeta *meta) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv = | ||||
|     clutter_actor_meta_get_instance_private (meta); | ||||
|  | ||||
|   if (priv->actor != group->actor) | ||||
|   if (meta->priv->actor != group->actor) | ||||
|     { | ||||
|       g_warning ("The meta of type '%s' with name '%s' is not " | ||||
|                  "attached to the actor '%s'", | ||||
|                  G_OBJECT_TYPE_NAME (meta), | ||||
|                  priv->name != NULL | ||||
|                    ? priv->name | ||||
|                  meta->priv->name != NULL | ||||
|                    ? meta->priv->name | ||||
|                    : "<unknown>", | ||||
|                  clutter_actor_get_name (group->actor) != NULL | ||||
|                    ? clutter_actor_get_name (group->actor) | ||||
| @@ -669,10 +635,8 @@ _clutter_meta_group_get_meta (ClutterMetaGroup *group, | ||||
|   for (l = group->meta; l != NULL; l = l->next) | ||||
|     { | ||||
|       ClutterActorMeta *meta = l->data; | ||||
|       ClutterActorMetaPrivate *priv = | ||||
|         clutter_actor_meta_get_instance_private (meta); | ||||
|  | ||||
|       if (g_strcmp0 (priv->name, name) == 0) | ||||
|       if (g_strcmp0 (meta->priv->name, name) == 0) | ||||
|         return meta; | ||||
|     } | ||||
|  | ||||
| @@ -692,8 +656,6 @@ _clutter_meta_group_get_meta (ClutterMetaGroup *group, | ||||
| const gchar * | ||||
| _clutter_actor_meta_get_debug_name (ClutterActorMeta *meta) | ||||
| { | ||||
|   ClutterActorMetaPrivate *priv = | ||||
|     clutter_actor_meta_get_instance_private (meta); | ||||
|  | ||||
|   return priv->name != NULL ? priv->name : G_OBJECT_TYPE_NAME (meta); | ||||
|   return meta->priv->name != NULL ? meta->priv->name | ||||
|                                   : G_OBJECT_TYPE_NAME (meta); | ||||
| } | ||||
|   | ||||
| @@ -22,23 +22,42 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_ACTOR_META_H__ | ||||
| #define __CLUTTER_ACTOR_META_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-types.h" | ||||
| #include <clutter/clutter-types.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| #define CLUTTER_TYPE_ACTOR_META (clutter_actor_meta_get_type ()) | ||||
| #define CLUTTER_TYPE_ACTOR_META                 (clutter_actor_meta_get_type ()) | ||||
| #define CLUTTER_ACTOR_META(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ACTOR_META, ClutterActorMeta)) | ||||
| #define CLUTTER_IS_ACTOR_META(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ACTOR_META)) | ||||
| #define CLUTTER_ACTOR_META_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_ACTOR_META, ClutterActorMetaClass)) | ||||
| #define CLUTTER_IS_ACTOR_META_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_ACTOR_META)) | ||||
| #define CLUTTER_ACTOR_META_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_ACTOR_META, ClutterActorMetaClass)) | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| G_DECLARE_DERIVABLE_TYPE (ClutterActorMeta, clutter_actor_meta, | ||||
|                           CLUTTER, ACTOR_META, GInitiallyUnowned); | ||||
| typedef struct _ClutterActorMetaPrivate         ClutterActorMetaPrivate; | ||||
| typedef struct _ClutterActorMetaClass           ClutterActorMetaClass; | ||||
|  | ||||
| typedef struct _ClutterActorMetaPrivate ClutterActorMetaPrivate; | ||||
| /** | ||||
|  * ClutterActorMeta: | ||||
|  * | ||||
|  * The #ClutterActorMeta structure contains only | ||||
|  * private data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _ClutterActorMeta | ||||
| { | ||||
|   /*< private >*/ | ||||
|   GInitiallyUnowned parent_instance; | ||||
|  | ||||
|   ClutterActorMetaPrivate *priv; | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * ClutterActorMetaClass: | ||||
| @@ -47,6 +66,8 @@ typedef struct _ClutterActorMetaPrivate ClutterActorMetaPrivate; | ||||
|  * | ||||
|  * The #ClutterActorMetaClass structure contains | ||||
|  * only private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _ClutterActorMetaClass | ||||
| { | ||||
| @@ -66,10 +87,19 @@ struct _ClutterActorMetaClass | ||||
|   void (* set_actor) (ClutterActorMeta *meta, | ||||
|                       ClutterActor     *actor); | ||||
|  | ||||
|   void (* set_enabled) (ClutterActorMeta *meta, | ||||
|                         gboolean          is_enabled); | ||||
|   /*< private >*/ | ||||
|   void (* _clutter_meta1) (void); | ||||
|   void (* _clutter_meta2) (void); | ||||
|   void (* _clutter_meta3) (void); | ||||
|   void (* _clutter_meta4) (void); | ||||
|   void (* _clutter_meta5) (void); | ||||
|   void (* _clutter_meta6) (void); | ||||
|   void (* _clutter_meta7) (void); | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| GType clutter_actor_meta_get_type (void) G_GNUC_CONST; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void            clutter_actor_meta_set_name     (ClutterActorMeta *meta, | ||||
|                                                  const gchar      *name); | ||||
| @@ -85,3 +115,5 @@ CLUTTER_EXPORT | ||||
| ClutterActor *  clutter_actor_meta_get_actor    (ClutterActorMeta *meta); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_ACTOR_META_H__ */ | ||||
|   | ||||
| @@ -19,13 +19,30 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_ACTOR_PRIVATE_H__ | ||||
| #define __CLUTTER_ACTOR_PRIVATE_H__ | ||||
|  | ||||
| #include "clutter/clutter-actor.h" | ||||
| #include "clutter/clutter-grab.h" | ||||
| #include <clutter/clutter-actor.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| /*< private > | ||||
|  * ClutterRedrawFlags: | ||||
|  * @CLUTTER_REDRAW_CLIPPED_TO_ALLOCATION: Tells clutter the maximum | ||||
|  *   extents of what needs to be redrawn lies within the actors | ||||
|  *   current allocation. (Only use this for 2D actors though because | ||||
|  *   any actor with depth may be projected outside of its allocation) | ||||
|  * | ||||
|  * Flags passed to the clutter_actor_queue_redraw_with_clip () | ||||
|  * function | ||||
|  * | ||||
|  * Since: 1.6 | ||||
|  */ | ||||
| typedef enum | ||||
| { | ||||
|   CLUTTER_REDRAW_CLIPPED_TO_ALLOCATION  = 1 << 0 | ||||
| } ClutterRedrawFlags; | ||||
|  | ||||
| /*< private > | ||||
|  * ClutterActorTraverseFlags: | ||||
|  * CLUTTER_ACTOR_TRAVERSE_DEPTH_FIRST: Traverse the graph in | ||||
| @@ -93,12 +110,35 @@ typedef ClutterActorTraverseVisitFlags (*ClutterTraverseCallback) (ClutterActor | ||||
| typedef gboolean (*ClutterForeachCallback) (ClutterActor *actor, | ||||
|                                             gpointer      user_data); | ||||
|  | ||||
| typedef struct _AnchorCoord             AnchorCoord; | ||||
| typedef struct _SizeRequest             SizeRequest; | ||||
|  | ||||
| typedef struct _ClutterLayoutInfo       ClutterLayoutInfo; | ||||
| typedef struct _ClutterTransformInfo    ClutterTransformInfo; | ||||
| typedef struct _ClutterAnimationInfo    ClutterAnimationInfo; | ||||
|  | ||||
| /* Internal helper struct to represent a point that can be stored in | ||||
|    either direct pixel coordinates or as a fraction of the actor's | ||||
|    size. It is used for the anchor point, scale center and rotation | ||||
|    centers. */ | ||||
| struct _AnchorCoord | ||||
| { | ||||
|   gboolean is_fractional; | ||||
|  | ||||
|   union | ||||
|   { | ||||
|     /* Used when is_fractional == TRUE */ | ||||
|     struct | ||||
|     { | ||||
|       gdouble x; | ||||
|       gdouble y; | ||||
|     } fraction; | ||||
|  | ||||
|     /* Use when is_fractional == FALSE */ | ||||
|     ClutterVertex units; | ||||
|   } v; | ||||
| }; | ||||
|  | ||||
| struct _SizeRequest | ||||
| { | ||||
|   guint  age; | ||||
| @@ -123,7 +163,7 @@ struct _SizeRequest | ||||
| struct _ClutterLayoutInfo | ||||
| { | ||||
|   /* fixed position coordinates */ | ||||
|   graphene_point_t fixed_pos; | ||||
|   ClutterPoint fixed_pos; | ||||
|  | ||||
|   ClutterMargin margin; | ||||
|  | ||||
| @@ -133,8 +173,8 @@ struct _ClutterLayoutInfo | ||||
|   guint x_expand : 1; | ||||
|   guint y_expand : 1; | ||||
|  | ||||
|   graphene_size_t minimum; | ||||
|   graphene_size_t natural; | ||||
|   ClutterSize minimum; | ||||
|   ClutterSize natural; | ||||
| }; | ||||
|  | ||||
| const ClutterLayoutInfo *       _clutter_actor_get_layout_info_or_defaults      (ClutterActor *self); | ||||
| @@ -143,30 +183,39 @@ ClutterLayoutInfo *             _clutter_actor_peek_layout_info | ||||
|  | ||||
| struct _ClutterTransformInfo | ||||
| { | ||||
|   /* rotation */ | ||||
|   /* rotation (angle and center) */ | ||||
|   gdouble rx_angle; | ||||
|   AnchorCoord rx_center; | ||||
|  | ||||
|   gdouble ry_angle; | ||||
|   AnchorCoord ry_center; | ||||
|  | ||||
|   gdouble rz_angle; | ||||
|   AnchorCoord rz_center; | ||||
|  | ||||
|   /* scaling */ | ||||
|   gdouble scale_x; | ||||
|   gdouble scale_y; | ||||
|   gdouble scale_z; | ||||
|   AnchorCoord scale_center; | ||||
|  | ||||
|   /* anchor point */ | ||||
|   AnchorCoord anchor; | ||||
|  | ||||
|   /* translation */ | ||||
|   graphene_point3d_t translation; | ||||
|   ClutterVertex translation; | ||||
|  | ||||
|   /* z_position */ | ||||
|   gfloat z_position; | ||||
|  | ||||
|   /* transformation center */ | ||||
|   graphene_point_t pivot; | ||||
|   ClutterPoint pivot; | ||||
|   gfloat pivot_z; | ||||
|  | ||||
|   graphene_matrix_t transform; | ||||
|   CoglMatrix transform; | ||||
|   guint transform_set : 1; | ||||
|  | ||||
|   graphene_matrix_t child_transform; | ||||
|   CoglMatrix child_transform; | ||||
|   guint child_transform_set : 1; | ||||
| }; | ||||
|  | ||||
| @@ -193,6 +242,9 @@ ClutterAnimationInfo *          _clutter_actor_get_animation_info | ||||
| ClutterTransition *             _clutter_actor_create_transition                        (ClutterActor *self, | ||||
|                                                                                          GParamSpec   *pspec, | ||||
|                                                                                          ...); | ||||
| ClutterTransition *             _clutter_actor_get_transition                           (ClutterActor *self, | ||||
|                                                                                          GParamSpec   *pspec); | ||||
|  | ||||
| gboolean                        _clutter_actor_foreach_child                            (ClutterActor *self, | ||||
|                                                                                          ClutterForeachCallback callback, | ||||
|                                                                                          gpointer user_data); | ||||
| @@ -203,11 +255,11 @@ void                            _clutter_actor_traverse | ||||
|                                                                                          gpointer user_data); | ||||
| ClutterActor *                  _clutter_actor_get_stage_internal                       (ClutterActor *actor); | ||||
|  | ||||
| void                            _clutter_actor_apply_modelview_transform                (ClutterActor      *self, | ||||
|                                                                                          graphene_matrix_t *matrix); | ||||
| void                            _clutter_actor_apply_relative_transformation_matrix     (ClutterActor      *self, | ||||
|                                                                                          ClutterActor      *ancestor, | ||||
|                                                                                          graphene_matrix_t *matrix); | ||||
| void                            _clutter_actor_apply_modelview_transform                (ClutterActor *self, | ||||
|                                                                                          CoglMatrix   *matrix); | ||||
| void                            _clutter_actor_apply_relative_transformation_matrix     (ClutterActor *self, | ||||
|                                                                                          ClutterActor *ancestor, | ||||
|                                                                                          CoglMatrix   *matrix); | ||||
|  | ||||
| void                            _clutter_actor_rerealize                                (ClutterActor    *self, | ||||
|                                                                                          ClutterCallback  callback, | ||||
| @@ -225,58 +277,53 @@ void                            _clutter_actor_set_enable_paint_unmapped | ||||
| void                            _clutter_actor_set_has_pointer                          (ClutterActor *self, | ||||
|                                                                                          gboolean      has_pointer); | ||||
|  | ||||
| void                            _clutter_actor_set_has_key_focus                        (ClutterActor *self, | ||||
|                                                                                          gboolean      has_key_focus); | ||||
|  | ||||
| void                            _clutter_actor_queue_redraw_with_clip                   (ClutterActor             *self, | ||||
|                                                                                          ClutterRedrawFlags        flags, | ||||
|                                                                                          const ClutterPaintVolume *clip_volume); | ||||
| void                            _clutter_actor_queue_redraw_full                        (ClutterActor             *self, | ||||
|                                                                                          ClutterRedrawFlags        flags, | ||||
|                                                                                          const ClutterPaintVolume *volume, | ||||
|                                                                                          ClutterEffect            *effect); | ||||
|  | ||||
| void                            _clutter_actor_finish_queue_redraw                      (ClutterActor *self); | ||||
| void                            _clutter_actor_finish_queue_redraw                      (ClutterActor       *self, | ||||
|                                                                                          ClutterPaintVolume *clip); | ||||
|  | ||||
| gboolean                        _clutter_actor_set_default_paint_volume                 (ClutterActor       *self, | ||||
|                                                                                          GType               check_gtype, | ||||
|                                                                                          ClutterPaintVolume *volume); | ||||
|  | ||||
| const char *                    _clutter_actor_get_debug_name                           (ClutterActor *self); | ||||
| const gchar *                   _clutter_actor_get_debug_name                           (ClutterActor *self); | ||||
|  | ||||
| void                            _clutter_actor_push_clone_paint                         (void); | ||||
| void                            _clutter_actor_pop_clone_paint                          (void); | ||||
|  | ||||
| guint32                         _clutter_actor_get_pick_id                              (ClutterActor *self); | ||||
|  | ||||
| void                            _clutter_actor_shader_pre_paint                         (ClutterActor *actor, | ||||
|                                                                                          gboolean      repeat); | ||||
| void                            _clutter_actor_shader_post_paint                        (ClutterActor *actor); | ||||
|  | ||||
| ClutterActorAlign               _clutter_actor_get_effective_x_align                    (ClutterActor *self); | ||||
|  | ||||
| void                            _clutter_actor_handle_event                             (ClutterActor       *actor, | ||||
|                                                                                          const ClutterEvent *event); | ||||
|  | ||||
| void                            _clutter_actor_attach_clone                             (ClutterActor *actor, | ||||
|                                                                                          ClutterActor *clone); | ||||
| void                            _clutter_actor_detach_clone                             (ClutterActor *actor, | ||||
|                                                                                          ClutterActor *clone); | ||||
| void                            _clutter_actor_queue_redraw_on_clones                   (ClutterActor *actor); | ||||
| void                            _clutter_actor_queue_relayout_on_clones                 (ClutterActor *actor); | ||||
| void                            _clutter_actor_queue_only_relayout                      (ClutterActor *actor); | ||||
| void                            clutter_actor_clear_stage_views_recursive               (ClutterActor *actor, | ||||
|                                                                                          gboolean      stop_transitions); | ||||
| void                            _clutter_actor_queue_update_resource_scale_recursive    (ClutterActor *actor); | ||||
|  | ||||
| float                           clutter_actor_get_real_resource_scale                   (ClutterActor *actor); | ||||
| CoglFramebuffer *               _clutter_actor_get_active_framebuffer                   (ClutterActor *actor); | ||||
| gboolean                        _clutter_actor_get_real_resource_scale                  (ClutterActor *actor, | ||||
|                                                                                          float        *resource_scale); | ||||
|  | ||||
| ClutterPaintNode *              clutter_actor_create_texture_paint_node                 (ClutterActor *self, | ||||
|                                                                                          CoglTexture  *texture); | ||||
|  | ||||
| void clutter_actor_finish_layout (ClutterActor *self, | ||||
|                                   int           phase); | ||||
|  | ||||
| void clutter_actor_queue_immediate_relayout (ClutterActor *self); | ||||
|  | ||||
| gboolean clutter_actor_is_painting_unmapped (ClutterActor *self); | ||||
|  | ||||
| void clutter_actor_attach_grab (ClutterActor *actor, | ||||
|                                 ClutterGrab  *grab); | ||||
| void clutter_actor_detach_grab (ClutterActor *actor, | ||||
|                                 ClutterGrab  *grab); | ||||
|  | ||||
| void clutter_actor_collect_event_actors (ClutterActor *self, | ||||
|                                          ClutterActor *deepmost, | ||||
|                                          GPtrArray    *actors); | ||||
|  | ||||
| const GList * clutter_actor_peek_actions (ClutterActor *self); | ||||
|  | ||||
| void clutter_actor_set_implicitly_grabbed (ClutterActor *actor, | ||||
|                                            gboolean      is_implicitly_grabbed); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_ACTOR_PRIVATE_H__ */ | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -22,7 +22,8 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_ACTOR_H__ | ||||
| #define __CLUTTER_ACTOR_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| @@ -34,13 +35,10 @@ | ||||
| #include <pango/pango.h> | ||||
| #include <atk/atk.h> | ||||
|  | ||||
| #include "cogl/cogl.h" | ||||
| #include <cogl/cogl.h> | ||||
|  | ||||
| #include "clutter/clutter-types.h" | ||||
| #include "clutter/clutter-event.h" | ||||
| #include "clutter/clutter-paint-context.h" | ||||
| #include "clutter/clutter-pick-context.h" | ||||
| #include "mtk/mtk.h" | ||||
| #include <clutter/clutter-types.h> | ||||
| #include <clutter/clutter-event.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -81,6 +79,22 @@ G_BEGIN_DECLS | ||||
|   CLUTTER_MACRO_DEPRECATED \ | ||||
|   (((ClutterActor*)(a))->flags &= ~(f)) | ||||
|  | ||||
| #define CLUTTER_ACTOR_IS_MAPPED(a) \ | ||||
|   CLUTTER_MACRO_DEPRECATED_FOR ("Deprecated macro. Use clutter_actor_is_mapped instead") \ | ||||
|   ((((ClutterActor*)(a))->flags & CLUTTER_ACTOR_MAPPED) != FALSE) | ||||
|  | ||||
| #define CLUTTER_ACTOR_IS_REALIZED(a) \ | ||||
|   CLUTTER_MACRO_DEPRECATED_FOR ("Deprecated macro. Use clutter_actor_is_realized instead") \ | ||||
|   ((((ClutterActor*)(a))->flags & CLUTTER_ACTOR_REALIZED) != FALSE) | ||||
|  | ||||
| #define CLUTTER_ACTOR_IS_VISIBLE(a) \ | ||||
|   CLUTTER_MACRO_DEPRECATED_FOR ("Deprecated macro. Use clutter_actor_is_visible instead") \ | ||||
|   ((((ClutterActor*)(a))->flags & CLUTTER_ACTOR_VISIBLE) != FALSE) | ||||
|  | ||||
| #define CLUTTER_ACTOR_IS_REACTIVE(a) \ | ||||
|   CLUTTER_MACRO_DEPRECATED_FOR ("Deprecated macro. Use clutter_actor_get_reactive instead") \ | ||||
|   ((((ClutterActor*)(a))->flags & CLUTTER_ACTOR_REACTIVE) != FALSE) | ||||
|  | ||||
| typedef struct _ClutterActorClass    ClutterActorClass; | ||||
| typedef struct _ClutterActorPrivate  ClutterActorPrivate; | ||||
|  | ||||
| @@ -102,7 +116,12 @@ typedef void (*ClutterCallback) (ClutterActor *actor, | ||||
|  */ | ||||
| #define CLUTTER_CALLBACK(f)        ((ClutterCallback) (f)) | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * ClutterActor: | ||||
|  * @flags: #ClutterActorFlags | ||||
|  * | ||||
|  * Base class for actors. | ||||
|  */ | ||||
| struct _ClutterActor | ||||
| { | ||||
|   /*< private >*/ | ||||
| @@ -121,6 +140,11 @@ struct _ClutterActor | ||||
|  * ClutterActorClass: | ||||
|  * @show: signal class handler for #ClutterActor::show; it must chain | ||||
|  *   up to the parent's implementation | ||||
|  * @show_all: virtual function for containers and composite actors, to | ||||
|  *   determine which children should be shown when calling | ||||
|  *   clutter_actor_show_all() on the actor. Defaults to calling | ||||
|  *   clutter_actor_show(). This virtual function is deprecated and it | ||||
|  *   should not be overridden. | ||||
|  * @hide: signal class handler for #ClutterActor::hide; it must chain | ||||
|  *   up to the parent's implementation | ||||
|  * @hide_all: virtual function for containers and composite actors, to | ||||
| @@ -149,23 +173,18 @@ struct _ClutterActor | ||||
|  * @get_preferred_height: virtual function, used when querying the minimum | ||||
|  *   and natural heights of an actor for a given width; it is used by | ||||
|  *   clutter_actor_get_preferred_height() | ||||
|  * @allocate: virtual function, used when setting the coordinates of an | ||||
|  *   actor; it is used by clutter_actor_allocate(); when overriding this | ||||
|  *   function without chaining up, clutter_actor_set_allocation() must be | ||||
|  *   called and children must be allocated by the implementation, when | ||||
|  *   chaining up though, those things will be done by the parent's | ||||
|  *   implementation. | ||||
|  * @allocate: virtual function, used when settings the coordinates of an | ||||
|  *   actor; it is used by clutter_actor_allocate(); it must chain up to | ||||
|  *   the parent's implementation, or call clutter_actor_set_allocation() | ||||
|  * @apply_transform: virtual function, used when applying the transformations | ||||
|  *   to an actor before painting it or when transforming coordinates or | ||||
|  *   the allocation; if the transformation calculated by this function may | ||||
|  *   have changed, the cached transformation must be invalidated by calling | ||||
|  *   clutter_actor_invalidate_transform(); it must chain up to the parent's | ||||
|  *   implementation | ||||
|  *   the allocation; it must chain up to the parent's implementation | ||||
|  * @parent_set: signal class handler for the #ClutterActor::parent-set | ||||
|  * @destroy: signal class handler for #ClutterActor::destroy. It must | ||||
|  *   chain up to the parent's implementation | ||||
|  * @pick: virtual function, used to draw an outline of the actor with | ||||
|  *   the given color | ||||
|  * @queue_redraw: class handler for #ClutterActor::queue-redraw | ||||
|  * @event: class handler for #ClutterActor::event | ||||
|  * @button_press_event: class handler for #ClutterActor::button-press-event | ||||
|  * @button_release_event: class handler for | ||||
| @@ -202,20 +221,24 @@ struct _ClutterActorClass | ||||
|  | ||||
|   /*< public >*/ | ||||
|   void (* show)                 (ClutterActor          *self); | ||||
|   void (* show_all)             (ClutterActor          *self); | ||||
|   void (* hide)                 (ClutterActor          *self); | ||||
|   void (* hide_all)             (ClutterActor          *self); | ||||
|   void (* realize)              (ClutterActor          *self); | ||||
|   void (* unrealize)            (ClutterActor          *self); | ||||
|   void (* map)                  (ClutterActor          *self); | ||||
|   void (* unmap)                (ClutterActor          *self); | ||||
|   void (* paint)                (ClutterActor          *self, | ||||
|                                  ClutterPaintContext   *paint_context); | ||||
|   void (* paint)                (ClutterActor          *self); | ||||
|   void (* parent_set)           (ClutterActor          *actor, | ||||
|                                  ClutterActor          *old_parent); | ||||
|  | ||||
|   void (* destroy)              (ClutterActor          *self); | ||||
|   void (* pick)                 (ClutterActor          *actor, | ||||
|                                  ClutterPickContext    *pick_context); | ||||
|                                  const ClutterColor    *color); | ||||
|  | ||||
|   gboolean (* queue_redraw)     (ClutterActor          *actor, | ||||
|                                  ClutterActor          *leaf_that_queued, | ||||
|                                  ClutterPaintVolume    *paint_volume); | ||||
|  | ||||
|   /* size negotiation */ | ||||
|   void (* get_preferred_width)  (ClutterActor           *self, | ||||
| @@ -227,31 +250,32 @@ struct _ClutterActorClass | ||||
|                                  gfloat                 *min_height_p, | ||||
|                                  gfloat                 *natural_height_p); | ||||
|   void (* allocate)             (ClutterActor           *self, | ||||
|                                  const ClutterActorBox  *box); | ||||
|                                  const ClutterActorBox  *box, | ||||
|                                  ClutterAllocationFlags  flags); | ||||
|  | ||||
|   /* transformations */ | ||||
|   void (* apply_transform)      (ClutterActor           *actor, | ||||
|                                  graphene_matrix_t      *matrix); | ||||
|                                  ClutterMatrix          *matrix); | ||||
|  | ||||
|   /* event signals */ | ||||
|   gboolean (* event)                (ClutterActor         *actor, | ||||
|                                      ClutterEvent         *event); | ||||
|   gboolean (* button_press_event)   (ClutterActor         *actor, | ||||
|                                      ClutterEvent         *event); | ||||
|                                      ClutterButtonEvent   *event); | ||||
|   gboolean (* button_release_event) (ClutterActor         *actor, | ||||
|                                      ClutterEvent         *event); | ||||
|                                      ClutterButtonEvent   *event); | ||||
|   gboolean (* scroll_event)         (ClutterActor         *actor, | ||||
|                                      ClutterEvent         *event); | ||||
|                                      ClutterScrollEvent   *event); | ||||
|   gboolean (* key_press_event)      (ClutterActor         *actor, | ||||
|                                      ClutterEvent         *event); | ||||
|                                      ClutterKeyEvent      *event); | ||||
|   gboolean (* key_release_event)    (ClutterActor         *actor, | ||||
|                                      ClutterEvent         *event); | ||||
|                                      ClutterKeyEvent      *event); | ||||
|   gboolean (* motion_event)         (ClutterActor         *actor, | ||||
|                                      ClutterEvent         *event); | ||||
|                                      ClutterMotionEvent   *event); | ||||
|   gboolean (* enter_event)          (ClutterActor         *actor, | ||||
|                                      ClutterEvent         *event); | ||||
|                                      ClutterCrossingEvent *event); | ||||
|   gboolean (* leave_event)          (ClutterActor         *actor, | ||||
|                                      ClutterEvent         *event); | ||||
|                                      ClutterCrossingEvent *event); | ||||
|   gboolean (* captured_event)       (ClutterActor         *actor, | ||||
|                                      ClutterEvent         *event); | ||||
|   void     (* key_focus_in)         (ClutterActor         *actor); | ||||
| @@ -271,11 +295,11 @@ struct _ClutterActorClass | ||||
|                                      ClutterPaintNode     *root); | ||||
|  | ||||
|   gboolean (* touch_event)          (ClutterActor         *self, | ||||
|                                      ClutterEvent         *event); | ||||
|   gboolean (* has_accessible)       (ClutterActor         *self); | ||||
|   void     (* resource_scale_changed) (ClutterActor *self); | ||||
|   float    (* calculate_resource_scale) (ClutterActor *self, | ||||
|                                          int           phase); | ||||
|                                      ClutterTouchEvent    *event); | ||||
|  | ||||
|   /*< private >*/ | ||||
|   /* padding for future expansion */ | ||||
|   gpointer _padding_dummy[26]; | ||||
| }; | ||||
|  | ||||
| /** | ||||
| @@ -286,13 +310,17 @@ struct _ClutterActorClass | ||||
|  * | ||||
|  * The contents of the #ClutterActorIter structure | ||||
|  * are private and should only be accessed using the provided API. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| struct _ClutterActorIter | ||||
| { | ||||
|   /*< private >*/ | ||||
|   gpointer CLUTTER_PRIVATE_FIELD (dummy1); | ||||
|   gpointer CLUTTER_PRIVATE_FIELD (dummy2); | ||||
|   gint     CLUTTER_PRIVATE_FIELD (dummy3); | ||||
|   gpointer CLUTTER_PRIVATE_FIELD (dummy3); | ||||
|   gint     CLUTTER_PRIVATE_FIELD (dummy4); | ||||
|   gpointer CLUTTER_PRIVATE_FIELD (dummy5); | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| @@ -322,22 +350,14 @@ void                            clutter_actor_map | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_unmap                             (ClutterActor                *self); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_paint                             (ClutterActor                *self, | ||||
|                                                                                  ClutterPaintContext         *paint_context); | ||||
| void                            clutter_actor_paint                             (ClutterActor                *self); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_continue_paint                    (ClutterActor                *self, | ||||
|                                                                                  ClutterPaintContext         *paint_context); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_pick                              (ClutterActor                *actor, | ||||
|                                                                                  ClutterPickContext          *pick_context); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_continue_pick                     (ClutterActor                *actor, | ||||
|                                                                                  ClutterPickContext          *pick_context); | ||||
| void                            clutter_actor_continue_paint                    (ClutterActor                *self); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_queue_redraw                      (ClutterActor                *self); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_queue_redraw_with_clip            (ClutterActor       *self, | ||||
|                                                                                  const MtkRectangle *clip); | ||||
| void                            clutter_actor_queue_redraw_with_clip            (ClutterActor                *self, | ||||
|                                                                                  const cairo_rectangle_int_t *clip); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_queue_relayout                    (ClutterActor                *self); | ||||
| CLUTTER_EXPORT | ||||
| @@ -349,8 +369,6 @@ CLUTTER_EXPORT | ||||
| const gchar *                   clutter_actor_get_name                          (ClutterActor                *self); | ||||
| CLUTTER_EXPORT | ||||
| AtkObject *                     clutter_actor_get_accessible                    (ClutterActor                *self); | ||||
| CLUTTER_EXPORT | ||||
| gboolean                        clutter_actor_has_accessible                    (ClutterActor                *self); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| gboolean                        clutter_actor_is_visible                        (ClutterActor                *self); | ||||
| @@ -383,31 +401,38 @@ void                            clutter_actor_get_preferred_size | ||||
|                                                                                  gfloat                      *natural_height_p); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_allocate                          (ClutterActor                *self, | ||||
|                                                                                  const ClutterActorBox       *box); | ||||
|                                                                                  const ClutterActorBox       *box, | ||||
|                                                                                  ClutterAllocationFlags       flags); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_allocate_preferred_size           (ClutterActor                *self, | ||||
|                                                                                  float                        x, | ||||
|                                                                                  float                        y); | ||||
|                                                                                  ClutterAllocationFlags       flags); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_allocate_available_size           (ClutterActor                *self, | ||||
|                                                                                  gfloat                       x, | ||||
|                                                                                  gfloat                       y, | ||||
|                                                                                  gfloat                       available_width, | ||||
|                                                                                  gfloat                       available_height); | ||||
|                                                                                  gfloat                       available_height, | ||||
|                                                                                  ClutterAllocationFlags       flags); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_allocate_align_fill               (ClutterActor                *self, | ||||
|                                                                                  const ClutterActorBox       *box, | ||||
|                                                                                  gdouble                      x_align, | ||||
|                                                                                  gdouble                      y_align, | ||||
|                                                                                  gboolean                     x_fill, | ||||
|                                                                                  gboolean                     y_fill); | ||||
|                                                                                  gboolean                     y_fill, | ||||
|                                                                                  ClutterAllocationFlags       flags); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_set_allocation                    (ClutterActor                *self, | ||||
|                                                                                  const ClutterActorBox       *box); | ||||
|                                                                                  const ClutterActorBox       *box, | ||||
|                                                                                  ClutterAllocationFlags       flags); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_get_allocation_box                (ClutterActor                *self, | ||||
|                                                                                  ClutterActorBox             *box); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_get_allocation_vertices           (ClutterActor                *self, | ||||
|                                                                                  ClutterActor                *ancestor, | ||||
|                                                                                  ClutterVertex                verts[]); | ||||
| CLUTTER_EXPORT | ||||
| gboolean                        clutter_actor_has_allocation                    (ClutterActor                *self); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_set_size                          (ClutterActor                *self, | ||||
| @@ -422,10 +447,6 @@ void                            clutter_actor_set_position | ||||
|                                                                                  gfloat                       x, | ||||
|                                                                                  gfloat                       y); | ||||
| CLUTTER_EXPORT | ||||
| gboolean clutter_actor_get_fixed_position (ClutterActor *self, | ||||
|                                            float        *x, | ||||
|                                            float        *y); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_get_position                      (ClutterActor                *self, | ||||
|                                                                                  gfloat                      *x, | ||||
|                                                                                  gfloat                      *y); | ||||
| @@ -557,8 +578,7 @@ void                            clutter_actor_set_offscreen_redirect | ||||
| CLUTTER_EXPORT | ||||
| ClutterOffscreenRedirect        clutter_actor_get_offscreen_redirect            (ClutterActor               *self); | ||||
| CLUTTER_EXPORT | ||||
| gboolean                        clutter_actor_should_pick                       (ClutterActor               *self, | ||||
|                                                                                  ClutterPickContext         *pick_context); | ||||
| gboolean                        clutter_actor_should_pick_paint                 (ClutterActor               *self); | ||||
| CLUTTER_EXPORT | ||||
| gboolean                        clutter_actor_is_in_clone_paint                 (ClutterActor               *self); | ||||
| CLUTTER_EXPORT | ||||
| @@ -566,7 +586,8 @@ gboolean                        clutter_actor_get_paint_box | ||||
|                                                                                  ClutterActorBox            *box); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| float                           clutter_actor_get_resource_scale                (ClutterActor *self); | ||||
| gboolean                        clutter_actor_get_resource_scale                (ClutterActor *self, | ||||
|                                                                                  gfloat       *resource_scale); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| gboolean                        clutter_actor_has_overlaps                      (ClutterActor               *self); | ||||
| @@ -595,13 +616,6 @@ void                            clutter_actor_set_content_repeat | ||||
|                                                                                  ClutterContentRepeat        repeat); | ||||
| CLUTTER_EXPORT | ||||
| ClutterContentRepeat            clutter_actor_get_content_repeat                (ClutterActor               *self); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void clutter_actor_set_color_state (ClutterActor      *self, | ||||
|                                     ClutterColorState *color_state); | ||||
| CLUTTER_EXPORT | ||||
| ClutterColorState *clutter_actor_get_color_state (ClutterActor *self); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_get_content_box                   (ClutterActor               *self, | ||||
|                                                                                  ClutterActorBox            *box); | ||||
| @@ -616,6 +630,8 @@ const ClutterPaintVolume *      clutter_actor_get_paint_volume | ||||
| CLUTTER_EXPORT | ||||
| const ClutterPaintVolume *      clutter_actor_get_transformed_paint_volume      (ClutterActor               *self, | ||||
|                                                                                  ClutterActor               *relative_to_ancestor); | ||||
| CLUTTER_EXPORT | ||||
| const ClutterPaintVolume *      clutter_actor_get_default_paint_volume          (ClutterActor               *self); | ||||
|  | ||||
| /* Events */ | ||||
| CLUTTER_EXPORT | ||||
| @@ -775,21 +791,16 @@ void                            clutter_actor_get_translation | ||||
|                                                                                  gfloat                     *translate_z); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_set_transform                     (ClutterActor               *self, | ||||
|                                                                                  const graphene_matrix_t    *transform); | ||||
|                                                                                  const ClutterMatrix        *transform); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_get_transform                     (ClutterActor               *self, | ||||
|                                                                                  graphene_matrix_t          *transform); | ||||
|                                                                                  ClutterMatrix              *transform); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_set_child_transform               (ClutterActor               *self, | ||||
|                                                                                  const graphene_matrix_t    *transform); | ||||
|                                                                                  const ClutterMatrix        *transform); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_get_child_transform               (ClutterActor               *self, | ||||
|                                                                                  graphene_matrix_t          *transform); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_get_transformed_extents          (ClutterActor               *self, | ||||
|                                                                                 graphene_rect_t            *rect); | ||||
|  | ||||
|                                                                                  ClutterMatrix              *transform); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_get_transformed_position          (ClutterActor               *self, | ||||
|                                                                                  gfloat                     *x, | ||||
| @@ -806,16 +817,16 @@ gboolean                        clutter_actor_transform_stage_point | ||||
|                                                                                  gfloat                     *y_out); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_get_abs_allocation_vertices       (ClutterActor               *self, | ||||
|                                                                                  graphene_point3d_t         *verts); | ||||
|                                                                                  ClutterVertex               verts[]); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_apply_transform_to_point          (ClutterActor               *self, | ||||
|                                                                                  const graphene_point3d_t   *point, | ||||
|                                                                                  graphene_point3d_t         *vertex); | ||||
|                                                                                  const ClutterVertex        *point, | ||||
|                                                                                  ClutterVertex              *vertex); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_apply_relative_transform_to_point (ClutterActor               *self, | ||||
|                                                                                  ClutterActor               *ancestor, | ||||
|                                                                                  const graphene_point3d_t   *point, | ||||
|                                                                                  graphene_point3d_t         *vertex); | ||||
|                                                                                  const ClutterVertex        *point, | ||||
|                                                                                  ClutterVertex              *vertex); | ||||
|  | ||||
| /* Implicit animations */ | ||||
| CLUTTER_EXPORT | ||||
| @@ -859,11 +870,6 @@ void                            clutter_actor_set_opacity_override | ||||
| CLUTTER_EXPORT | ||||
| gint                            clutter_actor_get_opacity_override              (ClutterActor               *self); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_inhibit_culling                   (ClutterActor               *actor); | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_actor_uninhibit_culling                 (ClutterActor               *actor); | ||||
|  | ||||
| /** | ||||
|  * ClutterActorCreateChildFunc: | ||||
|  * @item: (type GObject): the item in the model | ||||
| @@ -876,7 +882,9 @@ void                            clutter_actor_uninhibit_culling | ||||
|  * of interest, using g_object_bind_property(). This way, when the @item | ||||
|  * in the #GListModel changes, the #ClutterActor changes as well. | ||||
|  * | ||||
|  * Returns: (transfer full): The newly created child #ClutterActor4 | ||||
|  * Returns: (transfer full): The newly created child #ClutterActor | ||||
|  * | ||||
|  * Since: 1.24 | ||||
|  */ | ||||
| typedef ClutterActor * (* ClutterActorCreateChildFunc) (gpointer item, | ||||
|                                                         gpointer user_data); | ||||
| @@ -894,18 +902,6 @@ void                            clutter_actor_bind_model_with_properties | ||||
|                                                                                  const char                 *first_model_property, | ||||
|                                                                                  ...); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void clutter_actor_pick_box (ClutterActor          *self, | ||||
|                              ClutterPickContext    *pick_context, | ||||
|                              const ClutterActorBox *box); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| GList * clutter_actor_peek_stage_views (ClutterActor *self); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void clutter_actor_invalidate_transform (ClutterActor *self); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void clutter_actor_invalidate_paint_volume (ClutterActor *self); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_ACTOR_H__ */ | ||||
|   | ||||
| @@ -23,25 +23,27 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterAlignConstraint: | ||||
|  *  | ||||
|  * A constraint aligning the position of an actor | ||||
|  * SECTION:clutter-align-constraint | ||||
|  * @Title: ClutterAlignConstraint | ||||
|  * @Short_Description: A constraint aligning the position of an actor | ||||
|  * | ||||
|  * #ClutterAlignConstraint is a [class@Constraint] that aligns the position | ||||
|  * of the [class@Actor] to which it is applied to the size of another | ||||
|  * [class@Actor] using an alignment factor | ||||
|  * #ClutterAlignConstraint is a #ClutterConstraint that aligns the position | ||||
|  * of the #ClutterActor to which it is applied to the size of another | ||||
|  * #ClutterActor using an alignment factor | ||||
|  * | ||||
|  * #ClutterAlignConstraint is available since Clutter 1.4 | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-align-constraint.h" | ||||
| #include "clutter-align-constraint.h" | ||||
|  | ||||
| #include "clutter/clutter-actor-meta-private.h" | ||||
| #include "clutter/clutter-actor-private.h" | ||||
| #include "clutter/clutter-constraint.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-enum-types.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-actor-meta-private.h" | ||||
| #include "clutter-actor-private.h" | ||||
| #include "clutter-constraint.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-enum-types.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| #include <math.h> | ||||
|  | ||||
| @@ -56,7 +58,6 @@ struct _ClutterAlignConstraint | ||||
|   ClutterActor *actor; | ||||
|   ClutterActor *source; | ||||
|   ClutterAlignAxis align_axis; | ||||
|   graphene_point_t pivot; | ||||
|   gfloat factor; | ||||
| }; | ||||
|  | ||||
| @@ -71,7 +72,6 @@ enum | ||||
|  | ||||
|   PROP_SOURCE, | ||||
|   PROP_ALIGN_AXIS, | ||||
|   PROP_PIVOT_POINT, | ||||
|   PROP_FACTOR, | ||||
|  | ||||
|   PROP_LAST | ||||
| @@ -84,11 +84,13 @@ G_DEFINE_TYPE (ClutterAlignConstraint, | ||||
|                CLUTTER_TYPE_CONSTRAINT); | ||||
|  | ||||
| static void | ||||
| source_queue_relayout (ClutterActor           *actor, | ||||
|                        ClutterAlignConstraint *align) | ||||
| source_position_changed (ClutterActor           *actor, | ||||
|                          const ClutterActorBox  *allocation, | ||||
|                          ClutterAllocationFlags  flags, | ||||
|                          ClutterAlignConstraint *align) | ||||
| { | ||||
|   if (align->actor != NULL) | ||||
|     _clutter_actor_queue_only_relayout (align->actor); | ||||
|     clutter_actor_queue_relayout (align->actor); | ||||
| } | ||||
|  | ||||
| static void | ||||
| @@ -133,41 +135,35 @@ clutter_align_constraint_update_allocation (ClutterConstraint *constraint, | ||||
|   ClutterAlignConstraint *align = CLUTTER_ALIGN_CONSTRAINT (constraint); | ||||
|   gfloat source_width, source_height; | ||||
|   gfloat actor_width, actor_height; | ||||
|   gfloat offset_x_start, offset_y_start; | ||||
|   gfloat pivot_x, pivot_y; | ||||
|   gfloat source_x, source_y; | ||||
|  | ||||
|   if (align->source == NULL) | ||||
|     return; | ||||
|  | ||||
|   clutter_actor_box_get_size (allocation, &actor_width, &actor_height); | ||||
|  | ||||
|   clutter_actor_get_position (align->source, &source_x, &source_y); | ||||
|   clutter_actor_get_size (align->source, &source_width, &source_height); | ||||
|  | ||||
|   pivot_x = align->pivot.x == -1.f | ||||
|     ? align->factor | ||||
|     : align->pivot.x; | ||||
|   pivot_y = align->pivot.y == -1.f | ||||
|     ? align->factor | ||||
|     : align->pivot.y; | ||||
|  | ||||
|   offset_x_start = pivot_x * -actor_width; | ||||
|   offset_y_start = pivot_y * -actor_height; | ||||
|  | ||||
|   switch (align->align_axis) | ||||
|     { | ||||
|     case CLUTTER_ALIGN_X_AXIS: | ||||
|       allocation->x1 += offset_x_start + (source_width * align->factor); | ||||
|       allocation->x1 = ((source_width - actor_width) * align->factor) | ||||
|                      + source_x; | ||||
|       allocation->x2 = allocation->x1 + actor_width; | ||||
|       break; | ||||
|  | ||||
|     case CLUTTER_ALIGN_Y_AXIS: | ||||
|       allocation->y1 += offset_y_start + (source_height * align->factor); | ||||
|       allocation->y1 = ((source_height - actor_height) * align->factor) | ||||
|                      + source_y; | ||||
|       allocation->y2 = allocation->y1 + actor_height; | ||||
|       break; | ||||
|  | ||||
|     case CLUTTER_ALIGN_BOTH: | ||||
|       allocation->x1 += offset_x_start + (source_width * align->factor); | ||||
|       allocation->y1 += offset_y_start + (source_height * align->factor); | ||||
|       allocation->x1 = ((source_width - actor_width) * align->factor) | ||||
|                      + source_x; | ||||
|       allocation->y1 = ((source_height - actor_height) * align->factor) | ||||
|                      + source_y; | ||||
|       allocation->x2 = allocation->x1 + actor_width; | ||||
|       allocation->y2 = allocation->y1 + actor_height; | ||||
|       break; | ||||
| @@ -191,7 +187,7 @@ clutter_align_constraint_dispose (GObject *gobject) | ||||
|                                             G_CALLBACK (source_destroyed), | ||||
|                                             align); | ||||
|       g_signal_handlers_disconnect_by_func (align->source, | ||||
|                                             G_CALLBACK (source_queue_relayout), | ||||
|                                             G_CALLBACK (source_position_changed), | ||||
|                                             align); | ||||
|       align->source = NULL; | ||||
|     } | ||||
| @@ -217,10 +213,6 @@ clutter_align_constraint_set_property (GObject      *gobject, | ||||
|       clutter_align_constraint_set_align_axis (align, g_value_get_enum (value)); | ||||
|       break; | ||||
|  | ||||
|     case PROP_PIVOT_POINT: | ||||
|       clutter_align_constraint_set_pivot_point (align, g_value_get_boxed (value)); | ||||
|       break; | ||||
|  | ||||
|     case PROP_FACTOR: | ||||
|       clutter_align_constraint_set_factor (align, g_value_get_float (value)); | ||||
|       break; | ||||
| @@ -249,16 +241,6 @@ clutter_align_constraint_get_property (GObject    *gobject, | ||||
|       g_value_set_enum (value, align->align_axis); | ||||
|       break; | ||||
|  | ||||
|     case PROP_PIVOT_POINT: | ||||
|       { | ||||
|         graphene_point_t point; | ||||
|  | ||||
|         clutter_align_constraint_get_pivot_point (align, &point); | ||||
|  | ||||
|         g_value_set_boxed (value, &point); | ||||
|       } | ||||
|       break; | ||||
|  | ||||
|     case PROP_FACTOR: | ||||
|       g_value_set_float (value, align->factor); | ||||
|       break; | ||||
| @@ -287,9 +269,13 @@ clutter_align_constraint_class_init (ClutterAlignConstraintClass *klass) | ||||
|    * | ||||
|    * The #ClutterActor must not be a child or a grandchild of the actor | ||||
|    * using the constraint. | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   obj_props[PROP_SOURCE] = | ||||
|     g_param_spec_object ("source", NULL, NULL, | ||||
|     g_param_spec_object ("source", | ||||
|                            P_("Source"), | ||||
|                            P_("The source of the alignment"), | ||||
|                            CLUTTER_TYPE_ACTOR, | ||||
|                            CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT); | ||||
|  | ||||
| @@ -297,35 +283,17 @@ clutter_align_constraint_class_init (ClutterAlignConstraintClass *klass) | ||||
|    * ClutterAlignConstraint:align-axis: | ||||
|    * | ||||
|    * The axis to be used to compute the alignment | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   obj_props[PROP_ALIGN_AXIS] = | ||||
|     g_param_spec_enum ("align-axis", NULL, NULL, | ||||
|     g_param_spec_enum ("align-axis", | ||||
|                        P_("Align Axis"), | ||||
|                        P_("The axis to align the position to"), | ||||
|                        CLUTTER_TYPE_ALIGN_AXIS, | ||||
|                        CLUTTER_ALIGN_X_AXIS, | ||||
|                        CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT); | ||||
|  | ||||
|   /** | ||||
|    * ClutterAlignConstraint:pivot-point: | ||||
|    * | ||||
|    * The pivot point used by the constraint. The pivot point is the | ||||
|    * point in the constraint actor around which the aligning is applied, | ||||
|    * with (0, 0) being the top left corner of the actor and (1, 1) the | ||||
|    * bottom right corner of the actor. | ||||
|    * | ||||
|    * For example, setting the pivot point to (0.5, 0.5) and using a factor | ||||
|    * of 1 for both axes will align the actors horizontal and vertical | ||||
|    * center point with the bottom right corner of the source actor. | ||||
|    * | ||||
|    * By default, the pivot point is set to (-1, -1), which means it's not | ||||
|    * used and the constrained actor will be aligned to always stay inside | ||||
|    * the source actor. | ||||
|    */ | ||||
|   obj_props[PROP_PIVOT_POINT] = | ||||
|     g_param_spec_boxed ("pivot-point", NULL, NULL, | ||||
|                        GRAPHENE_TYPE_POINT, | ||||
|                        G_PARAM_READWRITE | | ||||
|                        G_PARAM_STATIC_STRINGS); | ||||
|  | ||||
|   /** | ||||
|    * ClutterAlignConstraint:factor: | ||||
|    * | ||||
| @@ -335,9 +303,13 @@ clutter_align_constraint_class_init (ClutterAlignConstraintClass *klass) | ||||
|    * with an align-axis value of %CLUTTER_ALIGN_X_AXIS, 0.0 means left and | ||||
|    * 1.0 means right; with a value of %CLUTTER_ALIGN_Y_AXIS, 0.0 means top | ||||
|    * and 1.0 means bottom. | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   obj_props[PROP_FACTOR] = | ||||
|     g_param_spec_float ("factor", NULL, NULL, | ||||
|     g_param_spec_float ("factor", | ||||
|                         P_("Factor"), | ||||
|                         P_("The alignment factor, between 0.0 and 1.0"), | ||||
|                         0.0, 1.0, | ||||
|                         0.0, | ||||
|                         CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT); | ||||
| @@ -354,8 +326,6 @@ clutter_align_constraint_init (ClutterAlignConstraint *self) | ||||
|   self->actor = NULL; | ||||
|   self->source = NULL; | ||||
|   self->align_axis = CLUTTER_ALIGN_X_AXIS; | ||||
|   self->pivot.x = -1.f; | ||||
|   self->pivot.y = -1.f; | ||||
|   self->factor = 0.0f; | ||||
| } | ||||
|  | ||||
| @@ -371,6 +341,8 @@ clutter_align_constraint_init (ClutterAlignConstraint *self) | ||||
|  * alignment @factor | ||||
|  * | ||||
|  * Return value: the newly created #ClutterAlignConstraint | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| ClutterConstraint * | ||||
| clutter_align_constraint_new (ClutterActor     *source, | ||||
| @@ -392,6 +364,8 @@ clutter_align_constraint_new (ClutterActor     *source, | ||||
|  * @source: (allow-none): a #ClutterActor, or %NULL to unset the source | ||||
|  * | ||||
|  * Sets the source of the alignment constraint | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_align_constraint_set_source (ClutterAlignConstraint *align, | ||||
| @@ -429,15 +403,15 @@ clutter_align_constraint_set_source (ClutterAlignConstraint *align, | ||||
|                                             G_CALLBACK (source_destroyed), | ||||
|                                             align); | ||||
|       g_signal_handlers_disconnect_by_func (old_source, | ||||
|                                             G_CALLBACK (source_queue_relayout), | ||||
|                                             G_CALLBACK (source_position_changed), | ||||
|                                             align); | ||||
|     } | ||||
|  | ||||
|   align->source = source; | ||||
|   if (align->source != NULL) | ||||
|     { | ||||
|       g_signal_connect (align->source, "queue-relayout", | ||||
|                         G_CALLBACK (source_queue_relayout), | ||||
|       g_signal_connect (align->source, "allocation-changed", | ||||
|                         G_CALLBACK (source_position_changed), | ||||
|                         align); | ||||
|       g_signal_connect (align->source, "destroy", | ||||
|                         G_CALLBACK (source_destroyed), | ||||
| @@ -458,6 +432,8 @@ clutter_align_constraint_set_source (ClutterAlignConstraint *align, | ||||
|  * | ||||
|  * Return value: (transfer none): the #ClutterActor used as the source | ||||
|  *   of the alignment | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| ClutterActor * | ||||
| clutter_align_constraint_get_source (ClutterAlignConstraint *align) | ||||
| @@ -473,6 +449,8 @@ clutter_align_constraint_get_source (ClutterAlignConstraint *align) | ||||
|  * @axis: the axis to which the alignment refers to | ||||
|  * | ||||
|  * Sets the axis to which the alignment refers to | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_align_constraint_set_align_axis (ClutterAlignConstraint *align, | ||||
| @@ -498,6 +476,8 @@ clutter_align_constraint_set_align_axis (ClutterAlignConstraint *align, | ||||
|  * Retrieves the value set using clutter_align_constraint_set_align_axis() | ||||
|  * | ||||
|  * Return value: the alignment axis | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| ClutterAlignAxis | ||||
| clutter_align_constraint_get_align_axis (ClutterAlignConstraint *align) | ||||
| @@ -508,60 +488,6 @@ clutter_align_constraint_get_align_axis (ClutterAlignConstraint *align) | ||||
|   return align->align_axis; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_align_constraint_set_pivot_point: | ||||
|  * @align: a #ClutterAlignConstraint | ||||
|  * @pivot_point: A #GraphenePoint | ||||
|  * | ||||
|  * Sets the pivot point used by the constraint, the pivot point is the | ||||
|  * point in the constraint actor around which the aligning is applied, | ||||
|  * with (0, 0) being the top left corner of the actor and (1, 1) the | ||||
|  * bottom right corner of the actor. | ||||
|  * | ||||
|  * If -1 is used, the pivot point is unset and the constrained actor | ||||
|  * will be aligned to always stay inside the source actor. | ||||
|  */ | ||||
| void | ||||
| clutter_align_constraint_set_pivot_point (ClutterAlignConstraint *align, | ||||
|                                           const graphene_point_t *pivot_point) | ||||
| { | ||||
|   g_return_if_fail (CLUTTER_IS_ALIGN_CONSTRAINT (align)); | ||||
|   g_return_if_fail (pivot_point != NULL); | ||||
|   g_return_if_fail (pivot_point->x == -1.f || | ||||
|                     (pivot_point->x >= 0.f && pivot_point->x <= 1.f)); | ||||
|   g_return_if_fail (pivot_point->y == -1.f || | ||||
|                     (pivot_point->y >= 0.f && pivot_point->y <= 1.f)); | ||||
|  | ||||
|   if (graphene_point_equal (&align->pivot, pivot_point)) | ||||
|     return; | ||||
|  | ||||
|   align->pivot = *pivot_point; | ||||
|  | ||||
|   if (align->actor != NULL) | ||||
|     clutter_actor_queue_relayout (align->actor); | ||||
|  | ||||
|   g_object_notify_by_pspec (G_OBJECT (align), obj_props[PROP_PIVOT_POINT]); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_align_constraint_get_pivot_point | ||||
|  * @align: a #ClutterAlignConstraint | ||||
|  * @pivot_point: (out caller-allocates): return location for a #GraphenePoint | ||||
|  * | ||||
|  * Gets the pivot point used by the constraint set with | ||||
|  * clutter_align_constraint_set_pivot_point(). If no custom pivot | ||||
|  * point is set, -1 is set. | ||||
|  */ | ||||
| void | ||||
| clutter_align_constraint_get_pivot_point (ClutterAlignConstraint *align, | ||||
|                                           graphene_point_t       *pivot_point) | ||||
| { | ||||
|   g_return_if_fail (CLUTTER_IS_ALIGN_CONSTRAINT (align)); | ||||
|   g_return_if_fail (pivot_point != NULL); | ||||
|  | ||||
|   *pivot_point = align->pivot; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_align_constraint_set_factor: | ||||
|  * @align: a #ClutterAlignConstraint | ||||
| @@ -578,6 +504,8 @@ clutter_align_constraint_get_pivot_point (ClutterAlignConstraint *align, | ||||
|  * meaning bottom, when #ClutterAlignConstraint:align-axis is set to | ||||
|  * %CLUTTER_ALIGN_Y_AXIS). A value of 0.5 aligns in the middle in either | ||||
|  * cases | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_align_constraint_set_factor (ClutterAlignConstraint *align, | ||||
| @@ -600,6 +528,8 @@ clutter_align_constraint_set_factor (ClutterAlignConstraint *align, | ||||
|  * Retrieves the factor set using clutter_align_constraint_set_factor() | ||||
|  * | ||||
|  * Return value: the alignment factor | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| gfloat | ||||
| clutter_align_constraint_get_factor (ClutterAlignConstraint *align) | ||||
|   | ||||
| @@ -22,13 +22,14 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_ALIGN_CONSTRAINT_H__ | ||||
| #define __CLUTTER_ALIGN_CONSTRAINT_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-constraint.h" | ||||
| #include <clutter/clutter-constraint.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -36,6 +37,14 @@ G_BEGIN_DECLS | ||||
| #define CLUTTER_ALIGN_CONSTRAINT(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ALIGN_CONSTRAINT, ClutterAlignConstraint)) | ||||
| #define CLUTTER_IS_ALIGN_CONSTRAINT(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ALIGN_CONSTRAINT)) | ||||
|  | ||||
| /** | ||||
|  * ClutterAlignConstraint: | ||||
|  * | ||||
|  * #ClutterAlignConstraint is an opaque structure | ||||
|  * whose members cannot be directly accesses | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| typedef struct _ClutterAlignConstraint          ClutterAlignConstraint; | ||||
| typedef struct _ClutterAlignConstraintClass     ClutterAlignConstraintClass; | ||||
|  | ||||
| @@ -58,15 +67,11 @@ void               clutter_align_constraint_set_align_axis (ClutterAlignConstrai | ||||
| CLUTTER_EXPORT | ||||
| ClutterAlignAxis   clutter_align_constraint_get_align_axis (ClutterAlignConstraint *align); | ||||
| CLUTTER_EXPORT | ||||
| void               clutter_align_constraint_set_pivot_point (ClutterAlignConstraint *align, | ||||
|                                                              const graphene_point_t *pivot_point); | ||||
| CLUTTER_EXPORT | ||||
| void               clutter_align_constraint_get_pivot_point (ClutterAlignConstraint *align, | ||||
|                                                              graphene_point_t       *pivot_point); | ||||
| CLUTTER_EXPORT | ||||
| void               clutter_align_constraint_set_factor     (ClutterAlignConstraint *align, | ||||
|                                                             gfloat                  factor); | ||||
| CLUTTER_EXPORT | ||||
| gfloat             clutter_align_constraint_get_factor     (ClutterAlignConstraint *align); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_ALIGN_CONSTRAINT_H__ */ | ||||
|   | ||||
| @@ -23,25 +23,39 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterAnimatable: | ||||
|  *  | ||||
|  * Interface for animatable classes | ||||
|  * SECTION:clutter-animatable | ||||
|  * @short_description: Interface for animatable classes | ||||
|  * | ||||
|  * #ClutterAnimatable is an interface that allows a [class@GObject.Object] class | ||||
|  * to control how an actor will animate a property. | ||||
|  * #ClutterAnimatable is an interface that allows a #GObject class | ||||
|  * to control how a #ClutterAnimation will animate a property. | ||||
|  * | ||||
|  * Each #ClutterAnimatable should implement the | ||||
|  * [vfunc@Animatable.interpolate_value] virtual function of the | ||||
|  * #ClutterAnimatableInterface.interpolate_property() virtual function of the | ||||
|  * interface to compute the animation state between two values of an interval | ||||
|  * depending on a progress factor, expressed as a floating point value. | ||||
|  * | ||||
|  * If a #ClutterAnimatable is animated by a #ClutterAnimation | ||||
|  * instance, the #ClutterAnimation will call | ||||
|  * clutter_animatable_interpolate_property() passing the name of the | ||||
|  * currently animated property; the values interval; and the progress factor. | ||||
|  * The #ClutterAnimatable implementation should return the computed value for | ||||
|  * the animated | ||||
|  * property. | ||||
|  * | ||||
|  * #ClutterAnimatable is available since Clutter 1.0 | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-animatable.h" | ||||
| #include "clutter/clutter-interval.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #define CLUTTER_DISABLE_DEPRECATION_WARNINGS | ||||
|  | ||||
| #include "clutter-animatable.h" | ||||
| #include "clutter-interval.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| #include "deprecated/clutter-animatable.h" | ||||
| #include "deprecated/clutter-animation.h" | ||||
|  | ||||
| G_DEFINE_INTERFACE (ClutterAnimatable, clutter_animatable, G_TYPE_OBJECT); | ||||
|  | ||||
| @@ -50,15 +64,91 @@ clutter_animatable_default_init (ClutterAnimatableInterface *iface) | ||||
| { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_animatable_animate_property: | ||||
|  * @animatable: a #ClutterAnimatable | ||||
|  * @animation: a #ClutterAnimation | ||||
|  * @property_name: the name of the animated property | ||||
|  * @initial_value: the initial value of the animation interval | ||||
|  * @final_value: the final value of the animation interval | ||||
|  * @progress: the progress factor | ||||
|  * @value: return location for the animation value | ||||
|  * | ||||
|  * Calls the animate_property() virtual function for @animatable. | ||||
|  * | ||||
|  * The @initial_value and @final_value #GValue<!-- -->s must contain | ||||
|  * the same type; @value must have been initialized to the same | ||||
|  * type of @initial_value and @final_value. | ||||
|  * | ||||
|  * All implementation of the #ClutterAnimatable interface must | ||||
|  * implement this function. | ||||
|  * | ||||
|  * Return value: %TRUE if the value has been validated and can | ||||
|  *   be applied to the #ClutterAnimatable, and %FALSE otherwise | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  * | ||||
|  * Deprecated: 1.8: Use clutter_animatable_interpolate_value() | ||||
|  *   instead | ||||
|  */ | ||||
| gboolean | ||||
| clutter_animatable_animate_property (ClutterAnimatable *animatable, | ||||
|                                      ClutterAnimation  *animation, | ||||
|                                      const gchar       *property_name, | ||||
|                                      const GValue      *initial_value, | ||||
|                                      const GValue      *final_value, | ||||
|                                      gdouble            progress, | ||||
|                                      GValue            *value) | ||||
| { | ||||
|   ClutterAnimatableInterface *iface; | ||||
|   gboolean res; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_ANIMATABLE (animatable), FALSE); | ||||
|   g_return_val_if_fail (CLUTTER_IS_ANIMATION (animation), FALSE); | ||||
|   g_return_val_if_fail (property_name != NULL, FALSE); | ||||
|   g_return_val_if_fail (initial_value != NULL && final_value != NULL, FALSE); | ||||
|   g_return_val_if_fail (G_VALUE_TYPE (initial_value) != G_TYPE_INVALID, FALSE); | ||||
|   g_return_val_if_fail (G_VALUE_TYPE (final_value) != G_TYPE_INVALID, FALSE); | ||||
|   g_return_val_if_fail (value != NULL, FALSE); | ||||
|   g_return_val_if_fail (G_VALUE_TYPE (value) == G_VALUE_TYPE (initial_value) && | ||||
|                         G_VALUE_TYPE (value) == G_VALUE_TYPE (final_value), | ||||
|                         FALSE); | ||||
|  | ||||
|   iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable); | ||||
|   if (iface->animate_property == NULL) | ||||
|     { | ||||
|       ClutterInterval *interval; | ||||
|  | ||||
|       interval = clutter_animation_get_interval (animation, property_name); | ||||
|       if (interval == NULL) | ||||
|         return FALSE; | ||||
|  | ||||
|       res = clutter_animatable_interpolate_value (animatable, property_name, | ||||
|                                                   interval, | ||||
|                                                   progress, | ||||
|                                                   value); | ||||
|     } | ||||
|   else | ||||
|     res = iface->animate_property (animatable, animation, | ||||
|                                    property_name, | ||||
|                                    initial_value, final_value, | ||||
|                                    progress, | ||||
|                                    value); | ||||
|  | ||||
|   return res; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_animatable_find_property: | ||||
|  * @animatable: a #ClutterAnimatable | ||||
|  * @property_name: the name of the animatable property to find | ||||
|  * | ||||
|  * Finds the [class@GObject.ParamSpec] for @property_name | ||||
|  * Finds the #GParamSpec for @property_name | ||||
|  * | ||||
|  * Return value: (transfer none): The #GParamSpec for the given property | ||||
|  *   or %NULL | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| GParamSpec * | ||||
| clutter_animatable_find_property (ClutterAnimatable *animatable, | ||||
| @@ -86,6 +176,8 @@ clutter_animatable_find_property (ClutterAnimatable *animatable, | ||||
|  * @value: a #GValue initialized to the type of the property to retrieve | ||||
|  * | ||||
|  * Retrieves the current state of @property_name and sets @value with it | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_animatable_get_initial_state (ClutterAnimatable *animatable, | ||||
| @@ -113,6 +205,8 @@ clutter_animatable_get_initial_state (ClutterAnimatable *animatable, | ||||
|  * @value: the value of the animatable property to set | ||||
|  * | ||||
|  * Sets the current state of @property_name to @value | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_animatable_set_final_state (ClutterAnimatable *animatable, | ||||
| @@ -149,12 +243,14 @@ clutter_animatable_set_final_state (ClutterAnimatable *animatable, | ||||
|  * value, and store the result inside @value. | ||||
|  * | ||||
|  * This function should be used for every property animation | ||||
|  * involving `ClutterAnimatable`s. | ||||
|  * involving #ClutterAnimatable<!-- -->s. | ||||
|  * | ||||
|  * This function replaces clutter_animatable_animate_property(). | ||||
|  * | ||||
|  * Return value: %TRUE if the interpolation was successful, | ||||
|  *   and %FALSE otherwise | ||||
|  * | ||||
|  * Since: 1.8 | ||||
|  */ | ||||
| gboolean | ||||
| clutter_animatable_interpolate_value (ClutterAnimatable *animatable, | ||||
| @@ -185,25 +281,3 @@ clutter_animatable_interpolate_value (ClutterAnimatable *animatable, | ||||
|   else | ||||
|     return clutter_interval_compute_value (interval, progress, value); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_animatable_get_actor: | ||||
|  * @animatable: a #ClutterAnimatable | ||||
|  * | ||||
|  * Get animated actor. | ||||
|  * | ||||
|  * Return value: (transfer none): a #ClutterActor | ||||
|  */ | ||||
| ClutterActor * | ||||
| clutter_animatable_get_actor (ClutterAnimatable *animatable) | ||||
| { | ||||
|   ClutterAnimatableInterface *iface; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_ANIMATABLE (animatable), NULL); | ||||
|  | ||||
|   iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable); | ||||
|  | ||||
|   g_return_val_if_fail (iface->get_actor, NULL); | ||||
|  | ||||
|   return iface->get_actor (animatable); | ||||
| } | ||||
|   | ||||
| @@ -22,13 +22,14 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_ANIMATABLE_H__ | ||||
| #define __CLUTTER_ANIMATABLE_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-types.h" | ||||
| #include <clutter/clutter-types.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -41,6 +42,8 @@ G_DECLARE_INTERFACE (ClutterAnimatable, clutter_animatable, | ||||
|  | ||||
| /** | ||||
|  * ClutterAnimatableInterface: | ||||
|  * @animate_property: virtual function for custom interpolation of a | ||||
|  *   property. This virtual function is deprecated | ||||
|  * @find_property: virtual function for retrieving the #GParamSpec of | ||||
|  *   an animatable property | ||||
|  * @get_initial_state: virtual function for retrieving the initial | ||||
| @@ -49,7 +52,11 @@ G_DECLARE_INTERFACE (ClutterAnimatable, clutter_animatable, | ||||
|  *   animatable property | ||||
|  * @interpolate_value: virtual function for interpolating the progress | ||||
|  *   of a property | ||||
|  * @get_actor: virtual function for getting associated actor | ||||
|  * | ||||
|  * Base interface for #GObject<!-- -->s that can be animated by a | ||||
|  * a #ClutterAnimation. | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| struct _ClutterAnimatableInterface | ||||
| { | ||||
| @@ -57,6 +64,13 @@ struct _ClutterAnimatableInterface | ||||
|   GTypeInterface parent_iface; | ||||
|  | ||||
|   /*< public >*/ | ||||
|   gboolean    (* animate_property)  (ClutterAnimatable *animatable, | ||||
|                                      ClutterAnimation  *animation, | ||||
|                                      const gchar       *property_name, | ||||
|                                      const GValue      *initial_value, | ||||
|                                      const GValue      *final_value, | ||||
|                                      gdouble            progress, | ||||
|                                      GValue            *value); | ||||
|   GParamSpec *(* find_property)     (ClutterAnimatable *animatable, | ||||
|                                      const gchar       *property_name); | ||||
|   void        (* get_initial_state) (ClutterAnimatable *animatable, | ||||
| @@ -70,7 +84,6 @@ struct _ClutterAnimatableInterface | ||||
|                                      ClutterInterval   *interval, | ||||
|                                      gdouble            progress, | ||||
|                                      GValue            *value); | ||||
|   ClutterActor * (* get_actor)      (ClutterAnimatable *animatable); | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| @@ -91,7 +104,6 @@ gboolean    clutter_animatable_interpolate_value (ClutterAnimatable *animatable, | ||||
|                                                   gdouble            progress, | ||||
|                                                   GValue            *value); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| ClutterActor * clutter_animatable_get_actor      (ClutterAnimatable *animatable); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_ANIMATABLE_H__ */ | ||||
|   | ||||
| @@ -21,7 +21,8 @@ | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_AUTO_CLEANUPS_H__ | ||||
| #define __CLUTTER_AUTO_CLEANUPS_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| @@ -29,7 +30,9 @@ | ||||
|  | ||||
| #ifndef __GI_SCANNER__ | ||||
|  | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterAction, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterActor, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterActorMeta, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterAlignConstraint, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBackend, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBindConstraint, g_object_unref) | ||||
| @@ -40,16 +43,22 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBoxLayout, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBrightnessContrastEffect, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterCanvas, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterChildMeta, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterClickAction, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterClone, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterColorizeEffect, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterConstraint, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterContainer, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDeformEffect, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDesaturateEffect, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDeviceManager, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDragAction, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDropAction, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterEffect, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterFixedLayout, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterFlowLayout, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterGestureAction, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterGridLayout, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterImage, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInputDevice, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInterval, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterKeyframeTransition, g_object_unref) | ||||
| @@ -81,9 +90,15 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterZoomAction, g_object_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterActorBox, clutter_actor_box_free) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterColor, clutter_color_free) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterMargin, clutter_margin_free) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPaintContext, clutter_paint_context_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterMatrix, clutter_matrix_free) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPaintNode, clutter_paint_node_unref) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPaintVolume, clutter_paint_volume_free) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPathNode, clutter_path_node_free) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPoint, clutter_point_free) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterRect, clutter_rect_free) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterSize, clutter_size_free) | ||||
| G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterVertex, clutter_vertex_free) | ||||
|  | ||||
| #endif /* __GI_SCANNER__ */ | ||||
|  | ||||
| #endif /* __CLUTTER_AUTO_CLEANUPS_H__ */ | ||||
|   | ||||
| @@ -19,11 +19,15 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_BACKEND_PRIVATE_H__ | ||||
| #define __CLUTTER_BACKEND_PRIVATE_H__ | ||||
|  | ||||
| #include "clutter/clutter-backend.h" | ||||
| #include "clutter/clutter-seat.h" | ||||
| #include "clutter/clutter-stage-window.h" | ||||
| #include <clutter/clutter-backend.h> | ||||
| #include <clutter/clutter-device-manager.h> | ||||
| #include <clutter/clutter-keymap.h> | ||||
| #include <clutter/clutter-stage-window.h> | ||||
|  | ||||
| #include "clutter-event-translator.h" | ||||
|  | ||||
| #define CLUTTER_BACKEND_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND, ClutterBackendClass)) | ||||
| #define CLUTTER_IS_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BACKEND)) | ||||
| @@ -45,6 +49,8 @@ struct _ClutterBackend | ||||
|  | ||||
|   CoglOnscreen *dummy_onscreen; | ||||
|  | ||||
|   ClutterDeviceManager *device_manager; | ||||
|  | ||||
|   cairo_font_options_t *font_options; | ||||
|  | ||||
|   gchar *font_name; | ||||
| @@ -52,11 +58,11 @@ struct _ClutterBackend | ||||
|   gfloat units_per_em; | ||||
|   gint32 units_serial; | ||||
|  | ||||
|   float fallback_resource_scale; | ||||
|  | ||||
|   ClutterStageWindow *stage_window; | ||||
|   GList *event_translators; | ||||
|  | ||||
|   ClutterInputMethod *input_method; | ||||
|  | ||||
|   ClutterKeymap *keymap; | ||||
| }; | ||||
|  | ||||
| struct _ClutterBackendClass | ||||
| @@ -65,11 +71,18 @@ struct _ClutterBackendClass | ||||
|   GObjectClass parent_class; | ||||
|  | ||||
|   /* vfuncs */ | ||||
|   gboolean              (* finish_init)        (ClutterBackend  *backend, | ||||
|   gboolean              (* pre_parse)          (ClutterBackend  *backend, | ||||
|                                                 GError         **error); | ||||
|   gboolean              (* post_parse)         (ClutterBackend  *backend, | ||||
|                                                 GError         **error); | ||||
|   ClutterStageWindow *  (* create_stage)       (ClutterBackend  *backend, | ||||
|                                                 ClutterStage    *wrapper, | ||||
|                                                 GError         **error); | ||||
|   void                  (* init_events)        (ClutterBackend  *backend); | ||||
|   void                  (* init_features)      (ClutterBackend  *backend); | ||||
|   void                  (* add_options)        (ClutterBackend  *backend, | ||||
|                                                 GOptionGroup    *group); | ||||
|   ClutterFeatureFlags   (* get_features)       (ClutterBackend  *backend); | ||||
|   CoglRenderer *        (* get_renderer)       (ClutterBackend  *backend, | ||||
|                                                 GError         **error); | ||||
|   CoglDisplay *         (* get_display)        (ClutterBackend  *backend, | ||||
| @@ -78,10 +91,23 @@ struct _ClutterBackendClass | ||||
|                                                 GError         **error); | ||||
|   gboolean              (* create_context)     (ClutterBackend  *backend, | ||||
|                                                 GError         **error); | ||||
|   ClutterDeviceManager *(* get_device_manager) (ClutterBackend  *backend); | ||||
|  | ||||
|   ClutterSeat *         (* get_default_seat)   (ClutterBackend *backend); | ||||
|   void                  (* copy_event_data)    (ClutterBackend     *backend, | ||||
|                                                 const ClutterEvent *src, | ||||
|                                                 ClutterEvent       *dest); | ||||
|   void                  (* free_event_data)    (ClutterBackend     *backend, | ||||
|                                                 ClutterEvent       *event); | ||||
|  | ||||
|   gboolean              (* is_display_server)  (ClutterBackend *backend); | ||||
|   gboolean              (* translate_event)    (ClutterBackend     *backend, | ||||
|                                                 gpointer            native, | ||||
|                                                 ClutterEvent       *event); | ||||
|  | ||||
|   PangoDirection        (* get_keymap_direction) (ClutterBackend   *backend); | ||||
|  | ||||
|   void                  (* bell_notify)          (ClutterBackend   *backend); | ||||
|  | ||||
|   ClutterKeymap *       (* get_keymap)           (ClutterBackend   *backend); | ||||
|  | ||||
|   /* signals */ | ||||
|   void (* resolution_changed) (ClutterBackend *backend); | ||||
| @@ -89,33 +115,51 @@ struct _ClutterBackendClass | ||||
|   void (* settings_changed)   (ClutterBackend *backend); | ||||
| }; | ||||
|  | ||||
| ClutterBackend *        _clutter_create_backend                         (void); | ||||
|  | ||||
| ClutterStageWindow *    _clutter_backend_create_stage                   (ClutterBackend         *backend, | ||||
|                                                                          ClutterStage           *wrapper, | ||||
|                                                                          GError                **error); | ||||
| gboolean                _clutter_backend_create_context                 (ClutterBackend         *backend, | ||||
|                                                                          GError                **error); | ||||
|  | ||||
| gboolean                _clutter_backend_finish_init                    (ClutterBackend         *backend, | ||||
| void                    _clutter_backend_add_options                    (ClutterBackend         *backend, | ||||
|                                                                          GOptionGroup           *group); | ||||
| gboolean                _clutter_backend_pre_parse                      (ClutterBackend         *backend, | ||||
|                                                                          GError                **error); | ||||
| gboolean                _clutter_backend_post_parse                     (ClutterBackend         *backend, | ||||
|                                                                          GError                **error); | ||||
|  | ||||
| void                    _clutter_backend_init_events                    (ClutterBackend         *backend); | ||||
| void                    _clutter_backend_copy_event_data                (ClutterBackend         *backend, | ||||
|                                                                          const ClutterEvent     *src, | ||||
|                                                                          ClutterEvent           *dest); | ||||
| void                    _clutter_backend_free_event_data                (ClutterBackend         *backend, | ||||
|                                                                          ClutterEvent           *event); | ||||
| gboolean                _clutter_backend_translate_event                (ClutterBackend         *backend, | ||||
|                                                                          gpointer                native, | ||||
|                                                                          ClutterEvent           *event); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void                    _clutter_backend_add_event_translator           (ClutterBackend         *backend, | ||||
|                                                                          ClutterEventTranslator *translator); | ||||
|  | ||||
| void                    _clutter_backend_remove_event_translator        (ClutterBackend         *backend, | ||||
|                                                                          ClutterEventTranslator *translator); | ||||
|  | ||||
| ClutterFeatureFlags     _clutter_backend_get_features                   (ClutterBackend         *backend); | ||||
|  | ||||
| gfloat                  _clutter_backend_get_units_per_em               (ClutterBackend         *backend, | ||||
|                                                                          PangoFontDescription   *font_desc); | ||||
| gint32                  _clutter_backend_get_units_serial               (ClutterBackend         *backend); | ||||
|  | ||||
| PangoDirection          _clutter_backend_get_keymap_direction           (ClutterBackend         *backend); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void                    _clutter_backend_reset_cogl_framebuffer         (ClutterBackend         *backend); | ||||
|  | ||||
| void                    clutter_set_allowed_drivers                     (const char             *drivers); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| ClutterStageWindow *    clutter_backend_get_stage_window                (ClutterBackend         *backend); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void clutter_backend_set_fallback_resource_scale (ClutterBackend *backend, | ||||
|                                                   float           fallback_resource_scale); | ||||
|  | ||||
| float clutter_backend_get_fallback_resource_scale (ClutterBackend *backend); | ||||
|  | ||||
| gboolean clutter_backend_is_display_server (ClutterBackend *backend); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void clutter_backend_destroy (ClutterBackend *backend); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_BACKEND_PRIVATE_H__ */ | ||||
|   | ||||
| @@ -25,9 +25,8 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterBackend: | ||||
|  *  | ||||
|  * Backend abstraction | ||||
|  * SECTION:clutter-backend | ||||
|  * @short_description: Backend abstraction | ||||
|  * | ||||
|  * Clutter can be compiled against different backends. Each backend | ||||
|  * has to implement a set of functions, in order to be used by Clutter. | ||||
| @@ -35,21 +34,46 @@ | ||||
|  * #ClutterBackend is the base class abstracting the various implementation; | ||||
|  * it provides a basic API to query the backend for generic information | ||||
|  * and settings. | ||||
|  * | ||||
|  * #ClutterBackend is available since Clutter 0.4 | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-backend-private.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-event-private.h" | ||||
| #include "clutter/clutter-marshal.h" | ||||
| #include "clutter/clutter-mutter.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter/clutter-stage-manager-private.h" | ||||
| #include "clutter/clutter-stage-private.h" | ||||
| #include "clutter/clutter-stage-window.h" | ||||
| #define CLUTTER_ENABLE_EXPERIMENTAL_API | ||||
|  | ||||
| #include "cogl/cogl.h" | ||||
| #include "clutter-backend-private.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-event-private.h" | ||||
| #include "clutter-marshal.h" | ||||
| #include "clutter-mutter.h" | ||||
| #include "clutter-private.h" | ||||
| #include "clutter-stage-manager-private.h" | ||||
| #include "clutter-stage-private.h" | ||||
| #include "clutter-stage-window.h" | ||||
| #include "clutter-device-manager-private.h" | ||||
|  | ||||
| #ifdef CLUTTER_HAS_WAYLAND_COMPOSITOR_SUPPORT | ||||
| #include "wayland/clutter-wayland-compositor.h" | ||||
| #endif | ||||
|  | ||||
| #include <cogl/cogl.h> | ||||
|  | ||||
| #ifdef CLUTTER_INPUT_X11 | ||||
| #include "x11/clutter-backend-x11.h" | ||||
| #endif | ||||
| #ifdef CLUTTER_INPUT_EVDEV | ||||
| #include "evdev/clutter-device-manager-evdev.h" | ||||
| #endif | ||||
| #ifdef CLUTTER_WINDOWING_EGL | ||||
| #include "egl/clutter-backend-eglnative.h" | ||||
| #endif | ||||
|  | ||||
| #ifdef CLUTTER_HAS_WAYLAND_COMPOSITOR_SUPPORT | ||||
| #include <cogl/cogl-wayland-server.h> | ||||
| #include <wayland-server.h> | ||||
| #include "wayland/clutter-wayland-compositor.h" | ||||
| #endif | ||||
|  | ||||
| #define DEFAULT_FONT_NAME       "Sans 10" | ||||
|  | ||||
| @@ -66,6 +90,12 @@ G_DEFINE_ABSTRACT_TYPE (ClutterBackend, clutter_backend, G_TYPE_OBJECT) | ||||
|  | ||||
| static guint backend_signals[LAST_SIGNAL] = { 0, }; | ||||
|  | ||||
| /* Global for being able to specify a compositor side wayland display | ||||
|  * pointer before clutter initialization */ | ||||
| #ifdef CLUTTER_HAS_WAYLAND_COMPOSITOR_SUPPORT | ||||
| static struct wl_display *_wayland_compositor_display; | ||||
| #endif | ||||
|  | ||||
| static void | ||||
| clutter_backend_dispose (GObject *gobject) | ||||
| { | ||||
| @@ -74,22 +104,28 @@ clutter_backend_dispose (GObject *gobject) | ||||
|   /* clear the events still in the queue of the main context */ | ||||
|   _clutter_clear_events_queue (); | ||||
|  | ||||
|   g_clear_object (&backend->dummy_onscreen); | ||||
|   if (backend->stage_window) | ||||
|     { | ||||
|       g_object_remove_weak_pointer (G_OBJECT (backend->stage_window), | ||||
|                                     (gpointer *) &backend->stage_window); | ||||
|       backend->stage_window = NULL; | ||||
|     } | ||||
|   /* remove all event translators */ | ||||
|   g_clear_pointer (&backend->event_translators, g_list_free); | ||||
|  | ||||
|   g_clear_pointer (&backend->cogl_source, g_source_destroy); | ||||
|   g_clear_pointer (&backend->font_name, g_free); | ||||
|   g_clear_pointer (&backend->font_options, cairo_font_options_destroy); | ||||
|   g_clear_object (&backend->input_method); | ||||
|   g_clear_pointer (&backend->dummy_onscreen, cogl_object_unref); | ||||
|  | ||||
|   G_OBJECT_CLASS (clutter_backend_parent_class)->dispose (gobject); | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_backend_finalize (GObject *gobject) | ||||
| { | ||||
|   ClutterBackend *backend = CLUTTER_BACKEND (gobject); | ||||
|  | ||||
|   g_source_destroy (backend->cogl_source); | ||||
|  | ||||
|   g_free (backend->font_name); | ||||
|   clutter_backend_set_font_options (backend, NULL); | ||||
|   g_clear_object (&backend->input_method); | ||||
|  | ||||
|   G_OBJECT_CLASS (clutter_backend_parent_class)->finalize (gobject); | ||||
| } | ||||
|  | ||||
| static gfloat | ||||
| get_units_per_em (ClutterBackend       *backend, | ||||
|                   PangoFontDescription *font_desc) | ||||
| @@ -188,20 +224,22 @@ clutter_backend_do_real_create_context (ClutterBackend  *backend, | ||||
| { | ||||
|   ClutterBackendClass *klass; | ||||
|   CoglSwapChain *swap_chain; | ||||
|   GError *internal_error; | ||||
|  | ||||
|   klass = CLUTTER_BACKEND_GET_CLASS (backend); | ||||
|  | ||||
|   swap_chain = NULL; | ||||
|   internal_error = NULL; | ||||
|  | ||||
|   CLUTTER_NOTE (BACKEND, "Creating Cogl renderer"); | ||||
|   backend->cogl_renderer = klass->get_renderer (backend, error); | ||||
|   backend->cogl_renderer = klass->get_renderer (backend, &internal_error); | ||||
|  | ||||
|   if (backend->cogl_renderer == NULL) | ||||
|     goto error; | ||||
|  | ||||
|   CLUTTER_NOTE (BACKEND, "Connecting the renderer"); | ||||
|   cogl_renderer_set_driver (backend->cogl_renderer, driver_id); | ||||
|   if (!cogl_renderer_connect (backend->cogl_renderer, error)) | ||||
|   if (!cogl_renderer_connect (backend->cogl_renderer, &internal_error)) | ||||
|     goto error; | ||||
|  | ||||
|   CLUTTER_NOTE (BACKEND, "Creating Cogl swap chain"); | ||||
| @@ -213,7 +251,7 @@ clutter_backend_do_real_create_context (ClutterBackend  *backend, | ||||
|       backend->cogl_display = klass->get_display (backend, | ||||
|                                                   backend->cogl_renderer, | ||||
|                                                   swap_chain, | ||||
|                                                   error); | ||||
|                                                   &internal_error); | ||||
|     } | ||||
|   else | ||||
|     { | ||||
| @@ -229,7 +267,7 @@ clutter_backend_do_real_create_context (ClutterBackend  *backend, | ||||
|        */ | ||||
|       res = cogl_renderer_check_onscreen_template (backend->cogl_renderer, | ||||
|                                                    tmpl, | ||||
|                                                    error); | ||||
|                                                    &internal_error); | ||||
|  | ||||
|       if (!res) | ||||
|         goto error; | ||||
| @@ -243,12 +281,17 @@ clutter_backend_do_real_create_context (ClutterBackend  *backend, | ||||
|   if (backend->cogl_display == NULL) | ||||
|     goto error; | ||||
|  | ||||
| #ifdef CLUTTER_HAS_WAYLAND_COMPOSITOR_SUPPORT | ||||
|   cogl_wayland_display_set_compositor_display (backend->cogl_display, | ||||
|                                                _wayland_compositor_display); | ||||
| #endif | ||||
|  | ||||
|   CLUTTER_NOTE (BACKEND, "Setting up the display"); | ||||
|   if (!cogl_display_setup (backend->cogl_display, error)) | ||||
|   if (!cogl_display_setup (backend->cogl_display, &internal_error)) | ||||
|     goto error; | ||||
|  | ||||
|   CLUTTER_NOTE (BACKEND, "Creating the Cogl context"); | ||||
|   backend->cogl_context = cogl_context_new (backend->cogl_display, error); | ||||
|   backend->cogl_context = cogl_context_new (backend->cogl_display, &internal_error); | ||||
|   if (backend->cogl_context == NULL) | ||||
|     goto error; | ||||
|  | ||||
| @@ -282,7 +325,8 @@ static const struct { | ||||
|   const char *driver_desc; | ||||
|   CoglDriver driver_id; | ||||
| } all_known_drivers[] = { | ||||
|   { "gl3", "OpenGL 3.1 core profile", COGL_DRIVER_GL3 }, | ||||
|   { "gl3", "OpenGL 3.2 core profile", COGL_DRIVER_GL3 }, | ||||
|   { "gl", "OpenGL legacy profile", COGL_DRIVER_GL }, | ||||
|   { "gles2", "OpenGL ES 2.0", COGL_DRIVER_GLES2 }, | ||||
|   { "any", "Default Cogl driver", COGL_DRIVER_ANY }, | ||||
| }; | ||||
| @@ -351,8 +395,9 @@ clutter_backend_real_create_context (ClutterBackend  *backend, | ||||
|       if (internal_error != NULL) | ||||
|         g_propagate_error (error, internal_error); | ||||
|       else | ||||
|         g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, | ||||
|                              "Unable to initialize the Clutter backend: no available drivers found."); | ||||
|         g_set_error_literal (error, CLUTTER_INIT_ERROR, | ||||
|                              CLUTTER_INIT_ERROR_BACKEND, | ||||
|                             _("Unable to initialize the Clutter backend: no available drivers found.")); | ||||
|  | ||||
|       return FALSE; | ||||
|     } | ||||
| @@ -363,62 +408,283 @@ clutter_backend_real_create_context (ClutterBackend  *backend, | ||||
|   return TRUE; | ||||
| } | ||||
|  | ||||
| static ClutterFeatureFlags | ||||
| clutter_backend_real_get_features (ClutterBackend *backend) | ||||
| { | ||||
|   ClutterFeatureFlags flags = 0; | ||||
|  | ||||
|   if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN)) | ||||
|     { | ||||
|       CLUTTER_NOTE (BACKEND, "Cogl supports multiple onscreen framebuffers"); | ||||
|       flags |= CLUTTER_FEATURE_STAGE_MULTIPLE; | ||||
|     } | ||||
|   else | ||||
|     { | ||||
|       CLUTTER_NOTE (BACKEND, "Cogl only supports one onscreen framebuffer"); | ||||
|       flags |= CLUTTER_FEATURE_STAGE_STATIC; | ||||
|     } | ||||
|  | ||||
|   if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_THROTTLE)) | ||||
|     { | ||||
|       CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers throttling"); | ||||
|       flags |= CLUTTER_FEATURE_SWAP_THROTTLE; | ||||
|     } | ||||
|   else | ||||
|     CLUTTER_NOTE (BACKEND, "Cogl doesn't support swap buffers throttling"); | ||||
|  | ||||
|   if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT)) | ||||
|     { | ||||
|       CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers complete events"); | ||||
|       flags |= CLUTTER_FEATURE_SWAP_EVENTS; | ||||
|     } | ||||
|  | ||||
|   return flags; | ||||
| } | ||||
|  | ||||
| static const char *allowed_backends; | ||||
|  | ||||
| static ClutterBackend * (* custom_backend_func) (void); | ||||
|  | ||||
| static const struct { | ||||
|   const char *name; | ||||
|   ClutterBackend * (* create_backend) (void); | ||||
| } available_backends[] = { | ||||
| #ifdef CLUTTER_WINDOWING_X11 | ||||
|   { CLUTTER_WINDOWING_X11, clutter_backend_x11_new }, | ||||
| #endif | ||||
| #ifdef CLUTTER_WINDOWING_EGL | ||||
|   { CLUTTER_WINDOWING_EGL, clutter_backend_egl_native_new }, | ||||
| #endif | ||||
|   { NULL, NULL }, | ||||
| }; | ||||
|  | ||||
| void | ||||
| clutter_set_custom_backend_func (ClutterBackend *(* func) (void)) | ||||
| { | ||||
|   custom_backend_func = func; | ||||
| } | ||||
|  | ||||
| ClutterBackend * | ||||
| _clutter_create_backend (void) | ||||
| { | ||||
|   const char *backends_list; | ||||
|   ClutterBackend *retval; | ||||
|   gboolean allow_any; | ||||
|   char **backends; | ||||
|   int i; | ||||
|  | ||||
|   if (custom_backend_func) | ||||
|     { | ||||
|       retval = custom_backend_func (); | ||||
|  | ||||
|       if (!retval) | ||||
|         g_error ("Failed to create custom backend."); | ||||
|  | ||||
|       return retval; | ||||
|     } | ||||
|  | ||||
|   if (allowed_backends == NULL) | ||||
|     allowed_backends = "*"; | ||||
|  | ||||
|   allow_any = strstr (allowed_backends, "*") != NULL; | ||||
|  | ||||
|   backends_list = g_getenv ("CLUTTER_BACKEND"); | ||||
|   if (backends_list == NULL) | ||||
|     backends_list = allowed_backends; | ||||
|  | ||||
|   backends = g_strsplit (backends_list, ",", 0); | ||||
|  | ||||
|   retval = NULL; | ||||
|  | ||||
|   for (i = 0; retval == NULL && backends[i] != NULL; i++) | ||||
|     { | ||||
|       const char *backend = backends[i]; | ||||
|       gboolean is_any = g_str_equal (backend, "*"); | ||||
|       int j; | ||||
|  | ||||
|       for (j = 0; available_backends[j].name != NULL; j++) | ||||
|         { | ||||
|           if ((is_any && allow_any) || | ||||
|               (is_any && strstr (allowed_backends, available_backends[j].name)) || | ||||
|               g_str_equal (backend, available_backends[j].name)) | ||||
|             { | ||||
|               retval = available_backends[j].create_backend (); | ||||
|               if (retval != NULL) | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   g_strfreev (backends); | ||||
|  | ||||
|   if (retval == NULL) | ||||
|     g_error ("No default Clutter backend found."); | ||||
|  | ||||
|   return retval; | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_backend_real_init_events (ClutterBackend *backend) | ||||
| { | ||||
|   const char *input_backend = NULL; | ||||
|  | ||||
|   input_backend = g_getenv ("CLUTTER_INPUT_BACKEND"); | ||||
|   if (input_backend != NULL) | ||||
|     input_backend = g_intern_string (input_backend); | ||||
|  | ||||
| #ifdef CLUTTER_INPUT_X11 | ||||
|   if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11) && | ||||
|       (input_backend == NULL || input_backend == I_(CLUTTER_INPUT_X11))) | ||||
|     { | ||||
|       _clutter_backend_x11_events_init (backend); | ||||
|     } | ||||
|   else | ||||
| #endif | ||||
| #ifdef CLUTTER_INPUT_EVDEV | ||||
|   /* Evdev can be used regardless of the windowing system */ | ||||
|   if ((input_backend != NULL && strcmp (input_backend, CLUTTER_INPUT_EVDEV) == 0) | ||||
| #ifdef CLUTTER_WINDOWING_EGL | ||||
|       /* but we do want to always use it for EGL native */ | ||||
|       || clutter_check_windowing_backend (CLUTTER_WINDOWING_EGL) | ||||
| #endif | ||||
|       ) | ||||
|     { | ||||
|       _clutter_events_evdev_init (backend); | ||||
|     } | ||||
|   else | ||||
| #endif | ||||
|   if (input_backend != NULL) | ||||
|     { | ||||
|       if (input_backend != I_(CLUTTER_INPUT_NULL)) | ||||
|         g_error ("Unrecognized input backend '%s'", input_backend); | ||||
|     } | ||||
|   else | ||||
|     g_error ("Unknown input backend"); | ||||
| } | ||||
|  | ||||
| static ClutterDeviceManager * | ||||
| clutter_backend_real_get_device_manager (ClutterBackend *backend) | ||||
| { | ||||
|   if (G_UNLIKELY (backend->device_manager == NULL)) | ||||
|     { | ||||
|       g_critical ("No device manager available, expect broken input"); | ||||
|       return NULL; | ||||
|     } | ||||
|  | ||||
|   return backend->device_manager; | ||||
| } | ||||
|  | ||||
| static ClutterKeymap * | ||||
| clutter_backend_real_get_keymap (ClutterBackend *backend) | ||||
| { | ||||
|   if (G_UNLIKELY (backend->keymap == NULL)) | ||||
|     { | ||||
|       g_critical ("No keymap available, expect broken keyboard input"); | ||||
|       return NULL; | ||||
|     } | ||||
|  | ||||
|   return backend->keymap; | ||||
| } | ||||
|  | ||||
| static gboolean | ||||
| clutter_backend_real_translate_event (ClutterBackend *backend, | ||||
|                                       gpointer        native, | ||||
|                                       ClutterEvent   *event) | ||||
| { | ||||
|   GList *l; | ||||
|  | ||||
|   for (l = backend->event_translators; | ||||
|        l != NULL; | ||||
|        l = l->next) | ||||
|     { | ||||
|       ClutterEventTranslator *translator = l->data; | ||||
|       ClutterTranslateReturn retval; | ||||
|  | ||||
|       retval = _clutter_event_translator_translate_event (translator, | ||||
|                                                           native, | ||||
|                                                           event); | ||||
|  | ||||
|       if (retval == CLUTTER_TRANSLATE_QUEUE) | ||||
|         return TRUE; | ||||
|  | ||||
|       if (retval == CLUTTER_TRANSLATE_REMOVE) | ||||
|         return FALSE; | ||||
|     } | ||||
|  | ||||
|   return FALSE; | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_backend_class_init (ClutterBackendClass *klass) | ||||
| { | ||||
|   GObjectClass *gobject_class = G_OBJECT_CLASS (klass); | ||||
|  | ||||
|   gobject_class->dispose = clutter_backend_dispose; | ||||
|   gobject_class->finalize = clutter_backend_finalize; | ||||
|  | ||||
|   /** | ||||
|    * ClutterBackend::resolution-changed: | ||||
|    * @backend: the #ClutterBackend that emitted the signal | ||||
|    * | ||||
|    * The signal is emitted each time the font | ||||
|    * The ::resolution-changed signal is emitted each time the font | ||||
|    * resolutions has been changed through #ClutterSettings. | ||||
|    * | ||||
|    * Since: 1.0 | ||||
|    */ | ||||
|   backend_signals[RESOLUTION_CHANGED] = | ||||
|     g_signal_new (I_("resolution-changed"), | ||||
|                   G_TYPE_FROM_CLASS (klass), | ||||
|                   G_SIGNAL_RUN_FIRST, | ||||
|                   G_STRUCT_OFFSET (ClutterBackendClass, resolution_changed), | ||||
|                   NULL, NULL, NULL, | ||||
|                   NULL, NULL, | ||||
|                   _clutter_marshal_VOID__VOID, | ||||
|                   G_TYPE_NONE, 0); | ||||
|  | ||||
|   /** | ||||
|    * ClutterBackend::font-changed: | ||||
|    * @backend: the #ClutterBackend that emitted the signal | ||||
|    * | ||||
|    * The signal is emitted each time the font options | ||||
|    * The ::font-changed signal is emitted each time the font options | ||||
|    * have been changed through #ClutterSettings. | ||||
|    * | ||||
|    * Since: 1.0 | ||||
|    */ | ||||
|   backend_signals[FONT_CHANGED] = | ||||
|     g_signal_new (I_("font-changed"), | ||||
|                   G_TYPE_FROM_CLASS (klass), | ||||
|                   G_SIGNAL_RUN_FIRST, | ||||
|                   G_STRUCT_OFFSET (ClutterBackendClass, font_changed), | ||||
|                   NULL, NULL, NULL, | ||||
|                   NULL, NULL, | ||||
|                   _clutter_marshal_VOID__VOID, | ||||
|                   G_TYPE_NONE, 0); | ||||
|  | ||||
|   /** | ||||
|    * ClutterBackend::settings-changed: | ||||
|    * @backend: the #ClutterBackend that emitted the signal | ||||
|    * | ||||
|    * The signal is emitted each time the #ClutterSettings | ||||
|    * The ::settings-changed signal is emitted each time the #ClutterSettings | ||||
|    * properties have been changed. | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   backend_signals[SETTINGS_CHANGED] = | ||||
|     g_signal_new (I_("settings-changed"), | ||||
|                   G_TYPE_FROM_CLASS (klass), | ||||
|                   G_SIGNAL_RUN_FIRST, | ||||
|                   G_STRUCT_OFFSET (ClutterBackendClass, settings_changed), | ||||
|                   NULL, NULL, NULL, | ||||
|                   NULL, NULL, | ||||
|                   _clutter_marshal_VOID__VOID, | ||||
|                   G_TYPE_NONE, 0); | ||||
|  | ||||
|   klass->resolution_changed = clutter_backend_real_resolution_changed; | ||||
|   klass->font_changed = clutter_backend_real_font_changed; | ||||
|  | ||||
|   klass->init_events = clutter_backend_real_init_events; | ||||
|   klass->get_device_manager = clutter_backend_real_get_device_manager; | ||||
|   klass->translate_event = clutter_backend_real_translate_event; | ||||
|   klass->create_context = clutter_backend_real_create_context; | ||||
|   klass->get_features = clutter_backend_real_get_features; | ||||
|   klass->get_keymap = clutter_backend_real_get_keymap; | ||||
| } | ||||
|  | ||||
| static void | ||||
| @@ -427,22 +693,48 @@ clutter_backend_init (ClutterBackend *self) | ||||
|   self->units_per_em = -1.0; | ||||
|   self->units_serial = 1; | ||||
|  | ||||
|   self->dummy_onscreen = NULL; | ||||
|  | ||||
|   self->fallback_resource_scale = 1.f; | ||||
|   self->dummy_onscreen = COGL_INVALID_HANDLE; | ||||
| } | ||||
|  | ||||
| gboolean | ||||
| _clutter_backend_finish_init (ClutterBackend  *backend, | ||||
|                               GError         **error) | ||||
| void | ||||
| _clutter_backend_add_options (ClutterBackend *backend, | ||||
|                               GOptionGroup   *group) | ||||
| { | ||||
|   ClutterBackendClass *klass; | ||||
|  | ||||
|   g_assert (CLUTTER_IS_BACKEND (backend)); | ||||
|  | ||||
|   klass = CLUTTER_BACKEND_GET_CLASS (backend); | ||||
|   if (klass->finish_init) | ||||
|     return klass->finish_init (backend, error); | ||||
|   if (klass->add_options) | ||||
|     klass->add_options (backend, group); | ||||
| } | ||||
|  | ||||
| gboolean | ||||
| _clutter_backend_pre_parse (ClutterBackend  *backend, | ||||
|                             GError         **error) | ||||
| { | ||||
|   ClutterBackendClass *klass; | ||||
|  | ||||
|   g_assert (CLUTTER_IS_BACKEND (backend)); | ||||
|  | ||||
|   klass = CLUTTER_BACKEND_GET_CLASS (backend); | ||||
|   if (klass->pre_parse) | ||||
|     return klass->pre_parse (backend, error); | ||||
|  | ||||
|   return TRUE; | ||||
| } | ||||
|  | ||||
| gboolean | ||||
| _clutter_backend_post_parse (ClutterBackend  *backend, | ||||
|                              GError         **error) | ||||
| { | ||||
|   ClutterBackendClass *klass; | ||||
|  | ||||
|   g_assert (CLUTTER_IS_BACKEND (backend)); | ||||
|  | ||||
|   klass = CLUTTER_BACKEND_GET_CLASS (backend); | ||||
|   if (klass->post_parse) | ||||
|     return klass->post_parse (backend, error); | ||||
|  | ||||
|   return TRUE; | ||||
| } | ||||
| @@ -469,10 +761,6 @@ _clutter_backend_create_stage (ClutterBackend  *backend, | ||||
|  | ||||
|   g_assert (CLUTTER_IS_STAGE_WINDOW (stage_window)); | ||||
|  | ||||
|   backend->stage_window = stage_window; | ||||
|   g_object_add_weak_pointer (G_OBJECT (backend->stage_window), | ||||
|                              (gpointer *) &backend->stage_window); | ||||
|  | ||||
|   return stage_window; | ||||
| } | ||||
|  | ||||
| @@ -487,6 +775,57 @@ _clutter_backend_create_context (ClutterBackend  *backend, | ||||
|   return klass->create_context (backend, error); | ||||
| } | ||||
|  | ||||
| ClutterFeatureFlags | ||||
| _clutter_backend_get_features (ClutterBackend *backend) | ||||
| { | ||||
|   ClutterBackendClass *klass; | ||||
|   GError *error; | ||||
|  | ||||
|   g_assert (CLUTTER_IS_BACKEND (backend)); | ||||
|  | ||||
|   klass = CLUTTER_BACKEND_GET_CLASS (backend); | ||||
|  | ||||
|   /* we need to have a context here; so we create the | ||||
|    * GL context first and the ask for features. if the | ||||
|    * context already exists this should be a no-op | ||||
|    */ | ||||
|   error = NULL; | ||||
|   if (klass->create_context != NULL) | ||||
|     { | ||||
|       gboolean res; | ||||
|  | ||||
|       res = klass->create_context (backend, &error); | ||||
|       if (!res) | ||||
|         { | ||||
|           if (error) | ||||
|             { | ||||
|               g_critical ("Unable to create a context: %s", error->message); | ||||
|               g_error_free (error); | ||||
|             } | ||||
|           else | ||||
|             g_critical ("Unable to create a context: unknown error"); | ||||
|  | ||||
|           return 0; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   if (klass->get_features) | ||||
|     return klass->get_features (backend); | ||||
|    | ||||
|   return 0; | ||||
| } | ||||
|  | ||||
| void | ||||
| _clutter_backend_init_events (ClutterBackend *backend) | ||||
| { | ||||
|   ClutterBackendClass *klass; | ||||
|  | ||||
|   g_assert (CLUTTER_IS_BACKEND (backend)); | ||||
|  | ||||
|   klass = CLUTTER_BACKEND_GET_CLASS (backend); | ||||
|   klass->init_events (backend); | ||||
| } | ||||
|  | ||||
| gfloat | ||||
| _clutter_backend_get_units_per_em (ClutterBackend       *backend, | ||||
|                                    PangoFontDescription *font_desc) | ||||
| @@ -501,6 +840,44 @@ _clutter_backend_get_units_per_em (ClutterBackend       *backend, | ||||
|   return backend->units_per_em; | ||||
| } | ||||
|  | ||||
| void | ||||
| _clutter_backend_copy_event_data (ClutterBackend     *backend, | ||||
|                                   const ClutterEvent *src, | ||||
|                                   ClutterEvent       *dest) | ||||
| { | ||||
|   ClutterEventExtenderInterface *iface; | ||||
|   ClutterBackendClass *klass; | ||||
|  | ||||
|   klass = CLUTTER_BACKEND_GET_CLASS (backend); | ||||
|   if (CLUTTER_IS_EVENT_EXTENDER (backend->device_manager)) | ||||
|     { | ||||
|       iface = CLUTTER_EVENT_EXTENDER_GET_IFACE (backend->device_manager); | ||||
|       iface->copy_event_data (CLUTTER_EVENT_EXTENDER (backend->device_manager), | ||||
|                               src, dest); | ||||
|     } | ||||
|   else if (klass->copy_event_data != NULL) | ||||
|     klass->copy_event_data (backend, src, dest); | ||||
| } | ||||
|  | ||||
| void | ||||
| _clutter_backend_free_event_data (ClutterBackend *backend, | ||||
|                                   ClutterEvent   *event) | ||||
| { | ||||
|   ClutterEventExtenderInterface *iface; | ||||
|   ClutterBackendClass *klass; | ||||
|  | ||||
|   klass = CLUTTER_BACKEND_GET_CLASS (backend); | ||||
|  | ||||
|   if (CLUTTER_IS_EVENT_EXTENDER (backend->device_manager)) | ||||
|     { | ||||
|       iface = CLUTTER_EVENT_EXTENDER_GET_IFACE (backend->device_manager); | ||||
|       iface->free_event_data (CLUTTER_EVENT_EXTENDER (backend->device_manager), | ||||
|                               event); | ||||
|     } | ||||
|   else if (klass->free_event_data != NULL) | ||||
|     klass->free_event_data (backend, event); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_get_default_backend: | ||||
|  * | ||||
| @@ -510,6 +887,8 @@ _clutter_backend_get_units_per_em (ClutterBackend       *backend, | ||||
|  * Return value: (transfer none): the default backend. You should | ||||
|  *   not ref or unref the returned object. Applications should rarely | ||||
|  *   need to use this. | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  */ | ||||
| ClutterBackend * | ||||
| clutter_get_default_backend (void) | ||||
| @@ -538,6 +917,8 @@ clutter_get_default_backend (void) | ||||
|  * | ||||
|  * Return value: the current resolution, or -1 if no resolution | ||||
|  *   has been set. | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  */ | ||||
| gdouble | ||||
| clutter_backend_get_resolution (ClutterBackend *backend) | ||||
| @@ -570,6 +951,8 @@ clutter_backend_get_resolution (ClutterBackend *backend) | ||||
|  * | ||||
|  * This function is intended for actors creating a Pango layout | ||||
|  * using the PangoCairo API. | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| void | ||||
| clutter_backend_set_font_options (ClutterBackend             *backend, | ||||
| @@ -600,6 +983,8 @@ clutter_backend_set_font_options (ClutterBackend             *backend, | ||||
|  * Return value: (transfer none): the font options of the #ClutterBackend. | ||||
|  *   The returned #cairo_font_options_t is owned by the backend and should | ||||
|  *   not be modified or freed | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| const cairo_font_options_t * | ||||
| clutter_backend_get_font_options (ClutterBackend *backend) | ||||
| @@ -626,8 +1011,40 @@ _clutter_backend_get_units_serial (ClutterBackend *backend) | ||||
|   return backend->units_serial; | ||||
| } | ||||
|  | ||||
| gboolean | ||||
| _clutter_backend_translate_event (ClutterBackend *backend, | ||||
|                                   gpointer        native, | ||||
|                                   ClutterEvent   *event) | ||||
| { | ||||
|   return CLUTTER_BACKEND_GET_CLASS (backend)->translate_event (backend, | ||||
|                                                                native, | ||||
|                                                                event); | ||||
| } | ||||
|  | ||||
| void | ||||
| _clutter_backend_add_event_translator (ClutterBackend         *backend, | ||||
|                                        ClutterEventTranslator *translator) | ||||
| { | ||||
|   if (g_list_find (backend->event_translators, translator) != NULL) | ||||
|     return; | ||||
|  | ||||
|   backend->event_translators = | ||||
|     g_list_prepend (backend->event_translators, translator); | ||||
| } | ||||
|  | ||||
| void | ||||
| _clutter_backend_remove_event_translator (ClutterBackend         *backend, | ||||
|                                           ClutterEventTranslator *translator) | ||||
| { | ||||
|   if (g_list_find (backend->event_translators, translator) == NULL) | ||||
|     return; | ||||
|  | ||||
|   backend->event_translators = | ||||
|     g_list_remove (backend->event_translators, translator); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_backend_get_cogl_context: | ||||
|  * clutter_backend_get_cogl_context: (skip) | ||||
|  * @backend: a #ClutterBackend | ||||
|  * | ||||
|  * Retrieves the #CoglContext associated with the given clutter | ||||
| @@ -642,6 +1059,9 @@ _clutter_backend_get_units_serial (ClutterBackend *backend) | ||||
|  * explicitly create a CoglContext. | ||||
|  * | ||||
|  * Return value: (transfer none): The #CoglContext associated with @backend. | ||||
|  * | ||||
|  * Since: 1.8 | ||||
|  * Stability: unstable | ||||
|  */ | ||||
| CoglContext * | ||||
| clutter_backend_get_cogl_context (ClutterBackend *backend) | ||||
| @@ -649,6 +1069,64 @@ clutter_backend_get_cogl_context (ClutterBackend *backend) | ||||
|   return backend->cogl_context; | ||||
| } | ||||
|  | ||||
| #ifdef CLUTTER_HAS_WAYLAND_COMPOSITOR_SUPPORT | ||||
| /** | ||||
|  * clutter_wayland_set_compositor_display: | ||||
|  * @display: A compositor side struct wl_display pointer | ||||
|  * | ||||
|  * This informs Clutter of your compositor side Wayland display | ||||
|  * object. This must be called before calling clutter_init(). | ||||
|  * | ||||
|  * Since: 1.8 | ||||
|  * Stability: unstable | ||||
|  */ | ||||
| void | ||||
| clutter_wayland_set_compositor_display (void *display) | ||||
| { | ||||
|   if (_clutter_context_is_initialized ()) | ||||
|     { | ||||
|       g_warning ("%s() can only be used before calling clutter_init()", | ||||
|                  G_STRFUNC); | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|   _wayland_compositor_display = display; | ||||
| } | ||||
| #endif | ||||
|  | ||||
| PangoDirection | ||||
| _clutter_backend_get_keymap_direction (ClutterBackend *backend) | ||||
| { | ||||
|   ClutterBackendClass *klass; | ||||
|  | ||||
|   klass = CLUTTER_BACKEND_GET_CLASS (backend); | ||||
|   if (klass->get_keymap_direction != NULL) | ||||
|     return klass->get_keymap_direction (backend); | ||||
|  | ||||
|   return PANGO_DIRECTION_NEUTRAL; | ||||
| } | ||||
|  | ||||
| void | ||||
| _clutter_backend_reset_cogl_framebuffer (ClutterBackend *backend) | ||||
| { | ||||
|   if (backend->dummy_onscreen == COGL_INVALID_HANDLE) | ||||
|     { | ||||
|       GError *internal_error = NULL; | ||||
|  | ||||
|       backend->dummy_onscreen = cogl_onscreen_new (backend->cogl_context, 1, 1); | ||||
|  | ||||
|       if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (backend->dummy_onscreen), | ||||
|                                       &internal_error)) | ||||
|         { | ||||
|           g_critical ("Unable to create dummy onscreen: %s", internal_error->message); | ||||
|           g_error_free (internal_error); | ||||
|           return; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   cogl_set_framebuffer (COGL_FRAMEBUFFER (backend->dummy_onscreen)); | ||||
| } | ||||
|  | ||||
| void | ||||
| clutter_set_allowed_drivers (const char *drivers) | ||||
| { | ||||
| @@ -661,6 +1139,16 @@ clutter_set_allowed_drivers (const char *drivers) | ||||
|   allowed_drivers = g_strdup (drivers); | ||||
| } | ||||
|  | ||||
| void | ||||
| clutter_backend_bell_notify (ClutterBackend *backend) | ||||
| { | ||||
|   ClutterBackendClass *klass; | ||||
|  | ||||
|   klass = CLUTTER_BACKEND_GET_CLASS (backend); | ||||
|   if (klass->bell_notify) | ||||
|     klass->bell_notify (backend); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_backend_get_input_method: | ||||
|  * @backend: the #CLutterBackend | ||||
| @@ -678,7 +1166,7 @@ clutter_backend_get_input_method (ClutterBackend *backend) | ||||
| /** | ||||
|  * clutter_backend_set_input_method: | ||||
|  * @backend: the #ClutterBackend | ||||
|  * @method: (nullable): the input method | ||||
|  * @method: the input method | ||||
|  * | ||||
|  * Sets the input method to be used by Clutter | ||||
|  **/ | ||||
| @@ -686,59 +1174,19 @@ void | ||||
| clutter_backend_set_input_method (ClutterBackend     *backend, | ||||
|                                   ClutterInputMethod *method) | ||||
| { | ||||
|   if (backend->input_method == method) | ||||
|     return; | ||||
|  | ||||
|   if (backend->input_method) | ||||
|     clutter_input_method_focus_out (backend->input_method); | ||||
|  | ||||
|   g_set_object (&backend->input_method, method); | ||||
| } | ||||
|  | ||||
| ClutterStageWindow * | ||||
| clutter_backend_get_stage_window (ClutterBackend *backend) | ||||
| { | ||||
|   return backend->stage_window; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_backend_get_default_seat: | ||||
|  * clutter_backend_get_keymap: | ||||
|  * @backend: the #ClutterBackend | ||||
|  * | ||||
|  * Returns the default seat | ||||
|  * Gets the keymap used by Clutter | ||||
|  * | ||||
|  * Returns: (transfer none): the default seat | ||||
|  * Returns: (transfer none): the keymap | ||||
|  **/ | ||||
| ClutterSeat * | ||||
| clutter_backend_get_default_seat (ClutterBackend *backend) | ||||
| ClutterKeymap * | ||||
| clutter_backend_get_keymap (ClutterBackend *backend) | ||||
| { | ||||
|   g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), NULL); | ||||
|  | ||||
|   return CLUTTER_BACKEND_GET_CLASS (backend)->get_default_seat (backend); | ||||
| } | ||||
|  | ||||
| void | ||||
| clutter_backend_set_fallback_resource_scale (ClutterBackend *backend, | ||||
|                                              float           fallback_resource_scale) | ||||
| { | ||||
|   backend->fallback_resource_scale = fallback_resource_scale; | ||||
| } | ||||
|  | ||||
| float | ||||
| clutter_backend_get_fallback_resource_scale (ClutterBackend *backend) | ||||
| { | ||||
|   return backend->fallback_resource_scale; | ||||
| } | ||||
|  | ||||
| gboolean | ||||
| clutter_backend_is_display_server (ClutterBackend *backend) | ||||
| { | ||||
|   return CLUTTER_BACKEND_GET_CLASS (backend)->is_display_server (backend); | ||||
| } | ||||
|  | ||||
| void | ||||
| clutter_backend_destroy (ClutterBackend *backend) | ||||
| { | ||||
|   g_object_run_dispose (G_OBJECT (backend)); | ||||
|   g_object_unref (backend); | ||||
|   return CLUTTER_BACKEND_GET_CLASS (backend)->get_keymap (backend); | ||||
| } | ||||
|   | ||||
| @@ -21,7 +21,8 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_BACKEND_H__ | ||||
| #define __CLUTTER_BACKEND_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| @@ -30,11 +31,11 @@ | ||||
| #include <cairo.h> | ||||
| #include <pango/pango.h> | ||||
|  | ||||
| #include "cogl/cogl.h" | ||||
| #include <cogl/cogl.h> | ||||
|  | ||||
| #include "clutter/clutter-keymap.h" | ||||
| #include "clutter/clutter-types.h" | ||||
| #include "clutter/clutter-seat.h" | ||||
| #include <clutter/clutter-config.h> | ||||
| #include <clutter/clutter-keymap.h> | ||||
| #include <clutter/clutter-types.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -42,6 +43,14 @@ G_BEGIN_DECLS | ||||
| #define CLUTTER_BACKEND(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND, ClutterBackend)) | ||||
| #define CLUTTER_IS_BACKEND(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND)) | ||||
|  | ||||
| /** | ||||
|  * ClutterBackend: | ||||
|  * | ||||
|  * #ClutterBackend is an opaque structure whose | ||||
|  * members cannot be directly accessed. | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  */ | ||||
| typedef struct _ClutterBackend          ClutterBackend; | ||||
| typedef struct _ClutterBackendClass     ClutterBackendClass; | ||||
|  | ||||
| @@ -63,6 +72,9 @@ const cairo_font_options_t *    clutter_backend_get_font_options        (Clutter | ||||
| CLUTTER_EXPORT | ||||
| CoglContext *                   clutter_backend_get_cogl_context        (ClutterBackend             *backend); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void                            clutter_backend_bell_notify             (ClutterBackend             *backend); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| ClutterInputMethod *            clutter_backend_get_input_method        (ClutterBackend             *backend); | ||||
|  | ||||
| @@ -70,6 +82,8 @@ CLUTTER_EXPORT | ||||
| void                            clutter_backend_set_input_method        (ClutterBackend             *backend, | ||||
|                                                                          ClutterInputMethod         *method); | ||||
| CLUTTER_EXPORT | ||||
| ClutterSeat *                   clutter_backend_get_default_seat        (ClutterBackend             *backend); | ||||
| ClutterKeymap *                 clutter_backend_get_keymap              (ClutterBackend             *backend); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_BACKEND_H__ */ | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -21,13 +21,12 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include <glib.h> | ||||
| #include <string.h> | ||||
|  | ||||
| #include "clutter/clutter-bezier.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter-bezier.h" | ||||
| #include "clutter-debug.h" | ||||
|  | ||||
| /* | ||||
|  * We have some experimental code here to allow for constant velocity | ||||
| @@ -36,7 +35,7 @@ | ||||
| #undef CBZ_L2T_INTERPOLATION | ||||
|  | ||||
| /**************************************************************************** | ||||
|  * ClutterBezier -- representation of a cubic bezier curve                   * | ||||
|  * ClutterBezier -- represenation of a cubic bezier curve                   * | ||||
|  * (private; a building block for the public bspline object)                * | ||||
|  ****************************************************************************/ | ||||
|  | ||||
| @@ -105,7 +104,7 @@ struct _ClutterBezier | ||||
| ClutterBezier * | ||||
| _clutter_bezier_new (void) | ||||
| { | ||||
|   return g_new0 (ClutterBezier, 1); | ||||
|   return g_slice_new0 (ClutterBezier); | ||||
| } | ||||
|  | ||||
| void | ||||
| @@ -113,7 +112,7 @@ _clutter_bezier_free (ClutterBezier * b) | ||||
| { | ||||
|   if (G_LIKELY (b)) | ||||
|     { | ||||
|       g_free (b); | ||||
|       g_slice_free (ClutterBezier, b); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -214,7 +213,7 @@ sqrti (int number) | ||||
|      * algorithm does not calculate the square root, but its reciprocal ('y' | ||||
|      * below), which is only at the end turned to the inverse value. In order | ||||
|      * for the algorithm to produce satisfactory results, the reciprocal value | ||||
|      * must be represented with sufficient precision; the 16.16 we use | ||||
|      * must be represented with sufficient precission; the 16.16 we use | ||||
|      * elsewhere in clutter is not good enough, and 10.22 is used instead. | ||||
|      */ | ||||
|     _FixedT x; | ||||
| @@ -237,7 +236,7 @@ sqrti (int number) | ||||
|     /* Now, we convert the float to 10.22 fixed. We exploit the mechanism | ||||
|      * described at http://www.d6.com/users/checker/pdfs/gdmfp.pdf. | ||||
|      * | ||||
|      * We want 22 bit fraction; a single precision float uses 23 bit | ||||
|      * We want 22 bit fraction; a single precission float uses 23 bit | ||||
|      * mantisa, so we only need to add 2^(23-22) (no need for the 1.5 | ||||
|      * multiplier as we are only dealing with positive numbers). | ||||
|      * | ||||
| @@ -257,7 +256,7 @@ sqrti (int number) | ||||
|     flt2.i = (flt2.i >> 11) * (y_1 >> 11); | ||||
|  | ||||
|     /* If the original argument is less than 342, we do another | ||||
|      * iteration to improve precision (for arguments >= 342, the single | ||||
|      * iteration to improve precission (for arguments >= 342, the single | ||||
|      * iteration produces generally better results). | ||||
|      */ | ||||
|     if (x < 171) | ||||
|   | ||||
| @@ -21,11 +21,11 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_BEZIER_H__ | ||||
| #define __CLUTTER_BEZIER_H__ | ||||
|  | ||||
| #include <glib.h> | ||||
|  | ||||
| #include "clutter/clutter-types.h" | ||||
| #include "clutter-types.h" | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -61,3 +61,5 @@ void           _clutter_bezier_adjust (ClutterBezier *b, | ||||
| guint          _clutter_bezier_get_length (const ClutterBezier *b); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_BEZIER_H__ */ | ||||
|   | ||||
| @@ -23,9 +23,8 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterBinLayout: | ||||
|  *  | ||||
|  * A simple layout manager | ||||
|  * SECTION:clutter-bin-layout | ||||
|  * @short_description: A simple layout manager | ||||
|  * | ||||
|  * #ClutterBinLayout is a layout manager which implements the following | ||||
|  * policy: | ||||
| @@ -40,23 +39,25 @@ | ||||
|  * | ||||
|  * The [bin-layout example](https://git.gnome.org/browse/clutter/tree/examples/bin-layout.c?h=clutter-1.18) | ||||
|  * shows how to pack actors inside a #ClutterBinLayout. | ||||
|  * | ||||
|  * #ClutterBinLayout is available since Clutter 1.2 | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include <math.h> | ||||
|  | ||||
| #define CLUTTER_DISABLE_DEPRECATION_WARNINGS | ||||
| #include "clutter/deprecated/clutter-container.h" | ||||
| #include "deprecated/clutter-container.h" | ||||
| #include "deprecated/clutter-bin-layout.h" | ||||
|  | ||||
| #include "clutter/clutter-actor-private.h" | ||||
| #include "clutter/clutter-animatable.h" | ||||
| #include "clutter/clutter-bin-layout.h" | ||||
| #include "clutter/clutter-child-meta.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-enum-types.h" | ||||
| #include "clutter/clutter-layout-meta.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-actor-private.h" | ||||
| #include "clutter-animatable.h" | ||||
| #include "clutter-child-meta.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-enum-types.h" | ||||
| #include "clutter-layout-meta.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| #define CLUTTER_TYPE_BIN_LAYER          (clutter_bin_layer_get_type ()) | ||||
| #define CLUTTER_BIN_LAYER(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BIN_LAYER, ClutterBinLayer)) | ||||
| @@ -213,13 +214,19 @@ clutter_bin_layer_class_init (ClutterBinLayerClass *klass) | ||||
|   gobject_class->get_property = clutter_bin_layer_get_property; | ||||
|  | ||||
|   layer_props[PROP_LAYER_X_ALIGN] = | ||||
|     g_param_spec_enum ("x-align", NULL, NULL, | ||||
|     g_param_spec_enum ("x-align", | ||||
|                        P_("Horizontal Alignment"), | ||||
|                        P_("Horizontal alignment for the actor " | ||||
|                           "inside the layout manager"), | ||||
|                        CLUTTER_TYPE_BIN_ALIGNMENT, | ||||
|                        CLUTTER_BIN_ALIGNMENT_CENTER, | ||||
|                        CLUTTER_PARAM_READWRITE); | ||||
|  | ||||
|   layer_props[PROP_LAYER_Y_ALIGN] = | ||||
|     g_param_spec_enum ("y-align", NULL, NULL, | ||||
|     g_param_spec_enum ("y-align", | ||||
|                        P_("Vertical Alignment"), | ||||
|                        P_("Vertical alignment for the actor " | ||||
|                           "inside the layout manager"), | ||||
|                        CLUTTER_TYPE_BIN_ALIGNMENT, | ||||
|                        CLUTTER_BIN_ALIGNMENT_CENTER, | ||||
|                        CLUTTER_PARAM_READWRITE); | ||||
| @@ -399,7 +406,8 @@ get_actor_align_factor (ClutterActorAlign alignment) | ||||
| static void | ||||
| clutter_bin_layout_allocate (ClutterLayoutManager   *manager, | ||||
|                              ClutterContainer       *container, | ||||
|                              const ClutterActorBox  *allocation) | ||||
|                              const ClutterActorBox  *allocation, | ||||
|                              ClutterAllocationFlags  flags) | ||||
| { | ||||
|   gfloat allocation_x, allocation_y; | ||||
|   gfloat available_w, available_h; | ||||
| @@ -507,7 +515,8 @@ clutter_bin_layout_allocate (ClutterLayoutManager   *manager, | ||||
|  | ||||
|       clutter_actor_allocate_align_fill (child, &child_alloc, | ||||
|                                          x_align, y_align, | ||||
|                                          x_fill, y_fill); | ||||
|                                          x_fill, y_fill, | ||||
|                                          flags); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -612,11 +621,16 @@ clutter_bin_layout_class_init (ClutterBinLayoutClass *klass) | ||||
|    * The default horizontal alignment policy for actors managed | ||||
|    * by the #ClutterBinLayout | ||||
|    * | ||||
|    * Since: 1.2 | ||||
|    * | ||||
|    * Deprecated: 1.12: Use the #ClutterActor:x-expand and the | ||||
|    *   #ClutterActor:x-align properties on #ClutterActor instead. | ||||
|    */ | ||||
|   bin_props[PROP_X_ALIGN] = | ||||
|     g_param_spec_enum ("x-align", NULL, NULL, | ||||
|     g_param_spec_enum ("x-align", | ||||
|                        P_("Horizontal Alignment"), | ||||
|                        P_("Default horizontal alignment for the actors " | ||||
|                           "inside the layout manager"), | ||||
|                        CLUTTER_TYPE_BIN_ALIGNMENT, | ||||
|                        CLUTTER_BIN_ALIGNMENT_CENTER, | ||||
|                        CLUTTER_PARAM_READWRITE); | ||||
| @@ -627,11 +641,16 @@ clutter_bin_layout_class_init (ClutterBinLayoutClass *klass) | ||||
|    * The default vertical alignment policy for actors managed | ||||
|    * by the #ClutterBinLayout | ||||
|    * | ||||
|    * Since: 1.2 | ||||
|    * | ||||
|    * Deprecated: 1.12: Use the #ClutterActor:y-expand and the | ||||
|    *   #ClutterActor:y-align properties on #ClutterActor instead. | ||||
|    */ | ||||
|   bin_props[PROP_Y_ALIGN] = | ||||
|     g_param_spec_enum ("y-align", NULL, NULL, | ||||
|     g_param_spec_enum ("y-align", | ||||
|                        P_("Vertical Alignment"), | ||||
|                        P_("Default vertical alignment for the actors " | ||||
|                           "inside the layout manager"), | ||||
|                        CLUTTER_TYPE_BIN_ALIGNMENT, | ||||
|                        CLUTTER_BIN_ALIGNMENT_CENTER, | ||||
|                        CLUTTER_PARAM_READWRITE); | ||||
| @@ -667,6 +686,8 @@ clutter_bin_layout_init (ClutterBinLayout *self) | ||||
|  * Creates a new #ClutterBinLayout layout manager | ||||
|  * | ||||
|  * Return value: the newly created layout manager | ||||
|  * | ||||
|  * Since: 1.2 | ||||
|  */ | ||||
| ClutterLayoutManager * | ||||
| clutter_bin_layout_new (ClutterBinAlignment x_align, | ||||
| @@ -677,3 +698,187 @@ clutter_bin_layout_new (ClutterBinAlignment x_align, | ||||
|                        "y-align", y_align, | ||||
|                        NULL); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_bin_layout_set_alignment: | ||||
|  * @self: a #ClutterBinLayout | ||||
|  * @child: (allow-none): a child of @container | ||||
|  * @x_align: the horizontal alignment policy to be used for the @child | ||||
|  *   inside @container | ||||
|  * @y_align: the vertical aligment policy to be used on the @child | ||||
|  *   inside @container | ||||
|  * | ||||
|  * Sets the horizontal and vertical alignment policies to be applied | ||||
|  * to a @child of @self | ||||
|  * | ||||
|  * If @child is %NULL then the @x_align and @y_align values will | ||||
|  * be set as the default alignment policies | ||||
|  * | ||||
|  * Since: 1.2 | ||||
|  * | ||||
|  * Deprecated: 1.12: Use the #ClutterActor:x-align and | ||||
|  *   #ClutterActor:y-align properties of #ClutterActor instead. | ||||
|  */ | ||||
| void | ||||
| clutter_bin_layout_set_alignment (ClutterBinLayout    *self, | ||||
|                                   ClutterActor        *child, | ||||
|                                   ClutterBinAlignment  x_align, | ||||
|                                   ClutterBinAlignment  y_align) | ||||
| { | ||||
|   ClutterBinLayoutPrivate *priv; | ||||
|   ClutterLayoutManager *manager; | ||||
|   ClutterLayoutMeta *meta; | ||||
|  | ||||
|   g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self)); | ||||
|   g_return_if_fail (child == NULL || CLUTTER_IS_ACTOR (child)); | ||||
|  | ||||
|   priv = self->priv; | ||||
|  | ||||
|   if (priv->container == NULL) | ||||
|     { | ||||
|       if (child == NULL) | ||||
|         { | ||||
|           set_x_align (self, x_align); | ||||
|           set_y_align (self, y_align); | ||||
|         } | ||||
|       else | ||||
|         g_warning ("The layout of type '%s' must be associated to " | ||||
|                    "a ClutterContainer before setting the alignment " | ||||
|                    "on its children", | ||||
|                    G_OBJECT_TYPE_NAME (self)); | ||||
|  | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|   manager = CLUTTER_LAYOUT_MANAGER (self); | ||||
|   meta = clutter_layout_manager_get_child_meta (manager, | ||||
|                                                 priv->container, | ||||
|                                                 child); | ||||
|   g_assert (CLUTTER_IS_BIN_LAYER (meta)); | ||||
|  | ||||
|   set_layer_x_align (CLUTTER_BIN_LAYER (meta), x_align); | ||||
|   set_layer_y_align (CLUTTER_BIN_LAYER (meta), y_align); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_bin_layout_get_alignment: | ||||
|  * @self: a #ClutterBinLayout | ||||
|  * @child: (allow-none): a child of @container | ||||
|  * @x_align: (out) (allow-none): return location for the horizontal | ||||
|  *   alignment policy | ||||
|  * @y_align: (out) (allow-none): return location for the vertical | ||||
|  *   alignment policy | ||||
|  * | ||||
|  * Retrieves the horizontal and vertical alignment policies for | ||||
|  * a child of @self | ||||
|  * | ||||
|  * If @child is %NULL the default alignment policies will be returned | ||||
|  * instead | ||||
|  * | ||||
|  * Since: 1.2 | ||||
|  * | ||||
|  * Deprecated: 1.12: Use the #ClutterActor:x-align and the | ||||
|  *   #ClutterActor:y-align properties of #ClutterActor instead. | ||||
|  */ | ||||
| void | ||||
| clutter_bin_layout_get_alignment (ClutterBinLayout    *self, | ||||
|                                   ClutterActor        *child, | ||||
|                                   ClutterBinAlignment *x_align, | ||||
|                                   ClutterBinAlignment *y_align) | ||||
| { | ||||
|   ClutterBinLayoutPrivate *priv; | ||||
|   ClutterLayoutManager *manager; | ||||
|   ClutterLayoutMeta *meta; | ||||
|   ClutterBinLayer *layer; | ||||
|  | ||||
|   g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self)); | ||||
|  | ||||
|   priv = self->priv; | ||||
|  | ||||
|   if (priv->container == NULL) | ||||
|     { | ||||
|       if (child == NULL) | ||||
|         { | ||||
|           if (x_align) | ||||
|             *x_align = priv->x_align; | ||||
|  | ||||
|           if (y_align) | ||||
|             *y_align = priv->y_align; | ||||
|         } | ||||
|       else | ||||
|         g_warning ("The layout of type '%s' must be associated to " | ||||
|                    "a ClutterContainer before getting the alignment " | ||||
|                    "of its children", | ||||
|                    G_OBJECT_TYPE_NAME (self)); | ||||
|  | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|   manager = CLUTTER_LAYOUT_MANAGER (self); | ||||
|   meta = clutter_layout_manager_get_child_meta (manager, | ||||
|                                                 priv->container, | ||||
|                                                 child); | ||||
|   g_assert (CLUTTER_IS_BIN_LAYER (meta)); | ||||
|  | ||||
|   layer = CLUTTER_BIN_LAYER (meta); | ||||
|  | ||||
|   if (x_align) | ||||
|     *x_align = layer->x_align; | ||||
|  | ||||
|   if (y_align) | ||||
|     *y_align = layer->y_align; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_bin_layout_add: | ||||
|  * @self: a #ClutterBinLayout | ||||
|  * @child: a #ClutterActor | ||||
|  * @x_align: horizontal alignment policy for @child | ||||
|  * @y_align: vertical alignment policy for @child | ||||
|  * | ||||
|  * Adds a #ClutterActor to the container using @self and | ||||
|  * sets the alignment policies for it | ||||
|  * | ||||
|  * This function is equivalent to clutter_container_add_actor() | ||||
|  * and clutter_layout_manager_child_set_property() but it does not | ||||
|  * require a pointer to the #ClutterContainer associated to the | ||||
|  * #ClutterBinLayout | ||||
|  * | ||||
|  * Since: 1.2 | ||||
|  * | ||||
|  * Deprecated: 1.12: Use clutter_actor_add_child() instead. | ||||
|  */ | ||||
| void | ||||
| clutter_bin_layout_add (ClutterBinLayout    *self, | ||||
|                         ClutterActor        *child, | ||||
|                         ClutterBinAlignment  x_align, | ||||
|                         ClutterBinAlignment  y_align) | ||||
| { | ||||
|   ClutterBinLayoutPrivate *priv; | ||||
|   ClutterLayoutManager *manager; | ||||
|   ClutterLayoutMeta *meta; | ||||
|  | ||||
|   g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self)); | ||||
|   g_return_if_fail (CLUTTER_IS_ACTOR (child)); | ||||
|  | ||||
|   priv = self->priv; | ||||
|  | ||||
|   if (priv->container == NULL) | ||||
|     { | ||||
|       g_warning ("The layout of type '%s' must be associated to " | ||||
|                  "a ClutterContainer before adding children", | ||||
|                  G_OBJECT_TYPE_NAME (self)); | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|   clutter_container_add_actor (priv->container, child); | ||||
|  | ||||
|   manager = CLUTTER_LAYOUT_MANAGER (self); | ||||
|   meta = clutter_layout_manager_get_child_meta (manager, | ||||
|                                                 priv->container, | ||||
|                                                 child); | ||||
|   g_assert (CLUTTER_IS_BIN_LAYER (meta)); | ||||
|  | ||||
|   set_layer_x_align (CLUTTER_BIN_LAYER (meta), x_align); | ||||
|   set_layer_y_align (CLUTTER_BIN_LAYER (meta), y_align); | ||||
| } | ||||
|   | ||||
| @@ -22,13 +22,14 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_BIN_LAYOUT_H__ | ||||
| #define __CLUTTER_BIN_LAYOUT_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-layout-manager.h" | ||||
| #include <clutter/clutter-layout-manager.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -43,6 +44,14 @@ typedef struct _ClutterBinLayout                ClutterBinLayout; | ||||
| typedef struct _ClutterBinLayoutPrivate         ClutterBinLayoutPrivate; | ||||
| typedef struct _ClutterBinLayoutClass           ClutterBinLayoutClass; | ||||
|  | ||||
| /** | ||||
|  * ClutterBinLayout: | ||||
|  * | ||||
|  * The #ClutterBinLayout structure contains only private data | ||||
|  * and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.2 | ||||
|  */ | ||||
| struct _ClutterBinLayout | ||||
| { | ||||
|   /*< private >*/ | ||||
| @@ -56,6 +65,8 @@ struct _ClutterBinLayout | ||||
|  * | ||||
|  * The #ClutterBinLayoutClass structure contains only private | ||||
|  * data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.2 | ||||
|  */ | ||||
| struct _ClutterBinLayoutClass | ||||
| { | ||||
| @@ -71,3 +82,5 @@ ClutterLayoutManager *  clutter_bin_layout_new  (ClutterBinAlignment x_align, | ||||
|                                                  ClutterBinAlignment y_align); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_BIN_LAYOUT_H__ */ | ||||
|   | ||||
| @@ -23,29 +23,27 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterBindConstraint: | ||||
|  *  | ||||
|  * A constraint binding the position or size of an actor | ||||
|  * SECTION:clutter-bind-constraint | ||||
|  * @Title: ClutterBindConstraint | ||||
|  * @Short_Description: A constraint binding the position or size of an actor | ||||
|  * | ||||
|  * #ClutterBindConstraint is a [class@Constraint] that binds the | ||||
|  * position or the size of the [class@Actor] to which it is applied | ||||
|  * to the the position or the size of another [class@Actor], or | ||||
|  * #ClutterBindConstraint is a #ClutterConstraint that binds the | ||||
|  * position or the size of the #ClutterActor to which it is applied | ||||
|  * to the the position or the size of another #ClutterActor, or | ||||
|  * "source". | ||||
|  * | ||||
|  * An offset can be applied to the constraint, to avoid overlapping. The offset | ||||
|  * can also be animated. For instance, the following code will set up three | ||||
|  * actors to be bound to the same origin: | ||||
|  * | ||||
|  * ```c | ||||
|  * |[<!-- language="C" --> | ||||
|  * // source | ||||
|  * rect[0] = clutter_actor_new (); | ||||
|  * clutter_actor_set_background_color (rect[0], &red_color); | ||||
|  * rect[0] = clutter_rectangle_new_with_color (&red_color); | ||||
|  * clutter_actor_set_position (rect[0], x_pos, y_pos); | ||||
|  * clutter_actor_set_size (rect[0], 100, 100); | ||||
|  * | ||||
|  * // second rectangle | ||||
|  * rect[1] = clutter_actor_new (); | ||||
|  * clutter_actor_set_background_color (rect[1], &green_color); | ||||
|  * rect[1] = clutter_rectangle_new_with_color (&green_color); | ||||
|  * clutter_actor_set_size (rect[1], 100, 100); | ||||
|  * clutter_actor_set_opacity (rect[1], 0); | ||||
|  * | ||||
| @@ -55,8 +53,7 @@ | ||||
|  * clutter_actor_add_constraint_with_name (rect[1], "green-y", constraint); | ||||
|  * | ||||
|  * // third rectangle | ||||
|  * rect[2] = clutter_actor_new (); | ||||
|  * clutter_actor_set_background_color (rect[2], &blue_color); | ||||
|  * rect[2] = clutter_rectangle_new_with_color (&blue_color); | ||||
|  * clutter_actor_set_size (rect[2], 100, 100); | ||||
|  * clutter_actor_set_opacity (rect[2], 0); | ||||
|  * | ||||
| @@ -64,12 +61,12 @@ | ||||
|  * clutter_actor_add_constraint_with_name (rect[2], "blue-x", constraint); | ||||
|  * constraint = clutter_bind_constraint_new (rect[0], CLUTTER_BIND_Y, 0.0); | ||||
|  * clutter_actor_add_constraint_with_name (rect[2], "blue-y", constraint); | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * The following code animates the second and third rectangles to "expand" | ||||
|  * them horizontally from underneath the first rectangle: | ||||
|  * | ||||
|  * ```c | ||||
|  * |[<!-- language="C" --> | ||||
|  * clutter_actor_animate (rect[1], CLUTTER_EASE_OUT_CUBIC, 250, | ||||
|  *                        "@constraints.green-x.offset", 100.0, | ||||
|  *                        "opacity", 255, | ||||
| @@ -78,21 +75,23 @@ | ||||
|  *                        "@constraints.blue-x.offset", 200.0, | ||||
|  *                        "opacity", 255, | ||||
|  *                        NULL); | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * #ClutterBindConstraint is available since Clutter 1.4 | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include <math.h> | ||||
|  | ||||
| #include "clutter/clutter-bind-constraint.h" | ||||
| #include "clutter-bind-constraint.h" | ||||
|  | ||||
| #include "clutter/clutter-actor-meta-private.h" | ||||
| #include "clutter/clutter-actor-private.h" | ||||
| #include "clutter/clutter-constraint.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-enum-types.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-actor-meta-private.h" | ||||
| #include "clutter-actor-private.h" | ||||
| #include "clutter-constraint.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-enum-types.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| #define CLUTTER_BIND_CONSTRAINT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BIND_CONSTRAINT, ClutterBindConstraintClass)) | ||||
| #define CLUTTER_IS_BIND_CONSTRAINT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BIND_CONSTRAINT)) | ||||
| @@ -145,58 +144,6 @@ source_destroyed (ClutterActor          *actor, | ||||
|   bind->source = NULL; | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_bind_constraint_update_preferred_size (ClutterConstraint  *constraint, | ||||
|                                                ClutterActor       *actor, | ||||
|                                                ClutterOrientation  direction, | ||||
|                                                float               for_size, | ||||
|                                                float              *minimum_size, | ||||
|                                                float              *natural_size) | ||||
| { | ||||
|   ClutterBindConstraint *bind = CLUTTER_BIND_CONSTRAINT (constraint); | ||||
|   float source_min, source_nat; | ||||
|  | ||||
|   if (bind->source == NULL) | ||||
|     return; | ||||
|  | ||||
|   /* only these bindings affect the preferred size */ | ||||
|   if (!(bind->coordinate == CLUTTER_BIND_WIDTH || | ||||
|         bind->coordinate == CLUTTER_BIND_HEIGHT || | ||||
|         bind->coordinate == CLUTTER_BIND_SIZE || | ||||
|         bind->coordinate == CLUTTER_BIND_ALL)) | ||||
|     return; | ||||
|  | ||||
|   if (clutter_actor_contains (bind->source, actor)) | ||||
|     return; | ||||
|  | ||||
|   switch (direction) | ||||
|     { | ||||
|     case CLUTTER_ORIENTATION_HORIZONTAL: | ||||
|       if (bind->coordinate != CLUTTER_BIND_HEIGHT) | ||||
|         { | ||||
|           clutter_actor_get_preferred_width (bind->source, for_size, | ||||
|                                              &source_min, | ||||
|                                              &source_nat); | ||||
|  | ||||
|           *minimum_size = source_min; | ||||
|           *natural_size = source_nat; | ||||
|         } | ||||
|       break; | ||||
|  | ||||
|     case CLUTTER_ORIENTATION_VERTICAL: | ||||
|       if (bind->coordinate != CLUTTER_BIND_WIDTH) | ||||
|         { | ||||
|           clutter_actor_get_preferred_height (bind->source, for_size, | ||||
|                                               &source_min, | ||||
|                                               &source_nat); | ||||
|  | ||||
|           *minimum_size = source_min; | ||||
|           *natural_size = source_nat; | ||||
|         } | ||||
|       break; | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_bind_constraint_update_allocation (ClutterConstraint *constraint, | ||||
|                                            ClutterActor      *actor, | ||||
| @@ -205,9 +152,7 @@ clutter_bind_constraint_update_allocation (ClutterConstraint *constraint, | ||||
|   ClutterBindConstraint *bind = CLUTTER_BIND_CONSTRAINT (constraint); | ||||
|   gfloat source_width, source_height; | ||||
|   gfloat actor_width, actor_height; | ||||
|   graphene_point3d_t source_position; | ||||
|  | ||||
|   source_position = GRAPHENE_POINT3D_INIT (0.f, 0.f, 0.f); | ||||
|   ClutterVertex source_position = { 0., }; | ||||
|  | ||||
|   if (bind->source == NULL) | ||||
|     return; | ||||
| @@ -381,8 +326,6 @@ clutter_bind_constraint_class_init (ClutterBindConstraintClass *klass) | ||||
|   meta_class->set_actor = clutter_bind_constraint_set_actor; | ||||
|  | ||||
|   constraint_class->update_allocation = clutter_bind_constraint_update_allocation; | ||||
|   constraint_class->update_preferred_size = clutter_bind_constraint_update_preferred_size; | ||||
|  | ||||
|   /** | ||||
|    * ClutterBindConstraint:source: | ||||
|    * | ||||
| @@ -390,9 +333,13 @@ clutter_bind_constraint_class_init (ClutterBindConstraintClass *klass) | ||||
|    * | ||||
|    * The #ClutterActor must not be contained inside the actor associated | ||||
|    * to the constraint. | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   obj_props[PROP_SOURCE] = | ||||
|     g_param_spec_object ("source", NULL, NULL, | ||||
|     g_param_spec_object ("source", | ||||
|                          P_("Source"), | ||||
|                          P_("The source of the binding"), | ||||
|                          CLUTTER_TYPE_ACTOR, | ||||
|                          CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT); | ||||
|  | ||||
| @@ -400,9 +347,13 @@ clutter_bind_constraint_class_init (ClutterBindConstraintClass *klass) | ||||
|    * ClutterBindConstraint:coordinate: | ||||
|    * | ||||
|    * The coordinate to be bound | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   obj_props[PROP_COORDINATE] = | ||||
|     g_param_spec_enum ("coordinate", NULL, NULL, | ||||
|     g_param_spec_enum ("coordinate", | ||||
|                        P_("Coordinate"), | ||||
|                        P_("The coordinate to bind"), | ||||
|                        CLUTTER_TYPE_BIND_COORDINATE, | ||||
|                        CLUTTER_BIND_X, | ||||
|                        CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT); | ||||
| @@ -411,9 +362,13 @@ clutter_bind_constraint_class_init (ClutterBindConstraintClass *klass) | ||||
|    * ClutterBindConstraint:offset: | ||||
|    * | ||||
|    * The offset, in pixels, to be applied to the binding | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   obj_props[PROP_OFFSET] = | ||||
|     g_param_spec_float ("offset", NULL, NULL, | ||||
|     g_param_spec_float ("offset", | ||||
|                         P_("Offset"), | ||||
|                         P_("The offset in pixels to apply to the binding"), | ||||
|                         -G_MAXFLOAT, G_MAXFLOAT, | ||||
|                         0.0f, | ||||
|                         CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT); | ||||
| @@ -443,6 +398,8 @@ clutter_bind_constraint_init (ClutterBindConstraint *self) | ||||
|  * the given @coordinate of the position of @source | ||||
|  * | ||||
|  * Return value: the newly created #ClutterBindConstraint | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| ClutterConstraint * | ||||
| clutter_bind_constraint_new (ClutterActor          *source, | ||||
| @@ -464,6 +421,8 @@ clutter_bind_constraint_new (ClutterActor          *source, | ||||
|  * @source: (allow-none): a #ClutterActor, or %NULL to unset the source | ||||
|  * | ||||
|  * Sets the source #ClutterActor for the constraint | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_bind_constraint_set_source (ClutterBindConstraint *constraint, | ||||
| @@ -529,6 +488,8 @@ clutter_bind_constraint_set_source (ClutterBindConstraint *constraint, | ||||
|  * Retrieves the #ClutterActor set using clutter_bind_constraint_set_source() | ||||
|  * | ||||
|  * Return value: (transfer none): a pointer to the source actor | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| ClutterActor * | ||||
| clutter_bind_constraint_get_source (ClutterBindConstraint *constraint) | ||||
| @@ -544,6 +505,8 @@ clutter_bind_constraint_get_source (ClutterBindConstraint *constraint) | ||||
|  * @coordinate: the coordinate to bind | ||||
|  * | ||||
|  * Sets the coordinate to bind in the constraint | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_bind_constraint_set_coordinate (ClutterBindConstraint *constraint, | ||||
| @@ -569,6 +532,8 @@ clutter_bind_constraint_set_coordinate (ClutterBindConstraint *constraint, | ||||
|  * Retrieves the bound coordinate of the constraint | ||||
|  * | ||||
|  * Return value: the bound coordinate | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| ClutterBindCoordinate | ||||
| clutter_bind_constraint_get_coordinate (ClutterBindConstraint *constraint) | ||||
| @@ -585,6 +550,8 @@ clutter_bind_constraint_get_coordinate (ClutterBindConstraint *constraint) | ||||
|  * @offset: the offset to apply, in pixels | ||||
|  * | ||||
|  * Sets the offset to be applied to the constraint | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_bind_constraint_set_offset (ClutterBindConstraint *constraint, | ||||
| @@ -610,6 +577,8 @@ clutter_bind_constraint_set_offset (ClutterBindConstraint *constraint, | ||||
|  * Retrieves the offset set using clutter_bind_constraint_set_offset() | ||||
|  * | ||||
|  * Return value: the offset, in pixels | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| gfloat | ||||
| clutter_bind_constraint_get_offset (ClutterBindConstraint *bind) | ||||
|   | ||||
| @@ -22,13 +22,14 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_BIND_CONSTRAINT_H__ | ||||
| #define __CLUTTER_BIND_CONSTRAINT_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-constraint.h" | ||||
| #include <clutter/clutter-constraint.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -36,6 +37,14 @@ G_BEGIN_DECLS | ||||
| #define CLUTTER_BIND_CONSTRAINT(obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BIND_CONSTRAINT, ClutterBindConstraint)) | ||||
| #define CLUTTER_IS_BIND_CONSTRAINT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BIND_CONSTRAINT)) | ||||
|  | ||||
| /** | ||||
|  * ClutterBindConstraint: | ||||
|  * | ||||
|  * #ClutterBindConstraint is an opaque structure | ||||
|  * whose members cannot be directly accessed | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| typedef struct _ClutterBindConstraint           ClutterBindConstraint; | ||||
| typedef struct _ClutterBindConstraintClass      ClutterBindConstraintClass; | ||||
|  | ||||
| @@ -64,3 +73,5 @@ CLUTTER_EXPORT | ||||
| gfloat                clutter_bind_constraint_get_offset     (ClutterBindConstraint *constraint); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_BIND_CONSTRAINT_H__ */ | ||||
|   | ||||
| @@ -22,9 +22,8 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterBindingPool | ||||
|  *  | ||||
|  * Pool for key bindings | ||||
|  * SECTION:clutter-binding-pool | ||||
|  * @short_description: Pool for key bindings | ||||
|  * | ||||
|  * #ClutterBindingPool is a data structure holding a set of key bindings. | ||||
|  * Each key binding associates a key symbol (eventually with modifiers) | ||||
| @@ -39,7 +38,7 @@ | ||||
|  * inside their class initialization function and then install actions | ||||
|  * like this: | ||||
|  * | ||||
|  * ```c | ||||
|  * |[<!-- language="C" --> | ||||
|  * static void | ||||
|  * foo_class_init (FooClass *klass) | ||||
|  * { | ||||
| @@ -56,23 +55,23 @@ | ||||
|  *                                        G_CALLBACK (foo_action_move_up), | ||||
|  *                                        NULL, NULL); | ||||
|  * } | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * The callback has a signature of: | ||||
|  * | ||||
|  * ```c | ||||
|  * |[<!-- language="C" --> | ||||
|  *    gboolean (* callback) (GObject             *instance, | ||||
|  *                           const gchar         *action_name, | ||||
|  *                           guint                key_val, | ||||
|  *                           ClutterModifierType  modifiers, | ||||
|  *                           gpointer             user_data); | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * The actor should then override the [signal@Actor::key-press-event] and | ||||
|  * use [method@BindingPool.activate] to match a [struct@Event] key event | ||||
|  * structure to one of the actions: | ||||
|  * The actor should then override the #ClutterActor::key-press-event and | ||||
|  * use clutter_binding_pool_activate() to match a #ClutterKeyEvent structure | ||||
|  * to one of the actions: | ||||
|  * | ||||
|  * ```c | ||||
|  * |[<!-- language="C" --> | ||||
|  *   ClutterBindingPool *pool; | ||||
|  * | ||||
|  *   // retrieve the binding pool for the type of the actor | ||||
| @@ -85,21 +84,23 @@ | ||||
|  *                                         key_event->keyval, | ||||
|  *                                         key_event->modifier_state, | ||||
|  *                                         G_OBJECT (actor)); | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * The [method@BindingPool.activate] function will return %FALSE if | ||||
|  * The clutter_binding_pool_activate() function will return %FALSE if | ||||
|  * no action for the given key binding was found, if the action was | ||||
|  * blocked (using [method@BindingPool.block_action]) or if the | ||||
|  * blocked (using clutter_binding_pool_block_action()) or if the | ||||
|  * key binding handler returned %FALSE. | ||||
|  * | ||||
|  * #ClutterBindingPool is available since Clutter 1.0 | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-binding-pool.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-enum-types.h" | ||||
| #include "clutter/clutter-marshal.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-binding-pool.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-enum-types.h" | ||||
| #include "clutter-marshal.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| #define CLUTTER_BINDING_POOL_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), CLUTTER_TYPE_BINDING_POOL, ClutterBindingPoolClass)) | ||||
| #define CLUTTER_IS_BINDING_POOL_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), CLUTTER_TYPE_BINDING_POOL)) | ||||
| @@ -188,7 +189,7 @@ binding_entry_new (const gchar         *name, | ||||
|  | ||||
|   modifiers = modifiers & BINDING_MOD_MASK; | ||||
|  | ||||
|   entry = g_new0 (ClutterBindingEntry, 1); | ||||
|   entry = g_slice_new (ClutterBindingEntry); | ||||
|   entry->key_val = key_val; | ||||
|   entry->modifiers = modifiers; | ||||
|   entry->name = (gchar *) g_intern_string (name); | ||||
| @@ -220,7 +221,7 @@ binding_entry_free (gpointer data) | ||||
|  | ||||
|       g_closure_unref (entry->closure); | ||||
|  | ||||
|       g_free (entry); | ||||
|       g_slice_free (ClutterBindingEntry, entry); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -306,9 +307,13 @@ clutter_binding_pool_class_init (ClutterBindingPoolClass *klass) | ||||
|    * ClutterBindingPool:name: | ||||
|    * | ||||
|    * The unique name of the #ClutterBindingPool. | ||||
|    * | ||||
|    * Since: 1.0 | ||||
|    */ | ||||
|   obj_props[PROP_NAME] = | ||||
|     g_param_spec_string ("name", NULL, NULL, | ||||
|     g_param_spec_string ("name", | ||||
|                          P_("Name"), | ||||
|                          P_("The unique name of the binding pool"), | ||||
|                          NULL, | ||||
|                          CLUTTER_PARAM_READWRITE | | ||||
|                          G_PARAM_CONSTRUCT_ONLY); | ||||
| @@ -340,6 +345,8 @@ clutter_binding_pool_init (ClutterBindingPool *pool) | ||||
|  * | ||||
|  * Return value: the newly created binding pool with the given | ||||
|  *   name. Use g_object_unref() when done. | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| ClutterBindingPool * | ||||
| clutter_binding_pool_new (const gchar *name) | ||||
| @@ -375,13 +382,15 @@ clutter_binding_pool_new (const gchar *name) | ||||
|  * A binding pool for a class can also be retrieved using | ||||
|  * clutter_binding_pool_find() with the class type name: | ||||
|  * | ||||
|  * ``` | ||||
|  * |[ | ||||
|  *   pool = clutter_binding_pool_find (G_OBJECT_TYPE_NAME (instance)); | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * Return value: (transfer none): the binding pool for the given class. | ||||
|  *   The returned #ClutterBindingPool is owned by Clutter and should not | ||||
|  *   be freed directly | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| ClutterBindingPool * | ||||
| clutter_binding_pool_get_for_class (gpointer klass) | ||||
| @@ -412,6 +421,8 @@ clutter_binding_pool_get_for_class (gpointer klass) | ||||
|  * Finds the #ClutterBindingPool with @name. | ||||
|  * | ||||
|  * Return value: (transfer none): a pointer to the #ClutterBindingPool, or %NULL | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| ClutterBindingPool * | ||||
| clutter_binding_pool_find (const gchar *name) | ||||
| @@ -454,6 +465,8 @@ clutter_binding_pool_find (const gchar *name) | ||||
|  * | ||||
|  * Actions can be blocked with clutter_binding_pool_block_action() | ||||
|  * and then unblocked using clutter_binding_pool_unblock_action(). | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_binding_pool_install_action (ClutterBindingPool  *pool, | ||||
| @@ -522,6 +535,8 @@ clutter_binding_pool_install_action (ClutterBindingPool  *pool, | ||||
|  * | ||||
|  * Actions can be blocked with clutter_binding_pool_block_action() | ||||
|  * and then unblocked using clutter_binding_pool_unblock_action(). | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_binding_pool_install_closure (ClutterBindingPool  *pool, | ||||
| @@ -583,6 +598,8 @@ clutter_binding_pool_install_closure (ClutterBindingPool  *pool, | ||||
|  * | ||||
|  * Actions can be blocked with clutter_binding_pool_block_action() | ||||
|  * and then unblocked using clutter_binding_pool_unblock_action(). | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_binding_pool_override_action (ClutterBindingPool  *pool, | ||||
| @@ -645,6 +662,8 @@ clutter_binding_pool_override_action (ClutterBindingPool  *pool, | ||||
|  * | ||||
|  * Actions can be blocked with clutter_binding_pool_block_action() | ||||
|  * and then unblocked using clutter_binding_pool_unblock_action(). | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_binding_pool_override_closure (ClutterBindingPool  *pool, | ||||
| @@ -698,6 +717,8 @@ clutter_binding_pool_override_closure (ClutterBindingPool  *pool, | ||||
|  * Return value: the name of the action, if found, or %NULL. The | ||||
|  *   returned string is owned by the binding pool and should never | ||||
|  *   be modified or freed | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| const gchar * | ||||
| clutter_binding_pool_find_action (ClutterBindingPool  *pool, | ||||
| @@ -724,6 +745,8 @@ clutter_binding_pool_find_action (ClutterBindingPool  *pool, | ||||
|  * | ||||
|  * Removes the action matching the given @key_val, @modifiers pair, | ||||
|  * if any exists. | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_binding_pool_remove_action (ClutterBindingPool  *pool, | ||||
| @@ -809,13 +832,13 @@ clutter_binding_entry_invoke (ClutterBindingEntry *entry, | ||||
|  * | ||||
|  * The callback has the following signature: | ||||
|  * | ||||
|  * ``` | ||||
|  * |[ | ||||
|  *   void (* callback) (GObject             *gobject, | ||||
|  *                      const gchar         *action_name, | ||||
|  *                      guint                key_val, | ||||
|  *                      ClutterModifierType  modifiers, | ||||
|  *                      gpointer             user_data); | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * Where the #GObject instance is @gobject and the user data | ||||
|  * is the one passed when installing the action with | ||||
| @@ -826,6 +849,8 @@ clutter_binding_entry_invoke (ClutterBindingEntry *entry, | ||||
|  * will not be invoked, and this function will return %FALSE. | ||||
|  * | ||||
|  * Return value: %TRUE if an action was found and was activated | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| gboolean | ||||
| clutter_binding_pool_activate (ClutterBindingPool  *pool, | ||||
| @@ -857,6 +882,8 @@ clutter_binding_pool_activate (ClutterBindingPool  *pool, | ||||
|  * @action_name: an action name | ||||
|  * | ||||
|  * Blocks all the actions with name @action_name inside @pool. | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_binding_pool_block_action (ClutterBindingPool *pool, | ||||
| @@ -886,6 +913,8 @@ clutter_binding_pool_block_action (ClutterBindingPool *pool, | ||||
|  * Unblocking an action does not cause the callback bound to it to | ||||
|  * be invoked in case clutter_binding_pool_activate() was called on | ||||
|  * an action previously blocked with clutter_binding_pool_block_action(). | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_binding_pool_unblock_action (ClutterBindingPool *pool, | ||||
|   | ||||
| @@ -21,15 +21,15 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_BINDING_POOL_H__ | ||||
| #define __CLUTTER_BINDING_POOL_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include <glib-object.h> | ||||
|  | ||||
| #include "clutter/clutter-event.h" | ||||
| #include <clutter/clutter-event.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -37,6 +37,14 @@ G_BEGIN_DECLS | ||||
| #define CLUTTER_BINDING_POOL(obj)       (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BINDING_POOL, ClutterBindingPool)) | ||||
| #define CLUTTER_IS_BINDING_POOL(obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BINDING_POOL)) | ||||
|  | ||||
| /** | ||||
|  * ClutterBindingPool: | ||||
|  * | ||||
|  * Container of key bindings. The #ClutterBindingPool struct is | ||||
|  * private. | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| typedef struct _ClutterBindingPool      ClutterBindingPool; | ||||
| typedef struct _ClutterBindingPoolClass ClutterBindingPoolClass; | ||||
|  | ||||
| @@ -54,6 +62,8 @@ typedef struct _ClutterBindingPoolClass ClutterBindingPoolClass; | ||||
|  * | ||||
|  * Return value: the function should return %TRUE if the key | ||||
|  *   binding has been handled, and return %FALSE otherwise | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| typedef gboolean (* ClutterBindingActionFunc) (GObject             *gobject, | ||||
|                                                const gchar         *action_name, | ||||
| @@ -121,3 +131,5 @@ void                  clutter_binding_pool_unblock_action   (ClutterBindingPool | ||||
|                                                              const gchar         *action_name); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_BINDING_POOL_H__ */ | ||||
|   | ||||
| @@ -23,27 +23,31 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterBlurEffect: | ||||
|  *  | ||||
|  * A blur effect | ||||
|  * SECTION:clutter-blur-effect | ||||
|  * @short_description: A blur effect | ||||
|  * @see_also: #ClutterEffect, #ClutterOffscreenEffect | ||||
|  * | ||||
|  * #ClutterBlurEffect is a sub-class of #ClutterEffect that allows blurring a | ||||
|  * actor and its contents. | ||||
|  * | ||||
|  * #ClutterBlurEffect is available since Clutter 1.4 | ||||
|  */ | ||||
|  | ||||
| #define CLUTTER_BLUR_EFFECT_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BLUR_EFFECT, ClutterBlurEffectClass)) | ||||
| #define CLUTTER_IS_BLUR_EFFECT_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BLUR_EFFECT)) | ||||
| #define CLUTTER_BLUR_EFFECT_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_BLUR_EFFECT, ClutterBlurEffectClass)) | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-blur-effect.h" | ||||
| #define CLUTTER_ENABLE_EXPERIMENTAL_API | ||||
|  | ||||
| #include "clutter-blur-effect.h" | ||||
|  | ||||
| #include "cogl/cogl.h" | ||||
|  | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-offscreen-effect.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-offscreen-effect.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| #define BLUR_PADDING    2 | ||||
|  | ||||
| @@ -77,6 +81,9 @@ struct _ClutterBlurEffect | ||||
|  | ||||
|   gint pixel_step_uniform; | ||||
|  | ||||
|   gint tex_width; | ||||
|   gint tex_height; | ||||
|  | ||||
|   CoglPipeline *pipeline; | ||||
| }; | ||||
|  | ||||
| @@ -91,33 +98,83 @@ G_DEFINE_TYPE (ClutterBlurEffect, | ||||
|                clutter_blur_effect, | ||||
|                CLUTTER_TYPE_OFFSCREEN_EFFECT); | ||||
|  | ||||
| static CoglPipeline * | ||||
| clutter_blur_effect_create_pipeline (ClutterOffscreenEffect *effect, | ||||
|                                      CoglTexture            *texture) | ||||
| static gboolean | ||||
| clutter_blur_effect_pre_paint (ClutterEffect *effect) | ||||
| { | ||||
|   ClutterBlurEffect *blur_effect = CLUTTER_BLUR_EFFECT (effect); | ||||
|   ClutterBlurEffect *self = CLUTTER_BLUR_EFFECT (effect); | ||||
|   ClutterEffectClass *parent_class; | ||||
|  | ||||
|   if (blur_effect->pixel_step_uniform > -1) | ||||
|   if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect))) | ||||
|     return FALSE; | ||||
|  | ||||
|   self->actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect)); | ||||
|   if (self->actor == NULL) | ||||
|     return FALSE; | ||||
|  | ||||
|   if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL)) | ||||
|     { | ||||
|       float pixel_step[2]; | ||||
|       int tex_width, tex_height; | ||||
|  | ||||
|       tex_width = cogl_texture_get_width (texture); | ||||
|       tex_height = cogl_texture_get_height (texture); | ||||
|  | ||||
|       pixel_step[0] = 1.0f / tex_width; | ||||
|       pixel_step[1] = 1.0f / tex_height; | ||||
|  | ||||
|       cogl_pipeline_set_uniform_float (blur_effect->pipeline, | ||||
|                                        blur_effect->pixel_step_uniform, | ||||
|                                        2, /* n_components */ | ||||
|                                        1, /* count */ | ||||
|                                        pixel_step); | ||||
|       /* if we don't have support for GLSL shaders then we | ||||
|        * forcibly disable the ActorMeta | ||||
|        */ | ||||
|       g_warning ("Unable to use the ShaderEffect: the graphics hardware " | ||||
|                  "or the current GL driver does not implement support " | ||||
|                  "for the GLSL shading language."); | ||||
|       clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (effect), FALSE); | ||||
|       return FALSE; | ||||
|     } | ||||
|  | ||||
|   cogl_pipeline_set_layer_texture (blur_effect->pipeline, 0, texture); | ||||
|   parent_class = CLUTTER_EFFECT_CLASS (clutter_blur_effect_parent_class); | ||||
|   if (parent_class->pre_paint (effect)) | ||||
|     { | ||||
|       ClutterOffscreenEffect *offscreen_effect = | ||||
|         CLUTTER_OFFSCREEN_EFFECT (effect); | ||||
|       CoglHandle texture; | ||||
|  | ||||
|   return cogl_object_ref (blur_effect->pipeline); | ||||
|       texture = clutter_offscreen_effect_get_texture (offscreen_effect); | ||||
|       self->tex_width = cogl_texture_get_width (texture); | ||||
|       self->tex_height = cogl_texture_get_height (texture); | ||||
|  | ||||
|       if (self->pixel_step_uniform > -1) | ||||
|         { | ||||
|           gfloat pixel_step[2]; | ||||
|  | ||||
|           pixel_step[0] = 1.0f / self->tex_width; | ||||
|           pixel_step[1] = 1.0f / self->tex_height; | ||||
|  | ||||
|           cogl_pipeline_set_uniform_float (self->pipeline, | ||||
|                                            self->pixel_step_uniform, | ||||
|                                            2, /* n_components */ | ||||
|                                            1, /* count */ | ||||
|                                            pixel_step); | ||||
|         } | ||||
|  | ||||
|       cogl_pipeline_set_layer_texture (self->pipeline, 0, texture); | ||||
|  | ||||
|       return TRUE; | ||||
|     } | ||||
|   else | ||||
|     return FALSE; | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_blur_effect_paint_target (ClutterOffscreenEffect *effect) | ||||
| { | ||||
|   ClutterBlurEffect *self = CLUTTER_BLUR_EFFECT (effect); | ||||
|   CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer (); | ||||
|   guint8 paint_opacity; | ||||
|  | ||||
|   paint_opacity = clutter_actor_get_paint_opacity (self->actor); | ||||
|  | ||||
|   cogl_pipeline_set_color4ub (self->pipeline, | ||||
|                               paint_opacity, | ||||
|                               paint_opacity, | ||||
|                               paint_opacity, | ||||
|                               paint_opacity); | ||||
|  | ||||
|   cogl_framebuffer_draw_rectangle (framebuffer, | ||||
|                                    self->pipeline, | ||||
|                                    0, 0, | ||||
|                                    self->tex_width, self->tex_height); | ||||
| } | ||||
|  | ||||
| static gboolean | ||||
| @@ -125,7 +182,7 @@ clutter_blur_effect_modify_paint_volume (ClutterEffect      *effect, | ||||
|                                          ClutterPaintVolume *volume) | ||||
| { | ||||
|   gfloat cur_width, cur_height; | ||||
|   graphene_point3d_t origin; | ||||
|   ClutterVertex origin; | ||||
|  | ||||
|   clutter_paint_volume_get_origin (volume, &origin); | ||||
|   cur_width = clutter_paint_volume_get_width (volume); | ||||
| @@ -165,10 +222,11 @@ clutter_blur_effect_class_init (ClutterBlurEffectClass *klass) | ||||
|  | ||||
|   gobject_class->dispose = clutter_blur_effect_dispose; | ||||
|  | ||||
|   effect_class->pre_paint = clutter_blur_effect_pre_paint; | ||||
|   effect_class->modify_paint_volume = clutter_blur_effect_modify_paint_volume; | ||||
|  | ||||
|   offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass); | ||||
|   offscreen_class->create_pipeline = clutter_blur_effect_create_pipeline; | ||||
|   offscreen_class->paint_target = clutter_blur_effect_paint_target; | ||||
| } | ||||
|  | ||||
| static void | ||||
| @@ -207,6 +265,8 @@ clutter_blur_effect_init (ClutterBlurEffect *self) | ||||
|  * clutter_actor_add_effect() | ||||
|  * | ||||
|  * Return value: the newly created #ClutterBlurEffect or %NULL | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| ClutterEffect * | ||||
| clutter_blur_effect_new (void) | ||||
|   | ||||
| @@ -22,13 +22,14 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_BLUR_EFFECT_H__ | ||||
| #define __CLUTTER_BLUR_EFFECT_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-effect.h" | ||||
| #include <clutter/clutter-effect.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -36,6 +37,14 @@ G_BEGIN_DECLS | ||||
| #define CLUTTER_BLUR_EFFECT(obj)        (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BLUR_EFFECT, ClutterBlurEffect)) | ||||
| #define CLUTTER_IS_BLUR_EFFECT(obj)     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BLUR_EFFECT)) | ||||
|  | ||||
| /** | ||||
|  * ClutterBlurEffect: | ||||
|  * | ||||
|  * #ClutterBlurEffect is an opaque structure | ||||
|  * whose members cannot be accessed directly | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| typedef struct _ClutterBlurEffect       ClutterBlurEffect; | ||||
| typedef struct _ClutterBlurEffectClass  ClutterBlurEffectClass; | ||||
|  | ||||
| @@ -46,3 +55,5 @@ CLUTTER_EXPORT | ||||
| ClutterEffect *clutter_blur_effect_new (void); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_BLUR_EFFECT_H__ */ | ||||
|   | ||||
| @@ -1,37 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (C) 2020 Endless OS Foundation, LLC | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include <glib-object.h> | ||||
|  | ||||
| #include "cogl/cogl.h" | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| typedef struct _ClutterBlur ClutterBlur; | ||||
|  | ||||
| ClutterBlur * clutter_blur_new (CoglTexture *texture, | ||||
|                                 float        sigma); | ||||
|  | ||||
| void clutter_blur_apply (ClutterBlur *blur); | ||||
|  | ||||
| CoglTexture * clutter_blur_get_texture (ClutterBlur *blur); | ||||
|  | ||||
| void clutter_blur_free (ClutterBlur *blur); | ||||
|  | ||||
| G_END_DECLS | ||||
| @@ -1,431 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (C) 2020 Endless OS Foundation, LLC | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-blur-private.h" | ||||
|  | ||||
| #include "clutter/clutter-backend.h" | ||||
|  | ||||
| /** | ||||
|  * SECTION:clutter-blur | ||||
|  * @short_description: Blur textures | ||||
|  * | ||||
|  * #ClutterBlur is a moderately fast gaussian blur implementation. | ||||
|  * | ||||
|  * # Optimizations | ||||
|  * | ||||
|  * There are a number of optimizations in place to make this blur implementation | ||||
|  * real-time. All in all, the implementation performs best when using large | ||||
|  * blur-radii that allow downscaling the texture to smaller sizes, at small | ||||
|  * radii where no downscaling is possible this can easily halve the framerate. | ||||
|  * | ||||
|  * ## Multipass | ||||
|  * | ||||
|  * It is implemented in 2 passes: vertical and horizontal. | ||||
|  * | ||||
|  * ## Downscaling | ||||
|  * | ||||
|  * #ClutterBlur uses dynamic downscaling to speed up blurring. Downscaling | ||||
|  * happens in factors of 2 (the image is downscaled either by 2, 4, 8, 16, …) | ||||
|  * and depends on the blur radius, the texture size, among others. | ||||
|  * | ||||
|  * The texture is drawn into a downscaled framebuffer; the blur passes are | ||||
|  * applied on the downscaled texture contents; and finally, the blurred | ||||
|  * contents are drawn | ||||
|  * upscaled again. | ||||
|  * | ||||
|  * ## Hardware Interpolation | ||||
|  * | ||||
|  * This blur implementation cuts down the number of sampling operations by | ||||
|  * exploiting the hardware interpolation that is performed when sampling between | ||||
|  * pixel boundaries. This technique is described at: | ||||
|  * | ||||
|  * http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/ | ||||
|  * | ||||
|  * ## Incremental gauss-factor calculation | ||||
|  * | ||||
|  * The kernel values for the gaussian kernel are computed incrementally instead | ||||
|  * of running the expensive calculations multiple times inside the blur shader. | ||||
|  * The implementation is based on the algorithm presented by K. Turkowski in | ||||
|  * GPU Gems 3, chapter 40: | ||||
|  * | ||||
|  * https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch40.html | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| static const char *gaussian_blur_glsl_declarations = | ||||
| "uniform float sigma;                                                      \n" | ||||
| "uniform float pixel_step;                                                 \n" | ||||
| "uniform vec2 direction;                                                   \n"; | ||||
|  | ||||
| static const char *gaussian_blur_glsl = | ||||
| "  vec2 uv = vec2 (cogl_tex_coord.st);                                     \n" | ||||
| "                                                                          \n" | ||||
| "  vec3 gauss_coefficient;                                                 \n" | ||||
| "  gauss_coefficient.x = 1.0 / (sqrt (2.0 * 3.14159265) * sigma);          \n" | ||||
| "  gauss_coefficient.y = exp (-0.5 / (sigma * sigma));                     \n" | ||||
| "  gauss_coefficient.z = gauss_coefficient.y * gauss_coefficient.y;        \n" | ||||
| "                                                                          \n" | ||||
| "  float gauss_coefficient_total = gauss_coefficient.x;                    \n" | ||||
| "                                                                          \n" | ||||
| "  vec4 ret = texture2D (cogl_sampler, uv) * gauss_coefficient.x;          \n" | ||||
| "  gauss_coefficient.xy *= gauss_coefficient.yz;                           \n" | ||||
| "                                                                          \n" | ||||
| "  int n_steps = int (ceil (1.5 * sigma)) * 2;                             \n" | ||||
| "                                                                          \n" | ||||
| "  for (int i = 1; i <= n_steps; i += 2) {                                 \n" | ||||
| "    float coefficient_subtotal = gauss_coefficient.x;                     \n" | ||||
| "    gauss_coefficient.xy *= gauss_coefficient.yz;                         \n" | ||||
| "    coefficient_subtotal += gauss_coefficient.x;                          \n" | ||||
| "                                                                          \n" | ||||
| "    float gauss_ratio = gauss_coefficient.x / coefficient_subtotal;       \n" | ||||
| "                                                                          \n" | ||||
| "    float foffset = float (i) + gauss_ratio;                              \n" | ||||
| "    vec2 offset = direction * foffset * pixel_step;                       \n" | ||||
| "                                                                          \n" | ||||
| "    ret += texture2D (cogl_sampler, uv + offset) * coefficient_subtotal;  \n" | ||||
| "    ret += texture2D (cogl_sampler, uv - offset) * coefficient_subtotal;  \n" | ||||
| "                                                                          \n" | ||||
| "    gauss_coefficient_total += 2.0 * coefficient_subtotal;                \n" | ||||
| "    gauss_coefficient.xy *= gauss_coefficient.yz;                         \n" | ||||
| "  }                                                                       \n" | ||||
| "                                                                          \n" | ||||
| "  cogl_texel = ret / gauss_coefficient_total;                             \n"; | ||||
|  | ||||
| #define MIN_DOWNSCALE_SIZE 256.f | ||||
| #define MAX_SIGMA 6.f | ||||
|  | ||||
| enum | ||||
| { | ||||
|   VERTICAL, | ||||
|   HORIZONTAL, | ||||
| }; | ||||
|  | ||||
| typedef struct | ||||
| { | ||||
|   CoglFramebuffer *framebuffer; | ||||
|   CoglPipeline *pipeline; | ||||
|   CoglTexture *texture; | ||||
|   int orientation; | ||||
| } BlurPass; | ||||
|  | ||||
| struct _ClutterBlur | ||||
| { | ||||
|   CoglTexture *source_texture; | ||||
|   float sigma; | ||||
|   float downscale_factor; | ||||
|  | ||||
|   BlurPass pass[2]; | ||||
| }; | ||||
|  | ||||
| static CoglPipeline* | ||||
| create_blur_pipeline (void) | ||||
| { | ||||
|   static CoglPipelineKey blur_pipeline_key = "clutter-blur-pipeline-private"; | ||||
|   CoglContext *ctx = | ||||
|     clutter_backend_get_cogl_context (clutter_get_default_backend ()); | ||||
|   CoglPipeline *blur_pipeline; | ||||
|  | ||||
|   blur_pipeline = | ||||
|     cogl_context_get_named_pipeline (ctx, &blur_pipeline_key); | ||||
|  | ||||
|   if (G_UNLIKELY (blur_pipeline == NULL)) | ||||
|     { | ||||
|       CoglSnippet *snippet; | ||||
|  | ||||
|       blur_pipeline = cogl_pipeline_new (ctx); | ||||
|       cogl_pipeline_set_layer_null_texture (blur_pipeline, 0); | ||||
|       cogl_pipeline_set_layer_filters (blur_pipeline, | ||||
|                                        0, | ||||
|                                        COGL_PIPELINE_FILTER_LINEAR, | ||||
|                                        COGL_PIPELINE_FILTER_LINEAR); | ||||
|       cogl_pipeline_set_layer_wrap_mode (blur_pipeline, | ||||
|                                          0, | ||||
|                                          COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE); | ||||
|  | ||||
|       snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP, | ||||
|                                   gaussian_blur_glsl_declarations, | ||||
|                                   NULL); | ||||
|       cogl_snippet_set_replace (snippet, gaussian_blur_glsl); | ||||
|       cogl_pipeline_add_layer_snippet (blur_pipeline, 0, snippet); | ||||
|       cogl_object_unref (snippet); | ||||
|  | ||||
|       cogl_context_set_named_pipeline (ctx, &blur_pipeline_key, blur_pipeline); | ||||
|     } | ||||
|  | ||||
|   return cogl_pipeline_copy (blur_pipeline); | ||||
| } | ||||
|  | ||||
| static void | ||||
| update_blur_uniforms (ClutterBlur *blur, | ||||
|                       BlurPass    *pass) | ||||
| { | ||||
|   gboolean vertical = pass->orientation == VERTICAL; | ||||
|   int sigma_uniform; | ||||
|   int pixel_step_uniform; | ||||
|   int direction_uniform; | ||||
|  | ||||
|   pixel_step_uniform = | ||||
|     cogl_pipeline_get_uniform_location (pass->pipeline, "pixel_step"); | ||||
|   if (pixel_step_uniform > -1) | ||||
|     { | ||||
|       float pixel_step; | ||||
|  | ||||
|       if (vertical) | ||||
|         pixel_step = 1.f / cogl_texture_get_height (pass->texture); | ||||
|       else | ||||
|         pixel_step = 1.f / cogl_texture_get_width (pass->texture); | ||||
|  | ||||
|       cogl_pipeline_set_uniform_1f (pass->pipeline, | ||||
|                                     pixel_step_uniform, | ||||
|                                     pixel_step); | ||||
|     } | ||||
|  | ||||
|   sigma_uniform = cogl_pipeline_get_uniform_location (pass->pipeline, "sigma"); | ||||
|   if (sigma_uniform > -1) | ||||
|     { | ||||
|       cogl_pipeline_set_uniform_1f (pass->pipeline, | ||||
|                                     sigma_uniform, | ||||
|                                     blur->sigma / blur->downscale_factor); | ||||
|     } | ||||
|  | ||||
|   direction_uniform = | ||||
|     cogl_pipeline_get_uniform_location (pass->pipeline, "direction"); | ||||
|   if (direction_uniform > -1) | ||||
|     { | ||||
|       gboolean horizontal = !vertical; | ||||
|       float direction[2] = { | ||||
|         horizontal, | ||||
|         vertical, | ||||
|       }; | ||||
|  | ||||
|       cogl_pipeline_set_uniform_float (pass->pipeline, | ||||
|                                        direction_uniform, | ||||
|                                        2, 1, | ||||
|                                        direction); | ||||
|     } | ||||
| } | ||||
|  | ||||
| static gboolean | ||||
| create_fbo (ClutterBlur *blur, | ||||
|             BlurPass    *pass) | ||||
| { | ||||
|   CoglContext *ctx = | ||||
|     clutter_backend_get_cogl_context (clutter_get_default_backend ()); | ||||
|   float scaled_height; | ||||
|   float scaled_width; | ||||
|   float height; | ||||
|   float width; | ||||
|  | ||||
|   g_clear_pointer (&pass->texture, cogl_object_unref); | ||||
|   g_clear_object (&pass->framebuffer); | ||||
|  | ||||
|   width = cogl_texture_get_width (blur->source_texture); | ||||
|   height = cogl_texture_get_height (blur->source_texture); | ||||
|   scaled_width = floorf (width / blur->downscale_factor); | ||||
|   scaled_height = floorf (height / blur->downscale_factor); | ||||
|  | ||||
|   pass->texture = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, | ||||
|                                                                scaled_width, | ||||
|                                                                scaled_height)); | ||||
|   if (!pass->texture) | ||||
|     return FALSE; | ||||
|  | ||||
|   pass->framebuffer = | ||||
|     COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (pass->texture)); | ||||
|   if (!pass->framebuffer) | ||||
|     { | ||||
|       g_warning ("%s: Unable to create an Offscreen buffer", G_STRLOC); | ||||
|       return FALSE; | ||||
|     } | ||||
|  | ||||
|   cogl_framebuffer_orthographic (pass->framebuffer, | ||||
|                                  0.0, 0.0, | ||||
|                                  scaled_width, | ||||
|                                  scaled_height, | ||||
|                                  0.0, 1.0); | ||||
|   return TRUE; | ||||
| } | ||||
|  | ||||
| static gboolean | ||||
| setup_blur_pass (ClutterBlur *blur, | ||||
|                  BlurPass    *pass, | ||||
|                  int          orientation, | ||||
|                  CoglTexture *texture) | ||||
| { | ||||
|   pass->orientation = orientation; | ||||
|   pass->pipeline = create_blur_pipeline (); | ||||
|   cogl_pipeline_set_layer_texture (pass->pipeline, 0, texture); | ||||
|  | ||||
|   if (!create_fbo (blur, pass)) | ||||
|     return FALSE; | ||||
|  | ||||
|   update_blur_uniforms (blur, pass); | ||||
|   return TRUE; | ||||
| } | ||||
|  | ||||
| static float | ||||
| calculate_downscale_factor (float width, | ||||
|                             float height, | ||||
|                             float sigma) | ||||
| { | ||||
|   float downscale_factor = 1.f; | ||||
|   float scaled_width = width; | ||||
|   float scaled_height = height; | ||||
|   float scaled_sigma = sigma; | ||||
|  | ||||
|   /* This is the algorithm used by Firefox; keep downscaling until either the | ||||
|    * blur radius is lower than the threshold, or the downscaled texture is too | ||||
|    * small. | ||||
|    */ | ||||
|   while (scaled_sigma > MAX_SIGMA && | ||||
|          scaled_width > MIN_DOWNSCALE_SIZE && | ||||
|          scaled_height > MIN_DOWNSCALE_SIZE) | ||||
|     { | ||||
|       downscale_factor *= 2.f; | ||||
|  | ||||
|       scaled_width = width / downscale_factor; | ||||
|       scaled_height = height / downscale_factor; | ||||
|       scaled_sigma = sigma / downscale_factor; | ||||
|     } | ||||
|  | ||||
|   return downscale_factor; | ||||
| } | ||||
|  | ||||
| static void | ||||
| apply_blur_pass (BlurPass *pass) | ||||
| { | ||||
|   CoglColor transparent; | ||||
|  | ||||
|   cogl_color_init_from_4ub (&transparent, 0, 0, 0, 0); | ||||
|  | ||||
|   cogl_framebuffer_clear (pass->framebuffer, | ||||
|                           COGL_BUFFER_BIT_COLOR, | ||||
|                           &transparent); | ||||
|  | ||||
|   cogl_framebuffer_draw_rectangle (pass->framebuffer, | ||||
|                                    pass->pipeline, | ||||
|                                    0, 0, | ||||
|                                    cogl_texture_get_width (pass->texture), | ||||
|                                    cogl_texture_get_height (pass->texture)); | ||||
| } | ||||
|  | ||||
| static void | ||||
| clear_blur_pass (BlurPass *pass) | ||||
| { | ||||
|   g_clear_pointer (&pass->pipeline, cogl_object_unref); | ||||
|   g_clear_pointer (&pass->texture, cogl_object_unref); | ||||
|   g_clear_object (&pass->framebuffer); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_blur_new: | ||||
|  * @texture: a #CoglTexture | ||||
|  * @sigma: blur sigma | ||||
|  * | ||||
|  * Creates a new #ClutterBlur. | ||||
|  * | ||||
|  * Returns: (transfer full) (nullable): A newly created #ClutterBlur | ||||
|  */ | ||||
| ClutterBlur * | ||||
| clutter_blur_new (CoglTexture *texture, | ||||
|                   float        sigma) | ||||
| { | ||||
|   ClutterBlur *blur; | ||||
|   unsigned int height; | ||||
|   unsigned int width; | ||||
|   BlurPass *hpass; | ||||
|   BlurPass *vpass; | ||||
|  | ||||
|   g_return_val_if_fail (texture != NULL, NULL); | ||||
|   g_return_val_if_fail (sigma >= 0.0, NULL); | ||||
|  | ||||
|   width = cogl_texture_get_width (texture); | ||||
|   height = cogl_texture_get_height (texture); | ||||
|  | ||||
|   blur = g_new0 (ClutterBlur, 1); | ||||
|   blur->sigma = sigma; | ||||
|   blur->source_texture = cogl_object_ref (texture); | ||||
|   blur->downscale_factor = calculate_downscale_factor (width, height, sigma); | ||||
|  | ||||
|   if (G_APPROX_VALUE (sigma, 0.0, FLT_EPSILON)) | ||||
|     goto out; | ||||
|  | ||||
|   vpass = &blur->pass[VERTICAL]; | ||||
|   hpass = &blur->pass[HORIZONTAL]; | ||||
|  | ||||
|   if (!setup_blur_pass (blur, vpass, VERTICAL, texture) || | ||||
|       !setup_blur_pass (blur, hpass, HORIZONTAL, vpass->texture)) | ||||
|     { | ||||
|       clutter_blur_free (blur); | ||||
|       return NULL; | ||||
|     } | ||||
|  | ||||
| out: | ||||
|   return g_steal_pointer (&blur); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_blur_apply: | ||||
|  * @blur: a #ClutterBlur | ||||
|  * | ||||
|  * Applies the blur. The resulting texture can be retrieved by | ||||
|  * clutter_blur_get_texture(). | ||||
|  */ | ||||
| void | ||||
| clutter_blur_apply (ClutterBlur *blur) | ||||
| { | ||||
|   if (G_APPROX_VALUE (blur->sigma, 0.0, FLT_EPSILON)) | ||||
|     return; | ||||
|  | ||||
|   apply_blur_pass (&blur->pass[VERTICAL]); | ||||
|   apply_blur_pass (&blur->pass[HORIZONTAL]); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_blur_get_texture: | ||||
|  * @blur: a #ClutterBlur | ||||
|  * | ||||
|  * Retrieves the texture where the blurred contents are stored. The | ||||
|  * contents are undefined until clutter_blur_apply() is called. | ||||
|  * | ||||
|  * Returns: (transfer none): a #CoglTexture | ||||
|  */ | ||||
| CoglTexture * | ||||
| clutter_blur_get_texture (ClutterBlur *blur) | ||||
| { | ||||
|   if (G_APPROX_VALUE (blur->sigma, 0.0, FLT_EPSILON)) | ||||
|     return blur->source_texture; | ||||
|   else | ||||
|     return blur->pass[HORIZONTAL].texture; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_blur_free: | ||||
|  * @blur: A #ClutterBlur | ||||
|  * | ||||
|  * Frees @blur. | ||||
|  */ | ||||
| void | ||||
| clutter_blur_free (ClutterBlur *blur) | ||||
| { | ||||
|   g_assert (blur); | ||||
|  | ||||
|   clear_blur_pass (&blur->pass[VERTICAL]); | ||||
|   clear_blur_pass (&blur->pass[HORIZONTAL]); | ||||
|   cogl_clear_object (&blur->source_texture); | ||||
|   g_free (blur); | ||||
| } | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -25,13 +25,14 @@ | ||||
|  *   Thomas Wood <thomas.wood@intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_BOX_LAYOUT_H__ | ||||
| #define __CLUTTER_BOX_LAYOUT_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-layout-manager.h" | ||||
| #include <clutter/clutter-layout-manager.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -46,6 +47,14 @@ typedef struct _ClutterBoxLayout                ClutterBoxLayout; | ||||
| typedef struct _ClutterBoxLayoutPrivate         ClutterBoxLayoutPrivate; | ||||
| typedef struct _ClutterBoxLayoutClass           ClutterBoxLayoutClass; | ||||
|  | ||||
| /** | ||||
|  * ClutterBoxLayout: | ||||
|  * | ||||
|  * The #ClutterBoxLayout structure contains only private data | ||||
|  * and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.2 | ||||
|  */ | ||||
| struct _ClutterBoxLayout | ||||
| { | ||||
|   /*< private >*/ | ||||
| @@ -59,6 +68,8 @@ struct _ClutterBoxLayout | ||||
|  * | ||||
|  * The #ClutterBoxLayoutClass structure contains only private | ||||
|  * data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.2 | ||||
|  */ | ||||
| struct _ClutterBoxLayoutClass | ||||
| { | ||||
| @@ -88,5 +99,70 @@ void                    clutter_box_layout_set_homogeneous      (ClutterBoxLayou | ||||
|                                                                  gboolean             homogeneous); | ||||
| CLUTTER_EXPORT | ||||
| gboolean                clutter_box_layout_get_homogeneous      (ClutterBoxLayout    *layout); | ||||
| CLUTTER_EXPORT | ||||
| void                    clutter_box_layout_set_pack_start       (ClutterBoxLayout    *layout, | ||||
|                                                                  gboolean             pack_start); | ||||
| CLUTTER_EXPORT | ||||
| gboolean                clutter_box_layout_get_pack_start       (ClutterBoxLayout    *layout); | ||||
|  | ||||
| CLUTTER_DEPRECATED_FOR(clutter_box_layout_set_orientation) | ||||
| void                    clutter_box_layout_set_vertical         (ClutterBoxLayout    *layout, | ||||
|                                                                  gboolean             vertical); | ||||
| CLUTTER_DEPRECATED_FOR(clutter_box_layout_get_orientation) | ||||
| gboolean                clutter_box_layout_get_vertical         (ClutterBoxLayout    *layout); | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void                    clutter_box_layout_pack                 (ClutterBoxLayout    *layout, | ||||
|                                                                  ClutterActor        *actor, | ||||
|                                                                  gboolean             expand, | ||||
|                                                                  gboolean             x_fill, | ||||
|                                                                  gboolean             y_fill, | ||||
|                                                                  ClutterBoxAlignment  x_align, | ||||
|                                                                  ClutterBoxAlignment  y_align); | ||||
| CLUTTER_DEPRECATED | ||||
| void                    clutter_box_layout_set_alignment        (ClutterBoxLayout    *layout, | ||||
|                                                                  ClutterActor        *actor, | ||||
|                                                                  ClutterBoxAlignment  x_align, | ||||
|                                                                  ClutterBoxAlignment  y_align); | ||||
| CLUTTER_DEPRECATED | ||||
| void                    clutter_box_layout_get_alignment        (ClutterBoxLayout    *layout, | ||||
|                                                                  ClutterActor        *actor, | ||||
|                                                                  ClutterBoxAlignment *x_align, | ||||
|                                                                  ClutterBoxAlignment *y_align); | ||||
| CLUTTER_DEPRECATED | ||||
| void                    clutter_box_layout_set_fill             (ClutterBoxLayout    *layout, | ||||
|                                                                  ClutterActor        *actor, | ||||
|                                                                  gboolean             x_fill, | ||||
|                                                                  gboolean             y_fill); | ||||
| CLUTTER_DEPRECATED | ||||
| void                    clutter_box_layout_get_fill             (ClutterBoxLayout    *layout, | ||||
|                                                                  ClutterActor        *actor, | ||||
|                                                                  gboolean            *x_fill, | ||||
|                                                                  gboolean            *y_fill); | ||||
| CLUTTER_DEPRECATED | ||||
| void                    clutter_box_layout_set_expand           (ClutterBoxLayout    *layout, | ||||
|                                                                  ClutterActor        *actor, | ||||
|                                                                  gboolean             expand); | ||||
| CLUTTER_DEPRECATED | ||||
| gboolean                clutter_box_layout_get_expand           (ClutterBoxLayout    *layout, | ||||
|                                                                  ClutterActor        *actor); | ||||
|  | ||||
| CLUTTER_DEPRECATED | ||||
| void                    clutter_box_layout_set_use_animations   (ClutterBoxLayout    *layout, | ||||
|                                                                  gboolean             animate); | ||||
| CLUTTER_DEPRECATED | ||||
| gboolean                clutter_box_layout_get_use_animations   (ClutterBoxLayout    *layout); | ||||
| CLUTTER_DEPRECATED | ||||
| void                    clutter_box_layout_set_easing_mode      (ClutterBoxLayout    *layout, | ||||
|                                                                  gulong               mode); | ||||
| CLUTTER_DEPRECATED | ||||
| gulong                  clutter_box_layout_get_easing_mode      (ClutterBoxLayout    *layout); | ||||
| CLUTTER_DEPRECATED | ||||
| void                    clutter_box_layout_set_easing_duration  (ClutterBoxLayout    *layout, | ||||
|                                                                  guint                msecs); | ||||
| CLUTTER_DEPRECATED | ||||
| guint                   clutter_box_layout_get_easing_duration  (ClutterBoxLayout    *layout); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_BOX_LAYOUT_H__ */ | ||||
|   | ||||
| @@ -23,29 +23,34 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterBrightnessContrastEffect: | ||||
|  *  | ||||
|  * Increase/decrease brightness and/or contrast of actor. | ||||
|  * SECTION:clutter-brightness-contrast-effect | ||||
|  * @short_description: Increase/decrease brightness and/or contrast of actor. | ||||
|  * @see_also: #ClutterEffect, #ClutterOffscreenEffect | ||||
|  * | ||||
|  * #ClutterBrightnessContrastEffect is a sub-class of #ClutterEffect that | ||||
|  * changes the overall brightness of a #ClutterActor. | ||||
|  * | ||||
|  * #ClutterBrightnessContrastEffect is available since Clutter 1.10 | ||||
|  */ | ||||
|  | ||||
| #define CLUTTER_BRIGHTNESS_CONTRAST_EFFECT_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BRIGHTNESS_CONTRAST_EFFECT, ClutterBrightnessContrastEffectClass)) | ||||
| #define CLUTTER_IS_BRIGHTNESS_CONTRAST_EFFECT_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BRIGHTNESS_CONTRAST_EFFECT)) | ||||
| #define CLUTTER_BRIGHTNESS_CONTRAST_EFFECT_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_BRIGHTNESS_CONTRAST_EFFECT, ClutterBrightnessContrastEffectClass)) | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include <math.h> | ||||
|  | ||||
| #include "cogl/cogl.h" | ||||
| #define CLUTTER_ENABLE_EXPERIMENTAL_API | ||||
|  | ||||
| #include "clutter/clutter-brightness-contrast-effect.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-enum-types.h" | ||||
| #include "clutter/clutter-offscreen-effect.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-brightness-contrast-effect.h" | ||||
|  | ||||
| #include <cogl/cogl.h> | ||||
|  | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-enum-types.h" | ||||
| #include "clutter-offscreen-effect.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| struct _ClutterBrightnessContrastEffect | ||||
| { | ||||
| @@ -64,6 +69,9 @@ struct _ClutterBrightnessContrastEffect | ||||
|   gint brightness_offset_uniform; | ||||
|   gint contrast_uniform; | ||||
|  | ||||
|   gint tex_width; | ||||
|   gint tex_height; | ||||
|  | ||||
|   CoglPipeline *pipeline; | ||||
| }; | ||||
|  | ||||
| @@ -113,41 +121,80 @@ G_DEFINE_TYPE (ClutterBrightnessContrastEffect, | ||||
| static gboolean | ||||
| will_have_no_effect (ClutterBrightnessContrastEffect *self) | ||||
| { | ||||
|   return (G_APPROX_VALUE (self->brightness_red, no_change, FLT_EPSILON) && | ||||
|           G_APPROX_VALUE (self->brightness_green, no_change, FLT_EPSILON) && | ||||
|           G_APPROX_VALUE (self->brightness_blue, no_change, FLT_EPSILON) && | ||||
|           G_APPROX_VALUE (self->contrast_red, no_change, FLT_EPSILON) && | ||||
|           G_APPROX_VALUE (self->contrast_green, no_change, FLT_EPSILON) && | ||||
|           G_APPROX_VALUE (self->contrast_blue, no_change, FLT_EPSILON)); | ||||
| } | ||||
|  | ||||
| static CoglPipeline * | ||||
| clutter_brightness_contrast_effect_create_pipeline (ClutterOffscreenEffect *effect, | ||||
|                                                     CoglTexture            *texture) | ||||
| { | ||||
|   ClutterBrightnessContrastEffect *self = | ||||
|     CLUTTER_BRIGHTNESS_CONTRAST_EFFECT (effect); | ||||
|  | ||||
|   cogl_pipeline_set_layer_texture (self->pipeline, 0, texture); | ||||
|  | ||||
|   return cogl_object_ref (self->pipeline); | ||||
|   return (self->brightness_red == no_change && | ||||
|           self->brightness_green == no_change && | ||||
|           self->brightness_blue == no_change && | ||||
|           self->contrast_red == no_change && | ||||
|           self->contrast_green == no_change && | ||||
|           self->contrast_blue == no_change); | ||||
| } | ||||
|  | ||||
| static gboolean | ||||
| clutter_brightness_contrast_effect_pre_paint (ClutterEffect       *effect, | ||||
|                                               ClutterPaintNode    *node, | ||||
|                                               ClutterPaintContext *paint_context) | ||||
| clutter_brightness_contrast_effect_pre_paint (ClutterEffect *effect) | ||||
| { | ||||
|   ClutterBrightnessContrastEffect *self = CLUTTER_BRIGHTNESS_CONTRAST_EFFECT (effect); | ||||
|   ClutterEffectClass *parent_class; | ||||
|  | ||||
|   if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect))) | ||||
|     return FALSE; | ||||
|  | ||||
|   if (will_have_no_effect (self)) | ||||
|     return FALSE; | ||||
|  | ||||
|   if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL)) | ||||
|     { | ||||
|       /* if we don't have support for GLSL shaders then we | ||||
|        * forcibly disable the ActorMeta | ||||
|        */ | ||||
|       g_warning ("Unable to use the ClutterBrightnessContrastEffect: the " | ||||
|                  "graphics hardware or the current GL driver does not " | ||||
|                  "implement support for the GLSL shading language. The " | ||||
|                  "effect will be disabled."); | ||||
|       clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (effect), FALSE); | ||||
|       return FALSE; | ||||
|     } | ||||
|  | ||||
|   parent_class = | ||||
|     CLUTTER_EFFECT_CLASS (clutter_brightness_contrast_effect_parent_class); | ||||
|   if (parent_class->pre_paint (effect)) | ||||
|     { | ||||
|       ClutterOffscreenEffect *offscreen_effect = | ||||
|         CLUTTER_OFFSCREEN_EFFECT (effect); | ||||
|       CoglHandle texture; | ||||
|  | ||||
|   return parent_class->pre_paint (effect, node, paint_context); | ||||
|       texture = clutter_offscreen_effect_get_texture (offscreen_effect); | ||||
|       self->tex_width = cogl_texture_get_width (texture); | ||||
|       self->tex_height = cogl_texture_get_height (texture); | ||||
|  | ||||
|       cogl_pipeline_set_layer_texture (self->pipeline, 0, texture); | ||||
|  | ||||
|       return TRUE; | ||||
|     } | ||||
|   else | ||||
|     return FALSE; | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_brightness_contrast_effect_paint_target (ClutterOffscreenEffect *effect) | ||||
| { | ||||
|   ClutterBrightnessContrastEffect *self = CLUTTER_BRIGHTNESS_CONTRAST_EFFECT (effect); | ||||
|   CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer (); | ||||
|   ClutterActor *actor; | ||||
|   guint8 paint_opacity; | ||||
|  | ||||
|   actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect)); | ||||
|   paint_opacity = clutter_actor_get_paint_opacity (actor); | ||||
|  | ||||
|   cogl_pipeline_set_color4ub (self->pipeline, | ||||
|                               paint_opacity, | ||||
|                               paint_opacity, | ||||
|                               paint_opacity, | ||||
|                               paint_opacity); | ||||
|  | ||||
|   cogl_framebuffer_draw_rectangle (framebuffer, | ||||
|                                    self->pipeline, | ||||
|                                    0, 0, | ||||
|                                    self->tex_width, self->tex_height); | ||||
| } | ||||
|  | ||||
| static void | ||||
| @@ -247,7 +294,7 @@ clutter_brightness_contrast_effect_class_init (ClutterBrightnessContrastEffectCl | ||||
|   ClutterOffscreenEffectClass *offscreen_class; | ||||
|  | ||||
|   offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass); | ||||
|   offscreen_class->create_pipeline = clutter_brightness_contrast_effect_create_pipeline; | ||||
|   offscreen_class->paint_target = clutter_brightness_contrast_effect_paint_target; | ||||
|  | ||||
|   effect_class->pre_paint = clutter_brightness_contrast_effect_pre_paint; | ||||
|  | ||||
| @@ -265,9 +312,13 @@ clutter_brightness_contrast_effect_class_init (ClutterBrightnessContrastEffectCl | ||||
|    * to indicate no change; values smaller than 127 indicate a decrease | ||||
|    * in brightness, and values larger than 127 indicate an increase in | ||||
|    * brightness. | ||||
|    * | ||||
|    * Since: 1.10 | ||||
|    */ | ||||
|   obj_props[PROP_BRIGHTNESS] = | ||||
|     clutter_param_spec_color ("brightness", NULL, NULL, | ||||
|     clutter_param_spec_color ("brightness", | ||||
|                               P_("Brightness"), | ||||
|                               P_("The brightness change to apply"), | ||||
|                               &no_brightness_change, | ||||
|                               CLUTTER_PARAM_READWRITE); | ||||
|  | ||||
| @@ -281,9 +332,13 @@ clutter_brightness_contrast_effect_class_init (ClutterBrightnessContrastEffectCl | ||||
|    * to indicate no change; values smaller than 127 indicate a decrease | ||||
|    * in contrast, and values larger than 127 indicate an increase in | ||||
|    * contrast. | ||||
|    * | ||||
|    * Since: 1.10 | ||||
|    */ | ||||
|   obj_props[PROP_CONTRAST] = | ||||
|     clutter_param_spec_color ("contrast", NULL, NULL, | ||||
|     clutter_param_spec_color ("contrast", | ||||
|                               P_("Contrast"), | ||||
|                               P_("The contrast change to apply"), | ||||
|                               &no_contrast_change, | ||||
|                               CLUTTER_PARAM_READWRITE); | ||||
|  | ||||
| @@ -409,6 +464,8 @@ clutter_brightness_contrast_effect_init (ClutterBrightnessContrastEffect *self) | ||||
|  * Return value: (transfer full): the newly created | ||||
|  *   #ClutterBrightnessContrastEffect or %NULL.  Use g_object_unref() when | ||||
|  *   done. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| ClutterEffect * | ||||
| clutter_brightness_contrast_effect_new (void) | ||||
| @@ -426,6 +483,8 @@ clutter_brightness_contrast_effect_new (void) | ||||
|  * The range for each component is [-1.0, 1.0] where 0.0 designates no change, | ||||
|  * values below 0.0 mean a decrease in brightness, and values above indicate | ||||
|  * an increase. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| void | ||||
| clutter_brightness_contrast_effect_set_brightness_full (ClutterBrightnessContrastEffect *effect, | ||||
| @@ -435,9 +494,9 @@ clutter_brightness_contrast_effect_set_brightness_full (ClutterBrightnessContras | ||||
| { | ||||
|   g_return_if_fail (CLUTTER_IS_BRIGHTNESS_CONTRAST_EFFECT (effect)); | ||||
|  | ||||
|   if (G_APPROX_VALUE (red, effect->brightness_red, FLT_EPSILON) && | ||||
|       G_APPROX_VALUE (green, effect->brightness_green, FLT_EPSILON) && | ||||
|       G_APPROX_VALUE (blue, effect->brightness_blue, FLT_EPSILON)) | ||||
|   if (red == effect->brightness_red && | ||||
|       green == effect->brightness_green && | ||||
|       blue == effect->brightness_blue) | ||||
|     return; | ||||
|  | ||||
|   effect->brightness_red = red; | ||||
| @@ -462,6 +521,8 @@ clutter_brightness_contrast_effect_set_brightness_full (ClutterBrightnessContras | ||||
|  *    change in brightness | ||||
|  * | ||||
|  * Retrieves the change in brightness used by @effect. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| void | ||||
| clutter_brightness_contrast_effect_get_brightness (ClutterBrightnessContrastEffect *effect, | ||||
| @@ -489,6 +550,8 @@ clutter_brightness_contrast_effect_get_brightness (ClutterBrightnessContrastEffe | ||||
|  * The range of @brightness is [-1.0, 1.0], where 0.0 designates no change; | ||||
|  * a value below 0.0 indicates a decrease in brightness; and a value | ||||
|  * above 0.0 indicates an increase of brightness. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| void | ||||
| clutter_brightness_contrast_effect_set_brightness (ClutterBrightnessContrastEffect *effect, | ||||
| @@ -510,6 +573,8 @@ clutter_brightness_contrast_effect_set_brightness (ClutterBrightnessContrastEffe | ||||
|  * The range for each component is [-1.0, 1.0] where 0.0 designates no change, | ||||
|  * values below 0.0 mean a decrease in contrast, and values above indicate | ||||
|  * an increase. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| void | ||||
| clutter_brightness_contrast_effect_set_contrast_full (ClutterBrightnessContrastEffect *effect, | ||||
| @@ -519,9 +584,9 @@ clutter_brightness_contrast_effect_set_contrast_full (ClutterBrightnessContrastE | ||||
| { | ||||
|   g_return_if_fail (CLUTTER_IS_BRIGHTNESS_CONTRAST_EFFECT (effect)); | ||||
|  | ||||
|   if (G_APPROX_VALUE (red, effect->contrast_red, FLT_EPSILON) && | ||||
|       G_APPROX_VALUE (green, effect->contrast_green, FLT_EPSILON) && | ||||
|       G_APPROX_VALUE (blue, effect->contrast_blue, FLT_EPSILON)) | ||||
|   if (red == effect->contrast_red && | ||||
|       green == effect->contrast_green && | ||||
|       blue == effect->contrast_blue) | ||||
|     return; | ||||
|  | ||||
|   effect->contrast_red = red; | ||||
| @@ -546,6 +611,8 @@ clutter_brightness_contrast_effect_set_contrast_full (ClutterBrightnessContrastE | ||||
|  *    change in contrast | ||||
|  * | ||||
|  * Retrieves the contrast value used by @effect. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| void | ||||
| clutter_brightness_contrast_effect_get_contrast (ClutterBrightnessContrastEffect *effect, | ||||
| @@ -573,6 +640,8 @@ clutter_brightness_contrast_effect_get_contrast (ClutterBrightnessContrastEffect | ||||
|  * The range for @contrast is [-1.0, 1.0], where 0.0 designates no change; | ||||
|  * a value below 0.0 indicates a decrease in contrast; and a value above | ||||
|  * 0.0 indicates an increase. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| void | ||||
| clutter_brightness_contrast_effect_set_contrast (ClutterBrightnessContrastEffect *effect, | ||||
|   | ||||
| @@ -22,14 +22,15 @@ | ||||
|  *   Joseph Scheuhammer <clown@alum.mit.edu> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_BRIGHTNESS_CONTRAST_EFFECT_H__ | ||||
| #define __CLUTTER_BRIGHTNESS_CONTRAST_EFFECT_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-color.h" | ||||
| #include "clutter/clutter-effect.h" | ||||
| #include <clutter/clutter-color.h> | ||||
| #include <clutter/clutter-effect.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -37,6 +38,14 @@ G_BEGIN_DECLS | ||||
| #define CLUTTER_BRIGHTNESS_CONTRAST_EFFECT(obj)     (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BRIGHTNESS_CONTRAST_EFFECT, ClutterBrightnessContrastEffect)) | ||||
| #define CLUTTER_IS_BRIGHTNESS_CONTRAST_EFFECT(obj)  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BRIGHTNESS_CONTRAST_EFFECT)) | ||||
|  | ||||
| /** | ||||
|  * ClutterBrightnessContrastEffect: | ||||
|  * | ||||
|  * #ClutterBrightnessContrastEffect is an opaque structure | ||||
|  * whose members cannot be directly accessed | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| typedef struct _ClutterBrightnessContrastEffect         ClutterBrightnessContrastEffect; | ||||
| typedef struct _ClutterBrightnessContrastEffectClass    ClutterBrightnessContrastEffectClass; | ||||
|  | ||||
| @@ -75,3 +84,5 @@ void            clutter_brightness_contrast_effect_get_contrast | ||||
|                                                                                  float                           *blue); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_BRIGHTNESS_CONTRAST_EFFECT_H__ */ | ||||
|   | ||||
| @@ -1,11 +1,14 @@ | ||||
| /* The prefix for our gettext translation domains. */ | ||||
| #mesondefine GETTEXT_PACKAGE | ||||
|  | ||||
| /* Mutter version */ | ||||
| #mesondefine MUTTER_VERSION | ||||
|  | ||||
| /* List of Cogl drivers */ | ||||
| #mesondefine CLUTTER_DRIVERS | ||||
|  | ||||
| /* Have evdev support for input handling */ | ||||
| #mesondefine HAVE_EVDEV | ||||
|  | ||||
| /* Building with libwacom for advanced tablet management */ | ||||
| #mesondefine HAVE_LIBWACOM | ||||
|  | ||||
| /* Supports PangoFt2 */ | ||||
| #mesondefine HAVE_PANGO_FT2 | ||||
|   | ||||
| @@ -27,10 +27,10 @@ | ||||
|  * Clutter provides some utility functions for using Cairo. | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-cairo.h" | ||||
| #include "clutter/clutter-color.h" | ||||
| #include "clutter-cairo.h" | ||||
| #include "clutter-color.h" | ||||
|  | ||||
| /** | ||||
|  * clutter_cairo_set_source_color: | ||||
| @@ -40,13 +40,15 @@ | ||||
|  * Utility function for setting the source color of @cr using | ||||
|  * a #ClutterColor. This function is the equivalent of: | ||||
|  * | ||||
|  * ```c | ||||
|  * |[ | ||||
|  *   cairo_set_source_rgba (cr, | ||||
|  *                          color->red / 255.0, | ||||
|  *                          color->green / 255.0, | ||||
|  *                          color->blue / 255.0, | ||||
|  *                          color->alpha / 255.0); | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_cairo_set_source_color (cairo_t            *cr, | ||||
| @@ -73,6 +75,8 @@ clutter_cairo_set_source_color (cairo_t            *cr, | ||||
|  * @cr: a Cairo context | ||||
|  * | ||||
|  * Utility function to clear a Cairo context. | ||||
|  * | ||||
|  * Since: 1.12 | ||||
|  */ | ||||
| void | ||||
| clutter_cairo_clear (cairo_t *cr) | ||||
|   | ||||
| @@ -19,13 +19,14 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_CAIRO_H__ | ||||
| #define __CLUTTER_CAIRO_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-types.h" | ||||
| #include <clutter/clutter-types.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -35,6 +36,8 @@ G_BEGIN_DECLS | ||||
|  * The #CoglPixelFormat to be used when uploading image data from | ||||
|  * and to a Cairo image surface using %CAIRO_FORMAT_ARGB32 and | ||||
|  * %CAIRO_FORMAT_RGB24 as #cairo_format_t. | ||||
|  * | ||||
|  * Since: 1.8 | ||||
|  */ | ||||
|  | ||||
| /* Cairo stores the data in native byte order as ARGB but Cogl's pixel | ||||
| @@ -54,3 +57,5 @@ void    clutter_cairo_set_source_color  (cairo_t               *cr, | ||||
|                                          const ClutterColor    *color); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_CAIRO_H__ */ | ||||
|   | ||||
| @@ -23,9 +23,10 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterCanvas: | ||||
|  *  | ||||
|  * Content for 2D painting | ||||
|  * SECTION:clutter-canvas | ||||
|  * @Title: ClutterCanvas | ||||
|  * @Short_Description: Content for 2D painting | ||||
|  * @See_Also: #ClutterContent | ||||
|  * | ||||
|  * The #ClutterCanvas class is a #ClutterContent implementation that allows | ||||
|  * drawing using the Cairo API on a 2D surface. | ||||
| @@ -36,27 +37,32 @@ | ||||
|  * signal when invalidated using clutter_content_invalidate(). | ||||
|  * | ||||
|  * See [canvas.c](https://git.gnome.org/browse/clutter/tree/examples/canvas.c?h=clutter-1.18) | ||||
|  * for an example of how to use #ClutterCanvas.. | ||||
|  * for an example of how to use #ClutterCanvas. | ||||
|  * | ||||
|  * #ClutterCanvas is available since Clutter 1.10. | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include <math.h> | ||||
| #include <cogl/cogl.h> | ||||
| #include <cairo-gobject.h> | ||||
|  | ||||
| #include "cogl/cogl.h" | ||||
| #include "clutter/clutter-canvas.h" | ||||
| #include "clutter/clutter-actor-private.h" | ||||
| #include "clutter/clutter-backend.h" | ||||
| #include "clutter/clutter-cairo.h" | ||||
| #include "clutter/clutter-color.h" | ||||
| #include "clutter/clutter-content-private.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-marshal.h" | ||||
| #include "clutter/clutter-paint-node.h" | ||||
| #include "clutter/clutter-paint-nodes.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter/clutter-settings.h" | ||||
| #include "clutter-canvas.h" | ||||
|  | ||||
| #define CLUTTER_ENABLE_EXPERIMENTAL_API | ||||
|  | ||||
| #include "clutter-actor-private.h" | ||||
| #include "clutter-backend.h" | ||||
| #include "clutter-cairo.h" | ||||
| #include "clutter-color.h" | ||||
| #include "clutter-content-private.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-marshal.h" | ||||
| #include "clutter-paint-node.h" | ||||
| #include "clutter-paint-nodes.h" | ||||
| #include "clutter-private.h" | ||||
| #include "clutter-settings.h" | ||||
|  | ||||
| struct _ClutterCanvasPrivate | ||||
| { | ||||
| @@ -231,9 +237,13 @@ clutter_canvas_class_init (ClutterCanvasClass *klass) | ||||
|    * ClutterCanvas:width: | ||||
|    * | ||||
|    * The width of the canvas. | ||||
|    * | ||||
|    * Since: 1.10 | ||||
|    */ | ||||
|   obj_props[PROP_WIDTH] = | ||||
|     g_param_spec_int ("width", NULL, NULL, | ||||
|     g_param_spec_int ("width", | ||||
|                       P_("Width"), | ||||
|                       P_("The width of the canvas"), | ||||
|                       -1, G_MAXINT, | ||||
|                       -1, | ||||
|                       G_PARAM_READWRITE | | ||||
| @@ -243,9 +253,13 @@ clutter_canvas_class_init (ClutterCanvasClass *klass) | ||||
|    * ClutterCanvas:height: | ||||
|    * | ||||
|    * The height of the canvas. | ||||
|    * | ||||
|    * Since: 1.10 | ||||
|    */ | ||||
|   obj_props[PROP_HEIGHT] = | ||||
|     g_param_spec_int ("height", NULL, NULL, | ||||
|     g_param_spec_int ("height", | ||||
|                       P_("Height"), | ||||
|                       P_("The height of the canvas"), | ||||
|                       -1, G_MAXINT, | ||||
|                       -1, | ||||
|                       G_PARAM_READWRITE | | ||||
| @@ -257,7 +271,9 @@ clutter_canvas_class_init (ClutterCanvasClass *klass) | ||||
|    * The height of the canvas. | ||||
|    */ | ||||
|   obj_props[PROP_SCALE_FACTOR] = | ||||
|     g_param_spec_float ("scale-factor", NULL, NULL, | ||||
|     g_param_spec_float ("scale-factor", | ||||
|                         P_("Scale Factor"), | ||||
|                         P_("The Scale factor of the canvas"), | ||||
|                         0.01f, G_MAXFLOAT, | ||||
|                         1.0f, | ||||
|                         G_PARAM_READWRITE | | ||||
| @@ -279,6 +295,8 @@ clutter_canvas_class_init (ClutterCanvasClass *klass) | ||||
|    * | ||||
|    * Return value: %TRUE if the signal emission should stop, and | ||||
|    *   %FALSE otherwise | ||||
|    * | ||||
|    * Since: 1.10 | ||||
|    */ | ||||
|   canvas_signals[DRAW] = | ||||
|     g_signal_new (I_("draw"), | ||||
| @@ -310,10 +328,9 @@ clutter_canvas_init (ClutterCanvas *self) | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_canvas_paint_content (ClutterContent      *content, | ||||
|                               ClutterActor        *actor, | ||||
|                               ClutterPaintNode    *root, | ||||
|                               ClutterPaintContext *paint_context) | ||||
| clutter_canvas_paint_content (ClutterContent   *content, | ||||
|                               ClutterActor     *actor, | ||||
|                               ClutterPaintNode *root) | ||||
| { | ||||
|   ClutterCanvas *self = CLUTTER_CANVAS (content); | ||||
|   ClutterCanvasPrivate *priv = self->priv; | ||||
| @@ -326,13 +343,15 @@ clutter_canvas_paint_content (ClutterContent      *content, | ||||
|     g_clear_pointer (&priv->texture, cogl_object_unref); | ||||
|  | ||||
|   if (priv->texture == NULL) | ||||
|     priv->texture = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (priv->buffer)); | ||||
|     priv->texture = cogl_texture_new_from_bitmap (priv->buffer, | ||||
|                                                   COGL_TEXTURE_NO_SLICING, | ||||
|                                                   CLUTTER_CAIRO_FORMAT_ARGB32); | ||||
|  | ||||
|   if (priv->texture == NULL) | ||||
|     return; | ||||
|  | ||||
|   node = clutter_actor_create_texture_paint_node (actor, priv->texture); | ||||
|   clutter_paint_node_set_static_name (node, "Canvas Content"); | ||||
|   clutter_paint_node_set_name (node, "Canvas Content"); | ||||
|   clutter_paint_node_add_child (root, node); | ||||
|   clutter_paint_node_unref (node); | ||||
|  | ||||
| @@ -495,6 +514,8 @@ clutter_content_iface_init (ClutterContentInterface *iface) | ||||
|  * | ||||
|  * Return value: (transfer full): The newly allocated instance of | ||||
|  *   #ClutterCanvas. Use g_object_unref() when done. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| ClutterContent * | ||||
| clutter_canvas_new (void) | ||||
| @@ -557,13 +578,15 @@ clutter_canvas_invalidate_internal (ClutterCanvas *canvas, | ||||
|  * the size, you can use the return value of the function to conditionally | ||||
|  * call clutter_content_invalidate(): | ||||
|  * | ||||
|  * ```c | ||||
|  * |[ | ||||
|  *   if (!clutter_canvas_set_size (canvas, width, height)) | ||||
|  *     clutter_content_invalidate (CLUTTER_CONTENT (canvas)); | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * Return value: this function returns %TRUE if the size change | ||||
|  *   caused a content invalidation, and %FALSE otherwise | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| gboolean | ||||
| clutter_canvas_set_size (ClutterCanvas *canvas, | ||||
|   | ||||
| @@ -22,13 +22,14 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_CANVAS_H__ | ||||
| #define __CLUTTER_CANVAS_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-types.h" | ||||
| #include <clutter/clutter-types.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -43,6 +44,15 @@ typedef struct _ClutterCanvas           ClutterCanvas; | ||||
| typedef struct _ClutterCanvasPrivate    ClutterCanvasPrivate; | ||||
| typedef struct _ClutterCanvasClass      ClutterCanvasClass; | ||||
|  | ||||
| /** | ||||
|  * ClutterCanvas: | ||||
|  * | ||||
|  * The #ClutterCanvas structure contains | ||||
|  * private data and should only be accessed using the provided | ||||
|  * API. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| struct _ClutterCanvas | ||||
| { | ||||
|   /*< private >*/ | ||||
| @@ -57,6 +67,8 @@ struct _ClutterCanvas | ||||
|  * | ||||
|  * The #ClutterCanvasClass structure contains | ||||
|  * private data. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| struct _ClutterCanvasClass | ||||
| { | ||||
| @@ -68,6 +80,9 @@ struct _ClutterCanvasClass | ||||
|                      cairo_t       *cr, | ||||
|                      int            width, | ||||
|                      int            height); | ||||
|  | ||||
|   /*< private >*/ | ||||
|   gpointer _padding[16]; | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| @@ -87,3 +102,5 @@ CLUTTER_EXPORT | ||||
| float                   clutter_canvas_get_scale_factor         (ClutterCanvas *canvas); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_CANVAS_H__ */ | ||||
|   | ||||
| @@ -25,51 +25,24 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * ClutterChildMeta: | ||||
|  *  | ||||
|  * Base interface for container specific state for child actors. | ||||
|  *  | ||||
|  * A child data is meant to be used when you need to keep track  | ||||
|  * of information about each individual child added to a container. | ||||
|  * SECTION:clutter-child-meta | ||||
|  * @short_description: Wrapper for actors inside a container | ||||
|  * | ||||
|  * In order to use it you should create your own subclass of | ||||
|  * #ClutterChildMeta and set the #ClutterContainerIface child_meta_type | ||||
|  * interface member to your subclass type, like: | ||||
|  * #ClutterChildMeta is a wrapper object created by #ClutterContainer | ||||
|  * implementations in order to store child-specific data and properties. | ||||
|  * | ||||
|  * ```c | ||||
|  * static void | ||||
|  * my_container_iface_init (ClutterContainerIface *iface) | ||||
|  * { | ||||
|  *   // set the rest of the #ClutterContainer vtable | ||||
|  * A #ClutterChildMeta wraps a #ClutterActor inside a #ClutterContainer. | ||||
|  * | ||||
|  *   container_iface->child_meta_type  = MY_TYPE_CHILD_META; | ||||
|  * } | ||||
|  * ``` | ||||
|  * | ||||
|  * This will automatically create a #ClutterChildMeta of type | ||||
|  * `MY_TYPE_CHILD_META` for every actor that is added to the container. | ||||
|  * | ||||
|  * The child data for an actor can be retrieved using the | ||||
|  * clutter_container_get_child_meta() function. | ||||
|  *  | ||||
|  * The properties of the data and your subclass can be manipulated with | ||||
|  * clutter_container_child_set() and clutter_container_child_get() which | ||||
|  * act like g_object_set() and g_object_get(). | ||||
|  * | ||||
|  * You can provide hooks for your own storage as well as control the | ||||
|  * instantiation by overriding the #ClutterContainerIface virtual functions | ||||
|  * #ClutterContainerIface.create_child_meta(), #ClutterContainerIface.destroy_child_meta(), | ||||
|  * and #ClutterContainerIface.get_child_meta(). | ||||
|  * #ClutterChildMeta is available since Clutter 0.8 | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-child-meta.h" | ||||
| #include "clutter/clutter-container.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-child-meta.h" | ||||
| #include "clutter-container.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| G_DEFINE_ABSTRACT_TYPE (ClutterChildMeta, clutter_child_meta, G_TYPE_OBJECT); | ||||
|  | ||||
| @@ -145,9 +118,13 @@ clutter_child_meta_class_init (ClutterChildMetaClass *klass) | ||||
|    * ClutterChildMeta:container: | ||||
|    * | ||||
|    * The #ClutterContainer that created this #ClutterChildMeta. | ||||
|    * | ||||
|    * Since: 0.8 | ||||
|    */ | ||||
|   obj_props[PROP_CONTAINER] = | ||||
|     g_param_spec_object ("container", NULL, NULL, | ||||
|     g_param_spec_object ("container", | ||||
|                          P_("Container"), | ||||
|                          P_("The container that created this data"), | ||||
|                          CLUTTER_TYPE_CONTAINER, | ||||
|                          G_PARAM_CONSTRUCT_ONLY | | ||||
|                          CLUTTER_PARAM_READWRITE); | ||||
| @@ -156,9 +133,13 @@ clutter_child_meta_class_init (ClutterChildMetaClass *klass) | ||||
|    * ClutterChildMeta:actor: | ||||
|    * | ||||
|    * The #ClutterActor being wrapped by this #ClutterChildMeta | ||||
|    * | ||||
|    * Since: 0.8 | ||||
|    */ | ||||
|   obj_props[PROP_ACTOR] = | ||||
|     g_param_spec_object ("actor", NULL, NULL, | ||||
|     g_param_spec_object ("actor", | ||||
|                          P_("Actor"), | ||||
|                          P_("The actor wrapped by this data"), | ||||
|                          CLUTTER_TYPE_ACTOR, | ||||
|                          G_PARAM_CONSTRUCT_ONLY | | ||||
|                          CLUTTER_PARAM_READWRITE); | ||||
| @@ -180,6 +161,8 @@ clutter_child_meta_init (ClutterChildMeta *self) | ||||
|  * Retrieves the container using @data | ||||
|  * | ||||
|  * Return value: (transfer none): a #ClutterContainer | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| ClutterContainer * | ||||
| clutter_child_meta_get_container (ClutterChildMeta *data) | ||||
| @@ -196,6 +179,8 @@ clutter_child_meta_get_container (ClutterChildMeta *data) | ||||
|  * Retrieves the actor wrapped by @data | ||||
|  * | ||||
|  * Return value: (transfer none): a #ClutterActor | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| ClutterActor * | ||||
| clutter_child_meta_get_actor (ClutterChildMeta *data) | ||||
|   | ||||
| @@ -25,15 +25,15 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_CHILD_META_H__ | ||||
| #define __CLUTTER_CHILD_META_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include <glib-object.h> | ||||
|  | ||||
| #include "clutter/clutter-types.h" | ||||
| #include <clutter/clutter-types.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -46,6 +46,46 @@ G_BEGIN_DECLS | ||||
|  | ||||
| typedef struct _ClutterChildMetaClass           ClutterChildMetaClass; | ||||
|  | ||||
| /** | ||||
|  * ClutterChildMeta: | ||||
|  * @container: the container handling this data | ||||
|  * @actor: the actor wrapped by this data | ||||
|  *  | ||||
|  * Base interface for container specific state for child actors. A child | ||||
|  * data is meant to be used when you need to keep track of information | ||||
|  * about each individual child added to a container. | ||||
|  * | ||||
|  * In order to use it you should create your own subclass of | ||||
|  * #ClutterChildMeta and set the #ClutterContainerIface child_meta_type | ||||
|  * interface member to your subclass type, like: | ||||
|  * | ||||
|  * |[ | ||||
|  * static void | ||||
|  * my_container_iface_init (ClutterContainerIface *iface) | ||||
|  * { | ||||
|  *   // set the rest of the #ClutterContainer vtable | ||||
|  * | ||||
|  *   container_iface->child_meta_type  = MY_TYPE_CHILD_META; | ||||
|  * } | ||||
|  * ]| | ||||
|  * | ||||
|  * This will automatically create a #ClutterChildMeta of type | ||||
|  * `MY_TYPE_CHILD_META` for every actor that is added to the container. | ||||
|  * | ||||
|  * The child data for an actor can be retrieved using the | ||||
|  * clutter_container_get_child_meta() function. | ||||
|  *  | ||||
|  * The properties of the data and your subclass can be manipulated with | ||||
|  * clutter_container_child_set() and clutter_container_child_get() which | ||||
|  * act like g_object_set() and g_object_get(). | ||||
|  * | ||||
|  * You can provide hooks for your own storage as well as control the | ||||
|  * instantiation by overriding the #ClutterContainerIface virtual functions | ||||
|  * #ClutterContainerIface.create_child_meta(), #ClutterContainerIface.destroy_child_meta(), | ||||
|  * and #ClutterContainerIface.get_child_meta(). | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| struct _ClutterChildMeta | ||||
| { | ||||
|   /*< private >*/ | ||||
| @@ -60,6 +100,8 @@ struct _ClutterChildMeta | ||||
|  * ClutterChildMetaClass: | ||||
|  * | ||||
|  * The #ClutterChildMetaClass contains only private data | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| struct _ClutterChildMetaClass | ||||
| { | ||||
| @@ -76,3 +118,5 @@ CLUTTER_EXPORT | ||||
| ClutterActor     *      clutter_child_meta_get_actor            (ClutterChildMeta *data); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_CHILD_META_H__ */ | ||||
|   | ||||
| @@ -23,39 +23,39 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterClickAction: | ||||
|  *  | ||||
|  * Action for clickable actors | ||||
|  * SECTION:clutter-click-action | ||||
|  * @Title: ClutterClickAction | ||||
|  * @Short_Description: Action for clickable actors | ||||
|  * | ||||
|  * #ClutterClickAction is a sub-class of [class@Action] that implements | ||||
|  * #ClutterClickAction is a sub-class of #ClutterAction that implements | ||||
|  * the logic for clickable actors, by using the low level events of | ||||
|  * [class@Actor], such as [signal@Actor::button-press-event] and | ||||
|  * [signal@Actor::button-release-event], to synthesize the high level | ||||
|  * [signal@ClickAction::clicked] signal. | ||||
|  * #ClutterActor, such as #ClutterActor::button-press-event and | ||||
|  * #ClutterActor::button-release-event, to synthesize the high level | ||||
|  * #ClutterClickAction::clicked signal. | ||||
|  * | ||||
|  * To use #ClutterClickAction you just need to apply it to a [class@Actor] | ||||
|  * using [method@Actor.add_action] and connect to the | ||||
|  * [signal@ClickAction::clicked] signal: | ||||
|  * To use #ClutterClickAction you just need to apply it to a #ClutterActor | ||||
|  * using clutter_actor_add_action() and connect to the | ||||
|  * #ClutterClickAction::clicked signal: | ||||
|  * | ||||
|  * ```c | ||||
|  * |[ | ||||
|  *   ClutterAction *action = clutter_click_action_new (); | ||||
|  * | ||||
|  *   clutter_actor_add_action (actor, action); | ||||
|  * | ||||
|  *   g_signal_connect (action, "clicked", G_CALLBACK (on_clicked), NULL); | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * #ClutterClickAction also supports long press gestures: a long press is | ||||
|  * activated if the pointer remains pressed within a certain threshold (as | ||||
|  * defined by the [property@ClickAction:long-press-threshold] property) for a | ||||
|  * defined by the #ClutterClickAction:long-press-threshold property) for a | ||||
|  * minimum amount of time (as the defined by the | ||||
|  * [property@ClickAction:long-press-duration] property). | ||||
|  * The [signal@ClickAction::long-press] signal is emitted multiple times, | ||||
|  * using different [enum@LongPressState] values; to handle long presses | ||||
|  * you should connect to the [signal@ClickAction::long-press] signal and | ||||
|  * #ClutterClickAction:long-press-duration property). | ||||
|  * The #ClutterClickAction::long-press signal is emitted multiple times, | ||||
|  * using different #ClutterLongPressState values; to handle long presses | ||||
|  * you should connect to the #ClutterClickAction::long-press signal and | ||||
|  * handle the different states: | ||||
|  * | ||||
|  * ```c | ||||
|  * |[ | ||||
|  *   static gboolean | ||||
|  *   on_long_press (ClutterClickAction    *action, | ||||
|  *                  ClutterActor          *actor, | ||||
| @@ -64,42 +64,49 @@ | ||||
|  *     switch (state) | ||||
|  *       { | ||||
|  *       case CLUTTER_LONG_PRESS_QUERY: | ||||
|  *         // return TRUE if the actor should support long press | ||||
|  *         // gestures, and FALSE otherwise; this state will be | ||||
|  *         // emitted on button presses | ||||
|  *         /* return TRUE if the actor should support long press | ||||
|  *          * gestures, and FALSE otherwise; this state will be | ||||
|  *          * emitted on button presses | ||||
|  *          */ | ||||
|  *         return TRUE; | ||||
|  * | ||||
|  *       case CLUTTER_LONG_PRESS_ACTIVATE: | ||||
|  *         // this state is emitted if the minimum duration has | ||||
|  *         // been reached without the gesture being cancelled. | ||||
|  *         // the return value is not used | ||||
|  *         /* this state is emitted if the minimum duration has | ||||
|  *          * been reached without the gesture being cancelled. | ||||
|  *          * the return value is not used | ||||
|  *          */ | ||||
|  *         return TRUE; | ||||
|  * | ||||
|  *       case CLUTTER_LONG_PRESS_CANCEL: | ||||
|  *         // this state is emitted if the long press was cancelled; | ||||
|  *         // for instance, the pointer went outside the actor or the | ||||
|  *         // allowed threshold, or the button was released before | ||||
|  *         // the minimum duration was reached. the return value is | ||||
|  *         // not used | ||||
|  *         /* this state is emitted if the long press was cancelled; | ||||
|  *          * for instance, the pointer went outside the actor or the | ||||
|  *          * allowed threshold, or the button was released before | ||||
|  *          * the minimum duration was reached. the return value is | ||||
|  *          * not used | ||||
|  *          */ | ||||
|  *         return FALSE; | ||||
|  *       } | ||||
|  *   } | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * #ClutterClickAction is available since Clutter 1.4 | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-click-action.h" | ||||
| #include "clutter-click-action.h" | ||||
|  | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-enum-types.h" | ||||
| #include "clutter/clutter-marshal.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-enum-types.h" | ||||
| #include "clutter-marshal.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| struct _ClutterClickActionPrivate | ||||
| { | ||||
|   ClutterActor *stage; | ||||
|  | ||||
|   guint event_id; | ||||
|   guint capture_id; | ||||
|   guint long_press_id; | ||||
|  | ||||
|   gint long_press_threshold; | ||||
| @@ -107,7 +114,7 @@ struct _ClutterClickActionPrivate | ||||
|   gint drag_threshold; | ||||
|  | ||||
|   guint press_button; | ||||
|   ClutterInputDevice *press_device; | ||||
|   gint press_device_id; | ||||
|   ClutterEventSequence *press_sequence; | ||||
|   ClutterModifierType modifier_state; | ||||
|   gfloat press_x; | ||||
| @@ -143,12 +150,16 @@ static guint click_signals[LAST_SIGNAL] = { 0, }; | ||||
|  | ||||
| G_DEFINE_TYPE_WITH_PRIVATE (ClutterClickAction, clutter_click_action, CLUTTER_TYPE_ACTION) | ||||
|  | ||||
| /* forward declaration */ | ||||
| static gboolean on_captured_event (ClutterActor       *stage, | ||||
|                                    ClutterEvent       *event, | ||||
|                                    ClutterClickAction *action); | ||||
|  | ||||
| static inline void | ||||
| click_action_set_pressed (ClutterClickAction *action, | ||||
|                           gboolean            is_pressed) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (action); | ||||
|   ClutterClickActionPrivate *priv = action->priv; | ||||
|  | ||||
|   is_pressed = !!is_pressed; | ||||
|  | ||||
| @@ -163,8 +174,7 @@ static inline void | ||||
| click_action_set_held (ClutterClickAction *action, | ||||
|                        gboolean            is_held) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (action); | ||||
|   ClutterClickActionPrivate *priv = action->priv; | ||||
|  | ||||
|   is_held = !!is_held; | ||||
|  | ||||
| @@ -179,8 +189,7 @@ static gboolean | ||||
| click_action_emit_long_press (gpointer data) | ||||
| { | ||||
|   ClutterClickAction *action = data; | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (action); | ||||
|   ClutterClickActionPrivate *priv = action->priv; | ||||
|   ClutterActor *actor; | ||||
|   gboolean result; | ||||
|  | ||||
| @@ -193,6 +202,12 @@ click_action_emit_long_press (gpointer data) | ||||
|                  CLUTTER_LONG_PRESS_ACTIVATE, | ||||
|                  &result); | ||||
|  | ||||
|   if (priv->capture_id != 0) | ||||
|     { | ||||
|       g_signal_handler_disconnect (priv->stage, priv->capture_id); | ||||
|       priv->capture_id = 0; | ||||
|     } | ||||
|  | ||||
|   click_action_set_pressed (action, FALSE); | ||||
|   click_action_set_held (action, FALSE); | ||||
|  | ||||
| @@ -202,8 +217,7 @@ click_action_emit_long_press (gpointer data) | ||||
| static inline void | ||||
| click_action_query_long_press (ClutterClickAction *action) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (action); | ||||
|   ClutterClickActionPrivate *priv = action->priv; | ||||
|   ClutterActor *actor; | ||||
|   gboolean result = FALSE; | ||||
|   gint timeout; | ||||
| @@ -228,7 +242,6 @@ click_action_query_long_press (ClutterClickAction *action) | ||||
|  | ||||
|   if (result) | ||||
|     { | ||||
|       g_clear_handle_id (&priv->long_press_id, g_source_remove); | ||||
|       priv->long_press_id = | ||||
|         clutter_threads_add_timeout (timeout, | ||||
|                                      click_action_emit_long_press, | ||||
| @@ -239,8 +252,7 @@ click_action_query_long_press (ClutterClickAction *action) | ||||
| static inline void | ||||
| click_action_cancel_long_press (ClutterClickAction *action) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (action); | ||||
|   ClutterClickActionPrivate *priv = action->priv; | ||||
|  | ||||
|   if (priv->long_press_id != 0) | ||||
|     { | ||||
| @@ -249,7 +261,8 @@ click_action_cancel_long_press (ClutterClickAction *action) | ||||
|  | ||||
|       actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (action)); | ||||
|  | ||||
|       g_clear_handle_id (&priv->long_press_id, g_source_remove); | ||||
|       g_source_remove (priv->long_press_id); | ||||
|       priv->long_press_id = 0; | ||||
|  | ||||
|       g_signal_emit (action, click_signals[LONG_PRESS], 0, | ||||
|                      actor, | ||||
| @@ -258,66 +271,33 @@ click_action_cancel_long_press (ClutterClickAction *action) | ||||
|     } | ||||
| } | ||||
|  | ||||
| static inline gboolean | ||||
| event_within_drag_threshold (ClutterClickAction *click_action, | ||||
|                              const ClutterEvent *event) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (click_action); | ||||
|   float motion_x, motion_y; | ||||
|   float delta_x, delta_y; | ||||
|  | ||||
|   clutter_event_get_coords (event, &motion_x, &motion_y); | ||||
|  | ||||
|   delta_x = ABS (motion_x - priv->press_x); | ||||
|   delta_y = ABS (motion_y - priv->press_y); | ||||
|  | ||||
|   return delta_x <= priv->drag_threshold && delta_y <= priv->drag_threshold; | ||||
| } | ||||
|  | ||||
| static gboolean | ||||
| clutter_click_action_handle_event (ClutterAction      *action, | ||||
|                                    const ClutterEvent *event) | ||||
| on_event (ClutterActor       *actor, | ||||
|           ClutterEvent       *event, | ||||
|           ClutterClickAction *action) | ||||
| { | ||||
|   ClutterClickAction *click_action = CLUTTER_CLICK_ACTION (action); | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (click_action); | ||||
|   ClutterActor *actor = | ||||
|     clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (action)); | ||||
|   ClutterClickActionPrivate *priv = action->priv; | ||||
|   gboolean has_button = TRUE; | ||||
|   ClutterModifierType modifier_state; | ||||
|   ClutterActor *target; | ||||
|  | ||||
|   if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (action))) | ||||
|     return CLUTTER_EVENT_PROPAGATE; | ||||
|  | ||||
|   if (priv->press_sequence != NULL && | ||||
|       clutter_event_get_event_sequence (event) != priv->press_sequence) | ||||
|     { | ||||
|       click_action_set_held (click_action, FALSE); | ||||
|       click_action_cancel_long_press (click_action); | ||||
|       return CLUTTER_EVENT_PROPAGATE; | ||||
|     } | ||||
|  | ||||
|   switch (clutter_event_type (event)) | ||||
|     { | ||||
|     case CLUTTER_TOUCH_BEGIN: | ||||
|       has_button = FALSE; | ||||
|  | ||||
|       G_GNUC_FALLTHROUGH; | ||||
|     case CLUTTER_BUTTON_PRESS: | ||||
|       if (has_button && clutter_event_get_click_count (event) != 1) | ||||
|         return CLUTTER_EVENT_PROPAGATE; | ||||
|  | ||||
|       if (priv->is_held) | ||||
|         return CLUTTER_EVENT_STOP; | ||||
|  | ||||
|       target = clutter_stage_get_device_actor (CLUTTER_STAGE (clutter_actor_get_stage (actor)), | ||||
|                                                clutter_event_get_device (event), | ||||
|                                                clutter_event_get_event_sequence (event)); | ||||
|  | ||||
|       if (!clutter_actor_contains (actor, target)) | ||||
|       if (!clutter_actor_contains (actor, clutter_event_get_source (event))) | ||||
|         return CLUTTER_EVENT_PROPAGATE; | ||||
|  | ||||
|       priv->press_button = has_button ? clutter_event_get_button (event) : 0; | ||||
|       priv->press_device = clutter_event_get_device (event); | ||||
|       priv->press_device_id = clutter_event_get_device_id (event); | ||||
|       priv->press_sequence = clutter_event_get_event_sequence (event); | ||||
|       priv->modifier_state = clutter_event_get_state (event); | ||||
|       clutter_event_get_coords (event, &priv->press_x, &priv->press_y); | ||||
| @@ -336,47 +316,78 @@ clutter_click_action_handle_event (ClutterAction      *action, | ||||
|       if (priv->stage == NULL) | ||||
|         priv->stage = clutter_actor_get_stage (actor); | ||||
|  | ||||
|       click_action_set_pressed (click_action, TRUE); | ||||
|       click_action_set_held (click_action, TRUE); | ||||
|       click_action_query_long_press (click_action); | ||||
|       priv->capture_id = g_signal_connect_after (priv->stage, "captured-event", | ||||
|                                                  G_CALLBACK (on_captured_event), | ||||
|                                                  action); | ||||
|  | ||||
|       click_action_set_pressed (action, TRUE); | ||||
|       click_action_set_held (action, TRUE); | ||||
|       click_action_query_long_press (action); | ||||
|       break; | ||||
|  | ||||
|     case CLUTTER_ENTER: | ||||
|       click_action_set_pressed (click_action, priv->is_held); | ||||
|       return CLUTTER_EVENT_PROPAGATE; | ||||
|       click_action_set_pressed (action, priv->is_held); | ||||
|       break; | ||||
|  | ||||
|     case CLUTTER_LEAVE: | ||||
|       click_action_set_pressed (click_action, FALSE); | ||||
|       click_action_cancel_long_press (click_action); | ||||
|       return CLUTTER_EVENT_PROPAGATE; | ||||
|       click_action_set_pressed (action, priv->is_held); | ||||
|       click_action_cancel_long_press (action); | ||||
|       break; | ||||
|  | ||||
|     default: | ||||
|       break; | ||||
|     } | ||||
|  | ||||
|   return CLUTTER_EVENT_PROPAGATE; | ||||
| } | ||||
|  | ||||
| static gboolean | ||||
| on_captured_event (ClutterActor       *stage, | ||||
|                    ClutterEvent       *event, | ||||
|                    ClutterClickAction *action) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv = action->priv; | ||||
|   ClutterActor *actor; | ||||
|   ClutterModifierType modifier_state; | ||||
|   gboolean has_button = TRUE; | ||||
|  | ||||
|   actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (action)); | ||||
|  | ||||
|   switch (clutter_event_type (event)) | ||||
|     { | ||||
|     case CLUTTER_TOUCH_CANCEL: | ||||
|       clutter_click_action_release (click_action); | ||||
|       clutter_click_action_release (action); | ||||
|       break; | ||||
|  | ||||
|     case CLUTTER_TOUCH_END: | ||||
|       has_button = FALSE; | ||||
|  | ||||
|       G_GNUC_FALLTHROUGH; | ||||
|     case CLUTTER_BUTTON_RELEASE: | ||||
|       if (!priv->is_held) | ||||
|         return CLUTTER_EVENT_PROPAGATE; | ||||
|         return CLUTTER_EVENT_STOP; | ||||
|  | ||||
|       if ((has_button && clutter_event_get_button (event) != priv->press_button) || | ||||
|           clutter_event_get_device (event) != priv->press_device || | ||||
|           (has_button && clutter_event_get_click_count (event) != 1) || | ||||
|           clutter_event_get_device_id (event) != priv->press_device_id || | ||||
|           clutter_event_get_event_sequence (event) != priv->press_sequence) | ||||
|         return CLUTTER_EVENT_PROPAGATE; | ||||
|  | ||||
|       click_action_set_held (click_action, FALSE); | ||||
|       click_action_cancel_long_press (click_action); | ||||
|       click_action_set_held (action, FALSE); | ||||
|       click_action_cancel_long_press (action); | ||||
|  | ||||
|       g_clear_handle_id (&priv->long_press_id, g_source_remove); | ||||
|       /* disconnect the capture */ | ||||
|       if (priv->capture_id != 0) | ||||
|         { | ||||
|           g_signal_handler_disconnect (priv->stage, priv->capture_id); | ||||
|           priv->capture_id = 0; | ||||
|         } | ||||
|  | ||||
|       target = clutter_stage_get_device_actor (CLUTTER_STAGE (clutter_actor_get_stage (actor)), | ||||
|                                                clutter_event_get_device (event), | ||||
|                                                clutter_event_get_event_sequence (event)); | ||||
|       if (priv->long_press_id != 0) | ||||
|         { | ||||
|           g_source_remove (priv->long_press_id); | ||||
|           priv->long_press_id = 0; | ||||
|         } | ||||
|  | ||||
|       if (!clutter_actor_contains (actor, target)) | ||||
|       if (!clutter_actor_contains (actor, clutter_event_get_source (event))) | ||||
|         return CLUTTER_EVENT_PROPAGATE; | ||||
|  | ||||
|       /* exclude any button-mask so that we can compare | ||||
| @@ -395,24 +406,31 @@ clutter_click_action_handle_event (ClutterAction      *action, | ||||
|       if (modifier_state != priv->modifier_state) | ||||
|         priv->modifier_state = 0; | ||||
|  | ||||
|       click_action_set_pressed (click_action, FALSE); | ||||
|  | ||||
|       if (event_within_drag_threshold (click_action, event)) | ||||
|         g_signal_emit (click_action, click_signals[CLICKED], 0, actor); | ||||
|       click_action_set_pressed (action, FALSE); | ||||
|       g_signal_emit (action, click_signals[CLICKED], 0, actor); | ||||
|       break; | ||||
|  | ||||
|     case CLUTTER_MOTION: | ||||
|     case CLUTTER_TOUCH_UPDATE: | ||||
|       { | ||||
|         if (clutter_event_get_device (event) != priv->press_device || | ||||
|         gfloat motion_x, motion_y; | ||||
|         gfloat delta_x, delta_y; | ||||
|  | ||||
|         if (clutter_event_get_device_id (event) != priv->press_device_id || | ||||
|             clutter_event_get_event_sequence (event) != priv->press_sequence) | ||||
|           return CLUTTER_EVENT_PROPAGATE; | ||||
|  | ||||
|         if (!priv->is_held) | ||||
|           return CLUTTER_EVENT_PROPAGATE; | ||||
|  | ||||
|         if (!event_within_drag_threshold (click_action, event)) | ||||
|           clutter_click_action_release (click_action); | ||||
|         clutter_event_get_coords (event, &motion_x, &motion_y); | ||||
|  | ||||
|         delta_x = ABS (motion_x - priv->press_x); | ||||
|         delta_y = ABS (motion_y - priv->press_y); | ||||
|  | ||||
|         if (delta_x > priv->drag_threshold || | ||||
|             delta_y > priv->drag_threshold) | ||||
|           click_action_cancel_long_press (action); | ||||
|       } | ||||
|       break; | ||||
|  | ||||
| @@ -420,20 +438,7 @@ clutter_click_action_handle_event (ClutterAction      *action, | ||||
|       break; | ||||
|     } | ||||
|  | ||||
|   return priv->is_held ? CLUTTER_EVENT_STOP : CLUTTER_EVENT_PROPAGATE; | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_click_action_sequence_cancelled (ClutterAction        *action, | ||||
|                                          ClutterInputDevice   *device, | ||||
|                                          ClutterEventSequence *sequence) | ||||
| { | ||||
|   ClutterClickAction *self = CLUTTER_CLICK_ACTION (action); | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (self); | ||||
|  | ||||
|   if (priv->press_device == device && priv->press_sequence == sequence) | ||||
|     clutter_click_action_release (self); | ||||
|   return CLUTTER_EVENT_STOP; | ||||
| } | ||||
|  | ||||
| static void | ||||
| @@ -441,39 +446,51 @@ clutter_click_action_set_actor (ClutterActorMeta *meta, | ||||
|                                 ClutterActor     *actor) | ||||
| { | ||||
|   ClutterClickAction *action = CLUTTER_CLICK_ACTION (meta); | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (action); | ||||
|   ClutterClickActionPrivate *priv = action->priv; | ||||
|  | ||||
|   g_clear_handle_id (&priv->long_press_id, g_source_remove); | ||||
|   if (priv->event_id != 0) | ||||
|     { | ||||
|       ClutterActor *old_actor = clutter_actor_meta_get_actor (meta); | ||||
|  | ||||
|       if (old_actor != NULL) | ||||
|         g_signal_handler_disconnect (old_actor, priv->event_id); | ||||
|  | ||||
|       priv->event_id = 0; | ||||
|     } | ||||
|  | ||||
|   if (priv->capture_id != 0) | ||||
|     { | ||||
|       if (priv->stage != NULL) | ||||
|         g_signal_handler_disconnect (priv->stage, priv->capture_id); | ||||
|  | ||||
|       priv->capture_id = 0; | ||||
|       priv->stage = NULL; | ||||
|     } | ||||
|  | ||||
|   if (priv->long_press_id != 0) | ||||
|     { | ||||
|       g_source_remove (priv->long_press_id); | ||||
|       priv->long_press_id = 0; | ||||
|     } | ||||
|  | ||||
|   click_action_set_pressed (action, FALSE); | ||||
|   click_action_set_held (action, FALSE); | ||||
|  | ||||
|   if (actor != NULL) | ||||
|     priv->event_id = g_signal_connect (actor, "event", | ||||
|                                        G_CALLBACK (on_event), | ||||
|                                        action); | ||||
|  | ||||
|   CLUTTER_ACTOR_META_CLASS (clutter_click_action_parent_class)->set_actor (meta, actor); | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_click_action_set_enabled (ClutterActorMeta *meta, | ||||
|                                   gboolean          is_enabled) | ||||
| { | ||||
|   ClutterClickAction *click_action = CLUTTER_CLICK_ACTION (meta); | ||||
|   ClutterActorMetaClass *parent_class = | ||||
|     CLUTTER_ACTOR_META_CLASS (clutter_click_action_parent_class); | ||||
|  | ||||
|   if (!is_enabled) | ||||
|     clutter_click_action_release (click_action); | ||||
|  | ||||
|   parent_class->set_enabled (meta, is_enabled); | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_click_action_set_property (GObject      *gobject, | ||||
|                                    guint         prop_id, | ||||
|                                    const GValue *value, | ||||
|                                    GParamSpec   *pspec) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (CLUTTER_CLICK_ACTION (gobject)); | ||||
|   ClutterClickActionPrivate *priv = CLUTTER_CLICK_ACTION (gobject)->priv; | ||||
|  | ||||
|   switch (prop_id) | ||||
|     { | ||||
| @@ -497,8 +514,7 @@ clutter_click_action_get_property (GObject    *gobject, | ||||
|                                    GValue     *value, | ||||
|                                    GParamSpec *pspec) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (CLUTTER_CLICK_ACTION (gobject)); | ||||
|   ClutterClickActionPrivate *priv = CLUTTER_CLICK_ACTION (gobject)->priv; | ||||
|  | ||||
|   switch (prop_id) | ||||
|     { | ||||
| @@ -527,26 +543,38 @@ clutter_click_action_get_property (GObject    *gobject, | ||||
| static void | ||||
| clutter_click_action_dispose (GObject *gobject) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (CLUTTER_CLICK_ACTION (gobject)); | ||||
|   ClutterClickActionPrivate *priv = CLUTTER_CLICK_ACTION (gobject)->priv; | ||||
|  | ||||
|   g_clear_handle_id (&priv->long_press_id, g_source_remove); | ||||
|   if (priv->event_id) | ||||
|     { | ||||
|       g_signal_handler_disconnect (clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (gobject)), | ||||
|                                    priv->event_id); | ||||
|       priv->event_id = 0; | ||||
|     } | ||||
|  | ||||
|   if (priv->capture_id) | ||||
|     { | ||||
|       g_signal_handler_disconnect (priv->stage, priv->capture_id); | ||||
|       priv->capture_id = 0; | ||||
|     } | ||||
|  | ||||
|   if (priv->long_press_id) | ||||
|     { | ||||
|       g_source_remove (priv->long_press_id); | ||||
|       priv->long_press_id = 0; | ||||
|     } | ||||
|  | ||||
|   G_OBJECT_CLASS (clutter_click_action_parent_class)->dispose (gobject); | ||||
| } | ||||
|  | ||||
|  | ||||
| static void | ||||
| clutter_click_action_class_init (ClutterClickActionClass *klass) | ||||
| { | ||||
|   GObjectClass *gobject_class = G_OBJECT_CLASS (klass); | ||||
|   ClutterActorMetaClass *meta_class = CLUTTER_ACTOR_META_CLASS (klass); | ||||
|   ClutterActionClass *action_class = CLUTTER_ACTION_CLASS (klass); | ||||
|  | ||||
|   action_class->handle_event = clutter_click_action_handle_event; | ||||
|   action_class->sequence_cancelled = clutter_click_action_sequence_cancelled; | ||||
|  | ||||
|   meta_class->set_actor = clutter_click_action_set_actor; | ||||
|   meta_class->set_enabled = clutter_click_action_set_enabled; | ||||
|  | ||||
|   gobject_class->dispose = clutter_click_action_dispose; | ||||
|   gobject_class->set_property = clutter_click_action_set_property; | ||||
| @@ -556,9 +584,13 @@ clutter_click_action_class_init (ClutterClickActionClass *klass) | ||||
|    * ClutterClickAction:pressed: | ||||
|    * | ||||
|    * Whether the clickable actor should be in "pressed" state | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   obj_props[PROP_PRESSED] = | ||||
|     g_param_spec_boolean ("pressed", NULL, NULL, | ||||
|     g_param_spec_boolean ("pressed", | ||||
|                           P_("Pressed"), | ||||
|                           P_("Whether the clickable should be in pressed state"), | ||||
|                           FALSE, | ||||
|                           CLUTTER_PARAM_READABLE); | ||||
|  | ||||
| @@ -566,9 +598,13 @@ clutter_click_action_class_init (ClutterClickActionClass *klass) | ||||
|    * ClutterClickAction:held: | ||||
|    * | ||||
|    * Whether the clickable actor has the pointer grabbed | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   obj_props[PROP_HELD] = | ||||
|     g_param_spec_boolean ("held", NULL, NULL, | ||||
|     g_param_spec_boolean ("held", | ||||
|                           P_("Held"), | ||||
|                           P_("Whether the clickable has a grab"), | ||||
|                           FALSE, | ||||
|                           CLUTTER_PARAM_READABLE); | ||||
|  | ||||
| @@ -579,10 +615,14 @@ clutter_click_action_class_init (ClutterClickActionClass *klass) | ||||
|    * press gesture, in milliseconds. | ||||
|    * | ||||
|    * A value of -1 will make the #ClutterClickAction use the value of | ||||
|    * the [property@Settings:long-press-duration] property. | ||||
|    * the #ClutterSettings:long-press-duration property. | ||||
|    * | ||||
|    * Since: 1.8 | ||||
|    */ | ||||
|   obj_props[PROP_LONG_PRESS_DURATION] = | ||||
|     g_param_spec_int ("long-press-duration", NULL, NULL, | ||||
|     g_param_spec_int ("long-press-duration", | ||||
|                       P_("Long Press Duration"), | ||||
|                       P_("The minimum duration of a long press to recognize the gesture"), | ||||
|                       -1, G_MAXINT, | ||||
|                       -1, | ||||
|                       CLUTTER_PARAM_READWRITE); | ||||
| @@ -594,10 +634,14 @@ clutter_click_action_class_init (ClutterClickActionClass *klass) | ||||
|    * a long press gesture is cancelled, in pixels. | ||||
|    * | ||||
|    * A value of -1 will make the #ClutterClickAction use the value of | ||||
|    * the [property@Settings:dnd-drag-threshold] property. | ||||
|    * the #ClutterSettings:dnd-drag-threshold property. | ||||
|    * | ||||
|    * Since: 1.8 | ||||
|    */ | ||||
|   obj_props[PROP_LONG_PRESS_THRESHOLD] = | ||||
|     g_param_spec_int ("long-press-threshold", NULL, NULL, | ||||
|     g_param_spec_int ("long-press-threshold", | ||||
|                       P_("Long Press Threshold"), | ||||
|                       P_("The maximum threshold before a long press is cancelled"), | ||||
|                       -1, G_MAXINT, | ||||
|                       -1, | ||||
|                       CLUTTER_PARAM_READWRITE); | ||||
| @@ -611,16 +655,19 @@ clutter_click_action_class_init (ClutterClickActionClass *klass) | ||||
|    * @action: the #ClutterClickAction that emitted the signal | ||||
|    * @actor: the #ClutterActor attached to the @action | ||||
|    * | ||||
|    * The signal is emitted when the [class@Actor] to which | ||||
|    * The ::clicked signal is emitted when the #ClutterActor to which | ||||
|    * a #ClutterClickAction has been applied should respond to a | ||||
|    * pointer button press and release events | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   click_signals[CLICKED] = | ||||
|     g_signal_new (I_("clicked"), | ||||
|                   G_TYPE_FROM_CLASS (klass), | ||||
|                   G_SIGNAL_RUN_LAST, | ||||
|                   G_STRUCT_OFFSET (ClutterClickActionClass, clicked), | ||||
|                   NULL, NULL, NULL, | ||||
|                   NULL, NULL, | ||||
|                   _clutter_marshal_VOID__OBJECT, | ||||
|                   G_TYPE_NONE, 1, | ||||
|                   CLUTTER_TYPE_ACTOR); | ||||
|  | ||||
| @@ -630,7 +677,7 @@ clutter_click_action_class_init (ClutterClickActionClass *klass) | ||||
|    * @actor: the #ClutterActor attached to the @action | ||||
|    * @state: the long press state | ||||
|    * | ||||
|    * The signal is emitted during the long press gesture | ||||
|    * The ::long-press signal is emitted during the long press gesture | ||||
|    * handling. | ||||
|    * | ||||
|    * This signal can be emitted multiple times with different states. | ||||
| @@ -644,10 +691,12 @@ clutter_click_action_class_init (ClutterClickActionClass *klass) | ||||
|    * %CLUTTER_LONG_PRESS_CANCEL state if the long press was cancelled. | ||||
|    * | ||||
|    * It is possible to forcibly cancel a long press detection using | ||||
|    * [method@ClickAction.release]. | ||||
|    * clutter_click_action_release(). | ||||
|    * | ||||
|    * Return value: Only the %CLUTTER_LONG_PRESS_QUERY state uses the | ||||
|    *   returned value of the handler; other states will ignore it | ||||
|    * | ||||
|    * Since: 1.8 | ||||
|    */ | ||||
|   click_signals[LONG_PRESS] = | ||||
|     g_signal_new (I_("long-press"), | ||||
| @@ -664,11 +713,9 @@ clutter_click_action_class_init (ClutterClickActionClass *klass) | ||||
| static void | ||||
| clutter_click_action_init (ClutterClickAction *self) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv = | ||||
|     clutter_click_action_get_instance_private (self); | ||||
|  | ||||
|   priv->long_press_threshold = -1; | ||||
|   priv->long_press_duration = -1; | ||||
|   self->priv = clutter_click_action_get_instance_private (self); | ||||
|   self->priv->long_press_threshold = -1; | ||||
|   self->priv->long_press_duration = -1; | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -677,6 +724,8 @@ clutter_click_action_init (ClutterClickAction *self) | ||||
|  * Creates a new #ClutterClickAction instance | ||||
|  * | ||||
|  * Return value: the newly created #ClutterClickAction | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| ClutterAction * | ||||
| clutter_click_action_new (void) | ||||
| @@ -689,13 +738,15 @@ clutter_click_action_new (void) | ||||
|  * @action: a #ClutterClickAction | ||||
|  * | ||||
|  * Emulates a release of the pointer button, which ungrabs the pointer | ||||
|  * and unsets the [property@ClickAction:pressed] state. | ||||
|  * and unsets the #ClutterClickAction:pressed state. | ||||
|  * | ||||
|  * This function will also cancel the long press gesture if one was | ||||
|  * initiated. | ||||
|  * | ||||
|  * This function is useful to break a grab, for instance after a certain | ||||
|  * amount of time has passed. | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_click_action_release (ClutterClickAction *action) | ||||
| @@ -704,11 +755,18 @@ clutter_click_action_release (ClutterClickAction *action) | ||||
|  | ||||
|   g_return_if_fail (CLUTTER_IS_CLICK_ACTION (action)); | ||||
|  | ||||
|   priv = clutter_click_action_get_instance_private (action); | ||||
|   priv = action->priv; | ||||
|  | ||||
|   if (!priv->is_held) | ||||
|     return; | ||||
|  | ||||
|   /* disconnect the capture */ | ||||
|   if (priv->capture_id != 0) | ||||
|     { | ||||
|       g_signal_handler_disconnect (priv->stage, priv->capture_id); | ||||
|       priv->capture_id = 0; | ||||
|     } | ||||
|  | ||||
|   click_action_cancel_long_press (action); | ||||
|   click_action_set_held (action, FALSE); | ||||
|   click_action_set_pressed (action, FALSE); | ||||
| @@ -721,17 +779,15 @@ clutter_click_action_release (ClutterClickAction *action) | ||||
|  * Retrieves the button that was pressed. | ||||
|  * | ||||
|  * Return value: the button value | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| guint | ||||
| clutter_click_action_get_button (ClutterClickAction *action) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_CLICK_ACTION (action), 0); | ||||
|  | ||||
|   priv = clutter_click_action_get_instance_private (action); | ||||
|  | ||||
|   return priv->press_button; | ||||
|   return action->priv->press_button; | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -741,17 +797,15 @@ clutter_click_action_get_button (ClutterClickAction *action) | ||||
|  * Retrieves the modifier state of the click action. | ||||
|  * | ||||
|  * Return value: the modifier state parameter, or 0 | ||||
|  * | ||||
|  * Since: 1.6 | ||||
|  */ | ||||
| ClutterModifierType | ||||
| clutter_click_action_get_state (ClutterClickAction *action) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_CLICK_ACTION (action), 0); | ||||
|  | ||||
|   priv = clutter_click_action_get_instance_private (action); | ||||
|  | ||||
|   return priv->modifier_state; | ||||
|   return action->priv->modifier_state; | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -761,21 +815,19 @@ clutter_click_action_get_state (ClutterClickAction *action) | ||||
|  * @press_y: (out): return location for the Y coordinate, or %NULL | ||||
|  * | ||||
|  * Retrieves the screen coordinates of the button press. | ||||
|  * | ||||
|  * Since: 1.8 | ||||
|  */ | ||||
| void | ||||
| clutter_click_action_get_coords (ClutterClickAction *action, | ||||
|                                  gfloat             *press_x, | ||||
|                                  gfloat             *press_y) | ||||
| { | ||||
|   ClutterClickActionPrivate *priv; | ||||
|  | ||||
|   g_return_if_fail (CLUTTER_IS_ACTION (action)); | ||||
|  | ||||
|   priv = clutter_click_action_get_instance_private (action); | ||||
|  | ||||
|   if (press_x != NULL) | ||||
|     *press_x = priv->press_x; | ||||
|     *press_x = action->priv->press_x; | ||||
|  | ||||
|   if (press_y != NULL) | ||||
|     *press_y = priv->press_y; | ||||
|     *press_y = action->priv->press_y; | ||||
| } | ||||
|   | ||||
| @@ -25,24 +25,44 @@ | ||||
|  *   Colin Walters <walters@verbum.org> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_CLICK_ACTION_H__ | ||||
| #define __CLUTTER_CLICK_ACTION_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-action.h" | ||||
| #include "clutter/clutter-event.h" | ||||
| #include <clutter/clutter-action.h> | ||||
| #include <clutter/clutter-event.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| #define CLUTTER_TYPE_CLICK_ACTION (clutter_click_action_get_type ()) | ||||
| #define CLUTTER_TYPE_CLICK_ACTION               (clutter_click_action_get_type ()) | ||||
| #define CLUTTER_CLICK_ACTION(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_CLICK_ACTION, ClutterClickAction)) | ||||
| #define CLUTTER_IS_CLICK_ACTION(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_CLICK_ACTION)) | ||||
| #define CLUTTER_CLICK_ACTION_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_CLICK_ACTION, ClutterClickActionClass)) | ||||
| #define CLUTTER_IS_CLICK_ACTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_CLICK_ACTION)) | ||||
| #define CLUTTER_CLICK_ACTION_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_CLICK_ACTION, ClutterClickActionClass)) | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| G_DECLARE_DERIVABLE_TYPE (ClutterClickAction, clutter_click_action, | ||||
|                           CLUTTER, CLICK_ACTION, ClutterAction); | ||||
| typedef struct _ClutterClickAction              ClutterClickAction; | ||||
| typedef struct _ClutterClickActionPrivate       ClutterClickActionPrivate; | ||||
| typedef struct _ClutterClickActionClass         ClutterClickActionClass; | ||||
|  | ||||
| typedef struct _ClutterClickActionPrivate ClutterClickActionPrivate; | ||||
| /** | ||||
|  * ClutterClickAction: | ||||
|  * | ||||
|  * The #ClutterClickAction structure contains | ||||
|  * only private data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _ClutterClickAction | ||||
| { | ||||
|   /*< private >*/ | ||||
|   ClutterAction parent_instance; | ||||
|  | ||||
|   ClutterClickActionPrivate *priv; | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * ClutterClickActionClass: | ||||
| @@ -51,6 +71,8 @@ typedef struct _ClutterClickActionPrivate ClutterClickActionPrivate; | ||||
|  * | ||||
|  * The #ClutterClickActionClass structure | ||||
|  * contains only private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _ClutterClickActionClass | ||||
| { | ||||
| @@ -64,8 +86,20 @@ struct _ClutterClickActionClass | ||||
|   gboolean (* long_press) (ClutterClickAction    *action, | ||||
|                            ClutterActor          *actor, | ||||
|                            ClutterLongPressState  state); | ||||
|  | ||||
|   /*< private >*/ | ||||
|   void (* _clutter_click_action1) (void); | ||||
|   void (* _clutter_click_action2) (void); | ||||
|   void (* _clutter_click_action3) (void); | ||||
|   void (* _clutter_click_action4) (void); | ||||
|   void (* _clutter_click_action5) (void); | ||||
|   void (* _clutter_click_action6) (void); | ||||
|   void (* _clutter_click_action7) (void); | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| GType clutter_click_action_get_type (void) G_GNUC_CONST; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| ClutterAction *        clutter_click_action_new        (void); | ||||
|  | ||||
| @@ -82,3 +116,5 @@ CLUTTER_EXPORT | ||||
| void                   clutter_click_action_release    (ClutterClickAction *action); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_CLICK_ACTION_H__ */ | ||||
|   | ||||
| @@ -22,9 +22,8 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterClone: | ||||
|  *  | ||||
|  * An actor that displays a clone of a source actor | ||||
|  * SECTION:clutter-clone | ||||
|  * @short_description: An actor that displays a clone of a source actor | ||||
|  * | ||||
|  * #ClutterClone is a #ClutterActor which draws with the paint | ||||
|  * function of another actor, scaled to fit its own allocation. | ||||
| @@ -34,24 +33,25 @@ | ||||
|  * Unlike clutter_texture_new_from_actor(), #ClutterClone does not require | ||||
|  * the presence of support for FBOs in the underlying GL or GLES | ||||
|  * implementation. | ||||
|  * | ||||
|  * #ClutterClone is available since Clutter 1.0 | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-actor-private.h" | ||||
| #include "clutter/clutter-clone.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-main.h" | ||||
| #include "clutter/clutter-paint-volume-private.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #define CLUTTER_ENABLE_EXPERIMENTAL_API | ||||
| #include "clutter-actor-private.h" | ||||
| #include "clutter-clone.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-main.h" | ||||
| #include "clutter-paint-volume-private.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| #include "cogl/cogl.h" | ||||
|  | ||||
| struct _ClutterClonePrivate | ||||
| { | ||||
|   ClutterActor *clone_source; | ||||
|   float x_scale, y_scale; | ||||
|  | ||||
|   gulong source_destroy_id; | ||||
| }; | ||||
|  | ||||
| @@ -119,22 +119,40 @@ clutter_clone_get_preferred_height (ClutterActor *self, | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_clone_apply_transform (ClutterActor      *self, | ||||
|                                graphene_matrix_t *matrix) | ||||
| clutter_clone_apply_transform (ClutterActor *self, CoglMatrix *matrix) | ||||
| { | ||||
|   ClutterClonePrivate *priv = CLUTTER_CLONE (self)->priv; | ||||
|   ClutterActorBox box, source_box; | ||||
|   gfloat x_scale, y_scale; | ||||
|  | ||||
|  | ||||
|   if (priv->clone_source) | ||||
|     graphene_matrix_scale (matrix, priv->x_scale, priv->y_scale, 1.f); | ||||
|  | ||||
|   /* First chain up and apply all the standard ClutterActor | ||||
|    * transformations... */ | ||||
|   CLUTTER_ACTOR_CLASS (clutter_clone_parent_class)->apply_transform (self, | ||||
|                                                                      matrix); | ||||
|  | ||||
|   /* if we don't have a source, nothing else to do */ | ||||
|   if (priv->clone_source == NULL) | ||||
|     return; | ||||
|  | ||||
|   /* get our allocated size */ | ||||
|   clutter_actor_get_allocation_box (self, &box); | ||||
|  | ||||
|   /* and get the allocated size of the source */ | ||||
|   clutter_actor_get_allocation_box (priv->clone_source, &source_box); | ||||
|  | ||||
|   /* We need to scale what the clone-source actor paints to fill our own | ||||
|    * allocation... | ||||
|    */ | ||||
|   x_scale = clutter_actor_box_get_width (&box) | ||||
|           / clutter_actor_box_get_width (&source_box); | ||||
|   y_scale = clutter_actor_box_get_height (&box) | ||||
|           / clutter_actor_box_get_height (&source_box); | ||||
|  | ||||
|   cogl_matrix_scale (matrix, x_scale, y_scale, x_scale); | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_clone_paint (ClutterActor        *actor, | ||||
|                      ClutterPaintContext *paint_context) | ||||
| clutter_clone_paint (ClutterActor *actor) | ||||
| { | ||||
|   ClutterClone *self = CLUTTER_CLONE (actor); | ||||
|   ClutterClonePrivate *priv = self->priv; | ||||
| @@ -171,7 +189,7 @@ clutter_clone_paint (ClutterActor        *actor, | ||||
|   if (clutter_actor_is_realized (priv->clone_source)) | ||||
|     { | ||||
|       _clutter_actor_push_clone_paint (); | ||||
|       clutter_actor_paint (priv->clone_source, paint_context); | ||||
|       clutter_actor_paint (priv->clone_source); | ||||
|       _clutter_actor_pop_clone_paint (); | ||||
|     } | ||||
|  | ||||
| @@ -194,7 +212,7 @@ clutter_clone_get_paint_volume (ClutterActor       *actor, | ||||
|   if (priv->clone_source == NULL) | ||||
|     return TRUE; | ||||
|  | ||||
|   /* query the volume of the source actor and simply masquerade it as | ||||
|   /* query the volume of the source actor and simply masquarade it as | ||||
|    * the clones volume... */ | ||||
|   source_volume = clutter_actor_get_paint_volume (priv->clone_source); | ||||
|   if (source_volume == NULL) | ||||
| @@ -221,16 +239,15 @@ clutter_clone_has_overlaps (ClutterActor *actor) | ||||
|  | ||||
| static void | ||||
| clutter_clone_allocate (ClutterActor           *self, | ||||
|                         const ClutterActorBox  *box) | ||||
|                         const ClutterActorBox  *box, | ||||
|                         ClutterAllocationFlags  flags) | ||||
| { | ||||
|   ClutterClonePrivate *priv = CLUTTER_CLONE (self)->priv; | ||||
|   ClutterActorClass *parent_class; | ||||
|   ClutterActorBox source_box; | ||||
|   float x_scale, y_scale; | ||||
|  | ||||
|   /* chain up */ | ||||
|   parent_class = CLUTTER_ACTOR_CLASS (clutter_clone_parent_class); | ||||
|   parent_class->allocate (self, box); | ||||
|   parent_class->allocate (self, box, flags); | ||||
|  | ||||
|   if (priv->clone_source == NULL) | ||||
|     return; | ||||
| @@ -240,31 +257,7 @@ clutter_clone_allocate (ClutterActor           *self, | ||||
|    */ | ||||
|   if (clutter_actor_get_parent (priv->clone_source) != NULL && | ||||
|       !clutter_actor_has_allocation (priv->clone_source)) | ||||
|     { | ||||
|       float x = 0.f; | ||||
|       float y = 0.f; | ||||
|  | ||||
|       clutter_actor_get_fixed_position (priv->clone_source, &x, &y); | ||||
|       clutter_actor_allocate_preferred_size (priv->clone_source, x, y); | ||||
|     } | ||||
|  | ||||
|   clutter_actor_get_allocation_box (priv->clone_source, &source_box); | ||||
|  | ||||
|   /* We need to scale what the clone-source actor paints to fill our own | ||||
|    * allocation... | ||||
|    */ | ||||
|   x_scale = clutter_actor_box_get_width (box) | ||||
|           / clutter_actor_box_get_width (&source_box); | ||||
|   y_scale = clutter_actor_box_get_height (box) | ||||
|           / clutter_actor_box_get_height (&source_box); | ||||
|  | ||||
|   if (!G_APPROX_VALUE (priv->x_scale, x_scale, FLT_EPSILON) || | ||||
|       !G_APPROX_VALUE (priv->y_scale, y_scale, FLT_EPSILON)) | ||||
|     { | ||||
|       priv->x_scale = x_scale; | ||||
|       priv->y_scale = y_scale; | ||||
|       clutter_actor_invalidate_transform (CLUTTER_ACTOR (self)); | ||||
|     } | ||||
|     clutter_actor_allocate_preferred_size (priv->clone_source, flags); | ||||
|  | ||||
| #if 0 | ||||
|   /* XXX - this is wrong: ClutterClone cannot clone unparented | ||||
| @@ -279,7 +272,7 @@ clutter_clone_allocate (ClutterActor           *self, | ||||
|    * paint cycle, we can safely give it as much size as it requires | ||||
|    */ | ||||
|   if (clutter_actor_get_parent (priv->clone_source) == NULL) | ||||
|     clutter_actor_allocate_preferred_size (priv->clone_source); | ||||
|     clutter_actor_allocate_preferred_size (priv->clone_source, flags); | ||||
| #endif | ||||
| } | ||||
|  | ||||
| @@ -353,9 +346,13 @@ clutter_clone_class_init (ClutterCloneClass *klass) | ||||
|    * ClutterClone:source: | ||||
|    * | ||||
|    * This property specifies the source actor being cloned. | ||||
|    * | ||||
|    * Since: 1.0 | ||||
|    */ | ||||
|   obj_props[PROP_SOURCE] = | ||||
|     g_param_spec_object ("source", NULL, NULL, | ||||
|     g_param_spec_object ("source", | ||||
|                          P_("Source"), | ||||
|                          P_("Specifies the actor to be cloned"), | ||||
|                          CLUTTER_TYPE_ACTOR, | ||||
|                          G_PARAM_CONSTRUCT | | ||||
|                          CLUTTER_PARAM_READWRITE); | ||||
| @@ -367,9 +364,6 @@ static void | ||||
| clutter_clone_init (ClutterClone *self) | ||||
| { | ||||
|   self->priv = clutter_clone_get_instance_private (self); | ||||
|  | ||||
|   self->priv->x_scale = 1.f; | ||||
|   self->priv->y_scale = 1.f; | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -379,6 +373,8 @@ clutter_clone_init (ClutterClone *self) | ||||
|  * Creates a new #ClutterActor which clones @source/ | ||||
|  * | ||||
|  * Return value: the newly created #ClutterClone | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| ClutterActor * | ||||
| clutter_clone_new (ClutterActor *source) | ||||
| @@ -404,7 +400,8 @@ clutter_clone_set_source_internal (ClutterClone *self, | ||||
|  | ||||
|   if (priv->clone_source != NULL) | ||||
|     { | ||||
|       g_clear_signal_handler (&priv->source_destroy_id, priv->clone_source); | ||||
|       g_signal_handler_disconnect (priv->clone_source, priv->source_destroy_id); | ||||
|       priv->source_destroy_id = 0; | ||||
|       _clutter_actor_detach_clone (priv->clone_source, CLUTTER_ACTOR (self)); | ||||
|       g_object_unref (priv->clone_source); | ||||
|       priv->clone_source = NULL; | ||||
| @@ -429,6 +426,8 @@ clutter_clone_set_source_internal (ClutterClone *self, | ||||
|  * @source: (allow-none): a #ClutterActor, or %NULL | ||||
|  * | ||||
|  * Sets @source as the source actor to be cloned by @self. | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| void | ||||
| clutter_clone_set_source (ClutterClone *self, | ||||
| @@ -448,6 +447,8 @@ clutter_clone_set_source (ClutterClone *self, | ||||
|  * Retrieves the source #ClutterActor being cloned by @self. | ||||
|  * | ||||
|  * Return value: (transfer none): the actor source for the clone | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| ClutterActor * | ||||
| clutter_clone_get_source (ClutterClone *self) | ||||
|   | ||||
| @@ -21,13 +21,14 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_CLONE_H__ | ||||
| #define __CLUTTER_CLONE_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-actor.h" | ||||
| #include <clutter/clutter-actor.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -42,6 +43,14 @@ typedef struct _ClutterClone            ClutterClone; | ||||
| typedef struct _ClutterCloneClass       ClutterCloneClass; | ||||
| typedef struct _ClutterClonePrivate     ClutterClonePrivate; | ||||
|  | ||||
| /** | ||||
|  * ClutterClone: | ||||
|  * | ||||
|  * The #ClutterClone structure contains only private data | ||||
|  * and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| struct _ClutterClone | ||||
| { | ||||
|   /*< private >*/ | ||||
| @@ -54,11 +63,19 @@ struct _ClutterClone | ||||
|  * ClutterCloneClass: | ||||
|  * | ||||
|  * The #ClutterCloneClass structure contains only private data | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| struct _ClutterCloneClass | ||||
| { | ||||
|   /*< private >*/ | ||||
|   ClutterActorClass parent_class; | ||||
|  | ||||
|   /* padding for future expansion */ | ||||
|   void (*_clutter_actor_clone1) (void); | ||||
|   void (*_clutter_actor_clone2) (void); | ||||
|   void (*_clutter_actor_clone3) (void); | ||||
|   void (*_clutter_actor_clone4) (void); | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| @@ -73,3 +90,5 @@ CLUTTER_EXPORT | ||||
| ClutterActor *  clutter_clone_get_source        (ClutterClone *self); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_CLONE_H__ */ | ||||
|   | ||||
| @@ -1,180 +0,0 @@ | ||||
| /* | ||||
|  * Clutter. | ||||
|  * | ||||
|  * An OpenGL based 'interactive canvas' library. | ||||
|  * | ||||
|  * Copyright (C) 2022  Intel Corporation. | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * | ||||
|  * Author: | ||||
|  *   Naveen Kumar <naveen1.kumar@intel.com> | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterColorState: | ||||
|  * | ||||
|  * Color state of each ClutterActor | ||||
|  * | ||||
|  * The #ClutterColorState class contains the colorspace of each color | ||||
|  * states (e.g. sRGB colorspace). | ||||
|  * | ||||
|  * Each [class@Actor] would own such an object. | ||||
|  * | ||||
|  * A single #ClutterColorState object can be shared by multiple [class@Actor] | ||||
|  * or maybe a separate color state for each [class@Actor] (depending on whether | ||||
|  * #ClutterColorState would be statefull or stateless). | ||||
|  * | ||||
|  * #ClutterColorState, if not set during construction, it will default to sRGB | ||||
|  * color state | ||||
|  * | ||||
|  * The #ClutterColorState would have API to get the colorspace, whether the | ||||
|  * actor content is in pq or not, and things like that | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-color-state.h" | ||||
|  | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-enum-types.h" | ||||
| #include "clutter/clutter-private.h" | ||||
|  | ||||
| enum | ||||
| { | ||||
|   PROP_0, | ||||
|  | ||||
|   PROP_COLORSPACE, | ||||
|  | ||||
|   N_PROPS | ||||
| }; | ||||
|  | ||||
| static GParamSpec *obj_props[N_PROPS]; | ||||
|  | ||||
| typedef struct _ClutterColorStatePrivate ClutterColorStatePrivate; | ||||
|  | ||||
| struct _ClutterColorState | ||||
| { | ||||
|   GObject parent_instance; | ||||
| }; | ||||
|  | ||||
| struct _ClutterColorStatePrivate | ||||
| { | ||||
|   ClutterColorspace colorspace; | ||||
| }; | ||||
|  | ||||
| G_DEFINE_TYPE_WITH_PRIVATE (ClutterColorState, | ||||
|                             clutter_color_state, | ||||
|                             G_TYPE_OBJECT) | ||||
|  | ||||
| ClutterColorspace | ||||
| clutter_color_state_get_colorspace (ClutterColorState *color_state) | ||||
| { | ||||
|   ClutterColorStatePrivate *priv; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_COLOR_STATE (color_state), | ||||
|                         CLUTTER_COLORSPACE_UNKNOWN); | ||||
|  | ||||
|   priv = clutter_color_state_get_instance_private (color_state); | ||||
|  | ||||
|   return priv->colorspace; | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_color_state_set_property (GObject      *object, | ||||
|                                   guint         prop_id, | ||||
|                                   const GValue *value, | ||||
|                                   GParamSpec   *pspec) | ||||
| { | ||||
|   ClutterColorState *color_state = CLUTTER_COLOR_STATE (object); | ||||
|   ClutterColorStatePrivate *priv; | ||||
|  | ||||
|   priv = clutter_color_state_get_instance_private (color_state); | ||||
|  | ||||
|   switch (prop_id) | ||||
|     { | ||||
|     case PROP_COLORSPACE: | ||||
|       priv->colorspace = g_value_get_enum (value); | ||||
|       break; | ||||
|  | ||||
|     default: | ||||
|       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||||
|       break; | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_color_state_get_property (GObject    *object, | ||||
|                                   guint       prop_id, | ||||
|                                   GValue     *value, | ||||
|                                   GParamSpec *pspec) | ||||
| { | ||||
|   ClutterColorState *color_state = CLUTTER_COLOR_STATE (object); | ||||
|  | ||||
|   switch (prop_id) | ||||
|     { | ||||
|     case PROP_COLORSPACE: | ||||
|       g_value_set_enum (value, | ||||
|                         clutter_color_state_get_colorspace (color_state)); | ||||
|       break; | ||||
|  | ||||
|     default: | ||||
|       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||||
|       break; | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_color_state_class_init (ClutterColorStateClass *klass) | ||||
| { | ||||
|   GObjectClass *gobject_class = G_OBJECT_CLASS (klass); | ||||
|  | ||||
|   gobject_class->set_property = clutter_color_state_set_property; | ||||
|   gobject_class->get_property = clutter_color_state_get_property; | ||||
|  | ||||
|   /** | ||||
|    * ClutterColorState:colorspace: | ||||
|    * | ||||
|    * Colorspace information of the each color state, | ||||
|    * defaults to sRGB colorspace | ||||
|    */ | ||||
|   obj_props[PROP_COLORSPACE] = | ||||
|     g_param_spec_enum ("colorspace", NULL, NULL, | ||||
|                        CLUTTER_TYPE_COLORSPACE, | ||||
|                        CLUTTER_COLORSPACE_SRGB, | ||||
|                        CLUTTER_PARAM_READWRITE | | ||||
|                        G_PARAM_CONSTRUCT_ONLY); | ||||
|  | ||||
|   g_object_class_install_properties (gobject_class, N_PROPS, obj_props); | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_color_state_init (ClutterColorState *color_state) | ||||
| { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_color_state_new: | ||||
|  * | ||||
|  * Create a new ClutterColorState object. | ||||
|  * | ||||
|  * Return value: A new ClutterColorState object. | ||||
|  **/ | ||||
| ClutterColorState* | ||||
| clutter_color_state_new (ClutterColorspace colorspace) | ||||
| { | ||||
|   return g_object_new (CLUTTER_TYPE_COLOR_STATE, | ||||
|                        "colorspace", colorspace, | ||||
|                        NULL); | ||||
| } | ||||
| @@ -19,7 +19,8 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_COLOR_STATIC_H__ | ||||
| #define __CLUTTER_COLOR_STATIC_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| @@ -74,3 +75,5 @@ | ||||
| #define CLUTTER_COLOR_Aluminium6        (__CLUTTER_COLOR_SYM (ALUMINIUM_6)) | ||||
|  | ||||
| #define CLUTTER_COLOR_Transparent       (__CLUTTER_COLOR_SYM (TRANSPARENT)) | ||||
|  | ||||
| #endif /* __CLUTTER_COLOR_STATIC_H__ */ | ||||
|   | ||||
| @@ -21,17 +21,29 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| /** | ||||
|  * SECTION:clutter-color | ||||
|  * @short_description: Color management and manipulation. | ||||
|  * | ||||
|  * #ClutterColor is a simple type for representing colors in Clutter. | ||||
|  * | ||||
|  * A #ClutterColor is expressed as a 4-tuple of values ranging from | ||||
|  * zero to 255, one for each color channel plus one for the alpha. | ||||
|  * | ||||
|  * The alpha channel is fully opaque at 255 and fully transparent at 0. | ||||
|  */ | ||||
|  | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include <math.h> | ||||
|  | ||||
| #include <pango/pango-attributes.h> | ||||
|  | ||||
| #include "clutter/clutter-interval.h" | ||||
| #include "clutter/clutter-main.h" | ||||
| #include "clutter/clutter-color.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter-interval.h" | ||||
| #include "clutter-main.h" | ||||
| #include "clutter-color.h" | ||||
| #include "clutter-private.h" | ||||
| #include "clutter-debug.h" | ||||
|  | ||||
| /* XXX - keep in sync with the ClutterStaticColor enumeration order */ | ||||
| static const ClutterColor static_colors[] = { | ||||
| @@ -98,6 +110,8 @@ static const ClutterColor static_colors[] = { | ||||
|  * | ||||
|  * Return value: a pointer to a static color; the returned pointer | ||||
|  *   is owned by Clutter and it should never be modified or freed | ||||
|  * | ||||
|  * Since: 1.6 | ||||
|  */ | ||||
| const ClutterColor * | ||||
| clutter_color_get_static (ClutterStaticColor color) | ||||
| @@ -597,7 +611,7 @@ parse_hsla (ClutterColor *color, | ||||
| /** | ||||
|  * clutter_color_from_string: | ||||
|  * @color: (out caller-allocates): return location for a #ClutterColor | ||||
|  * @str: a string specifying a color | ||||
|  * @str: a string specifiying a color | ||||
|  * | ||||
|  * Parses a string definition of a color, filling the #ClutterColor.red, | ||||
|  * #ClutterColor.green, #ClutterColor.blue and #ClutterColor.alpha fields  | ||||
| @@ -635,6 +649,8 @@ parse_hsla (ClutterColor *color, | ||||
|  * be fully opaque. | ||||
|  * | ||||
|  * Return value: %TRUE if parsing succeeded, and %FALSE otherwise | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| gboolean | ||||
| clutter_color_from_string (ClutterColor *color, | ||||
| @@ -767,6 +783,8 @@ clutter_color_from_string (ClutterColor *color, | ||||
|  * respectively. | ||||
|  * | ||||
|  * Return value: (transfer full): a newly-allocated text string | ||||
|  * | ||||
|  * Since: 0.2 | ||||
|  */ | ||||
| gchar * | ||||
| clutter_color_to_string (const ClutterColor *color) | ||||
| @@ -785,12 +803,14 @@ clutter_color_to_string (const ClutterColor *color) | ||||
|  * @v1: (type Clutter.Color): a #ClutterColor | ||||
|  * @v2: (type Clutter.Color): a #ClutterColor | ||||
|  * | ||||
|  * Compares two `ClutterColor`s and checks if they are the same. | ||||
|  * Compares two #ClutterColor<!-- -->s and checks if they are the same. | ||||
|  * | ||||
|  * This function can be passed to g_hash_table_new() as the @key_equal_func | ||||
|  * parameter, when using `ClutterColor`s as keys in a #GHashTable. | ||||
|  * parameter, when using #ClutterColor<!-- -->s as keys in a #GHashTable. | ||||
|  * | ||||
|  * Return value: %TRUE if the two colors are the same. | ||||
|  * | ||||
|  * Since: 0.2 | ||||
|  */ | ||||
| gboolean | ||||
| clutter_color_equal (gconstpointer v1, | ||||
| @@ -820,9 +840,11 @@ clutter_color_equal (gconstpointer v1, | ||||
|  * Converts a #ClutterColor to a hash value. | ||||
|  * | ||||
|  * This function can be passed to g_hash_table_new() as the @hash_func | ||||
|  * parameter, when using `ClutterColor`s as keys in a #GHashTable. | ||||
|  * parameter, when using #ClutterColor<!-- -->s as keys in a #GHashTable. | ||||
|  * | ||||
|  * Return value: a hash value corresponding to the color | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| guint | ||||
| clutter_color_hash (gconstpointer v) | ||||
| @@ -837,8 +859,10 @@ clutter_color_hash (gconstpointer v) | ||||
|  * @progress: the interpolation progress | ||||
|  * @result: (out): return location for the interpolation | ||||
|  * | ||||
|  * Interpolates between @initial and @final `ClutterColor`s | ||||
|  * Interpolates between @initial and @final #ClutterColor<!-- -->s | ||||
|  * using @progress | ||||
|  * | ||||
|  * Since: 1.6 | ||||
|  */ | ||||
| void | ||||
| clutter_color_interpolate (const ClutterColor *initial, | ||||
| @@ -880,12 +904,14 @@ clutter_color_progress (const GValue *a, | ||||
|  * freed using clutter_color_free(). | ||||
|  * | ||||
|  * Return value: (transfer full): an allocated copy of @color. | ||||
|  * | ||||
|  * Since: 0.2 | ||||
|  */ | ||||
| ClutterColor * | ||||
| clutter_color_copy (const ClutterColor *color) | ||||
| { | ||||
|   if (G_LIKELY (color != NULL)) | ||||
|     return g_memdup2 (color, sizeof (ClutterColor)); | ||||
|     return g_slice_dup (ClutterColor, color); | ||||
|  | ||||
|   return NULL; | ||||
| } | ||||
| @@ -895,12 +921,14 @@ clutter_color_copy (const ClutterColor *color) | ||||
|  * @color: a #ClutterColor | ||||
|  * | ||||
|  * Frees a color structure created with clutter_color_copy(). | ||||
|  * | ||||
|  * Since: 0.2 | ||||
|  */ | ||||
| void | ||||
| clutter_color_free (ClutterColor *color) | ||||
| { | ||||
|   if (G_LIKELY (color != NULL)) | ||||
|     g_free (color); | ||||
|     g_slice_free (ClutterColor, color); | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -914,12 +942,14 @@ clutter_color_free (ClutterColor *color) | ||||
|  * | ||||
|  * This function is the equivalent of: | ||||
|  * | ||||
|  * ```c | ||||
|  * |[ | ||||
|  *   clutter_color_init (clutter_color_alloc (), red, green, blue, alpha); | ||||
|  * ``` | ||||
|  * ]| | ||||
|  * | ||||
|  * Return value: (transfer full): the newly allocated color. | ||||
|  *   Use clutter_color_free() when done | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| ClutterColor * | ||||
| clutter_color_new (guint8 red, | ||||
| @@ -941,11 +971,13 @@ clutter_color_new (guint8 red, | ||||
|  * | ||||
|  * Return value: (transfer full): the newly allocated #ClutterColor; use | ||||
|  *   clutter_color_free() to free its resources | ||||
|  * | ||||
|  * Since: 1.12 | ||||
|  */ | ||||
| ClutterColor * | ||||
| clutter_color_alloc (void) | ||||
| { | ||||
|   return g_new0 (ClutterColor, 1); | ||||
|   return g_slice_new0 (ClutterColor); | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -959,6 +991,8 @@ clutter_color_alloc (void) | ||||
|  * Initializes @color with the given values. | ||||
|  * | ||||
|  * Return value: (transfer none): the initialized #ClutterColor | ||||
|  * | ||||
|  * Since: 1.12 | ||||
|  */ | ||||
| ClutterColor * | ||||
| clutter_color_init (ClutterColor *color, | ||||
| @@ -1024,6 +1058,8 @@ G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterColor, clutter_color, | ||||
|  * @color: the color to set | ||||
|  * | ||||
|  * Sets @value to @color. | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| void | ||||
| clutter_value_set_color (GValue             *value, | ||||
| @@ -1041,6 +1077,8 @@ clutter_value_set_color (GValue             *value, | ||||
|  * Gets the #ClutterColor contained in @value. | ||||
|  * | ||||
|  * Return value: (transfer none): the color inside the passed #GValue | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| const ClutterColor * | ||||
| clutter_value_get_color (const GValue *value) | ||||
| @@ -1134,6 +1172,8 @@ clutter_param_color_get_type (void) | ||||
|  * Creates a #GParamSpec for properties using #ClutterColor. | ||||
|  * | ||||
|  * Return value: the newly created #GParamSpec | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| GParamSpec * | ||||
| clutter_param_spec_color (const gchar        *name, | ||||
|   | ||||
| @@ -23,13 +23,14 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_COLOR_H__ | ||||
| #define __CLUTTER_COLOR_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-types.h" | ||||
| #include <clutter/clutter-types.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -42,12 +43,7 @@ G_BEGIN_DECLS | ||||
|  * @blue: blue component, between 0 and 255 | ||||
|  * @alpha: alpha component, between 0 and 255 | ||||
|  * | ||||
|  * A simple type for representing colors. | ||||
|  * | ||||
|  * A #ClutterColor is expressed as a 4-tuple of values ranging from | ||||
|  * zero to 255, one for each color channel plus one for the alpha. | ||||
|  * | ||||
|  * The alpha channel is fully opaque at 255 and fully transparent at 0. | ||||
|  * Color representation. | ||||
|  */ | ||||
| struct _ClutterColor | ||||
| { | ||||
| @@ -67,6 +63,8 @@ struct _ClutterColor | ||||
|  * @a: value for the alpha channel, between 0 and 255 | ||||
|  * | ||||
|  * A macro that initializes a #ClutterColor, to be used when declaring it. | ||||
|  * | ||||
|  * Since: 1.12 | ||||
|  */ | ||||
| #define CLUTTER_COLOR_INIT(r,g,b,a)     { (r), (g), (b), (a) } | ||||
|  | ||||
| @@ -153,7 +151,9 @@ void          clutter_color_interpolate (const ClutterColor *initial, | ||||
|  * CLUTTER_VALUE_HOLDS_COLOR: | ||||
|  * @x: a #GValue | ||||
|  * | ||||
|  * Evaluates to %TRUE if @x holds a `ClutterColor`. | ||||
|  * Evaluates to %TRUE if @x holds a #ClutterColor<!-- -->. | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| #define CLUTTER_VALUE_HOLDS_COLOR(x)       (G_VALUE_HOLDS ((x), CLUTTER_TYPE_COLOR)) | ||||
|  | ||||
| @@ -165,6 +165,8 @@ typedef struct _ClutterParamSpecColor  ClutterParamSpecColor; | ||||
|  * | ||||
|  * A #GParamSpec subclass for defining properties holding | ||||
|  * a #ClutterColor. | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  */ | ||||
| struct _ClutterParamSpecColor | ||||
| { | ||||
| @@ -194,3 +196,5 @@ CLUTTER_EXPORT | ||||
| const ClutterColor *clutter_color_get_static (ClutterStaticColor color); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_COLOR_H__ */ | ||||
|   | ||||
| @@ -23,28 +23,32 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterColorizeEffect: | ||||
|  *  | ||||
|  * A colorization effect | ||||
|  * SECTION:clutter-colorize-effect | ||||
|  * @short_description: A colorization effect | ||||
|  * @see_also: #ClutterEffect, #ClutterOffscreenEffect | ||||
|  * | ||||
|  * #ClutterColorizeEffect is a sub-class of #ClutterEffect that | ||||
|  * colorizes an actor with the given tint. | ||||
|  * | ||||
|  * #ClutterColorizeEffect is available since Clutter 1.4 | ||||
|  */ | ||||
|  | ||||
| #define CLUTTER_COLORIZE_EFFECT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_COLORIZE_EFFECT, ClutterColorizeEffectClass)) | ||||
| #define CLUTTER_IS_COLORIZE_EFFECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_COLORIZE_EFFECT)) | ||||
| #define CLUTTER_COLORIZE_EFFECT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_COLORIZE_EFFECT, ClutterColorizeEffectClass)) | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-colorize-effect.h" | ||||
| #define CLUTTER_ENABLE_EXPERIMENTAL_API | ||||
|  | ||||
| #include "clutter-colorize-effect.h" | ||||
|  | ||||
| #include "cogl/cogl.h" | ||||
|  | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-enum-types.h" | ||||
| #include "clutter/clutter-offscreen-effect.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-enum-types.h" | ||||
| #include "clutter-offscreen-effect.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| struct _ClutterColorizeEffect | ||||
| { | ||||
| @@ -55,6 +59,9 @@ struct _ClutterColorizeEffect | ||||
|  | ||||
|   gint tint_uniform; | ||||
|  | ||||
|   gint tex_width; | ||||
|   gint tex_height; | ||||
|  | ||||
|   CoglPipeline *pipeline; | ||||
| }; | ||||
|  | ||||
| @@ -97,15 +104,67 @@ G_DEFINE_TYPE (ClutterColorizeEffect, | ||||
|                clutter_colorize_effect, | ||||
|                CLUTTER_TYPE_OFFSCREEN_EFFECT); | ||||
|  | ||||
| static CoglPipeline * | ||||
| clutter_colorize_effect_create_pipeline (ClutterOffscreenEffect *effect, | ||||
|                                          CoglTexture            *texture) | ||||
| static gboolean | ||||
| clutter_colorize_effect_pre_paint (ClutterEffect *effect) | ||||
| { | ||||
|   ClutterColorizeEffect *colorize_effect = CLUTTER_COLORIZE_EFFECT (effect); | ||||
|   ClutterColorizeEffect *self = CLUTTER_COLORIZE_EFFECT (effect); | ||||
|   ClutterEffectClass *parent_class; | ||||
|  | ||||
|   cogl_pipeline_set_layer_texture (colorize_effect->pipeline, 0, texture); | ||||
|   if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect))) | ||||
|     return FALSE; | ||||
|  | ||||
|   return cogl_object_ref (colorize_effect->pipeline); | ||||
|   if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL)) | ||||
|     { | ||||
|       /* if we don't have support for GLSL shaders then we | ||||
|        * forcibly disable the ActorMeta | ||||
|        */ | ||||
|       g_warning ("Unable to use the ShaderEffect: the graphics hardware " | ||||
|                  "or the current GL driver does not implement support " | ||||
|                  "for the GLSL shading language."); | ||||
|       clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (effect), FALSE); | ||||
|       return FALSE; | ||||
|     } | ||||
|  | ||||
|   parent_class = CLUTTER_EFFECT_CLASS (clutter_colorize_effect_parent_class); | ||||
|   if (parent_class->pre_paint (effect)) | ||||
|     { | ||||
|       ClutterOffscreenEffect *offscreen_effect = | ||||
|         CLUTTER_OFFSCREEN_EFFECT (effect); | ||||
|       CoglHandle texture; | ||||
|  | ||||
|       texture = clutter_offscreen_effect_get_texture (offscreen_effect); | ||||
|       self->tex_width = cogl_texture_get_width (texture); | ||||
|       self->tex_height = cogl_texture_get_height (texture); | ||||
|  | ||||
|       cogl_pipeline_set_layer_texture (self->pipeline, 0, texture); | ||||
|  | ||||
|       return TRUE; | ||||
|     } | ||||
|   else | ||||
|     return FALSE; | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_colorize_effect_paint_target (ClutterOffscreenEffect *effect) | ||||
| { | ||||
|   ClutterColorizeEffect *self = CLUTTER_COLORIZE_EFFECT (effect); | ||||
|   CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer (); | ||||
|   ClutterActor *actor; | ||||
|   guint8 paint_opacity; | ||||
|  | ||||
|   actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect)); | ||||
|   paint_opacity = clutter_actor_get_paint_opacity (actor); | ||||
|  | ||||
|   cogl_pipeline_set_color4ub (self->pipeline, | ||||
|                               paint_opacity, | ||||
|                               paint_opacity, | ||||
|                               paint_opacity, | ||||
|                               paint_opacity); | ||||
|  | ||||
|   cogl_framebuffer_draw_rectangle (framebuffer, | ||||
|                                    self->pipeline, | ||||
|                                    0, 0, | ||||
|                                    self->tex_width, self->tex_height); | ||||
| } | ||||
|  | ||||
| static void | ||||
| @@ -166,11 +225,14 @@ clutter_colorize_effect_get_property (GObject    *gobject, | ||||
| static void | ||||
| clutter_colorize_effect_class_init (ClutterColorizeEffectClass *klass) | ||||
| { | ||||
|   ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass); | ||||
|   GObjectClass *gobject_class = G_OBJECT_CLASS (klass); | ||||
|   ClutterOffscreenEffectClass *offscreen_class; | ||||
|  | ||||
|   offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass); | ||||
|   offscreen_class->create_pipeline = clutter_colorize_effect_create_pipeline; | ||||
|   offscreen_class->paint_target = clutter_colorize_effect_paint_target; | ||||
|  | ||||
|   effect_class->pre_paint = clutter_colorize_effect_pre_paint; | ||||
|  | ||||
|   gobject_class->set_property = clutter_colorize_effect_set_property; | ||||
|   gobject_class->get_property = clutter_colorize_effect_get_property; | ||||
| @@ -180,9 +242,13 @@ clutter_colorize_effect_class_init (ClutterColorizeEffectClass *klass) | ||||
|    * ClutterColorizeEffect:tint: | ||||
|    * | ||||
|    * The tint to apply to the actor | ||||
|    * | ||||
|    * Since: 1.4 | ||||
|    */ | ||||
|   obj_props[PROP_TINT] = | ||||
|     clutter_param_spec_color ("tint", NULL, NULL, | ||||
|     clutter_param_spec_color ("tint", | ||||
|                               P_("Tint"), | ||||
|                               P_("The tint to apply"), | ||||
|                               &default_tint, | ||||
|                               CLUTTER_PARAM_READWRITE); | ||||
|  | ||||
| @@ -248,6 +314,8 @@ clutter_colorize_effect_init (ClutterColorizeEffect *self) | ||||
|  * clutter_actor_add_effect() | ||||
|  * | ||||
|  * Return value: the newly created #ClutterColorizeEffect or %NULL | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| ClutterEffect * | ||||
| clutter_colorize_effect_new (const ClutterColor *tint) | ||||
| @@ -263,6 +331,8 @@ clutter_colorize_effect_new (const ClutterColor *tint) | ||||
|  * @tint: the color to be used | ||||
|  * | ||||
|  * Sets the tint to be used when colorizing | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_colorize_effect_set_tint (ClutterColorizeEffect *effect, | ||||
| @@ -285,6 +355,8 @@ clutter_colorize_effect_set_tint (ClutterColorizeEffect *effect, | ||||
|  * @tint: (out caller-allocates): return location for the color used | ||||
|  * | ||||
|  * Retrieves the tint used by @effect | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| void | ||||
| clutter_colorize_effect_get_tint (ClutterColorizeEffect *effect, | ||||
|   | ||||
| @@ -22,14 +22,15 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_COLORIZE_EFFECT_H__ | ||||
| #define __CLUTTER_COLORIZE_EFFECT_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-color.h" | ||||
| #include "clutter/clutter-effect.h" | ||||
| #include <clutter/clutter-color.h> | ||||
| #include <clutter/clutter-effect.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -37,6 +38,14 @@ G_BEGIN_DECLS | ||||
| #define CLUTTER_COLORIZE_EFFECT(obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_COLORIZE_EFFECT, ClutterColorizeEffect)) | ||||
| #define CLUTTER_IS_COLORIZE_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_COLORIZE_EFFECT)) | ||||
|  | ||||
| /** | ||||
|  * ClutterColorizeEffect: | ||||
|  * | ||||
|  * #ClutterColorizeEffect is an opaque structure | ||||
|  * whose members cannot be directly accessed | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| typedef struct _ClutterColorizeEffect           ClutterColorizeEffect; | ||||
| typedef struct _ClutterColorizeEffectClass      ClutterColorizeEffectClass; | ||||
|  | ||||
| @@ -54,3 +63,5 @@ void           clutter_colorize_effect_get_tint (ClutterColorizeEffect *effect, | ||||
|                                                  ClutterColor          *tint); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_COLORIZE_EFFECT_H__ */ | ||||
|   | ||||
							
								
								
									
										16
									
								
								clutter/clutter/clutter-config.h.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								clutter/clutter/clutter-config.h.in
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #ifndef __CLUTTER_CONFIG_H__ | ||||
| #define __CLUTTER_CONFIG_H__ | ||||
|  | ||||
| #include <glib.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @CLUTTER_CONFIG_DEFINES@ | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_CONFIG_H__ */ | ||||
| @@ -19,9 +19,10 @@ | ||||
|  * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_CONSTRAINT_PRIVATE_H__ | ||||
| #define __CLUTTER_CONSTRAINT_PRIVATE_H__ | ||||
|  | ||||
| #include "clutter/clutter-constraint.h" | ||||
| #include "clutter-constraint.h" | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -29,4 +30,13 @@ gboolean clutter_constraint_update_allocation (ClutterConstraint *constraint, | ||||
|                                                ClutterActor      *actor, | ||||
|                                                ClutterActorBox   *allocation); | ||||
|  | ||||
| void clutter_constraint_update_preferred_size (ClutterConstraint  *constraint, | ||||
|                                                ClutterActor       *actor, | ||||
|                                                ClutterOrientation  direction, | ||||
|                                                float               for_size, | ||||
|                                                float              *minimum_size, | ||||
|                                                float              *natural_size); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_CONSTRAINT_PRIVATE_H__ */ | ||||
|   | ||||
| @@ -23,9 +23,10 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterConstraint: | ||||
|  *  | ||||
|  * Abstract class for constraints on position or size | ||||
|  * SECTION:clutter-constraint | ||||
|  * @Title: ClutterConstraint | ||||
|  * @Short_Description: Abstract class for constraints on position or size | ||||
|  * @See_Also: #ClutterAction | ||||
|  * | ||||
|  * #ClutterConstraint is a base abstract class for modifiers of a #ClutterActor | ||||
|  * position or size. | ||||
| @@ -36,6 +37,8 @@ | ||||
|  * allocation of the actor to which they are applied by overriding the | ||||
|  * #ClutterConstraintClass.update_allocation() virtual function. | ||||
|  * | ||||
|  * #ClutterConstraint is available since Clutter 1.4 | ||||
|  * | ||||
|  * ## Using Constraints | ||||
|  * | ||||
|  * Constraints can be used with fixed layout managers, like | ||||
| @@ -45,7 +48,7 @@ | ||||
|  * Constraints provide a way to build user interfaces by using | ||||
|  * relations between #ClutterActors, without explicit fixed | ||||
|  * positioning and sizing, similarly to how fluid layout managers like | ||||
|  * #ClutterBoxLayout lay out their children. | ||||
|  * #ClutterBoxLayout and #ClutterTableLayout lay out their children. | ||||
|  * | ||||
|  * Constraints are attached to a #ClutterActor, and are available | ||||
|  * for inspection using clutter_actor_get_constraints(). | ||||
| @@ -125,15 +128,15 @@ | ||||
|  * can be recovered at any point using clutter_actor_meta_get_actor(). | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include <string.h> | ||||
|  | ||||
| #include "clutter/clutter-constraint-private.h" | ||||
| #include "clutter-constraint-private.h" | ||||
|  | ||||
| #include "clutter/clutter-actor.h" | ||||
| #include "clutter/clutter-actor-meta-private.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-actor.h" | ||||
| #include "clutter-actor-meta-private.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| G_DEFINE_ABSTRACT_TYPE (ClutterConstraint, | ||||
|                         clutter_constraint, | ||||
| @@ -157,26 +160,28 @@ constraint_update_preferred_size (ClutterConstraint  *constraint, | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_constraint_set_enabled (ClutterActorMeta *meta, | ||||
|                                 gboolean          is_enabled) | ||||
| clutter_constraint_notify (GObject    *gobject, | ||||
|                            GParamSpec *pspec) | ||||
| { | ||||
|   ClutterActorMetaClass *parent_class = | ||||
|     CLUTTER_ACTOR_META_CLASS (clutter_constraint_parent_class); | ||||
|   ClutterActor *actor; | ||||
|   if (strcmp (pspec->name, "enabled") == 0) | ||||
|     { | ||||
|       ClutterActorMeta *meta = CLUTTER_ACTOR_META (gobject); | ||||
|       ClutterActor *actor = clutter_actor_meta_get_actor (meta); | ||||
|  | ||||
|   actor = clutter_actor_meta_get_actor (meta); | ||||
|   if (actor) | ||||
|     clutter_actor_queue_relayout (actor); | ||||
|       if (actor != NULL) | ||||
|         clutter_actor_queue_relayout (actor); | ||||
|     } | ||||
|  | ||||
|   parent_class->set_enabled (meta, is_enabled); | ||||
|   if (G_OBJECT_CLASS (clutter_constraint_parent_class)->notify != NULL) | ||||
|     G_OBJECT_CLASS (clutter_constraint_parent_class)->notify (gobject, pspec); | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_constraint_class_init (ClutterConstraintClass *klass) | ||||
| { | ||||
|   ClutterActorMetaClass *actor_meta_class = CLUTTER_ACTOR_META_CLASS (klass); | ||||
|   GObjectClass *gobject_class = G_OBJECT_CLASS (klass); | ||||
|  | ||||
|   actor_meta_class->set_enabled = clutter_constraint_set_enabled; | ||||
|   gobject_class->notify = clutter_constraint_notify; | ||||
|  | ||||
|   klass->update_allocation = constraint_update_allocation; | ||||
|   klass->update_preferred_size = constraint_update_preferred_size; | ||||
| @@ -217,17 +222,6 @@ clutter_constraint_update_allocation (ClutterConstraint *constraint, | ||||
|   return !clutter_actor_box_equal (allocation, &old_alloc); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_constraint_update_preferred_size: | ||||
|  * @constraint: a #ClutterConstraint | ||||
|  * @actor: a #ClutterActor | ||||
|  * @direction: a #ClutterOrientation | ||||
|  * @for_size: the size in the opposite direction | ||||
|  * @minimum_size: (inout): the minimum size to modify | ||||
|  * @natural_size: (inout): the natural size to modify | ||||
|  * | ||||
|  * Asks the @constraint to update the size request of a #ClutterActor. | ||||
|  */ | ||||
| void | ||||
| clutter_constraint_update_preferred_size (ClutterConstraint  *constraint, | ||||
|                                           ClutterActor       *actor, | ||||
|   | ||||
| @@ -22,13 +22,14 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_CONSTRAINT_H__ | ||||
| #define __CLUTTER_CONSTRAINT_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-actor-meta.h" | ||||
| #include <clutter/clutter-actor-meta.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -41,6 +42,14 @@ G_BEGIN_DECLS | ||||
|  | ||||
| typedef struct _ClutterConstraintClass          ClutterConstraintClass; | ||||
|  | ||||
| /** | ||||
|  * ClutterConstraint: | ||||
|  * | ||||
|  * The #ClutterConstraint structure contains only | ||||
|  * private data and should be accessed using the provided API | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _ClutterConstraint | ||||
| { | ||||
|   /*< private >*/ | ||||
| @@ -57,6 +66,8 @@ struct _ClutterConstraint | ||||
|  * | ||||
|  * The #ClutterConstraintClass structure contains | ||||
|  * only private data | ||||
|  * | ||||
|  * Since: 1.4 | ||||
|  */ | ||||
| struct _ClutterConstraintClass | ||||
| { | ||||
| @@ -74,19 +85,20 @@ struct _ClutterConstraintClass | ||||
|                                   float               for_size, | ||||
|                                   float              *minimum_size, | ||||
|                                   float              *natural_size); | ||||
|  | ||||
|   /*< private >*/ | ||||
|   void (* _clutter_constraint1) (void); | ||||
|   void (* _clutter_constraint2) (void); | ||||
|   void (* _clutter_constraint3) (void); | ||||
|   void (* _clutter_constraint4) (void); | ||||
|   void (* _clutter_constraint5) (void); | ||||
|   void (* _clutter_constraint6) (void); | ||||
|   void (* _clutter_constraint7) (void); | ||||
| }; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| GType clutter_constraint_get_type (void) G_GNUC_CONST; | ||||
|  | ||||
| CLUTTER_EXPORT | ||||
| void clutter_constraint_update_preferred_size (ClutterConstraint  *constraint, | ||||
|                                                ClutterActor       *actor, | ||||
|                                                ClutterOrientation  direction, | ||||
|                                                float               for_size, | ||||
|                                                float              *minimum_size, | ||||
|                                                float              *natural_size); | ||||
|  | ||||
| /* ClutterActor API */ | ||||
| CLUTTER_EXPORT | ||||
| void               clutter_actor_add_constraint            (ClutterActor      *self, | ||||
| @@ -113,3 +125,5 @@ CLUTTER_EXPORT | ||||
| gboolean           clutter_actor_has_constraints           (ClutterActor      *self); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_CONSTRAINT_H__ */ | ||||
|   | ||||
| @@ -26,23 +26,22 @@ | ||||
|  * Author: Emmanuele Bassi <ebassi@openedhand.com> | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include <stdarg.h> | ||||
| #include <glib-object.h> | ||||
| #include <gobject/gvaluecollector.h> | ||||
|  | ||||
| #define CLUTTER_DISABLE_DEPRECATION_WARNINGS | ||||
| #include "clutter/deprecated/clutter-container.h" | ||||
| #include "deprecated/clutter-container.h" | ||||
|  | ||||
| #include "clutter/clutter-actor-private.h" | ||||
| #include "clutter/clutter-child-meta.h" | ||||
| #include "clutter/clutter-container-private.h" | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-main.h" | ||||
| #include "clutter/clutter-marshal.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter/clutter-enum-types.h" | ||||
| #include "clutter-actor-private.h" | ||||
| #include "clutter-child-meta.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-main.h" | ||||
| #include "clutter-marshal.h" | ||||
| #include "clutter-private.h" | ||||
| #include "clutter-enum-types.h" | ||||
|  | ||||
| #define CLUTTER_CONTAINER_WARN_NOT_IMPLEMENTED(container,vfunc) \ | ||||
|         G_STMT_START { \ | ||||
| @@ -63,14 +62,20 @@ | ||||
|         } G_STMT_END | ||||
|  | ||||
| /** | ||||
|  * ClutterContainer: | ||||
|  *  | ||||
|  * An interface for container actors | ||||
|  * SECTION:clutter-container | ||||
|  * @short_description: An interface for container actors | ||||
|  * | ||||
|  * #ClutterContainer is an interface implemented by [class@Actor], and | ||||
|  * #ClutterContainer is an interface implemented by #ClutterActor, and | ||||
|  * it provides some common API for notifying when a child actor is added | ||||
|  * or removed, as well as the infrastructure for accessing child properties | ||||
|  * through [class@ChildMeta]. | ||||
|  * through #ClutterChildMeta. | ||||
|  * | ||||
|  * Until Clutter 1.10, the #ClutterContainer interface was also the public | ||||
|  * API for implementing container actors; this part of the interface has | ||||
|  * been deprecated: #ClutterContainer has a default implementation which | ||||
|  * defers to #ClutterActor the child addition and removal, as well as the | ||||
|  * iteration. See the documentation of #ClutterContainerIface for the list | ||||
|  * of virtual functions that should be overridden. | ||||
|  */ | ||||
|  | ||||
| enum | ||||
| @@ -113,6 +118,62 @@ container_real_remove (ClutterContainer *container, | ||||
|   clutter_actor_remove_child (CLUTTER_ACTOR (container), actor); | ||||
| } | ||||
|  | ||||
| typedef struct { | ||||
|   ClutterCallback callback; | ||||
|   gpointer data; | ||||
| } ForeachClosure; | ||||
|  | ||||
| static gboolean | ||||
| foreach_cb (ClutterActor *actor, | ||||
|             gpointer      data) | ||||
| { | ||||
|   ForeachClosure *clos = data; | ||||
|  | ||||
|   clos->callback (actor, clos->data); | ||||
|  | ||||
|   return TRUE; | ||||
| } | ||||
|  | ||||
| static void | ||||
| container_real_foreach (ClutterContainer *container, | ||||
|                         ClutterCallback   callback, | ||||
|                         gpointer          user_data) | ||||
| { | ||||
|   ForeachClosure clos; | ||||
|  | ||||
|   clos.callback = callback; | ||||
|   clos.data = user_data; | ||||
|  | ||||
|   _clutter_actor_foreach_child (CLUTTER_ACTOR (container), | ||||
|                                 foreach_cb, | ||||
|                                 &clos); | ||||
| } | ||||
|  | ||||
| static void | ||||
| container_real_raise (ClutterContainer *container, | ||||
|                       ClutterActor     *child, | ||||
|                       ClutterActor     *sibling) | ||||
| { | ||||
|   ClutterActor *self = CLUTTER_ACTOR (container); | ||||
|  | ||||
|   clutter_actor_set_child_above_sibling (self, child, sibling); | ||||
| } | ||||
|  | ||||
| static void | ||||
| container_real_lower (ClutterContainer *container, | ||||
|                       ClutterActor     *child, | ||||
|                       ClutterActor     *sibling) | ||||
| { | ||||
|   ClutterActor *self = CLUTTER_ACTOR (container); | ||||
|  | ||||
|   clutter_actor_set_child_below_sibling (self, child, sibling); | ||||
| } | ||||
|  | ||||
| static void | ||||
| container_real_sort_depth_order (ClutterContainer *container) | ||||
| { | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_container_default_init (ClutterContainerInterface *iface) | ||||
| { | ||||
| @@ -126,15 +187,18 @@ clutter_container_default_init (ClutterContainerInterface *iface) | ||||
|    * @container: the actor which received the signal | ||||
|    * @actor: the new child that has been added to @container | ||||
|    * | ||||
|    * The signal is emitted each time an actor | ||||
|    * The ::actor-added signal is emitted each time an actor | ||||
|    * has been added to @container. | ||||
|    * | ||||
|    * Since: 0.4 | ||||
|    */ | ||||
|   container_signals[ACTOR_ADDED] = | ||||
|     g_signal_new (I_("actor-added"), | ||||
|                   iface_type, | ||||
|                   G_SIGNAL_RUN_FIRST, | ||||
|                   G_STRUCT_OFFSET (ClutterContainerIface, actor_added), | ||||
|                   NULL, NULL, NULL, | ||||
|                   NULL, NULL, | ||||
|                   _clutter_marshal_VOID__OBJECT, | ||||
|                   G_TYPE_NONE, 1, | ||||
|                   CLUTTER_TYPE_ACTOR); | ||||
|   /** | ||||
| @@ -142,15 +206,18 @@ clutter_container_default_init (ClutterContainerInterface *iface) | ||||
|    * @container: the actor which received the signal | ||||
|    * @actor: the child that has been removed from @container | ||||
|    * | ||||
|    * The signal is emitted each time an actor | ||||
|    * The ::actor-removed signal is emitted each time an actor | ||||
|    * is removed from @container. | ||||
|    * | ||||
|    * Since: 0.4 | ||||
|    */ | ||||
|   container_signals[ACTOR_REMOVED] = | ||||
|     g_signal_new (I_("actor-removed"), | ||||
|                   iface_type, | ||||
|                   G_SIGNAL_RUN_FIRST, | ||||
|                   G_STRUCT_OFFSET (ClutterContainerIface, actor_removed), | ||||
|                   NULL, NULL, NULL, | ||||
|                   NULL, NULL, | ||||
|                   _clutter_marshal_VOID__OBJECT, | ||||
|                   G_TYPE_NONE, 1, | ||||
|                   CLUTTER_TYPE_ACTOR); | ||||
|  | ||||
| @@ -160,9 +227,11 @@ clutter_container_default_init (ClutterContainerInterface *iface) | ||||
|    * @actor: the child that has had a property set | ||||
|    * @pspec: (type GParamSpec): the #GParamSpec of the property set | ||||
|    * | ||||
|    * The signal is emitted each time a property is | ||||
|    * The ::child-notify signal is emitted each time a property is | ||||
|    * being set through the clutter_container_child_set() and | ||||
|    * clutter_container_child_set_property() calls. | ||||
|    * | ||||
|    * Since: 0.8 | ||||
|    */ | ||||
|   container_signals[CHILD_NOTIFY] = | ||||
|     g_signal_new (I_("child-notify"), | ||||
| @@ -176,6 +245,10 @@ clutter_container_default_init (ClutterContainerInterface *iface) | ||||
|  | ||||
|   iface->add = container_real_add; | ||||
|   iface->remove = container_real_remove; | ||||
|   iface->foreach = container_real_foreach; | ||||
|   iface->raise = container_real_raise; | ||||
|   iface->lower = container_real_lower; | ||||
|   iface->sort_depth_order = container_real_sort_depth_order; | ||||
|  | ||||
|   iface->child_meta_type = G_TYPE_INVALID; | ||||
|   iface->create_child_meta = create_child_meta; | ||||
| @@ -289,7 +362,7 @@ container_remove_valist (ClutterContainer *container, | ||||
|  * @first_actor: the first #ClutterActor to add | ||||
|  * @...: %NULL terminated list of actors to add | ||||
|  * | ||||
|  * Adds a list of `ClutterActor`s to @container. Each time and | ||||
|  * Adds a list of #ClutterActor<!-- -->s to @container. Each time and | ||||
|  * actor is added, the "actor-added" signal is emitted. Each actor should | ||||
|  * be parented to @container, which takes a reference on the actor. You | ||||
|  * cannot add a #ClutterActor to more than one #ClutterContainer. | ||||
| @@ -298,6 +371,8 @@ container_remove_valist (ClutterContainer *container, | ||||
|  * deprecated virtual function. The default implementation will | ||||
|  * call clutter_actor_add_child(). | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  * | ||||
|  * Deprecated: 1.10: Use clutter_actor_add_child() instead. | ||||
|  */ | ||||
| void | ||||
| @@ -329,6 +404,8 @@ clutter_container_add (ClutterContainer *container, | ||||
|  * deprecated virtual function. The default implementation will | ||||
|  * call clutter_actor_add_child(). | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  * | ||||
|  * Deprecated: 1.10: Use clutter_actor_add_child() instead. | ||||
|  */ | ||||
| void | ||||
| @@ -341,13 +418,40 @@ clutter_container_add_actor (ClutterContainer *container, | ||||
|   container_add_actor (container, actor); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_container_add_valist: (skip) | ||||
|  * @container: a #ClutterContainer | ||||
|  * @first_actor: the first #ClutterActor to add | ||||
|  * @var_args: list of actors to add, followed by %NULL | ||||
|  * | ||||
|  * Alternative va_list version of clutter_container_add(). | ||||
|  * | ||||
|  * This function will call #ClutterContainerIface.add(), which is a | ||||
|  * deprecated virtual function. The default implementation will | ||||
|  * call clutter_actor_add_child(). | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  * | ||||
|  * Deprecated: 1.10: Use clutter_actor_add_child() instead. | ||||
|  */ | ||||
| void | ||||
| clutter_container_add_valist (ClutterContainer *container, | ||||
|                               ClutterActor     *first_actor, | ||||
|                               va_list           var_args) | ||||
| { | ||||
|   g_return_if_fail (CLUTTER_IS_CONTAINER (container)); | ||||
|   g_return_if_fail (CLUTTER_IS_ACTOR (first_actor)); | ||||
|  | ||||
|   container_add_valist (container, first_actor, var_args); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_container_remove: (skip) | ||||
|  * @container: a #ClutterContainer | ||||
|  * @first_actor: first #ClutterActor to remove | ||||
|  * @...: a %NULL-terminated list of actors to remove | ||||
|  * | ||||
|  * Removes a %NULL terminated list of `ClutterActor`s from | ||||
|  * Removes a %NULL terminated list of #ClutterActor<!-- -->s from | ||||
|  * @container. Each actor should be unparented, so if you want to keep it | ||||
|  * around you must hold a reference to it yourself, using g_object_ref(). | ||||
|  * Each time an actor is removed, the "actor-removed" signal is | ||||
| @@ -357,6 +461,8 @@ clutter_container_add_actor (ClutterContainer *container, | ||||
|  * deprecated virtual function. The default implementation will call | ||||
|  * clutter_actor_remove_child(). | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  * | ||||
|  * Deprecated: 1.10: Use clutter_actor_remove_child() instead. | ||||
|  */ | ||||
| void | ||||
| @@ -388,6 +494,8 @@ clutter_container_remove (ClutterContainer *container, | ||||
|  * deprecated virtual function. The default implementation will call | ||||
|  * clutter_actor_remove_child(). | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  * | ||||
|  * Deprecated: 1.10: Use clutter_actor_remove_child() instead. | ||||
|  */ | ||||
| void | ||||
| @@ -400,6 +508,337 @@ clutter_container_remove_actor (ClutterContainer *container, | ||||
|   container_remove_actor (container, actor); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_container_remove_valist: (skip) | ||||
|  * @container: a #ClutterContainer | ||||
|  * @first_actor: the first #ClutterActor to add | ||||
|  * @var_args: list of actors to remove, followed by %NULL | ||||
|  * | ||||
|  * Alternative va_list version of clutter_container_remove(). | ||||
|  * | ||||
|  * This function will call #ClutterContainerIface.remove(), which is a | ||||
|  * deprecated virtual function. The default implementation will call | ||||
|  * clutter_actor_remove_child(). | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  * | ||||
|  * Deprecated: 1.10: Use clutter_actor_remove_child() instead. | ||||
|  */ | ||||
| void | ||||
| clutter_container_remove_valist (ClutterContainer *container, | ||||
|                                  ClutterActor     *first_actor, | ||||
|                                  va_list           var_args) | ||||
| { | ||||
|   g_return_if_fail (CLUTTER_IS_CONTAINER (container)); | ||||
|   g_return_if_fail (CLUTTER_IS_ACTOR (first_actor)); | ||||
|  | ||||
|   container_remove_valist (container, first_actor, var_args); | ||||
| } | ||||
|  | ||||
| static void | ||||
| get_children_cb (ClutterActor *child, | ||||
|                  gpointer      data) | ||||
| { | ||||
|   GList **children = data; | ||||
|  | ||||
|   *children = g_list_prepend (*children, child); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_container_get_children: | ||||
|  * @container: a #ClutterContainer | ||||
|  * | ||||
|  * Retrieves all the children of @container. | ||||
|  * | ||||
|  * Return value: (element-type Clutter.Actor) (transfer container): a list | ||||
|  *   of #ClutterActor<!-- -->s. Use g_list_free() on the returned | ||||
|  *   list when done. | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  * | ||||
|  * Deprecated: 1.10: Use clutter_actor_get_children() instead. | ||||
|  */ | ||||
| GList * | ||||
| clutter_container_get_children (ClutterContainer *container) | ||||
| { | ||||
|   GList *retval; | ||||
|  | ||||
|   g_return_val_if_fail (CLUTTER_IS_CONTAINER (container), NULL); | ||||
|  | ||||
|   retval = NULL; | ||||
|   clutter_container_foreach (container, get_children_cb, &retval); | ||||
|  | ||||
|   return g_list_reverse (retval); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_container_foreach: | ||||
|  * @container: a #ClutterContainer | ||||
|  * @callback: (scope call): a function to be called for each child | ||||
|  * @user_data: data to be passed to the function, or %NULL | ||||
|  * | ||||
|  * Calls @callback for each child of @container that was added | ||||
|  * by the application (with clutter_container_add_actor()). Does | ||||
|  * not iterate over "internal" children that are part of the | ||||
|  * container's own implementation, if any. | ||||
|  * | ||||
|  * This function calls the #ClutterContainerIface.foreach() | ||||
|  * virtual function, which has been deprecated. | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  * | ||||
|  * Deprecated: 1.10: Use clutter_actor_get_first_child() or | ||||
|  *   clutter_actor_get_last_child() to retrieve the beginning of | ||||
|  *   the list of children, and clutter_actor_get_next_sibling() | ||||
|  *   and clutter_actor_get_previous_sibling() to iterate over it; | ||||
|  *   alternatively, use the #ClutterActorIter API. | ||||
|  */ | ||||
| void | ||||
| clutter_container_foreach (ClutterContainer *container, | ||||
|                            ClutterCallback   callback, | ||||
|                            gpointer          user_data) | ||||
| { | ||||
|   g_return_if_fail (CLUTTER_IS_CONTAINER (container)); | ||||
|   g_return_if_fail (callback != NULL); | ||||
|  | ||||
| #ifdef CLUTTER_ENABLE_DEBUG | ||||
|   if (G_UNLIKELY (_clutter_diagnostic_enabled ())) | ||||
|     { | ||||
|       ClutterContainerIface *iface = CLUTTER_CONTAINER_GET_IFACE (container); | ||||
|  | ||||
|       if (iface->foreach != container_real_foreach) | ||||
|         _clutter_diagnostic_message ("The ClutterContainer::foreach() " | ||||
|                                      "virtual function has been deprecated " | ||||
|                                      "and it should not be overridden by " | ||||
|                                      "newly written code"); | ||||
|     } | ||||
| #endif /* CLUTTER_ENABLE_DEBUG */ | ||||
|  | ||||
|   CLUTTER_CONTAINER_GET_IFACE (container)->foreach (container, | ||||
|                                                     callback, | ||||
|                                                     user_data); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_container_foreach_with_internals: | ||||
|  * @container: a #ClutterContainer | ||||
|  * @callback: (scope call): a function to be called for each child | ||||
|  * @user_data: data to be passed to the function, or %NULL | ||||
|  * | ||||
|  * Calls @callback for each child of @container, including "internal" | ||||
|  * children built in to the container itself that were never added | ||||
|  * by the application. | ||||
|  * | ||||
|  * This function calls the #ClutterContainerIface.foreach_with_internals() | ||||
|  * virtual function, which has been deprecated. | ||||
|  * | ||||
|  * Since: 1.0 | ||||
|  * | ||||
|  * Deprecated: 1.10: See clutter_container_foreach(). | ||||
|  */ | ||||
| void | ||||
| clutter_container_foreach_with_internals (ClutterContainer *container, | ||||
|                                           ClutterCallback   callback, | ||||
|                                           gpointer          user_data) | ||||
| { | ||||
|   ClutterContainerIface *iface; | ||||
|  | ||||
|   g_return_if_fail (CLUTTER_IS_CONTAINER (container)); | ||||
|   g_return_if_fail (callback != NULL); | ||||
|  | ||||
|   iface = CLUTTER_CONTAINER_GET_IFACE (container); | ||||
|  | ||||
| #ifdef CLUTTER_ENABLE_DEBUG | ||||
|   if (G_UNLIKELY (_clutter_diagnostic_enabled ())) | ||||
|     { | ||||
|       if (iface->foreach_with_internals != NULL) | ||||
|         _clutter_diagnostic_message ("The ClutterContainer::foreach_with_internals() " | ||||
|                                      "virtual function has been deprecated " | ||||
|                                      "and it should not be overridden by " | ||||
|                                      "newly written code"); | ||||
|     } | ||||
| #endif /* CLUTTER_ENABLE_DEBUG */ | ||||
|  | ||||
|   if (iface->foreach_with_internals != NULL) | ||||
|     iface->foreach_with_internals (container, callback, user_data); | ||||
|   else | ||||
|     iface->foreach (container, callback, user_data); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_container_raise_child: (virtual raise) | ||||
|  * @container: a #ClutterContainer | ||||
|  * @actor: the actor to raise | ||||
|  * @sibling: (allow-none): the sibling to raise to, or %NULL to raise | ||||
|  *   to the top | ||||
|  * | ||||
|  * Raises @actor to @sibling level, in the depth ordering. | ||||
|  * | ||||
|  * This function calls the #ClutterContainerIface.raise() virtual function, | ||||
|  * which has been deprecated. The default implementation will call | ||||
|  * clutter_actor_set_child_above_sibling(). | ||||
|  * | ||||
|  * Since: 0.6 | ||||
|  * | ||||
|  * Deprecated: 1.10: Use clutter_actor_set_child_above_sibling() instead. | ||||
|  */ | ||||
| void | ||||
| clutter_container_raise_child (ClutterContainer *container, | ||||
|                                ClutterActor     *actor, | ||||
|                                ClutterActor     *sibling) | ||||
| { | ||||
|   ClutterContainerIface *iface; | ||||
|   ClutterActor *self; | ||||
|  | ||||
|   g_return_if_fail (CLUTTER_IS_CONTAINER (container)); | ||||
|   g_return_if_fail (CLUTTER_IS_ACTOR (actor)); | ||||
|   g_return_if_fail (sibling == NULL || CLUTTER_IS_ACTOR (sibling)); | ||||
|  | ||||
|   if (actor == sibling) | ||||
|     return; | ||||
|  | ||||
|   self = CLUTTER_ACTOR (container); | ||||
|  | ||||
|   if (clutter_actor_get_parent (actor) != self) | ||||
|     { | ||||
|       g_warning ("Actor of type '%s' is not a child of the container " | ||||
|                  "of type '%s'", | ||||
|                  g_type_name (G_OBJECT_TYPE (actor)), | ||||
|                  g_type_name (G_OBJECT_TYPE (container))); | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|   if (sibling != NULL && | ||||
|       clutter_actor_get_parent (sibling) != self) | ||||
|     { | ||||
|       g_warning ("Actor of type '%s' is not a child of the container " | ||||
|                  "of type '%s'", | ||||
|                  g_type_name (G_OBJECT_TYPE (sibling)), | ||||
|                  g_type_name (G_OBJECT_TYPE (container))); | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|   iface = CLUTTER_CONTAINER_GET_IFACE (container); | ||||
|  | ||||
| #ifdef CLUTTER_ENABLE_DEBUG | ||||
|   if (G_UNLIKELY (_clutter_diagnostic_enabled ())) | ||||
|     { | ||||
|       if (iface->raise != container_real_raise) | ||||
|         _clutter_diagnostic_message ("The ClutterContainer::raise() " | ||||
|                                      "virtual function has been deprecated " | ||||
|                                      "and it should not be overridden by " | ||||
|                                      "newly written code"); | ||||
|     } | ||||
| #endif /* CLUTTER_ENABLE_DEBUG */ | ||||
|  | ||||
|   iface->raise (container, actor, sibling); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_container_lower_child: (virtual lower) | ||||
|  * @container: a #ClutterContainer | ||||
|  * @actor: the actor to raise | ||||
|  * @sibling: (allow-none): the sibling to lower to, or %NULL to lower | ||||
|  *   to the bottom | ||||
|  * | ||||
|  * Lowers @actor to @sibling level, in the depth ordering. | ||||
|  * | ||||
|  * This function calls the #ClutterContainerIface.lower() virtual function, | ||||
|  * which has been deprecated. The default implementation will call | ||||
|  * clutter_actor_set_child_below_sibling(). | ||||
|  * | ||||
|  * Since: 0.6 | ||||
|  * | ||||
|  * Deprecated: 1.10: Use clutter_actor_set_child_below_sibling() instead. | ||||
|  */ | ||||
| void | ||||
| clutter_container_lower_child (ClutterContainer *container, | ||||
|                                ClutterActor     *actor, | ||||
|                                ClutterActor     *sibling) | ||||
| { | ||||
|   ClutterContainerIface *iface; | ||||
|   ClutterActor *self; | ||||
|  | ||||
|   g_return_if_fail (CLUTTER_IS_CONTAINER (container)); | ||||
|   g_return_if_fail (CLUTTER_IS_ACTOR (actor)); | ||||
|   g_return_if_fail (sibling == NULL || CLUTTER_IS_ACTOR (sibling)); | ||||
|  | ||||
|   if (actor == sibling) | ||||
|     return; | ||||
|  | ||||
|   self = CLUTTER_ACTOR (container); | ||||
|  | ||||
|   if (clutter_actor_get_parent (actor) != self) | ||||
|     { | ||||
|       g_warning ("Actor of type '%s' is not a child of the container " | ||||
|                  "of type '%s'", | ||||
|                  g_type_name (G_OBJECT_TYPE (actor)), | ||||
|                  g_type_name (G_OBJECT_TYPE (container))); | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|   if (sibling != NULL&& | ||||
|       clutter_actor_get_parent (sibling) != self) | ||||
|     { | ||||
|       g_warning ("Actor of type '%s' is not a child of the container " | ||||
|                  "of type '%s'", | ||||
|                  g_type_name (G_OBJECT_TYPE (sibling)), | ||||
|                  g_type_name (G_OBJECT_TYPE (container))); | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|   iface = CLUTTER_CONTAINER_GET_IFACE (container); | ||||
|  | ||||
| #ifdef CLUTTER_ENABLE_DEBUG | ||||
|   if (G_UNLIKELY (_clutter_diagnostic_enabled ())) | ||||
|     { | ||||
|       if (iface->lower != container_real_lower) | ||||
|         _clutter_diagnostic_message ("The ClutterContainer::lower() " | ||||
|                                      "virtual function has been deprecated " | ||||
|                                      "and it should not be overridden by " | ||||
|                                      "newly written code"); | ||||
|     } | ||||
| #endif /* CLUTTER_ENABLE_DEBUG */ | ||||
|  | ||||
|   iface->lower (container, actor, sibling); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_container_sort_depth_order: | ||||
|  * @container: a #ClutterContainer | ||||
|  * | ||||
|  * Sorts a container's children using their depth. This function should not | ||||
|  * be normally used by applications. | ||||
|  * | ||||
|  * Since: 0.6 | ||||
|  * | ||||
|  * Deprecated: 1.10: The #ClutterContainerIface.sort_depth_order() virtual | ||||
|  *   function should not be used any more; the default implementation in | ||||
|  *   #ClutterContainer does not do anything. | ||||
|  */ | ||||
| void | ||||
| clutter_container_sort_depth_order (ClutterContainer *container) | ||||
| { | ||||
|   ClutterContainerIface *iface; | ||||
|  | ||||
|   g_return_if_fail (CLUTTER_IS_CONTAINER (container)); | ||||
|  | ||||
|   iface = CLUTTER_CONTAINER_GET_IFACE (container); | ||||
|  | ||||
| #ifdef CLUTTER_ENABLE_DEBUG | ||||
|   if (G_UNLIKELY (_clutter_diagnostic_enabled ())) | ||||
|     { | ||||
|       if (iface->sort_depth_order != container_real_sort_depth_order) | ||||
|         _clutter_diagnostic_message ("The ClutterContainer::sort_depth_order() " | ||||
|                                      "virtual function has been deprecated " | ||||
|                                      "and it should not be overridden by " | ||||
|                                      "newly written code"); | ||||
|     } | ||||
| #endif /* CLUTTER_ENABLE_DEBUG */ | ||||
|  | ||||
|   iface->sort_depth_order (container); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_container_find_child_by_name: | ||||
|  * @container: a #ClutterContainer | ||||
| @@ -410,6 +849,8 @@ clutter_container_remove_actor (ClutterContainer *container, | ||||
|  * | ||||
|  * Return value: (transfer none): The child actor with the requested name, | ||||
|  *   or %NULL if no actor with that name was found. | ||||
|  * | ||||
|  * Since: 0.6 | ||||
|  */ | ||||
| ClutterActor * | ||||
| clutter_container_find_child_by_name (ClutterContainer *container, | ||||
| @@ -422,7 +863,7 @@ clutter_container_find_child_by_name (ClutterContainer *container, | ||||
|   g_return_val_if_fail (CLUTTER_IS_CONTAINER (container), NULL); | ||||
|   g_return_val_if_fail (child_name != NULL, NULL); | ||||
|  | ||||
|   children = clutter_actor_get_children (CLUTTER_ACTOR (container)); | ||||
|   children = clutter_container_get_children (container); | ||||
|  | ||||
|   for (iter = children; iter; iter = g_list_next (iter)) | ||||
|     { | ||||
| @@ -518,8 +959,10 @@ destroy_child_meta (ClutterContainer *container, | ||||
|  * @container specific state for @actor. | ||||
|  * | ||||
|  * Return value: (transfer none): the #ClutterChildMeta for the @actor child | ||||
|  *   of @container or %NULL if the specific actor does not exist or the | ||||
|  *   container is not configured to provide `ClutterChildMeta`s | ||||
|  *   of @container or %NULL if the specifiec actor does not exist or the | ||||
|  *   container is not configured to provide #ClutterChildMeta<!-- -->s | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| ClutterChildMeta * | ||||
| clutter_container_get_child_meta (ClutterContainer *container, | ||||
| @@ -550,6 +993,8 @@ clutter_container_get_child_meta (ClutterContainer *container, | ||||
|  * #ClutterContainer::add() virtual function implementation. | ||||
|  * | ||||
|  * Applications should not call this function. | ||||
|  * | ||||
|  * Since: 1.2 | ||||
|  */ | ||||
| void | ||||
| clutter_container_create_child_meta (ClutterContainer *container, | ||||
| @@ -584,6 +1029,8 @@ clutter_container_create_child_meta (ClutterContainer *container, | ||||
|  * #ClutterContainer::add() virtual function implementation. | ||||
|  * | ||||
|  * Applications should not call this function. | ||||
|  * | ||||
|  * Since: 1.2 | ||||
|  */ | ||||
| void | ||||
| clutter_container_destroy_child_meta (ClutterContainer *container, | ||||
| @@ -612,6 +1059,8 @@ clutter_container_destroy_child_meta (ClutterContainer *container, | ||||
|  * | ||||
|  * Return value: (transfer none): The #GParamSpec for the property or %NULL | ||||
|  *   if no such property exist. | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| GParamSpec * | ||||
| clutter_container_class_find_child_property (GObjectClass *klass, | ||||
| @@ -648,7 +1097,9 @@ clutter_container_class_find_child_property (GObjectClass *klass, | ||||
|  * Returns an array of #GParamSpec for all child properties. | ||||
|  * | ||||
|  * Return value: (array length=n_properties) (transfer full): an array | ||||
|  *   of `GParamSpec`s which should be freed after use. | ||||
|  *   of #GParamSpec<!-- -->s which should be freed after use. | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| GParamSpec ** | ||||
| clutter_container_class_list_child_properties (GObjectClass *klass, | ||||
| @@ -709,6 +1160,8 @@ container_set_child_property (ClutterContainer *container, | ||||
|  * @value: the value. | ||||
|  * | ||||
|  * Sets a container-specific property on a child of @container. | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| void | ||||
| clutter_container_child_set_property (ClutterContainer *container, | ||||
| @@ -755,6 +1208,8 @@ clutter_container_child_set_property (ClutterContainer *container, | ||||
|  * pairs terminated with NULL. | ||||
|  * | ||||
|  * Sets container specific properties on the child of a container. | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| void | ||||
| clutter_container_child_set (ClutterContainer *container, | ||||
| @@ -848,6 +1303,8 @@ container_get_child_property (ClutterContainer *container, | ||||
|  * Note that clutter_container_child_set_property() is really intended for | ||||
|  * language bindings, clutter_container_child_set() is much more convenient | ||||
|  * for C programming. | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| void | ||||
| clutter_container_child_get_property (ClutterContainer *container, | ||||
| @@ -899,6 +1356,8 @@ clutter_container_child_get_property (ClutterContainer *container, | ||||
|  * In general, a copy is made of the property contents and the caller is | ||||
|  * responsible for freeing the memory in the appropriate manner for the type, for | ||||
|  * instance by calling g_free() or g_object_unref().  | ||||
|  * | ||||
|  * Since: 0.8 | ||||
|  */ | ||||
| void | ||||
| clutter_container_child_get (ClutterContainer *container, | ||||
| @@ -969,6 +1428,8 @@ clutter_container_child_get (ClutterContainer *container, | ||||
|  * Calls the #ClutterContainerIface.child_notify() virtual function | ||||
|  * of #ClutterContainer. The default implementation will emit the | ||||
|  * #ClutterContainer::child-notify signal. | ||||
|  * | ||||
|  * Since: 1.6 | ||||
|  */ | ||||
| void | ||||
| clutter_container_child_notify (ClutterContainer *container, | ||||
| @@ -985,23 +1446,3 @@ clutter_container_child_notify (ClutterContainer *container, | ||||
|                                                          child, | ||||
|                                                          pspec); | ||||
| } | ||||
|  | ||||
| void | ||||
| _clutter_container_emit_actor_added (ClutterContainer *container, | ||||
|                                      ClutterActor     *actor) | ||||
| { | ||||
|   g_return_if_fail (CLUTTER_IS_CONTAINER (container)); | ||||
|   g_return_if_fail (CLUTTER_IS_ACTOR (actor)); | ||||
|  | ||||
|   g_signal_emit (container, container_signals[ACTOR_ADDED], 0, actor); | ||||
| } | ||||
|  | ||||
| void | ||||
| _clutter_container_emit_actor_removed (ClutterContainer *container, | ||||
|                                        ClutterActor     *actor) | ||||
| { | ||||
|   g_return_if_fail (CLUTTER_IS_CONTAINER (container)); | ||||
|   g_return_if_fail (CLUTTER_IS_ACTOR (actor)); | ||||
|  | ||||
|   g_signal_emit (container, container_signals[ACTOR_REMOVED], 0, actor); | ||||
| } | ||||
|   | ||||
| @@ -24,15 +24,16 @@ | ||||
|  * Author: Emmanuele Bassi <ebassi@openedhand.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_CONTAINER_H__ | ||||
| #define __CLUTTER_CONTAINER_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-actor.h" | ||||
| #include "clutter/clutter-child-meta.h" | ||||
| #include "clutter/clutter-types.h" | ||||
| #include <clutter/clutter-actor.h> | ||||
| #include <clutter/clutter-child-meta.h> | ||||
| #include <clutter/clutter-types.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -43,12 +44,36 @@ G_BEGIN_DECLS | ||||
|  | ||||
| typedef struct _ClutterContainerIface   ClutterContainerIface; | ||||
|  | ||||
| /** | ||||
|  * ClutterContainer: | ||||
|  * | ||||
|  * #ClutterContainer is an opaque structure whose members cannot be directly | ||||
|  * accessed | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterContainerIface: | ||||
|  * @add: virtual function for adding an actor to the container. This virtual | ||||
|  *   function is deprecated, and it should not be overridden. | ||||
|  * @remove: virtual function for removing an actor from the container. This | ||||
|  *   virtual function is deprecated, and it should not be overridden. | ||||
|  * @foreach: virtual function for iterating over the container's children. | ||||
|  *   This virtual function is deprecated, and it should not be overridden. | ||||
|  * @foreach_with_internals: virtual functions for iterating over the | ||||
|  *   container's children, both added using the #ClutterContainer API | ||||
|  *   and internal children. The implementation of this virtual function | ||||
|  *   is required only if the #ClutterContainer implementation has | ||||
|  *   internal children. This virtual function is deprecated, and it should | ||||
|  *   not be overridden. | ||||
|  * @raise: virtual function for raising a child. This virtual function is | ||||
|  *   deprecated and it should not be overridden. | ||||
|  * @lower: virtual function for lowering a child. This virtual function is | ||||
|  *   deprecated and it should not be overridden. | ||||
|  * @sort_depth_order: virtual function for sorting the children of a | ||||
|  *   container depending on their depth. This virtual function is deprecated | ||||
|  *   and it should not be overridden. | ||||
|  * @child_meta_type: The GType used for storing auxiliary information about | ||||
|  *   each of the containers children. | ||||
|  * @create_child_meta: virtual function that gets called for each added | ||||
| @@ -57,15 +82,17 @@ typedef struct _ClutterContainerIface   ClutterContainerIface; | ||||
|  *   fields in the instance and add the record to a data structure for | ||||
|  *   subsequent access for #ClutterContainerIface::get_child_meta | ||||
|  * @destroy_child_meta: virtual function that gets called when a child is | ||||
|  *   removed; it should release all resources held by the record | ||||
|  *   removed; it shuld release all resources held by the record | ||||
|  * @get_child_meta: return the record for a container child | ||||
|  * @actor_added: class handler for #ClutterContainer::actor-added | ||||
|  * @actor_removed: class handler for #ClutterContainer::actor-removed | ||||
|  * @child_notify: class handler for #ClutterContainer::child-notify | ||||
|  * | ||||
|  * Base interface for container actors. The @add and @remove | ||||
|  * Base interface for container actors. The @add, @remove and @foreach | ||||
|  * virtual functions must be provided by any implementation; the other | ||||
|  * virtual functions are optional. | ||||
|  * | ||||
|  * Since: 0.4 | ||||
|  */ | ||||
| struct _ClutterContainerIface | ||||
| { | ||||
| @@ -77,6 +104,22 @@ struct _ClutterContainerIface | ||||
|                              ClutterActor     *actor); | ||||
|   void (* remove)           (ClutterContainer *container, | ||||
|                              ClutterActor     *actor); | ||||
|   void (* foreach)          (ClutterContainer *container, | ||||
|                              ClutterCallback   callback, | ||||
|                              gpointer          user_data); | ||||
|  | ||||
|   void (* foreach_with_internals) (ClutterContainer *container, | ||||
|                                    ClutterCallback   callback, | ||||
|                                    gpointer          user_data); | ||||
|  | ||||
|   /* child stacking */ | ||||
|   void (* raise)            (ClutterContainer *container, | ||||
|                              ClutterActor     *actor, | ||||
|                              ClutterActor     *sibling); | ||||
|   void (* lower)            (ClutterContainer *container, | ||||
|                              ClutterActor     *actor, | ||||
|                              ClutterActor     *sibling); | ||||
|   void (* sort_depth_order) (ClutterContainer *container); | ||||
|  | ||||
|   /* ClutterChildMeta management */ | ||||
|   GType                child_meta_type; | ||||
| @@ -149,3 +192,5 @@ void                    clutter_container_child_notify                  (Clutter | ||||
|                                                                          GParamSpec       *pspec); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_CONTAINER_H__ */ | ||||
|   | ||||
| @@ -22,9 +22,10 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_CONTENT_PRIVATE_H__ | ||||
| #define __CLUTTER_CONTENT_PRIVATE_H__ | ||||
|  | ||||
| #include "clutter/clutter-content.h" | ||||
| #include <clutter/clutter-content.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -33,9 +34,10 @@ void            _clutter_content_attached               (ClutterContent   *conte | ||||
| void            _clutter_content_detached               (ClutterContent   *content, | ||||
|                                                          ClutterActor     *actor); | ||||
|  | ||||
| void            _clutter_content_paint_content          (ClutterContent      *content, | ||||
|                                                          ClutterActor        *actor, | ||||
|                                                          ClutterPaintNode    *node, | ||||
|                                                          ClutterPaintContext *paint_context); | ||||
| void            _clutter_content_paint_content          (ClutterContent   *content, | ||||
|                                                          ClutterActor     *actor, | ||||
|                                                          ClutterPaintNode *node); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_CONTENT_PRIVATE_H__ */ | ||||
|   | ||||
| @@ -23,25 +23,27 @@ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * ClutterContent: | ||||
|  *  | ||||
|  * Delegate for painting the content of an actor | ||||
|  * SECTION:clutter-content | ||||
|  * @Title: ClutterContent | ||||
|  * @Short_Description: Delegate for painting the content of an actor | ||||
|  * | ||||
|  * #ClutterContent is an interface to implement types responsible for | ||||
|  * painting the content of a [class@Actor]. | ||||
|  * painting the content of a #ClutterActor. | ||||
|  * | ||||
|  * Multiple actors can use the same #ClutterContent instance, in order | ||||
|  * to share the resources associated with painting the same content.. | ||||
|  * to share the resources associated with painting the same content. | ||||
|  * | ||||
|  * #ClutterContent is available since Clutter 1.10. | ||||
|  */ | ||||
|  | ||||
| #include "clutter/clutter-build-config.h" | ||||
| #include "clutter-build-config.h" | ||||
|  | ||||
| #include "clutter/clutter-actor-private.h" | ||||
| #include "clutter/clutter-content-private.h" | ||||
| #include "clutter-actor-private.h" | ||||
| #include "clutter-content-private.h" | ||||
|  | ||||
| #include "clutter/clutter-debug.h" | ||||
| #include "clutter/clutter-marshal.h" | ||||
| #include "clutter/clutter-private.h" | ||||
| #include "clutter-debug.h" | ||||
| #include "clutter-marshal.h" | ||||
| #include "clutter-private.h" | ||||
|  | ||||
| enum | ||||
| { | ||||
| @@ -94,10 +96,9 @@ clutter_content_real_invalidate_size (ClutterContent *content) | ||||
| } | ||||
|  | ||||
| static void | ||||
| clutter_content_real_paint_content (ClutterContent      *content, | ||||
|                                     ClutterActor        *actor, | ||||
|                                     ClutterPaintNode    *context, | ||||
|                                     ClutterPaintContext *paint_context) | ||||
| clutter_content_real_paint_content (ClutterContent   *content, | ||||
|                                     ClutterActor     *actor, | ||||
|                                     ClutterPaintNode *context) | ||||
| { | ||||
| } | ||||
|  | ||||
| @@ -120,13 +121,16 @@ clutter_content_default_init (ClutterContentInterface *iface) | ||||
|    * | ||||
|    * This signal is emitted each time a #ClutterContent implementation is | ||||
|    * assigned to a #ClutterActor. | ||||
|    * | ||||
|    * Since: 1.10 | ||||
|    */ | ||||
|   content_signals[ATTACHED] = | ||||
|     g_signal_new (I_("attached"), | ||||
|                   G_TYPE_FROM_INTERFACE (iface), | ||||
|                   G_SIGNAL_RUN_FIRST, | ||||
|                   G_STRUCT_OFFSET (ClutterContentInterface, attached), | ||||
|                   NULL, NULL, NULL, | ||||
|                   NULL, NULL, | ||||
|                   _clutter_marshal_VOID__OBJECT, | ||||
|                   G_TYPE_NONE, 1, | ||||
|                   CLUTTER_TYPE_ACTOR); | ||||
|  | ||||
| @@ -137,13 +141,16 @@ clutter_content_default_init (ClutterContentInterface *iface) | ||||
|    * | ||||
|    * This signal is emitted each time a #ClutterContent implementation is | ||||
|    * removed from a #ClutterActor. | ||||
|    * | ||||
|    * Since: 1.10 | ||||
|    */ | ||||
|   content_signals[DETACHED] = | ||||
|     g_signal_new (I_("detached"), | ||||
|                   G_TYPE_FROM_INTERFACE (iface), | ||||
|                   G_SIGNAL_RUN_FIRST, | ||||
|                   G_STRUCT_OFFSET (ClutterContentInterface, detached), | ||||
|                   NULL, NULL, NULL, | ||||
|                   NULL, NULL, | ||||
|                   _clutter_marshal_VOID__OBJECT, | ||||
|                   G_TYPE_NONE, 1, | ||||
|                   CLUTTER_TYPE_ACTOR); | ||||
| } | ||||
| @@ -157,6 +164,8 @@ clutter_content_default_init (ClutterContentInterface *iface) | ||||
|  * This function should be called by #ClutterContent implementations when | ||||
|  * they change the way a the content should be painted regardless of the | ||||
|  * actor state. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| void | ||||
| clutter_content_invalidate (ClutterContent *content) | ||||
| @@ -293,8 +302,7 @@ _clutter_content_detached (ClutterContent *content, | ||||
|  * _clutter_content_paint_content: | ||||
|  * @content: a #ClutterContent | ||||
|  * @actor: a #ClutterActor | ||||
|  * @node: a #ClutterPaintNode | ||||
|  * @paint_context: a #ClutterPaintContext | ||||
|  * @context: a #ClutterPaintNode | ||||
|  * | ||||
|  * Creates the render tree for the @content and @actor. | ||||
|  * | ||||
| @@ -302,20 +310,18 @@ _clutter_content_detached (ClutterContent *content, | ||||
|  * virtual function. | ||||
|  */ | ||||
| void | ||||
| _clutter_content_paint_content (ClutterContent      *content, | ||||
|                                 ClutterActor        *actor, | ||||
|                                 ClutterPaintNode    *node, | ||||
|                                 ClutterPaintContext *paint_context) | ||||
| _clutter_content_paint_content (ClutterContent   *content, | ||||
|                                 ClutterActor     *actor, | ||||
|                                 ClutterPaintNode *node) | ||||
| { | ||||
|   CLUTTER_CONTENT_GET_IFACE (content)->paint_content (content, actor, node, | ||||
|                                                       paint_context); | ||||
|   CLUTTER_CONTENT_GET_IFACE (content)->paint_content (content, actor, node); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * clutter_content_get_preferred_size: | ||||
|  * @content: a #ClutterContent | ||||
|  * @width: (out) (optional): return location for the natural width of the content | ||||
|  * @height: (out) (optional): return location for the natural height of the content | ||||
|  * @width: (out): return location for the natural width of the content | ||||
|  * @height: (out): return location for the natural height of the content | ||||
|  * | ||||
|  * Retrieves the natural size of the @content, if any. | ||||
|  * | ||||
| @@ -325,6 +331,8 @@ _clutter_content_paint_content (ClutterContent      *content, | ||||
|  * | ||||
|  * Return value: %TRUE if the content has a preferred size, and %FALSE | ||||
|  *   otherwise | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| gboolean | ||||
| clutter_content_get_preferred_size (ClutterContent *content, | ||||
|   | ||||
| @@ -22,13 +22,14 @@ | ||||
|  *   Emmanuele Bassi <ebassi@linux.intel.com> | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
| #ifndef __CLUTTER_CONTENT_H__ | ||||
| #define __CLUTTER_CONTENT_H__ | ||||
|  | ||||
| #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) | ||||
| #error "Only <clutter/clutter.h> can be included directly." | ||||
| #endif | ||||
|  | ||||
| #include "clutter/clutter-types.h" | ||||
| #include <clutter/clutter-types.h> | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| @@ -52,6 +53,8 @@ G_DECLARE_INTERFACE (ClutterContent, clutter_content, CLUTTER, CONTENT, GObject) | ||||
|  * | ||||
|  * The #ClutterContentInterface structure contains only | ||||
|  * private data. | ||||
|  * | ||||
|  * Since: 1.10 | ||||
|  */ | ||||
| struct _ClutterContentInterface | ||||
| { | ||||
| @@ -62,10 +65,9 @@ struct _ClutterContentInterface | ||||
|   gboolean      (* get_preferred_size)  (ClutterContent   *content, | ||||
|                                          gfloat           *width, | ||||
|                                          gfloat           *height); | ||||
|   void          (* paint_content)       (ClutterContent      *content, | ||||
|                                          ClutterActor        *actor, | ||||
|                                          ClutterPaintNode    *node, | ||||
|                                          ClutterPaintContext *paint_context); | ||||
|   void          (* paint_content)       (ClutterContent   *content, | ||||
|                                          ClutterActor     *actor, | ||||
|                                          ClutterPaintNode *node); | ||||
|  | ||||
|   void          (* attached)            (ClutterContent   *content, | ||||
|                                          ClutterActor     *actor); | ||||
| @@ -88,3 +90,5 @@ CLUTTER_EXPORT | ||||
| void            clutter_content_invalidate_size         (ClutterContent *content); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __CLUTTER_CONTENT_H__ */ | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user