Skip to content

Commit

Permalink
fix: use IndexMap to preserve insertion order
Browse files Browse the repository at this point in the history
  • Loading branch information
decipher3114 committed Oct 2, 2024
1 parent 4908909 commit e43d698
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
13 changes: 10 additions & 3 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ arboard = { version = "3.4", features = ["wayland-data-control", "wl-clipboard-r
chrono = "0.4"
iced = { version = "0.13", features = ["advanced", "canvas", "multi-window", "image", "tokio"] }
iced_anim = { version = "0.1", features = ["derive", "serde"] }
indexmap = "2.6"
interprocess = { version = "2.2", features = ["tokio"] }
rdev = { git = "https://github.com/rustdesk-org/rdev", branch = "master"}
rfd = { version = "0.14", features = ["gtk3", "tokio"], default-features = false }
Expand Down
5 changes: 2 additions & 3 deletions src/entities/capture/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::BTreeMap;

use iced::{widget::canvas, Point};
use indexmap::IndexMap;
use shape::{Shape, ShapeColor, ShapeStroke, ShapeType};
use xcap::image::RgbaImage;

Expand All @@ -11,7 +10,7 @@ pub struct CaptureWindow {
pub crop_mode: CropMode,
pub mode_desc: String,
pub display: CapturedMonitor,
pub windows: BTreeMap<u32, CapturedWindow>,
pub windows: IndexMap<u32, CapturedWindow>,
pub cursor_position: Point,
pub mode: Mode,
pub endpoints: Endpoints,
Expand Down
7 changes: 3 additions & 4 deletions src/utils/capture/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::BTreeMap;

use arboard::{Clipboard, ImageData};
use iced::{widget::canvas::Cache, Point};
use indexmap::IndexMap;
use tiny_skia::{FillRule, Paint, PathBuilder, Pixmap, Rect, Stroke, Transform};
use xcap::{
image::{imageops::overlay, DynamicImage, ImageFormat, RgbaImage},
Expand Down Expand Up @@ -99,7 +98,7 @@ impl CaptureWindow {
base
}
CropMode::SpecificWindow(id) => {
let window = self.windows.remove(&id).unwrap();
let window = self.windows.swap_remove(&id).unwrap();

let x = window.x;
let y = window.y;
Expand Down Expand Up @@ -151,7 +150,7 @@ pub fn get_display() -> CapturedMonitor {
}
}

pub fn get_windows(monitor_id: u32) -> BTreeMap<u32, CapturedWindow> {
pub fn get_windows(monitor_id: u32) -> IndexMap<u32, CapturedWindow> {
let all_windows = xcap::Window::all().unwrap();

let valid_windows = all_windows
Expand Down

0 comments on commit e43d698

Please sign in to comment.