Skip to content

Commit

Permalink
Update piet and fix breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
atlanticaccent committed Nov 16, 2023
1 parent fbb92db commit 08fff64
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 32 deletions.
8 changes: 4 additions & 4 deletions druid-shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ hdr = ["piet-common/hdr"]
serde = ["piet-common/serde"]

[dependencies]
piet-common = "0.6.2"
piet-common = { git = "https://github.com/linebender/piet.git", rev = "303b9a932de61cca5a12a8a1ecfbba742638dc52" }

tracing = "0.1.37"
once_cell = "1.17.1"
Expand Down Expand Up @@ -100,8 +100,8 @@ 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.0", default-features = false, features = ["xcb"] }
cairo-sys-rs = { version = "0.18.0", default-features = false, optional = true }
futures = { version = "0.3.26", optional = true, features = ["executor"]}
gdk-sys = { version = "0.18.0", optional = true }
# `gtk` gets renamed to `gtk-rs` so that we can use `gtk` as the feature name.
Expand All @@ -127,7 +127,7 @@ version = "0.3.61"
features = ["Window", "MouseEvent", "CssStyleDeclaration", "WheelEvent", "KeyEvent", "KeyboardEvent", "Navigator"]

[dev-dependencies]
piet-common = { version = "0.6.2", features = ["png"] }
piet-common = { git = "https://github.com/linebender/piet.git", rev = "303b9a932de61cca5a12a8a1ecfbba742638dc52", features = ["png"] }
static_assertions = "1.1.0"
test-log = { version = "0.2.11", features = ["trace"], default-features = false }
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/backend/gtk/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ 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);
dialog.add_filter(filter.clone());

if let Some(default) = &options.default_type {
if default == f {
Expand Down
1 change: 1 addition & 0 deletions druid-shell/src/backend/gtk/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use crate::kurbo::{Point, Rect, Size};
use crate::screen::Monitor;
use gtk::gdk::{Display, DisplayManager, Rectangle};
use gtk_rs::prelude::MonitorExt as _;

fn translate_gdk_rectangle(r: Rectangle) -> Rect {
Rect::from_origin_size(
Expand Down
44 changes: 24 additions & 20 deletions druid-shell/src/backend/gtk/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ use std::slice;
use std::sync::{Arc, Mutex, Weak};
use std::time::Instant;

use cairo::glib::{Propagation, ControlFlow};
use gtk::gdk_pixbuf::Colorspace::Rgb;
use gtk::gdk_pixbuf::Pixbuf;
use gtk::glib::source::Continue;
use gtk::glib::translate::FromGlib;
use gtk::prelude::*;
use gtk::traits::SettingsExt;
use gtk::traits::GtkSettingsExt;
use gtk::{AccelGroup, ApplicationWindow, DrawingArea};

use gdk_sys::GdkKeymapKey;
Expand Down Expand Up @@ -427,7 +427,7 @@ impl WindowBuilder {
.connect_enter_notify_event(|widget, _| {
widget.grab_focus();

Inhibit(true)
cairo::glib::Propagation::Stop
});

// Set the minimum size
Expand Down Expand Up @@ -539,7 +539,7 @@ impl WindowBuilder {
}
}

Inhibit(false)
cairo::glib::Propagation::Proceed
}));

win_state.drawing_area.connect_screen_changed(
Expand Down Expand Up @@ -595,7 +595,7 @@ impl WindowBuilder {
});
}

Inhibit(true)
cairo::glib::Propagation::Stop
}));

win_state.drawing_area.connect_button_release_event(clone!(handle => move |_widget, event| {
Expand All @@ -622,7 +622,7 @@ impl WindowBuilder {
});
}

Inhibit(true)
cairo::glib::Propagation::Stop
}));

win_state.drawing_area.connect_motion_notify_event(
Expand All @@ -643,7 +643,7 @@ impl WindowBuilder {
state.with_handler(|h| h.mouse_move(&mouse_event));
}

Inhibit(true)
cairo::glib::Propagation::Stop
}),
);

Expand All @@ -653,7 +653,7 @@ impl WindowBuilder {
state.with_handler(|h| h.mouse_leave());
}

Inhibit(true)
cairo::glib::Propagation::Stop
}),
);

Expand Down Expand Up @@ -709,7 +709,7 @@ impl WindowBuilder {
}
}

Inhibit(true)
cairo::glib::Propagation::Stop
}));

win_state
Expand All @@ -727,7 +727,7 @@ impl WindowBuilder {
);
}

