diff --git a/src/wayland/data_device/dnd_grab.rs b/src/wayland/data_device/dnd_grab.rs index c46e822..3ff7791 100644 --- a/src/wayland/data_device/dnd_grab.rs +++ b/src/wayland/data_device/dnd_grab.rs @@ -300,7 +300,11 @@ fn implement_dnd_data_offer( preferred_action, } => { let preferred_action = preferred_action; - if ![DndAction::Move, DndAction::Copy, DndAction::Ask].contains(&preferred_action) { + + // preferred_action must only contain one bitflag at the same time + if ![DndAction::None, DndAction::Move, DndAction::Copy, DndAction::Ask] + .contains(&preferred_action) + { offer.as_ref().post_error( wl_data_offer::Error::InvalidAction as u32, "Invalid preferred action.".into(), @@ -312,7 +316,8 @@ fn implement_dnd_data_offer( data.chosen_action = (&mut *action_choice.borrow_mut())(possible_actions, preferred_action); // check that the user provided callback respects that one precise action should be chosen debug_assert!( - [DndAction::Move, DndAction::Copy, DndAction::Ask].contains(&data.chosen_action) + [DndAction::None, DndAction::Move, DndAction::Copy, DndAction::Ask] + .contains(&data.chosen_action) ); offer.action(data.chosen_action); source.action(data.chosen_action); diff --git a/src/wayland/data_device/server_dnd_grab.rs b/src/wayland/data_device/server_dnd_grab.rs index 11a08dd..454d1d7 100644 --- a/src/wayland/data_device/server_dnd_grab.rs +++ b/src/wayland/data_device/server_dnd_grab.rs @@ -295,7 +295,11 @@ where preferred_action, } => { let preferred_action = preferred_action; - if ![DndAction::Move, DndAction::Copy, DndAction::Ask].contains(&preferred_action) { + + // preferred_action must only contain one bitflag at the same time + if ![DndAction::None, DndAction::Move, DndAction::Copy, DndAction::Ask] + .contains(&preferred_action) + { offer.as_ref().post_error( wl_data_offer::Error::InvalidAction as u32, "Invalid preferred action.".into(), @@ -305,7 +309,8 @@ where data.chosen_action = (&mut *action_choice.borrow_mut())(possible_actions, preferred_action); // check that the user provided callback respects that one precise action should be chosen debug_assert!( - [DndAction::Move, DndAction::Copy, DndAction::Ask].contains(&data.chosen_action) + [DndAction::None, DndAction::Move, DndAction::Copy, DndAction::Ask] + .contains(&data.chosen_action) ); offer.action(data.chosen_action); (&mut *callback.borrow_mut())(ServerDndEvent::Action(data.chosen_action));