Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use wlroots scene graph api #6844

Merged
merged 28 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c8dfabf
desktop: Rename layers to shell_layers
Nefsen402 Mar 1, 2022
ea6dc8e
view: init function should return a success bool
Nefsen402 Mar 5, 2022
7b11e79
scene_graph: Maintain `wlr_scene_node`s for the sway tree.
Nefsen402 Jan 18, 2024
31f11bb
scene_graph: Use built-in linux dmabuf feedback handling
Nefsen402 Apr 13, 2023
7509975
scene_graph: Introduce sway_scene_descriptor
Nefsen402 Nov 22, 2023
3532e42
renderer: Render scene_graph
Nefsen402 Dec 4, 2023
73e28f5
scene_graph: Port seat drag icons
Nefsen402 Nov 22, 2023
a28b7ba
scene_graph: Port seatop_move_tiling indicators
Nefsen402 Nov 22, 2023
8e46e2f
scene_graph: Port ext_session_v1
Nefsen402 Jan 18, 2024
164e496
seat: Remove dead seatop_render function
Nefsen402 Feb 22, 2022
ad2fd11
renderer: Remove in favor of scene_graph
Nefsen402 Mar 4, 2023
fac3d3a
Introduce sway_text_node
Nefsen402 Nov 23, 2023
05887c8
input: Query scene graph for relevant surface/node intersections
Nefsen402 Nov 23, 2023
35a7eda
scene_graph: Port layer_shell
Nefsen402 Jan 18, 2024
b2e9e0c
scene_graph: Port container server side decorations
Nefsen402 Nov 22, 2023
531cf4c
transaction: ready signals will return success bools
Nefsen402 Mar 5, 2022
e861571
scene_graph: Port xdg_shell
Nefsen402 Dec 6, 2023
c240189
scene_graph: Port xwayland
Nefsen402 Jan 18, 2024
c41b35f
xwayland: Cleanup geometry handling on commit
Nefsen402 Mar 1, 2022
ac63561
scene_graph: Port view saved buffers
Nefsen402 Apr 27, 2023
bf1aa93
Delete old damage tracking code
Nefsen402 Apr 6, 2023
9aac54c
container: Don't track outputs
Nefsen402 Feb 22, 2023
26fee42
scene_graph: Arrange scene graph on transaction apply
Nefsen402 Jan 18, 2024
dca8f1a
scene_graph: Port opacity and filter modes
Nefsen402 Aug 16, 2023
803a3eb
scene_graph: Implement toplevel clipping
Nefsen402 Nov 22, 2023
c110b9c
Fix SIGSEGV on surface destroy
Nefsen402 Mar 18, 2022
46ae39d
remove damage debug options
Nefsen402 Apr 30, 2022
079ebb6
scene_graph: port wlr_forgein_toplevel_management output enter/leave …
Nefsen402 Nov 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions include/sway/desktop.h

This file was deleted.

11 changes: 9 additions & 2 deletions include/sway/desktop/transaction.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _SWAY_TRANSACTION_H
#define _SWAY_TRANSACTION_H
#include <stdint.h>
#include <stdbool.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: include order.


