Skip to content

Commit 184cb7e

Browse files
committed
WIP Dispatch API changes in new wayland-rs
WIP WEnum/etc. downcast unknown bits Dispatch bounds dispatch Dispatch WIP registry registry API changes `data_as_any` Not sure why this is different. WIP lazy init of `cursor_shape_mananger_state`? Fix deadlock WIP example example WIP update dialog WIP WIP WIP examples WIP examples WIP WIP update CursorShapeManagerState `get_pointer_with_theme()` now takes `GlobalList`. That was the only this `RegistryHandler::registry()` was needed for. example tests clippy tests doc doc tests doc test `SimpleGlobal::bind_singleton()` now takes a `udata` argument
1 parent 0df5bda commit 184cb7e

61 files changed

Lines changed: 661 additions & 1355 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,12 @@ pollster = "0.3.0"
6161
[[example]]
6262
name = "wgpu"
6363
required-features = ["system"]
64+
65+
[patch.crates-io]
66+
wayland-client = { git = "https://github.com/smithay/wayland-rs" }
67+
wayland-protocols = { git = "https://github.com/smithay/wayland-rs" }
68+
wayland-protocols-wlr = { git = "https://github.com/smithay/wayland-rs" }
69+
wayland-protocols-misc = { git = "https://github.com/smithay/wayland-rs" }
70+
wayland-protocols-experimental = { git = "https://github.com/smithay/wayland-rs" }
71+
wayland-cursor = { git = "https://github.com/smithay/wayland-rs" }
72+
wayland-backend = { git = "https://github.com/smithay/wayland-rs" }

