Skip to content

Commit

Permalink
Merge pull request #10 from guchengxi1994/master
Browse files Browse the repository at this point in the history
fix : linux
  • Loading branch information
guchengxi1994 authored Apr 17, 2024
2 parents 434a6f7 + 972d426 commit f7e2cf9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: all_in_one
description: "A new Flutter project."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 0.0.3+5
version: 0.0.3+6

environment:
sdk: '>=3.3.0 <4.0.0'
Expand Down
8 changes: 4 additions & 4 deletions rust/src/api/software_monitor_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::software_monitor::{
};
use winreg::enums::{HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE};

#[cfg(windows)]
#[cfg(target_os = "windows")]
pub fn get_windows_installed_softwares() -> Vec<software::Software> {
let local = software::_Hkey(HKEY_LOCAL_MACHINE);
let user = software::_Hkey(HKEY_CURRENT_USER);
Expand All @@ -28,7 +28,7 @@ pub fn software_watching_message_stream(s: StreamSink<Vec<i64>>) -> anyhow::Resu
}

#[flutter_rust_bridge::frb(sync)]
#[cfg(windows)]
#[cfg(target_os = "windows")]
pub fn software_watching_with_foreground_message_stream(
s: StreamSink<(Vec<i64>, String)>,
) -> anyhow::Result<()> {
Expand All @@ -50,7 +50,7 @@ pub fn remove_from_watching_list(id: i64) {
list.retain(|x| x.0 != id);
}

#[cfg(linux)]
#[cfg(target_os = "linux")]
pub fn init_monitor(items: Vec<(i64, String)>) {
{
let mut list = WATCHING_LIST.write().unwrap();
Expand All @@ -59,7 +59,7 @@ pub fn init_monitor(items: Vec<(i64, String)>) {
start_watch()
}

#[cfg(windows)]
#[cfg(target_os = "windows")]
pub fn init_monitor(items: Vec<(i64, String)>) {
{
let mut list = WATCHING_LIST.write().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion rust/src/software_monitor/foreground_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::monitor::WATCHING_LIST;
pub static WATCHING_FOREGROUND_MESSAGE_SINK: RwLock<Option<StreamSink<(Vec<i64>, String)>>> =
RwLock::new(None);

#[cfg(windows)]
#[cfg(target_os = "windows")]
#[allow(unused_unsafe)]
pub fn start_monitor_with_foreground() {
let mut sys = System::new();
Expand Down
4 changes: 2 additions & 2 deletions rust/src/software_monitor/software.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ impl Hash for Software {
}
}

#[cfg(windows)]
#[cfg(target_os = "windows")]
#[frb(ignore)]
pub struct _Hkey(pub isize);

#[cfg(windows)]
#[cfg(target_os = "windows")]
impl _Hkey {
#[frb(ignore)]
pub fn get_all(&self) -> Vec<Software> {
Expand Down
7 changes: 2 additions & 5 deletions rust_simple_notify_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ use std::{
time::Duration,
};

use tao::{
event_loop::{EventLoop, EventLoopBuilder},
platform::windows::EventLoopBuilderExtWindows,
};
use tao::event_loop::{EventLoop, EventLoopBuilder};

pub mod ui;
pub mod utils;
Expand Down Expand Up @@ -55,7 +52,7 @@ pub fn create_event_loop() -> anyhow::Result<()> {
EventLoopBuilder::<EventMessage>::with_user_event();

#[cfg(target_os = "windows")]
builder.with_any_thread(true);
tao::platform::windows::EventLoopBuilderExtWindows::with_any_thread(&mut builder, true);

let event_loop: EventLoop<EventMessage> = builder.build();
let (_tx, rx) = channel::<String>();
Expand Down
6 changes: 4 additions & 2 deletions rust_simple_notify_lib/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#[cfg(target_os = "windows")]
use winapi::um::winuser::{GetSystemMetrics, SM_CXSCREEN, SM_CYSCREEN};

#[cfg(target_os = "windows")]
fn get_screen_size_on_windows() -> (i32, i32) {
let width = unsafe { GetSystemMetrics(SM_CXSCREEN) };
let height = unsafe { GetSystemMetrics(SM_CYSCREEN) };
// println!("Screen size: {} x {}", width, height);
(width, height)
}

#[cfg(windows)]
#[cfg(target_os = "windows")]
pub fn get_screen_size() -> (i32, i32) {
return get_screen_size_on_windows();
}

#[cfg(linux)]
#[cfg(target_os = "linux")]
pub fn get_screen_size() -> (i32, i32) {
return (-1,-1);
}

0 comments on commit f7e2cf9

Please sign in to comment.