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

Fix layer shell popup positions #1

Closed
Closed
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
095219a
desktop: Rename layers to shell_layers
Nefsen402 Mar 1, 2022
17ecef9
view: init function should return a success bool
Nefsen402 Mar 5, 2022
edbf1a5
scene_graph: Maintain `wlr_scene_node`s for the sway tree.
Nefsen402 Apr 29, 2022
78f1798
scene_graph: Wire up presentation time
Nefsen402 Feb 27, 2022
5598df0
renderer: Render scene_graph
Nefsen402 Mar 5, 2022
03ec449
scene_graph: Introduce sway_scene_descriptor
Nefsen402 Mar 5, 2022
7dc0ba1
scene_graph: Port seat drag icons
Nefsen402 Apr 30, 2022
b27ca68
scene_graph: Port ext_session_v1
Nefsen402 Apr 30, 2022
1746b71
scene_graph: Port seatop_move_tiling indicators
Nefsen402 Mar 5, 2022
9ada581
seat: Remove dead seatop_render function
Nefsen402 Feb 22, 2022
b3e35a7
renderer: Remove in favor of scene_graph
Nefsen402 Feb 21, 2022
6bf2613
Introduce sway_buffer
Nefsen402 Mar 12, 2022
2038863
input: Query scene graph for relevant surface/node intersections
Nefsen402 Apr 26, 2022
985e57e
scene_graph: Port layer_shell
Nefsen402 Apr 16, 2022
c198ebf
container: Remove dead location query code
Nefsen402 Feb 21, 2022
1edba10
scene_graph: Port container server side decorations
Nefsen402 Mar 12, 2022
844ec30
transaction: ready signals will return success bools
Nefsen402 Mar 5, 2022
cf6af33
scene_graph: Port xdg_shell
Nefsen402 Mar 5, 2022
f621fcf
scene_graph: Port xwayland
Nefsen402 Apr 26, 2022
bf23f46
xwayland: Cleanup geometry handling on commit
Nefsen402 Mar 1, 2022
507d75d
scene_graph: Port view saved buffers
Nefsen402 Mar 7, 2022
8614409
Delete old damage tracking code
Nefsen402 Mar 7, 2022
9344816
container: Don't track outputs
Nefsen402 Feb 21, 2022
91bd378
scene_graph: Arrange scene graph on transaction apply
Nefsen402 Apr 30, 2022
d474073
output: destroy output after ensuring it is disabled
Nefsen402 Feb 22, 2022
f500673
Fix SIGSEGV on surface destroy
Nefsen402 Mar 18, 2022
67093ab
Disable this until upstream UAF is resolved
Nefsen402 Apr 30, 2022
b8bb2da
Fix layer shell popup positions
danieldg Apr 26, 2022
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>

/**
* 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,
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
31 changes: 14 additions & 17 deletions include/sway/input/seat.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/util/edges.h>
#include <wlr/types/wlr_scene.h>
#include "sway/config.h"
#include "sway/input/input-manager.h"
#include "sway/input/tablet.h"
Expand All @@ -26,8 +27,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 sway_output *output,
pixman_region32_t *damage);
bool allow_set_cursor;
};

Expand All @@ -51,16 +50,12 @@ struct sway_seat_node {
};

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
struct wlr_scene_node *node;
struct wlr_scene_node *surface_tree_node;

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

struct sway_drag {
Expand All @@ -73,6 +68,15 @@ struct sway_seat {
struct wlr_seat *wlr_seat;
struct sway_cursor *cursor;

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

bool has_focus;
struct wl_list focus_stack; // list of containers in focus order
struct sway_workspace *workspace;
Expand Down Expand Up @@ -235,7 +239,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_icon_update_position(struct sway_seat *seat, struct sway_drag_icon *icon);

enum wlr_edges find_resize_edge(struct sway_container *cont,
struct wlr_surface *surface, struct sway_cursor *cursor);
Expand Down Expand Up @@ -301,13 +305,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 sway_output *output,
pixman_region32_t *damage);

bool seatop_allows_set_cursor(struct sway_seat *seat);

/**
Expand Down
39 changes: 4 additions & 35 deletions include/sway/layers.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,29 @@
#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 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 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_node *scene;

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

struct sway_output;
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
78 changes: 14 additions & 64 deletions include/sway/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <unistd.h>
#include <wayland-server-core.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 @@ -18,15 +19,25 @@ struct sway_output_state {

struct sway_output {
struct sway_node node;

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

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_output_damage *damage;

int lx, ly; // layout coords
int width, height; // transformed buffer size
Expand All @@ -44,8 +55,7 @@ struct sway_output {
struct wl_listener commit;
struct wl_listener mode;
struct wl_listener present;
struct wl_listener damage_destroy;
struct wl_listener damage_frame;
struct wl_listener frame_request;

struct {
struct wl_signal disable;
Expand Down Expand Up @@ -75,19 +85,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);

// this ONLY includes the enabled outputs
struct sway_output *output_by_name_or_id(const char *name_or_id);

Expand All @@ -100,47 +97,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 sway_output *output, struct timespec *when,
pixman_region32_t *damage);

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 @@ -158,14 +116,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 sway_output *output,
pixman_region32_t *output_damage, 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
25 changes: 25 additions & 0 deletions include/sway/scene_descriptor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef _SWAY_SCENE_DESCRIPTOR_H
#define _SWAY_SCENE_DESCRIPTOR_H
#include <wlr/types/wlr_scene.h>

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

struct sway_scene_descriptor {
enum sway_scene_descriptor_type type;
void *data;

struct wl_listener destroy;
};

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

#endif
9 changes: 4 additions & 5 deletions include/sway/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#endif

struct sway_transaction;
struct sway_session_lock;

struct sway_server {
struct wl_display *wl_display;
Expand Down Expand Up @@ -92,13 +93,9 @@ struct sway_server {

struct {
bool locked;
struct sway_session_lock *lock;
struct wlr_session_lock_manager_v1 *manager;

struct wlr_session_lock_v1 *lock;
struct wl_listener lock_new_surface;
struct wl_listener lock_unlock;
struct wl_listener lock_destroy;

struct wl_listener new_lock;
struct wl_listener manager_destroy;
} session_lock;
Expand Down Expand Up @@ -163,6 +160,8 @@ void handle_new_output(struct wl_listener *listener, void *data);
void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data);
void handle_layer_shell_surface(struct wl_listener *listener, void *data);
void sway_session_lock_init(void);
void sway_session_lock_add_output(struct sway_session_lock *lock,
struct sway_output *output);
void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
#if HAVE_XWAYLAND
void handle_xwayland_surface(struct wl_listener *listener, void *data);
Expand Down
21 changes: 21 additions & 0 deletions include/sway/sway_buffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef _SWAY_BUFFER_H
#define _SWAY_BUFFER_H
#include <wlr/interfaces/wlr_buffer.h>

struct sway_buffer {
struct wlr_buffer base;
void *data;
uint32_t format;
size_t stride;

uint32_t width, height, scale;
};

struct sway_buffer *sway_buffer_create(uint32_t width, uint32_t height,
uint32_t scale, uint32_t format);

void sway_buffer_destroy(struct sway_buffer *buffer);

struct sway_buffer *sway_buffer_from_wlr_buffer(struct wlr_buffer *wlr_buffer);

#endif
Loading