-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial impl of org.gnome.Shell.Screenshot
Enough to make the portal all-outputs screenshot work. With this, Flameshot kinda-works.
- Loading branch information
Showing
6 changed files
with
198 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use std::path::PathBuf; | ||
|
||
use smithay::reexports::calloop; | ||
use zbus::{dbus_interface, fdo}; | ||
|
||
pub struct Screenshot { | ||
to_niri: calloop::channel::Sender<ScreenshotToNiri>, | ||
from_niri: async_channel::Receiver<NiriToScreenshot>, | ||
} | ||
|
||
pub enum ScreenshotToNiri { | ||
TakeScreenshot { include_cursor: bool }, | ||
} | ||
|
||
pub enum NiriToScreenshot { | ||
ScreenshotResult(Option<PathBuf>), | ||
} | ||
|
||
#[dbus_interface(name = "org.gnome.Shell.Screenshot")] | ||
impl Screenshot { | ||
async fn screenshot( | ||
&self, | ||
include_cursor: bool, | ||
_flash: bool, | ||
_filename: PathBuf, | ||
) -> fdo::Result<(bool, PathBuf)> { | ||
if let Err(err) = self | ||
.to_niri | ||
.send(ScreenshotToNiri::TakeScreenshot { include_cursor }) | ||
{ | ||
warn!("error sending message to niri: {err:?}"); | ||
return Err(fdo::Error::Failed("internal error".to_owned())); | ||
} | ||
|
||
let filename = match self.from_niri.recv().await { | ||
Ok(NiriToScreenshot::ScreenshotResult(Some(filename))) => filename, | ||
Ok(NiriToScreenshot::ScreenshotResult(None)) => { | ||
return Err(fdo::Error::Failed("internal error".to_owned())); | ||
} | ||
Err(err) => { | ||
warn!("error receiving message from niri: {err:?}"); | ||
return Err(fdo::Error::Failed("internal error".to_owned())); | ||
} | ||
}; | ||
|
||
Ok((true, filename)) | ||
} | ||
} | ||
|
||
impl Screenshot { | ||
pub fn new( | ||
to_niri: calloop::channel::Sender<ScreenshotToNiri>, | ||
from_niri: async_channel::Receiver<NiriToScreenshot>, | ||
) -> Self { | ||
Self { to_niri, from_niri } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod gnome_shell_screenshot; | ||
pub mod mutter_display_config; | ||
pub mod mutter_screen_cast; | ||
pub mod mutter_service_channel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters