Commit graph

20 commits

Author SHA1 Message Date
hujianwei
e7b89cec3b Fix crashes during scale changes
* compositor.h (struct _XdgRoleImplementationFuncs): New
function `rescale'.
* subsurface.c (Rescale): If the parent has been detached, don't
call MoveFractional.
* xdg_surface.c (Rescale): Call rescale hook.
* xdg_toplevel.c (SendOutputBounds): Check that some fields are
present.  Scale geometry correctly.
(Rescale): New function.
(ShowWindowMenu): Scale coordinates correctly.
(XLGetXdgToplevel): Add Rescale hook.
2022-11-15 12:17:26 +00:00
hujianwei
ad9d1c3d6a Add new test for role actions
* subcompositor.c (ViewSetSubcompositor):
* subsurface.c (Teardown, XLSubsurfaceParentDestroyed):
* surface.c (HandleSurfaceDestroy): Restore previous code with
more comments.

* tests/subsurface_test.c (test_single_step): Test that surface
actions work with unconfirmed subsurfaces.
2022-11-15 05:00:56 +00:00
hujianwei
e8b746e7ec Update subsurface tests to handle reparenting and fix discovered bugs
* 12to11-test.xml (test_manager) <set_buffer_label>: New
request.
* 12to11.man:
* README: Add missing documentation.
* buffer.c (ExtBufferDestroy): Free buffer label.
* compositor.h (struct _ExtBuffer): New field `label'
* linux-dmabuf-unstable-v1.xml: Update from wayland-protocols.
* subcompositor.c (IsSkipped, SetSkipped, ClearSkipped): Delete
macros.
(SubcompositorUpdateBounds, SubcompositorUpdateBoundsForInsert)
(SkipSlug): Adjust accordingly.
(DamageIncludingInferiors): Fix function.
(SubcompositorInsert, SubcompositorInsertBefore)
(SubcompositorInsertAfter, ViewIsVisible, ViewRecomputeChildren)
(ViewInsert, ViewInsertAfter, ViewInsertBefore): Call
DamageIncludingInferiors on child, not view.
(ViewSetSubcompositor, ViewAfterSizeUpdate, ViewMove): Get rid
of "skipped" state.
(ViewUnskip, ViewSkip): delete functions.
(ViewFree, DoCull, SubcompositorLookupView): Get rid of
"skipped" state.
* subsurface.c (struct _Subsurface): New field `pending'.
(AfterParentCommit): Attach views whenever pending.
(Setup): Stop attaching views upon setup.
(Teardown): Only detach views when not pending.
(GetSubsurface): Add comment.
(XLSubsurfaceParentDestroyed): Set subcompositor to NULL when
parent is destroyed.
(XLSubsurfaceHandleParentCommit): New function.
* surface.c (RunCommitCallbacks): Run commit callbacks in the
order in which they were created.
(NotifySubsurfaceDestroyed): Assert that a role is present.
(HandleSurfaceDestroy): Clear subsurfaces before releasing role.
Set subsurfaces to NULL.
* test.c (SetBufferLabel): New function.
(test_manager_impl): Implement.
* tests/subsurface_test.c (enum test_kind): New
SUBSURFACE_REPARENT_KIND.
(test_names): Add names
(LAST_TEST): Set to SUBSURFACE_REPARENT_KIND.
(test_single_step): Implement new test.
* tests/test_harness.c (load_png_image): Set buffer debug label.
2022-11-15 04:26:36 +00:00
hujianwei
3dcceb506b Fix subsurface commit behavior
* subsurface.c (EarlyCommit): Clear pending_commit after merging
cached state.
* tests/subsurface_test.c (test_single_step): Add test that
found this problem.
2022-11-06 05:09:57 +00:00
hujianwei
e73914d7dd Correctly implement nested subsurface sync or desync
* compositor.h (struct _RoleFuncs): Get rid of note_desync_child
and co.
* frame_clock.c (StartFrame): Fix typo.
* subsurface.c (struct _Subsurface): New field
`should_be_desync'.
(NoteDesyncChild, NoteChildSynced): Delete functions.
(IsParentSynchronous): New function.
(SetSync1, NoteSubsurfaceDesynchronous, NoteSubsurfaceTeardown):
New functions.
(SetSync): Make all children synchronous when required.
(SetDesync): Desynchronize all children if possible; otherwise,
keep the surface synchronous but set the `should_be_desync'
flag.
(EarlyCommit): Merge pending state if required.
(Setup): Call SetSync1 to make children synchronous.
(Teardown): Call NoteSubsurfaceTeardown to make children
desynchronous as required.
(GetSubsurface): Stop setting
note_child_synced/note_desync_child.

* surface.c (InternalCommit1): New function.
(InternalCommit): Move state merging logic to InternalCommit1.
(XLSurfaceMergeCachedState): New function.

* xdg_surface.c (struct _XdgRole): Remove `n_desync_children'.
(UpdateFrameRefreshPrediction): Resort to counting the number of
children on each frame instead.
(Setup, NoteFrame, NoteChildSynced, NoteDesyncChild, HandleFreeze)
(XLGetXdgSurface): Stop counting sync/desync children.

