tauri: Problems with window customization's rounded corners and shadows

Describe the bug

Because tauri does not support the extension of native windows, I have to manually implement custom windows. I tried to simulate macos’ window implementation and expand on it, such as menus, tabs, and titles. I implemented some basic functions through the tauri-controls library, but there are still some issues.

1. Incomplete implementation of rounded corners

To support rounded corners, I made some settings:

"windows": [
      {
        "title": "myapp",
        "shadow": true,
        "width": 1000,
        "height": 700,
        "fullscreen": false,
        "center": true,
        "transparent": true,
        "decorations": false,
        "resizable": true
      }
 ],

and then (styles.css):

:root {
    border-radius: 12px;
    ...
}
body{
    background: #fff;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

The final effect: 11111

Obviously, the corners on the top left and top right are not rounded. The background seems to be transparent, but it still has a border that affects the implementation of rounded corners. How can I fix it?

2. Shadow enhancement

I want to make some modifications to the shadow to enhance it. How can I do that? 2222

About tauri v2, I hope the official can provide a complete case of customizing windows, including simulating native windows, as well as customizing menus, tabs, titles, and other features.

Reproduction

No response

Expected behavior

No response

Full tauri info output

nothing

Stack trace

No response

Additional context

system: macOS monterey version: 12.6 tauri version:

tauri = { version = "2.0.0-beta.13", features = ["macos-private-api"] }
tauri-plugin-os = "2.0.0-beta.3"
tauri-plugin-shell = "2.0.0-beta.3"
{
   "@tauri-apps/api": "v2.0.0-beta.6",
    "@tauri-apps/plugin-os": "2.0.0-beta.2",
    "@tauri-apps/cli": "2.0.0-beta.11"
}

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 15
  • Comments: 18

Most upvoted comments

"app": {
    "macOSPrivateApi": true,
    "windows": [
      {
        "fullscreen": false,
        "height": 800,
        "resizable": false,
        "title": "Pavo",
        "width": 380,
        "visible": false,
        "decorations": false,
        "transparent": true
      }
    ],
    "withGlobalTauri": true,
    "security": {
      "csp": null
    }
  }

the key is macOSPrivateApi: true

image

Just to note… I’d be weary relying on these MacOS private APIs. Have used these in the past for some graphics things and they change frequently without apologies. They are unstable and undocumented in many cases. Also, I don’t believe you can deploy things to the Mac App store that leverage private MacOS APIs due to their instability.

@DragorWW @zhanglun

You’re absolutely right. However, since my app isn’t intended for the App Store, I’ve decided to go ahead and use them.

“app”: { “macOSPrivateApi”: true, } the key is macOSPrivateApi: true

@zhanglun thanks, this work for me in v2