examples/data_device.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ use smithay_client_toolkit::{
1818
data_source::{CopyPasteSource, DataSourceHandler, DragSource},
1919
DataDeviceManagerState, WritePipe,
2020
},
21-
delegate_registry,
2221
output::{OutputHandler, OutputState},
2322
primary_selection::{
2423
device::{PrimarySelectionDevice, PrimarySelectionDeviceHandler},
2524
offer::PrimarySelectionOffer,
2625
selection::{PrimarySelectionSource, PrimarySelectionSourceHandler},
2726
PrimarySelectionManagerState,
2827
},
29-
registry::{ProvidesRegistryState, RegistryState},
3028
registry_handlers,
3129
seat::{
3230
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers, RawModifiers},
@@ -46,7 +44,7 @@ use smithay_client_toolkit::{
4644
},
4745
};
4846
use wayland_client::{
49-
globals::registry_queue_init,
47+
globals::{registry_queue_init, GlobalListHandler},
5048
protocol::{
5149
wl_data_device::WlDataDevice,
5250
wl_data_device_manager::DndAction,
@@ -117,7 +115,6 @@ fn main() {
117115

118116
let mut simple_window = DataDeviceWindow {
119117
compositor,
120-
registry_state: RegistryState::new(&globals),
121118
seat_state: SeatState::new(&globals, &qh),
122119
output_state: OutputState::new(&globals, &qh),
123120
shm_state: shm,
@@ -163,7 +160,6 @@ fn main() {
163160

164161
struct DataDeviceWindow {
165162
compositor: CompositorState,
166-
registry_state: RegistryState,
167163
seat_state: SeatState,
168164
output_state: OutputState,
169165
shm_state: Shm,
@@ -1064,10 +1060,7 @@ impl PrimarySelectionSourceHandler for DataDeviceWindow {
10641060
}
10651061
}
10661062

1067-
impl ProvidesRegistryState for DataDeviceWindow {
1068-
fn registry(&mut self) -> &mut RegistryState {
1069-
&mut self.registry_state
1070-
}
1063+
impl GlobalListHandler for DataDeviceWindow {
10711064
registry_handlers![OutputState, SeatState];
10721065
}
10731066

@@ -1079,8 +1072,6 @@ struct SeatObject {
10791072
primary_device: Option<PrimarySelectionDevice>,
10801073
}
10811074

1082-
delegate_registry!(DataDeviceWindow);
1083-
10841075
const SUPPORTED_MIME_TYPES: &[&str; 6] = &[
10851076
"text/plain;charset=utf-8",
10861077
"text/plain;charset=UTF-8",
@@ -1098,5 +1089,3 @@ fn pick_mime(mime_types: &[String]) -> Option<String> {
10981089

10991090
None
11001091
}
1101-
1102-
smithay_client_toolkit::delegate_dispatch2!(DataDeviceWindow);

examples/dialog.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ use smithay_client_toolkit::seat::{Capability, SeatHandler, SeatState};
44
use smithay_client_toolkit::shell::xdg::dialog::{Dialog, DialogHandler};
55
use smithay_client_toolkit::{
66
compositor::{CompositorHandler, CompositorState, FrameCallbackData},
7-
delegate_registry,
87
output::{OutputHandler, OutputState},
9-
registry::{ProvidesRegistryState, RegistryState},
108
registry_handlers,
119
shell::{
1210
xdg::{
@@ -23,7 +21,7 @@ use smithay_client_toolkit::{
2321
use wayland_client::protocol::wl_keyboard;
2422
use wayland_client::protocol::wl_seat;
2523
use wayland_client::{
26-
globals::registry_queue_init,
24+
globals::{registry_queue_init, GlobalListHandler},
2725
protocol::{wl_output, wl_shm, wl_surface},
2826
Connection, QueueHandle,
2927
};
@@ -53,7 +51,6 @@ struct Viewer {
5351
}
5452

5553
struct State {
56-
registry_state: RegistryState,
5754
output_state: OutputState,
5855
compositor_state: CompositorState,
5956
shm_state: Shm,
@@ -84,7 +81,6 @@ fn main() {
8481
EventLoop::try_new().expect("Failed to initialize the event loop!");
8582

8683
let mut state = State {
87-
registry_state: RegistryState::new(&globals),
8884
output_state: OutputState::new(&globals, &qh),
8985
compositor_state: CompositorState::bind(&globals, &qh)
9086
.expect("wl_compositor not available"),
@@ -540,14 +536,6 @@ impl ShmHandler for State {
540536
}
541537
}
542538

543-
delegate_registry!(State);
544-
545-
impl ProvidesRegistryState for State {
546-
fn registry(&mut self) -> &mut RegistryState {
547-
&mut self.registry_state
548-
}
549-
539+
impl GlobalListHandler for State {
550540
registry_handlers!(OutputState);
551541
}
552-
553-
smithay_client_toolkit::delegate_dispatch2!(State);

examples/dmabuf_formats.rs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
use drm_fourcc::{DrmFourcc, DrmModifier};
2-
use smithay_client_toolkit::{
3-
dmabuf::{DmabufFeedback, DmabufFormat, DmabufHandler, DmabufState},
4-
registry::{ProvidesRegistryState, RegistryState},
5-
registry_handlers,
2+
use smithay_client_toolkit::dmabuf::{DmabufFeedback, DmabufFormat, DmabufHandler, DmabufState};
3+
use wayland_client::{
4+
globals::{registry_queue_init, GlobalListHandler},
5+
protocol::wl_buffer,
6+
Connection, QueueHandle,
67
};
7-
use wayland_client::{globals::registry_queue_init, protocol::wl_buffer, Connection, QueueHandle};
88
use wayland_protocols::wp::linux_dmabuf::zv1::client::{
99
zwp_linux_buffer_params_v1, zwp_linux_dmabuf_feedback_v1,
1010
};
1111

1212
struct AppData {
13-
registry_state: RegistryState,
1413
dmabuf_state: DmabufState,
1514
feedback: Option<DmabufFeedback>,
1615
}
@@ -56,12 +55,7 @@ impl DmabufHandler for AppData {
5655
}
5756
}
5857

59-
impl ProvidesRegistryState for AppData {
60-
fn registry(&mut self) -> &mut RegistryState {
61-
&mut self.registry_state
62-
}
63-
registry_handlers![,];
64-
}
58+
impl GlobalListHandler for AppData {}
6559

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

74-
let mut app_data = AppData {
75-
registry_state: RegistryState::new(&globals),
76-
dmabuf_state: DmabufState::new(&globals, &qh),
77-
feedback: None,
78-
};
68+
let mut app_data = AppData { dmabuf_state: DmabufState::new(&globals, &qh), feedback: None };
7969

8070
match app_data.dmabuf_state.version() {
8171
None => println!("`zwp_linux_dmabuf_v1` version `>3` not supported by compositor."),
@@ -126,6 +116,3 @@ fn print_format(format: &DmabufFormat) {
126116
}
127117
println!(", Modifier: {:?}", DrmModifier::from(format.modifier));
128118
}
129-
130-
smithay_client_toolkit::delegate_registry!(AppData);
131-
smithay_client_toolkit::delegate_dispatch2!(AppData);

examples/foreign-toplevel-monitor.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,31 @@
11
use std::error::Error;
22

3-
use smithay_client_toolkit::{
4-
delegate_registry,
5-
foreign_toplevel_list::{ForeignToplevelList, ForeignToplevelListHandler},
6-
registry::{ProvidesRegistryState, RegistryState},
7-
registry_handlers,
3+
use smithay_client_toolkit::foreign_toplevel_list::{
4+
ForeignToplevelList, ForeignToplevelListHandler,
5+
};
6+
use wayland_client::{
7+
globals::{registry_queue_init, GlobalListHandler},
8+
Connection, QueueHandle,
89
};
9-
use wayland_client::{globals::registry_queue_init, Connection, QueueHandle};
1010
use wayland_protocols::ext::foreign_toplevel_list::v1::client::ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1;
1111

1212
struct State {
13-
registry_state: RegistryState,
1413
foreign_toplevel_list: ForeignToplevelList,
1514
}
1615

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

24-
let mut state = State { registry_state, foreign_toplevel_list };
22+
let mut state = State { foreign_toplevel_list };
2523
loop {
2624
event_queue.blocking_dispatch(&mut state)?;
2725
}
2826
}
2927

30-
impl ProvidesRegistryState for State {
31-
fn registry(&mut self) -> &mut RegistryState {
32-
&mut self.registry_state
33-
}
34-
35-
registry_handlers! {}
36-
}
28+
impl GlobalListHandler for State {}
3729

3830
impl ForeignToplevelListHandler for State {
3931
fn foreign_toplevel_list_state(&mut self) -> &mut ForeignToplevelList {
@@ -76,6 +68,3 @@ impl ForeignToplevelListHandler for State {
7668
println!("Close toplevel: {:?}", info);
7769
}
7870
}
79-
80-
delegate_registry!(State);
81-
smithay_client_toolkit::delegate_dispatch2!(State);

examples/generic_list_seats.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
use smithay_client_toolkit::{
2-
delegate_registry,
3-
registry::{ProvidesRegistryState, RegistryState},
42
registry_handlers,
53
seat::{Capability, SeatHandler, SeatState},
64
};
7-
use wayland_client::{globals::registry_queue_init, protocol::wl_seat, Connection, QueueHandle};
5+
use wayland_client::{
6+
globals::{registry_queue_init, GlobalListHandler},
7+
protocol::wl_seat,
8+
Connection, QueueHandle,
9+
};
810

911
fn main() {
1012
env_logger::init();
@@ -14,11 +16,7 @@ fn main() {
1416
let (globals, mut event_queue) = registry_queue_init(&conn).unwrap();
1517
let qh = event_queue.handle();
1618

17-
let mut list_seats = ListSeats {
18-
registry_state: RegistryState::new(&globals),
19-
seat_state: SeatState::new(&globals, &qh),
20-
_dummy: MyTest {},
21-
};
19+
let mut list_seats = ListSeats { seat_state: SeatState::new(&globals, &qh), _dummy: MyTest {} };
2220

2321
event_queue.roundtrip(&mut list_seats).unwrap();
2422

@@ -43,7 +41,6 @@ impl Test for MyTest {}
4341

4442
struct ListSeats<T: Test + 'static> {
4543
seat_state: SeatState,
46-
registry_state: RegistryState,
4744
_dummy: T,
4845
}
4946

@@ -81,14 +78,6 @@ impl<T: Test + 'static> SeatHandler for ListSeats<T> {
8178
}
8279
}
8380

84-
delegate_registry!(@<T: Test + 'static> ListSeats<T>);
85-
86-
impl<T: Test + 'static> ProvidesRegistryState for ListSeats<T> {
87-
fn registry(&mut self) -> &mut RegistryState {
88-
&mut self.registry_state
89-
}
90-
81+
impl<T: Test + 'static> GlobalListHandler for ListSeats<T> {
9182
registry_handlers!(SeatState);
9283
}
93-
94-
smithay_client_toolkit::delegate_dispatch2!(@<T: Test + 'static> ListSeats<T>);

examples/generic_simple_window.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ use std::convert::TryInto;
22

33
use smithay_client_toolkit::{
44
compositor::{CompositorHandler, CompositorState, FrameCallbackData},
5-
delegate_registry,
65
output::{OutputHandler, OutputState},
7-
registry::{ProvidesRegistryState, RegistryState},
86
registry_handlers,
97
seat::{
108
keyboard::{KeyEvent, KeyboardHandler, Modifiers, RawModifiers},
@@ -24,7 +22,7 @@ use smithay_client_toolkit::{
2422
},
2523
};
2624
use wayland_client::{
27-
globals::registry_queue_init,
25+
globals::{registry_queue_init, GlobalListHandler},
2826
protocol::{wl_keyboard, wl_output, wl_pointer, wl_seat, wl_shm, wl_surface},
2927
Connection, QueueHandle,
3028
};
@@ -72,7 +70,6 @@ fn main() {
7270
let pool = SlotPool::new(256 * 256 * 4, &shm).expect("Failed to create pool");
7371

7472
let mut simple_window = SimpleWindow {
75-
registry_state: RegistryState::new(&globals),
7673
seat_state: SeatState::new(&globals, &qh),
7774
output_state: OutputState::new(&globals, &qh),
7875
shm,
@@ -113,7 +110,6 @@ pub struct MyTest {}
113110
impl Test for MyTest {}
114111

115112
struct SimpleWindow<T: Test + 'static> {
116-
registry_state: RegistryState,
117113
seat_state: SeatState,
118114
output_state: OutputState,
119115
shm: Shm,
@@ -475,13 +471,6 @@ impl<T: Test + 'static> SimpleWindow<T> {
475471
}
476472
}
477473

478-
delegate_registry!(@<T: Test + 'static> SimpleWindow<T>);
479-
480-
impl<T: Test + 'static> ProvidesRegistryState for SimpleWindow<T> {
481-
fn registry(&mut self) -> &mut RegistryState {
482-
&mut self.registry_state
483-
}
474+
impl<T: Test + 'static> GlobalListHandler for SimpleWindow<T> {
484475
registry_handlers![OutputState, SeatState,];
485476
}
486-
487-
smithay_client_toolkit::delegate_dispatch2!(@<T: Test + 'static> SimpleWindow<T>);

examples/image_viewer.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ use std::env;
22

33
use smithay_client_toolkit::{
44
compositor::{CompositorHandler, CompositorState, FrameCallbackData},
5-
delegate_registry,
65
output::{OutputHandler, OutputState},
7-
registry::{ProvidesRegistryState, RegistryState},
86
registry_handlers,
97
shell::{
108
xdg::{
@@ -19,7 +17,7 @@ use smithay_client_toolkit::{
1917
},
2018
};
2119
use wayland_client::{
22-
globals::registry_queue_init,
20+
globals::{registry_queue_init, GlobalListHandler},
2321
protocol::{wl_output, wl_shm, wl_surface},
2422
Connection, QueueHandle,
2523
};
@@ -33,7 +31,6 @@ fn main() {
3331
let qh = event_queue.handle();
3432

3533
let mut state = State {
36-
registry_state: RegistryState::new(&globals),
3734
output_state: OutputState::new(&globals, &qh),
3835
compositor_state: CompositorState::bind(&globals, &qh)
3936
.expect("wl_compositor not available"),
@@ -108,7 +105,6 @@ fn main() {
108105
}
109106

110107
struct State {
111-
registry_state: RegistryState,
112108
output_state: OutputState,
113109
compositor_state: CompositorState,
114110
shm_state: Shm,
@@ -317,14 +313,6 @@ impl State {
317313
}
318314
}
319315

320-
delegate_registry!(State);
321-
322-
impl ProvidesRegistryState for State {
323-
fn registry(&mut self) -> &mut RegistryState {
324-
&mut self.registry_state
325-
}
326-
316+
impl GlobalListHandler for State {
327317
registry_handlers!(OutputState);
328318
}
329-
330-
smithay_client_toolkit::delegate_dispatch2!(State);

0 commit comments

Comments
 (0)