Move Rectangle to utils module.
This commit is contained in:
parent
e6600dfbe9
commit
3dd559cdf1
|
@ -94,6 +94,7 @@ use self::region::RegionData;
|
|||
use self::roles::{Role, RoleType, WrongRole};
|
||||
use self::tree::SurfaceData;
|
||||
pub use self::tree::TraversalAction;
|
||||
use utils::Rectangle;
|
||||
use wayland_server::{resource_is_registered, EventLoop, EventLoopHandle, Global};
|
||||
use wayland_server::protocol::{wl_buffer, wl_callback, wl_compositor, wl_output, wl_region,
|
||||
wl_subcompositor, wl_surface};
|
||||
|
@ -217,19 +218,6 @@ pub enum RectangleKind {
|
|||
Subtract,
|
||||
}
|
||||
|
||||
/// A rectangle defined by its top-left corner and dimensions
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct Rectangle {
|
||||
/// horizontal position of the top-leftcorner of the rectangle, in surface coordinates
|
||||
pub x: i32,
|
||||
/// vertical position of the top-leftcorner of the rectangle, in surface coordinates
|
||||
pub y: i32,
|
||||
/// width of the rectangle
|
||||
pub width: i32,
|
||||
/// height of the rectangle
|
||||
pub height: i32,
|
||||
}
|
||||
|
||||
/// Description of the contents of a region
|
||||
///
|
||||
/// A region is defined as an union and difference of rectangle.
|
||||
|
|
|
@ -46,6 +46,7 @@ pub mod compositor;
|
|||
pub mod shm;
|
||||
pub mod seat;
|
||||
pub mod shell;
|
||||
pub mod utils;
|
||||
|
||||
fn slog_or_stdlog<L>(logger: L) -> ::slog::Logger
|
||||
where
|
||||
|
|
|
@ -105,10 +105,11 @@
|
|||
//! access from the `state()` of the event loop and the token returned by the init
|
||||
//! function.
|
||||
|
||||
use compositor::{CompositorToken, Rectangle};
|
||||
use compositor::CompositorToken;
|
||||
use compositor::roles::Role;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use utils::Rectangle;
|
||||
use wayland_protocols::unstable::xdg_shell::server::{zxdg_popup_v6, zxdg_positioner_v6 as xdg_positioner,
|
||||
zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6};
|
||||
use wayland_server::{EventLoop, EventLoopHandle, EventResult, Global, Liveness, Resource, StateToken};
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use super::{make_shell_client_data, PopupConfigure, PopupState, PositionerState, ShellClient,
|
||||
ShellClientData, ShellSurfaceIData, ShellSurfacePendingState, ShellSurfaceRole,
|
||||
ToplevelConfigure, ToplevelState};
|
||||
use compositor::{CompositorToken, Rectangle};
|
||||
use compositor::CompositorToken;
|
||||
use compositor::roles::*;
|
||||
use std::sync::Mutex;
|
||||
use utils::Rectangle;
|
||||
use wayland_protocols::unstable::xdg_shell::server::{zxdg_positioner_v6 as xdg_positioner, zxdg_toplevel_v6};
|
||||
use wayland_server::{Client, EventLoopHandle, Resource};
|
||||
use wayland_server::protocol::{wl_output, wl_shell, wl_shell_surface, wl_surface};
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use super::{make_shell_client_data, PopupConfigure, PopupState, PositionerState, ShellClient,
|
||||
ShellClientData, ShellSurfaceIData, ShellSurfacePendingState, ShellSurfaceRole,
|
||||
ToplevelConfigure, ToplevelState};
|
||||
use compositor::{CompositorToken, Rectangle};
|
||||
use compositor::CompositorToken;
|
||||
use compositor::roles::*;
|
||||
use std::sync::Mutex;
|
||||
use utils::Rectangle;
|
||||
use wayland_protocols::unstable::xdg_shell::server::{zxdg_popup_v6, zxdg_positioner_v6, zxdg_shell_v6,
|
||||
zxdg_surface_v6, zxdg_toplevel_v6};
|
||||
use wayland_server::{Client, EventLoopHandle, Resource};
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
//! Various utilities functions and types
|
||||
|
||||
mod rectangle;
|
||||
|
||||
pub use self::rectangle::Rectangle;
|
|
@ -0,0 +1,21 @@
|
|||
/// A rectangle defined by its top-left corner and dimensions
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct Rectangle {
|
||||
/// horizontal position of the top-leftcorner of the rectangle, in surface coordinates
|
||||
pub x: i32,
|
||||
/// vertical position of the top-leftcorner of the rectangle, in surface coordinates
|
||||
pub y: i32,
|
||||
/// width of the rectangle
|
||||
pub width: i32,
|
||||
/// height of the rectangle
|
||||
pub height: i32,
|
||||
}
|
||||
|
||||
impl Rectangle {
|
||||
/// Checks wether given point is inside a rectangle
|
||||
pub fn contains(&self, point: (i32, i32)) -> bool {
|
||||
let (x, y) = point;
|
||||
(x >= self.x) && (x < self.x + self.width)
|
||||
&& (y >= self.y) && (y < self.y + self.height)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue