mirror of
https://github.com/swaywm/sway.git
synced 2026-04-24 06:46:22 -04:00
sway_mirror: implement wlr_mirror_v1 allowing mirroring of variable source on a single destination output
This commit is contained in:
parent
b8995ced8f
commit
d39d8180c8
14 changed files with 760 additions and 8 deletions
|
|
@ -198,6 +198,7 @@ sway_cmd cmd_workspace;
|
|||
sway_cmd cmd_workspace_layout;
|
||||
sway_cmd cmd_ws_auto_back_and_forth;
|
||||
sway_cmd cmd_xwayland;
|
||||
sway_cmd cmd_mirror;
|
||||
|
||||
sway_cmd bar_cmd_bindcode;
|
||||
sway_cmd bar_cmd_binding_mode_indicator;
|
||||
|
|
|
|||
94
include/sway/mirror.h
Normal file
94
include/sway/mirror.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
#ifndef _SWAY_MIRROR_H
|
||||
#define _SWAY_MIRROR_H
|
||||
|
||||
#include <wlr/types/wlr_mirror_v1.h>
|
||||
#include <wlr/util/box.h>
|
||||
#include "sway/output.h"
|
||||
|
||||
/**
|
||||
* Allows mirroring: rendering some contents of one output (the src) on another
|
||||
* output (the dst). dst is fixed for the duration of the session, src may vary.
|
||||
*
|
||||
* See wlr_mirror_v1.h for full details.
|
||||
*/
|
||||
|
||||
enum sway_mirror_flavour {
|
||||
/**
|
||||
* Mirror the entirety of src on dst.
|
||||
*/
|
||||
SWAY_MIRROR_FLAVOUR_ENTIRE,
|
||||
|
||||
/**
|
||||
* Mirror a fixed box on one src on dst.
|
||||
*/
|
||||
SWAY_MIRROR_FLAVOUR_BOX,
|
||||
|
||||
/**
|
||||
* Mirror a container from its current src on dst, adjusting size and
|
||||
* position as required.
|
||||
*/
|
||||
SWAY_MIRROR_FLAVOUR_CONTAINER,
|
||||
};
|
||||
|
||||
/**
|
||||
* Immutable over session.
|
||||
*/
|
||||
struct sway_mirror_params {
|
||||
|
||||
struct wlr_mirror_v1_params wlr_params;
|
||||
|
||||
enum sway_mirror_flavour flavour;
|
||||
|
||||
// ENTIRE, BOX
|
||||
struct wlr_output *output_src;
|
||||
struct wlr_box box;
|
||||
|
||||
// CONTAINER
|
||||
size_t con_id;
|
||||
};
|
||||
|
||||
struct sway_mirror {
|
||||
struct wl_list link;
|
||||
|
||||
struct sway_mirror_params params;
|
||||
|
||||
/**
|
||||
* Frame is ready, from the potential src passed.
|
||||
*/
|
||||
struct wl_listener ready;
|
||||
|
||||
/**
|
||||
* Mirror session ended prematurely.
|
||||
*/
|
||||
struct wl_listener destroy;
|
||||
|
||||
struct wlr_mirror_v1 *wlr_mirror_v1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Start a mirror session, adding a sway_mirror to server::mirrors.
|
||||
*/
|
||||
bool mirror_create(struct sway_mirror_params *params);
|
||||
|
||||
/**
|
||||
* Stop a mirror session.
|
||||
*/
|
||||
void mirror_destroy(struct sway_mirror *mirror);
|
||||
|
||||
/**
|
||||
* Stop all mirror sessions.
|
||||
*/
|
||||
void mirror_destroy_all();
|
||||
|
||||
/**
|
||||
* Output is currently in use as a mirror.
|
||||
*/
|
||||
bool mirror_output_is_mirror_dst(struct sway_output *output);
|
||||
|
||||
/**
|
||||
* Translate a layout box to local output. Returns true if within output.
|
||||
*/
|
||||
bool mirror_layout_box_within_output(struct wlr_box *box, struct wlr_output *output);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -108,8 +108,9 @@ 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);
|
||||
struct sway_view *view, 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,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
|
||||
#include <wlr/types/wlr_drm_lease_v1.h>
|
||||
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||
#include <wlr/types/wlr_mirror_v1.h>
|
||||
#include <wlr/types/wlr_output_management_v1.h>
|
||||
#include <wlr/types/wlr_output_power_management_v1.h>
|
||||
#include <wlr/types/wlr_presentation_time.h>
|
||||
|
|
@ -98,6 +99,8 @@ struct sway_server {
|
|||
struct wlr_xdg_activation_v1 *xdg_activation_v1;
|
||||
struct wl_listener xdg_activation_v1_request_activate;
|
||||
|
||||
struct wl_list mirrors; // sway_mirror::link
|
||||
|
||||
// The timeout for transactions, after which a transaction is applied
|
||||
// regardless of readiness.
|
||||
size_t txn_timeout_ms;
|
||||
|
|
|
|||
|
|
@ -97,6 +97,10 @@ struct sway_view {
|
|||
// when a transaction is applied.
|
||||
struct wlr_box saved_geometry;
|
||||
|
||||
// The most recently rendered output and destination box.
|
||||
struct sway_output *last_output;
|
||||
struct wlr_box last_destination;
|
||||
|
||||
struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel;
|
||||
struct wl_listener foreign_activate_request;
|
||||
struct wl_listener foreign_fullscreen_request;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue