1
0
Fork 0
forked from wry/wry

autocommit 2022-01-08 19:02:10 CET

This commit is contained in:
Julian Orth 2022-01-08 19:02:11 +01:00
parent d061a5c313
commit 3336f1ab6a
37 changed files with 243 additions and 136 deletions

View file

@ -3,6 +3,7 @@ pub mod wl_callback;
pub mod wl_compositor;
pub mod wl_data_device;
pub mod wl_data_device_manager;
pub mod wl_data_offer;
pub mod wl_data_source;
pub mod wl_display;
pub mod wl_output;
@ -15,4 +16,3 @@ pub mod wl_subcompositor;
pub mod wl_surface;
pub mod xdg_positioner;
pub mod xdg_wm_base;
pub mod wl_data_offer;

View file

@ -30,6 +30,7 @@ pub struct WlBuffer {
}
impl WlBuffer {
#[allow(clippy::too_many_arguments)]
pub fn new(
id: WlBufferId,
client: &Rc<Client>,

View file

@ -17,7 +17,8 @@ const MOTION: u32 = 4;
const DROP: u32 = 5;
const SELECTION: u32 = 5;
#[allow(dead_code)] const ROLE: u32 = 0;
#[allow(dead_code)]
const ROLE: u32 = 0;
id!(WlDataDeviceId);

View file

@ -1,6 +1,7 @@
use crate::client::{ClientError, EventFormatter, RequestParser};
use crate::fixed::Fixed;
use crate::ifs::wl_data_device::{WlDataDevice, DATA_OFFER, DROP, ENTER, LEAVE, MOTION, SELECTION};
use crate::ifs::wl_data_offer::WlDataOfferId;
use crate::ifs::wl_data_source::WlDataSourceId;
use crate::ifs::wl_surface::WlSurfaceId;
use crate::object::Object;
@ -8,7 +9,6 @@ use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
use std::fmt::{Debug, Formatter};
use std::rc::Rc;
use thiserror::Error;
use crate::ifs::wl_data_offer::WlDataOfferId;
#[derive(Debug, Error)]
pub enum WlDataDeviceError {

View file

@ -2,20 +2,24 @@ mod types;
use crate::client::{AddObj, Client};
use crate::globals::{Global, GlobalName};
use crate::ifs::wl_data_device::WlDataDevice;
use crate::ifs::wl_data_source::WlDataSource;
use crate::object::{Interface, Object, ObjectId};
use crate::utils::buffd::MsgParser;
use std::rc::Rc;
pub use types::*;
use crate::ifs::wl_data_device::WlDataDevice;
use crate::ifs::wl_data_source::WlDataSource;
const CREATE_DATA_SOURCE: u32 = 0;
const GET_DATA_DEVICE: u32 = 1;
#[allow(dead_code)] const DND_NONE: u32 = 0;
#[allow(dead_code)] const DND_COPY: u32 = 1;
#[allow(dead_code)] const DND_MOVE: u32 = 2;
#[allow(dead_code)] const DND_ASK: u32 = 4;
#[allow(dead_code)]
const DND_NONE: u32 = 0;
#[allow(dead_code)]
const DND_COPY: u32 = 1;
#[allow(dead_code)]
const DND_MOVE: u32 = 2;
#[allow(dead_code)]
const DND_ASK: u32 = 4;
id!(WlDataDeviceManagerId);

View file

@ -1,10 +1,10 @@
use crate::client::{ClientError, RequestParser};
use crate::ifs::wl_data_device::WlDataDeviceId;
use crate::ifs::wl_data_source::WlDataSourceId;
use crate::ifs::wl_seat::WlSeatId;
use crate::utils::buffd::{MsgParser, MsgParserError};
use std::fmt::{Debug, Formatter};
use thiserror::Error;
use crate::ifs::wl_data_device::WlDataDeviceId;
#[derive(Debug, Error)]
pub enum WlDataDeviceManagerError {

View file

@ -16,10 +16,14 @@ const OFFER: u32 = 0;
const SOURCE_ACTIONS: u32 = 1;
const ACTION: u32 = 2;
#[allow(dead_code)] const INVALID_FINISH: u32 = 0;
#[allow(dead_code)] const INVALID_ACTION_MASK: u32 = 1;
#[allow(dead_code)] const INVALID_ACTION: u32 = 2;
#[allow(dead_code)] const INVALID_OFFER: u32 = 3;
#[allow(dead_code)]
const INVALID_FINISH: u32 = 0;
#[allow(dead_code)]
const INVALID_ACTION_MASK: u32 = 1;
#[allow(dead_code)]
const INVALID_ACTION: u32 = 2;
#[allow(dead_code)]
const INVALID_OFFER: u32 = 3;
id!(WlDataOfferId);

View file

@ -1,4 +1,5 @@
use crate::client::{ClientError, EventFormatter, RequestParser};
use crate::ifs::wl_data_offer::{WlDataOffer, ACTION, OFFER, SOURCE_ACTIONS};
use crate::object::Object;
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
use bstr::{BStr, BString};
@ -6,7 +7,6 @@ use std::fmt::{Debug, Formatter};
use std::rc::Rc;
use thiserror::Error;
use uapi::OwnedFd;
use crate::ifs::wl_data_offer::{ACTION, OFFER, SOURCE_ACTIONS, WlDataOffer};
#[derive(Debug, Error)]
pub enum WlDataOfferError {
@ -89,7 +89,11 @@ impl<'a> RequestParser<'a> for Accept<'a> {
}
impl Debug for Accept<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "accept(serial: {}, mime_type: {:?})", self.serial, self.mime_type)
write!(
f,
"accept(serial: {}, mime_type: {:?})",
self.serial, self.mime_type
)
}
}
@ -107,7 +111,12 @@ impl<'a> RequestParser<'a> for Receive<'a> {
}
impl Debug for Receive<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "receive(mime_type: {:?}, fd: {})", self.mime_type, self.fd.raw())
write!(
f,
"receive(mime_type: {:?}, fd: {})",
self.mime_type,
self.fd.raw()
)
}
}
@ -149,7 +158,11 @@ impl<'a> RequestParser<'a> for SetActions {
}
impl Debug for SetActions {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "set_actions(dnd_actions: {}, preferred_action: {})", self.dnd_actions, self.preferred_action)
write!(
f,
"set_actions(dnd_actions: {}, preferred_action: {})",
self.dnd_actions, self.preferred_action
)
}
}
@ -186,11 +199,7 @@ impl EventFormatter for SourceActions {
}
impl Debug for SourceActions {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"source_actions(source_actions: {})",
self.source_actions,
)
write!(f, "source_actions(source_actions: {})", self.source_actions,)
}
}
@ -200,8 +209,7 @@ pub(super) struct Action {
}
impl EventFormatter for Action {
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
fmt.header(self.obj.id, ACTION)
.uint(self.dnd_action);
fmt.header(self.obj.id, ACTION).uint(self.dnd_action);
}
fn obj(&self) -> &dyn Object {
&*self.obj
@ -209,10 +217,6 @@ impl EventFormatter for Action {
}
impl Debug for Action {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"action(dnd_action: {})",
self.dnd_action,
)
write!(f, "action(dnd_action: {})", self.dnd_action,)
}
}

