Crate rustwlc [] [src]

rustwlc is a wrapper for wlc, a library for writing a window manager using the wayland protocol. Compositors using rustwlc will not need unsafe code for basic interaction with wayland.

wlc

wlc is a library written in C which acts as a wayland compositor. It provides abstractions over wayland via structs such as WlcView, WlcOutput, Geometry, or KeyboardModifiers. It provides callbacks (found in the callback module) for events such as view_created, mouse_move, or view_focused.

Example

For more information on how to use rustwlc, see the callbacks module and the run_wlc() method.

For a more complete example, see the example program on our GitHub page.

extern crate rustwlc;
use rustwlc::callback;
// VIEW_ACTIVATED is a bitflags enum variant, and those must be imported
// manually, or using a wildcatd.
use rustwlc::{WlcView, VIEW_ACTIVATED};

// Callbacks must be labeled extern as they will be called from C
extern "C" fn view_created(view: WlcView) -> bool {
    view.bring_to_front();
    view.focus();
    return true;
}

extern "C" fn view_focus(view: WlcView, focused: bool) {
    view.set_state(VIEW_ACTIVATED, focused);
}

// Entry point for a compositor
fn compositor_main() {
    callback::view_created(view_created);
    callback::view_focus(view_focus);

    // The default log handler will print wlc logs to stdout
    rustwlc::log_set_default_handler();
    let run_fn = rustwlc::init().expect("Unable to initialize!");
    // This will run wlc's event loop and launch wayland.
    run_fn();
}

For a more full-featured compositor using rustwlc, see way-cooler.

Reexports

pub use types::*;
pub use handle::WlcOutput;
pub use handle::WlcView;

Modules

callback

Register wlc callbacks to events.

handle

Contains definitions for wlc handle types.

input

Contains methods for interacting with the pointer and keyboard of wlc.

render

Contains definitions for wlc render functions (wlc-render.h)

types

Contains struct and enum declarations for structs defined by wlc.

xkb [
Deprecated
]

Deprecated libxkbcommon bindings.

Functions

get_backend_type

Query backend wlc is using.

init

Initialize wlc's callbacks and logger with a WlcInterface.

init2 [
Deprecated
]

Deprecated alias to init().

log_set_default_handler

Sets the wlc log callback to a simple function that prints to console.

log_set_handler

Registers a C callback for wlc logging.

log_set_rust_handler

Registers a Rust callback for wlc logging. This is a nice convenience function that should be used in place of log_set_handler. That way you can just pass a safe Rust &str and not depend on libc`.

pointer_to_string

Unsafe strings conversion function.

terminate

Halts execution of wlc.