Skip to content
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

fix: use dummy window for clipboard #203

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions winit/src/platform_specific/wayland/sctk_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,16 +666,14 @@ impl SctkEvent {
LayerSurfaceEventVariant::Done => {
if let Some(id) = surface_ids.remove(&surface.id()) {
if let Some(w) = window_manager.remove(id.inner()) {
clipboard.register_dnd_destination(
DndSurface(Arc::new(Box::new(w.raw.clone()))),
Vec::new(),
);
if clipboard
.window_id()
.is_some_and(|id| w.raw.id() == id)
{
clipboard.register_dnd_destination(
DndSurface(Arc::new(Box::new(
w.raw.clone(),
))),
Vec::new(),
);
*clipboard = Clipboard::unconnected();
}
}
Expand Down
13 changes: 12 additions & 1 deletion winit/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use crate::futures::{Executor, Runtime};
use crate::graphics;
use crate::graphics::{compositor, Compositor};
use crate::platform_specific;

Check warning on line 30 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unused import: `crate::platform_specific`

Check warning on line 30 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unused import: `crate::platform_specific`

Check warning on line 30 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unused import: `crate::platform_specific`

Check warning on line 30 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unused import: `crate::platform_specific`
use crate::runtime::user_interface::{self, UserInterface};
use crate::runtime::Debug;
use crate::runtime::{self, Action, Task};
Expand Down Expand Up @@ -245,6 +245,7 @@
sender: mpsc::UnboundedSender<Event<Message>>,
receiver: mpsc::UnboundedReceiver<Control>,
error: Option<Error>,
proxy: Proxy<Message>,

#[cfg(target_arch = "wasm32")]
is_booted: std::rc::Rc<std::cell::RefCell<bool>>,
Expand Down Expand Up @@ -274,6 +275,7 @@
sender: event_sender,
receiver: control_receiver,
error: None,
proxy: proxy.clone(),

#[cfg(target_arch = "wasm32")]
is_booted: std::rc::Rc::new(std::cell::RefCell::new(false)),
Expand Down Expand Up @@ -374,10 +376,11 @@

#[cfg(target_arch = "wasm32")]
{
use winit::platform::web::WindowExtWebSys;

Check failure on line 379 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unresolved import `winit::platform::web::WindowExtWebSys`

Check failure on line 379 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unresolved import `winit::platform::web::WindowExtWebSys`

Check failure on line 379 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unresolved import `winit::platform::web::WindowExtWebSys`

Check failure on line 379 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unresolved import `winit::platform::web::WindowExtWebSys`
self.canvas = window.canvas();

Check failure on line 380 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

no method named `canvas` found for struct `std::sync::Arc<dyn winit::window::Window>` in the current scope

Check failure on line 380 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

no method named `canvas` found for struct `std::sync::Arc<dyn winit::window::Window>` in the current scope

Check failure on line 380 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

no method named `canvas` found for struct `std::sync::Arc<dyn winit::window::Window>` in the current scope

Check failure on line 380 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

no method named `canvas` found for struct `std::sync::Arc<dyn winit::window::Window>` in the current scope
}

let proxy = self.proxy.raw.clone();
let finish_boot = async move {
let mut compositor =
C::new(graphics_settings, window.clone()).await?;
Expand All @@ -390,6 +393,13 @@
.send(Boot {
compositor,
is_wayland,
clipboard: Clipboard::connect(
window,
crate::clipboard::ControlSender {
sender: control_sender,
proxy,
},
),
})
.ok()
.expect("Send boot event");
Expand Down Expand Up @@ -491,14 +501,14 @@

#[cfg(target_arch = "wasm32")]
let window_attributes = {
use winit::platform::web::WindowAttributesExtWebSys;

Check failure on line 504 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unresolved import `winit::platform::web::WindowAttributesExtWebSys`

Check failure on line 504 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unresolved import `winit::platform::web::WindowAttributesExtWebSys`

Check failure on line 504 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unresolved import `winit::platform::web::WindowAttributesExtWebSys`

Check failure on line 504 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unresolved import `winit::platform::web::WindowAttributesExtWebSys`
window_attributes
.with_canvas(self.canvas.take())

Check failure on line 506 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

no method named `with_canvas` found for struct `WindowAttributes` in the current scope

Check failure on line 506 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

no method named `with_canvas` found for struct `WindowAttributes` in the current scope

Check failure on line 506 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

no method named `with_canvas` found for struct `WindowAttributes` in the current scope

Check failure on line 506 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

no method named `with_canvas` found for struct `WindowAttributes` in the current scope
};

log::info!("Window attributes for id `{id:#?}`: {window_attributes:#?}");

let window = Arc::from(

Check failure on line 511 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

type annotations needed for `std::sync::Arc<_, _>`

Check failure on line 511 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

type annotations needed for `std::sync::Arc<_, _>`

Check failure on line 511 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

type annotations needed for `std::sync::Arc<_, _>`

Check failure on line 511 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

type annotations needed for `std::sync::Arc<_, _>`
event_loop
.create_window(window_attributes)
.expect("Create window"),
Expand All @@ -506,7 +516,7 @@

#[cfg(target_arch = "wasm32")]
{
use winit::platform::web::WindowExtWebSys;

Check failure on line 519 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unresolved import `winit::platform::web::WindowExtWebSys`

Check failure on line 519 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unresolved import `winit::platform::web::WindowExtWebSys`

Check failure on line 519 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unresolved import `winit::platform::web::WindowExtWebSys`

Check failure on line 519 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unresolved import `winit::platform::web::WindowExtWebSys`

let canvas = window
.canvas()
Expand Down Expand Up @@ -626,8 +636,8 @@

#[cfg(target_arch = "wasm32")]
{
use winit::platform::web::EventLoopExtWebSys;

Check failure on line 639 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unresolved import `winit::platform::web::EventLoopExtWebSys`

Check failure on line 639 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unresolved import `winit::platform::web::EventLoopExtWebSys`

Check failure on line 639 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unresolved import `winit::platform::web::EventLoopExtWebSys`

Check failure on line 639 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unresolved import `winit::platform::web::EventLoopExtWebSys`
let _ = event_loop.spawn_app(runner);

Check failure on line 640 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

no method named `spawn_app` found for struct `EventLoop` in the current scope

Check failure on line 640 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

no method named `spawn_app` found for struct `EventLoop` in the current scope

Check failure on line 640 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

no method named `spawn_app` found for struct `EventLoop` in the current scope

Check failure on line 640 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

no method named `spawn_app` found for struct `EventLoop` in the current scope

Ok(())
}
Expand All @@ -636,6 +646,7 @@
struct Boot<C> {
compositor: C,
is_wayland: bool,
clipboard: Clipboard,
}

pub(crate) enum Event<Message: 'static> {
Expand Down Expand Up @@ -689,7 +700,7 @@
boot: oneshot::Receiver<Boot<C>>,
mut event_receiver: mpsc::UnboundedReceiver<Event<P::Message>>,
mut control_sender: mpsc::UnboundedSender<Control>,
display_handle: OwnedDisplayHandle,

Check warning on line 703 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unused variable: `display_handle`

Check warning on line 703 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unused variable: `display_handle`

Check warning on line 703 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unused variable: `display_handle`

Check warning on line 703 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unused variable: `display_handle`
is_daemon: bool,
) where
P: Program + 'static,
Expand All @@ -701,7 +712,8 @@

let Boot {
mut compositor,
is_wayland,

Check warning on line 715 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unused variable: `is_wayland`

Check warning on line 715 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unused variable: `is_wayland`

Check warning on line 715 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unused variable: `is_wayland`

Check warning on line 715 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unused variable: `is_wayland`
mut clipboard,
} = boot.await.expect("Receive boot");

let mut platform_specific_handler =
Expand Down Expand Up @@ -781,7 +793,6 @@
rustc_hash::FxBuildHasher,
>,
> = ManuallyDrop::new(FxHashMap::default());
let mut clipboard = Clipboard::unconnected();

let mut cur_dnd_surface: Option<window::Id> = None;

Expand All @@ -797,7 +808,7 @@
let Some(event) = event else {
break;
};
let mut rebuild_a11y_tree = false;

Check warning on line 811 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

variable `rebuild_a11y_tree` is assigned to, but never used

Check warning on line 811 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

variable `rebuild_a11y_tree` is assigned to, but never used

Check warning on line 811 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

variable `rebuild_a11y_tree` is assigned to, but never used

Check warning on line 811 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

variable `rebuild_a11y_tree` is assigned to, but never used

match event {
Event::StartDnd => {
Expand Down Expand Up @@ -1093,7 +1104,7 @@
is_window_opening = false;
}
Event::UserEvent(action) => {
rebuild_a11y_tree = true;

Check warning on line 1107 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

value assigned to `rebuild_a11y_tree` is never read

Check warning on line 1107 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

value assigned to `rebuild_a11y_tree` is never read
let exited = run_action(
action,
&program,
Expand Down Expand Up @@ -1244,7 +1255,7 @@
{
let logical_size = window.state.logical_size();
debug.layout_started();
let mut ui = user_interfaces

Check warning on line 1258 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

variable does not need to be mutable

Check warning on line 1258 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

variable does not need to be mutable
.remove(&id)
.expect("Remove user interface")
.relayout(logical_size, &mut window.renderer);
Expand Down Expand Up @@ -1422,7 +1433,7 @@
}
}
}
_ => {}

Check warning on line 1436 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unreachable pattern

Check warning on line 1436 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unreachable pattern

Check warning on line 1436 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unreachable pattern

Check warning on line 1436 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unreachable pattern
}
}
Event::AboutToWait => {
Expand Down Expand Up @@ -1574,7 +1585,7 @@

window.request_redraw();
}
rebuild_a11y_tree = true;

Check warning on line 1588 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

value assigned to `rebuild_a11y_tree` is never read

Check warning on line 1588 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

value assigned to `rebuild_a11y_tree` is never read

user_interfaces = ManuallyDrop::new(build_user_interfaces(
&program,
Expand Down
Loading