Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows: add builder method to make a tool window #2719

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lunixbochs
Copy link
Contributor

@lunixbochs lunixbochs commented Mar 6, 2023

  • Tested on all platforms changed
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

This adds the ability to make a window with the style WS_EX_TOOLWINDOW. This is the missing piece to be able to create borderless/transparent desktop overlay windows with winit that don't show up in the taskbar, don't animate on open/close, etc.

You can build a cross-platform window in this style like the following (I don't target Wayland so I don't have a Wayland example):

let builder = winit::window::WindowBuilder::new()
    .with_transparent(true)
    .with_decorations(false)
    .with_resizable(false)
    .with_title("Canvas");

#[cfg(target_os = "linux")]
let builder = builder
    .with_x11_window_type(vec![XWindowType::Utility])
    .with_override_redirect(true);
#[cfg(target_os = "windows")]
let builder = builder.with_tool_window(true);
#[cfg(target_os = "macos")]
let builder = builder.with_has_shadow(false);

(Anyone drawing a transparent window over the whole screen probably also cares about window.set_cursor_hittest(false) so they can click through it, which is why I just PR'd support for that on X11)

@lunixbochs lunixbochs requested a review from msiglreith as a code owner March 6, 2023 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants