Commit Graph

224 Commits

Author SHA1 Message Date
Antonin Décimo d9bb792794 Fix incorrect format parameters 2020-07-27 10:49:19 +02:00
Simon Ser d177abecae surface: ignore viewport src rect on NULL buffer
According to the viewporter protocol:

> If the wl_buffer is NULL, the surface has no content and therefore no size.
2020-06-18 07:55:33 -06:00
Rouven Czerwinski c18c419b56 surface: don't unset width and height in finalize
During surface finalization we may not have received a new buffer,
resetting width and height in this case is wrong since we display the
old buffer in this case.
2020-06-18 09:54:15 +02:00
Simon Ser c618a76540 surface: introduce wlr_surface_get_buffer_source_box
This helper allows compositors to retrieve the buffer source box in
buffer-local coordinates.
2020-06-17 09:10:54 -06:00
Simon Ser eb22ae97b0 surface: add wlr_surface_state.viewport
This field contains the viewport source and destination parameters. It's
intended to be updated by a third-party protocol, for instance
viewporter.
2020-06-17 09:10:54 -06:00
Tudor Brindus c9c31f803e util/time: de-duplicate `timespec_to_msec` 2020-06-06 00:09:19 +02:00
Simon Ser 6595db6409 buffer: add a release event
Consumers call wlr_buffer_lock. Once all consumers are done with the
buffer, only the producer should have a reference to the buffer. In this
case, we can release the buffer (and let the producer re-use it).
2020-04-02 15:03:43 +02:00
Scott Anderson 34303e1b47 wlr_surface: Post error if multiple role objects created
This fixes an assertion failure if a client tries to do this, e.g. by
creating multiple toplevel objects for the same surface. If the same
role data is set multiple times, this does not cause an error, which is
how cursors use this interface.
2020-03-21 13:58:27 +01:00
Simon Ser 41f9916ae5 buffer: remove unused wlr_client_buffer fields
Forgot to remove these, they are superseded by fields in wlr_buffer. Some
functions were still using them.

Fixes: 8afc1ed68c ("Introduce wlr_client_buffer")
Closes: https://github.com/swaywm/sway/issues/5087
2020-03-09 19:26:12 +01:00
Simon Ser 8afc1ed68c Introduce wlr_client_buffer
Split out the client/resource handling out of wlr_buffer by introducing
wlr_client_buffer. Make wlr_buffer an interface so that compositors can
create their own wlr_buffers (e.g. backed by GBM, like glider [1]).

[1]: c66847dd1c/include/gbm_allocator.h (L7)
2020-03-06 21:32:06 +01:00
Simon Ser 7fc58e704a surface: don't unref the current buffer on failure
If wlr_buffer_create fails, keep the previous buffer.
2019-12-14 09:19:44 -05:00
Alynx Zhou aa9ea95e1f Skip assign when sub_x or sub_y is NULL in wlr_surface_surface_at 2019-11-08 08:48:30 +01:00
Antonin Décimo 8f3d73e3a3 wlr_surface: condition is always false 2019-08-12 09:37:21 +09:00
Simon Ser ca45f4490c Remove all wayland-server.h includes
The documentation for wayland-server.h says:

> Use of this header file is discouraged. Prefer including
> wayland-server-core.h instead, which does not include the server protocol
> header and as such only defines the library PI, excluding the deprecated API
> below.

Replacing wayland-server.h with wayland-server-core.h allows us to drop the
WL_HIDE_DEPRECATED declaration.
2019-07-27 15:49:32 -04:00
emersion 943e918a96
subsurface: add map/unmap events
Fixes https://github.com/swaywm/wlroots/issues/1414
2019-02-17 12:01:15 +01:00
emersion d238cc9f56
surface: error out on invalid transform 2019-02-15 00:50:18 +01:00
Sebastian Krzyszkowiak 69b9e2ae8f Post protocol error on invalid wl_surface scale
Letting the scale be set to 0 causes division by zero errors.
2019-02-15 00:45:12 +01:00
emersion a5b8ea90d2
surface: fix destroyed subsurfaces handling
wlr_subsurface_from_wlr_surface can return NULL if the wl_surface is still
alive and if the wl_subsurface has been destroyed. Make sure we check for NULL.

