Skip to content

Commit

Permalink
Merge pull request #197 from mahkoh/jorth/layer-shell
Browse files Browse the repository at this point in the history
Implement remaining layer shell features
  • Loading branch information
mahkoh authored May 9, 2024
2 parents 2742b23 + 52afd94 commit 3c61dd5
Show file tree
Hide file tree
Showing 45 changed files with 851 additions and 396 deletions.
2 changes: 2 additions & 0 deletions deploy-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Needs jay-compositor release.

# 1.2.0

- Needs jay-config release.
Expand Down
89 changes: 44 additions & 45 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,54 +126,53 @@ Jay's supports leasing VR headsets to applications.

Jay supports the following wayland protocols:

| Global | Version | Privileged |
|-----------------------------------------|:-----------------|---------------|
| ext_foreign_toplevel_list_v1 | 1 | Yes |
| ext_idle_notifier_v1 | 1 | Yes |
| ext_session_lock_manager_v1 | 1 | Yes |
| ext_transient_seat_manager_v1 | 1[^ts_rejected] | Yes |
| org_kde_kwin_server_decoration_manager | 1 | |
| wl_compositor | 6[^no_touch] | |
| wl_data_device_manager | 3 | |
| wl_drm | 2 | |
| wl_output | 4 | |
| wl_seat | 9 | |
| wl_shm | 2 | |
| wl_subcompositor | 1 | |
| wp_alpha_modifier_v1 | 1 | |
| wp_content_type_manager_v1 | 1 | |
| wp_cursor_shape_manager_v1 | 1 | |
| wp_drm_lease_device_v1 | 1 | |
| wp_fractional_scale_manager_v1 | 1 | |
| wp_linux_drm_syncobj_manager_v1 | 1 | |
| wp_presentation | 1 | |
| wp_security_context_manager_v1 | 1 | |
| wp_single_pixel_buffer_manager_v1 | 1 | |
| wp_tearing_control_manager_v1 | 1[^no_tearing] | |
| wp_viewporter | 1 | |
| xdg_activation_v1 | 1 | |
| xdg_toplevel_drag_manager_v1 | 1 | |
| xdg_wm_base | 6 | |
| xdg_wm_dialog_v1 | 1 | |
| zwlr_data_control_manager_v1 | 2 | Yes |
| zwlr_layer_shell_v1 | 4[^no_exclusive] | No[^lsaccess] |
| zwlr_screencopy_manager_v1 | 3 | Yes |
| zwp_idle_inhibit_manager_v1 | 1 | |
| zwp_input_method_manager_v2 | 1 | Yes |
| zwp_linux_dmabuf_v1 | 5 | |
| zwp_pointer_constraints_v1 | 1 | |
| zwp_pointer_gestures_v1 | 3 | |
| zwp_primary_selection_device_manager_v1 | 1 | |
| zwp_relative_pointer_manager_v1 | 1 | |
| zwp_tablet_manager_v2 | 1 | |
| zwp_text_input_manager_v3 | 1 | |
| zwp_virtual_keyboard_manager_v1 | 1 | Yes |
| zxdg_decoration_manager_v1 | 1 | |
| zxdg_output_manager_v1 | 3 | |
| Global | Version | Privileged |
|-----------------------------------------|:----------------|---------------|
| ext_foreign_toplevel_list_v1 | 1 | Yes |
| ext_idle_notifier_v1 | 1 | Yes |
| ext_session_lock_manager_v1 | 1 | Yes |
| ext_transient_seat_manager_v1 | 1[^ts_rejected] | Yes |
| org_kde_kwin_server_decoration_manager | 1 | |
| wl_compositor | 6[^no_touch] | |
| wl_data_device_manager | 3 | |
| wl_drm | 2 | |
| wl_output | 4 | |
| wl_seat | 9 | |
| wl_shm | 2 | |
| wl_subcompositor | 1 | |
| wp_alpha_modifier_v1 | 1 | |
| wp_content_type_manager_v1 | 1 | |
| wp_cursor_shape_manager_v1 | 1 | |
| wp_drm_lease_device_v1 | 1 | |
| wp_fractional_scale_manager_v1 | 1 | |
| wp_linux_drm_syncobj_manager_v1 | 1 | |
| wp_presentation | 1 | |
| wp_security_context_manager_v1 | 1 | |
| wp_single_pixel_buffer_manager_v1 | 1 | |
| wp_tearing_control_manager_v1 | 1[^no_tearing] | |
| wp_viewporter | 1 | |
| xdg_activation_v1 | 1 | |
| xdg_toplevel_drag_manager_v1 | 1 | |
| xdg_wm_base | 6 | |
| xdg_wm_dialog_v1 | 1 | |
| zwlr_data_control_manager_v1 | 2 | Yes |
| zwlr_layer_shell_v1 | 5 | No[^lsaccess] |
| zwlr_screencopy_manager_v1 | 3 | Yes |
| zwp_idle_inhibit_manager_v1 | 1 | |
| zwp_input_method_manager_v2 | 1 | Yes |
| zwp_linux_dmabuf_v1 | 5 | |
| zwp_pointer_constraints_v1 | 1 | |
| zwp_pointer_gestures_v1 | 3 | |
| zwp_primary_selection_device_manager_v1 | 1 | |
| zwp_relative_pointer_manager_v1 | 1 | |
| zwp_tablet_manager_v2 | 1 | |
| zwp_text_input_manager_v3 | 1 | |
| zwp_virtual_keyboard_manager_v1 | 1 | Yes |
| zxdg_decoration_manager_v1 | 1 | |
| zxdg_output_manager_v1 | 3 | |

