diff --git a/druid-shell/Cargo.toml b/druid-shell/Cargo.toml index 8b510e3f9c..5bcdaa9e55 100755 --- a/druid-shell/Cargo.toml +++ b/druid-shell/Cargo.toml @@ -63,8 +63,8 @@ serde = ["kurbo/serde"] [dependencies] # NOTE: When changing the piet or kurbo versions, ensure that # the kurbo version included in piet is compatible with the kurbo version specified here. -piet-common = "=0.5.0" -kurbo = "0.8.2" +piet-common = "=0.6.0" +kurbo = "0.9" tracing = "0.1.22" once_cell = "1.14.0" @@ -100,14 +100,14 @@ bitflags = "1.2.1" [target.'cfg(any(target_os = "freebsd", target_os="linux", target_os="openbsd"))'.dependencies] ashpd = { version = "0.3.0", optional = true } # TODO(x11/dependencies): only use feature "xcb" if using X11 -cairo-rs = { version = "0.14.0", default_features = false, features = ["xcb"] } -cairo-sys-rs = { version = "0.14.0", default_features = false, optional = true } +cairo-rs = { version = "0.16.3", default_features = false, features = ["xcb"] } +cairo-sys-rs = { version = "0.16.3", default_features = false, optional = true } futures = { version = "0.3.21", optional = true, features = ["executor"]} -gdk-sys = { version = "0.14.0", optional = true } +gdk-sys = { version = "0.16.0", optional = true } # `gtk` gets renamed to `gtk-rs` so that we can use `gtk` as the feature name. -gtk-rs = { version = "0.14.0", features = ["v3_22"], package = "gtk", optional = true } -glib-sys = { version = "0.14.0", optional = true } -gtk-sys = { version = "0.14.0", optional = true } +gtk-rs = { version = "0.16.1", package = "gtk", optional = true } +glib-sys = { version = "0.16.3", optional = true } +gtk-sys = { version = "0.16.0", optional = true } nix = { version = "0.24.0", optional = true } x11rb = { version = "0.10", features = ["allow-unsafe-code", "present", "render", "randr", "xfixes", "xkb", "resource_manager", "cursor"], optional = true } wayland-client = { version = "0.29", optional = true } @@ -127,7 +127,7 @@ version = "0.3.44" features = ["Window", "MouseEvent", "CssStyleDeclaration", "WheelEvent", "KeyEvent", "KeyboardEvent", "Navigator"] [dev-dependencies] -piet-common = { version = "=0.5.0", features = ["png"] } +piet-common = { version = "=0.6.0", features = ["png"] } static_assertions = "1.1.0" test-log = { version = "0.2.5", features = ["trace"], default-features = false } tracing-subscriber = { version = "0.3.2", features = ["env-filter"] } diff --git a/druid-shell/src/backend/gtk/clipboard.rs b/druid-shell/src/backend/gtk/clipboard.rs index d6dce15821..04422b0eb2 100644 --- a/druid-shell/src/backend/gtk/clipboard.rs +++ b/druid-shell/src/backend/gtk/clipboard.rs @@ -147,8 +147,7 @@ impl Clipboard { let targets = clipboard.wait_for_targets().unwrap_or_default(); targets .iter() - // SAFETY: Atom::value() is 'self.0 as usize'. No idea why that is unsafe. - .map(|atom| format!("{} ({})", atom.name(), unsafe { atom.value() })) + .map(|atom| format!("{} ({})", atom.name(), atom.value())) .collect() } } diff --git a/druid-shell/src/backend/gtk/dialog.rs b/druid-shell/src/backend/gtk/dialog.rs index c1b4ca5155..26025a93e6 100644 --- a/druid-shell/src/backend/gtk/dialog.rs +++ b/druid-shell/src/backend/gtk/dialog.rs @@ -47,7 +47,7 @@ pub(crate) fn get_file_dialog_path( }; let title = options.title.as_deref().unwrap_or(title); - let mut dialog = gtk::FileChooserNativeBuilder::new() + let mut dialog = gtk::FileChooserNative::builder() .transient_for(window) .title(title); if let Some(button_text) = &options.button_text { diff --git a/druid-shell/src/backend/gtk/menu.rs b/druid-shell/src/backend/gtk/menu.rs index 921f142399..15eb60f43f 100644 --- a/druid-shell/src/backend/gtk/menu.rs +++ b/druid-shell/src/backend/gtk/menu.rs @@ -18,7 +18,7 @@ use gtk::gdk::ModifierType; use gtk::{ AccelGroup, CheckMenuItem, Menu as GtkMenu, MenuBar as GtkMenuBar, MenuItem as GtkMenuItem, }; -use gtk_rs::SeparatorMenuItemBuilder; +use gtk_rs::SeparatorMenuItem; use gtk::prelude::{GtkMenuExt, GtkMenuItemExt, MenuShellExt, WidgetExt}; @@ -114,7 +114,7 @@ impl Menu { menu.append(&item); } - MenuItem::Separator => menu.append(&SeparatorMenuItemBuilder::new().build()), + MenuItem::Separator => menu.append(&SeparatorMenuItem::new()), } } } diff --git a/druid-shell/src/backend/gtk/screen.rs b/druid-shell/src/backend/gtk/screen.rs index 1e7963efd3..f839ea1ee8 100644 --- a/druid-shell/src/backend/gtk/screen.rs +++ b/druid-shell/src/backend/gtk/screen.rs @@ -20,8 +20,8 @@ use kurbo::{Point, Rect, Size}; fn translate_gdk_rectangle(r: Rectangle) -> Rect { Rect::from_origin_size( - Point::new(r.x as f64, r.y as f64), - Size::new(r.width as f64, r.height as f64), + Point::new(r.x() as f64, r.y() as f64), + Size::new(r.width() as f64, r.height() as f64), ) } @@ -30,9 +30,7 @@ fn translate_gdk_monitor(mon: gtk::gdk::Monitor) -> Monitor { Monitor::new( mon.is_primary(), area, - mon.get_property_workarea() - .map(translate_gdk_rectangle) - .unwrap_or(area), + translate_gdk_rectangle(mon.workarea()), ) } diff --git a/druid-shell/src/backend/gtk/window.rs b/druid-shell/src/backend/gtk/window.rs index 1622c44328..2154553ebb 100644 --- a/druid-shell/src/backend/gtk/window.rs +++ b/druid-shell/src/backend/gtk/window.rs @@ -293,7 +293,7 @@ impl WindowBuilder { window.set_decorated(self.show_titlebar); let mut transparent = false; if self.transparent { - if let Some(screen) = window.screen() { + if let Some(screen) = gtk::prelude::GtkWindowExt::screen(&window) { let visual = screen.rgba_visual(); transparent = visual.is_some(); window.set_visual(visual.as_ref()); @@ -475,13 +475,13 @@ impl WindowBuilder { // Create a new cairo surface if necessary (either because there is no surface, or // because the size or scale changed). let extents = widget.allocation(); - let size_px = Size::new(extents.width as f64, extents.height as f64); + let size_px = Size::new(extents.width() as f64, extents.height() as f64); let no_surface = state.surface.try_borrow().map(|x| x.is_none()).ok() == Some(true); if no_surface || scale_changed || state.area.get().size_px() != size_px { let area = ScaledArea::from_px(size_px, scale); let size_dp = area.size_dp(); state.area.set(area); - if let Err(e) = state.resize_surface(extents.width, extents.height) { + if let Err(e) = state.resize_surface(extents.width(), extents.height()) { error!("Failed to resize surface: {}", e); } state.with_handler(|h| h.size(size_dp)); @@ -526,7 +526,7 @@ impl WindowBuilder { // TODO: how are we supposed to handle these errors? What can we do besides panic? Probably nothing right? let alloc = widget.allocation(); context.set_source_surface(surface, 0.0, 0.0).unwrap(); - context.rectangle(0.0, 0.0, alloc.width as f64, alloc.height as f64); + context.rectangle(0.0, 0.0, alloc.width() as f64, alloc.height() as f64); context.fill().unwrap(); }); } else { @@ -1025,24 +1025,24 @@ impl WindowHandle { let scale = state.scale.get(); let (width_px, height_px) = state.window.size(); let alloc_px = state.drawing_area.allocation(); - let menu_height_px = height_px - alloc_px.height; + let menu_height_px = height_px - alloc_px.height(); if let Some(window) = state.window.window() { let frame = window.frame_extents(); let (pos_x, pos_y) = window.position(); Insets::new( - (pos_x - frame.x) as f64, - (pos_y - frame.y + menu_height_px) as f64, - (frame.x + frame.width - (pos_x + width_px)) as f64, - (frame.y + frame.height - (pos_y + height_px)) as f64, + (pos_x - frame.x()) as f64, + (pos_y - frame.y() + menu_height_px) as f64, + (frame.x() + frame.width() - (pos_x + width_px)) as f64, + (frame.y() + frame.height() - (pos_y + height_px)) as f64, ) .to_dp(scale) .nonnegative() } else { let window = Size::new(width_px as f64, height_px as f64).to_dp(scale); let alloc = Rect::from_origin_size( - (alloc_px.x as f64, alloc_px.y as f64), - (alloc_px.width as f64, alloc_px.height as f64), + (alloc_px.x() as f64, alloc_px.y() as f64), + (alloc_px.width() as f64, alloc_px.height() as f64), ) .to_dp(scale); window.to_rect() - alloc diff --git a/druid-shell/src/backend/mac/window.rs b/druid-shell/src/backend/mac/window.rs index 8ceb135a4b..d39f1bb935 100644 --- a/druid-shell/src/backend/mac/window.rs +++ b/druid-shell/src/backend/mac/window.rs @@ -631,7 +631,7 @@ fn mouse_event( unsafe { let point = nsevent.locationInWindow(); let view_point = view.convertPoint_fromView_(point, nil); - let pos = Point::new(view_point.x as f64, view_point.y as f64); + let pos = Point::new(view_point.x, view_point.y); let buttons = get_mouse_buttons(NSEvent::pressedMouseButtons(nsevent)); let modifiers = make_modifiers(nsevent.modifierFlags()); MouseEvent { @@ -776,8 +776,8 @@ extern "C" fn scroll_wheel(this: &mut Object, _: Sel, nsevent: id) { let view_state: *mut c_void = *this.get_ivar("viewState"); let view_state = &mut *(view_state as *mut ViewState); let (dx, dy) = { - let dx = -nsevent.scrollingDeltaX() as f64; - let dy = -nsevent.scrollingDeltaY() as f64; + let dx = -nsevent.scrollingDeltaX(); + let dy = -nsevent.scrollingDeltaY(); if nsevent.hasPreciseScrollingDeltas() == cocoa::base::YES { (dx, dy) } else { @@ -803,7 +803,7 @@ extern "C" fn pinch_event(this: &mut Object, _: Sel, nsevent: id) { let view_state = &mut *(view_state as *mut ViewState); let delta: CGFloat = msg_send![nsevent, magnification]; - view_state.handler.zoom(delta as f64); + view_state.handler.zoom(delta); } } diff --git a/druid-shell/src/backend/x11/window.rs b/druid-shell/src/backend/x11/window.rs index 941ae6b86f..e88709dc30 100644 --- a/druid-shell/src/backend/x11/window.rs +++ b/druid-shell/src/backend/x11/window.rs @@ -783,7 +783,7 @@ impl Window { let invalid = std::mem::replace(&mut *borrow_mut!(self.invalid)?, Region::EMPTY); { let surface = borrow!(self.cairo_surface)?; - let cairo_ctx = cairo::Context::new(&surface).unwrap(); + let cairo_ctx = cairo::Context::new(&*surface).unwrap(); let scale = self.scale.get(); for rect in invalid.rects() { let rect = rect.to_px(scale).round(); diff --git a/druid/Cargo.toml b/druid/Cargo.toml index 110c237fcc..c2773f5555 100644 --- a/druid/Cargo.toml +++ b/druid/Cargo.toml @@ -82,7 +82,7 @@ console_error_panic_hook = { version = "0.1.6" } float-cmp = { version = "0.8.0", features = ["std"], default-features = false } # tempfile 3.2.0 broke wasm; I assume it will be yanked (Jan 12, 2021) tempfile = "=3.1.0" -piet-common = { version = "=0.5.0", features = ["png"] } +piet-common = { version = "=0.6.0", features = ["png"] } pulldown-cmark = { version = "0.8", default-features = false } test-log = { version = "0.2.5", features = ["trace"], default-features = false } # test-env-log needs it diff --git a/druid/examples/async_event.rs b/druid/examples/async_event.rs index 1b6cc453c8..a33939cd5f 100644 --- a/druid/examples/async_event.rs +++ b/druid/examples/async_event.rs @@ -70,10 +70,9 @@ fn generate_colors(event_sink: druid::ExtEventSink) { (_, _) => Color::rgb8(r, g, b.wrapping_add(3)), }; - let color_clone = color.clone(); // schedule idle callback to change the data event_sink.add_idle_callback(move |data: &mut Color| { - *data = color_clone; + *data = color; }); thread::sleep(Duration::from_millis(20)); } diff --git a/druid/examples/scroll.rs b/druid/examples/scroll.rs index 9d9e0fff26..0d6a5d59bd 100644 --- a/druid/examples/scroll.rs +++ b/druid/examples/scroll.rs @@ -63,7 +63,7 @@ impl Widget for OverPainter { let color = env.get_debug_color(self.0); let radius = (rect + INSETS).size().height / 2.0; let circle = Circle::new(rect.center(), radius); - let grad = RadialGradient::new(1.0, (color.clone(), color.clone().with_alpha(0.0))); + let grad = RadialGradient::new(1.0, (color, color.with_alpha(0.0))); ctx.fill(circle, &grad); ctx.stroke(rect, &color, 2.0); } diff --git a/druid/src/env.rs b/druid/src/env.rs index 70a15e9718..b830a08844 100644 --- a/druid/src/env.rs +++ b/druid/src/env.rs @@ -370,7 +370,7 @@ impl Env { #[doc(hidden)] pub fn get_debug_color(&self, id: u64) -> Color { let color_num = id as usize % DEBUG_COLOR.len(); - DEBUG_COLOR[color_num].clone() + DEBUG_COLOR[color_num] } } diff --git a/druid/src/widget/slider.rs b/druid/src/widget/slider.rs index 7299144983..7e2e0da540 100644 --- a/druid/src/widget/slider.rs +++ b/druid/src/widget/slider.rs @@ -469,7 +469,7 @@ impl> Annotated { while walk < self.mapping.max + f64::EPSILON * 10.0 { let layout = text .new_text_layout(format!("{}", walk)) - .text_color(text_color.clone()) + .text_color(text_color) .build() .unwrap(); diff --git a/druid/src/widget/spinner.rs b/druid/src/widget/spinner.rs index 82e4945cfe..cdadbe296e 100644 --- a/druid/src/widget/spinner.rs +++ b/druid/src/widget/spinner.rs @@ -127,7 +127,7 @@ impl Widget for Spinner { let t = self.t; let (width, height) = (ctx.size().width, ctx.size().height); let center = Point::new(width / 2.0, height / 2.0); - let (r, g, b, original_alpha) = Color::as_rgba(&self.color.resolve(env)); + let (r, g, b, original_alpha) = Color::as_rgba(self.color.resolve(env)); let scale_factor = width.min(height) / 40.0; for step in 1..=12 {