use super::types::*;
use ::{WlcOutput, WlcView};
#[cfg_attr(feature = "static-wlc", link(name = "wlc", kind = "static"))]
#[cfg_attr(not(feature = "static-wlc"), link(name = "wlc"))]
extern "C" {
fn wlc_set_output_created_cb(cb: extern "C" fn(WlcOutput) -> bool);
fn wlc_set_output_destroyed_cb(cb: extern "C" fn(WlcOutput));
fn wlc_set_output_focus_cb(cb: extern "C" fn(WlcOutput, bool));
fn wlc_set_output_resolution_cb(cb: extern "C" fn(WlcOutput, &Size, &Size));
fn wlc_set_output_context_created_cb(cb: extern "C" fn(WlcOutput));
fn wlc_set_output_context_destroyed_cb(cb: extern "C" fn(WlcOutput));
fn wlc_set_output_render_pre_cb(cb: extern "C" fn(WlcOutput));
fn wlc_set_output_render_post_cb(cb: extern "C" fn(WlcOutput));
fn wlc_set_view_created_cb(cb: extern "C" fn(WlcView) -> bool);
fn wlc_set_view_destroyed_cb(cb: extern "C" fn(handle: WlcView));
fn wlc_set_view_focus_cb(cb: extern "C" fn(WlcView, bool));
fn wlc_set_view_move_to_output_cb(cb: extern "C" fn(WlcView, WlcOutput,
WlcOutput));
fn wlc_set_view_request_geometry_cb(cb: extern "C" fn(WlcView,
&Geometry));
fn wlc_set_view_request_state_cb(cb: extern "C" fn(WlcView,
ViewState, bool));
fn wlc_set_view_request_move_cb(cb: extern "C" fn(WlcView, &Point));
fn wlc_set_view_request_resize_cb(cb: extern "C" fn(WlcView, ResizeEdge,
&Point));
fn wlc_set_view_render_pre_cb(cb: extern "C" fn(WlcView));
fn wlc_set_view_render_post_cb(cb: extern "C" fn(WlcView));
fn wlc_set_keyboard_key_cb(cb: extern "C" fn(WlcView, u32,
&KeyboardModifiers,
u32, KeyState) -> bool);
fn wlc_set_pointer_button_cb(cb: extern "C" fn(WlcView, u32,
&KeyboardModifiers, u32,
ButtonState, &Point) -> bool);
fn wlc_set_pointer_scroll_cb(cb: extern "C" fn(WlcView, u32,
&KeyboardModifiers,
ScrollAxis, [f64; 2]) -> bool);
#[deprecated(since="0.7.0", note="Use wlc_set_pointer_motion_cb_v2 instead")]
fn wlc_set_pointer_motion_cb(cb: extern "C" fn(WlcView, u32,
&Point) -> bool);
fn wlc_set_pointer_motion_cb_v2(cb: extern "C" fn(WlcView, u32,
f64, f64) -> bool);
fn wlc_set_touch_cb(cb: extern "C" fn(WlcView, u32, &KeyboardModifiers,
TouchType, i32, &Point) -> bool);
fn wlc_set_compositor_ready_cb(cb: extern "C" fn());
fn wlc_set_compositor_terminate_cb(cb: extern "C" fn());
fn wlc_set_view_properties_updated_cb(cb: extern "C" fn(handle: WlcView,
mask: ViewPropertyType));
fn wlc_view_positioner_get_anchor_rect(view: WlcView) -> *const Geometry;
fn wlc_view_positioner_get_size(view: WlcView) -> *const Size;
fn wlc_view_positioner_get_anchor(view: WlcView) -> PositionerAnchorBit;
fn wlc_view_positioner_get_gravity(view: WlcView) -> PositionerGravityBit;
fn wlc_view_positioner_get_constraint_adjustment(view: WlcView)
-> PositionerConstraintAdjustmentBits;
}
pub fn output_created(callback: extern "C" fn(output: WlcOutput) -> bool) {
unsafe {
wlc_set_output_created_cb(callback);
}
}
pub fn output_destroyed(callback: extern "C" fn(output: WlcOutput)) {
unsafe {
wlc_set_output_destroyed_cb(callback);
}
}
pub fn output_focus(callback: extern "C" fn(output: WlcOutput, focused: bool)) {
unsafe {
wlc_set_output_focus_cb(callback);
}
}
pub fn output_resolution(callback: extern "C" fn(output: WlcOutput,
old_size: &Size,
new_size: &Size)) {
unsafe {
wlc_set_output_resolution_cb(callback);
}
}
pub fn output_context_destroyed(cb: extern "C" fn(output: WlcOutput)) {
unsafe {
wlc_set_output_context_destroyed_cb(cb);
}
}
pub fn output_context_created(cb: extern "C" fn(output: WlcOutput)) {
unsafe {
wlc_set_output_context_created_cb(cb);
}
}
pub fn output_render_pre(callback: extern "C" fn(output: WlcOutput)) {
unsafe {
wlc_set_output_render_pre_cb(callback);
}
}
pub fn output_render_post(callback: extern "C" fn(output: WlcOutput)) {
unsafe {
wlc_set_output_render_post_cb(callback);
}
}
pub fn view_created(callback: extern "C" fn(view: WlcView) -> bool) {
unsafe {
wlc_set_view_created_cb(callback);
}
}
pub fn view_destroyed(callback: extern "C" fn(view: WlcView)) {
unsafe {
wlc_set_view_destroyed_cb(callback);
}
}
pub fn view_focus(callback: extern "C" fn(handle: WlcView, focused: bool)) {
unsafe {
wlc_set_view_focus_cb(callback);
}
}
pub fn view_move_to_output(callback: extern "C" fn(view: WlcView,
old_output: WlcOutput,
new_output: WlcOutput)) {
unsafe {
wlc_set_view_move_to_output_cb(callback);
}
}
pub fn view_request_geometry(callback: extern "C" fn(handle: WlcView,
geometry: &Geometry)) {
unsafe {
wlc_set_view_request_geometry_cb(callback);
}
}
pub fn view_request_state(callback: extern "C" fn(current: WlcView,
state: ViewState,
handled: bool)) {
unsafe {
wlc_set_view_request_state_cb(callback);
}
}
pub fn view_request_move(callback: extern "C" fn(handle: WlcView,
destination: &Point)) {
unsafe {
wlc_set_view_request_move_cb(callback);
}
}
pub fn view_request_resize(callback: extern "C" fn(handle: WlcView,
edge: ResizeEdge,
location: &Point)) {
unsafe {
wlc_set_view_request_resize_cb(callback);
}
}
pub fn view_render_pre(callback: extern "C" fn(view: WlcView)) {
unsafe {
wlc_set_view_render_pre_cb(callback);
}
}
pub fn view_render_post(callback: extern "C" fn(view: WlcView)) {
unsafe {
wlc_set_view_render_post_cb(callback);
}
}
pub fn keyboard_key(callback: extern "C" fn(view: WlcView, time: u32,
mods: &KeyboardModifiers, key: u32,
state: KeyState) -> bool) {
unsafe {
wlc_set_keyboard_key_cb(callback);
}
}
pub fn pointer_button(callback: extern "C" fn(view: WlcView, time: u32,
mods: &KeyboardModifiers,
button: u32, state: ButtonState,
point: &Point) -> bool) {
unsafe {
wlc_set_pointer_button_cb(callback);
}
}
pub fn pointer_scroll(callback: extern "C" fn(view: WlcView, time: u32,
mods: &KeyboardModifiers,
axis: ScrollAxis,
amount: [f64; 2]) -> bool) {
unsafe {
wlc_set_pointer_scroll_cb(callback);
}
}
#[deprecated(since="0.7.0", note="Use pointer_motion_v2 instead")]
#[allow(deprecated)]
pub fn pointer_motion(callback: extern "C" fn(view: WlcView, time: u32,
point: &Point) -> bool) {
unsafe {
wlc_set_pointer_motion_cb(callback);
}
}
pub fn pointer_motion_v2(callback: extern "C" fn(view: WlcView, time: u32,
x: f64, y: f64) -> bool) {
unsafe {
wlc_set_pointer_motion_cb_v2(callback);
}
}
pub fn touch(callback: extern "C" fn(handle: WlcView, time: u32,
mods: &KeyboardModifiers, touch: TouchType,
slot: i32, point: &Point) -> bool) {
unsafe {
wlc_set_touch_cb(callback);
}
}
pub fn compositor_ready(callback: extern "C" fn()) {
unsafe {
wlc_set_compositor_ready_cb(callback);
}
}
pub fn compositor_terminate(callback: extern "C" fn()) {
unsafe {
wlc_set_compositor_terminate_cb(callback);
}
}
pub fn view_properties_changed(callback: extern "C" fn(handle: WlcView, mask: ViewPropertyType)) {
unsafe {
wlc_set_view_properties_updated_cb(callback);
}
}
pub fn positioner_get_anchor_rect(view: WlcView) -> Option<Geometry> {
unsafe {
let out = wlc_view_positioner_get_anchor_rect(view);
if out.is_null() {
None
} else {
Some(*out)
}
}
}
pub fn positioner_get_size(view: WlcView) -> Option<Size> {
unsafe {
let out = wlc_view_positioner_get_size(view);
if out.is_null() {
None
} else {
Some(*out)
}
}
}
pub fn positioner_get_anchor(view: WlcView) -> PositionerAnchorBit {
unsafe {
wlc_view_positioner_get_anchor(view)
}
}
pub fn positioner_get_gravity(view: WlcView) -> PositionerGravityBit {
unsafe {
wlc_view_positioner_get_gravity(view)
}
}
pub fn positioner_get_constraint_adjustment(view: WlcView)
-> PositionerConstraintAdjustmentBits {
unsafe {
wlc_view_positioner_get_constraint_adjustment(view)
}
}