use libc::{int16_t, uint16_t};
use wlroots_sys::{wlr_xwayland_move_event, wlr_xwayland_resize_event,
wlr_xwayland_surface_configure_event};
use {xwayland, utils::edges::Edges};
pub struct Configure {
event: *mut wlr_xwayland_surface_configure_event
}
pub struct Move {
event: *mut wlr_xwayland_move_event
}
pub struct Resize {
event: *mut wlr_xwayland_resize_event
}
impl Configure {
pub(crate) unsafe fn from_ptr(event: *mut wlr_xwayland_surface_configure_event) -> Self {
Configure { event }
}
pub fn surface(&self) -> Option<xwayland::surface::Handle> {
unsafe {
if (*self.event).surface.is_null() {
None
} else {
Some(xwayland::surface::Handle::from_ptr((*self.event).surface))
}
}
}
pub fn coords(&self) -> (int16_t, int16_t) {
unsafe { ((*self.event).x, (*self.event).y) }
}
pub fn dimensions(&self) -> (uint16_t, uint16_t) {
unsafe { ((*self.event).width, (*self.event).height) }
}
}
impl Move {
pub(crate) unsafe fn from_ptr(event: *mut wlr_xwayland_move_event) -> Self {
Move { event }
}
pub fn surface(&self) -> Option<xwayland::surface::Handle> {
unsafe {
if (*self.event).surface.is_null() {
None
} else {
Some(xwayland::surface::Handle::from_ptr((*self.event).surface))
}
}
}
}
impl Resize {
pub(crate) unsafe fn from_ptr(event: *mut wlr_xwayland_resize_event) -> Self {
Resize { event }
}
pub fn surface(&self) -> Option<xwayland::surface::Handle> {
unsafe {
if (*self.event).surface.is_null() {
None
} else {
Some(xwayland::surface::Handle::from_ptr((*self.event).surface))
}
}
}
pub fn edges(&self) -> Edges {
unsafe {
let edges_bits = (*self.event).edges;
match Edges::from_bits(edges_bits) {
Some(edges) => edges,
None => panic!("got invalid edges: {}", edges_bits)
}
}
}
}