[^no_touch]: Touch input is not supported.
[^no_tearing]: Tearing screen updates are not supported.
[^no_exclusive]: Exclusive zones are not supported.
[^lsaccess]: Sandboxes can restrict access to this protocol.
[^ts_rejected]: Seat creation is always rejected.

Expand Down
2 changes: 2 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Add remaining layer-shell features.

# 1.2.0 (2024-05-05)

- Add support for wp-security-manager-v1.
Expand Down
9 changes: 5 additions & 4 deletions src/backends/metal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use {
clonecell::{CloneCell, UnsafeCellCloneSafe},
copyhashmap::CopyHashMap,
errorfmt::ErrorFmt,
hash_map_ext::HashMapExt,
numcell::NumCell,
oserror::OsError,
smallmap::SmallMap,
Expand Down Expand Up @@ -184,7 +185,7 @@ impl Backend for MetalBackend {
dev.cb.take();
}
}
for (_, dev) in self.device_holder.drm_devices.lock().drain() {
for dev in self.device_holder.drm_devices.lock().drain_values() {
dev.futures.clear();
for crtc in dev.dev.crtcs.values() {
crtc.connector.take();
Expand All @@ -196,13 +197,13 @@ impl Backend for MetalBackend {
lease.crtcs.clear();
lease.planes.clear();
};
for (_, mut lease) in dev.dev.leases.lock().drain() {
for mut lease in dev.dev.leases.lock().drain_values() {
clear_lease(&mut lease);
}
for (_, mut lease) in dev.dev.leases_to_break.lock().drain() {
for mut lease in dev.dev.leases_to_break.lock().drain_values() {
clear_lease(&mut lease);
}
for (_, connector) in dev.connectors.lock().drain() {
for connector in dev.connectors.lock().drain_values() {
{
let d = &mut *connector.display.borrow_mut();
d.crtcs.clear();
Expand Down
9 changes: 6 additions & 3 deletions src/client/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use {
wl_registry::WlRegistry,
wl_seat::{tablet::zwp_tablet_tool_v2::ZwpTabletToolV2, wl_pointer::WlPointer, WlSeat},
wl_surface::{
xdg_surface::{xdg_toplevel::XdgToplevel, XdgSurface},
xdg_surface::{xdg_popup::XdgPopup, xdg_toplevel::XdgToplevel, XdgSurface},
WlSurface,
},
wp_drm_lease_connector_v1::WpDrmLeaseConnectorV1,
Expand All @@ -33,8 +33,8 @@ use {
wire::{
JayOutputId, JayScreencastId, JayToplevelId, JayWorkspaceId, WlBufferId,
WlDataSourceId, WlOutputId, WlPointerId, WlRegionId, WlRegistryId, WlSeatId,
WlSurfaceId, WpDrmLeaseConnectorV1Id, WpLinuxDrmSyncobjTimelineV1Id, XdgPositionerId,
XdgSurfaceId, XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id,
WlSurfaceId, WpDrmLeaseConnectorV1Id, WpLinuxDrmSyncobjTimelineV1Id, XdgPopupId,
XdgPositionerId, XdgSurfaceId, XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id,
ZwpPrimarySelectionSourceV1Id, ZwpTabletToolV2Id,
},
},
Expand Down Expand Up @@ -66,6 +66,7 @@ pub struct Objects {
pub jay_toplevels: CopyHashMap<JayToplevelId, Rc<JayToplevel>>,
pub drm_lease_outputs: CopyHashMap<WpDrmLeaseConnectorV1Id, Rc<WpDrmLeaseConnectorV1>>,
pub tablet_tools: CopyHashMap<ZwpTabletToolV2Id, Rc<ZwpTabletToolV2>>,
pub xdg_popups: CopyHashMap<XdgPopupId, Rc<XdgPopup>>,
ids: RefCell<Vec<usize>>,
}

Expand Down Expand Up @@ -98,6 +99,7 @@ impl Objects {
jay_toplevels: Default::default(),
drm_lease_outputs: Default::default(),
tablet_tools: Default::default(),
xdg_popups: Default::default(),
ids: RefCell::new(vec![]),
}
}
Expand Down Expand Up @@ -134,6 +136,7 @@ impl Objects {
self.jay_toplevels.clear();
self.drm_lease_outputs.clear();
self.tablet_tools.clear();
self.xdg_popups.clear();
}

pub fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>
Expand Down
4 changes: 4 additions & 0 deletions src/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ fn create_dummy_output(state: &Rc<State>) {
workspace: Default::default(),
seat_state: Default::default(),
layers: Default::default(),
exclusive_zones: Default::default(),
workspace_rect: Default::default(),
non_exclusive_rect_rel: Default::default(),
non_exclusive_rect: Default::default(),
render_data: Default::default(),
state: state.clone(),
is_dummy: true,
Expand Down
6 changes: 3 additions & 3 deletions src/cursor_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use {
state::State,
tree::OutputNode,
utils::{
clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, rc_eq::rc_eq,
transform_ext::TransformExt,
clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt,
hash_map_ext::HashMapExt, rc_eq::rc_eq, transform_ext::TransformExt,
},
},
std::{cell::Cell, ops::Deref, rc::Rc},
Expand Down Expand Up @@ -99,7 +99,7 @@ impl CursorUserGroup {
.set(self.state.dummy_output.get().unwrap());
self.state.remove_cursor_size(self.size.get());
self.state.cursor_user_groups.remove(&self.id);
for (_, user) in self.users.lock().drain() {
for user in self.users.lock().drain_values() {
user.detach();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
ops::{Add, AddAssign, Sub, SubAssign},
};

#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
#[repr(transparent)]
pub struct Fixed(pub i32);

Expand Down
4 changes: 2 additions & 2 deletions src/ifs/wl_seat/event_handling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use {
object::Version,
state::DeviceHandlerData,
tree::{Direction, Node, ToplevelNode},
utils::{bitflags::BitflagsExt, smallmap::SmallMap},
utils::{bitflags::BitflagsExt, hash_map_ext::HashMapExt, smallmap::SmallMap},
wire::WlDataOfferId,
xkbcommon::{KeyboardState, XkbState, XKB_KEY_DOWN, XKB_KEY_UP},
},
Expand Down Expand Up @@ -237,7 +237,7 @@ impl WlSeatGlobal {
| InputEvent::TabletPadStrip { time_usec, .. } => {
self.last_input_usec.set(time_usec);
if self.idle_notifications.is_not_empty() {
for (_, notification) in self.idle_notifications.lock().drain() {
for notification in self.idle_notifications.lock().drain_values() {
notification.resume.trigger();
}
}
Expand Down
17 changes: 10 additions & 7 deletions src/ifs/wl_seat/tablet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ use {
object::Version,
time::now_usec,
tree::{FoundNode, Node},
utils::{bindings::PerClientBindings, clonecell::CloneCell, copyhashmap::CopyHashMap},
utils::{
bindings::PerClientBindings, clonecell::CloneCell, copyhashmap::CopyHashMap,
hash_map_ext::HashMapExt,
},
},
std::{
cell::{Cell, RefCell},
Expand Down Expand Up @@ -293,18 +296,18 @@ impl WlSeatGlobal {

pub fn tablet_clear(&self) {
self.tablet.seats.clear();
for (_, tablet) in self.tablet.tablets.lock().drain() {
for tablet in self.tablet.tablets.lock().drain_values() {
tablet.pads.clear();
tablet.bindings.clear();
tablet.tools.clear();
}
for (_, tool) in self.tablet.tools.lock().drain() {
for tool in self.tablet.tools.lock().drain_values() {
tool.cursor.detach();
tool.opt.tool.take();
tool.tool_owner.destroy(&tool);
tool.bindings.clear();
}
for (_, pad) in self.tablet.pads.lock().drain() {
for pad in self.tablet.pads.lock().drain_values() {
pad.pad_owner.destroy(&pad);
pad.tablet.take();
pad.bindings.clear();
Expand All @@ -324,14 +327,14 @@ impl WlSeatGlobal {
let Some(tablet) = self.tablet.tablets.remove(&id) else {
return;
};
for (_, tool) in tablet.tools.lock().drain() {
for tool in tablet.tools.lock().drain_values() {
self.tablet_handle_remove_tool(now_usec(), tool.id);
}
for (_, pad) in tablet.pads.lock().drain() {
for pad in tablet.pads.lock().drain_values() {
pad.pad_owner.destroy(&pad);
pad.tablet.take();
}
for (_, binding) in tablet.bindings.lock().drain() {
for binding in tablet.bindings.lock().drain_values() {
binding.send_removed();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ifs/wl_seat/tablet/pad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use {
wl_surface::WlSurface,
},
time::{now_usec, usec_to_msec},
utils::clonecell::CloneCell,
utils::{clonecell::CloneCell, hash_map_ext::HashMapExt},
},
std::{cell::Cell, rc::Rc},
};
Expand Down Expand Up @@ -76,7 +76,7 @@ impl WlSeatGlobal {
if let Some(tablet) = pad.tablet.take() {
tablet.pads.remove(&pad.id);
}
for (_, binding) in pad.bindings.lock().drain() {
for binding in pad.bindings.lock().drain_values() {
binding.send_removed();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ifs/wl_seat/tablet/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use {
},
rect::Rect,
time::usec_to_msec,
utils::clonecell::CloneCell,
utils::{clonecell::CloneCell, hash_map_ext::HashMapExt},
},
std::{cell::Cell, rc::Rc},
};
Expand All @@ -31,7 +31,7 @@ impl WlSeatGlobal {
tool.opt.tool.take();
tool.cursor.detach();
tool.tool_owner.destroy(&tool);
for (_, binding) in tool.bindings.lock().drain() {
for binding in tool.bindings.lock().drain_values() {
binding.send_removed();
}
tool.tablet.tools.remove(&id);
Expand Down
6 changes: 6 additions & 0 deletions src/ifs/wl_seat/wl_pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub struct WlPointer {
id: WlPointerId,
pub seat: Rc<WlSeat>,
pub tracker: Tracker<Self>,
last_motion: Cell<(Fixed, Fixed)>,
}

impl WlPointer {
Expand All @@ -82,10 +83,12 @@ impl WlPointer {
id,
seat: seat.clone(),
tracker: Default::default(),
last_motion: Default::default(),
}
}

pub fn send_enter(&self, serial: u32, surface: WlSurfaceId, x: Fixed, y: Fixed) {
self.last_motion.set((x, y));
self.seat.client.event(Enter {
self_id: self.id,
serial,
Expand All @@ -104,6 +107,9 @@ impl WlPointer {
}

pub fn send_motion(&self, time: u32, x: Fixed, y: Fixed) {
if self.last_motion.replace((x, y)) == (x, y) {
return;
}
self.seat.client.event(Motion {
self_id: self.id,
time,
Expand Down
3 changes: 2 additions & 1 deletion src/ifs/wl_surface/commit_timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use {
utils::{
clonecell::CloneCell,
copyhashmap::CopyHashMap,
hash_map_ext::HashMapExt,
linkedlist::{LinkedList, LinkedNode, NodeRef},
numcell::NumCell,
},
Expand Down Expand Up @@ -102,7 +103,7 @@ impl CommitTimelines {
}

pub fn clear(&self) {
for (_, list) in self.gc.lock().drain() {
for list in self.gc.lock().drain_values() {
break_loops(&list);
}
}
Expand Down
Loading

0 comments on commit 3c61dd5

Please sign in to comment.