Merge pull request #18 from andraantariksa/dummy-platform
Add dummy platform 🌮
This commit is contained in:
commit
f27a89054e
5 changed files with 74 additions and 16 deletions
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
|
|
@ -14,3 +14,7 @@ jobs:
|
|||
- uses: actions/checkout@master
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
||||
- name: Add Wasm target
|
||||
run: rustup target add wasm32-unknown-unknown
|
||||
- name: Run tests on Wasm
|
||||
run: cargo build --verbose --target wasm32-unknown-unknown
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ categories = ["gui"]
|
|||
|
||||
[dependencies]
|
||||
raw-window-handle = "0.3"
|
||||
thiserror = "1.0"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
clipboard-win = { version = "4.0", features = ["std"] }
|
||||
|
|
|
|||
18
src/lib.rs
18
src/lib.rs
|
|
@ -26,6 +26,24 @@ mod platform;
|
|||
#[path = "platform/android.rs"]
|
||||
mod platform;
|
||||
|
||||
#[cfg(not(any(
|
||||
all(
|
||||
unix,
|
||||
not(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "android",
|
||||
target_os = "emscripten"
|
||||
))
|
||||
),
|
||||
target_os = "windows",
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "android"
|
||||
)))]
|
||||
#[path = "platform/dummy.rs"]
|
||||
mod platform;
|
||||
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
use std::error::Error;
|
||||
|
||||
|
|
|
|||
30
src/platform/dummy.rs
Normal file
30
src/platform/dummy.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use crate::ClipboardProvider;
|
||||
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
|
||||
struct Dummy;
|
||||
|
||||
pub fn connect<W: HasRawWindowHandle>(
|
||||
_window: &W,
|
||||
) -> Result<Box<dyn ClipboardProvider>, Box<dyn std::error::Error>> {
|
||||
Ok(Box::new(Dummy))
|
||||
}
|
||||
|
||||
impl ClipboardProvider for Dummy {
|
||||
fn read(&self) -> Result<String, Box<dyn std::error::Error>> {
|
||||
Err(Box::new(Error::Unimplemented))
|
||||
}
|
||||
|
||||
fn write(
|
||||
&mut self,
|
||||
_contents: String,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
Err(Box::new(Error::Unimplemented))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, thiserror::Error)]
|
||||
enum Error {
|
||||
#[error("unimplemented")]
|
||||
Unimplemented,
|
||||
}
|
||||
|
|
@ -360,23 +360,28 @@ impl Worker {
|
|||
if event.target == self.context.atoms.targets {
|
||||
let data = [self.context.atoms.targets, target];
|
||||
|
||||
self.context.connection.change_property32(
|
||||
xproto::PropMode::REPLACE,
|
||||
event.requestor,
|
||||
event.property,
|
||||
xproto::AtomEnum::ATOM,
|
||||
&data,
|
||||
)
|
||||
.expect("Change property");
|
||||
self.context
|
||||
.connection
|
||||
.change_property32(
|
||||
xproto::PropMode::REPLACE,
|
||||
event.requestor,
|
||||
event.property,
|
||||
xproto::AtomEnum::ATOM,
|
||||
&data,
|
||||
)
|
||||
.expect("Change property");
|
||||
} else {
|
||||
let _ = self.context.connection.change_property8(
|
||||
xproto::PropMode::REPLACE,
|
||||
event.requestor,
|
||||
event.property,
|
||||
target,
|
||||
value,
|
||||
)
|
||||
.expect("Change property");
|
||||
let _ = self
|
||||
.context
|
||||
.connection
|
||||
.change_property8(
|
||||
xproto::PropMode::REPLACE,
|
||||
event.requestor,
|
||||
event.property,
|
||||
target,
|
||||
value,
|
||||
)
|
||||
.expect("Change property");
|
||||
}
|
||||
|
||||
let _ = xproto::send_event(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue