Merge pull request #751 from mahkoh/jorth/no-late-singletons
globals: add all globals during startup
This commit is contained in:
commit
699881aba9
6 changed files with 35 additions and 26 deletions
|
|
@ -322,6 +322,7 @@ fn start_compositor2(
|
|||
subsurface_ids: Default::default(),
|
||||
wait_for_sync_obj: Rc::new(WaitForSyncObj::new(&ring, &engine)),
|
||||
explicit_sync_enabled: Cell::new(true),
|
||||
explicit_sync_supported: Default::default(),
|
||||
keyboard_state_ids: Default::default(),
|
||||
physical_keyboard_ids: Default::default(),
|
||||
security_context_acceptors: Default::default(),
|
||||
|
|
@ -373,6 +374,7 @@ fn start_compositor2(
|
|||
udmabuf: Default::default(),
|
||||
gfx_ctx_changed: Default::default(),
|
||||
copy_device_registry: Rc::new(CopyDeviceRegistry::new(&ring, &engine)),
|
||||
supports_presentation_feedback: Default::default(),
|
||||
});
|
||||
state.tracker.register(ClientId::from_raw(0));
|
||||
create_dummy_output(&state);
|
||||
|
|
@ -412,7 +414,9 @@ async fn start_compositor3(state: Rc<State>, test_future: Option<TestFuture>) {
|
|||
}
|
||||
};
|
||||
state.backend.set(backend.clone());
|
||||
state.globals.add_backend_singletons(&backend);
|
||||
state
|
||||
.supports_presentation_feedback
|
||||
.set(backend.supports_presentation_feedback());
|
||||
|
||||
if backend.import_environment() {
|
||||
if let Some(acc) = state.acceptor.get() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
use {
|
||||
crate::{
|
||||
backend::Backend,
|
||||
client::{Client, ClientCaps},
|
||||
ifs::{
|
||||
color_management::wp_color_manager_v1::WpColorManagerV1Global,
|
||||
|
|
@ -24,6 +23,7 @@ use {
|
|||
jay_popup_ext_manager_v1::JayPopupExtManagerV1Global,
|
||||
org_kde_kwin_server_decoration_manager::OrgKdeKwinServerDecorationManagerGlobal,
|
||||
wl_compositor::WlCompositorGlobal,
|
||||
wl_drm::WlDrmGlobal,
|
||||
wl_fixes::WlFixesGlobal,
|
||||
wl_output::WlOutputGlobal,
|
||||
wl_registry::WlRegistry,
|
||||
|
|
@ -53,6 +53,7 @@ use {
|
|||
wp_cursor_shape_manager_v1::WpCursorShapeManagerV1Global,
|
||||
wp_fifo_manager_v1::WpFifoManagerV1Global,
|
||||
wp_fractional_scale_manager_v1::WpFractionalScaleManagerV1Global,
|
||||
wp_linux_drm_syncobj_manager_v1::WpLinuxDrmSyncobjManagerV1Global,
|
||||
wp_presentation::WpPresentationGlobal,
|
||||
wp_security_context_manager_v1::WpSecurityContextManagerV1Global,
|
||||
wp_single_pixel_buffer_manager_v1::WpSinglePixelBufferManagerV1Global,
|
||||
|
|
@ -68,6 +69,7 @@ use {
|
|||
zwlr_layer_shell_v1::ZwlrLayerShellV1Global,
|
||||
zwlr_screencopy_manager_v1::ZwlrScreencopyManagerV1Global,
|
||||
zwp_idle_inhibit_manager_v1::ZwpIdleInhibitManagerV1Global,
|
||||
zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1Global,
|
||||
zxdg_decoration_manager_v1::ZxdgDecorationManagerV1Global,
|
||||
zxdg_output_manager_v1::ZxdgOutputManagerV1Global,
|
||||
},
|
||||
|
|
@ -237,17 +239,10 @@ impl Globals {
|
|||
add_singleton!(JayPopupExtManagerV1Global);
|
||||
add_singleton!(ZwlrGammaControlManagerV1Global);
|
||||
add_singleton!(WpColorRepresentationManagerV1Global);
|
||||
}
|
||||
|
||||
pub fn add_backend_singletons(&self, backend: &Rc<dyn Backend>) {
|
||||
macro_rules! add_singleton {
|
||||
($name:ident) => {
|
||||
self.add_global_no_broadcast(&Rc::new($name::new(self.name())));
|
||||
};
|
||||
}
|
||||
if backend.supports_presentation_feedback() {
|
||||
add_singleton!(WpPresentationGlobal);
|
||||
}
|
||||
add_singleton!(WlDrmGlobal);
|
||||
add_singleton!(ZwpLinuxDmabufV1Global);
|
||||
add_singleton!(WpLinuxDrmSyncobjManagerV1Global);
|
||||
add_singleton!(WpPresentationGlobal);
|
||||
}
|
||||
|
||||
pub fn name(&self) -> GlobalName {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
state::State,
|
||||
video::drm::sync_obj::SyncObj,
|
||||
wire::{WpLinuxDrmSyncobjManagerV1Id, wp_linux_drm_syncobj_manager_v1::*},
|
||||
},
|
||||
|
|
@ -65,6 +66,10 @@ impl Global for WpLinuxDrmSyncobjManagerV1Global {
|
|||
fn version(&self) -> u32 {
|
||||
1
|
||||
}
|
||||
|
||||
fn exposed(&self, state: &State) -> bool {
|
||||
state.explicit_sync_enabled.get() && state.explicit_sync_supported.get()
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_global!(WpLinuxDrmSyncobjManagerV1Global);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use {
|
|||
ifs::wp_presentation_feedback::WpPresentationFeedback,
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
state::State,
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
|
|
@ -50,6 +51,10 @@ impl Global for WpPresentationGlobal {
|
|||
fn version(&self) -> u32 {
|
||||
2
|
||||
}
|
||||
|
||||
fn exposed(&self, state: &State) -> bool {
|
||||
state.supports_presentation_feedback.get()
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_global!(WpPresentationGlobal);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
state::State,
|
||||
wire::{ZwpLinuxDmabufFeedbackV1Id, ZwpLinuxDmabufV1Id, zwp_linux_dmabuf_v1::*},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -71,6 +72,10 @@ impl Global for ZwpLinuxDmabufV1Global {
|
|||
fn version(&self) -> u32 {
|
||||
5
|
||||
}
|
||||
|
||||
fn exposed(&self, state: &State) -> bool {
|
||||
state.render_ctx_ever_initialized.get()
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_global!(ZwpLinuxDmabufV1Global);
|
||||
|
|
|
|||
21
src/state.rs
21
src/state.rs
|
|
@ -55,7 +55,6 @@ use {
|
|||
jay_seat_events::JaySeatEvents,
|
||||
jay_workspace_watcher::JayWorkspaceWatcher,
|
||||
wl_buffer::WlBuffer,
|
||||
wl_drm::WlDrmGlobal,
|
||||
wl_output::{OutputGlobalOpt, OutputId, PersistentOutputState},
|
||||
wl_seat::{
|
||||
PhysicalKeyboardId, PhysicalKeyboardIds, PositionHintRequest, SeatIds,
|
||||
|
|
@ -78,11 +77,9 @@ use {
|
|||
workspace_manager::WorkspaceManagerState,
|
||||
wp_drm_lease_connector_v1::WpDrmLeaseConnectorV1,
|
||||
wp_drm_lease_device_v1::WpDrmLeaseDeviceV1Global,
|
||||
wp_linux_drm_syncobj_manager_v1::WpLinuxDrmSyncobjManagerV1Global,
|
||||
zwlr_foreign_toplevel_manager_v1::ZwlrForeignToplevelManagerV1,
|
||||
zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1,
|
||||
zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1,
|
||||
zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1Global,
|
||||
},
|
||||
io_uring::IoUring,
|
||||
kbvm::{KbvmContext, KbvmMap},
|
||||
|
|
@ -242,6 +239,7 @@ pub struct State {
|
|||
pub subsurface_ids: SubsurfaceIds,
|
||||
pub wait_for_sync_obj: Rc<WaitForSyncObj>,
|
||||
pub explicit_sync_enabled: Cell<bool>,
|
||||
pub explicit_sync_supported: Cell<bool>,
|
||||
pub keyboard_state_ids: KeyboardStateIds,
|
||||
pub physical_keyboard_ids: PhysicalKeyboardIds,
|
||||
pub security_context_acceptors: SecurityContextAcceptors,
|
||||
|
|
@ -295,6 +293,7 @@ pub struct State {
|
|||
pub udmabuf: Rc<UdmabufHolder>,
|
||||
pub gfx_ctx_changed: EventSource<WlBuffer>,
|
||||
pub copy_device_registry: Rc<CopyDeviceRegistry>,
|
||||
pub supports_presentation_feedback: Cell<bool>,
|
||||
}
|
||||
|
||||
// impl Drop for State {
|
||||
|
|
@ -628,6 +627,7 @@ impl State {
|
|||
}
|
||||
|
||||
pub fn set_render_ctx(&self, ctx: Option<Rc<dyn GfxContext>>) {
|
||||
self.explicit_sync_supported.set(false);
|
||||
self.render_ctx.set(ctx.clone());
|
||||
self.render_ctx_version.fetch_add(1);
|
||||
self.cursors.set(None);
|
||||
|
|
@ -710,20 +710,15 @@ impl State {
|
|||
cursor_user_groups.render_ctx_changed();
|
||||
}
|
||||
|
||||
if let Some(ctx) = &ctx
|
||||
&& !self.render_ctx_ever_initialized.replace(true)
|
||||
{
|
||||
self.add_global(&Rc::new(WlDrmGlobal::new(self.globals.name())));
|
||||
self.add_global(&Rc::new(ZwpLinuxDmabufV1Global::new(self.globals.name())));
|
||||
if let Some(ctx) = &ctx {
|
||||
if let Some(ctx) = ctx.sync_obj_ctx()
|
||||
&& ctx.supports_async_wait()
|
||||
&& self.explicit_sync_enabled.get()
|
||||
{
|
||||
self.add_global(&Rc::new(WpLinuxDrmSyncobjManagerV1Global::new(
|
||||
self.globals.name(),
|
||||
)));
|
||||
self.explicit_sync_supported.set(true);
|
||||
}
|
||||
if let Some(config) = self.config.get() {
|
||||
if !self.render_ctx_ever_initialized.replace(true)
|
||||
&& let Some(config) = self.config.get()
|
||||
{
|
||||
config.graphics_initialized();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue