diff --git a/CHANGELOG.md b/CHANGELOG.md index 93600f4e7..3c3978b3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ You can find its changes [documented below](#083---2023-02-28). ### Maintenance +- Updated `piet-common` to 0.7, `cairo-rs` and `gtk` to 0.18, `core-graphics` to 0.24, `foreign-types` to 0.5, and `kurbo` to 0.11. ([#2410] by [@xStrom]) + ### Outside News ## [0.8.3] - 2023-02-28 @@ -336,7 +338,7 @@ Later support was widened in [#2254] by [@PolyMeilex]. - Replaced `lazy_static` with `once_cell`. ([#2263] by [@jplatte]) - Updated `piet-common` to 0.6, `kurbo` to 0.9. ([#1677], [#2040] by [@cmyr]; [#1845] by [@JAicewizard]; [#2290] by [@jneem]) -- Updated `cairo-rs`, `cairo-sys-rs`, `gdk-sys`, `gtk-rs`, `glib-sys`, `gtk-sys` to 0.16. ([#1845] by [@JAicewizard], [#2290] by [@jneem]) +- Updated `cairo-rs`, `cairo-sys-rs`, `gdk-sys`, `gtk`, `glib-sys`, `gtk-sys` to 0.16. ([#1845] by [@JAicewizard], [#2290] by [@jneem]) - Updated `x11rb` to 0.10. ([#1519], [#2231] by [@psychon]) - Updated `fluent-bundle` to 0.15 and `fluent-syntax` to 0.11. ([#1772] by [@r-ml]) - Updated `tracing-wasm` to 0.2. ([#1793] by [@Maan2003]) @@ -1246,6 +1248,7 @@ Last release without a changelog :( [#2380]: https://github.com/linebender/druid/pull/2380 [#2402]: https://github.com/linebender/druid/pull/2402 [#2409]: https://github.com/linebender/druid/pull/2409 +[#2410]: https://github.com/linebender/druid/pull/2410 [#2413]: https://github.com/linebender/druid/pull/2413 [Unreleased]: https://github.com/linebender/druid/compare/v0.8.3...master diff --git a/druid-shell/Cargo.toml b/druid-shell/Cargo.toml index 481a5c491..39a86ddbd 100755 --- a/druid-shell/Cargo.toml +++ b/druid-shell/Cargo.toml @@ -18,22 +18,21 @@ cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] [features] default = ["gtk"] -gtk = ["gdk-sys", "glib-sys", "gtk-sys", "gtk-rs"] +gtk = ["gtk-rs"] x11 = [ "ashpd", "bindgen", - "cairo-sys-rs", "futures", "nix", "pkg-config", "x11rb", + "cairo-rs/xcb", ] wayland = [ "wayland-client", "wayland-protocols/client", "wayland-protocols/unstable_protocols", "nix", - "cairo-sys-rs", "rand", "calloop", "wayland-cursor", @@ -50,7 +49,6 @@ raw-win-handle = ["raw-window-handle"] image = ["piet-common/image"] image_png = ["piet-common/image_png"] jpeg = ["piet-common/jpeg"] -jpeg_rayon = ["piet-common/jpeg_rayon"] gif = ["piet-common/gif"] bmp = ["piet-common/bmp"] ico = ["piet-common/ico"] @@ -59,13 +57,11 @@ webp = ["piet-common/webp"] pnm = ["piet-common/pnm"] dds = ["piet-common/dds"] tga = ["piet-common/tga"] -farbfeld = ["piet-common/farbfeld"] -dxt = ["piet-common/dxt"] hdr = ["piet-common/hdr"] serde = ["piet-common/serde"] [dependencies] -piet-common = "0.6.2" +piet-common = { version = "=0.7.0-cairo18" } tracing = "0.1.40" once_cell = "1.20.2" @@ -93,21 +89,16 @@ features = ["d2d1_1", "dwrite", "winbase", "libloaderapi", "errhandlingapi", "wi block = "0.1.6" cocoa = "0.24.1" objc = "0.2.7" -core-graphics = "0.22.3" -foreign-types = "0.3.2" +core-graphics = "0.24.0" +foreign-types = "0.5.0" bitflags = "1.3.2" [target.'cfg(any(target_os = "freebsd", target_os="linux", target_os="openbsd"))'.dependencies] ashpd = { version = "0.3.2", optional = true } -# TODO(x11/dependencies): only use feature "xcb" if using X11 -cairo-rs = { version = "0.16.7", default-features = false, features = ["xcb"] } -cairo-sys-rs = { version = "0.16.3", default-features = false, optional = true } +cairo-rs = { version = "0.18.5", default-features = false } futures = { version = "0.3.31", optional = true, features = ["executor"]} -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.16.2", package = "gtk", optional = true } -glib-sys = { version = "0.16.3", optional = true } -gtk-sys = { version = "0.16.0", optional = true } +gtk-rs = { version = "0.18.1", package = "gtk", optional = true } nix = { version = "0.24.3", optional = true } x11rb = { version = "0.10.1", features = ["allow-unsafe-code", "present", "render", "randr", "xfixes", "xkb", "resource_manager", "cursor"], optional = true } wayland-client = { version = "0.29.5", optional = true } @@ -127,7 +118,7 @@ version = "0.3.72" features = ["Window", "MouseEvent", "CssStyleDeclaration", "WheelEvent", "KeyEvent", "KeyboardEvent", "Navigator"] [dev-dependencies] -piet-common = { version = "0.6.2", features = ["png"] } +piet-common = { version = "=0.7.0-cairo18", features = ["png"] } static_assertions = "1.1.0" test-log = { version = "0.2.16", features = ["trace"], default-features = false } tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } diff --git a/druid-shell/src/backend/gtk/dialog.rs b/druid-shell/src/backend/gtk/dialog.rs index e2b14f575..81152d2da 100644 --- a/druid-shell/src/backend/gtk/dialog.rs +++ b/druid-shell/src/backend/gtk/dialog.rs @@ -59,13 +59,12 @@ pub(crate) fn get_file_dialog_path( if let Some(file_types) = &options.allowed_types { for f in file_types { let filter = file_filter(f); - dialog.add_filter(&filter); + // We need to clone filter, because we may need it again for the default filter. + // It has to be the same FileFilter instance and can't be a new file_filter() call. + dialog.add_filter(filter.clone()); if let Some(default) = &options.default_type { if default == f { - // Note that we're providing the same FileFilter object to - // add_filter and set_filter, because gtk checks them for - // identity, not structural equality. dialog.set_filter(&filter); found_default_filter = true; } diff --git a/druid-shell/src/backend/gtk/screen.rs b/druid-shell/src/backend/gtk/screen.rs index 7c6ba6c7f..2be0599bd 100644 --- a/druid-shell/src/backend/gtk/screen.rs +++ b/druid-shell/src/backend/gtk/screen.rs @@ -6,6 +6,7 @@ use crate::kurbo::{Point, Rect, Size}; use crate::screen::Monitor; use gtk::gdk::{Display, DisplayManager, Rectangle}; +use gtk::prelude::MonitorExt as _; fn translate_gdk_rectangle(r: Rectangle) -> Rect { Rect::from_origin_size( diff --git a/druid-shell/src/backend/gtk/window.rs b/druid-shell/src/backend/gtk/window.rs index 688610583..f823236e8 100644 --- a/druid-shell/src/backend/gtk/window.rs +++ b/druid-shell/src/backend/gtk/window.rs @@ -13,16 +13,14 @@ use std::slice; use std::sync::{Arc, Mutex, Weak}; use std::time::Instant; +use gtk::gdk::ffi::GdkKeymapKey; use gtk::gdk_pixbuf::Colorspace::Rgb; use gtk::gdk_pixbuf::Pixbuf; -use gtk::glib::source::Continue; use gtk::glib::translate::FromGlib; +use gtk::glib::{ControlFlow, Propagation}; use gtk::prelude::*; -use gtk::traits::SettingsExt; use gtk::{AccelGroup, ApplicationWindow, DrawingArea}; -use gdk_sys::GdkKeymapKey; - use anyhow::anyhow; use cairo::Surface; use gtk::gdk::{ @@ -416,7 +414,7 @@ impl WindowBuilder { .connect_enter_notify_event(|widget, _| { widget.grab_focus(); - Inhibit(true) + Propagation::Stop }); // Set the minimum size @@ -528,7 +526,7 @@ impl WindowBuilder { } } - Inhibit(false) + Propagation::Proceed })); win_state.drawing_area.connect_screen_changed( @@ -584,7 +582,7 @@ impl WindowBuilder { }); } - Inhibit(true) + Propagation::Stop })); win_state.drawing_area.connect_button_release_event(clone!(handle => move |_widget, event| { @@ -611,7 +609,7 @@ impl WindowBuilder { }); } - Inhibit(true) + Propagation::Stop })); win_state.drawing_area.connect_motion_notify_event( @@ -632,7 +630,7 @@ impl WindowBuilder { state.with_handler(|h| h.mouse_move(&mouse_event)); } - Inhibit(true) + Propagation::Stop }), ); @@ -642,7 +640,7 @@ impl WindowBuilder { state.with_handler(|h| h.mouse_leave()); } - Inhibit(true) + Propagation::Stop }), ); @@ -698,7 +696,7 @@ impl WindowBuilder { } } - Inhibit(true) + Propagation::Stop })); win_state @@ -716,7 +714,7 @@ impl WindowBuilder { ); } - Inhibit(true) + Propagation::Stop })); win_state @@ -734,7 +732,7 @@ impl WindowBuilder { ); } - Inhibit(true) + Propagation::Stop })); win_state @@ -743,7 +741,7 @@ impl WindowBuilder { if let Some(state) = handle.state.upgrade() { state.with_handler(|h| h.got_focus()); } - Inhibit(true) + Propagation::Stop })); win_state @@ -752,7 +750,7 @@ impl WindowBuilder { if let Some(state) = handle.state.upgrade() { state.with_handler(|h| h.lost_focus()); } - Inhibit(true) + Propagation::Stop })); win_state @@ -760,9 +758,12 @@ impl WindowBuilder { .connect_delete_event(clone!(handle => move |_widget, _ev| { if let Some(state) = handle.state.upgrade() { state.with_handler(|h| h.request_close()); - Inhibit(!state.closing.get()) + match state.closing.get() { + true => Propagation::Proceed, + false => Propagation::Stop, + } } else { - Inhibit(false) + Propagation::Proceed } })); @@ -1218,9 +1219,9 @@ impl WindowHandle { if let Some(state) = self.state.upgrade() { gtk::glib::timeout_add(interval, move || { if state.with_handler(|h| h.timer(token)).is_some() { - return Continue(false); + return ControlFlow::Break; } - Continue(true) + ControlFlow::Continue }); } token @@ -1379,7 +1380,7 @@ impl IdleHandle { } } -fn run_idle(state: &Arc) -> Continue { +fn run_idle(state: &Arc) -> ControlFlow { util::assert_main_thread(); let result = state.with_handler(|handler| { let queue: Vec<_> = std::mem::take(&mut state.idle_queue.lock().unwrap()); @@ -1401,7 +1402,7 @@ fn run_idle(state: &Arc) -> Continue { let timeout = Duration::from_millis(16); gtk::glib::timeout_add(timeout, move || run_idle(&state)); } - Continue(false) + ControlFlow::Break } fn make_gdk_cursor(cursor: &Cursor, gdk_window: &Window) -> Option { @@ -1501,7 +1502,7 @@ fn make_key_event(key: &EventKey, repeat: bool, state: KeyState) -> KeyEvent { let keyval = key.keyval(); let hardware_keycode = key.hardware_keycode(); - let keycode = hardware_keycode_to_keyval(hardware_keycode).unwrap_or_else(|| keyval.clone()); + let keycode = hardware_keycode_to_keyval(hardware_keycode).unwrap_or(keyval); let text = keyval.to_unicode(); let mods = get_modifiers(key.state()); @@ -1535,14 +1536,14 @@ fn make_key_event(key: &EventKey, repeat: bool, state: KeyState) -> KeyEvent { /// keyval with the lowest group and level fn hardware_keycode_to_keyval(keycode: u16) -> Option { unsafe { - let keymap = gdk_sys::gdk_keymap_get_default(); + let keymap = gtk::gdk::ffi::gdk_keymap_get_default(); let mut nkeys = 0; let mut keys: *mut GdkKeymapKey = ptr::null_mut(); let mut keyvals: *mut c_uint = ptr::null_mut(); // call into gdk to retrieve the keyvals and keymap keys - gdk_sys::gdk_keymap_get_entries_for_keycode( + gtk::gdk::ffi::gdk_keymap_get_entries_for_keycode( keymap, c_uint::from(keycode), &mut keys as *mut *mut GdkKeymapKey, @@ -1563,8 +1564,8 @@ fn hardware_keycode_to_keyval(keycode: u16) -> Option { }); // notify glib to free the allocated arrays - glib_sys::g_free(keyvals as *mut c_void); - glib_sys::g_free(keys as *mut c_void); + gtk::glib::ffi::g_free(keyvals as *mut c_void); + gtk::glib::ffi::g_free(keys as *mut c_void); resolved_keyval } else { diff --git a/druid-shell/src/backend/wayland/surfaces/surface.rs b/druid-shell/src/backend/wayland/surfaces/surface.rs index e215ce13b..81ee06228 100644 --- a/druid-shell/src/backend/wayland/surfaces/surface.rs +++ b/druid-shell/src/backend/wayland/surfaces/surface.rs @@ -500,7 +500,10 @@ impl Data { tracing::trace!("invalidate_rect initiated {:?}", rect); // Quick check to see if we can skip the rect entirely (if it is outside the visible // screen). - if rect.intersect(self.logical_size.get().to_rect()).is_empty() { + if rect + .intersect(self.logical_size.get().to_rect()) + .is_zero_area() + { return; } /* this would be useful for debugging over-keen invalidation by clients. diff --git a/druid-shell/src/backend/x11/window.rs b/druid-shell/src/backend/x11/window.rs index d2cf0c7a0..32f6335f9 100644 --- a/druid-shell/src/backend/x11/window.rs +++ b/druid-shell/src/backend/x11/window.rs @@ -192,14 +192,14 @@ impl WindowBuilder { let conn = self.app.connection(); let cairo_xcb_connection = unsafe { CairoXCBConnection::from_raw_none( - conn.get_raw_xcb_connection() as *mut cairo_sys::xcb_connection_t + conn.get_raw_xcb_connection() as *mut cairo::ffi::xcb_connection_t ) }; let cairo_drawable = XCBDrawable(window_id); let mut xcb_visual = xcb_visualtype_t::from(*visual_type); let cairo_visual_type = unsafe { XCBVisualType::from_raw_none( - &mut xcb_visual as *mut xcb_visualtype_t as *mut cairo_sys::xcb_visualtype_t, + &mut xcb_visual as *mut xcb_visualtype_t as *mut cairo::ffi::xcb_visualtype_t, ) }; let cairo_surface = XCBSurface::create( diff --git a/druid/Cargo.toml b/druid/Cargo.toml index 5912d98df..5ecc49e20 100644 --- a/druid/Cargo.toml +++ b/druid/Cargo.toml @@ -34,7 +34,6 @@ raw-win-handle = ["druid-shell/raw-win-handle"] # support decoding, and that's all we use `Image` for. png = ["druid-shell/image_png"] jpeg = ["druid-shell/jpeg"] -jpeg_rayon = ["druid-shell/jpeg_rayon"] gif = ["druid-shell/gif"] bmp = ["druid-shell/bmp"] ico = ["druid-shell/ico"] @@ -43,12 +42,10 @@ webp = ["druid-shell/webp"] pnm = ["druid-shell/pnm"] dds = ["druid-shell/dds"] tga = ["druid-shell/tga"] -farbfeld = ["druid-shell/farbfeld"] -dxt = ["druid-shell/dxt"] hdr = ["druid-shell/hdr"] # Remember to update this when changing an image feature. -image-all = ["image", "svg", "png", "jpeg", "jpeg_rayon", "gif", "bmp", "ico", "tiff", "webp", "pnm", "dds", "tga", "farbfeld", "dxt", "hdr"] +image-all = ["image", "svg", "png", "jpeg", "gif", "bmp", "ico", "tiff", "webp", "pnm", "dds", "tga", "hdr"] [dependencies] druid-shell = { version = "0.8.3", default-features = false, path = "../druid-shell" } @@ -79,7 +76,7 @@ console_error_panic_hook = { version = "0.1.7" } [dev-dependencies] float-cmp = { version = "0.9.0", features = ["std"], default-features = false } tempfile = "3.13.0" -piet-common = { version = "0.6.2", features = ["png"] } +piet-common = { version = "=0.7.0-cairo18", features = ["png"] } pulldown-cmark = { version = "0.8.0", default-features = false } test-log = { version = "0.2.16", features = ["trace"], default-features = false } # test-env-log needs it diff --git a/druid/src/widget/image.rs b/druid/src/widget/image.rs index 8e689ad9b..e031741f1 100644 --- a/druid/src/widget/image.rs +++ b/druid/src/widget/image.rs @@ -221,7 +221,7 @@ impl Widget for Image { self.paint_data .get_or_insert_with(|| image_data.to_image(ctx.render_ctx)) }; - if piet_image.size().is_empty() { + if piet_image.size().is_zero_area() { // zero-sized image = nothing to draw return; }