Skip to content

Commit

Permalink
修改光标颜色不需要重启
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnux committed Sep 7, 2023
1 parent b852493 commit ab76233
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/beacon.rs
Original file line number Diff line number Diff line change
@@ -41,6 +41,9 @@ static mut ANIMATION_ARG_DURATION_STEP: usize = 100;
const TIMER_ANIMATION_DURATION: UINT_PTR = 3;
static mut ANIMATION_DURATION_LEFT_COUNT: isize = 0; // 百分比
static mut cursor_color: HBRUSH = std::ptr::null_mut();
static mut cursor_color_r_old: u8 = 0;
static mut cursor_color_g_old: u8 = 0;
static mut cursor_color_b_old: u8 = 0;
static mut cursor_color_r: u8 = 255;
static mut cursor_color_g: u8 = 255;
static mut cursor_color_b: u8 = 255;
@@ -319,10 +322,22 @@ fn show_animation_wnd() {
TIMER_BEACON_DURATION_STEP as u32,
None,
);
// TODO: 目前仅支持一次性设置
if cursor_color.is_null() {

if cursor_color.is_null()
|| cursor_color_r_old != cursor_color_r
|| cursor_color_g_old != cursor_color_g
|| cursor_color_b_old != cursor_color_b
{
if !cursor_color.is_null() {
DeleteObject(cursor_color as *mut _);
cursor_color = std::ptr::null_mut();
}
cursor_color = CreateSolidBrush(RGB(cursor_color_r, cursor_color_g, cursor_color_b));
cursor_color_r_old = cursor_color_r;
cursor_color_g_old = cursor_color_g;
cursor_color_b_old = cursor_color_b;
}

// SetForegroundWindow(ANIMATION_WND); // 这个会发生焦点切换
on_animation_timer(ANIMATION_DURATION_LEFT_COUNT);
}

0 comments on commit ab76233

Please sign in to comment.