Repository: tauri-apps/window-shadows Branch: dev Commit: 48fa81bbd955 Files: 27 Total size: 31.4 KB Directory structure: gitextract_1gvi5f2t/ ├── .changes/ │ ├── config.json │ └── readme.md ├── .github/ │ └── workflows/ │ ├── audit.yml │ ├── clippy-fmt.yml │ ├── covector-status.yml │ ├── covector-version-or-publish.yml │ └── test.yml ├── .gitignore ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── LICENSE.spdx ├── README.md ├── examples/ │ ├── tao.rs │ ├── tauri/ │ │ ├── .gitignore │ │ ├── package.json │ │ ├── public/ │ │ │ └── index.html │ │ └── src-tauri/ │ │ ├── .gitignore │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── icons/ │ │ │ └── icon.icns │ │ ├── src/ │ │ │ └── main.rs │ │ └── tauri.conf.json │ └── winit.rs ├── renovate.json └── src/ └── lib.rs ================================================ FILE CONTENTS ================================================ ================================================ FILE: .changes/config.json ================================================ { "gitSiteUrl": "https://github.com/tauri-apps/window-shadows/", "pkgManagers": { "rust": { "version": true, "getPublishedVersion": "cargo search ${ pkg.pkg } --limit 1 | sed -nE 's/^[^\"]*\"//; s/\".*//1p' -", "publish": [ { "command": "cargo package --allow-dirty", "dryRunCommand": true }, { "command": "echo \"# Cargo Publish\"", "dryRunCommand": true, "pipe": true }, { "command": "echo \"\\`\\`\\`\"", "dryRunCommand": true, "pipe": true }, { "command": "cargo publish --no-verify", "dryRunCommand": "cargo publish --no-verify --dry-run --allow-dirty", "pipe": true }, { "command": "echo \"\\`\\`\\`\"", "dryRunCommand": true, "pipe": true } ] } }, "packages": { "window-shadows": { "path": ".", "manager": "rust" } } } ================================================ FILE: .changes/readme.md ================================================ # Changes ##### via https://github.com/jbolda/covector As you create PRs and make changes that require a version bump, please add a new markdown file in this folder. You do not note the version _number_, but rather the type of bump that you expect: major, minor, or patch. The filename is not important, as long as it is a `.md`, but we recommend that it represents the overall change for organizational purposes. When you select the version bump required, you do _not_ need to consider dependencies. Only note the package with the actual change, and any packages that depend on that package will be bumped automatically in the process. Use the following format: ```md --- "package-a": patch "package-b": minor --- Change summary goes here ``` Summaries do not have a specific character limit, but are text only. These summaries are used within the (future implementation of) changelogs. They will give context to the change and also point back to the original PR if more details and context are needed. Changes will be designated as a `major`, `minor` or `patch` as further described in [semver](https://semver.org/). Given a version number MAJOR.MINOR.PATCH, increment the: - MAJOR version when you make incompatible API changes, - MINOR version when you add functionality in a backwards compatible manner, and - PATCH version when you make backwards compatible bug fixes. Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format, but will be discussed prior to usage (as extra steps will be necessary in consideration of merging and publishing). ================================================ FILE: .github/workflows/audit.yml ================================================ # Copyright 2022-2022 Tauri Programme within The Commons Conservancy # SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: MIT name: audit on: workflow_dispatch: schedule: - cron: '0 0 * * *' push: branches: - dev paths: - 'Cargo.lock' - 'Cargo.toml' pull_request: paths: - 'Cargo.lock' - 'Cargo.toml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: audit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: rustsec/audit-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} ================================================ FILE: .github/workflows/clippy-fmt.yml ================================================ # Copyright 2022-2022 Tauri Programme within The Commons Conservancy # SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: MIT name: clippy & fmt on: push: branches: - dev pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: clippy: strategy: fail-fast: false matrix: platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v4 - name: install system deps if: matrix.platform == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install -y libgtk-3-dev - uses: dtolnay/rust-toolchain@stable with: components: clippy - run: cargo clippy --all-targets --all-features -- -D warnings fmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: components: rustfmt - run: cargo fmt --all -- --check ================================================ FILE: .github/workflows/covector-status.yml ================================================ name: covector status on: [pull_request] jobs: covector: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: covector status uses: jbolda/covector/packages/action@covector-v0 id: covector with: command: 'status' ================================================ FILE: .github/workflows/covector-version-or-publish.yml ================================================ name: covector version or publish on: push: branches: - dev jobs: version-or-publish: runs-on: ubuntu-latest timeout-minutes: 65 outputs: change: ${{ steps.covector.outputs.change }} commandRan: ${{ steps.covector.outputs.commandRan }} successfulPublish: ${{ steps.covector.outputs.successfulPublish }} steps: - uses: actions/checkout@v4 - name: cargo login run: cargo login ${{ secrets.ORG_CRATES_IO_TOKEN }} - name: git config run: | git config --global user.name "${{ github.event.pusher.name }}" git config --global user.email "${{ github.event.pusher.email }}" - name: covector version or publish (publish when no change files present) uses: jbolda/covector/packages/action@covector-v0 id: covector env: CARGO_AUDIT_OPTIONS: ${{ secrets.CARGO_AUDIT_OPTIONS }} with: token: ${{ secrets.GITHUB_TOKEN }} command: "version-or-publish" createRelease: true - name: Create Pull Request With Versions Bumped id: cpr uses: tauri-apps/create-pull-request@v3 if: steps.covector.outputs.commandRan == 'version' with: token: ${{ secrets.GITHUB_TOKEN }} title: Apply Version Updates From Current Changes commit-message: 'apply version updates' labels: 'version updates' branch: 'release' body: ${{ steps.covector.outputs.change }} ================================================ FILE: .github/workflows/test.yml ================================================ name: test on: push: branches: - dev pull_request: jobs: test: strategy: fail-fast: false matrix: platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v4 - name: install system deps if: matrix.platform == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install -y libgtk-3-dev - uses: dtolnay/rust-toolchain@stable - run: cargo test ================================================ FILE: .gitignore ================================================ # Copyright 2020-2022 Tauri Programme within The Commons Conservancy # SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: MIT /target Cargo.lock ================================================ FILE: CHANGELOG.md ================================================ # Changelog ## \[0.2.2] - [`791c43d`](https://github.com/tauri-apps/window-shadows/commit/791c43def0e802a47a7b163e7bc612b3a0faf794) Update `windows-sys` version to `0.48` ## \[0.2.1] - Update docs to include conditional compliation flags. - [a9db8cf](https://github.com/tauri-apps/window-shadows/commit/a9db8cf57317ed4383a094daef33e0cc9875b702) chore: update docs on 2022-12-29 ## \[0.2.0] - Update `raw-window-handle` dependency to 0.5 - [26f0c3c](https://github.com/tauri-apps/window-shadows/commit/26f0c3c3c7e8d2ab47009987ae4027b67b891f40) chore(deps): update raw-window-handle to 0.5 on 2022-07-25 ## \[0.1.3] - Update documentation about macOS transparent windows. - [196fea6](https://github.com/tauri-apps/window-shadows/commit/196fea6d8059c1d3d73837c842bb89f6138dbad7) chore: update crate cos on 2022-03-29 - [5ec769e](https://github.com/tauri-apps/window-shadows/commit/5ec769e6a14c25ed824604020ab3d2d1bf21e413) publish new versions ([#17](https://github.com/tauri-apps/window-shadows/pull/17)) on 2022-03-29 - [918b3dd](https://github.com/tauri-apps/window-shadows/commit/918b3ddc0a7359ad540067ef1ec6f6cbe7052c55) docs: update docs for macOS transparent windows on 2022-05-06 - Add screenshots - [c908533](https://github.com/tauri-apps/window-shadows/commit/c9085333e1867f840509ffdc1cab869dd06b768c) chore: add screenshots ([#24](https://github.com/tauri-apps/window-shadows/pull/24)) on 2022-05-23 ## \[0.1.2] - Fix docs failing because of a wrong example. - [ca3b8a1](https://github.com/tauri-apps/window-shadows/commit/ca3b8a11f6b9bf456f2372684bd4fabef74504a0) fix: fix docs on 2022-03-29 ## \[0.1.1] - Update crate docs. - [196fea6](https://github.com/tauri-apps/window-shadows/commit/196fea6d8059c1d3d73837c842bb89f6138dbad7) chore: update crate cos on 2022-03-29 ## \[0.1.0] - Initial Release. - [4489c8f](https://github.com/tauri-apps/window-shadows/commit/4489c8fadc6a04c0b83d5e9dbf45cf006c4266af) chroe: update `README.md` on 2022-03-05 - [bd80ba3](https://github.com/tauri-apps/window-shadows/commit/bd80ba3849d3f27eb8e3e445f54931b5b522d9d3) chore: bump changefile to minor on 2022-03-05 ================================================ FILE: Cargo.toml ================================================ [package] name = "window-shadows" description = "Add native shadows to your windows." authors = [ "Tauri Programme within The Commons Conservancy" ] version = "0.2.2" edition = "2021" license = "Apache-2.0 OR MIT" readme = "README.md" repository = "https://github.com/tauri-apps/tauri-plugin-shadows" documentation = "https://docs.rs/tauri-plugin-shadows" keywords = [ "shadows", "windowing", "gui" ] categories = [ "gui" ] [package.metadata.docs.rs] default-target = "x86_64-pc-windows-msvc" targets = [ "x86_64-apple-darwin", "x86_64-pc-windows-msvc" ] [dependencies] raw-window-handle = "0.5" [dev-dependencies] tao = { version = "0.25", features = ["rwh_05"] } winit = {version = "0.29", default-features = false, features = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita", "rwh_05"] } [target."cfg(target_os = \"windows\")".dependencies] windows-sys = { version = "0.52.0", features = [ "Win32_Foundation", "Win32_Graphics_Dwm", "Win32_UI_Controls" ] } [target."cfg(target_os = \"macos\")".dependencies] cocoa = "0.25" objc = "0.2" ================================================ FILE: LICENSE-APACHE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: LICENSE-MIT ================================================ MIT License Copyright (c) 2020-2022 Tauri Programme within The Commons Conservancy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: LICENSE.spdx ================================================ SPDXVersion: SPDX-2.1 DataLicense: CC0-1.0 PackageName: window-shadows DataFormat: SPDXRef-1 PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy PackageHomePage: https://tauri.app PackageLicenseDeclared: Apache-2.0 PackageLicenseDeclared: MIT PackageCopyrightText: 2020-2022, The Tauri Programme in the Commons Conservancy PackageSummary: Add native shadows to your windows. PackageComment: The package includes the following libraries; see Relationship information. Created: 2020-05-20T09:00:00Z PackageDownloadLocation: git://github.com/tauri-apps/window-shadows PackageDownloadLocation: git+https://github.com/tauri-apps/window-shadows.git PackageDownloadLocation: git+ssh://github.com/tauri-apps/window-shadows.git Creator: Person: Daniel Thompson-Yvetot ================================================ FILE: README.md ================================================ > [!warning] > # ARCHIVE NOTICE > > This crate is **Unmaintained**! it served its purpose which was an interim solution to enable shadows on undecorated windows for `tao` and `tauri`. > > As of `tauri@v2` and recent versions of `tao` and `winit`, they all support enablind/disabling shadows so this crate is not needed. > > If you're using `tauri@v1` and need this crate, don't worry, this crate will still function with `tauri@v1` without any problems. # window-shadows [![](https://img.shields.io/crates/v/window-shadows)](https://crates.io/crates/window-shadows) [![](https://img.shields.io/docsrs/window-shadows)](https://docs.rs/window-shadows/) ![](https://img.shields.io/crates/l/window-shadows) [![Chat Server](https://img.shields.io/badge/chat-on%20discord-7289da.svg)](https://discord.gg/SpmNs4S) Add native shadows to your windows. ## Platform-specific - **Windows**: On Windows 11, the window will also have rounded corners. - **macOS**: Shadows are always disabled for transparent windows. - **Linux**: Unsupported, Shadows are controlled by the compositor installed on the end-user system. ## Example ```rs use window_shadows::set_shadow; #[cfg(any(windows, target_os = "macos"))] set_shadow(&window, true).unwrap(); ``` ## Screenshots

