clearlysid / tauri-plugin-decorum

Opinionated window decorations for Tauri apps
https://crates.io/crates/tauri-plugin-decorum
MIT License
154 stars 10 forks source link

Having some issues getting started #19

Closed kareemmahlees closed 2 months ago

kareemmahlees commented 3 months ago

Hi! I have been searching for a while on how to make my tauri windows look a little cooler, and this plugin will probably do the trick for me πŸ‘πŸ» . However, I am having trouble getting the plugin to work as expected, it's probably a silly mistake from me and I will be happy if you can point me to it!

Here is what my window looks like: image I can move and resize the window, but as you can see there are no controls! Here is my setup function in main.rs:

  let app_handle = app.app_handle();
  let main_window = app.get_webview_window("main").unwrap();
  let rt = tokio::runtime::Runtime::new().unwrap();
  let _settings = load_settings_file(app_handle.clone())?;

  ensure_config_files_exist(app_handle)?;
  builder.mount_events(app);

  rt.block_on(cli::handle_cli_args(app_handle, args, cmd));

  // Create a custom titlebar for main window
  // On Windows this hides decoration and creates custom window controls
  // On macOS it needs hiddenTitle: true and titleBarStyle: overlay
  main_window.create_overlay_titlebar().unwrap();

Here are my capabilities:

// main.json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-capability",
  "description": "Capability for the main window",
  "windows": [
    "main"
  ],
  "permissions": [
    "shell:allow-open",
    "core:app:allow-version",
    "core:event:allow-listen",
    "core:event:allow-unlisten",
    "core:event:allow-emit",
    "dialog:allow-open",
    "updater:allow-check",
    "clipboard-manager:allow-write-text",
    "core:window:allow-close",
    "core:window:allow-center",
    "core:window:allow-minimize",
    "core:window:allow-maximize",
    "core:window:allow-set-size",
    "core:window:allow-set-focus",
    "core:window:allow-start-dragging",
    "decorum:allow-show-snap-overlay",
    {
      "identifier":"fs:allow-read-file",
      "allow": [{"path": "*/*.(db|db3|s3db|sl3|sqlite|sqlite3)"}]
    },
    {
     "identifier": "fs:allow-read-text-file",
      "allow": [{ "path": "$APPDATA/*.json" }]
    }
  ]
}

And here is my tauri.conf.json:

// snip
  "app": {
    "windows": [
      {
        "fullscreen": false,
        "height": 600,
        "resizable": true,
        "title": "TableX",
        "width": 800,
        "center": true,
        "visible": false,
        "titleBarStyle": "Overlay"
      },
      {
        "width": 600,
        "height": 350,
        "decorations": false,
        "url": "splashscreen.html",
        "label": "splashscreen",
        "center": true,
        "visible": false
      }
    ],
    "security": {
      "csp": null,
      "capabilities": ["main-capability"]
    }
  }

P.S.: I am only interested in Windows at the moment.

Environment info

Platform: Windows 11 Tauri version: 2.0.0-rc.0 tauri-plugin-decorum version: 1.0.0

clearlysid commented 3 months ago

Sorry about the issue. Can you check the browser console of this Window and share if there are any errors there? That will help me debug this better.

clearlysid commented 3 months ago

Usually the buttons not showing up is a result of either:

  1. Permissions not being correctly granted
  2. CSS being overriden from somewhere / not getting applied correctly.

Both should be debug-able from the frontend in most cases.

kareemmahlees commented 2 months ago

Can you check the browser console of this Window and share if there are any errors there

Sorry, I didn't notice that, It did complain about withGlobalTauri not being enabled ( this should be documented tbh ).

Although window controls are now displayed, it is in triplets πŸ˜…: image

Btw, this is the codebase I am trying to integrate the plugin into.

clearlysid commented 2 months ago

Ah good catch. I will add the withGlobalTauri requirement in the README, thank you!

About the triplets: I'm able to reproduce it on my end too! Something must've changed in Tauri's event mechanism. Will debug this tonight and see if I can work out a fix, thanks for reporting!

kareemmahlees commented 2 months ago

Speaking about documentation, there are two missing permissions "core:window:allow-is-maximized" and "core:window:allow-toggle-maximize"

clearlysid commented 2 months ago

Strange that I can't replicate the triplets issue in the example app but I can in my own other apps. Will have to look deeper here.

Will close this issue and making a fresh one for the triplets.

clearlysid commented 2 months ago

Closing in favour of #22