surface: split ext::pre_commit into two parts
This commit is contained in:
parent
86d37b5aa4
commit
943626a7f7
5 changed files with 39 additions and 26 deletions
|
|
@ -198,13 +198,22 @@ enum CommitAction {
|
|||
}
|
||||
|
||||
trait SurfaceExt {
|
||||
fn pre_commit(self: Rc<Self>, ctx: CommitContext) -> Result<CommitAction, WlSurfaceError> {
|
||||
fn prepare_commit(&self, ctx: CommitContext, pending: &mut PendingState) -> CommitAction {
|
||||
let _ = ctx;
|
||||
Ok(CommitAction::ContinueCommit)
|
||||
let _ = pending;
|
||||
CommitAction::ContinueCommit
|
||||
}
|
||||
|
||||
fn post_commit(self: Rc<Self>) {
|
||||
// nothing
|
||||
fn before_apply_commit(
|
||||
self: Rc<Self>,
|
||||
pending: &mut PendingState,
|
||||
) -> Result<(), WlSurfaceError> {
|
||||
let _ = pending;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn after_apply_commit(self: Rc<Self>, pending: &mut PendingState) {
|
||||
let _ = pending;
|
||||
}
|
||||
|
||||
fn is_some(&self) -> bool {
|
||||
|
|
@ -647,9 +656,11 @@ impl WlSurface {
|
|||
|
||||
fn do_commit(self: &Rc<Self>, ctx: CommitContext) -> Result<(), WlSurfaceError> {
|
||||
let ext = self.ext.get();
|
||||
if ext.clone().pre_commit(ctx)? == CommitAction::AbortCommit {
|
||||
let pending = &mut *self.pending.borrow_mut();
|
||||
if ext.prepare_commit(ctx, pending) == CommitAction::AbortCommit {
|
||||
return Ok(());
|
||||
}
|
||||
ext.clone().before_apply_commit(pending)?;
|
||||
{
|
||||
let children = self.children.borrow();
|
||||
if let Some(children) = children.deref() {
|
||||
|
|
@ -658,7 +669,6 @@ impl WlSurface {
|
|||
}
|
||||
}
|
||||
}
|
||||
let pending = &mut *self.pending.borrow_mut();
|
||||
let mut scale_changed = false;
|
||||
if let Some(scale) = pending.scale.take() {
|
||||
scale_changed = true;
|
||||
|
|
@ -853,7 +863,7 @@ impl WlSurface {
|
|||
cursor.update_hardware_cursor();
|
||||
}
|
||||
}
|
||||
ext.post_commit();
|
||||
ext.after_apply_commit(pending);
|
||||
self.client.state.damage();
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use {
|
|||
crate::{
|
||||
client::ClientError,
|
||||
ifs::wl_surface::{
|
||||
CommitAction, CommitContext, StackElement, SurfaceExt, SurfaceRole, WlSurface,
|
||||
WlSurfaceError, WlSurfaceId,
|
||||
CommitAction, CommitContext, PendingState, StackElement, SurfaceExt, SurfaceRole,
|
||||
WlSurface, WlSurfaceError, WlSurfaceId,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
|
|
@ -264,15 +264,15 @@ impl Object for WlSubsurface {
|
|||
simple_add_obj!(WlSubsurface);
|
||||
|
||||
impl SurfaceExt for WlSubsurface {
|
||||
fn pre_commit(self: Rc<Self>, ctx: CommitContext) -> Result<CommitAction, WlSurfaceError> {
|
||||
fn prepare_commit(&self, ctx: CommitContext, _pending: &mut PendingState) -> CommitAction {
|
||||
if ctx == CommitContext::RootCommit && self.sync() {
|
||||
log::debug!("Aborting commit due to sync");
|
||||
return Ok(CommitAction::AbortCommit);
|
||||
return CommitAction::AbortCommit;
|
||||
}
|
||||
Ok(CommitAction::ContinueCommit)
|
||||
CommitAction::ContinueCommit
|
||||
}
|
||||
|
||||
fn post_commit(self: Rc<Self>) {
|
||||
fn after_apply_commit(self: Rc<Self>, _pending: &mut PendingState) {
|
||||
if let Some(v) = self.pending.node.take() {
|
||||
v.pending.set(false);
|
||||
self.node.borrow_mut().replace(v);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use {
|
|||
crate::{
|
||||
ifs::wl_surface::{
|
||||
x_surface::{xwayland_surface_v1::XwaylandSurfaceV1, xwindow::Xwindow},
|
||||
SurfaceExt, WlSurface, WlSurfaceError,
|
||||
PendingState, SurfaceExt, WlSurface, WlSurfaceError,
|
||||
},
|
||||
leaks::Tracker,
|
||||
tree::ToplevelNode,
|
||||
|
|
@ -23,7 +23,7 @@ pub struct XSurface {
|
|||
}
|
||||
|
||||
impl SurfaceExt for XSurface {
|
||||
fn post_commit(self: Rc<Self>) {
|
||||
fn after_apply_commit(self: Rc<Self>, _pending: &mut PendingState) {
|
||||
if let Some(xwindow) = self.xwindow.get() {
|
||||
xwindow.map_status_changed();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use {
|
|||
xdg_popup::{XdgPopup, XdgPopupError},
|
||||
xdg_toplevel::{XdgToplevel, WM_CAPABILITIES_SINCE},
|
||||
},
|
||||
CommitAction, CommitContext, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError,
|
||||
PendingState, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError,
|
||||
},
|
||||
xdg_wm_base::XdgWmBase,
|
||||
},
|
||||
|
|
@ -357,7 +357,10 @@ impl Object for XdgSurface {
|
|||
dedicated_add_obj!(XdgSurface, XdgSurfaceId, xdg_surfaces);
|
||||
|
||||
impl SurfaceExt for XdgSurface {
|
||||
fn pre_commit(self: Rc<Self>, _ctx: CommitContext) -> Result<CommitAction, WlSurfaceError> {
|
||||
fn before_apply_commit(
|
||||
self: Rc<Self>,
|
||||
_pending: &mut PendingState,
|
||||
) -> Result<(), WlSurfaceError> {
|
||||
{
|
||||
let ase = self.acked_serial.get();
|
||||
let rse = self.requested_serial.get();
|
||||
|
|
@ -368,17 +371,16 @@ impl SurfaceExt for XdgSurface {
|
|||
}
|
||||
self.send_configure(rse);
|
||||
}
|
||||
// return CommitAction::AbortCommit;
|
||||
}
|
||||
}
|
||||
if let Some(geometry) = self.pending.geometry.take() {
|
||||
self.geometry.set(Some(geometry));
|
||||
self.update_extents();
|
||||
}
|
||||
Ok(CommitAction::ContinueCommit)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn post_commit(self: Rc<Self>) {
|
||||
fn after_apply_commit(self: Rc<Self>, _pending: &mut PendingState) {
|
||||
if let Some(ext) = self.ext.get() {
|
||||
ext.post_commit();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@ use {
|
|||
client::{Client, ClientError},
|
||||
ifs::{
|
||||
wl_seat::NodeSeatState,
|
||||
wl_surface::{
|
||||
CommitAction, CommitContext, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError,
|
||||
},
|
||||
wl_surface::{PendingState, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError},
|
||||
zwlr_layer_shell_v1::{ZwlrLayerShellV1, OVERLAY},
|
||||
},
|
||||
leaks::Tracker,
|
||||
|
|
@ -313,12 +311,15 @@ impl ZwlrLayerSurfaceV1 {
|
|||
}
|
||||
|
||||
impl SurfaceExt for ZwlrLayerSurfaceV1 {
|
||||
fn pre_commit(self: Rc<Self>, _ctx: CommitContext) -> Result<CommitAction, WlSurfaceError> {
|
||||
fn before_apply_commit(
|
||||
self: Rc<Self>,
|
||||
_pending: &mut PendingState,
|
||||
) -> Result<(), WlSurfaceError> {
|
||||
self.deref().pre_commit()?;
|
||||
Ok(CommitAction::ContinueCommit)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn post_commit(self: Rc<Self>) {
|
||||
fn after_apply_commit(self: Rc<Self>, _pending: &mut PendingState) {
|
||||
let buffer = self.surface.buffer.get();
|
||||
if self.mapped.get() {
|
||||
if buffer.is_none() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue