-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support open/save dialogs on wayland. #2228
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,5 +26,6 @@ cfg_if::cfg_if! { | |
pub(crate) use timer::*; | ||
pub(crate) mod xkb; | ||
pub(crate) mod linux; | ||
pub(crate) mod zbus; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,9 @@ use wayland_protocols::xdg_shell::client::xdg_popup; | |
use wayland_protocols::xdg_shell::client::xdg_positioner; | ||
use wayland_protocols::xdg_shell::client::xdg_surface; | ||
|
||
use crate::kurbo; | ||
use crate::backend::shared::zbus; | ||
use crate::window; | ||
use crate::{kurbo, FileDialogOptions, FileDialogToken}; | ||
use crate::{piet::Piet, region::Region, scale::Scale, TextFieldToken}; | ||
|
||
use super::super::Changed; | ||
|
@@ -190,6 +191,14 @@ impl Handle for Surface { | |
self.inner.invalidate_rect(rect) | ||
} | ||
|
||
fn open_file(&self, options: FileDialogOptions) -> Option<FileDialogToken> { | ||
self.inner.open_file(options) | ||
} | ||
|
||
fn save_as(&self, options: FileDialogOptions) -> Option<FileDialogToken> { | ||
self.inner.save_as(options) | ||
} | ||
|
||
fn run_idle(&self) { | ||
self.inner.run_idle(); | ||
} | ||
|
@@ -469,6 +478,26 @@ impl Data { | |
self.schedule_deferred_task(DeferredTask::Paint); | ||
} | ||
|
||
fn open_file(&self, options: FileDialogOptions) -> Option<FileDialogToken> { | ||
// FIXME: current ashpd has issues with wayland versions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a link to the upstream issue we could put here as a reference? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this. Which is merged, but there's still an issue with Also, it looks like getting an identifier requires a round-trip to the compositor, and so the new function is async... |
||
//let id = ashpd::WindowIdentifier::from_wayland(&self.wl_surface.borrow()); | ||
Some(zbus::open_file( | ||
Default::default(), | ||
crate::IdleHandle(self.get_idle_handle()), | ||
options, | ||
)) | ||
} | ||
|
||
fn save_as(&self, options: FileDialogOptions) -> Option<FileDialogToken> { | ||
// FIXME: current ashpd has issues with wayland versions | ||
//let id = ashpd::WindowIdentifier::from_wayland(&self.wl_surface.borrow()); | ||
Some(zbus::save_file( | ||
Default::default(), | ||
crate::IdleHandle(self.get_idle_handle()), | ||
options, | ||
)) | ||
} | ||
|
||
pub fn schedule_deferred_task(&self, task: DeferredTask) { | ||
tracing::trace!("scedule_deferred_task initiated"); | ||
self.deferred_tasks.borrow_mut().push_back(task); | ||
|
@@ -625,6 +654,16 @@ impl Handle for Dead { | |
tracing::warn!("invalidate_rect invoked on a dead surface") | ||
} | ||
|
||
fn open_file(&self, _options: FileDialogOptions) -> Option<FileDialogToken> { | ||
tracing::warn!("open_file invoked on a dead surface"); | ||
None | ||
} | ||
|
||
fn save_as(&self, _options: FileDialogOptions) -> Option<FileDialogToken> { | ||
tracing::warn!("save_as invoked on a dead surface"); | ||
None | ||
} | ||
|
||
fn run_idle(&self) { | ||
tracing::warn!("run_idle invoked on a dead surface") | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor question: do we need to add these to every surface or can we just use the already implemented data() method to access the implementations directly vs expanding the api surface of handle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was kinda wondering that too, but it seemed better to just follow what all the other methods were doing... I'd be happy to change it, though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the PR is fine strictly speaking as is; since you're basically following the pattern every backend is doing.... its just a nit i have with druids internals. these methods shouldn't need to be nested as deeply into the backends as they are. a backend really should not care about opening file dialogs. i've covered the topic in detail in other issues.
looks like you're only using the idle handle. which is already exposed, and long term the wayland id. I'd try to keep the file stuff as lightly coupled as possible personally. but rather see functionality implemented than worry about architectural issues that impact every backend currently =)