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 Feb 26, 2024
1 parent 7e8b084 commit e8d014f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 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

0 comments on commit e8d014f

Please sign in to comment.