Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ lerna-debug.log*
node_modules
dist
dist-ssr
vm-dist/
*.local

# Editor directories and files
Expand All @@ -27,4 +28,4 @@ target/rust-analyzer

2

windisplay.key
windisplay.key
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [0.3.21] - 2026-05-30

- [#18](https://github.com/zpix1/windisplay/pull/18) Improve tray responsiveness, expose an option to hide controls when the window loses focus, and disable brightness controls while HDR is enabled by @Cesarsk

## [0.3.20] - 2026-04-02

- [#16](https://github.com/zpix1/windisplay/pull/16) Improve brightness responsiveness and add theme toggle by @Cesarsk
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "windisplay",
"private": true,
"version": "0.3.20",
"version": "0.3.21",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "WinDisplay"
version = "0.3.20"
version = "0.3.21"
description = "Like BetterDisplay, but for Windows. Change resolution and refresh rate of your monitors from your system tray."
authors = ["zpix1"]
edition = "2021"
Expand Down Expand Up @@ -52,4 +52,3 @@ fake-displays = []

[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-updater = "2"

8 changes: 2 additions & 6 deletions src-tauri/src/display_monitor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(target_os = "windows")]
use std::sync::Mutex;
#[cfg(target_os = "windows")]
use tauri::{AppHandle, Emitter, Manager};
use tauri::{AppHandle, Emitter};
#[cfg(target_os = "windows")]
use windows::Win32::{
Foundation::{HWND, LPARAM, LRESULT, WPARAM},
Expand Down Expand Up @@ -30,11 +30,7 @@ unsafe extern "system" fn window_proc(
let _ = app.emit("display-changed", ());
// Optionally reveal UI if user enabled it in settings
if crate::settings::should_show_ui_on_monitor_change_handle(app) {
if let Some(window) = app.get_webview_window("main") {
let _ = window.unminimize();
let _ = window.show();
let _ = window.set_focus();
}
crate::reveal_main_window(app);
}
}
}
Expand Down
62 changes: 39 additions & 23 deletions src-tauri/src/displays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,71 +94,87 @@ pub fn active_provider() -> Box<dyn Displays> {
}
}

async fn run_display_task<T, F>(task: F) -> Result<T, String>
where
T: Send + 'static,
F: FnOnce() -> Result<T, String> + Send + 'static,
{
tauri::async_runtime::spawn_blocking(task)
.await
.map_err(|e| format!("Display task failed: {e}"))?
}

// Tauri commands delegate to the selected provider
#[tauri::command]
pub fn get_all_monitors() -> Result<Vec<DisplayInfo>, String> {
active_provider().get_all_monitors()
pub async fn get_all_monitors() -> Result<Vec<DisplayInfo>, String> {
run_display_task(|| active_provider().get_all_monitors()).await
}

#[tauri::command]
pub fn set_monitor_resolution(
pub async fn set_monitor_resolution(
device_name: String,
width: u32,
height: u32,
refresh_hz: Option<u32>,
) -> Result<(), String> {
active_provider().set_monitor_resolution(device_name, width, height, refresh_hz)
run_display_task(move || {
active_provider().set_monitor_resolution(device_name, width, height, refresh_hz)
})
.await
}

#[tauri::command]
pub fn set_monitor_orientation(
pub async fn set_monitor_orientation(
device_name: String,
orientation_degrees: u32,
) -> Result<(), String> {
active_provider().set_monitor_orientation(device_name, orientation_degrees)
run_display_task(move || {
active_provider().set_monitor_orientation(device_name, orientation_degrees)
})
.await
}

#[tauri::command]
pub fn get_monitor_brightness(device_name: String) -> Result<BrightnessInfo, String> {
active_provider().get_monitor_brightness(device_name)
pub async fn get_monitor_brightness(device_name: String) -> Result<BrightnessInfo, String> {
run_display_task(move || active_provider().get_monitor_brightness(device_name)).await
}

#[tauri::command]
pub fn set_monitor_brightness(device_name: String, percent: u32) -> Result<(), String> {
active_provider().set_monitor_brightness(device_name, percent)
pub async fn set_monitor_brightness(device_name: String, percent: u32) -> Result<(), String> {
run_display_task(move || active_provider().set_monitor_brightness(device_name, percent)).await
}

#[tauri::command]
pub async fn identify_monitors(app_handle: tauri::AppHandle) -> Result<(), String> {
active_provider().identify_monitors(app_handle)
run_display_task(move || active_provider().identify_monitors(app_handle)).await
}

#[tauri::command]
pub fn set_monitor_scale(device_name: String, scale_percent: u32) -> Result<(), String> {
active_provider().set_monitor_scale(device_name, scale_percent)
pub async fn set_monitor_scale(device_name: String, scale_percent: u32) -> Result<(), String> {
run_display_task(move || active_provider().set_monitor_scale(device_name, scale_percent)).await
}

#[tauri::command]
pub fn enable_hdr(device_name: String, enable: bool) -> Result<(), String> {
active_provider().enable_hdr(device_name, enable)
pub async fn enable_hdr(device_name: String, enable: bool) -> Result<(), String> {
run_display_task(move || active_provider().enable_hdr(device_name, enable)).await
}

#[tauri::command]
pub fn set_monitor_input_source(device_name: String, input: String) -> Result<(), String> {
active_provider().set_monitor_input_source(device_name, input)
pub async fn set_monitor_input_source(device_name: String, input: String) -> Result<(), String> {
run_display_task(move || active_provider().set_monitor_input_source(device_name, input)).await
}

#[tauri::command]
pub fn get_monitor_input_source(device_name: String) -> Result<String, String> {
active_provider().get_monitor_input_source(device_name)
pub async fn get_monitor_input_source(device_name: String) -> Result<String, String> {
run_display_task(move || active_provider().get_monitor_input_source(device_name)).await
}

#[tauri::command]
pub fn get_monitor_ddc_caps(device_name: String) -> Result<String, String> {
active_provider().get_monitor_ddc_caps(device_name)
pub async fn get_monitor_ddc_caps(device_name: String) -> Result<String, String> {
run_display_task(move || active_provider().get_monitor_ddc_caps(device_name)).await
}

#[tauri::command]
pub fn set_monitor_power(device_name: String, power_on: bool) -> Result<(), String> {
active_provider().set_monitor_power(device_name, power_on)
pub async fn set_monitor_power(device_name: String, power_on: bool) -> Result<(), String> {
run_display_task(move || active_provider().set_monitor_power(device_name, power_on)).await
}
Loading