Skip to content

Commit

Permalink
Merge pull request #169 from mahkoh/jorth/select-toplevel
Browse files Browse the repository at this point in the history
portal: implement window capture
  • Loading branch information
mahkoh authored Apr 19, 2024
2 parents 9a7e6c2 + 4e10415 commit 670588f
Show file tree
Hide file tree
Showing 61 changed files with 1,548 additions and 291 deletions.
4 changes: 4 additions & 0 deletions jay-config/src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ pub mod colors {
///
/// Default: `#23092c`.
const 14 => ATTENTION_REQUESTED_BACKGROUND_COLOR,
/// Color used to highlight parts of the UI.
///
/// Default: `#9d28c67f`.
const 15 => HIGHLIGHT_COLOR,
}

/// Sets the color of GUI element.
Expand Down
1 change: 1 addition & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

- Screencasts now support window capture.
- Add support for wp-alpha-modifier.
- Add support for per-device keymaps.
- Add support for virtual-keyboard-unstable-v1.
Expand Down
12 changes: 8 additions & 4 deletions src/client/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use {
},
jay_output::JayOutput,
jay_screencast::JayScreencast,
jay_toplevel::JayToplevel,
jay_workspace::JayWorkspace,
wl_buffer::WlBuffer,
wl_display::WlDisplay,
Expand All @@ -29,10 +30,10 @@ use {
copyhashmap::{CopyHashMap, Locked},
},
wire::{
JayOutputId, JayScreencastId, JayWorkspaceId, WlBufferId, WlDataSourceId, WlOutputId,
WlPointerId, WlRegionId, WlRegistryId, WlSeatId, WlSurfaceId,
WpLinuxDrmSyncobjTimelineV1Id, XdgPositionerId, XdgSurfaceId, XdgToplevelId,
XdgWmBaseId, ZwlrDataControlSourceV1Id, ZwpPrimarySelectionSourceV1Id,
JayOutputId, JayScreencastId, JayToplevelId, JayWorkspaceId, WlBufferId,
WlDataSourceId, WlOutputId, WlPointerId, WlRegionId, WlRegistryId, WlSeatId,
WlSurfaceId, WpLinuxDrmSyncobjTimelineV1Id, XdgPositionerId, XdgSurfaceId,
XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id, ZwpPrimarySelectionSourceV1Id,
},
},
std::{cell::RefCell, mem, rc::Rc},
Expand Down Expand Up @@ -60,6 +61,7 @@ pub struct Objects {
pub screencasts: CopyHashMap<JayScreencastId, Rc<JayScreencast>>,
pub timelines: CopyHashMap<WpLinuxDrmSyncobjTimelineV1Id, Rc<WpLinuxDrmSyncobjTimelineV1>>,
pub zwlr_data_sources: CopyHashMap<ZwlrDataControlSourceV1Id, Rc<ZwlrDataControlSourceV1>>,
pub jay_toplevels: CopyHashMap<JayToplevelId, Rc<JayToplevel>>,
ids: RefCell<Vec<usize>>,
}

Expand Down Expand Up @@ -89,6 +91,7 @@ impl Objects {
screencasts: Default::default(),
timelines: Default::default(),
zwlr_data_sources: Default::default(),
jay_toplevels: Default::default(),
ids: RefCell::new(vec![]),
}
}
Expand Down Expand Up @@ -122,6 +125,7 @@ impl Objects {
self.screencasts.clear();
self.timelines.clear();
self.zwlr_data_sources.clear();
self.jay_toplevels.clear();
}

