mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-10-26 09:44:14 +00:00
add wlr_ext_foreign_toplevel allowing screenshare of single windows.
This commit is contained in:
parent
db2cf6624e
commit
4087f8a3c8
46
dwl.c
46
dwl.c
@ -61,6 +61,8 @@
|
||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
||||
#include <wlr/types/wlr_xdg_output_v1.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/types/wlr_ext_image_capture_source_v1.h>
|
||||
#include <wlr/types/wlr_ext_foreign_toplevel_list_v1.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/region.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
@ -122,6 +124,9 @@ typedef struct {
|
||||
} surface;
|
||||
struct wlr_xdg_toplevel_decoration_v1 *decoration;
|
||||
struct wl_listener commit;
|
||||
struct wlr_scene *image_capture_scene;
|
||||
struct wlr_ext_image_capture_source_v1 *image_capture_source;
|
||||
struct wlr_scene_tree *image_capture_tree;
|
||||
struct wl_listener map;
|
||||
struct wl_listener maximize;
|
||||
struct wl_listener unmap;
|
||||
@ -141,6 +146,7 @@ typedef struct {
|
||||
uint32_t tags;
|
||||
int isfloating, isurgent, isfullscreen;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
struct wlr_ext_foreign_toplevel_handle_v1 *ext_foreign_toplevel;
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
@ -373,6 +379,8 @@ static struct wlr_session *session;
|
||||
|
||||
static struct wlr_xdg_shell *xdg_shell;
|
||||
static struct wlr_xdg_activation_v1 *activation;
|
||||
static struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1 *ext_foreign_toplevel_image_capture_source_manager_v1;
|
||||
static struct wl_listener new_foreign_toplevel_capture_request;
|
||||
static struct wlr_xdg_decoration_manager_v1 *xdg_decoration_mgr;
|
||||
static struct wl_list clients; /* tiling order */
|
||||
static struct wl_list fstack; /* focus order */
|
||||
@ -384,6 +392,7 @@ static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
|
||||
static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr;
|
||||
static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr;
|
||||
static struct wlr_output_power_manager_v1 *power_mgr;
|
||||
static struct wlr_ext_foreign_toplevel_list_v1 *foreign_toplevel_list;
|
||||
|
||||
static struct wlr_pointer_constraints_v1 *pointer_constraints;
|
||||
static struct wlr_relative_pointer_manager_v1 *relative_pointer_mgr;
|
||||
@ -784,6 +793,7 @@ cleanuplisteners(void)
|
||||
wl_list_remove(&request_start_drag.link);
|
||||
wl_list_remove(&start_drag.link);
|
||||
wl_list_remove(&new_session_lock.link);
|
||||
wl_list_remove(&new_foreign_toplevel_capture_request.link);
|
||||
#ifdef XWAYLAND
|
||||
wl_list_remove(&new_xwayland_surface.link);
|
||||
wl_list_remove(&xwayland_ready.link);
|
||||
@ -1125,6 +1135,7 @@ createnotify(struct wl_listener *listener, void *data)
|
||||
struct wlr_xdg_toplevel *toplevel = data;
|
||||
Client *c = NULL;
|
||||
|
||||
|
||||
/* Allocate a Client for this surface */
|
||||
c = toplevel->base->data = ecalloc(1, sizeof(*c));
|
||||
c->surface.xdg = toplevel->base;
|
||||
@ -1744,6 +1755,12 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
Monitor *m;
|
||||
int i;
|
||||
|
||||
struct wlr_ext_foreign_toplevel_handle_v1_state foreign_toplevel_state = {
|
||||
.app_id = client_get_appid(c),
|
||||
.title = client_get_title(c),
|
||||
};
|
||||
|
||||
|
||||
/* Create scene tree for this client and its border */
|
||||
c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]);
|
||||
/* Enabled later by a call to arrange() */
|
||||
@ -1752,6 +1769,12 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
? wlr_scene_xdg_surface_create(c->scene, c->surface.xdg)
|
||||
: wlr_scene_subsurface_tree_create(c->scene, client_surface(c));
|
||||
c->scene->node.data = c->scene_surface->node.data = c;
|
||||
printf("image capture tree\n");
|
||||
c->image_capture_scene = wlr_scene_create();
|
||||
c->ext_foreign_toplevel = wlr_ext_foreign_toplevel_handle_v1_create(foreign_toplevel_list,&foreign_toplevel_state);
|
||||
c->ext_foreign_toplevel->data = c;
|
||||
c->image_capture_tree = wlr_scene_xdg_surface_create(&c->image_capture_scene->tree, c->surface.xdg);
|
||||
|
||||
|
||||
client_get_geometry(c, &c->geom);
|
||||
|
||||
@ -2442,6 +2465,20 @@ setsel(struct wl_listener *listener, void *data)
|
||||
struct wlr_seat_request_set_selection_event *event = data;
|
||||
wlr_seat_set_selection(seat, event->source, event->serial);
|
||||
}
|
||||
static void handle_new_foreign_toplevel_capture_request(struct wl_listener *listener, void *data) {
|
||||
struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request *request = data;
|
||||
Client *view = request->toplevel_handle->data;
|
||||
|
||||
if (view->image_capture_source == NULL) {
|
||||
view->image_capture_source = wlr_ext_image_capture_source_v1_create_with_scene_node(
|
||||
&view->image_capture_scene->tree.node, event_loop, alloc, drw);
|
||||
if (view->image_capture_source == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept(request, view->image_capture_source);
|
||||
}
|
||||
|
||||
void
|
||||
setup(void)
|
||||
@ -2576,6 +2613,11 @@ setup(void)
|
||||
(float [4]){0.1f, 0.1f, 0.1f, 1.0f});
|
||||
wlr_scene_node_set_enabled(&locked_bg->node, 0);
|
||||
|
||||
foreign_toplevel_list = wlr_ext_foreign_toplevel_list_v1_create(dpy,1);
|
||||
ext_foreign_toplevel_image_capture_source_manager_v1 = wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create(dpy, 1);
|
||||
new_foreign_toplevel_capture_request.notify = handle_new_foreign_toplevel_capture_request;
|
||||
wl_signal_add(&ext_foreign_toplevel_image_capture_source_manager_v1->events.new_request,&new_foreign_toplevel_capture_request);
|
||||
|
||||
/* Use decoration protocols to negotiate server-side decorations */
|
||||
wlr_server_decoration_manager_set_default_mode(
|
||||
wlr_server_decoration_manager_create(dpy),
|
||||
@ -2833,7 +2875,11 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
setmon(c, NULL, 0);
|
||||
wl_list_remove(&c->flink);
|
||||
}
|
||||
if (c->ext_foreign_toplevel) {
|
||||
wlr_ext_foreign_toplevel_handle_v1_destroy(c->ext_foreign_toplevel);
|
||||
}
|
||||
|
||||
wlr_scene_node_destroy(&c->image_capture_scene->tree.node);
|
||||
wlr_scene_node_destroy(&c->scene->node);
|
||||
printstatus();
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user