* tests/subsurface_test.c (enum test_kind, test_names): Add
SUBSURFACE_DESYNC_KIND.
(LAST_TEST): Set to SUBSURFACE_DESYNC_KIND.
(test_single_step): Implement SUBSURFACE_DESYNC_KIND.
2022-11-06 03:21:27 +00:00
hujianwei
da212fe729 Fix problems seen with some programs in the wild
* subcompositor.c (ViewAttachBuffer): Correctly determine when
to recompute view bounds.
* subsurface.c (AfterParentCommit): Unskip view first, and
commit pending state second.  Explain why.
* xdg_toplevel.c (Unmap, Map): Add new "initial configure" flag.
(Commit): Use it instead of testing current_buffer.  Explain
why.
(XLGetXdgToplevel): Set that flag by default.
2022-10-30 13:53:10 +00:00
hujianwei
0c3e5a0e7d Fix subsurface PlaceBelow relationship checks
* subsurface.c (PlaceBelow): Fix conditions in check.
2022-10-30 11:38:41 +00:00
hujianwei
a63a7ebdd6 Fix frame timing prediction algorithm
* compositor.h (struct _RoleFuncs): Replace subframe with
`subsurface_update'.
* dmabuf.c (ExistingModifier):
* fns.c (RebalanceBusfault): Pacify various compiler warnings.
* frame_clock.c (struct _FrameClock, PostEndFrame)
(XLFrameClockHandleFrameEvent, XLMakeFrameClockForWindow): Fix
presentation logic.  First, store absolute presentation
timestamps.  Secondly, use the frame_delay to adjust timestamps.
* icon_surface.c (Subframe): Delete function.
(SubsurfaceUpdate): New function.
(EndSubframe): Delete function.
(XLGetIconSurface): Change attached functions.
* picture_renderer.c (struct _PictureTarget, RecordBufferActivity)
(HandleActivityEvent, DestroyRenderTarget)
(FillBoxesWithTransparency, Composite, FinishRender)
(picture_render_funcs): Send roundtrip event only once, and
flush upon FinishRender.
* process.c (ProcessPendingDescriptions, RunProcess,
ProcessPoll): Don't block signals where unnecessary.
* seat.c (struct _Seat, CursorFromRole, ReleaseSeat, Subframe)
(EndSubframe, MakeCurrentCursor, HandleBind, MakeSeatForDevicePair)
(StartResizeTracking):
* subsurface.c (Subframe, EndSubframe, Commit, Teardown)
(GetSubsurface):
* surface.c (HandleScaleChanged):
* xdg_surface.c (CheckFrame, Commit, Subframe, SubsurfaceUpdate)
(EndSubframe, XLGetXdgSurface):
* xdg_toplevel.c (Unmap): Adjust for above changes, and fix some
compiler warnings.
2022-10-24 03:45:57 +00:00
hujianwei
19f6f6454c Fix problems found with Firefox Nightly
* subsurface.c (Teardown): Correctly free subsurface actions.
* xdg_surface.c (NoteFrame): Fix conditions to avoid frame
callback spam.
2022-10-23 11:56:35 +00:00
hujianwei
f83f80abd8 Fix reusing subsurfaces and XDG surfaces after roles are destroyed
* subsurface.c (DestroySubsurface):
* xdg_surface.c (Destroy): Release/detach role from surface.
2022-10-23 06:38:04 +00:00
hujianwei
3fe08b5c7c Fix various problems encountered
* egl.c (AddShmFormat): Fix coding style.
* explicit_synchronization.c (HandleSurfaceCommit): Remove
redundant NULL check.
* run.c (RunStep): Flush clients after completing selection
transfers.  Fix sizeof when allocating pollfds.
* seat.c (CancelResizeOperation): Avoid NULL-pointer dereference
when subcompositor is not specified.
* shm.c (DereferencePool, CreatePool): Remove redundant checks
of pool->size; it can never be zero.
* subsurface.c (Setup): Remove redundant NULL check.
* text_input.c (SetCursorRectangle): Fix some statements.
(FindTextSections, EncodeIMString, CheckStyles, ConvertString)
(PreeditString, CommitString): Fix usage of format modifiers in
debug trace code.
* xdata.c (HandleSelectionNotify): Use selection time, not event
time.
* xdg_popup.c (MoveWindow, InternalReposition): Remove various
redundant checks.
2022-10-22 07:13:21 +00:00
hujianwei
c4f2e07a4b Detect idle inhibition on subsurfaces
* compositor.h: Update prototypes.
* idle_inhibit.c (DetectSurfaceIdleInhibit): Handle subsurfaces;
when an inhibitor attached to a subsurface is displayed, check
if the subsurface's root is focused or not.
(CreateInhibitor): Likewise; handle subsurfaces specially.
* subcompositor.c (ViewisVisible): New function.
* subsurface.c (struct _Subsurface): New field `mapped'.
(Commit, Teardown): Update idle inhibition when the surface is
mapped or unmapped.
(XLSubsurfaceGetRoot): New function.
2022-10-22 05:48:23 +00:00
hujianwei
8d310f9ab3 Implement wl_seat version 8
* 12to11.man:
* README: Update documentation.
* seat.c (MakeSeatForDevicePair): Support version 8.
(HandleRawButton): Minor markup changes.
(DispatchEntryExit): Send motion event for ungrab events.
(SendScrollAxis): Send value120 events when supported by the
client.
* subsurface.c (GetRootSurface): New function.
(GetSubsurface): Disallow invalid parent/child combinations.
2022-10-20 07:53:56 +00:00
oldosfan
17571b6f97 Implement keyboard shortcut inhibition
* 12to11.c (XLMain): Initialize keyboard shortcut inhibition.
* Imakefile (SRCS): Add keyboard_shortcuts_inhibit.c.
(OBJS): Add keyboard_shortcuts_inhibit.o.
* compositor.h (enum _ClientDataType): Add ShortcutInhibitData.
(struct _ClientData): New structure.
(struct _Surface): Make client data a linked list.
* pointer_constraints.c (Reconfine, XLPointerBarrierLeft)
(XLPointerBarrierCheck, XLPointerConstraintsSurfaceMovedTo):
Adjust to new client data storage approach.
* seat.c (struct _Seat): New fields `last_focus_time' and
`external_grab_time'.
(HandleBind, SelectDeviceEvents, SetFocusSurface): Use size_t to
represent mask length.
(DispatchFocusIn): Set last focus time.
(FakePointerEdge, XLSelectStandardEvents): Likewise; use size_t.
(XLSeatExplicitlyGrabSurface): Clear active grab.
(XLSeatBeginDrag): Use size_t to represent XI mask length.
(XLSeatApplyExternalGrab, XLSeatCancelExternalGrab): New
functions.
* subsurface.c (Teardown, XLSubsurfaceHandleParentCommit):
Adjust client data storage.
* surface.c (HandleSurfaceDestroy, XLSurfaceGetClientData):
Adjust client data storage to use a linked list.
(XLSurfaceFindClientData): New function.
* text_input.c (FilterInputCallback): Pacify cppcheck.
2022-10-18 05:35:52 +00:00
oldosfan
98bbad068c Implement support for zwp_pointer_constraints_v1
* 12to11.c (XLMain): Initialize pointer constraints.
* 12to11.conf: Add Emacs local variables section.
* 12to11.man: Document new protocol.
* Imakefile (SRCS): Add pointer_constraints.c.
(OBJS): Add pointer_constraints.o.
(pointer-constraints-unstable-v1): New scanner target.
* README: Update accordingly.
* compositor.h (enum _ClientDataType): Add
PointerConfinementData.
* dmabuf.c (struct _BufferParams): Rearrange for alignment.
(struct _Buffer): Rearrange for alignment.
* dnd.c (struct _DndState, struct _DragState)
(struct _WindowCacheEntry):
* seat.c (struct _SeatCursor, struct _ScrollValuator)
(struct _SeatClientInfo, struct _Seat): Rearrange for alignment.
(SendMotion): Do not send pointer motion to locked seats.
(CheckPointerBarrier): New function.
(EnteredSurface, DispatchMotion): Check for pointer confinement
changes.
(XLSeatGetPointerDevice): New function.
(XLPointerGetSeat, XLSeatGetMouseData, XLSeatLockPointer)
(XLSeatUnlockPointer): New functions.
* shm.c (HandleResourceDestroy, CreatePool, HandleBind): Remove
redundant `all_shms' field.
* subcompositor.c (struct _View): New function `maybe_resized'.
(ViewAfterSizeUpdate): Call it if necessary.
(ViewAttachBuffer): Update a comment.
(ViewSetMaybeResizedFunction): New function.
* subsurface.c (MoveFractional):
* surface.c (ApplyInputRegion, HandleScaleChanged, MaybeResized)
(XLCreateSurface, XLWindowFromSurface): Update pointer
constraints.
* xdata.c (struct _ReadTargetsData, struct _ConversionTransferInfo)
(struct _TargetMappingTable): Rearrange for alignment.
(XLInitXData): Require fixes 1.5.
* xdg_surface.c (struct _XdgRole): Rearrange fr alignment.
(AckConfigure): Fix serial monotonicity checking.
(NoteConfigure): Update pointer constraints.
* xdg_toplevel.c (struct _XdgToplevel): Rearrange for alignment.
2022-10-15 07:58:40 +00:00
oldosfan
085f493150 Fix subsurface visibility lifecycle
* compositor.h: Update prototypes.
* dmabuf.c (MakeFeedback): Fix comment.
* shm.c (Pool): New field `flags'.
(DereferencePool, ResizePool, CreatePool): Detect whether or not
accessing a pool cannot result in SIGBUS, and refrain from
adding bus traps if that is the case.
* subcompositor.c (IsSkipped, SetSkipped, ClearSkipped): New
view state.
(SubcompositorUpdateBounds, SubcompositorUpdateBoundsForInsert)
(ViewRecomputeChildren, ViewAfterSizeUpdate, ViewMove, ViewFree)
(SubcompositorUpdate, SubcompositorExpose,
SubcompositorLookupView): Skip "skipped" views.
* subsurface.c (AfterParentCommit): Unskip views.
(Setup): Mark view as unskipped.
2022-09-30 03:13:11 +00:00
oldosfan
4d2e85d002 Implement wp_viewporter support and fix scaling for fractional values
* 12to11.c (XLMain): Initialize wp_viewporter.
* Imakefile (ETAGS): Remove unused variable.
(SRCS, OBJS): Add wp_viewporter.c and wp_viewporter.o.
(GENHEADERS): Remove unnecessary headers.
(viewporter): New scanner target.
* README: Document support for wp_viewporter.
* compositor.h (struct _ViewportExt): New forward declaration.
(struct _DrawParams): New fields for cropping and stretching.
(struct _RenderFuncs): Describe how composite works.
(struct _BufferFuncs): Make update_buffer_for_damage take
DrawParams as an argument.
(struct _State): New fields for viewporting.
(struct _Surface): New field `viewport' and associated input
delta.
(struct _XdgRoleImplementationFuncs): New field
`is_window_mapped'.  Do not commit while unmapped.
* dmabuf.c (XLInitDmabuf): Remove outdated comment.
* dnd.c (HandleMotion): Use TruncateWindowToSurface.
* egl.c (struct _EglBuffer): Add 3x3 reverse transformation
matrix.
(struct _CompositeProgram): Rename `scale' to `source'.
(Index): New macro.
(PickBetterVisual, FindVisual): Compensate for EGL picking a
non-RGBA visual.
(EglCompileCompositeProgram): Look for source, not scale.
(ComputeTransformMatrix): New function.
(Composite): Compute transformation matrix and draw using that.
(BufferFromDmaBuf, BufferFromShm): Copy identity transform and
stop setting scale.
(ReverseTransformToBox): New function.
(UpdateShmBufferIncrementally): Accept DrawParams and invert
damage according to that.
(UpdateBuffer, UpdateBufferForDamage): Pass draw params to the
incremental buffer update function.
* fns.c (XLExtendRegion): New function.
* frame_clock.c (CurrentHighPrecisionTimestamp): Delete
function.
(HighPrecisionTimestamp, HighPrecisionTimestamp32): New
functions.
(PostEndFrame): Handle X server time truncation to 32 bits.
(XLFrameClockFreeze): Remove trailing whitespace.
* picture_renderer.c (GetSourceX, GetSourceY, CompareStretch):
New functions.
(MaybeApplyTransform): Check more values before applying
transformations.  Then, handle stretch and offset.
* positioner.c (GetAdjustmentOffset, ApplyConstraintAdjustment)
(XLPositionerCalculateGeometry): Scale coordinates using new
functions.
* renderer.c (RenderUpdateBufferForDamage): Accept DrawParams
instead of scale.
* shaders.txt (Composite Rectangle Fragment Shader RGBA)
(Composite Rectangle Fragment Shader RGBX)
(Composite Rectangle Fragment Shader External): Stop
transforming texcoords.
(Composite Rectangle Vertex Shader): Transform texcoords in the
vertex shader instead.
* subcompositor.c (IsViewported, SetViewported,
ClearViewported): New functions.
(struct _View): New fields for tracking viewports and fractional
offsets.
(ViewAttachBuffer): Do not garbage upon buffer size change if a
viewport is set.
(ViewMoveFractional): New function.
(ViewDamage): Describe what the damage is and is not transformed
by.
(GetContentScale): New function.
(ViewWidth, ViewHeight): Apply viewport.
(ViewSetScale): Use ViewAfterSizeUpdate instead of duplicating
code.
(ViewSetViewport, ViewClearViewport): New functions.
(ViewComputeTransform): Compute transform for viewports.  New
arg draw; use it to determine whether or not to include a
fractional offset.
(IntersectBoxes): Fix intersection calculation.
(SubcompositorUpdate): Don't keep calling ViewWidth and
ViewHeight in a loop.
(SubcompositorExpose): Adjust for changes to buffer damage
uploading.
* subsurface.c (MoveFractional): New function.  Handle
fractional offsets after scaling.
(MaybeUpdateOutputs, AfterParentCommit, Setup, Rescale): Use
that function to move the subsurface instead.
* surface.c (ApplyScale): Update comment.
(ApplyViewport, CheckViewportValues): New functions.
(HandleScaleChanged): Apply the viewport as well upon scale
change.
(ApplyDamage): Improve damage calculation for viewported
surfaces.
(SavePendingState, InternalCommit): Save and commit viewport
state; check old values upon buffer commit.
(InitState): Initialize viewport to initial values.
(XLSurfaceRunFrameCallbacks): Handle overflows of 32-bit time at
the 49-day mark.
(SurfaceToWindow, ScaleToWindow, WindowToSurface, ScaleToSurface)
(TruncateScaleToWindow, TruncateScaleToWindow)
(TruncateWindowToSurface, TruncateScaleToSurface): New functions
for handling scale.
* xdg_popup.c (MoveWindow, IsWindowMapped, XLGetXdgPopup):
* xdg_surface.c (IsRoleMapped, Commit, Subframe)
(GetResizeDimensions, XLXdgRoleCalcNewWindowSize):
* xdg_toplevel.c (IsWindowMapped, NoteConfigureTime, SendStates)
(RecordStateSize, HandleWindowGeometryChange, NoteWindowPreResize)
(XLGetXdgToplevel): Use them instead of manually multiplying
with the factor.
2022-09-30 01:17:47 +00:00
oldosfan
7f33ba9ae3 Improve handling buffer scale factors
* compositor.h (struct _DrawParams): New structure.
(struct _RenderFuncs): Remove `apply_transform' and
`reset_transform'.  Make `composite' accept DrawParams.
(struct _BufferFuncs): Give scale to update_buffer_for_damage.
(struct _Surface): New field `factor'.
(struct _RoleFuncs): New callback `parent_rescale'.
* dnd.c (HandleMotion): Fix some aspects of scale handling.
* egl.c (struct _EglBuffer): Remove `scale' field.
(ApplyTransform): Delete function.
(Composite): Pass scale specified in params as uniform to
program.
(ResetTransform): Delete function.
(egl_render_funcs): Delete apply_transform and reset_transform.
(BufferFromDmaBuf, BufferFromShm): Stop setting scale attribute.
(UpdateBufferForDamage): Accept new arg `scale' and use it.