| Windows | macOS | | :---: | :---: | | ![Windows screenshot](./screenshots/windows.png) | ![macOS screenshot](./screenshots/macOS.png) |

================================================ FILE: examples/tao.rs ================================================ // Copyright 2020-2022 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT fn main() { use tao::{ event::{Event, WindowEvent}, event_loop::{ControlFlow, EventLoop}, window::WindowBuilder, }; use window_shadows::set_shadow; let event_loop = EventLoop::new(); let window = WindowBuilder::new() .with_decorations(false) .build(&event_loop) .unwrap(); set_shadow(&window, true).expect("Unsupported platform!"); window.set_title("A fantastic window!"); event_loop.run(move |event, _, control_flow| { *control_flow = ControlFlow::Wait; if let Event::WindowEvent { event: WindowEvent::CloseRequested, .. } = event { *control_flow = ControlFlow::Exit } }); } ================================================ FILE: examples/tauri/.gitignore ================================================ # Copyright 2020-2022 Tauri Programme within The Commons Conservancy # SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: MIT node_modules/ ================================================ FILE: examples/tauri/package.json ================================================ { "name": "app", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "MIT OR Apache-2.0", "dependencies": { "@tauri-apps/cli": "^1.0.0" } } ================================================ FILE: examples/tauri/public/index.html ================================================
window shadows example
================================================ FILE: examples/tauri/src-tauri/.gitignore ================================================ # Copyright 2020-2022 Tauri Programme within The Commons Conservancy # SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: MIT # Generated by Cargo # will have compiled files and executables /target/ ================================================ FILE: examples/tauri/src-tauri/Cargo.toml ================================================ [package] name = "app" version = "0.1.0" description = "A Tauri App" authors = ["Tauri Programme within The Commons Conservancy"] edition = "2021" license = "MIT OR Apache-2.0" [dependencies] serde_json = "1" serde = { version = "1.0", features = ["derive"] } tauri = { version = "1", features = ["api-all"] } window-shadows = { path = "../../../" } [build-dependencies] tauri-build = { version = "1" } [features] default = ["custom-protocol"] custom-protocol = ["tauri/custom-protocol"] ================================================ FILE: examples/tauri/src-tauri/build.rs ================================================ // Copyright 2020-2022 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT fn main() { tauri_build::build() } ================================================ FILE: examples/tauri/src-tauri/src/main.rs ================================================ // Copyright 2020-2022 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT #![cfg_attr( all(not(debug_assertions), target_os = "windows"), windows_subsystem = "windows" )] use tauri::Manager; use window_shadows::set_shadow; fn main() { tauri::Builder::default() .setup(|app| { let window = app.get_window("main").unwrap(); set_shadow(&window, true).expect("Unsupported platform!"); Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application"); } ================================================ FILE: examples/tauri/src-tauri/tauri.conf.json ================================================ { "package": { "productName": "app", "version": "0.1.0" }, "build": { "distDir": "../public", "devPath": "../public" }, "tauri": { "bundle": { "active": true, "targets": "all", "identifier": "com.tauri.window-shadows", "icon": [ "icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico" ], "resources": [], "externalBin": [], "copyright": "", "category": "DeveloperTool", "shortDescription": "", "longDescription": "", "deb": { "depends": [] }, "macOS": { "frameworks": [], "exceptionDomain": "", "signingIdentity": null, "entitlements": null }, "windows": { "certificateThumbprint": null, "digestAlgorithm": "sha256", "timestampUrl": "" } }, "updater": { "active": false }, "allowlist": { "all": true }, "windows": [ { "title": "app", "width": 800, "height": 600, "resizable": true, "fullscreen": false, "decorations": false } ], "security": { "csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'" } } } ================================================ FILE: examples/winit.rs ================================================ // Copyright 2020-2022 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT fn main() { use window_shadows::set_shadow; use winit::{ event::{Event, WindowEvent}, event_loop::{ControlFlow, EventLoop}, window::WindowBuilder, }; let event_loop = EventLoop::new().unwrap(); let window = WindowBuilder::new() .with_decorations(false) .build(&event_loop) .unwrap(); set_shadow(&window, true).expect("Unsupported platform!"); window.set_title("A fantastic window!"); event_loop .run(move |event, event_loop| { event_loop.set_control_flow(ControlFlow::Wait); if let Event::WindowEvent { event: WindowEvent::CloseRequested, .. } = event { event_loop.exit() } }) .unwrap(); } ================================================ FILE: renovate.json ================================================ { "extends": ["config:base", ":disableDependencyDashboard"] } ================================================ FILE: src/lib.rs ================================================ // Copyright 2020-2022 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT //! Add native shadows to your windows. //! //! ## Platform-specific //! //! - **Windows**: On Windows 11, the window will also have rounded corners. //! - **macOS**: Shadows are always disabled for transparent windows. //! - **Linux**: Unsupported, Shadows are controlled by the compositor installed on the end-user system. //! //! # Example //! //! ```no_run //! use window_shadows::set_shadow; //! //! # let window: &dyn raw_window_handle::HasRawWindowHandle = unsafe { std::mem::zeroed() }; //! #[cfg(any(windows, target_os = "macos"))] //! set_shadow(&window, true).unwrap(); //! ``` /// Enables or disables the shadows for a window. /// /// ## Platform-specific /// /// - **Windows**: On Windows 11, the window will also have rounded corners. /// - **macOS**: Shadows are always disabled for transparent windows. /// - **Linux**: Unsupported, Shadows are controlled by the compositor installed on the end-user system. pub fn set_shadow( window: impl raw_window_handle::HasRawWindowHandle, #[allow(unused)] enable: bool, ) -> Result<(), Error> { match window.raw_window_handle() { #[cfg(target_os = "macos")] raw_window_handle::RawWindowHandle::AppKit(handle) => { use cocoa::{appkit::NSWindow, base::id}; use objc::runtime::{NO, YES}; unsafe { (handle.ns_window as id).setHasShadow_(if enable { YES } else { NO }); } Ok(()) } #[cfg(target_os = "windows")] raw_window_handle::RawWindowHandle::Win32(handle) => { use windows_sys::Win32::{ Graphics::Dwm::DwmExtendFrameIntoClientArea, UI::Controls::MARGINS, }; let m = if enable { 1 } else { 0 }; let margins = MARGINS { cxLeftWidth: m, cxRightWidth: m, cyTopHeight: m, cyBottomHeight: m, }; unsafe { DwmExtendFrameIntoClientArea(handle.hwnd as _, &margins); }; Ok(()) } _ => Err(Error::UnsupportedPlatform), } } #[derive(Debug)] pub enum Error { UnsupportedPlatform, } impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "\"set_shadow()\" is only supported on Windows and macOS") } }