pub fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>
Expand Down
5 changes: 5 additions & 0 deletions src/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use {
forker,
globals::Globals,
ifs::{
jay_screencast::{perform_screencast_realloc, perform_toplevel_screencasts},
wl_output::{OutputId, PersistentOutputState, WlOutputGlobal},
wl_surface::{zwp_input_popup_surface_v2::input_popup_positioning, NoneSurfaceExt},
},
Expand Down Expand Up @@ -173,6 +174,8 @@ fn start_compositor2(
pending_float_layout: Default::default(),
pending_float_titles: Default::default(),
pending_input_popup_positioning: Default::default(),
pending_toplevel_screencasts: Default::default(),
pending_toplevel_screencast_reallocs: Default::default(),
dbus: Dbus::new(&engine, &ring, &run_toplevel),
fdcloser: FdCloser::new(),
logger: logger.clone(),
Expand Down Expand Up @@ -329,6 +332,8 @@ fn start_global_event_handlers(
eng.spawn2(Phase::PostLayout, float_titles(state.clone())),
eng.spawn2(Phase::PostLayout, idle(state.clone(), backend.clone())),
eng.spawn2(Phase::PostLayout, input_popup_positioning(state.clone())),
eng.spawn2(Phase::Present, perform_toplevel_screencasts(state.clone())),
eng.spawn2(Phase::PostLayout, perform_screencast_realloc(state.clone())),
]
}

Expand Down
1 change: 1 addition & 0 deletions src/config/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,7 @@ impl ConfigProxyHandler {
FOCUSED_INACTIVE_TITLE_TEXT_COLOR => &colors.focused_inactive_title_text,
BAR_STATUS_TEXT_COLOR => &colors.bar_text,
ATTENTION_REQUESTED_BACKGROUND_COLOR => &colors.attention_requested_background,
HIGHLIGHT_COLOR => &colors.highlight,
_ => return Err(CphError::UnknownColor(colorable.0)),
};
Ok(colorable)
Expand Down
2 changes: 2 additions & 0 deletions src/ifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub mod jay_render_ctx;
pub mod jay_screencast;
pub mod jay_screenshot;
pub mod jay_seat_events;
pub mod jay_select_toplevel;
pub mod jay_toplevel;
pub mod jay_workspace;
pub mod jay_workspace_watcher;
pub mod org_kde_kwin_server_decoration;
Expand Down
50 changes: 45 additions & 5 deletions src/ifs/jay_compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ use {
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::{
jay_idle::JayIdle, jay_input::JayInput, jay_log_file::JayLogFile,
jay_output::JayOutput, jay_pointer::JayPointer, jay_randr::JayRandr,
jay_render_ctx::JayRenderCtx, jay_screencast::JayScreencast,
jay_screenshot::JayScreenshot, jay_seat_events::JaySeatEvents,
jay_idle::JayIdle,
jay_input::JayInput,
jay_log_file::JayLogFile,
jay_output::JayOutput,
jay_pointer::JayPointer,
jay_randr::JayRandr,
jay_render_ctx::JayRenderCtx,
jay_screencast::JayScreencast,
jay_screenshot::JayScreenshot,
jay_seat_events::JaySeatEvents,
jay_select_toplevel::{JaySelectToplevel, JayToplevelSelector},
jay_workspace_watcher::JayWorkspaceWatcher,
},
leaks::Tracker,
Expand All @@ -18,7 +25,7 @@ use {
},
bstr::ByteSlice,
log::Level,
std::{ops::Deref, rc::Rc},
std::{cell::Cell, ops::Deref, rc::Rc},
thiserror::Error,
};

Expand All @@ -44,6 +51,7 @@ impl JayCompositorGlobal {
});
track!(client, obj);
client.add_client_obj(&obj)?;
obj.send_capabilities();
Ok(())
}
}
Expand Down Expand Up @@ -72,7 +80,21 @@ pub struct JayCompositor {
tracker: Tracker<Self>,
}

pub struct Cap;

impl Cap {
pub const NONE: u16 = 0;
pub const WINDOW_CAPTURE: u16 = 1;
}

impl JayCompositor {
fn send_capabilities(&self) {
self.client.event(Capabilities {
self_id: self.id,
cap: &[Cap::NONE, Cap::WINDOW_CAPTURE],
});
}

fn take_screenshot_impl(
&self,
id: JayScreenshotId,
Expand Down Expand Up @@ -322,6 +344,24 @@ impl JayCompositorRequestHandler for JayCompositor {
self.client.add_client_obj(&sc)?;
Ok(())
}

fn select_toplevel(&self, req: SelectToplevel, _slf: &Rc<Self>) -> Result<(), Self::Error> {
let seat = self.client.lookup(req.seat)?;
let obj = Rc::new(JaySelectToplevel {
id: req.id,
client: self.client.clone(),
tracker: Default::default(),
destroyed: Cell::new(false),
});
track!(self.client, obj);
self.client.add_client_obj(&obj)?;
let selector = JayToplevelSelector {
tl: Default::default(),
jst: obj.clone(),
};
seat.global.select_toplevel(selector);
Ok(())
}
}

object_base! {
Expand Down
Loading

0 comments on commit 670588f

Please sign in to comment.