├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ └── bug_report.md
└── workflows
│ ├── extract-version.yml
│ ├── publish-docs-requirements.txt
│ ├── publish-docs.yml
│ ├── publish-release.yml
│ └── publish-snapshot.yml
├── .gitignore
├── .idea
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── copyright
│ ├── copyright.xml
│ └── profiles_settings.xml
└── dictionaries
│ └── default_user.xml
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── build.gradle.kts
├── docs
├── images
│ ├── demo_preview.webp
│ └── logo.png
├── index.md
└── styles
│ └── dokka.css
├── gradle.properties
├── gradle
├── libs.versions.toml
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── mkdocs.yml
├── settings.gradle.kts
├── window-styler-demo
├── build.gradle.kts
└── src
│ └── jvmMain
│ └── kotlin
│ ├── Main.kt
│ └── RadioGroup.kt
└── window-styler
├── build.gradle.kts
├── gradle.properties
└── src
└── jvmMain
└── kotlin
└── com
└── mayakapps
└── compose
└── windowstyler
├── HackedContentPane.kt
├── TransparencyUtils.kt
├── Utils.kt
├── WindowBackdrop.kt
├── WindowFrameStyle.kt
├── WindowStyle.kt
├── WindowStyleManager.kt
└── windows
├── ColorUtils.kt
├── Utils.kt
├── WindowsBackdropApis.kt
├── WindowsWindowStyleManager.kt
└── jna
├── Dwm.kt
├── Nt.kt
├── User32.kt
├── Utils.kt
├── enums
├── AccentFlag.kt
├── AccentState.kt
├── DwmSystemBackdrop.kt
├── DwmWindowAttribute.kt
├── DwmWindowCornerPreference.kt
└── WindowCompositionAttribute.kt
└── structs
├── AccentPolicy.kt
├── BaseStructure.kt
├── Margins.kt
├── OsVersionInfo.kt
└── WindowCompositionAttributeData.kt
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [MayakaApps,MSDarwish2000]
4 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **OS (please complete the following information):**
27 | - OS: [e.g. Windows 11]
28 | - Build: [e.g. 22000]
29 |
30 | **Additional context**
31 | Add any other context about the problem here.
32 |
--------------------------------------------------------------------------------
/.github/workflows/extract-version.yml:
--------------------------------------------------------------------------------
1 | name: Extract Library Version
2 |
3 | on:
4 | workflow_call:
5 | # Map the workflow outputs to job outputs
6 | outputs:
7 | library-version:
8 | description: The extracted library version
9 | value: ${{ jobs.extract-version.outputs.library-version }}
10 |
11 | jobs:
12 | extract-version:
13 | name: Extract Library Version
14 |
15 | runs-on: ubuntu-latest
16 |
17 | permissions:
18 | contents: read
19 |
20 | # Map the job outputs to step outputs
21 | outputs:
22 | library-version: ${{ steps.extract.outputs.library-version }}
23 |
24 | steps:
25 | - name: Checkout
26 | uses: actions/checkout@v4
27 |
28 | - name: Extract Library version
29 | id: extract
30 | run: |
31 | echo "library-version=$(sed -rn 's/^VERSION_NAME=(.*)\r?$/\1/p' 'window-styler/gradle.properties')" >> $GITHUB_OUTPUT
32 |
--------------------------------------------------------------------------------
/.github/workflows/publish-docs-requirements.txt:
--------------------------------------------------------------------------------
1 | mike==2.1.3
2 | mkdocs==1.6.1
3 | mkdocs-macros-plugin==1.3.7
4 | mkdocs-material==9.6.5
5 |
--------------------------------------------------------------------------------
/.github/workflows/publish-docs.yml:
--------------------------------------------------------------------------------
1 | name: Publish Documentation
2 |
3 | on:
4 | workflow_call:
5 | inputs:
6 | library-version:
7 | required: true
8 | type: string
9 |
10 | jobs:
11 | publish-docs:
12 | name: Publish Documentation
13 |
14 | runs-on: ubuntu-latest
15 |
16 | env:
17 | LIBRARY_VERSION: ${{ inputs.library-version }}
18 |
19 | permissions:
20 | contents: write
21 | pages: write
22 | id-token: write
23 |
24 | steps:
25 | - name: Checkout
26 | uses: actions/checkout@v4
27 |
28 | - name: Configure Pages
29 | uses: actions/configure-pages@v5
30 |
31 | - name: Setup JDK
32 | uses: actions/setup-java@v4
33 | with:
34 | distribution: 'temurin'
35 | java-version: 17
36 |
37 | - name: Setup gradle
38 | uses: gradle/actions/setup-gradle@v4
39 |
40 | - name: Setup Python
41 | uses: actions/setup-python@v5
42 | with:
43 | python-version: 3.13.2
44 |
45 | - name: Generate the API documentation
46 | run: ./gradlew :window-styler:dokkaGenerate
47 |
48 | - name: Build mkdocs
49 | run: |
50 | pip3 install -r .github/workflows/publish-docs-requirements.txt
51 | mkdocs build
52 |
53 | - name: Configure git for mike
54 | run: |
55 | git config --local user.email "github-actions[bot]@users.noreply.github.com"
56 | git config --local user.name "github-actions[bot]"
57 | git fetch origin gh-pages --depth=1
58 |
59 | - name: Deploy documentation with mike
60 | if: ${{ success() }}
61 | run: |
62 | mike deploy -u --push ${{ inputs.library-version }} \
63 | ${{ (endsWith(inputs.library-version, '-SNAPSHOT') && 'snapshot') || 'latest' }}
64 |
--------------------------------------------------------------------------------
/.github/workflows/publish-release.yml:
--------------------------------------------------------------------------------
1 | name: Publish Release
2 |
3 | on:
4 | release:
5 | types: [ created ]
6 |
7 | concurrency:
8 | group: "publish-release"
9 | cancel-in-progress: false
10 |
11 | env:
12 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
13 | ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
14 | ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }}
15 | ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }}
16 | ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }}
17 |
18 | jobs:
19 | publish-release:
20 | name: Publish Release
21 |
22 | runs-on: ubuntu-latest
23 | if: github.repository == 'MayakaApps/ComposeWindowStyler'
24 |
25 | permissions:
26 | contents: read
27 |
28 | steps:
29 | - name: Checkout
30 | uses: actions/checkout@v4
31 |
32 | - name: Setup JDK
33 | uses: actions/setup-java@v4
34 | with:
35 | distribution: 'temurin'
36 | java-version: 17
37 |
38 | - name: Setup gradle
39 | uses: gradle/actions/setup-gradle@v4
40 |
41 | - name: Publish
42 | run: ./gradlew publishAllPublicationsToMavenCentralRepository
43 |
44 | extract-version:
45 | name: Extract Library Version
46 | if: github.repository == 'MayakaApps/ComposeWindowStyler'
47 | uses: ./.github/workflows/extract-version.yml
48 |
49 | publish-docs:
50 | name: Publish Documentation
51 |
52 | needs: extract-version
53 | if: github.repository == 'MayakaApps/ComposeWindowStyler'
54 |
55 | uses: ./.github/workflows/publish-docs.yml
56 | with:
57 | library-version: ${{ needs.extract-version.outputs.library-version }}
58 |
--------------------------------------------------------------------------------
/.github/workflows/publish-snapshot.yml:
--------------------------------------------------------------------------------
1 | name: Publish Snapshot
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 |
8 | concurrency:
9 | group: "publish-snapshot"
10 | cancel-in-progress: true
11 |
12 | env:
13 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
14 | ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
15 |
16 | jobs:
17 | extract-version:
18 | name: Extract Library Version
19 | if: github.repository == 'MayakaApps/ComposeWindowStyler'
20 | uses: ./.github/workflows/extract-version.yml
21 |
22 | publish-library:
23 | name: Publish Snapshot
24 |
25 | needs: extract-version
26 |
27 | runs-on: macOS-14
28 | if: github.repository == 'MayakaApps/ComposeWindowStyler' && endsWith(needs.extract-version.outputs.library-version, '-SNAPSHOT')
29 |
30 | permissions:
31 | contents: read
32 |
33 | steps:
34 | - name: Checkout
35 | uses: actions/checkout@v4
36 |
37 | - name: Setup JDK
38 | uses: actions/setup-java@v4
39 | with:
40 | distribution: 'temurin'
41 | java-version: 17
42 |
43 | - name: Setup gradle
44 | uses: gradle/actions/setup-gradle@v4
45 |
46 | - name: Publish
47 | run: ./gradlew publishAllPublicationsToMavenCentralRepository
48 |
49 | publish-docs:
50 | name: Publish Documentation
51 |
52 | needs: extract-version
53 | if: github.repository == 'MayakaApps/ComposeWindowStyler' && endsWith(needs.extract-version.outputs.library-version, '-SNAPSHOT')
54 |
55 | uses: ./.github/workflows/publish-docs.yml
56 | with:
57 | library-version: ${{ needs.extract-version.outputs.library-version }}
58 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #
2 | # Gradle
3 | #
4 |
5 | .gradle/
6 | **/build/
7 | !**/src/**/build/
8 |
9 | # Local configuration file
10 | local.properties
11 |
12 | #
13 | # Kotlin
14 | #
15 |
16 | .kotlin
17 |
18 | #
19 | # IntelliJ
20 | #
21 |
22 | **/.idea/*
23 | !**/.idea/codeStyles
24 | !**/.idea/copyright
25 | !**/.idea/dictionaries
26 | **/.idea/dictionaries/*
27 | !**/.idea/dictionaries/default_user.xml
28 | *.iml
29 |
30 | #
31 | # CI
32 | #
33 |
34 | # Mkdocs
35 | site/
36 | docs/api/
37 |
38 | #
39 | # Common
40 | #
41 |
42 | # Mac files
43 | .DS_Store
44 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/copyright/copyright.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/dictionaries/default_user.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | darwish
5 | mayaka
6 | mayakapps
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | mayaka.apps@outlook.com.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Compose Window Styler
8 |
9 |
10 |
11 | 
12 | [](https://github.com/MayakaApps/ComposeWindowStyler/stargazers)
13 | [](https://github.com/MayakaApps/ComposeWindowStyler/blob/main/LICENSE)
14 | 
15 | 
16 | [](https://twitter.com/intent/tweet?text=Compose%20Window%20Styler%20is%20a%20library%20that%20lets%20you%20style%20your%20Compose%20for%20Desktop%20window%20to%20have%20more%20native%20and%20modern%20UI.:&url=https%3A%2F%2Fgithub.com%2FMayakaApps%2FComposeWindowStyler)
17 |
18 |
19 |
20 | Compose Window Styler is a library that lets you style your Compose for Desktop window to have more
21 | native and modern UI. This includes styling the window to use acrylic, mica, ...etc.
22 |
23 | ---
24 |
25 | 
26 |
27 | ---
28 |
29 | ## Setup (Gradle)
30 |
31 | ```kotlin
32 | repositories {
33 | mavenCentral()
34 |
35 | // Add only if you're using snapshot version
36 | maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
37 | }
38 |
39 | dependencies {
40 | implementation("com.mayakapps.compose:window-styler:")
41 | }
42 | ```
43 |
44 | Don't forget to replace `` with the latest/desired version found on the badges above.
45 |
46 | ## Usage
47 |
48 | You can apply the desired style to your window by using `WindowStyle` inside the `WindowScope` of
49 | `Window` or similar composable calls. It can be placed anywhere inside them.
50 |
51 | Sample Code:
52 |
53 | ```kotlin
54 | Window(onCloseRequest = ::exitApplication) {
55 | WindowStyle(
56 | isDarkTheme = isDarkTheme,
57 | backdropType = backdropType,
58 | frameStyle = WindowFrameStyle(cornerPreference = WindowCornerPreference.NOT_ROUNDED),
59 | )
60 |
61 | App()
62 | }
63 | ```
64 |
65 | ## Documentation
66 |
67 | See documentation [here](https://mayakaapps.github.io/ComposeWindowStyler/)
68 |
69 | ## Available Styles
70 |
71 | ### `isDarkTheme`
72 |
73 | This property should match the theming system used in your application. Its effect depends on the
74 | used backdrop as follows:
75 |
76 | * If the `backdropType` is `WindowBackdrop.Mica` or `WindowBackdrop.Tabbed`, it is used to manage
77 | the color of the background whether it is light or dark.
78 | * Otherwise, it is used to control the color of the title bar of the window white/black.
79 |
80 | ### `backdropType`
81 |
82 | * `WindowBackdrop.Default`: Though its name may imply that the window will be left unchanged, this
83 | is not the case as once the transparency is hacked into the window, it can't be reverted. So, this
84 | effect provides a simple solid backdrop colored as white or black according to `isDarkTheme`. This
85 | allows the backdrop to blend with the title bar as well.
86 | * `WindowBackdrop.Solid(val color: Color)`: This applies the color as a solid background which means
87 | that any alpha component is ignored and the color is rendered as opaque.
88 | * `WindowBackdrop.Transparent`: This makes the window fully transparent.
89 | * `WindowBackdrop.Transparent(val color: Color)`: Same as `Solid` but allows transparency taking
90 | into account the alpha value. If the passed color is fully opaque, the alpha is set to `0.5F`.
91 | * `WindowBackdrop.Aero`: This applies [Aero](https://en.wikipedia.org/wiki/Windows_Aero) backdrop
92 | which is Windows Vista and Windows 7 version of blur. This effect doesn't allow any customization.
93 | * `WindowBackdrop.Acrylic(val color: Color)`: This
94 | applies [Acrylic](https://docs.microsoft.com/en-us/windows/apps/design/style/acrylic) backdrop
95 | blended with the supplied color. If the backdrop is rendered opaque, double check that `color` has
96 | a reasonable alpha value. Supported on Windows 10 version 1803 or greater.
97 | * `WindowBackdrop.Mica`: This
98 | applies [Mica](https://docs.microsoft.com/en-us/windows/apps/design/style/mica) backdrop themed
99 | according to `isDarkTheme` value. Supported on Windows 11 21H2 or greater.
100 | * `WindowBackdrop.Tabbed`: This applies Tabbed backdrop themed according to `isDarkTheme` value.
101 | This is a backdrop that is similar to `Mica` but targeted at tabbed windows. Supported on Windows
102 | 11 22H2 or greater.
103 |
104 | #### Fallback Strategy
105 |
106 | In case of unsupported effect the library tries to fall back to the nearest supported effect as
107 | follows (If an effect is not supported, check for the next):
108 |
109 | `Tabbed` -> `Mica` -> `Acrylic` -> `Transparent`
110 |
111 | Aero is dropped as it is much more transparent than `Tabbed` or `Mica` and not customizable as
112 | `Acrylic`. If `Tabbed`
113 | or `Mica` falls back to `Acrylic` or `Transparent`, high alpha is used with white or black color
114 | according to `isDarkTheme` to emulate these effects.
115 |
116 | ### `frameStyle`
117 |
118 | All the following properties are only supported on Windows 11 or greater and has no effect on other
119 | OSes.
120 |
121 | * `borderColor`: specifies the color of the window border that is running around the window if the
122 | window is decorated. This property doesn't support transparency.
123 | * `titleBarColor`: specifies the color of the window title bar (caption bar) if the window is
124 | decorated. This property doesn't support transparency.
125 | * `captionColor`: specifies the color of the window caption (title) text if the window is decorated.
126 | This property doesn't support transparency.
127 | * `cornerPreference`: specifies the shape of the corners you want. For example, you can use this
128 | property to avoid rounded corners in a decorated window or get the corners rounded in an
129 | undecorated window.
130 |
131 | ## License
132 |
133 | This library is distributed under Apache 2.0 License. See [LICENSE](LICENSE) for more information.
134 |
135 | ## Contributing
136 |
137 | All contributions are welcome. If you are reporting an issue, please use the provided template. If
138 | you're planning to contribute to the code, please open an issue first describing what feature you're
139 | planning to add or what issue you're planning to fix. This allows better discussion and coordination
140 | of efforts. You can also check open issues for bugs/features that needs to be fixed/implemented.
141 |
142 | ## Acknowledgements
143 |
144 | * [flutter_acrylic](https://github.com/alexmercerind/flutter_acrylic): This library is heavily based
145 | on flutter_acrylic.
146 | * [Swing Acrylic](https://github.com/krlvm/SwingAcrylic): as a reference for the Java implementation
147 | of required APIs.
148 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.kotlinMultiplatform) apply false
3 | alias(libs.plugins.composeMultiplatform) apply false
4 | alias(libs.plugins.composeCompiler) apply false
5 |
6 | alias(libs.plugins.dokka) apply false
7 | alias(libs.plugins.vanniktech.publish) apply false
8 | }
9 |
10 | subprojects {
11 | repositories {
12 | google()
13 | mavenCentral()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/docs/images/demo_preview.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MayakaApps/ComposeWindowStyler/ee3bdcb89efbe89698a7edf389afc2a3cac38173/docs/images/demo_preview.webp
--------------------------------------------------------------------------------
/docs/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MayakaApps/ComposeWindowStyler/ee3bdcb89efbe89698a7edf389afc2a3cac38173/docs/images/logo.png
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | Compose Window Styler is a library that lets you style your Compose for Desktop window to have more
2 | native and modern UI. This includes styling the window to use acrylic, mica, ...etc.
3 |
4 | ---
5 |
6 | 
7 |
8 | ---
9 |
10 | ## Setup (Gradle)
11 |
12 | ```kotlin
13 | repositories {
14 | mavenCentral()
15 |
16 | // Add only if you're using snapshot version
17 | maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
18 | }
19 |
20 | dependencies {
21 | implementation("com.mayakapps.compose:window-styler:{{ versions.library }}")
22 | }
23 | ```
24 |
25 | ## Usage
26 |
27 | You can apply the desired style to your window by using `WindowStyle` inside the `WindowScope` of
28 | `Window` or similar composable calls. It can be placed anywhere inside them.
29 |
30 | Sample Code:
31 |
32 | ```kotlin
33 | Window(onCloseRequest = ::exitApplication) {
34 | WindowStyle(
35 | isDarkTheme = isDarkTheme,
36 | backdropType = backdropType,
37 | frameStyle = WindowFrameStyle(cornerPreference = WindowCornerPreference.NOT_ROUNDED),
38 | )
39 |
40 | App()
41 | }
42 | ```
43 |
44 | ## Available Styles
45 |
46 | ### `isDarkTheme`
47 |
48 | This property should match the theming system used in your application. Its effect depends on the
49 | used backdrop as follows:
50 |
51 | * If the `backdropType` is `WindowBackdrop.Mica` or `WindowBackdrop.Tabbed`, it is used to manage
52 | the color of the background whether it is light or dark.
53 | * Otherwise, it is used to control the color of the title bar of the window white/black.
54 |
55 | ### `backdropType`
56 |
57 | * `WindowBackdrop.Default`: Though its name may imply that the window will be left unchanged, this
58 | is not the case as once the transparency is hacked into the window, it can't be reverted. So, this
59 | effect provides a simple solid backdrop colored as white or black according to `isDarkTheme`. This
60 | allows the backdrop to blend with the title bar as well.
61 | * `WindowBackdrop.Solid(val color: Color)`: This applies the color as a solid background which means
62 | that any alpha component is ignored and the color is rendered as opaque.
63 | * `WindowBackdrop.Transparent`: This makes the window fully transparent.
64 | * `WindowBackdrop.Transparent(val color: Color)`: Same as `Solid` but allows transparency, taking
65 | into account the alpha value. If the passed color is fully opaque, the alpha is set to `0.5F`.
66 | * `WindowBackdrop.Aero`: This applies [Aero](https://en.wikipedia.org/wiki/Windows_Aero) backdrop
67 | which is Windows Vista and Windows 7 version of blur. This effect doesn't allow any customization.
68 | * `WindowBackdrop.Acrylic(val color: Color)`: This
69 | applies [Acrylic](https://docs.microsoft.com/en-us/windows/apps/design/style/acrylic) backdrop
70 | blended with the supplied color. If the backdrop is rendered opaque, double check that `color` has
71 | a reasonable alpha value. Supported on Windows 10 version 1803 or greater.
72 | * `WindowBackdrop.Mica`: This
73 | applies [Mica](https://docs.microsoft.com/en-us/windows/apps/design/style/mica) backdrop themed
74 | according to `isDarkTheme` value. Supported on Windows 11 21H2 or greater.
75 | * `WindowBackdrop.Tabbed`: This applies Tabbed backdrop themed according to `isDarkTheme` value.
76 | This is a backdrop that is similar to `Mica` but targeted at tabbed windows. Supported on Windows
77 | 11 22H2 or greater.
78 |
79 | #### Fallback Strategy
80 |
81 | In case of unsupported effect the library tries to fall back to the nearest supported effect as
82 | follows (If an effect is not supported, check for the next):
83 |
84 | `Tabbed` -> `Mica` -> `Acrylic` -> `Transparent`
85 |
86 | Aero is dropped as it is much more transparent than `Tabbed` or `Mica` and not customizable as
87 | `Acrylic`. If `Tabbed`
88 | or `Mica` falls back to `Acrylic` or `Transparent`, high alpha is used with white or black color
89 | according to `isDarkTheme` to emulate these effects.
90 |
91 | ### `frameStyle`
92 |
93 | All the following properties are only supported on Windows 11 or greater and has no effect on other
94 | OSes.
95 |
96 | * `borderColor`: specifies the color of the window border that is running around the window if the
97 | window is decorated. This property doesn't support transparency.
98 | * `titleBarColor`: specifies the color of the window title bar (caption bar) if the window is
99 | decorated. This property doesn't support transparency.
100 | * `captionColor`: specifies the color of the window caption (title) text if the window is decorated.
101 | This property doesn't support transparency.
102 | * `cornerPreference`: specifies the shape of the corners you want. For example, you can use this
103 | property to avoid rounded corners in a decorated window or get the corners rounded in an
104 | undecorated window.
105 |
106 | ## License
107 |
108 | This library is distributed under Apache 2.0 License.
109 |
110 | ## Contributing
111 |
112 | All contributions are welcome. If you are reporting an issue, please use the provided template. If
113 | you're planning to contribute to the code, please open an issue first describing what feature you're
114 | planning to add or what issue you're planning to fix. This allows better discussion and coordination
115 | of efforts. You can also check open issues for bugs/features that needs to be fixed/implemented.
116 |
117 | ## Acknowledgements
118 |
119 | * [flutter_acrylic](https://github.com/alexmercerind/flutter_acrylic): This library is heavily based
120 | on flutter_acrylic
121 | * [Swing Acrylic](https://github.com/krlvm/SwingAcrylic): as a reference for the Java implementation
122 | of required APIs
123 |
--------------------------------------------------------------------------------
/docs/styles/dokka.css:
--------------------------------------------------------------------------------
1 | .library-name--link:before {
2 | background: url("../images/logo.png") center no-repeat;
3 | background-size: contain;
4 | }
5 |
6 | .navigation {
7 | padding: 4px max(calc((100% - 1220px) / 2), 16px);
8 | }
9 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Kotlin
3 | #
4 |
5 | kotlin.code.style=official
6 | org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
7 | org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
8 |
9 | #
10 | # Gradle VM
11 | #
12 |
13 | org.gradle.jvmargs=-Xmx8192m
14 | org.gradle.parallel=true
15 | org.gradle.caching=true
16 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | kotlin = "2.1.10"
3 | compose-multiplatform = "1.7.3"
4 |
5 | jna = "5.16.0"
6 |
7 | dokka = "2.0.0"
8 | vanniktech-publish = "0.30.0"
9 |
10 | [plugins]
11 | kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
12 | composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "compose-multiplatform" }
13 | composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
14 |
15 | dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
16 | vanniktech-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech-publish" }
17 |
18 | [libraries]
19 | jna = { module = "net.java.dev.jna:jna", version.ref = "jna" }
20 | jna-platform = { module = "net.java.dev.jna:jna-platform", version.ref = "jna" }
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MayakaApps/ComposeWindowStyler/ee3bdcb89efbe89698a7edf389afc2a3cac38173/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | if ! command -v java >/dev/null 2>&1
137 | then
138 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
139 |
140 | Please set the JAVA_HOME variable in your environment to match the
141 | location of your Java installation."
142 | fi
143 | fi
144 |
145 | # Increase the maximum file descriptors if we can.
146 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
147 | case $MAX_FD in #(
148 | max*)
149 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
150 | # shellcheck disable=SC2039,SC3045
151 | MAX_FD=$( ulimit -H -n ) ||
152 | warn "Could not query maximum file descriptor limit"
153 | esac
154 | case $MAX_FD in #(
155 | '' | soft) :;; #(
156 | *)
157 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
158 | # shellcheck disable=SC2039,SC3045
159 | ulimit -n "$MAX_FD" ||
160 | warn "Could not set maximum file descriptor limit to $MAX_FD"
161 | esac
162 | fi
163 |
164 | # Collect all arguments for the java command, stacking in reverse order:
165 | # * args from the command line
166 | # * the main class name
167 | # * -classpath
168 | # * -D...appname settings
169 | # * --module-path (only if needed)
170 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
171 |
172 | # For Cygwin or MSYS, switch paths to Windows format before running java
173 | if "$cygwin" || "$msys" ; then
174 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176 |
177 | JAVACMD=$( cygpath --unix "$JAVACMD" )
178 |
179 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
180 | for arg do
181 | if
182 | case $arg in #(
183 | -*) false ;; # don't mess with options #(
184 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
185 | [ -e "$t" ] ;; #(
186 | *) false ;;
187 | esac
188 | then
189 | arg=$( cygpath --path --ignore --mixed "$arg" )
190 | fi
191 | # Roll the args list around exactly as many times as the number of
192 | # args, so each arg winds up back in the position where it started, but
193 | # possibly modified.
194 | #
195 | # NB: a `for` loop captures its iteration list before it begins, so
196 | # changing the positional parameters here affects neither the number of
197 | # iterations, nor the values presented in `arg`.
198 | shift # remove old arg
199 | set -- "$@" "$arg" # push replacement arg
200 | done
201 | fi
202 |
203 |
204 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206 |
207 | # Collect all arguments for the java command:
208 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209 | # and any embedded shellness will be escaped.
210 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211 | # treated as '${Hostname}' itself on the command line.
212 |
213 | set -- \
214 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
215 | -classpath "$CLASSPATH" \
216 | org.gradle.wrapper.GradleWrapperMain \
217 | "$@"
218 |
219 | # Stop when "xargs" is not available.
220 | if ! command -v xargs >/dev/null 2>&1
221 | then
222 | die "xargs is not available"
223 | fi
224 |
225 | # Use "xargs" to parse quoted args.
226 | #
227 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
228 | #
229 | # In Bash we could simply go:
230 | #
231 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
232 | # set -- "${ARGS[@]}" "$@"
233 | #
234 | # but POSIX shell has neither arrays nor command substitution, so instead we
235 | # post-process each arg (as a line of input to sed) to backslash-escape any
236 | # character that might be a shell metacharacter, then use eval to reverse
237 | # that process (while maintaining the separation between arguments), and wrap
238 | # the whole thing up as a single "set" statement.
239 | #
240 | # This will of course break if any of these variables contains a newline or
241 | # an unmatched quote.
242 | #
243 |
244 | eval "set -- $(
245 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
246 | xargs -n1 |
247 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248 | tr '\n' ' '
249 | )" '"$@"'
250 |
251 | exec "$JAVACMD" "$@"
252 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/mkdocs.yml:
--------------------------------------------------------------------------------
1 | site_name: Compose Window Styler
2 | site_description: A library that lets you style your Compose for Desktop window to have more native and modern UI.
3 | site_author: MayakaApps
4 | site_url: https://mayakaapps.github.io/ComposeWindowStyler
5 | repo_name: ComposeWindowStyler
6 | repo_url: https://github.com/MayakaApps/ComposeWindowStyler
7 | copyright: Copyright © 2022-2025 MayakaApps. # Also, update copyright notice in Dokka
8 | remote_branch: gh-pages
9 |
10 | nav:
11 | - 'Overview': index.md
12 | - 'API Reference': api/index.html
13 |
14 | theme:
15 | name: 'material'
16 | favicon: images/logo.png
17 | logo: images/logo.png
18 | palette:
19 | # Palette toggle for light mode
20 | - scheme: default
21 | media: "(prefers-color-scheme: light)"
22 | primary: 'indigo'
23 | accent: 'pink'
24 | toggle:
25 | icon: material/brightness-7
26 | name: Switch to dark mode
27 |
28 | # Palette toggle for dark mode
29 | - scheme: slate
30 | media: "(prefers-color-scheme: dark)"
31 | primary: 'indigo'
32 | accent: 'pink'
33 | toggle:
34 | icon: material/brightness-4
35 | name: Switch to light mode
36 | features:
37 | - content.code.annotate
38 | - content.action.view
39 |
40 | markdown_extensions:
41 | - pymdownx.highlight:
42 | use_pygments: true
43 | - pymdownx.superfences
44 | - codehilite:
45 | guess_lang: false
46 | - pymdownx.tabbed:
47 | alternate_style: true
48 | - pymdownx.critic
49 | - pymdownx.critic
50 | - admonition
51 | - pymdownx.details
52 | - toc:
53 | permalink: true
54 | - md_in_html
55 | - attr_list
56 | - pymdownx.emoji:
57 | emoji_index: !!python/name:material.extensions.emoji.twemoji
58 | emoji_generator: !!python/name:material.extensions.emoji.to_svg
59 |
60 | plugins:
61 | - search
62 | - macros
63 | - mike
64 |
65 | extra:
66 | versions:
67 | library: !ENV [LIBRARY_VERSION]
68 | version:
69 | provider: mike
70 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | }
5 | }
6 |
7 | rootProject.name = "ComposeWindowStyler"
8 | include("window-styler", "window-styler-demo")
9 |
--------------------------------------------------------------------------------
/window-styler-demo/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.jetbrains.compose.desktop.application.dsl.TargetFormat
2 |
3 | plugins {
4 | alias(libs.plugins.kotlinMultiplatform)
5 | alias(libs.plugins.composeMultiplatform)
6 | alias(libs.plugins.composeCompiler)
7 | }
8 |
9 | kotlin {
10 | jvmToolchain(17)
11 |
12 | jvm()
13 |
14 | sourceSets {
15 | jvmMain {
16 | dependencies {
17 | implementation(compose.desktop.currentOs)
18 |
19 | implementation(project(":window-styler"))
20 | }
21 | }
22 | }
23 | }
24 |
25 | compose.desktop {
26 | application {
27 | mainClass = "MainKt"
28 |
29 | nativeDistributions {
30 | targetFormats(TargetFormat.Msi)
31 |
32 | packageName = "window-styler-demo"
33 | packageVersion = "1.0.0"
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/window-styler-demo/src/jvmMain/kotlin/Main.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | import androidx.compose.desktop.ui.tooling.preview.Preview
18 | import androidx.compose.foundation.layout.*
19 | import androidx.compose.material.LocalContentColor
20 | import androidx.compose.material.MaterialTheme
21 | import androidx.compose.material.darkColors
22 | import androidx.compose.material.lightColors
23 | import androidx.compose.runtime.*
24 | import androidx.compose.ui.Alignment
25 | import androidx.compose.ui.Modifier
26 | import androidx.compose.ui.graphics.Color
27 | import androidx.compose.ui.unit.dp
28 | import androidx.compose.ui.window.Window
29 | import androidx.compose.ui.window.application
30 | import com.mayakapps.compose.windowstyler.WindowBackdrop
31 | import com.mayakapps.compose.windowstyler.WindowCornerPreference
32 | import com.mayakapps.compose.windowstyler.WindowFrameStyle
33 | import com.mayakapps.compose.windowstyler.WindowStyle
34 |
35 | @Composable
36 | @Preview
37 | fun App(
38 | isDarkTheme: Boolean,
39 | onThemeChange: (Boolean) -> Unit,
40 | backdropType: WindowBackdrop,
41 | onBackdropChange: (WindowBackdrop) -> Unit,
42 | ) {
43 | Column(
44 | modifier = Modifier
45 | .padding(16.dp)
46 | .fillMaxSize(),
47 | verticalArrangement = Arrangement.Center,
48 | horizontalAlignment = Alignment.CenterHorizontally,
49 | ) {
50 | RadioGroup("Theme", themeOptions, isDarkTheme, onThemeChange)
51 | Spacer(Modifier.height(50.dp))
52 | RadioGroup("Backdrop Type", backdropOptions, backdropType, onBackdropChange)
53 | }
54 | }
55 |
56 | fun main() = application {
57 | Window(
58 | onCloseRequest = ::exitApplication,
59 | title = "Compose Window Styler Demo",
60 | ) {
61 | var isDarkTheme by remember { mutableStateOf(false) }
62 | var backdropType by remember { mutableStateOf(WindowBackdrop.Default) }
63 |
64 | WindowStyle(
65 | isDarkTheme = isDarkTheme,
66 | backdropType = backdropType,
67 | frameStyle = WindowFrameStyle(cornerPreference = WindowCornerPreference.NOT_ROUNDED),
68 | )
69 |
70 | MaterialTheme(colors = if (isDarkTheme) darkColors() else lightColors()) {
71 | CompositionLocalProvider(LocalContentColor provides MaterialTheme.colors.onBackground) {
72 | App(
73 | isDarkTheme = isDarkTheme,
74 | onThemeChange = { isDarkTheme = it },
75 | backdropType = backdropType,
76 | onBackdropChange = { backdropType = it },
77 | )
78 | }
79 | }
80 | }
81 | }
82 |
83 | val themeOptions = listOf(false to "Light", true to "Dark")
84 | val backdropOptions = listOf(
85 | WindowBackdrop.Default to "Default",
86 | WindowBackdrop.Solid(Color.Red) to "Solid Red",
87 | WindowBackdrop.Solid(Color.Blue) to "Solid Blue",
88 | WindowBackdrop.Transparent to "Transparent",
89 | WindowBackdrop.Transparent(Color.Yellow.copy(alpha = 0.25F)) to "Yellow Transparent",
90 | WindowBackdrop.Aero to "Aero",
91 | WindowBackdrop.Acrylic(Color.Magenta.copy(alpha = 0.25F)) to "Acrylic Magenta",
92 | WindowBackdrop.Acrylic(Color.Cyan.copy(alpha = 0.25F)) to "Acrylic Cyan",
93 | WindowBackdrop.Mica to "Mica",
94 | WindowBackdrop.Tabbed to "Tabbed",
95 | )
--------------------------------------------------------------------------------
/window-styler-demo/src/jvmMain/kotlin/RadioGroup.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | import androidx.compose.foundation.layout.Column
18 | import androidx.compose.foundation.layout.Row
19 | import androidx.compose.foundation.layout.Spacer
20 | import androidx.compose.foundation.layout.height
21 | import androidx.compose.foundation.lazy.grid.GridCells
22 | import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
23 | import androidx.compose.foundation.lazy.grid.items
24 | import androidx.compose.material.MaterialTheme
25 | import androidx.compose.material.RadioButton
26 | import androidx.compose.material.Text
27 | import androidx.compose.runtime.Composable
28 | import androidx.compose.ui.Alignment
29 | import androidx.compose.ui.Modifier
30 | import androidx.compose.ui.unit.dp
31 |
32 | @Composable
33 | fun RadioGroup(title: String, options: List>, selected: T, onSelectedChange: (T) -> Unit) {
34 | Column(horizontalAlignment = Alignment.CenterHorizontally) {
35 | Text(
36 | text = title,
37 | style = MaterialTheme.typography.h6,
38 | )
39 |
40 | Spacer(Modifier.height(8.dp))
41 |
42 | LazyVerticalGrid(columns = GridCells.Adaptive(200.dp)) {
43 | items(options) { (option, name) ->
44 | Row(verticalAlignment = Alignment.CenterVertically) {
45 | RadioButton(
46 | selected = option == selected,
47 | onClick = { onSelectedChange(option) },
48 | )
49 |
50 | Text(name)
51 | }
52 | }
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/window-styler/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.kotlinMultiplatform)
3 | alias(libs.plugins.composeMultiplatform)
4 | alias(libs.plugins.composeCompiler)
5 |
6 | alias(libs.plugins.dokka)
7 | alias(libs.plugins.vanniktech.publish)
8 | }
9 |
10 | group = extra["GROUP"] as String
11 | version = extra["VERSION_NAME"] as String
12 |
13 | kotlin {
14 | jvmToolchain(17)
15 |
16 | jvm()
17 |
18 | sourceSets {
19 | jvmMain {
20 | dependencies {
21 | implementation(compose.runtime)
22 | implementation(compose.ui)
23 |
24 | implementation(libs.jna)
25 | implementation(libs.jna.platform)
26 | }
27 | }
28 | }
29 | }
30 |
31 | dokka {
32 | moduleName.set("Compose Window Styler")
33 |
34 | dokkaPublications.html {
35 | outputDirectory.set(rootProject.layout.projectDirectory.dir("docs/api"))
36 | }
37 |
38 | pluginsConfiguration.html {
39 | customStyleSheets.from(rootProject.layout.projectDirectory.file("docs/styles/dokka.css"))
40 | customAssets.from(rootProject.layout.projectDirectory.file("docs/images/logo.png"))
41 |
42 | footerMessage.set("Copyright © 2022-2025 MayakaApps.")
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/window-styler/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Publishing Configuration
3 | #
4 |
5 | SONATYPE_HOST=S01
6 | RELEASE_SIGNING_ENABLED=true
7 |
8 | GROUP=com.mayakapps.compose
9 | POM_ARTIFACT_ID=window-styler
10 | VERSION_NAME=0.4.0
11 |
12 | POM_NAME=Compose Window Styler
13 | POM_DESCRIPTION=A library that lets you style your Compose Desktop application window
14 | POM_INCEPTION_YEAR=2022
15 |
16 | POM_URL=https://github.com/MayakaApps/ComposeWindowStyler
17 | POM_SCM_URL=https://github.com/MayakaApps/ComposeWindowStyler
18 | POM_SCM_CONNECTION=scm:git:git://github.com/MayakaApps/ComposeWindowStyler.git
19 | POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/MayakaApps/ComposeWindowStyler.git
20 |
21 | POM_LICENSE_NAME=Apache License, Version 2.0
22 | POM_LICENSE_URL=https://raw.githubusercontent.com/MayakaApps/ComposeWindowStyler/main/LICENSE
23 | POM_LICENSE_DIST=repo
24 |
25 | POM_DEVELOPER_ID=MayakaApps
26 | POM_DEVELOPER_NAME=MayakaApps
27 | POM_DEVELOPER_URL=https://github.com/MayakaApps/
28 |
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/HackedContentPane.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler
18 |
19 | import java.awt.AlphaComposite
20 | import java.awt.Graphics
21 | import java.awt.Graphics2D
22 | import javax.swing.JPanel
23 |
24 | internal class HackedContentPane : JPanel() {
25 |
26 | override fun paint(g: Graphics) {
27 | if (background.alpha != 255) {
28 | val gg = g.create()
29 | try {
30 | if (gg is Graphics2D) {
31 | gg.setColor(background)
32 | gg.composite = AlphaComposite.getInstance(AlphaComposite.SRC)
33 | gg.fillRect(0, 0, width, height)
34 | }
35 | } finally {
36 | gg.dispose()
37 | }
38 | }
39 |
40 | super.paint(g)
41 | }
42 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/TransparencyUtils.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler
18 |
19 | import androidx.compose.ui.awt.ComposeWindow
20 | import org.jetbrains.skiko.SkiaLayer
21 | import java.awt.BorderLayout
22 | import java.awt.Color
23 | import java.awt.Component
24 | import java.awt.Container
25 | import java.awt.Frame
26 | import java.awt.Window
27 | import javax.swing.JComponent
28 | import javax.swing.JDialog
29 | import javax.swing.JWindow
30 |
31 | internal fun ComposeWindow.setComposeLayerTransparency(isTransparent: Boolean) {
32 | findSkiaLayer()?.transparency = isTransparent
33 | }
34 |
35 | internal fun Window.hackContentPane() {
36 | val oldContentPane = contentPane ?: return
37 |
38 | // Create hacked content pane the same way of AWT
39 | val newContentPane: JComponent = HackedContentPane()
40 | newContentPane.name = "$name.contentPane"
41 | newContentPane.layout = object : BorderLayout() {
42 | override fun addLayoutComponent(comp: Component, constraints: Any?) {
43 | super.addLayoutComponent(comp, constraints ?: CENTER)
44 | }
45 | }
46 |
47 | newContentPane.background = Color(0, 0, 0, 0)
48 |
49 | oldContentPane.components.forEach { newContentPane.add(it) }
50 |
51 | contentPane = newContentPane
52 | }
53 |
54 | private fun findComponent(
55 | container: Container,
56 | klass: Class,
57 | ): T? {
58 | val componentSequence = container.components.asSequence()
59 | return componentSequence.filter { klass.isInstance(it) }.ifEmpty {
60 | componentSequence.filterIsInstance()
61 | .mapNotNull { findComponent(it, klass) }
62 | }.map { klass.cast(it) }.firstOrNull()
63 | }
64 |
65 | private inline fun Container.findComponent() =
66 | findComponent(this, T::class.java)
67 |
68 | private fun ComposeWindow.findSkiaLayer(): SkiaLayer? = findComponent()
69 |
70 | internal val Window.isTransparent
71 | get() = when (this) {
72 | is ComposeWindow -> findSkiaLayer()?.transparency ?: false
73 | else -> background.alpha != 255
74 | }
75 |
76 | internal val Window.isUndecorated
77 | get() = when (this) {
78 | is Frame -> isUndecorated
79 | is JDialog -> isUndecorated
80 | is JWindow -> true
81 | else -> false
82 | }
83 |
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/Utils.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler
18 |
19 | import java.awt.Window
20 | import javax.swing.JDialog
21 | import javax.swing.JFrame
22 | import javax.swing.JWindow
23 |
24 | // Try hard to get the contentPane
25 | internal var Window.contentPane
26 | get() = when (this) {
27 | is JFrame -> contentPane
28 | is JDialog -> contentPane
29 | is JWindow -> contentPane
30 | else -> null
31 | }
32 | set(value) = when (this) {
33 | is JFrame -> contentPane = value
34 | is JDialog -> contentPane = value
35 | is JWindow -> contentPane = value
36 | else -> throw IllegalStateException()
37 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/WindowBackdrop.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler
18 |
19 | import androidx.compose.ui.graphics.Color
20 |
21 | /**
22 | * The type of the window backdrop/background.
23 | *
24 | * **Fallback Strategy**
25 | *
26 | * In case of unsupported effect the library tries to fall back to the nearest supported effect as follows:
27 | *
28 | * [Tabbed] -> [Mica] -> [Acrylic] -> [Transparent]
29 | *
30 | * [Aero] is dropped from the fallback as it is much more transparent than [Tabbed] or [Mica] and not customizable as
31 | * [Acrylic]. If [Tabbed] or [Mica] falls back to [Acrylic] or [Transparent], high alpha is used with white or black
32 | * color according to `isDarkTheme` to emulate these effects.
33 | */
34 | sealed interface WindowBackdrop {
35 |
36 | /**
37 | * This effect provides a simple solid backdrop colored as white or black according to isDarkTheme. This allows the
38 | * backdrop to blend with the title bar as well. Though its name may imply that the window will be left unchanged,
39 | * this is not the case as once the transparency is hacked into the window, it can't be reverted.
40 | */
41 | object Default : WindowBackdrop
42 |
43 | /**
44 | * This applies [color] as a solid background which means that any alpha component is ignored and the color is
45 | * rendered as opaque.
46 | */
47 | open class Solid(override val color: Color) : WindowBackdrop, ColorableWindowBackdrop {
48 | override fun equals(other: Any?): Boolean = equalsImpl(other)
49 | override fun hashCode(): Int = hashCodeImpl()
50 | }
51 |
52 | /**
53 | * Same as [Solid] but allows transparency taking into account the alpha value. If the passed [color] is fully
54 | * opaque, the alpha is set to 0.5F.
55 | */
56 | open class Transparent(color: Color) : WindowBackdrop, ColorableWindowBackdrop {
57 | // If you really want the color to be fully opaque, just use Solid which is simpler and more stable
58 | override val color: Color =
59 | if (color.alpha != 1F) color else color.copy(alpha = 0.5F)
60 |
61 | override fun equals(other: Any?): Boolean = equalsImpl(other)
62 | override fun hashCode(): Int = hashCodeImpl()
63 |
64 | /**
65 | * This makes the window fully transparent.
66 | */
67 | companion object : Transparent(Color.Transparent)
68 | }
69 |
70 | /**
71 | * This applies [Aero](https://en.wikipedia.org/wiki/Windows_Aero) backdrop which is Windows Vista and Windows 7
72 | * version of blur.
73 | *
74 | * This effect doesn't allow any customization.
75 | */
76 | object Aero : WindowBackdrop
77 |
78 | /**
79 | * This applies [Acrylic](https://docs.microsoft.com/en-us/windows/apps/design/style/acrylic) backdrop blended with
80 | * the supplied [color]. If the backdrop is rendered opaque, double check that [color] has reasonable alpha value.
81 | *
82 | * **Supported on Windows 10 version 1803 or greater.**
83 | */
84 | open class Acrylic(override val color: Color) : WindowBackdrop, ColorableWindowBackdrop {
85 | override fun equals(other: Any?): Boolean = equalsImpl(other)
86 | override fun hashCode(): Int = hashCodeImpl()
87 | }
88 |
89 | /**
90 | * This applies [Mica](https://docs.microsoft.com/en-us/windows/apps/design/style/mica) backdrop themed according
91 | * to `isDarkTheme` value.
92 | *
93 | * **Supported on Windows 11 21H2 or greater.**
94 | */
95 | object Mica : WindowBackdrop
96 |
97 | /**
98 | * This applies Tabbed backdrop themed according to `isDarkTheme` value. This is a backdrop that is similar to
99 | * [Mica] but targeted at tabbed windows.
100 | *
101 | * **Supported on Windows 11 22H2 or greater.**
102 | */
103 | object Tabbed : WindowBackdrop
104 | }
105 |
106 | internal sealed interface ColorableWindowBackdrop {
107 | val color: Color
108 |
109 | fun equalsImpl(other: Any?): Boolean {
110 | if (this === other) return true
111 | if (javaClass != other?.javaClass) return false
112 |
113 | other as ColorableWindowBackdrop
114 |
115 | return color == other.color
116 | }
117 |
118 | fun hashCodeImpl(): Int = color.hashCode()
119 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/WindowFrameStyle.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler
18 |
19 | import androidx.compose.ui.graphics.Color
20 |
21 | /**
22 | * Styles for the window frame which includes the title bar and window border.
23 | *
24 | * All these styles are only supported on Windows 11 or greater and has no effect on other OSes.
25 | *
26 | * @property borderColor Specifies the color of the window border that is running around the window if the window is
27 | * decorated. This property doesn't support transparency.
28 | * @property titleBarColor Specifies the color of the window title bar (caption bar) if the window is decorated. This
29 | * property doesn't support transparency.
30 | * @property captionColor Specifies the color of the window caption (title) text if the window is decorated. This
31 | * property doesn't support transparency.
32 | * @property cornerPreference Specifies the shape of the corners you want. For example, you can use this property to
33 | * avoid rounded corners in a decorated window or get the corners rounded in an undecorated window.
34 | */
35 | data class WindowFrameStyle(
36 | val borderColor: Color = Color.Unspecified,
37 | val titleBarColor: Color = Color.Unspecified,
38 | val captionColor: Color = Color.Unspecified,
39 | val cornerPreference: WindowCornerPreference = WindowCornerPreference.DEFAULT
40 | )
41 |
42 | /**
43 | * The preferred corner shape of the window.
44 | */
45 | enum class WindowCornerPreference {
46 | DEFAULT,
47 | NOT_ROUNDED,
48 | ROUNDED,
49 | SMALL_ROUNDED,
50 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/WindowStyle.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler
18 |
19 | import androidx.compose.runtime.Composable
20 | import androidx.compose.runtime.LaunchedEffect
21 | import androidx.compose.runtime.remember
22 | import androidx.compose.ui.window.WindowScope
23 |
24 | /**
25 | * Applies the provided styles to the current window.
26 | *
27 | * See [WindowStyleManager.isDarkTheme], [WindowBackdrop], [WindowFrameStyle].
28 | */
29 | @Composable
30 | fun WindowScope.WindowStyle(
31 | isDarkTheme: Boolean = false,
32 | backdropType: WindowBackdrop = WindowBackdrop.Default,
33 | frameStyle: WindowFrameStyle = WindowFrameStyle(),
34 | ) {
35 | val manager = remember { WindowStyleManager(window, isDarkTheme, backdropType, frameStyle) }
36 |
37 | LaunchedEffect(isDarkTheme) {
38 | manager.isDarkTheme = isDarkTheme
39 | }
40 |
41 | LaunchedEffect(backdropType) {
42 | manager.backdropType = backdropType
43 | }
44 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/WindowStyleManager.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler
18 |
19 | import com.mayakapps.compose.windowstyler.windows.WindowsWindowStyleManager
20 | import org.jetbrains.skiko.OS
21 | import org.jetbrains.skiko.hostOs
22 | import java.awt.Window
23 |
24 | /**
25 | * Creates a suitable [WindowStyleManager] for [window] or a stub manager if the OS is not supported.
26 | *
27 | * The created manager is initialized by the supplied parameters.
28 | * See [WindowStyleManager.isDarkTheme], [WindowBackdrop], [WindowFrameStyle].
29 | */
30 | fun WindowStyleManager(
31 | window: Window,
32 | isDarkTheme: Boolean = false,
33 | backdropType: WindowBackdrop = WindowBackdrop.Default,
34 | frameStyle: WindowFrameStyle = WindowFrameStyle(),
35 | ) = when (hostOs) {
36 | OS.Windows -> WindowsWindowStyleManager(window, isDarkTheme, backdropType, frameStyle)
37 | else -> StubWindowStyleManager(isDarkTheme, backdropType, frameStyle)
38 | }
39 |
40 | /**
41 | * Style manager which lets you update the style of the provided window using the exposed properties.
42 | *
43 | * Only use this manager if you can't use the `@Composable` method [WindowStyle]
44 | */
45 | interface WindowStyleManager {
46 |
47 | /**
48 | * This property should match the theming system used in your application. It's effect depends on the used backdrop
49 | * as follows:
50 | * * If the [backdropType] is [WindowBackdrop.Default], [WindowBackdrop.Mica] or [WindowBackdrop.Tabbed], it is
51 | * used to manage the color of the background whether it is light or dark.
52 | * * Otherwise, it is used to control the color of the title bar of the window white/black.
53 | */
54 | var isDarkTheme: Boolean
55 |
56 | /**
57 | * The type of the window backdrop/background. See [WindowBackdrop] and its implementations.
58 | */
59 | var backdropType: WindowBackdrop
60 |
61 | /**
62 | * The style of the window frame which includes the title bar and window border. See [WindowFrameStyle].
63 | */
64 | var frameStyle: WindowFrameStyle
65 | }
66 |
67 | internal class StubWindowStyleManager(
68 | override var isDarkTheme: Boolean,
69 | override var backdropType: WindowBackdrop,
70 | override var frameStyle: WindowFrameStyle,
71 | ) : WindowStyleManager
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/ColorUtils.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows
18 |
19 | import androidx.compose.ui.graphics.Color
20 | import androidx.compose.ui.graphics.colorspace.connect
21 |
22 | internal fun Color.toBgr(): Int {
23 | val colorSpace = colorSpace
24 | val color = floatArrayOf(red, green, blue)
25 |
26 | // The transformation saturates the output
27 | colorSpace.connect().transform(color)
28 |
29 | return ((color[2] * 255.0f + 0.5f).toInt() shl 16) or
30 | ((color[1] * 255.0f + 0.5f).toInt() shl 8) or
31 | (color[0] * 255.0f + 0.5f).toInt()
32 | }
33 |
34 | // Modified version of toArgb
35 | internal fun Color.toAbgr(): Int {
36 | val colorSpace = colorSpace
37 | val color = floatArrayOf(red, green, blue, alpha)
38 |
39 | // The transformation saturates the output
40 | colorSpace.connect().transform(color)
41 |
42 | return (color[3] * 255.0f + 0.5f).toInt() shl 24 or
43 | ((color[2] * 255.0f + 0.5f).toInt() shl 16) or
44 | ((color[1] * 255.0f + 0.5f).toInt() shl 8) or
45 | (color[0] * 255.0f + 0.5f).toInt()
46 | }
47 |
48 | // For some reason, passing 0 (fully transparent black) to the setAccentPolicy with
49 | // transparent accent policy results in solid red color. As a workaround, we pass
50 | // fully transparent white which has the same visual effect.
51 | internal fun Color.toAbgrForTransparent() = if (alpha == 0F) 0x00FFFFFF else toAbgr()
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/Utils.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows
18 |
19 | import androidx.compose.ui.awt.ComposeWindow
20 | import com.mayakapps.compose.windowstyler.WindowCornerPreference
21 | import com.mayakapps.compose.windowstyler.windows.jna.Nt
22 | import com.mayakapps.compose.windowstyler.windows.jna.enums.DwmWindowCornerPreference
23 | import com.sun.jna.Native
24 | import com.sun.jna.Pointer
25 | import com.sun.jna.platform.win32.WinDef
26 | import java.awt.Window
27 |
28 | internal val Window.hwnd
29 | get() =
30 | if (this is ComposeWindow) WinDef.HWND(Pointer(windowHandle))
31 | else WinDef.HWND(Native.getWindowPointer(this))
32 |
33 | internal val windowsBuild by lazy {
34 | val osVersionInfo = Nt.getVersion()
35 | val buildNumber = osVersionInfo.buildNumber
36 | osVersionInfo.dispose()
37 | buildNumber
38 | }
39 |
40 | internal fun WindowCornerPreference.toDwmWindowCornerPreference(): DwmWindowCornerPreference =
41 | when (this) {
42 | WindowCornerPreference.DEFAULT -> DwmWindowCornerPreference.DWMWCP_DEFAULT
43 | WindowCornerPreference.NOT_ROUNDED -> DwmWindowCornerPreference.DWMWCP_DONOTROUND
44 | WindowCornerPreference.ROUNDED -> DwmWindowCornerPreference.DWMWCP_ROUND
45 | WindowCornerPreference.SMALL_ROUNDED -> DwmWindowCornerPreference.DWMWCP_ROUNDSMALL
46 | }
47 |
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/WindowsBackdropApis.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows
18 |
19 | import com.mayakapps.compose.windowstyler.windows.jna.Dwm
20 | import com.mayakapps.compose.windowstyler.windows.jna.User32
21 | import com.mayakapps.compose.windowstyler.windows.jna.enums.AccentFlag
22 | import com.mayakapps.compose.windowstyler.windows.jna.enums.AccentState
23 | import com.mayakapps.compose.windowstyler.windows.jna.enums.DwmSystemBackdrop
24 | import com.mayakapps.compose.windowstyler.windows.jna.enums.DwmWindowAttribute
25 | import com.sun.jna.platform.win32.WinDef
26 |
27 | internal class WindowsBackdropApis(private val hwnd: WinDef.HWND) {
28 |
29 | var systemBackdrop: DwmSystemBackdrop? = null
30 | set(value) {
31 | requireNotNull(value)
32 | if (field == value) return
33 |
34 | val result = Dwm.setSystemBackdrop(hwnd, value)
35 | if (result) field = value
36 | }
37 |
38 | var isMicaEffectEnabled: Boolean? = null
39 | set(value) {
40 | requireNotNull(value)
41 | if (field == value) return
42 |
43 | val result = Dwm.setWindowAttribute(hwnd, DwmWindowAttribute.DWMWA_MICA_EFFECT, value)
44 | if (result) field = value
45 | }
46 |
47 | var isSheetOfGlassEffectEnabled: Boolean? = null
48 | set(value) {
49 | requireNotNull(value)
50 |
51 | val result = if (value) {
52 | // Negative margins have special meaning to DwmExtendFrameIntoClientArea.
53 | // Negative margins create the "sheet of glass" effect, where the client area is
54 | // rendered as a solid surface with no window border.
55 | Dwm.extendFrameIntoClientArea(hwnd = hwnd, margin = -1)
56 | } else {
57 | // At least one margin should be non-negative in order to show the DWM window shadow
58 | // created by handling [WM_NCCALCSIZE]. Matching value with bitsdojo_window:
59 | // https://github.com/bitsdojo/bitsdojo_window/blob/adad0cd40be3d3e12df11d864f18a96a2d0fb4fb/bitsdojo_window_windows/windows/bitsdojo_window.cpp#L149
60 | Dwm.extendFrameIntoClientArea(
61 | hwnd = hwnd,
62 | leftWidth = 0,
63 | rightWidth = 0,
64 | topHeight = 1,
65 | bottomHeight = 0,
66 | )
67 | }
68 |
69 | if (result) field = value
70 | }
71 |
72 | fun setAccentPolicy(
73 | accentState: AccentState = AccentState.ACCENT_DISABLED,
74 | accentFlags: Set = emptySet(),
75 | color: Int = 0,
76 | animationId: Int = 0,
77 | ) {
78 | User32.setAccentPolicy(hwnd, accentState, accentFlags, color, animationId)
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/WindowsWindowStyleManager.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows
18 |
19 | import androidx.compose.ui.awt.ComposeWindow
20 | import androidx.compose.ui.graphics.Color
21 | import androidx.compose.ui.graphics.isSpecified
22 | import androidx.compose.ui.graphics.isUnspecified
23 | import com.mayakapps.compose.windowstyler.ColorableWindowBackdrop
24 | import com.mayakapps.compose.windowstyler.WindowBackdrop
25 | import com.mayakapps.compose.windowstyler.WindowCornerPreference
26 | import com.mayakapps.compose.windowstyler.WindowFrameStyle
27 | import com.mayakapps.compose.windowstyler.WindowStyleManager
28 | import com.mayakapps.compose.windowstyler.hackContentPane
29 | import com.mayakapps.compose.windowstyler.isTransparent
30 | import com.mayakapps.compose.windowstyler.isUndecorated
31 | import com.mayakapps.compose.windowstyler.setComposeLayerTransparency
32 | import com.mayakapps.compose.windowstyler.windows.jna.Dwm
33 | import com.mayakapps.compose.windowstyler.windows.jna.enums.AccentFlag
34 | import com.mayakapps.compose.windowstyler.windows.jna.enums.AccentState
35 | import com.mayakapps.compose.windowstyler.windows.jna.enums.DwmSystemBackdrop
36 | import com.mayakapps.compose.windowstyler.windows.jna.enums.DwmWindowAttribute
37 | import com.sun.jna.platform.win32.WinDef.HWND
38 | import java.awt.Window
39 | import javax.swing.SwingUtilities
40 |
41 | /**
42 | * Windows implementation of [WindowStyleManager]. It is not recommended to use this class directly.
43 | *
44 | * If used on an OS other than Windows, it'll crash.
45 | */
46 | class WindowsWindowStyleManager(
47 | window: Window,
48 | isDarkTheme: Boolean = false,
49 | backdropType: WindowBackdrop = WindowBackdrop.Default,
50 | frameStyle: WindowFrameStyle = WindowFrameStyle(),
51 | ) : WindowStyleManager {
52 |
53 | private val hwnd: HWND = window.hwnd
54 | private val isUndecorated = window.isUndecorated
55 |
56 | private val backdropApis = WindowsBackdropApis(hwnd)
57 |
58 | override var isDarkTheme: Boolean = isDarkTheme
59 | set(value) {
60 | if (field != value) {
61 | field = value
62 | updateTheme()
63 | }
64 | }
65 |
66 | override var backdropType: WindowBackdrop = backdropType
67 | set(value) {
68 | val finalValue = value.fallbackIfUnsupported()
69 |
70 | if (field != finalValue) {
71 | field = finalValue
72 | updateBackdrop()
73 | }
74 | }
75 |
76 | override var frameStyle: WindowFrameStyle = frameStyle
77 | set(value) {
78 | if (field != value) {
79 | val oldValue = field
80 | field = value
81 | updateFrameStyle(oldValue)
82 | }
83 | }
84 |
85 | init {
86 | // invokeLater is called to make sure that ComposeLayer was initialized first
87 | SwingUtilities.invokeLater {
88 | // If the window is not already transparent, hack it to be transparent
89 | if (!window.isTransparent) {
90 | // For some reason, reversing the order of these two calls doesn't work.
91 | if (window is ComposeWindow) window.setComposeLayerTransparency(true)
92 | window.hackContentPane()
93 | }
94 |
95 | updateTheme()
96 | updateBackdrop()
97 | updateFrameStyle()
98 | }
99 | }
100 |
101 | private fun updateTheme() {
102 | val attribute = when {
103 | windowsBuild < 17763 -> return
104 | windowsBuild >= 18985 -> DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE
105 | else -> DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1
106 | }
107 |
108 | if (Dwm.setWindowAttribute(hwnd, attribute, isDarkTheme)) {
109 | // Default: This is done to update the background color between white or black
110 | // ThemedAcrylic: Update the acrylic effect if it is themed
111 | // Transparent:
112 | // For some reason, using setImmersiveDarkModeEnabled after setting accent policy to transparent
113 | // results in solid red backdrop. So, we have to reset the transparent backdrop after using it.
114 | // This is also required for updating emulated transparent effect
115 | if (backdropType is WindowBackdrop.Default || backdropType is WindowBackdrop.Acrylic ||
116 | backdropType is WindowBackdrop.Transparent
117 | ) updateBackdrop()
118 | // This is necessary for window buttons to change color correctly
119 | else if (backdropType is WindowBackdrop.Mica && !isUndecorated) {
120 | backdropApis.isSheetOfGlassEffectEnabled = true
121 | }
122 | }
123 | }
124 |
125 | private fun updateBackdrop() {
126 | // This is done to make sure that the window has become visible
127 | // If the window isn't shown yet, and we try to apply Default, Solid, Aero,
128 | // or Acrylic, the effect will be applied to the title bar background
129 | // leaving the caption with awkward background box.
130 | // Unfortunately, even with this method, mica has this background box.
131 | SwingUtilities.invokeLater {
132 | if (windowsBuild >= 22523) {
133 | backdropApis.systemBackdrop = when (backdropType) {
134 | is WindowBackdrop.Mica -> DwmSystemBackdrop.DWMSBT_MAINWINDOW
135 | is WindowBackdrop.Acrylic -> DwmSystemBackdrop.DWMSBT_TRANSIENTWINDOW
136 | is WindowBackdrop.Tabbed -> DwmSystemBackdrop.DWMSBT_TABBEDWINDOW
137 | else -> DwmSystemBackdrop.DWMSBT_AUTO
138 | }
139 | } else if (windowsBuild >= 22000) {
140 | backdropApis.isMicaEffectEnabled = backdropType is WindowBackdrop.Mica
141 | }
142 |
143 | if (windowsBuild >= 22000 && frameStyle.titleBarColor.isUnspecified) {
144 | Dwm.setWindowAttribute(
145 | hwnd,
146 | DwmWindowAttribute.DWMWA_CAPTION_COLOR,
147 | when (backdropType) {
148 | WindowBackdrop.Default,
149 | is WindowBackdrop.Solid,
150 | is WindowBackdrop.Transparent,
151 | WindowBackdrop.Aero -> Color.Black.toBgr()
152 |
153 | is WindowBackdrop.Acrylic,
154 | is WindowBackdrop.Mica,
155 | WindowBackdrop.Tabbed -> 0xFFFFFFFE.toInt() // None
156 | },
157 | )
158 | }
159 |
160 | val color = when (val backdropType = backdropType) {
161 | // As the transparency hack is irreversible, the default effect is applied by solid backdrop.
162 | // The default color is white or black depending on the theme
163 | is WindowBackdrop.Default -> (if (isDarkTheme) Color.Black else Color.White).toAbgr()
164 | is WindowBackdrop.Transparent -> backdropType.color.toAbgrForTransparent()
165 | is ColorableWindowBackdrop -> backdropType.color.toAbgr()
166 | else -> 0x7FFFFFFF
167 | }
168 |
169 | backdropApis.setAccentPolicy(
170 | accentState = when (backdropType) {
171 | is WindowBackdrop.Default, is WindowBackdrop.Solid -> AccentState.ACCENT_ENABLE_GRADIENT
172 | is WindowBackdrop.Transparent -> AccentState.ACCENT_ENABLE_TRANSPARENTGRADIENT
173 | is WindowBackdrop.Aero -> AccentState.ACCENT_ENABLE_BLURBEHIND
174 | is WindowBackdrop.Acrylic -> when {
175 | windowsBuild >= 22523 -> AccentState.ACCENT_DISABLED
176 | else -> AccentState.ACCENT_ENABLE_ACRYLICBLURBEHIND
177 | }
178 |
179 | else -> AccentState.ACCENT_DISABLED
180 | },
181 | accentFlags = if (backdropType is WindowBackdrop.Transparent) {
182 | setOf(AccentFlag.FLAG_FOR_TRANSPARENCY, AccentFlag.DRAW_ALL_BORDERS)
183 | } else {
184 | setOf(AccentFlag.DRAW_ALL_BORDERS)
185 | },
186 | color = color,
187 | )
188 |
189 | if (windowsBuild >= 17063) {
190 | backdropApis.isSheetOfGlassEffectEnabled =
191 | backdropType is WindowBackdrop.Mica ||
192 | backdropType is WindowBackdrop.Tabbed ||
193 | backdropType is WindowBackdrop.Acrylic
194 | }
195 | }
196 | }
197 |
198 | /*
199 | * Frame Style
200 | */
201 |
202 | private fun updateFrameStyle(oldStyle: WindowFrameStyle? = null) {
203 | if (windowsBuild >= 22000) {
204 | if ((oldStyle?.cornerPreference
205 | ?: WindowCornerPreference.DEFAULT) != frameStyle.cornerPreference
206 | ) {
207 | Dwm.setWindowCornerPreference(
208 | hwnd,
209 | frameStyle.cornerPreference.toDwmWindowCornerPreference()
210 | )
211 | }
212 |
213 | if (frameStyle.borderColor.isSpecified && oldStyle?.borderColor != frameStyle.borderColor) {
214 | Dwm.setWindowAttribute(
215 | hwnd,
216 | DwmWindowAttribute.DWMWA_BORDER_COLOR,
217 | frameStyle.borderColor.toBgr()
218 | )
219 | }
220 |
221 | if (frameStyle.titleBarColor.isSpecified && oldStyle?.titleBarColor != frameStyle.titleBarColor) {
222 | Dwm.setWindowAttribute(
223 | hwnd,
224 | DwmWindowAttribute.DWMWA_CAPTION_COLOR,
225 | frameStyle.titleBarColor.toBgr()
226 | )
227 | }
228 |
229 | if (frameStyle.captionColor.isSpecified && oldStyle?.captionColor != frameStyle.captionColor) {
230 | Dwm.setWindowAttribute(
231 | hwnd,
232 | DwmWindowAttribute.DWMWA_TEXT_COLOR,
233 | frameStyle.captionColor.toBgr()
234 | )
235 | }
236 | }
237 | }
238 |
239 | /*
240 | * Fallback Strategy
241 | */
242 |
243 | private fun WindowBackdrop.fallbackIfUnsupported(): WindowBackdrop {
244 | if (windowsBuild >= supportedSince) return this
245 |
246 | return when (this) {
247 | is WindowBackdrop.Tabbed -> WindowBackdrop.Mica
248 | is WindowBackdrop.Mica -> themedAcrylic
249 | is WindowBackdrop.Acrylic -> WindowBackdrop.Transparent(color)
250 |
251 | else -> WindowBackdrop.Default
252 | }.fallbackIfUnsupported()
253 | }
254 |
255 | private val themedAcrylic
256 | get() = WindowBackdrop.Acrylic(themedFallbackColor)
257 |
258 | private val themedFallbackColor
259 | get() = if (isDarkTheme) Color(0xEF000000L) else Color(0xEFFFFFFFL)
260 |
261 | private val WindowBackdrop.supportedSince
262 | get() = when (this) {
263 | is WindowBackdrop.Acrylic -> 17063
264 | is WindowBackdrop.Mica -> 22000
265 | is WindowBackdrop.Tabbed -> 22523
266 | else -> 0
267 | }
268 | }
269 |
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/Dwm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna
18 |
19 | import com.mayakapps.compose.windowstyler.windows.jna.enums.DwmSystemBackdrop
20 | import com.mayakapps.compose.windowstyler.windows.jna.enums.DwmWindowAttribute
21 | import com.mayakapps.compose.windowstyler.windows.jna.enums.DwmWindowCornerPreference
22 | import com.mayakapps.compose.windowstyler.windows.jna.structs.Margins
23 | import com.sun.jna.Native
24 | import com.sun.jna.PointerType
25 | import com.sun.jna.platform.win32.W32Errors
26 | import com.sun.jna.platform.win32.WinDef
27 | import com.sun.jna.platform.win32.WinDef.HWND
28 | import com.sun.jna.platform.win32.WinNT.HRESULT
29 | import com.sun.jna.ptr.IntByReference
30 | import com.sun.jna.win32.StdCallLibrary
31 | import com.sun.jna.win32.W32APIOptions
32 |
33 | internal object Dwm {
34 | fun extendFrameIntoClientArea(hwnd: HWND, margin: Int = 0) =
35 | extendFrameIntoClientArea(hwnd, margin, margin, margin, margin)
36 |
37 | fun extendFrameIntoClientArea(
38 | hwnd: HWND,
39 | leftWidth: Int = 0,
40 | rightWidth: Int = 0,
41 | topHeight: Int = 0,
42 | bottomHeight: Int = 0,
43 | ): Boolean {
44 | val margins = Margins(leftWidth, rightWidth, topHeight, bottomHeight)
45 |
46 | val result = DwmImpl.DwmExtendFrameIntoClientArea(hwnd, margins)
47 | if (result != W32Errors.S_OK) println("DwmExtendFrameIntoClientArea failed with result $result")
48 |
49 | margins.dispose()
50 | return result == W32Errors.S_OK
51 | }
52 |
53 |
54 | fun setSystemBackdrop(hwnd: HWND, systemBackdrop: DwmSystemBackdrop): Boolean =
55 | setWindowAttribute(hwnd, DwmWindowAttribute.DWMWA_SYSTEMBACKDROP_TYPE, systemBackdrop.value)
56 |
57 | fun setWindowCornerPreference(hwnd: HWND, cornerPreference: DwmWindowCornerPreference): Boolean =
58 | setWindowAttribute(hwnd, DwmWindowAttribute.DWMWA_WINDOW_CORNER_PREFERENCE, cornerPreference.value)
59 |
60 | fun setWindowAttribute(hwnd: HWND, attribute: DwmWindowAttribute, value: Boolean) =
61 | setWindowAttribute(hwnd, attribute, WinDef.BOOLByReference(WinDef.BOOL(value)), WinDef.BOOL.SIZE)
62 |
63 | fun setWindowAttribute(hwnd: HWND, attribute: DwmWindowAttribute, value: Int) =
64 | setWindowAttribute(hwnd, attribute, IntByReference(value), INT_SIZE)
65 |
66 | private fun setWindowAttribute(
67 | hwnd: HWND,
68 | attribute: DwmWindowAttribute,
69 | value: PointerType?,
70 | valueSize: Int,
71 | ): Boolean {
72 | val result = DwmImpl.DwmSetWindowAttribute(hwnd, attribute.value, value, valueSize)
73 |
74 | if (result != W32Errors.S_OK) println("DwmSetWindowAttribute(${attribute.name}) failed with result $result")
75 | return result == W32Errors.S_OK
76 | }
77 | }
78 |
79 | @Suppress("SpellCheckingInspection")
80 | private object DwmImpl : DwmApi by Native.load("dwmapi", DwmApi::class.java, W32APIOptions.DEFAULT_OPTIONS)
81 |
82 | @Suppress("FunctionName")
83 | private interface DwmApi : StdCallLibrary {
84 | fun DwmExtendFrameIntoClientArea(hwnd: HWND, margins: Margins): HRESULT
85 | fun DwmSetWindowAttribute(hwnd: HWND, attribute: Int, value: PointerType?, valueSize: Int): HRESULT
86 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/Nt.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna
18 |
19 | import com.mayakapps.compose.windowstyler.windows.jna.structs.OsVersionInfo
20 | import com.sun.jna.Native
21 | import com.sun.jna.win32.StdCallLibrary
22 | import com.sun.jna.win32.W32APIOptions
23 |
24 | internal object Nt {
25 | fun getVersion() = OsVersionInfo().also { NtImpl.RtlGetVersion(it) }
26 | }
27 |
28 | @Suppress("SpellCheckingInspection")
29 | private object NtImpl : NtApi by Native.load("Ntdll", NtApi::class.java, W32APIOptions.DEFAULT_OPTIONS)
30 |
31 | @Suppress("FunctionName")
32 | private interface NtApi : StdCallLibrary {
33 | fun RtlGetVersion(osVersionInfo: OsVersionInfo): Int
34 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/User32.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna
18 |
19 | import com.mayakapps.compose.windowstyler.windows.jna.enums.AccentFlag
20 | import com.mayakapps.compose.windowstyler.windows.jna.enums.AccentState
21 | import com.mayakapps.compose.windowstyler.windows.jna.enums.WindowCompositionAttribute
22 | import com.mayakapps.compose.windowstyler.windows.jna.structs.AccentPolicy
23 | import com.mayakapps.compose.windowstyler.windows.jna.structs.WindowCompositionAttributeData
24 | import com.sun.jna.Native
25 | import com.sun.jna.platform.win32.WinDef
26 | import com.sun.jna.win32.StdCallLibrary
27 | import com.sun.jna.win32.W32APIOptions
28 |
29 | internal object User32 {
30 | fun setAccentPolicy(
31 | hwnd: WinDef.HWND,
32 | accentState: AccentState = AccentState.ACCENT_DISABLED,
33 | accentFlags: Set = emptySet(),
34 | color: Int = 0,
35 | animationId: Int = 0,
36 | ): Boolean {
37 | val data = WindowCompositionAttributeData(
38 | WindowCompositionAttribute.WCA_ACCENT_POLICY,
39 | AccentPolicy(accentState, accentFlags, color, animationId),
40 | )
41 |
42 | val isSuccess = setWindowCompositionAttribute(hwnd, data)
43 |
44 | data.dispose()
45 | return isSuccess
46 | }
47 |
48 | private fun setWindowCompositionAttribute(
49 | hwnd: WinDef.HWND,
50 | attributeData: WindowCompositionAttributeData
51 | ): Boolean {
52 | Native.setLastError(0)
53 |
54 | val isSuccess = User32Impl.SetWindowCompositionAttribute(hwnd, attributeData)
55 |
56 | if (!isSuccess) println("SetWindowCompositionAttribute(${attributeData.attribute}) failed with last error ${Native.getLastError()}")
57 | return isSuccess
58 | }
59 | }
60 |
61 | private object User32Impl : User32Api by Native.load("user32", User32Api::class.java, W32APIOptions.DEFAULT_OPTIONS)
62 |
63 | @Suppress("FunctionName")
64 | private interface User32Api : StdCallLibrary {
65 | fun SetWindowCompositionAttribute(hwnd: WinDef.HWND, attributeData: WindowCompositionAttributeData): Boolean
66 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/Utils.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna
18 |
19 | internal inline fun Iterable.orOf(selector: (T) -> Int): Int {
20 | var result = 0
21 | forEach { result = result or selector(it) }
22 | return result
23 | }
24 |
25 | internal const val INT_SIZE = 4
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/enums/AccentFlag.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna.enums
18 |
19 | @Suppress("unused")
20 | internal enum class AccentFlag(val value: Int) {
21 | NONE(0),
22 | FLAG_FOR_TRANSPARENCY(0x02),
23 | DRAW_LEFT_BORDER(0x20),
24 | DRAW_TOP_BORDER(0x40),
25 | DRAW_RIGHT_BORDER(0x80),
26 | DRAW_BOTTOM_BORDER(0x100),
27 | DRAW_ALL_BORDERS(0x1E0), // OR result of all borders
28 | }
29 |
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/enums/AccentState.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna.enums
18 |
19 | @Suppress("SpellCheckingInspection", "unused")
20 | internal enum class AccentState(val value: Int) {
21 | ACCENT_DISABLED(0),
22 | ACCENT_ENABLE_GRADIENT(1),
23 | ACCENT_ENABLE_TRANSPARENTGRADIENT(2),
24 | ACCENT_ENABLE_BLURBEHIND(3),
25 | ACCENT_ENABLE_ACRYLICBLURBEHIND(4),
26 | ACCENT_ENABLE_HOSTBACKDROP(5),
27 | ACCENT_INVALID_STATE(6),
28 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/enums/DwmSystemBackdrop.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna.enums
18 |
19 | @Suppress("SpellCheckingInspection", "unused")
20 | internal enum class DwmSystemBackdrop(val value: Int) {
21 | DWMSBT_AUTO(0),
22 | DWMSBT_DISABLE(1), // None
23 | DWMSBT_MAINWINDOW(2), // Mica
24 | DWMSBT_TRANSIENTWINDOW(3), // Acrylic
25 | DWMSBT_TABBEDWINDOW(4), // Tabbed
26 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/enums/DwmWindowAttribute.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna.enums
18 |
19 | @Suppress("SpellCheckingInspection", "unused")
20 | internal enum class DwmWindowAttribute(val value: Int) {
21 | DWMWA_NCRENDERING_ENABLED(0),
22 | DWMWA_NCRENDERING_POLICY(1),
23 | DWMWA_TRANSITIONS_FORCEDISABLED(2),
24 | DWMWA_ALLOW_NCPAINT(3),
25 | DWMWA_CAPTION_BUTTON_BOUNDS(4),
26 | DWMWA_NONCLIENT_RTL_LAYOUT(5),
27 | DWMWA_FORCE_ICONIC_REPRESENTATION(6),
28 | DWMWA_FLIP3D_POLICY(7),
29 | DWMWA_EXTENDED_FRAME_BOUNDS(8),
30 | DWMWA_HAS_ICONIC_BITMAP(9),
31 | DWMWA_DISALLOW_PEEK(10),
32 | DWMWA_EXCLUDED_FROM_PEEK(11),
33 | DWMWA_CLOAK(12),
34 | DWMWA_CLOAKED(13),
35 | DWMWA_FREEZE_REPRESENTATION(14),
36 | DWMWA_PASSIVE_UPDATE_MODE(15),
37 | DWMWA_USE_HOSTBACKDROPBRUSH(16),
38 | DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1(19),
39 | DWMWA_USE_IMMERSIVE_DARK_MODE(20),
40 | DWMWA_WINDOW_CORNER_PREFERENCE(33),
41 | DWMWA_BORDER_COLOR(34),
42 | DWMWA_CAPTION_COLOR(35),
43 | DWMWA_TEXT_COLOR(36),
44 | DWMWA_VISIBLE_FRAME_BORDER_THICKNESS(37),
45 | DWMWA_SYSTEMBACKDROP_TYPE(38),
46 | DWMWA_LAST(39),
47 | DWMWA_MICA_EFFECT(1029),
48 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/enums/DwmWindowCornerPreference.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna.enums
18 |
19 | @Suppress("SpellCheckingInspection", "unused")
20 | internal enum class DwmWindowCornerPreference(val value: Int) {
21 | DWMWCP_DEFAULT(0),
22 | DWMWCP_DONOTROUND(1),
23 | DWMWCP_ROUND(2),
24 | DWMWCP_ROUNDSMALL(3),
25 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/enums/WindowCompositionAttribute.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna.enums
18 |
19 | @Suppress("SpellCheckingInspection", "unused")
20 | internal enum class WindowCompositionAttribute(val value: Int) {
21 | WCA_UNDEFINED(0),
22 | WCA_NCRENDERING_ENABLED(1),
23 | WCA_NCRENDERING_POLICY(2),
24 | WCA_TRANSITIONS_FORCEDISABLED(3),
25 | WCA_ALLOW_NCPAINT(4),
26 | WCA_CAPTION_BUTTON_BOUNDS(5),
27 | WCA_NONCLIENT_RTL_LAYOUT(6),
28 | WCA_FORCE_ICONIC_REPRESENTATION(7),
29 | WCA_EXTENDED_FRAME_BOUNDS(8),
30 | WCA_HAS_ICONIC_BITMAP(9),
31 | WCA_THEME_ATTRIBUTES(10),
32 | WCA_NCRENDERING_EXILED(11),
33 | WCA_NCADORNMENTINFO(12),
34 | WCA_EXCLUDED_FROM_LIVEPREVIEW(13),
35 | WCA_VIDEO_OVERLAY_ACTIVE(14),
36 | WCA_FORCE_ACTIVEWINDOW_APPEARANCE(15),
37 | WCA_DISALLOW_PEEK(16),
38 | WCA_CLOAK(17),
39 | WCA_CLOAKED(18),
40 | WCA_ACCENT_POLICY(19),
41 | WCA_FREEZE_REPRESENTATION(20),
42 | WCA_EVER_UNCLOAKED(21),
43 | WCA_VISUAL_OWNER(22),
44 | WCA_HOLOGRAPHIC(23),
45 | WCA_EXCLUDED_FROM_DDA(24),
46 | WCA_PASSIVEUPDATEMODE(25),
47 | WCA_USEDARKMODECOLORS(26),
48 | WCA_LAST(27),
49 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/structs/AccentPolicy.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna.structs
18 |
19 | import com.mayakapps.compose.windowstyler.windows.jna.enums.AccentFlag
20 | import com.mayakapps.compose.windowstyler.windows.jna.enums.AccentState
21 | import com.mayakapps.compose.windowstyler.windows.jna.orOf
22 | import com.sun.jna.Structure.FieldOrder
23 |
24 | @Suppress("unused")
25 | @FieldOrder(
26 | "accentState",
27 | "accentFlags",
28 | "color",
29 | "animationId",
30 | )
31 | internal class AccentPolicy(
32 | accentState: AccentState = AccentState.ACCENT_DISABLED,
33 | accentFlags: Set = emptySet(),
34 | @JvmField var color: Int = 0,
35 | @JvmField var animationId: Int = 0,
36 | ) : BaseStructure() {
37 |
38 | @JvmField
39 | var accentState: Int = accentState.value
40 |
41 | @JvmField
42 | var accentFlags: Int = accentFlags.orOf { it.value }
43 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/structs/BaseStructure.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna.structs
18 |
19 | import com.sun.jna.Structure
20 |
21 | internal open class BaseStructure : Structure(), Structure.ByReference {
22 | open fun dispose() = clear()
23 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/structs/Margins.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna.structs
18 |
19 | import com.sun.jna.Structure
20 |
21 | @Structure.FieldOrder(
22 | "leftWidth",
23 | "rightWidth",
24 | "topHeight",
25 | "bottomHeight",
26 | )
27 | internal data class Margins(
28 | @JvmField var leftWidth: Int = 0,
29 | @JvmField var rightWidth: Int = 0,
30 | @JvmField var topHeight: Int = 0,
31 | @JvmField var bottomHeight: Int = 0,
32 | ) : BaseStructure()
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/structs/OsVersionInfo.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna.structs
18 |
19 | import com.sun.jna.Pointer
20 | import com.sun.jna.Structure.FieldOrder
21 | import com.sun.jna.platform.win32.WinDef.ULONG
22 |
23 | @Suppress("unused")
24 | @FieldOrder(
25 | "osVersionInfoSize",
26 | "majorVersion",
27 | "minorVersion",
28 | "buildNumber",
29 | "platformId",
30 | "csdVersion",
31 | )
32 | internal class OsVersionInfo(
33 | @JvmField var majorVersion: Int = 0,
34 | @JvmField var minorVersion: Int = 0,
35 | @JvmField var buildNumber: Int = 0,
36 | @JvmField var platformId: Int = 0,
37 | ) : BaseStructure() {
38 |
39 | @JvmField
40 | var osVersionInfoSize: Int = (ULONG.SIZE * 5) + 4
41 |
42 | @JvmField
43 | var csdVersion: Pointer? = null
44 | }
--------------------------------------------------------------------------------
/window-styler/src/jvmMain/kotlin/com/mayakapps/compose/windowstyler/windows/jna/structs/WindowCompositionAttributeData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2025 MayakaApps
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mayakapps.compose.windowstyler.windows.jna.structs
18 |
19 | import com.mayakapps.compose.windowstyler.windows.jna.enums.WindowCompositionAttribute
20 | import com.sun.jna.Structure.FieldOrder
21 |
22 | @Suppress("unused")
23 | @FieldOrder(
24 | "attribute",
25 | "data",
26 | "sizeOfData",
27 | )
28 | internal class WindowCompositionAttributeData(
29 | attribute: WindowCompositionAttribute = WindowCompositionAttribute.WCA_UNDEFINED,
30 | @JvmField var data: AccentPolicy = AccentPolicy(),
31 | ) : BaseStructure() {
32 |
33 | @JvmField
34 | var attribute: Int = attribute.value
35 |
36 | @JvmField
37 | var sizeOfData: Int = data.size()
38 |
39 | override fun dispose() {
40 | data.dispose()
41 | super.dispose()
42 | }
43 | }
--------------------------------------------------------------------------------