* picture_renderer.c (struct _PictureBuffer): New structure.
Store picture and last seen draw parameters.
(ApplyTransform): Delete function.
(GetScale): New function.
(MaybeApplyTransform): New function.
(Composite): Recompute and set pictures if draw parameters
change.
(ResetTransform): Delete function.
(picture_render_funcs): Remove unused hooks.
(BufferFromDmaBuf, FinishDmaBufRecord, BufferFromShm)
(FreeShmBuffer, FreeDmabufBuffer): Replace xid with wrapper
structure.

* positioner.c (TryFlipX, TryFlipY, GetAdjustmentOffset)
(ApplyConstraintAdjustment):
* renderer.c (RenderApplyTransform, RenderComposite)
(RenderResetTransform, RenderFinishRender)
(RenderUpdateBufferForDamage):
* seat.c (UpdateCursorOutput, ComputeHotspot, HandleRawButton)
(TransformToView, DispatchEntryExit, DispatchMotion, CancelGrab)
(DispatchButton, ForceEntry):
* subcompositor.c (GetTxTy, ViewApplyTransform, ViewHaveTransform)
(ViewComputeTransform, SubcompositorUpdate,
SubcompositorExpose):
* subsurface.c (MaybeUpdateOutputs, AfterParentCommit, Rescale)
(Teardown, GetSubsurface, XLUpdateOutputsForChildren): Use
surface-specific scale factors.
* surface.c (ApplyScale): Compute a new scale factor to convert
between window and surface scale.
(ApplyOpaqueRegion, ApplyInputRegion, HandleScaleChanged)
(ApplySurfaceDamage, InternalCommit, XLCreateSurface): Use new
factors instead.
* xdg_popup.c (MoveWindow):
* xdg_surface.c (GetResizeDimensions,
XLXdgRoleCalcNewWindowSize):
* xdg_toplevel.c (NoteConfigureTime, SendStates, RecordStateSize)
(HandleWindowGeometryChange, NoteWindowPreResize): Use
surface-specific scale factors.
2022-09-27 01:37:31 +00:00
oldosfan
007ba43dba Resolve some TODOs
* 12to11.c (PickVisual): Remove redundant TODOs.
* dmabuf.c (CreateHeader): Handle flags like wlroots.
* dnd.c (HandleXdndPositionEvent):
* subsurface.c:
* xdg_surface.c (CurrentRootPosition, XLGetXdgSurface): Remove
outdated TODOs.
2022-09-15 02:38:06 +00:00
oldosfan
528f7ba858 Import files 2022-09-12 13:24:50 +00:00