Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,12 @@ pollster = "0.3.0"
[[example]]
name = "wgpu"
required-features = ["system"]

[patch.crates-io]
wayland-client = { git = "https://github.com/smithay/wayland-rs" }
wayland-protocols = { git = "https://github.com/smithay/wayland-rs" }
wayland-protocols-wlr = { git = "https://github.com/smithay/wayland-rs" }
wayland-protocols-misc = { git = "https://github.com/smithay/wayland-rs" }
wayland-protocols-experimental = { git = "https://github.com/smithay/wayland-rs" }
wayland-cursor = { git = "https://github.com/smithay/wayland-rs" }
wayland-backend = { git = "https://github.com/smithay/wayland-rs" }
15 changes: 2 additions & 13 deletions examples/data_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ use smithay_client_toolkit::{
data_source::{CopyPasteSource, DataSourceHandler, DragSource},
DataDeviceManagerState, WritePipe,
},
delegate_registry,
output::{OutputHandler, OutputState},
primary_selection::{
device::{PrimarySelectionDevice, PrimarySelectionDeviceHandler},
offer::PrimarySelectionOffer,
selection::{PrimarySelectionSource, PrimarySelectionSourceHandler},
PrimarySelectionManagerState,
},
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
seat::{
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers, RawModifiers},
Expand All @@ -46,7 +44,7 @@ use smithay_client_toolkit::{
},
};
use wayland_client::{
globals::registry_queue_init,
globals::{registry_queue_init, GlobalListHandler},
protocol::{
wl_data_device::WlDataDevice,
wl_data_device_manager::DndAction,
Expand Down Expand Up @@ -117,7 +115,6 @@ fn main() {

let mut simple_window = DataDeviceWindow {
compositor,
registry_state: RegistryState::new(&globals),
seat_state: SeatState::new(&globals, &qh),
output_state: OutputState::new(&globals, &qh),
shm_state: shm,
Expand Down Expand Up @@ -163,7 +160,6 @@ fn main() {

struct DataDeviceWindow {
compositor: CompositorState,
registry_state: RegistryState,
seat_state: SeatState,
output_state: OutputState,
shm_state: Shm,
Expand Down Expand Up @@ -1064,10 +1060,7 @@ impl PrimarySelectionSourceHandler for DataDeviceWindow {
}
}

impl ProvidesRegistryState for DataDeviceWindow {
fn registry(&mut self) -> &mut RegistryState {
&mut self.registry_state
}
impl GlobalListHandler for DataDeviceWindow {
registry_handlers![OutputState, SeatState];
}

Expand All @@ -1079,8 +1072,6 @@ struct SeatObject {
primary_device: Option<PrimarySelectionDevice>,
}

delegate_registry!(DataDeviceWindow);

const SUPPORTED_MIME_TYPES: &[&str; 6] = &[
"text/plain;charset=utf-8",
"text/plain;charset=UTF-8",
Expand All @@ -1098,5 +1089,3 @@ fn pick_mime(mime_types: &[String]) -> Option<String> {

None
}

smithay_client_toolkit::delegate_dispatch2!(DataDeviceWindow);
92 changes: 38 additions & 54 deletions examples/dialog.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
use std::collections::hash_map::RandomState;
use std::env;
use std::hash::{BuildHasher, Hasher};

use smithay_client_toolkit::reexports::calloop::{EventLoop, LoopHandle};
use smithay_client_toolkit::seat::keyboard::KeyboardHandler;
use smithay_client_toolkit::seat::{Capability, SeatHandler, SeatState};
use smithay_client_toolkit::shell::xdg::dialog::{Dialog, DialogHandler};
use smithay_client_toolkit::{
compositor::{CompositorHandler, CompositorState, FrameCallbackData},
delegate_registry,
output::{OutputHandler, OutputState},
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
shell::{
xdg::{
Expand All @@ -27,7 +21,7 @@ use smithay_client_toolkit::{
use wayland_client::protocol::wl_keyboard;
use wayland_client::protocol::wl_seat;
use wayland_client::{
globals::registry_queue_init,
globals::{registry_queue_init, GlobalListHandler},
protocol::{wl_output, wl_shm, wl_surface},
Connection, QueueHandle,
};
Expand Down Expand Up @@ -57,7 +51,6 @@ struct Viewer {
}

struct State {
registry_state: RegistryState,
output_state: OutputState,
compositor_state: CompositorState,
shm_state: Shm,
Expand Down Expand Up @@ -88,7 +81,6 @@ fn main() {
EventLoop::try_new().expect("Failed to initialize the event loop!");

let mut state = State {
registry_state: RegistryState::new(&globals),
output_state: OutputState::new(&globals, &qh),
compositor_state: CompositorState::bind(&globals, &qh)
.expect("wl_compositor not available"),
Expand Down Expand Up @@ -348,7 +340,7 @@ impl DialogHandler for State {
qh: &QueueHandle<Self>,
window: &smithay_client_toolkit::shell::xdg::dialog::Dialog,
configure: WindowConfigure,
serial: u32,
_serial: u32,
) {
for viewer in &mut self.windows {
if viewer.window != *window {
Expand All @@ -368,8 +360,8 @@ impl DialogHandler for State {

fn request_close(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
_conn: &Connection,
_qh: &QueueHandle<Self>,
window: &smithay_client_toolkit::shell::xdg::dialog::Dialog,
) {
println!("Closing a Popup");
Expand Down Expand Up @@ -430,33 +422,33 @@ impl SeatHandler for State {
impl KeyboardHandler for State {
fn enter(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard,
surface: &wl_surface::WlSurface,
serial: u32,
raw: &[u32],
keysyms: &[xkeysym::Keysym],
_conn: &Connection,
_qh: &QueueHandle<Self>,
_keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard,
_surface: &wl_surface::WlSurface,
_serial: u32,
_raw: &[u32],
_keysyms: &[xkeysym::Keysym],
) {
}

fn leave(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard,
surface: &wl_surface::WlSurface,
serial: u32,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard,
_surface: &wl_surface::WlSurface,
_serial: u32,
) {
}

fn press_key(
&mut self,
conn: &Connection,
_conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard,
serial: u32,
event: smithay_client_toolkit::seat::keyboard::KeyEvent,
_keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard,
_serial: u32,
_event: smithay_client_toolkit::seat::keyboard::KeyEvent,
) {
if self.have_dialog {
// Close the dialog
Expand Down Expand Up @@ -489,21 +481,21 @@ impl KeyboardHandler for State {

fn release_key(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard,
serial: u32,
event: smithay_client_toolkit::seat::keyboard::KeyEvent,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard,
_serial: u32,
_event: smithay_client_toolkit::seat::keyboard::KeyEvent,
) {
}

fn repeat_key(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard,
serial: u32,
event: smithay_client_toolkit::seat::keyboard::KeyEvent,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard,
_serial: u32,
_event: smithay_client_toolkit::seat::keyboard::KeyEvent,
) {
}

Expand All @@ -518,13 +510,13 @@ impl KeyboardHandler for State {

fn update_modifiers(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard,
serial: u32,
modifiers: smithay_client_toolkit::seat::keyboard::Modifiers,
raw_modifiers: smithay_client_toolkit::seat::keyboard::RawModifiers,
layout: u32,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard,
_serial: u32,
_modifiers: smithay_client_toolkit::seat::keyboard::Modifiers,
_raw_modifiers: smithay_client_toolkit::seat::keyboard::RawModifiers,
_layout: u32,
) {
}

Expand All @@ -544,14 +536,6 @@ impl ShmHandler for State {
}
}

delegate_registry!(State);

impl ProvidesRegistryState for State {
fn registry(&mut self) -> &mut RegistryState {
&mut self.registry_state
}

impl GlobalListHandler for State {
registry_handlers!(OutputState);
}

smithay_client_toolkit::delegate_dispatch2!(State);
27 changes: 7 additions & 20 deletions examples/dmabuf_formats.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use drm_fourcc::{DrmFourcc, DrmModifier};
use smithay_client_toolkit::{
dmabuf::{DmabufFeedback, DmabufFormat, DmabufHandler, DmabufState},
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
use smithay_client_toolkit::dmabuf::{DmabufFeedback, DmabufFormat, DmabufHandler, DmabufState};
use wayland_client::{
globals::{registry_queue_init, GlobalListHandler},
protocol::wl_buffer,
Connection, QueueHandle,
};
use wayland_client::{globals::registry_queue_init, protocol::wl_buffer, Connection, QueueHandle};
use wayland_protocols::wp::linux_dmabuf::zv1::client::{
zwp_linux_buffer_params_v1, zwp_linux_dmabuf_feedback_v1,
};

struct AppData {
registry_state: RegistryState,
dmabuf_state: DmabufState,
feedback: Option<DmabufFeedback>,
}
Expand Down Expand Up @@ -56,12 +55,7 @@ impl DmabufHandler for AppData {
}
}

impl ProvidesRegistryState for AppData {
fn registry(&mut self) -> &mut RegistryState {
&mut self.registry_state
}
registry_handlers![,];
}
impl GlobalListHandler for AppData {}

fn main() {
env_logger::init();
Expand All @@ -71,11 +65,7 @@ fn main() {
let (globals, mut event_queue) = registry_queue_init(&conn).unwrap();
let qh = event_queue.handle();

let mut app_data = AppData {
registry_state: RegistryState::new(&globals),
dmabuf_state: DmabufState::new(&globals, &qh),
feedback: None,
};
let mut app_data = AppData { dmabuf_state: DmabufState::new(&globals, &qh), feedback: None };

match app_data.dmabuf_state.version() {
None => println!("`zwp_linux_dmabuf_v1` version `>3` not supported by compositor."),
Expand Down Expand Up @@ -126,6 +116,3 @@ fn print_format(format: &DmabufFormat) {
}
println!(", Modifier: {:?}", DrmModifier::from(format.modifier));
}

smithay_client_toolkit::delegate_registry!(AppData);
smithay_client_toolkit::delegate_dispatch2!(AppData);
27 changes: 8 additions & 19 deletions examples/foreign-toplevel-monitor.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
use std::error::Error;

use smithay_client_toolkit::{
delegate_registry,
foreign_toplevel_list::{ForeignToplevelList, ForeignToplevelListHandler},
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
use smithay_client_toolkit::foreign_toplevel_list::{
ForeignToplevelList, ForeignToplevelListHandler,
};
use wayland_client::{
globals::{registry_queue_init, GlobalListHandler},
Connection, QueueHandle,
};
use wayland_client::{globals::registry_queue_init, Connection, QueueHandle};
use wayland_protocols::ext::foreign_toplevel_list::v1::client::ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1;

struct State {
registry_state: RegistryState,
foreign_toplevel_list: ForeignToplevelList,
}

fn main() -> Result<(), Box<dyn Error>> {
let conn = Connection::connect_to_env()?;
let (globals, mut event_queue) = registry_queue_init(&conn)?;
let qh = event_queue.handle();
let registry_state = RegistryState::new(&globals);
let foreign_toplevel_list = ForeignToplevelList::new(&globals, &qh);

let mut state = State { registry_state, foreign_toplevel_list };
let mut state = State { foreign_toplevel_list };
loop {
event_queue.blocking_dispatch(&mut state)?;
}
}

impl ProvidesRegistryState for State {
fn registry(&mut self) -> &mut RegistryState {
&mut self.registry_state
}

registry_handlers! {}
}
impl GlobalListHandler for State {}

impl ForeignToplevelListHandler for State {
fn foreign_toplevel_list_state(&mut self) -> &mut ForeignToplevelList {
Expand Down Expand Up @@ -76,6 +68,3 @@ impl ForeignToplevelListHandler for State {
println!("Close toplevel: {:?}", info);
}
}

delegate_registry!(State);
smithay_client_toolkit::delegate_dispatch2!(State);
Loading