| Crates.io | tauri-winutils |
| lib.rs | tauri-winutils |
| version | 0.1.6 |
| created_at | 2025-07-19 17:00:30.783066+00 |
| updated_at | 2025-07-22 16:23:00.836494+00 |
| description | A cross-platform window manager crate for Tauri applications |
| homepage | https://github.com/Pranav6000/TauriWinUtils |
| repository | https://github.com/Pranav6000/TauriWinUtils |
| max_upload_size | |
| id | 1760395 |
| size | 199,290 |
A cross-platform window manager crate for Tauri applications that provides workspace management, window tiling, and layout control.
Add this to your Cargo.toml:
[dependencies]
tauri-winutils-crate = "0.1.0"
use tauri_winutils_crate;
fn main() {
tauri::Builder::default()
.plugin(tauri_winutils_crate::init_window_manager())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
use tauri_winutils_crate::setup_window_manager;
fn main() {
let app = tauri::Builder::default();
setup_window_manager!(app)
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
import { invoke } from '@tauri-apps/api/tauri';
// Get all system windows
const systemWindows = await invoke('get_system_windows');
// Move a window
await invoke('move_system_window', { handle: windowHandle, x: 100, y: 100 });
// Resize a window
await invoke('resize_system_window', { handle: windowHandle, width: 800, height: 600 });
// Minimize/maximize/restore
await invoke('minimize_system_window', { handle: windowHandle });
await invoke('maximize_system_window', { handle: windowHandle });
await invoke('restore_system_window', { handle: windowHandle });
// Close a window
await invoke('close_system_window', { handle: windowHandle });
// Focus a window
await invoke('focus_system_window', { handle: windowHandle });
// Arrange multiple windows in a tiling layout
await invoke('arrange_system_windows', { windowHandles: [handle1, handle2, handle3] });
// Create a new workspace
const workspaceId = await invoke('create_workspace', {
name: 'Development',
layout: 'tiling'
});
// Switch to a workspace
await invoke('switch_workspace', { workspaceId });
// Add a window to management
const windowId = await invoke('add_window_to_manager', {
title: 'My App',
app_name: 'my-app'
});
// Arrange windows in current workspace
await invoke('arrange_windows', { workspaceId });
get_system_windows() - Get all system windowsmove_system_window(handle, x, y) - Move a windowresize_system_window(handle, width, height) - Resize a windowset_system_window_bounds(handle, x, y, width, height) - Set position and sizeminimize_system_window(handle) - Minimize a windowmaximize_system_window(handle) - Maximize a windowrestore_system_window(handle) - Restore a windowclose_system_window(handle) - Close a windowfocus_system_window(handle) - Focus a windowhide_system_window(handle) - Hide a windowshow_system_window(handle) - Show a windowarrange_system_windows(handles) - Arrange multiple windows in a tiling layoutadd_window_to_manager(title, app_name) - Add a window to managementremove_window_from_manager(window_id) - Remove a windowclose_window(window_id) - Close a windowminimize_window(window_id) - Minimize a windowmaximize_window(window_id) - Maximize a windowfocus_window(window_id) - Focus a windowget_workspaces() - Get all workspacescreate_workspace(name, layout) - Create a new workspaceswitch_workspace(workspace_id) - Switch to a workspacearrange_windows(workspace_id) - Arrange windows in a workspaceget_config() - Get current configurationupdate_config(config) - Update configurationuse tauri_winutils_crate::Config;
let config = Config {
window_gap: 10,
screen_width: 1920,
screen_height: 1080,
auto_arrange: true,
focus_follows_mouse: false,
border_width: 2,
border_color_active: "#0066cc".to_string(),
border_color_inactive: "#666666".to_string(),
// ... keybindings
};
use tauri_winutils_crate::{get_window_manager, WindowManager};
#[tauri::command]
fn my_custom_command(app_handle: tauri::AppHandle) -> Result<Vec<String>, String> {
if let Some(wm) = get_window_manager(&app_handle) {
let system_windows = wm.get_system_windows()?;
let titles: Vec<String> = system_windows.iter().map(|w| w.title.clone()).collect();
Ok(titles)
} else {
Err("Window manager not initialized".to_string())
}
}
use tauri_winutils_crate::{WindowManager, SystemWindow};
// In your Tauri command
#[tauri::command]
fn tile_all_windows(wm: tauri::State<WindowManager>) -> Result<(), String> {
let system_windows = wm.get_system_windows()?;
let handles: Vec<u64> = system_windows.iter().map(|w| w.handle).collect();
wm.arrange_system_windows(&handles)?;
Ok(())
}
See the examples/ directory for complete example applications that demonstrate:
MIT License - see LICENSE file for details.