mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-22 14:35:57 +01:00
screencast: restore window share by class
This commit is contained in:
parent
4f0c5756c9
commit
ca077cc05c
2 changed files with 37 additions and 13 deletions
|
@ -164,6 +164,7 @@ struct xdpw_share {
|
||||||
struct xdph_restore_token {
|
struct xdph_restore_token {
|
||||||
char *token;
|
char *token;
|
||||||
char *outputPort; // NULL if not set
|
char *outputPort; // NULL if not set
|
||||||
|
char *windowClass; // NULL if not set
|
||||||
uint64_t windowHandle; // 0 if not set
|
uint64_t windowHandle; // 0 if not set
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
bool withCursor;
|
bool withCursor;
|
||||||
|
|
|
@ -132,6 +132,16 @@ bool setup_outputs(struct xdpw_screencast_context *ctx, struct xdpw_session *ses
|
||||||
if (token) {
|
if (token) {
|
||||||
// attempt to restore
|
// attempt to restore
|
||||||
if (token->outputPort) {
|
if (token->outputPort) {
|
||||||
|
if (strncmp(token->outputPort, "class:", 6) == 0) {
|
||||||
|
struct SToplevelEntry *current;
|
||||||
|
wl_list_for_each(current, &ctx->toplevel_resource_list, link) {
|
||||||
|
if (strcmp(token->outputPort + 6, current->clazz) == 0) {
|
||||||
|
out.window_handle = token->windowHandle;
|
||||||
|
tokenSuccess = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
struct xdpw_wlr_output *output;
|
struct xdpw_wlr_output *output;
|
||||||
wl_list_for_each(output, &ctx->output_list, link) {
|
wl_list_for_each(output, &ctx->output_list, link) {
|
||||||
if (strcmp(output->name, token->outputPort) == 0) {
|
if (strcmp(output->name, token->outputPort) == 0) {
|
||||||
|
@ -140,6 +150,8 @@ bool setup_outputs(struct xdpw_screencast_context *ctx, struct xdpw_session *ses
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (token->windowHandle > 0) {
|
} else if (token->windowHandle > 0) {
|
||||||
struct SToplevelEntry *current;
|
struct SToplevelEntry *current;
|
||||||
wl_list_for_each(current, &ctx->toplevel_resource_list, link) {
|
wl_list_for_each(current, &ctx->toplevel_resource_list, link) {
|
||||||
|
@ -249,6 +261,16 @@ static struct xdph_restore_token *getRestoreToken(char *sessionToken, struct xdp
|
||||||
restoreToken->token = uuid_str;
|
restoreToken->token = uuid_str;
|
||||||
restoreToken->withCursor = withCursor;
|
restoreToken->withCursor = withCursor;
|
||||||
|
|
||||||
|
if (windowSelected) {
|
||||||
|
struct SToplevelEntry *current;
|
||||||
|
wl_list_for_each(current, &state->screencast.toplevel_resource_list, link) {
|
||||||
|
if (current->handle == restoreToken->windowHandle) {
|
||||||
|
restoreToken->windowClass = getFormat("class:%x", current->clazz);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return restoreToken;
|
return restoreToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,12 +666,13 @@ static int method_screencast_start(sd_bus_message *msg, void *data, sd_bus_error
|
||||||
|
|
||||||
logprint(DEBUG, "dbus: start: returning node %d", (int)cast->node_id);
|
logprint(DEBUG, "dbus: start: returning node %d", (int)cast->node_id);
|
||||||
if (restoreToken)
|
if (restoreToken)
|
||||||
ret = sd_bus_message_append(reply, "ua{sv}", PORTAL_RESPONSE_SUCCESS, 3, "streams", "a(ua{sv})", 1, cast->node_id, 3, "position", "(ii)", 0,
|
ret = sd_bus_message_append(
|
||||||
0, "size", "(ii)", cast->screencopy_frame_info[WL_SHM].width, cast->screencopy_frame_info[WL_SHM].height,
|
reply, "ua{sv}", PORTAL_RESPONSE_SUCCESS, 3, "streams", "a(ua{sv})", 1, cast->node_id, 3, "position", "(ii)", 0, 0, "size", "(ii)",
|
||||||
"source_type", "u", (cast->target.output ? (1 << MONITOR) : (1 << WINDOW)), "persist_mode", "u", sess->persist,
|
cast->screencopy_frame_info[WL_SHM].width, cast->screencopy_frame_info[WL_SHM].height, "source_type", "u",
|
||||||
"restore_data", "(suv)", "hyprland", 2, "(susbt)" /* amogus */, restoreToken->token, restoreToken->windowHandle,
|
(cast->target.output ? (1 << MONITOR) : (1 << WINDOW)), "persist_mode", "u", sess->persist, "restore_data", "(suv)", "hyprland", 2,
|
||||||
(restoreToken->outputPort == NULL ? "" : restoreToken->outputPort), restoreToken->withCursor,
|
"(susbt)" /* amogus */, restoreToken->token, restoreToken->windowHandle,
|
||||||
(unsigned long)time(NULL));
|
(restoreToken->outputPort == NULL ? (restoreToken->windowHandle ? restoreToken->windowClass : "") : restoreToken->outputPort),
|
||||||
|
restoreToken->withCursor, (unsigned long)time(NULL));
|
||||||
else
|
else
|
||||||
ret = sd_bus_message_append(reply, "ua{sv}", PORTAL_RESPONSE_SUCCESS, 1, "streams", "a(ua{sv})", 1, cast->node_id, 3, "position", "(ii)", 0,
|
ret = sd_bus_message_append(reply, "ua{sv}", PORTAL_RESPONSE_SUCCESS, 1, "streams", "a(ua{sv})", 1, cast->node_id, 3, "position", "(ii)", 0,
|
||||||
0, "size", "(ii)", cast->screencopy_frame_info[WL_SHM].width, cast->screencopy_frame_info[WL_SHM].height,
|
0, "size", "(ii)", cast->screencopy_frame_info[WL_SHM].width, cast->screencopy_frame_info[WL_SHM].height,
|
||||||
|
|
Loading…
Reference in a new issue