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
|
- uses: actions/checkout@master
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test --verbose
|
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]
|
[dependencies]
|
||||||
raw-window-handle = "0.3"
|
raw-window-handle = "0.3"
|
||||||
|
thiserror = "1.0"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
clipboard-win = { version = "4.0", features = ["std"] }
|
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"]
|
#[path = "platform/android.rs"]
|
||||||
mod platform;
|
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 raw_window_handle::HasRawWindowHandle;
|
||||||
use std::error::Error;
|
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 {
|
if event.target == self.context.atoms.targets {
|
||||||
let data = [self.context.atoms.targets, target];
|
let data = [self.context.atoms.targets, target];
|
||||||
|
|
||||||
self.context.connection.change_property32(
|
self.context
|
||||||
xproto::PropMode::REPLACE,
|
.connection
|
||||||
event.requestor,
|
.change_property32(
|
||||||
event.property,
|
xproto::PropMode::REPLACE,
|
||||||
xproto::AtomEnum::ATOM,
|
event.requestor,
|
||||||
&data,
|
event.property,
|
||||||
)
|
xproto::AtomEnum::ATOM,
|
||||||
.expect("Change property");
|
&data,
|
||||||
|
)
|
||||||
|
.expect("Change property");
|
||||||
} else {
|
} else {
|
||||||
let _ = self.context.connection.change_property8(
|
let _ = self
|
||||||
xproto::PropMode::REPLACE,
|
.context
|
||||||
event.requestor,
|
.connection
|
||||||
event.property,
|
.change_property8(
|
||||||
target,
|
xproto::PropMode::REPLACE,
|
||||||
value,
|
event.requestor,
|
||||||
)
|
event.property,
|
||||||
.expect("Change property");
|
target,
|
||||||
|
value,
|
||||||
|
)
|
||||||
|
.expect("Change property");
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = xproto::send_event(
|
let _ = xproto::send_event(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue