Giter Site home page Giter Site logo

window-shadows's Introduction

Warning

ARCHIVE NOTICE

This crate is Unmaintained! it served its purpose which was an interim solution to enable shadows on undecorated windows for tao and tauri.

As of tauri@v2 and recent versions of tao and winit, they all support enablind/disabling shadows so this crate is not needed.

If you're using tauri@v1 and need this crate, don't worry, this crate will still function with tauri@v1 without any problems.

window-shadows

Chat Server

Add native shadows to your windows.

Platform-specific

  • Windows: On Windows 11, the window will also have rounded corners.
  • macOS: Shadows are always disabled for transparent windows.
  • Linux: Unsupported, Shadows are controlled by the compositor installed on the end-user system.

Example

use window_shadows::set_shadow;

#[cfg(any(windows, target_os = "macos"))]
set_shadow(&window, true).unwrap();

Screenshots

Windows macOS
Windows screenshot macOS screenshot

window-shadows's People

Contributors

amrbashir avatar fabianlars avatar github-actions[bot] avatar jonaskruckenberg avatar lucasfernog avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

window-shadows's Issues

Shadow working in dev but not work in build.

Everything is ok when I in dev environment. But after I install the bundle, shadow can not work.
I tried to debug the build, there's no any error. I don't know what's wrong.

Any helps, thank u.

fn main() {
    tauri::Builder::default()
        .setup(|app| {
            #[cfg(debug_assertions)] // only include this code on debug builds
            {
                let window = app.get_window("main").unwrap();
                window
                    .set_size(Size::Logical(LogicalSize {
                        width: 600.0,
                        height: 800.0,
                    }))
                    .unwrap();
                set_shadow(&window, true).expect("Unsupported platform!");
                window.open_devtools();
                window.close_devtools();
            }
            Ok(())
        })
        .plugin(tauri_plugin_store::Builder::default().build())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

No Shadows on Linux running under Wayland

When running GNOME under Xorg I get shadows as expected, but when running GNOME under Wayland I don't. I understand that Wayland only supports client side decorations, so some support in Tauri is probably required. Googling around I see various references to _GTK_FRAME_EXTENTS, which supposedly enables Windows to extend their drawable area to include an additional border for shadows, but presumably something still needs to actually draw a shadow in that region..

Example code doesn't seem to work

Adding the example code to the main.rs file and adding the crate to the Cargo.toml file ends with this error while running the tauri dev command.

 set_shadow(&window, true).unwrap();
           ^ expected one of `!` or `::`

Am I missing something or is something wrong with the way I installed it?

1px white edge appears when enable shadow

image

When these lines are commented, it works well.

image

And enable shadow, and focus the window, 1px white edge appears on the right and bottom of window.

image

image

  • This issue only happens when the backgound-color has opacity setting, pure color is fine.
  • Only happends when window is focused
  • I haven't set any 1px border to it.

Could not find native static library `WebView2LoaderStatic`

Hi, after adding tauri-plugin-shadows as dependencies, my app rebuild and i get this error

image

Operating System - Windows, version 10.0.19042 X64

Node.js environment
  Node.js - 14.17.0
  @tauri-apps/cli - 1.0.0-beta.10

Global packages
  npm - 6.14.13
  yarn - 1.22.17

Rust environment
  rustc - 1.58.0
  cargo - 1.58.0

Thank you for your help

the trait `raw_window_handle::HasRawWindowHandle` is not implemented for `Window`

error[E0277]: the trait bound `Window: raw_window_handle::HasRawWindowHandle` is not satisfied
   --> src\main.rs:13:24
    |
13  |             set_shadow(&window, true).expect("Unsupported platform!");
    |             ---------- ^^^^^^^ the trait `raw_window_handle::HasRawWindowHandle` is not implemented for `Window`
    |             |
    |             required by a bound introduced by this call
    |
help: trait impl with same name found
   --> C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\tauri-1.0.2\src\window.rs:492:1
    |
492 | / unsafe impl<R: Runtime> raw_window_handle::HasRawWindowHandle for Window<R> {
493 | |   fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle {
494 | |     self.window.dispatcher.raw_window_handle().unwrap()
495 | |   }
496 | | }
    | |_^
    = note: perhaps two different versions of crate `raw_window_handle` are being used?
    = help: the trait `raw_window_handle::HasRawWindowHandle` is implemented for `&'a T`
    = note: required because of the requirements on the impl of `raw_window_handle::HasRawWindowHandle` for `&Window`
note: required by a bound in `set_shadow`
   --> C:\Users\User\.cargo\git\checkouts\window-shadows-e91032ebb014230a\af1010a\src\lib.rs:30:16
    |
30  |   window: impl raw_window_handle::HasRawWindowHandle,
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `set_shadow`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `app` due to previous error

Use .ok() instead of .expect(...) for better cross platform compatability

By following the usage instructions, an app will fail to run on an unsupported platform. For example, I'm testing out my template on Manjaro and the AppImage fails to run because of the set shadows fails. Who care if set shadows is not supported on a particular OS, it's a decoration not a functional necessity!

I suggest removing the .expect in place of ok

Multi window use

How can I also set the shadow on a window that I open via javascript?

I open in window like this:

const webview = new WebviewWindow(`${Date.now()}`, {
	title: 'New Window',
	url: '/',
	decorations: false
});
webview.once('tauri://created', function () {
	console.log('created');
});
webview.once('tauri://error', function (e) {
	console.log('error', e);
});

Unused import

Following the previous issue i get this one:

image

Also Cargo notice this error:

image

My main.rs file look like this:

#![cfg_attr(
  all(not(debug_assertions), target_os = "windows"),
  windows_subsystem = "windows"
)]

use tauri::Manager;
use tauri_plugin_shadows::Shadows;

fn main() {
  tauri::Builder::default()
    .setup(|app| {
      let window = app.get_window("main").unwrap();
      //use tauri_plugin_shadows::Shadows;
      window.set_shadow(true);
      Ok(())
    })
    .run(tauri::generate_context!())
    .expect("error while running tauri application");

Thank you very much for your help

Originally posted by @skarab42 in #3 (comment)

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Repository problems

These problems occurred while renovating this repository.

  • WARN: App has not been granted permissions to update Workflows - aborting branch.

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • Update actions/checkout action to v3

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.


  • Check this box to trigger a request for Renovate to run again on this repository

set shadow to a new window

main.rs

fn open_window(handle: tauri::AppHandle) {
  tauri::WindowBuilder::new(
    &handle, "label", tauri::WindowUrl::App("/path".into())
  ).inner_size(width, height).build().unwrap();
}

and i called it in js

import { invoke } from "@tauri-apps/api/tauri";

invoke("open_window")

how could i set shadow to this new window

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.