Inhibit(true)
cairo::glib::Propagation::Stop
}));

win_state
Expand All @@ -745,7 +745,7 @@ impl WindowBuilder {
);
}

Inhibit(true)
cairo::glib::Propagation::Stop
}));

win_state
Expand All @@ -754,7 +754,7 @@ impl WindowBuilder {
if let Some(state) = handle.state.upgrade() {
state.with_handler(|h| h.got_focus());
}
Inhibit(true)
cairo::glib::Propagation::Stop
}));

win_state
Expand All @@ -763,17 +763,21 @@ impl WindowBuilder {
if let Some(state) = handle.state.upgrade() {
state.with_handler(|h| h.lost_focus());
}
Inhibit(true)
cairo::glib::Propagation::Stop
}));

win_state
.window
.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())
if !state.closing.get() {
Propagation::Stop
} else {
Propagation::Proceed
}
} else {
Inhibit(false)
cairo::glib::Propagation::Proceed
}
}));

Expand Down Expand Up @@ -1221,9 +1225,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
Expand Down Expand Up @@ -1382,7 +1386,7 @@ impl IdleHandle {
}
}

fn run_idle(state: &Arc<WindowState>) -> Continue {
fn run_idle(state: &Arc<WindowState>) -> ControlFlow {
util::assert_main_thread();
let result = state.with_handler(|handler| {
let queue: Vec<_> = std::mem::take(&mut state.idle_queue.lock().unwrap());
Expand All @@ -1404,7 +1408,7 @@ fn run_idle(state: &Arc<WindowState>) -> 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<gtk::gdk::Cursor> {
Expand Down Expand Up @@ -1504,7 +1508,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());
Expand Down
2 changes: 1 addition & 1 deletion druid/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ console_error_panic_hook = { version = "0.1.7" }
[dev-dependencies]
float-cmp = { version = "0.9.0", features = ["std"], default-features = false }
tempfile = "3.4.0"
piet-common = { version = "0.6.2", features = ["png"] }
piet-common = { git = "https://github.com/linebender/piet.git", rev = "303b9a932de61cca5a12a8a1ecfbba742638dc52", features = ["png"] }
pulldown-cmark = { version = "0.8.0", default-features = false }
test-log = { version = "0.2.11", features = ["trace"], default-features = false }
# test-env-log needs it
Expand Down
5 changes: 2 additions & 3 deletions druid/src/sub_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use crate::win_handler::AppState;
use crate::{Data, Point, Widget, WidgetExt, WidgetId, WidgetPod, WindowHandle, WindowId};
use druid_shell::Error;
use std::any::Any;
use std::ops::Deref;
use tracing::{instrument, warn};
// We can't have any type arguments here, as both ends would need to know them
// ahead of time in order to instantiate correctly.
Expand Down Expand Up @@ -70,7 +69,7 @@ impl SubWindowDesc {
app_state: &mut AppState<T>,
) -> Result<WindowHandle, Error> {
let sub_window_root = self.sub_window_root;
let pending = PendingWindow::new(sub_window_root.lens(Unit::default()));
let pending = PendingWindow::new(sub_window_root.lens(Unit));
app_state.build_native_window(self.window_id, pending, self.window_config)
}
}
Expand Down Expand Up @@ -107,7 +106,7 @@ impl<U: Data, W: Widget<U>> Widget<()> for SubWindowHost<U, W> {
let update = cmd.get_unchecked(SUB_WINDOW_PARENT_TO_HOST);
if let Some(data_update) = &update.data {
if let Some(dc) = data_update.downcast_ref::<U>() {
self.data = dc.deref().clone();
self.data = dc.clone();
ctx.request_update();
} else {
warn!("Received a sub window parent to host command that could not be unwrapped. \
Expand Down
2 changes: 1 addition & 1 deletion druid/src/widget/progress_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct ProgressBar;
impl ProgressBar {
/// Return a new `ProgressBar`.
pub fn new() -> ProgressBar {
Self::default()
Self
}
}

Expand Down
4 changes: 2 additions & 2 deletions druid/src/widget/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ impl<L: Lens<State, In>, In, State> LensScopeTransfer<L, In, State> {
pub fn new(lens: L) -> Self {
LensScopeTransfer {
lens,
phantom_in: PhantomData::default(),
phantom_state: PhantomData::default(),
phantom_in: PhantomData,
phantom_state: PhantomData,
}
}
}
Expand Down

0 comments on commit 08fff64

Please sign in to comment.