View file

@ -17,8 +17,10 @@ const DND_DROP_PERFORMED: u32 = 4;
const DND_FINISHED: u32 = 5;
const ACTION: u32 = 5;
#[allow(dead_code)] const INVALID_ACTION_MASK: u32 = 0;
#[allow(dead_code)] const INVALID_SOURCE: u32 = 1;
#[allow(dead_code)]
const INVALID_ACTION_MASK: u32 = 0;
#[allow(dead_code)]
const INVALID_SOURCE: u32 = 1;
id!(WlDataSourceId);

View file

@ -16,7 +16,8 @@ const DELETE_ID: u32 = 1;
const INVALID_OBJECT: u32 = 0;
const INVALID_METHOD: u32 = 1;
#[allow(dead_code)] const NO_MEMORY: u32 = 2;
#[allow(dead_code)]
const NO_MEMORY: u32 = 2;
const IMPLEMENTATION: u32 = 3;
pub struct WlDisplay {
@ -45,7 +46,7 @@ impl WlDisplay {
async fn sync(&self, parser: MsgParser<'_, '_>) -> Result<(), SyncError> {
let sync: Sync = self.client.parse(self, parser)?;
let cb = Rc::new(WlCallback::new(sync.callback.into()));
let cb = Rc::new(WlCallback::new(sync.callback));
self.client.add_client_obj(&cb)?;
self.client.event(cb.done()).await?;
self.client.remove_obj(&*cb).await?;

View file

@ -22,23 +22,36 @@ const DONE: u32 = 2;
const SCALE: u32 = 3;
const SP_UNKNOWN: i32 = 0;
#[allow(dead_code)] const SP_NONE: i32 = 1;
#[allow(dead_code)] const SP_HORIZONTAL_RGB: i32 = 2;
#[allow(dead_code)] const SP_HORIZONTAL_BGR: i32 = 3;
#[allow(dead_code)] const SP_VERTICAL_RGB: i32 = 4;
#[allow(dead_code)] const SP_VERTICAL_BGR: i32 = 5;
#[allow(dead_code)]
const SP_NONE: i32 = 1;
#[allow(dead_code)]
const SP_HORIZONTAL_RGB: i32 = 2;
#[allow(dead_code)]
const SP_HORIZONTAL_BGR: i32 = 3;
#[allow(dead_code)]
const SP_VERTICAL_RGB: i32 = 4;
#[allow(dead_code)]
const SP_VERTICAL_BGR: i32 = 5;
const TF_NORMAL: i32 = 0;
#[allow(dead_code)] const TF_90: i32 = 1;
#[allow(dead_code)] const TF_180: i32 = 2;
#[allow(dead_code)] const TF_270: i32 = 3;
#[allow(dead_code)] const TF_FLIPPED: i32 = 4;
#[allow(dead_code)] const TF_FLIPPED_90: i32 = 5;
#[allow(dead_code)] const TF_FLIPPED_180: i32 = 6;
#[allow(dead_code)] const TF_FLIPPED_270: i32 = 7;
#[allow(dead_code)]
const TF_90: i32 = 1;
#[allow(dead_code)]
const TF_180: i32 = 2;
#[allow(dead_code)]
const TF_270: i32 = 3;
#[allow(dead_code)]
const TF_FLIPPED: i32 = 4;
#[allow(dead_code)]
const TF_FLIPPED_90: i32 = 5;
#[allow(dead_code)]
const TF_FLIPPED_180: i32 = 6;
#[allow(dead_code)]
const TF_FLIPPED_270: i32 = 7;
const MODE_CURRENT: u32 = 1;
#[allow(dead_code)] const MODE_PREFERRED: u32 = 2;
#[allow(dead_code)]
const MODE_PREFERRED: u32 = 2;
pub struct WlOutputGlobal {
name: GlobalName,

View file

@ -36,9 +36,11 @@ const NAME: u32 = 1;
const POINTER: u32 = 1;
const KEYBOARD: u32 = 2;
#[allow(dead_code)] const TOUCH: u32 = 4;
#[allow(dead_code)]
const TOUCH: u32 = 4;
#[allow(dead_code)] const MISSING_CAPABILITY: u32 = 0;
#[allow(dead_code)]
const MISSING_CAPABILITY: u32 = 0;
pub struct WlSeatGlobal {
name: GlobalName,
@ -178,10 +180,10 @@ impl WlSeatGlobal {
x += Fixed::from_int(ee.x1);
y += Fixed::from_int(ee.y1);
if enter {
self.tl_pointer_event(&tl, |p| p.enter(0, tl.surface.surface.surface.id, x, y))
self.tl_pointer_event(tl, |p| p.enter(0, tl.surface.surface.surface.id, x, y))
.await;
}
self.tl_pointer_event(&tl, |p| p.motion(0, x, y)).await;
self.tl_pointer_event(tl, |p| p.motion(0, x, y)).await;
}
}
@ -237,9 +239,7 @@ impl WlSeatGlobal {
client.event(obj.capabilities()).await?;
{
let mut bindings = self.bindings.borrow_mut();
let bindings = bindings
.entry(client.id)
.or_insert_with(|| Default::default());
let bindings = bindings.entry(client.id).or_insert_with(Default::default);
bindings.insert(id, obj.clone());
}
Ok(())

View file

@ -18,11 +18,14 @@ const KEY: u32 = 3;
const MODIFIERS: u32 = 4;
const REPEAT_INFO: u32 = 5;
#[allow(dead_code)] const NO_KEYMAP: u32 = 0;
#[allow(dead_code)]
const NO_KEYMAP: u32 = 0;
pub(super) const XKB_V1: u32 = 1;
#[allow(dead_code)] const RELEASED: u32 = 0;
#[allow(dead_code)] const PRESSED: u32 = 1;
#[allow(dead_code)]
const RELEASED: u32 = 0;
#[allow(dead_code)]
const PRESSED: u32 = 1;
id!(WlKeyboardId);

View file

@ -22,7 +22,8 @@ const AXIS_SOURCE: u32 = 6;
const AXIS_STOP: u32 = 7;
const AXIS_DISCRETE: u32 = 8;
#[allow(dead_code)] const ROLE: u32 = 0;
#[allow(dead_code)]
const ROLE: u32 = 0;
pub(super) const RELEASED: u32 = 0;
pub(super) const PRESSED: u32 = 1;
@ -30,10 +31,14 @@ pub(super) const PRESSED: u32 = 1;
pub(super) const VERTICAL_SCROLL: u32 = 0;
pub(super) const HORIZONTAL_SCROLL: u32 = 1;
#[allow(dead_code)] const WHEEL: u32 = 0;
#[allow(dead_code)] const FINGER: u32 = 1;
#[allow(dead_code)] const CONTINUOUS: u32 = 2;
#[allow(dead_code)] const WHEEL_TILT: u32 = 3;
#[allow(dead_code)]
const WHEEL: u32 = 0;
#[allow(dead_code)]
const FINGER: u32 = 1;
#[allow(dead_code)]
const CONTINUOUS: u32 = 2;
#[allow(dead_code)]
const WHEEL_TILT: u32 = 3;
id!(WlPointerId);

View file

@ -9,13 +9,20 @@ pub use types::*;
const RELEASE: u32 = 0;
#[allow(dead_code)] const DOWN: u32 = 0;
#[allow(dead_code)] const UP: u32 = 1;
#[allow(dead_code)] const MOTION: u32 = 2;
#[allow(dead_code)] const FRAME: u32 = 3;
#[allow(dead_code)] const CANCEL: u32 = 4;
#[allow(dead_code)] const SHAPE: u32 = 5;
#[allow(dead_code)] const ORIENTATION: u32 = 6;
#[allow(dead_code)]
const DOWN: u32 = 0;
#[allow(dead_code)]
const UP: u32 = 1;
#[allow(dead_code)]
const MOTION: u32 = 2;
#[allow(dead_code)]
const FRAME: u32 = 3;
#[allow(dead_code)]
const CANCEL: u32 = 4;
#[allow(dead_code)]
const SHAPE: u32 = 5;
#[allow(dead_code)]
const ORIENTATION: u32 = 6;
id!(WlTouchId);

View file

@ -11,7 +11,8 @@ pub use types::*;
const DESTROY: u32 = 0;
const GET_SUBSURFACE: u32 = 1;
#[allow(dead_code)] const BAD_SURFACE: u32 = 0;
#[allow(dead_code)]
const BAD_SURFACE: u32 = 0;
id!(WlSubcompositorId);

View file

@ -33,12 +33,17 @@ const SET_BUFFER_TRANSFORM: u32 = 7;
const SET_BUFFER_SCALE: u32 = 8;
const DAMAGE_BUFFER: u32 = 9;
#[allow(dead_code)] const ENTER: u32 = 0;
#[allow(dead_code)] const LEAVE: u32 = 1;
#[allow(dead_code)]
const ENTER: u32 = 0;
#[allow(dead_code)]
const LEAVE: u32 = 1;
#[allow(dead_code)] const INVALID_SCALE: u32 = 0;
#[allow(dead_code)] const INVALID_TRANSFORM: u32 = 1;
#[allow(dead_code)] const INVALID_SIZE: u32 = 2;
#[allow(dead_code)]
const INVALID_SCALE: u32 = 0;
#[allow(dead_code)]
const INVALID_TRANSFORM: u32 = 1;
#[allow(dead_code)]
const INVALID_SIZE: u32 = 2;
id!(WlSurfaceId);

View file

@ -17,7 +17,8 @@ const PLACE_BELOW: u32 = 3;
const SET_SYNC: u32 = 4;
const SET_DESYNC: u32 = 5;
#[allow(dead_code)] const BAD_SURFACE: u32 = 0;
#[allow(dead_code)]
const BAD_SURFACE: u32 = 0;
const MAX_SUBSURFACE_DEPTH: u32 = 100;
@ -108,7 +109,7 @@ impl WlSubsurface {
}
let node = {
let mut data = self.parent.children.borrow_mut();
let data = data.get_or_insert_with(|| Default::default());
let data = data.get_or_insert_with(Default::default);
data.subsurfaces
.insert(self.surface.id, self.surface.clone());
data.above.add_first(StackElement {

View file

@ -24,9 +24,11 @@ const ACK_CONFIGURE: u32 = 4;
const CONFIGURE: u32 = 0;
#[allow(dead_code)] const NOT_CONSTRUCTED: u32 = 1;
#[allow(dead_code)]
const NOT_CONSTRUCTED: u32 = 1;
const ALREADY_CONSTRUCTED: u32 = 2;
#[allow(dead_code)] const UNCONFIGURED_BUFFER: u32 = 3;
#[allow(dead_code)]
const UNCONFIGURED_BUFFER: u32 = 3;
id!(XdgSurfaceId);
@ -37,11 +39,7 @@ pub struct XdgSurface {
}
impl XdgSurface {
pub fn new(
wm_base: &Rc<XdgWmBaseObj>,
id: XdgSurfaceId,
surface: &Rc<WlSurface>,
) -> Self {
pub fn new(wm_base: &Rc<XdgWmBaseObj>, id: XdgSurfaceId, surface: &Rc<WlSurface>) -> Self {
Self {
id,
base: wm_base.clone(),
@ -167,7 +165,10 @@ impl XdgSurface {
xdg.popups.set(self.surface.id, popup.clone());
}
}
data.role_data = XdgSurfaceRoleData::Popup(XdgPopupData { _popup: popup, parent });
data.role_data = XdgSurfaceRoleData::Popup(XdgPopupData {
_popup: popup,
parent,
});
}
Ok(())
}

View file

@ -15,7 +15,8 @@ const CONFIGURE: u32 = 0;
const POPUP_DONE: u32 = 1;
const REPOSITIONED: u32 = 2;
#[allow(dead_code)] const INVALID_GRAB: u32 = 1;
#[allow(dead_code)]
const INVALID_GRAB: u32 = 1;
id!(XdgPopupId);

View file

@ -40,14 +40,22 @@ pub enum ResizeEdge {
BottomRight = 10,
}
#[allow(dead_code)] const STATE_MAXIMIZED: u32 = 1;
#[allow(dead_code)] const STATE_FULLSCREEN: u32 = 2;
#[allow(dead_code)] const STATE_RESIZING: u32 = 3;
#[allow(dead_code)] const STATE_ACTIVATED: u32 = 4;
#[allow(dead_code)] const STATE_TILED_LEFT: u32 = 5;
#[allow(dead_code)] const STATE_TILED_RIGHT: u32 = 6;
#[allow(dead_code)] const STATE_TILED_TOP: u32 = 7;
#[allow(dead_code)] const STATE_TILED_BOTTOM: u32 = 8;
#[allow(dead_code)]
const STATE_MAXIMIZED: u32 = 1;
#[allow(dead_code)]
const STATE_FULLSCREEN: u32 = 2;
#[allow(dead_code)]
const STATE_RESIZING: u32 = 3;
#[allow(dead_code)]
const STATE_ACTIVATED: u32 = 4;
#[allow(dead_code)]
const STATE_TILED_LEFT: u32 = 5;
#[allow(dead_code)]
const STATE_TILED_RIGHT: u32 = 6;
#[allow(dead_code)]
const STATE_TILED_TOP: u32 = 7;
#[allow(dead_code)]
const STATE_TILED_BOTTOM: u32 = 8;
id!(XdgToplevelId);

View file

@ -1,6 +1,7 @@
mod types;
use crate::client::{AddObj, Client};
use crate::ifs::xdg_wm_base::XdgWmBaseObj;
use crate::object::{Interface, Object, ObjectId};
use crate::utils::buffd::MsgParser;
use bitflags::bitflags;
@ -9,7 +10,6 @@ use num_traits::FromPrimitive;
use std::cell::RefCell;
use std::rc::Rc;
pub use types::*;
use crate::ifs::xdg_wm_base::XdgWmBaseObj;
const DESTROY: u32 = 0;
const SET_SIZE: u32 = 1;

View file

@ -17,12 +17,17 @@ const PONG: u32 = 3;
const PING: u32 = 0;
#[allow(dead_code)] const ROLE: u32 = 0;
#[allow(dead_code)]
const ROLE: u32 = 0;
const DEFUNCT_SURFACES: u32 = 1;
#[allow(dead_code)] const NOT_THE_TOPMOST_POPUP: u32 = 2;
#[allow(dead_code)] const INVALID_POPUP_PARENT: u32 = 3;
#[allow(dead_code)] const INVALID_SURFACE_STATE: u32 = 4;
#[allow(dead_code)] const INVALID_POSITIONER: u32 = 5;
#[allow(dead_code)]
const NOT_THE_TOPMOST_POPUP: u32 = 2;
#[allow(dead_code)]
const INVALID_POPUP_PARENT: u32 = 3;
#[allow(dead_code)]
const INVALID_SURFACE_STATE: u32 = 4;
#[allow(dead_code)]
const INVALID_POSITIONER: u32 = 5;
id!(XdgWmBaseId);