Fixes https://github.com/swaywm/sway/issues/3195
2018-11-26 23:17:52 +01:00
Drew DeVault d7b010024a
Merge pull request #1261 from arandomhuman/damage-control
Fix damage tracking for surfaces with transforms
2018-11-04 14:31:17 +01:00
emersion dec303bea6
surface: fix wlr_surface_get_effective_damage to give surface coords
Transforms were applied, but scale wasn't.
2018-11-04 11:13:10 +01:00
random human 3e0a0f3c3a
wlr_surface: add wlr_surface_get_effective_damage
This calculates and returns the effective damage of the surface in
surface coordinates, including the client damage (in buffer
coordinates), and damage induced by resize or move events.
2018-10-04 02:19:09 +05:30
random human 84ecfb546b
wlr_surface: more consistent argument naming in surface_update_damage 2018-09-25 02:06:02 +05:30
random human 5eca5d8946
wlr_surface: remove duplicated damage calculation
The damage is already calculated and stored in surface->buffer_damage
by surface_update_damage().
2018-09-25 01:38:09 +05:30
random human 3fd5da58a0
wlr_surface: fix surface damage on resize
Instead of damaging the buffer, damage only the surface on surface (not
buffer) resize.
2018-09-25 01:25:30 +05:30
random human 971cbeaa19
wlr_surface: fix surface damage transformation
Damage tracking on transformed surfaces now work (see
"weston-simple-damage --rotation=90"), using either of buffer or surface
damage.
2018-09-24 22:03:41 +05:30
Las afa2e399aa Fix implicit conversion of floats to ints in calls to pixman_region32_contains_point
I do not think the conversion is specifically defined, but on my system and SirCmpwn's
the floats are rounded instead of floored, which is incorrect in this case, since
for a range from 0 to 256, any value greater or equal to 0 and less than 256 is valid.
I.e. [0;256[, or 0 <= x < 256, but if x is e.g. -0.1, then it will be rounded to 0, which
is invalid. The correct behavior would be to floor to -1.
2018-09-18 13:05:44 +02:00
Las 6367e0bc93 Add wlr_surface::input_region member
This is analogous to the opaque_region member.

In addition the code for setting the opaque region is cleaned up.
2018-09-18 10:14:33 +02:00
emersion 16d7e09d99 surface: add wlr_surface_role.precommit
This allows to emit the unmap event before the surface becomes
actually unmapped for most shells.
2018-07-15 19:30:19 +01:00
emersion 5bb272d7f3 surface: add wlr_surface.opaque_region 2018-07-13 10:54:51 +01:00
Drew DeVault c0b4217fce
Merge pull request #1116 from emersion/surface-role
surface: replace wlr_surface_set_role_committed with wlr_surface_role
2018-07-11 15:27:42 -07:00
emersion 7cbef15206
util: add wlr_ prefix to log symbols 2018-07-09 22:49:54 +01:00
emersion deeca53e33
Rename wl_resources to resource, wl_global to global 2018-07-08 19:21:31 +01:00
emersion 33db4263a0
surface: replace wlr_surface_set_role_committed with wlr_surface_role 2018-07-07 22:45:16 +01:00
emersion 515d682312
surface: fix damage when moving subsurfaces with scale > 1 2018-07-04 19:16:16 +01:00
emersion e665a74122
surface: don't clip input and opaque regions
These can be set to e.g. regions larger than the surface. If the
surface resizes itself, it doesn't need to set again these regions.
2018-07-04 19:12:18 +01:00
emersion 226306ed45
surface: rename wlr_surface_state.buffer to buffer_resource 2018-07-04 19:12:18 +01:00
emersion 68c133da2f
surface: fix crash on NULL commit 2018-07-04 19:12:18 +01:00
emersion 6f0eb11024
surface: fix previous state eating current state resources 2018-07-04 19:12:18 +01:00
emersion 012e38fbe5
surface: add wlr_surface.previous 2018-07-04 19:12:18 +01:00
emersion 78555abba3
surface: move position and scale out of wlr_surface_state 2018-07-04 19:12:17 +01:00
emersion 233bfe2f4f
surface: do not monkey-patch state damage 2018-07-04 19:12:17 +01:00
emersion adf0423f7c
surface: better buffer position handling 2018-07-04 19:12:17 +01:00
emersion 3c0d672ebd
surface: make pending and current embedded structs 2018-07-04 19:12:17 +01:00
emersion 64836ddfe7
surface: remove wlr_surface_state.subsurface_position 2018-07-04 19:12:17 +01:00
emersion 3ee86b6105
surface: rename invalid state 2018-07-04 19:12:16 +01:00
Ilia Bozhinov 00ccf5c3ae properly check if the point is inside the surface in wlr_surface_point_accepts_input 2018-07-03 10:29:02 +03:00
Dominique Martinet c263f7ca29 s/wlr_subsurface_from_surface/wlr_subsurface_from_wlr_surface/
This was the only x_from_wlr_surface function that lacked the wlr_ prefix,
let's have an API as uniform as possible.
2018-06-30 21:21:13 +09:00
emersion a6c0e25d36
surface: remove wlr_frame_callback
This removes the need to allocate a structure for frame callbacks.
wl_resource_get_link is used instead.
2018-06-20 20:00:23 +01:00
emersion 843621714f
surface: fix double wl_buffer.release events
Prior to this commit, we re-uploaded the buffer even if a new one
wasn't attached. After uploading, we send wl_buffer.release. So,
this sequence of requests resulted in a double release:

    surface.attach(buffer, 0, 0)
    surface.commit()
    <- buffer.release()
    surface.commit()
    <- buffer.release()
2018-06-17 12:49:34 +01:00
emersion 0378d143d9
surface: remove wlr_surface.texture
The texture is managed by the surface's wlr_buffer now. In
particular, the buffer can destroy the texture early if it becomes
invalid.
2018-06-13 19:38:10 +01:00
emersion e4933ab445
Introduce wlr_buffer 2018-06-08 20:06:13 +01:00
Dominique Martinet c6821f3dd3 wlr_surface: insert subsurfaces in revert order
sibling surfaces were drawn in incorrect order (e.g. latest below).
This attempts to fix that by reverting the order of the list.
2018-06-05 21:02:42 +09:00
Dominique Martinet cf9b8c0a8c wlr_surface_get_root_surface: walk up parent
This would dead-loop and never walk up if called on a subsurface
2018-06-05 00:17:58 +09:00
Markus Ongyerth 7b07b3f95d Fix type in wlr_surface_get_extends 2018-06-01 16:36:04 +02:00
Markus Ongyerth 3994762ae0 Add wlr_surface_get_geometry
This function defaults and clips the xdg-surface geometry to the
bounding box of the surface + its subsurfaces, as specified by the
protocol spec.
2018-06-01 15:21:18 +02:00
Genki Sky d1cf9acbd5 cleanup: Use void for zero-parameter functions
Signed-off-by: Genki Sky <sky@genki.is>
2018-05-30 20:19:16 -04:00
emersion 28020ff577
Only allow one modifier per DMA-BUF, split attributes struct in render/ 2018-05-30 09:29:12 +01:00
emersion da504f9253
surface: remove wl_resource_post_event 2018-05-26 19:43:55 +01:00
emersion 6d569def6d
compositor, surface: correctly destroy resources 2018-05-03 18:45:30 +01:00
emersion 43012f3740
compositor: redesign how resources are managed
All public resource creators now take a new ID for the resource
and an optional list where the resource link is added. When the
resource is destroyed it is its own responsibility to remove
itself from the list. This removes the need for the caller to add
a destroy listener.

This commit fixes a few segfaults with resources not removed from
the list when destroyed.
2018-04-26 17:51:06 +01:00
Drew DeVault fecb971518
Merge pull request #902 from emersion/various-memory-leaks
Various memory leaks
2018-04-26 11:34:49 +02:00
emersion 449f06556a
Destroy wlr_surface with wlr_renderer 2018-04-26 00:11:36 +01:00
emersion d47713ac0f
compositor: destroy subsurface resources with wlr_subcompositor 2018-04-25 23:53:44 +01:00
emersion 625a7a48dc
Don't use the wlr_ prefix for static functions 2018-04-25 23:51:00 +01:00
emersion b0d99f5c67
Remove wlr_ prefix from local symbols 2018-04-25 23:00:46 +01:00
emersion fa84b267e0
Remove wlr_surface::subsurface 2018-04-21 18:40:25 +01:00
emersion 4a9a9eae9a
Add surface iterators 2018-04-05 14:18:17 -04:00
emersion 1a8b24bdd2
rootston: fix view_at 2018-04-04 17:16:35 -04:00
emersion d16127b3cb
Fix wlr_surface_subsurface_at, change it to be wlr_surface_surface_at 2018-04-04 16:48:23 -04:00
Drew DeVault e19ee6d469 Add wlr_surface_point_accepts_input
Ref https://github.com/swaywm/sway/pull/1674
2018-03-30 23:02:11 -04:00
emersion 6bbf507082
surface: fix texture not updated on commit
When a client attaches a wl_drm or a linux_dmabuf buffer, we only
update it if the size is different from the one of the old buffer.
This means that if the client attaches a new, updated buffer with
the same size as the old buffer, the texture won't get updated.

This commit changes this behavior and re-creates the texture if
the client attaches a new buffer, without requiring the size to be
different.
2018-03-29 19:44:57 -04:00
emersion c63d94483b
Redesign wlr_texture
- Textures are now immutable (apart from those created from raw
  pixels), no more invalid textures
- Move all wl_drm stuff in wlr_renderer
- Most of wlr_texture fields are now private
- Remove some duplicated DMA-BUF code in the DRM backend
- Add more assertions
- Stride is now always given as bytes rather than pixels
- Drop wl_shm functions

Fun fact: this patch has been written 10,000 meters up in the air.
2018-03-24 23:48:32 -04:00
Guido Günther 805039457a wlr_surface: fix indentation 2018-03-23 08:59:48 +01:00
emersion 1914a1aa2b
surface: drop wlr_surface_get_matrix 2018-03-15 18:35:22 +01:00
emersion 8b58e1a3ad
Merge branch 'master' into matrix-redesign 2018-03-15 15:48:09 +01:00
emersion 824a95ad19
matrix: use 2D matrices 2018-03-15 15:33:58 +01:00
emersion de0e40d621
Merge pull request #698 from agx/linux-dmabuf
Add initial linux_dmabuf protocol support
2018-03-15 12:45:07 +01:00
Guido Günther 14cdb6153f Add initial linux_dmabuf protocol support
Tested with

    ./weston-simple-dmabuf-drm
    ./weston-simple-dmabuf-drm --import-immediate=1
    ./weston-simple-dmabuf-drm --y-inverted=1
    (and combinations)

Supports only single plane XRGB dmabufs for now.
2018-03-15 12:40:18 +01:00
emersion d26b67cb06
matrix: unify API, don't use array pointers 2018-03-15 11:10:56 +01:00
emersion b6a3f240c7
matrix: move to types/ 2018-03-15 09:11:27 +01:00
emersion 90148e64ab
Fix clients binding multiple times to the same output 2018-03-01 10:19:48 +01:00
emersion f0404f6d75
surface: don't reset frame_callback_list on resize 2018-02-22 22:40:02 +01:00
Drew DeVault 1d9be89e2d
Revert "ELF Visibility" 2018-02-19 18:01:27 -05:00
Scott Anderson 86269052eb Explicitly export EFL symbols 2018-02-19 14:26:40 +13:00
emersion 392d54a35d
Wrap wl_resource_get_user_data into safer helper functions
This ensures we're not incorrectly casting a resource.

Fixes #628
2018-02-13 23:48:46 +01:00
emersion c2e1474010
Reformat all #include directives 2018-02-12 21:29:23 +01:00
emersion 36ead80cd1
Make wlr_signal_emit_safe private 2018-02-12 19:52:47 +01:00
emersion 5e58d46cc1
Add wlr_signal_emit_safe 2018-02-12 09:12:31 +01:00
emersion e049610b47
surface: copy buffer damage to surface damage 2018-01-28 21:29:51 +01:00
emersion 861d5bdff2
surface: fix damage when resizing a surface in QT apps 2018-01-27 21:49:40 +01:00
emersion ece2c1e4e2
Damage tracking for transformed outputs 2018-01-26 22:11:09 +01:00
emersion a8cb02f585
surface: add damage when subsurface moves 2018-01-22 10:34:23 +01:00
emersion 59c53e8333
Merge remote-tracking branch 'upstream/master' into output-damage 2018-01-21 22:18:06 +01:00
Johannes Schramm dcc743047b style: include brackets for if/while/for, even if it's a single statement 2018-01-21 16:28:21 +01:00
emersion eeffe11337
surface: add wlr_surface new_subsurface and wlr_subsurface destroy events 2018-01-21 14:22:33 +01:00
emersion ddafcb86a2
surface: add resize damage 2018-01-20 00:52:43 +01:00
emersion 59ba8f35ed
rootston: use surface damage 2018-01-18 21:34:10 +01:00
Tony Crisci 5a18f62fee add role-committed hook 2017-12-27 06:06:29 -05:00
emersion 54f1135c05
Fix fullscreen in xdg-shell 2017-11-20 20:53:13 +01:00
Drew DeVault 86b8729998 Merge remote-tracking branch 'origin/master' into hidpi 2017-11-02 23:34:02 -04:00