/**
* Transactions enable us to perform atomic layout updates.
Expand Down Expand Up @@ -38,17 +39,23 @@ void transaction_commit_dirty_client(void);
* Notify the transaction system that a view is ready for the new layout.
*
* When all views in the transaction are ready, the layout will be applied.
*
* A success boolean is returned denoting that this part of the transaction is
* ready.
*/
void transaction_notify_view_ready_by_serial(struct sway_view *view,
bool transaction_notify_view_ready_by_serial(struct sway_view *view,
Nefsen402 marked this conversation as resolved.
Show resolved Hide resolved
uint32_t serial);

/**
* Notify the transaction system that a view is ready for the new layout, but
* identifying the instruction by geometry rather than by serial.
*
* This is used by xwayland views, as they don't have serials.
*
* A success boolean is returned denoting that this part of the transaction is
* ready.
*/
void transaction_notify_view_ready_by_geometry(struct sway_view *view,
bool transaction_notify_view_ready_by_geometry(struct sway_view *view,
double x, double y, int width, int height);

#endif
34 changes: 11 additions & 23 deletions include/sway/input/seat.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_touch.h>
#include <wlr/util/edges.h>
Expand All @@ -12,7 +13,6 @@
#include "sway/input/text_input.h"

struct sway_seat;
struct render_context;

struct sway_seatop_impl {
void (*button)(struct sway_seat *seat, uint32_t time_msec,
Expand Down Expand Up @@ -52,7 +52,6 @@ struct sway_seatop_impl {
uint32_t time_msec, enum wlr_tablet_tool_tip_state state);
void (*end)(struct sway_seat *seat);
void (*unref)(struct sway_seat *seat, struct sway_container *con);
void (*render)(struct sway_seat *seat, struct render_context *ctx);
bool allow_set_cursor;
};

Expand All @@ -75,20 +74,6 @@ struct sway_seat_node {
struct wl_listener destroy;
};

struct sway_drag_icon {
struct sway_seat *seat;
struct wlr_drag_icon *wlr_drag_icon;
struct wl_list link; // sway_root::drag_icons

double x, y; // in layout-local coordinates
int dx, dy; // offset in surface-local coordinates

struct wl_listener surface_commit;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
};

struct sway_drag {
struct sway_seat *seat;
struct wlr_drag *wlr_drag;
Expand All @@ -99,6 +84,15 @@ struct sway_seat {
struct wlr_seat *wlr_seat;
struct sway_cursor *cursor;

// Seat scene tree structure
// - scene_tree
// - drag icons
// - drag icon 1
// - drag icon 2
// - seatop specific stuff
struct wlr_scene_tree *scene_tree;
struct wlr_scene_tree *drag_icons;

bool has_focus;
struct wl_list focus_stack; // list of containers in focus order
struct sway_workspace *workspace;
Expand Down Expand Up @@ -257,7 +251,7 @@ void seat_idle_notify_activity(struct sway_seat *seat,

bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface);

void drag_icon_update_position(struct sway_drag_icon *icon);
void drag_icons_update_position(struct sway_seat *seat);

enum wlr_edges find_resize_edge(struct sway_container *cont,
struct wlr_surface *surface, struct sway_cursor *cursor);
Expand Down Expand Up @@ -357,12 +351,6 @@ void seatop_end(struct sway_seat *seat);
*/
void seatop_unref(struct sway_seat *seat, struct sway_container *con);

/**
* Instructs a seatop to render anything that it needs to render
* (eg. dropzone for move-tiling)
*/
void seatop_render(struct sway_seat *seat, struct render_context *ctx);

bool seatop_allows_set_cursor(struct sway_seat *seat);

/**
Expand Down
44 changes: 9 additions & 35 deletions include/sway/layers.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,30 @@
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_layer_shell_v1.h>

enum layer_parent {
LAYER_PARENT_LAYER,
LAYER_PARENT_POPUP,
};

struct sway_layer_surface {
struct wlr_layer_surface_v1 *layer_surface;
struct wl_list link;

struct wl_listener destroy;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener surface_commit;
struct wl_listener output_destroy;
struct wl_listener node_destroy;
struct wl_listener new_popup;
struct wl_listener new_subsurface;

struct wlr_box geo;
bool mapped;
struct wlr_box extent;
enum zwlr_layer_shell_v1_layer layer;

struct wl_list subsurfaces;
struct sway_output *output;
struct wlr_scene_layer_surface_v1 *scene;
struct wlr_scene_tree *tree;
struct wlr_scene_tree *popups;
struct wlr_layer_surface_v1 *layer_surface;
};

struct sway_layer_popup {
struct wlr_xdg_popup *wlr_popup;
enum layer_parent parent_type;
union {
struct sway_layer_surface *parent_layer;
struct sway_layer_popup *parent_popup;
};
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
struct wl_listener commit;
struct wl_listener new_popup;
};

struct sway_layer_subsurface {
struct wlr_subsurface *wlr_subsurface;
struct sway_layer_surface *layer_surface;
struct wl_list link;
struct wlr_scene_tree *scene;
struct sway_layer_surface *toplevel;

struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
struct wl_listener new_popup;
struct wl_listener commit;
};

Expand All @@ -61,7 +38,4 @@ struct wlr_layer_surface_v1 *toplevel_layer_surface_from_surface(

void arrange_layers(struct sway_output *output);

struct sway_layer_surface *layer_from_wlr_layer_surface_v1(
struct wlr_layer_surface_v1 *layer_surface);

#endif
92 changes: 20 additions & 72 deletions include/sway/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <wayland-server-core.h>
#include <wlr/types/wlr_damage_ring.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_scene.h>
#include "config.h"
#include "sway/tree/node.h"
#include "sway/tree/view.h"
Expand All @@ -19,16 +20,31 @@ struct sway_output_state {

struct sway_output {
struct sway_node node;

struct {
struct wlr_scene_tree *shell_background;
struct wlr_scene_tree *shell_bottom;
struct wlr_scene_tree *tiling;
struct wlr_scene_tree *fullscreen;
struct wlr_scene_tree *shell_top;
struct wlr_scene_tree *shell_overlay;
struct wlr_scene_tree *session_lock;
} layers;

// when a container is fullscreen, in case the fullscreen surface is
// translucent (can see behind) we must make sure that the background is a
// solid color in order to conform to the wayland protocol. This rect
// ensures that when looking through a surface, all that will be seen
// is black.
struct wlr_scene_rect *fullscreen_background;

struct wlr_output *wlr_output;
struct wlr_scene_output *scene_output;
struct sway_server *server;
struct wl_list link;

struct wl_list layers[4]; // sway_layer_surface::link
struct wlr_box usable_area;

struct timespec last_frame;
struct wlr_damage_ring damage_ring;

int lx, ly; // layout coords
int width, height; // transformed buffer size
enum wl_output_subpixel detected_subpixel;
Expand All @@ -43,9 +59,7 @@ struct sway_output {
struct wl_listener destroy;
struct wl_listener commit;
struct wl_listener present;
struct wl_listener damage;
struct wl_listener frame;
struct wl_listener needs_frame;
struct wl_listener request_state;

struct {
Expand All @@ -65,14 +79,6 @@ struct sway_output_non_desktop {
struct wl_listener destroy;
};

struct render_context {
struct sway_output *output;
struct wlr_renderer *renderer;
const pixman_region32_t *output_damage;

struct wlr_render_pass *pass;
};

struct sway_output *output_create(struct wlr_output *wlr_output);

void output_destroy(struct sway_output *output);
Expand All @@ -91,19 +97,6 @@ typedef void (*sway_surface_iterator_func_t)(struct sway_output *output,
struct sway_view *view, struct wlr_surface *surface, struct wlr_box *box,
void *user_data);

void output_damage_whole(struct sway_output *output);

void output_damage_surface(struct sway_output *output, double ox, double oy,
struct wlr_surface *surface, bool whole);

void output_damage_from_view(struct sway_output *output,
struct sway_view *view);

void output_damage_box(struct sway_output *output, struct wlr_box *box);

void output_damage_whole_container(struct sway_output *output,
struct sway_container *con);

bool output_match_name_or_id(struct sway_output *output,
const char *name_or_id);

Expand All @@ -119,46 +112,8 @@ void output_enable(struct sway_output *output);

void output_disable(struct sway_output *output);

bool output_has_opaque_overlay_layer_surface(struct sway_output *output);

struct sway_workspace *output_get_active_workspace(struct sway_output *output);

void output_render(struct render_context *ctx);

void output_surface_for_each_surface(struct sway_output *output,
struct wlr_surface *surface, double ox, double oy,
sway_surface_iterator_func_t iterator, void *user_data);

void output_view_for_each_surface(struct sway_output *output,
struct sway_view *view, sway_surface_iterator_func_t iterator,
void *user_data);

void output_view_for_each_popup_surface(struct sway_output *output,
struct sway_view *view, sway_surface_iterator_func_t iterator,
void *user_data);

void output_layer_for_each_surface(struct sway_output *output,
struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
void *user_data);

void output_layer_for_each_toplevel_surface(struct sway_output *output,
struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
void *user_data);

void output_layer_for_each_popup_surface(struct sway_output *output,
struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
void *user_data);

#if HAVE_XWAYLAND
void output_unmanaged_for_each_surface(struct sway_output *output,
struct wl_list *unmanaged, sway_surface_iterator_func_t iterator,
void *user_data);
#endif

void output_drag_icons_for_each_surface(struct sway_output *output,
struct wl_list *drag_icons, sway_surface_iterator_func_t iterator,
void *user_data);

void output_for_each_workspace(struct sway_output *output,
void (*f)(struct sway_workspace *ws, void *data), void *data);

Expand All @@ -176,13 +131,6 @@ void output_get_box(struct sway_output *output, struct wlr_box *box);
enum sway_container_layout output_get_default_layout(
struct sway_output *output);

void render_rect(struct render_context *ctx, const struct wlr_box *_box,
float color[static 4]);

void premultiply_alpha(float color[4], float opacity);

void scale_box(struct wlr_box *box, float scale);

enum wlr_direction opposite_direction(enum wlr_direction d);

void handle_output_layout_change(struct wl_listener *listener, void *data);
Expand Down
33 changes: 33 additions & 0 deletions include/sway/scene_descriptor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Across a wayland compositor, there are multiple shells: It can be
* a toplevel, or a layer_shell, or even something more meta like a drag
* icon or highlight indicators when dragging windows around.
*
* This object lets us store values that represent these modes of operation
* and keep track of what object is being represented.
*/
#ifndef _SWAY_SCENE_DESCRIPTOR_H
Nefsen402 marked this conversation as resolved.
Show resolved Hide resolved
#define _SWAY_SCENE_DESCRIPTOR_H
#include <wlr/types/wlr_scene.h>

enum sway_scene_descriptor_type {
SWAY_SCENE_DESC_BUFFER_TIMER,
SWAY_SCENE_DESC_NON_INTERACTIVE,
SWAY_SCENE_DESC_CONTAINER,
SWAY_SCENE_DESC_VIEW,
SWAY_SCENE_DESC_LAYER_SHELL,
SWAY_SCENE_DESC_XWAYLAND_UNMANAGED,
SWAY_SCENE_DESC_POPUP,
SWAY_SCENE_DESC_DRAG_ICON,
};

bool scene_descriptor_assign(struct wlr_scene_node *node,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we're calling this assign, rather than set (which at first glance better matches try_get)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's called assign because it can only be set once. If you try to assign the same scene descriptor to the same node, it will abort. (The abort happens in wlroots: wlr_addon is the thing that doesn't allow this)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I've usually seen this called _set_once in that case to clearly communicate the semantics, but I don't feel very strongly about this.

enum sway_scene_descriptor_type type, void *data);

void *scene_descriptor_try_get(struct wlr_scene_node *node,
enum sway_scene_descriptor_type type);

void scene_descriptor_destroy(struct wlr_scene_node *node,
enum sway_scene_descriptor_type type);

#endif
Loading