Skip to content

Commit

Permalink
missing pieces after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Oct 23, 2024
1 parent 33e8eec commit 45c5404
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changes/window-class-name-config-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tauri-apps/api": 'minor:feat'
---

Added `windowClassname` option, when constructing a `Webview` or `WebviewWindow`, to specify the name of the window class on Windows.
6 changes: 6 additions & 0 deletions .changes/window-class-name-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri": 'minor:feat'
"tauri-utils": 'minor:feat'
---

Added `app > windows > windowClassname` config option to specify the name of the window class on Windows.
3 changes: 1 addition & 2 deletions .changes/window-class-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"tauri": 'minor:feat'
"tauri-runtime-wry": 'minor:feat'
"tauri-runtime": 'minor:feat'
"tauri-utils": 'minor:feat'
---

Added the `window_classname` configuration option to `WindowBuilder`, `Window`, and `WindowConfig`. In order to set the name of the window class on Windows.
Added `WindowBuilder/WebviewWindowBuilder::window_classname` method to specify the name of the window class on Windows.
7 changes: 7 additions & 0 deletions crates/tauri-cli/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,13 @@
"default": false,
"type": "boolean"
},
"windowClassname": {
"description": "The name of the window class created on Windows to create the window. **Windows only**.",
"type": [
"string",
"null"
]
},
"theme": {
"description": "The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.",
"anyOf": [
Expand Down
17 changes: 17 additions & 0 deletions crates/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,11 @@ impl WindowBuilder for WindowBuilderWrapper {
builder = builder.title_bar_style(TitleBarStyle::Visible);
}

#[cfg(windows)]
{
builder = builder.window_classname("Tauri Window");
}

builder
}

Expand Down Expand Up @@ -828,6 +833,10 @@ impl WindowBuilder for WindowBuilderWrapper {
if config.center {
window = window.center();
}

if let Some(window_classname) = &config.window_classname {
window = window.window_classname(window_classname);
}
}

window
Expand Down Expand Up @@ -1088,6 +1097,14 @@ impl WindowBuilder for WindowBuilderWrapper {
_ => Theme::Light,
})
}

fn window_classname<S: Into<String>>(mut self, _window_classname: S) -> Self {
#[cfg(windows)]
{
self.inner = self.inner.with_window_classname(_window_classname);
}
self
}
}

#[cfg(any(
Expand Down
4 changes: 4 additions & 0 deletions crates/tauri-runtime/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ pub trait WindowBuilder: WindowBuilderBase {
fn has_icon(&self) -> bool;

fn get_theme(&self) -> Option<Theme>;

/// Sets custom name for Windows' window class. **Windows only**.
#[must_use]
fn window_classname<S: Into<String>>(self, window_classname: S) -> Self;
}

/// A window that has yet to be built.
Expand Down
7 changes: 7 additions & 0 deletions crates/tauri-schema-generator/schemas/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,13 @@
"default": false,
"type": "boolean"
},
"windowClassname": {
"description": "The name of the window class created on Windows to create the window. **Windows only**.",
"type": [
"string",
"null"
]
},
"theme": {
"description": "The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.",
"anyOf": [
Expand Down
13 changes: 4 additions & 9 deletions crates/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1396,9 +1396,8 @@ pub struct WindowConfig {
/// If `true`, hides the window icon from the taskbar on Windows and Linux.
#[serde(default, alias = "skip-taskbar")]
pub skip_taskbar: bool,
/// The name of the window class created on Windows to create the window.
#[serde(default = "default_window_classname")]
pub window_classname: String,
/// The name of the window class created on Windows to create the window. **Windows only**.
pub window_classname: Option<String>,
/// The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.
pub theme: Option<crate::Theme>,
/// The style of the macOS title bar.
Expand Down Expand Up @@ -1524,7 +1523,7 @@ impl Default for WindowConfig {
visible_on_all_workspaces: false,
content_protected: false,
skip_taskbar: false,
window_classname: default_window_classname(),
window_classname: None,
theme: None,
title_bar_style: Default::default(),
hidden_title: false,
Expand Down Expand Up @@ -1558,10 +1557,6 @@ fn default_title() -> String {
"Tauri App".to_string()
}

fn default_window_classname() -> String {
"Window Class".to_string()
}

/// A Content-Security-Policy directive source list.
/// See <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/Sources#sources>.
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
Expand Down Expand Up @@ -2501,7 +2496,7 @@ mod build {
let visible_on_all_workspaces = self.visible_on_all_workspaces;
let content_protected = self.content_protected;
let skip_taskbar = self.skip_taskbar;
let window_classname = str_lit(&self.window_classname);
let window_classname = opt_str_lit(self.window_classname.as_ref());
let theme = opt_lit(self.theme.as_ref());
let title_bar_style = &self.title_bar_style;
let hidden_title = self.hidden_title;
Expand Down
7 changes: 7 additions & 0 deletions crates/tauri/src/webview/webview_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,13 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
self
}

/// Sets custom name for Windows' window class. **Windows only**.
#[must_use]
pub fn window_classname<S: Into<String>>(mut self, classname: S) -> Self {
self.window_builder = self.window_builder.window_classname(classname);
self
}

/// Sets whether or not the window has shadow.
///
/// ## Platform-specific
Expand Down
7 changes: 7 additions & 0 deletions crates/tauri/src/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,13 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
self
}

/// Sets custom name for Windows' window class. **Windows only**.
#[must_use]
pub fn window_classname<S: Into<String>>(mut self, classname: S) -> Self {
self.window_builder = self.window_builder.window_classname(classname);
self
}

/// Sets whether or not the window has shadow.
///
/// ## Platform-specific
Expand Down

0 comments on commit 45c5404

Please sign in to comment.