mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
fullscreen-shell: remove
The protocol implementation has been marked as deprecated in the previous release. Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3846
This commit is contained in:
parent
99da6ccc87
commit
9dbf5b9f6b
6 changed files with 0 additions and 447 deletions
|
|
@ -1,257 +0,0 @@
|
|||
#include <getopt.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_fullscreen_shell_v1.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/util/box.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/transform.h>
|
||||
|
||||
/**
|
||||
* A minimal fullscreen-shell server. It only supports rendering.
|
||||
*/
|
||||
|
||||
struct fullscreen_server {
|
||||
struct wl_display *wl_display;
|
||||
struct wlr_backend *backend;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
|
||||
struct wlr_fullscreen_shell_v1 *fullscreen_shell;
|
||||
struct wl_listener present_surface;
|
||||
|
||||
struct wlr_output_layout *output_layout;
|
||||
struct wl_list outputs;
|
||||
struct wl_listener new_output;
|
||||
};
|
||||
|
||||
struct fullscreen_output {
|
||||
struct wl_list link;
|
||||
struct fullscreen_server *server;
|
||||
struct wlr_output *wlr_output;
|
||||
struct wlr_surface *surface;
|
||||
struct wl_listener surface_destroy;
|
||||
|
||||
struct wl_listener frame;
|
||||
};
|
||||
|
||||
struct render_data {
|
||||
struct wlr_output *output;
|
||||
struct wlr_render_pass *render_pass;
|
||||
struct timespec *when;
|
||||
};
|
||||
|
||||
static void render_surface(struct wlr_surface *surface,
|
||||
int sx, int sy, void *data) {
|
||||
struct render_data *rdata = data;
|
||||
struct wlr_output *output = rdata->output;
|
||||
|
||||
struct wlr_texture *texture = wlr_surface_get_texture(surface);
|
||||
if (texture == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_box box = {
|
||||
.x = sx * output->scale,
|
||||
.y = sy * output->scale,
|
||||
.width = surface->current.width * output->scale,
|
||||
.height = surface->current.height * output->scale,
|
||||
};
|
||||
|
||||
enum wl_output_transform transform = wlr_output_transform_invert(surface->current.transform);
|
||||
transform = wlr_output_transform_compose(transform, output->transform);
|
||||
|
||||
wlr_render_pass_add_texture(rdata->render_pass, &(struct wlr_render_texture_options){
|
||||
.texture = texture,
|
||||
.dst_box = box,
|
||||
.transform = transform,
|
||||
});
|
||||
|
||||
wlr_surface_send_frame_done(surface, rdata->when);
|
||||
}
|
||||
|
||||
static void output_handle_frame(struct wl_listener *listener, void *data) {
|
||||
struct fullscreen_output *output =
|
||||
wl_container_of(listener, output, frame);
|
||||
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
int width, height;
|
||||
wlr_output_effective_resolution(output->wlr_output, &width, &height);
|
||||
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
struct wlr_render_pass *pass = wlr_output_begin_render_pass(output->wlr_output, &state, NULL);
|
||||
if (pass == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
|
||||
.color = { 0.3, 0.3, 0.3, 1.0 },
|
||||
.box = { .width = width, .height = height },
|
||||
});
|
||||
|
||||
if (output->surface != NULL) {
|
||||
struct render_data rdata = {
|
||||
.output = output->wlr_output,
|
||||
.render_pass = pass,
|
||||
.when = &now,
|
||||
};
|
||||
wlr_surface_for_each_surface(output->surface, render_surface, &rdata);
|
||||
}
|
||||
|
||||
wlr_render_pass_submit(pass);
|
||||
wlr_output_commit_state(output->wlr_output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
}
|
||||
|
||||
static void output_set_surface(struct fullscreen_output *output,
|
||||
struct wlr_surface *surface);
|
||||
|
||||
static void output_handle_surface_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct fullscreen_output *output =
|
||||
wl_container_of(listener, output, surface_destroy);
|
||||
output_set_surface(output, NULL);
|
||||
}
|
||||
|
||||
static void output_set_surface(struct fullscreen_output *output,
|
||||
struct wlr_surface *surface) {
|
||||
if (output->surface == surface) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (output->surface != NULL) {
|
||||
wl_list_remove(&output->surface_destroy.link);
|
||||
output->surface = NULL;
|
||||
}
|
||||
|
||||
if (surface != NULL) {
|
||||
output->surface_destroy.notify = output_handle_surface_destroy;
|
||||
wl_signal_add(&surface->events.destroy, &output->surface_destroy);
|
||||
output->surface = surface;
|
||||
}
|
||||
|
||||
wlr_log(WLR_DEBUG, "Presenting surface %p on output %s",
|
||||
surface, output->wlr_output->name);
|
||||
}
|
||||
|
||||
static void server_handle_new_output(struct wl_listener *listener, void *data) {
|
||||
struct fullscreen_server *server =
|
||||
wl_container_of(listener, server, new_output);
|
||||
struct wlr_output *wlr_output = data;
|
||||
|
||||
wlr_output_init_render(wlr_output, server->allocator, server->renderer);
|
||||
|
||||
struct fullscreen_output *output = calloc(1, sizeof(*output));
|
||||
output->wlr_output = wlr_output;
|
||||
output->server = server;
|
||||
output->frame.notify = output_handle_frame;
|
||||
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
||||
wl_list_insert(&server->outputs, &output->link);
|
||||
|
||||
wlr_output_layout_add_auto(server->output_layout, wlr_output);
|
||||
wlr_output_create_global(wlr_output, server->wl_display);
|
||||
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
wlr_output_state_set_enabled(&state, true);
|
||||
struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output);
|
||||
if (mode != NULL) {
|
||||
wlr_output_state_set_mode(&state, mode);
|
||||
}
|
||||
wlr_output_commit_state(wlr_output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
}
|
||||
|
||||
static void server_handle_present_surface(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct fullscreen_server *server =
|
||||
wl_container_of(listener, server, present_surface);
|
||||
struct wlr_fullscreen_shell_v1_present_surface_event *event = data;
|
||||
|
||||
struct fullscreen_output *output;
|
||||
wl_list_for_each(output, &server->outputs, link) {
|
||||
if (event->output == NULL || event->output == output->wlr_output) {
|
||||
output_set_surface(output, event->surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
wlr_log_init(WLR_DEBUG, NULL);
|
||||
|
||||
char *startup_cmd = NULL;
|
||||
|
||||
int c;
|
||||
while ((c = getopt(argc, argv, "s:")) != -1) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
startup_cmd = optarg;
|
||||
break;
|
||||
default:
|
||||
printf("usage: %s [-s startup-command]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
if (optind < argc) {
|
||||
printf("usage: %s [-s startup-command]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
struct fullscreen_server server = {0};
|
||||
server.wl_display = wl_display_create();
|
||||
server.backend = wlr_backend_autocreate(wl_display_get_event_loop(server.wl_display), NULL);
|
||||
server.renderer = wlr_renderer_autocreate(server.backend);
|
||||
wlr_renderer_init_wl_display(server.renderer, server.wl_display);
|
||||
server.allocator = wlr_allocator_autocreate(server.backend,
|
||||
server.renderer);
|
||||
|
||||
wlr_compositor_create(server.wl_display, 5, server.renderer);
|
||||
|
||||
server.output_layout = wlr_output_layout_create(server.wl_display);
|
||||
|
||||
wl_list_init(&server.outputs);
|
||||
server.new_output.notify = server_handle_new_output;
|
||||
wl_signal_add(&server.backend->events.new_output, &server.new_output);
|
||||
|
||||
server.fullscreen_shell = wlr_fullscreen_shell_v1_create(server.wl_display);
|
||||
server.present_surface.notify = server_handle_present_surface;
|
||||
wl_signal_add(&server.fullscreen_shell->events.present_surface,
|
||||
&server.present_surface);
|
||||
|
||||
const char *socket = wl_display_add_socket_auto(server.wl_display);
|
||||
if (!socket) {
|
||||
wl_display_destroy(server.wl_display);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!wlr_backend_start(server.backend)) {
|
||||
wl_display_destroy(server.wl_display);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
setenv("WAYLAND_DISPLAY", socket, true);
|
||||
if (startup_cmd != NULL) {
|
||||
if (fork() == 0) {
|
||||
execl("/bin/sh", "/bin/sh", "-c", startup_cmd, (void *)NULL);
|
||||
}
|
||||
}
|
||||
|
||||
wlr_log(WLR_INFO, "Running Wayland compositor on WAYLAND_DISPLAY=%s",
|
||||
socket);
|
||||
wl_display_run(server.wl_display);
|
||||
|
||||
wl_display_destroy_clients(server.wl_display);
|
||||
wl_display_destroy(server.wl_display);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -25,10 +25,6 @@ compositors = {
|
|||
'output-layout': {
|
||||
'src': ['output-layout.c', 'cat.c'],
|
||||
},
|
||||
'fullscreen-shell': {
|
||||
'src': 'fullscreen-shell.c',
|
||||
'proto': ['fullscreen-shell-unstable-v1'],
|
||||
},
|
||||
'scene-graph': {
|
||||
'src': 'scene-graph.c',
|
||||
'proto': ['xdg-shell'],
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* This is a deprecated interface of wlroots. It will be removed in a future
|
||||
* version.
|
||||
*/
|
||||
|
||||
#ifndef WLR_USE_UNSTABLE
|
||||
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
||||
#endif
|
||||
|
||||
#ifndef WLR_TYPES_WLR_FULLSCREEN_SHELL_V1_H
|
||||
#define WLR_TYPES_WLR_FULLSCREEN_SHELL_V1_H
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
#include "fullscreen-shell-unstable-v1-protocol.h"
|
||||
|
||||
struct wlr_fullscreen_shell_v1 {
|
||||
struct wl_global *global;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
// struct wlr_fullscreen_shell_v1_present_surface_event
|
||||
struct wl_signal present_surface;
|
||||
} events;
|
||||
|
||||
void *data;
|
||||
|
||||
struct {
|
||||
struct wl_listener display_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_fullscreen_shell_v1_present_surface_event {
|
||||
struct wl_client *client;
|
||||
struct wlr_surface *surface; // can be NULL
|
||||
enum zwp_fullscreen_shell_v1_present_method method;
|
||||
struct wlr_output *output; // can be NULL
|
||||
};
|
||||
|
||||
struct wlr_fullscreen_shell_v1 *wlr_fullscreen_shell_v1_create(
|
||||
struct wl_display *display);
|
||||
|
||||
#endif
|
||||
|
|
@ -45,7 +45,6 @@ protocols = {
|
|||
'tearing-control-v1': wl_protocol_dir / 'staging/tearing-control/tearing-control-v1.xml',
|
||||
|
||||
# Unstable upstream protocols
|
||||
'fullscreen-shell-unstable-v1': wl_protocol_dir / 'unstable/fullscreen-shell/fullscreen-shell-unstable-v1.xml',
|
||||
'idle-inhibit-unstable-v1': wl_protocol_dir / 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml',
|
||||
'keyboard-shortcuts-inhibit-unstable-v1': wl_protocol_dir / 'unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml',
|
||||
'pointer-constraints-unstable-v1': wl_protocol_dir / 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml',
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ wlr_files += files(
|
|||
'wlr_ext_foreign_toplevel_list_v1.c',
|
||||
'wlr_ext_data_control_v1.c',
|
||||
'wlr_fractional_scale_v1.c',
|
||||
'wlr_fullscreen_shell_v1.c',
|
||||
'wlr_gamma_control_v1.c',
|
||||
'wlr_idle_inhibit_v1.c',
|
||||
'wlr_idle_notify_v1.c',
|
||||
|
|
|
|||
|
|
@ -1,142 +0,0 @@
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_fullscreen_shell_v1.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#define FULLSCREEN_SHELL_VERSION 1
|
||||
|
||||
static const struct zwp_fullscreen_shell_v1_interface shell_impl;
|
||||
|
||||
static void shell_handle_release(struct wl_client *client,
|
||||
struct wl_resource *resource) {
|
||||
wl_resource_destroy(resource);
|
||||
}
|
||||
|
||||
static struct wlr_fullscreen_shell_v1 *shell_from_resource(
|
||||
struct wl_resource *resource) {
|
||||
assert(wl_resource_instance_of(resource,
|
||||
&zwp_fullscreen_shell_v1_interface, &shell_impl));
|
||||
return wl_resource_get_user_data(resource);
|
||||
}
|
||||
|
||||
static void fullscreen_shell_surface_handle_commit(struct wlr_surface *surface) {
|
||||
if (wlr_surface_has_buffer(surface)) {
|
||||
wlr_surface_map(surface);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wlr_surface_role fullscreen_shell_surface_role = {
|
||||
.name = "zwp_fullscreen_shell_v1-surface",
|
||||
.no_object = true,
|
||||
.commit = fullscreen_shell_surface_handle_commit,
|
||||
};
|
||||
|
||||
static void shell_handle_present_surface(struct wl_client *client,
|
||||
struct wl_resource *shell_resource,
|
||||
struct wl_resource *surface_resource, uint32_t method,
|
||||
struct wl_resource *output_resource) {
|
||||
struct wlr_fullscreen_shell_v1 *shell = shell_from_resource(shell_resource);
|
||||
struct wlr_surface *surface = NULL;
|
||||
if (surface_resource != NULL) {
|
||||
surface = wlr_surface_from_resource(surface_resource);
|
||||
}
|
||||
struct wlr_output *output = NULL;
|
||||
if (output_resource != NULL) {
|
||||
output = wlr_output_from_resource(output_resource);
|
||||
}
|
||||
|
||||
if (!wlr_surface_set_role(surface, &fullscreen_shell_surface_role,
|
||||
shell_resource, ZWP_FULLSCREEN_SHELL_V1_ERROR_ROLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_fullscreen_shell_v1_present_surface_event event = {
|
||||
.client = client,
|
||||
.surface = surface,
|
||||
.method = method,
|
||||
.output = output,
|
||||
};
|
||||
wl_signal_emit_mutable(&shell->events.present_surface, &event);
|
||||
}
|
||||
|
||||
static void shell_handle_present_surface_for_mode(struct wl_client *client,
|
||||
struct wl_resource *shell_resource,
|
||||
struct wl_resource *surface_resource,
|
||||
struct wl_resource *output_resource, int32_t framerate,
|
||||
uint32_t feedback_id) {
|
||||
struct wlr_surface *surface = wlr_surface_from_resource(surface_resource);
|
||||
|
||||
if (!wlr_surface_set_role(surface, &fullscreen_shell_surface_role,
|
||||
shell_resource, ZWP_FULLSCREEN_SHELL_V1_ERROR_ROLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t version = wl_resource_get_version(shell_resource);
|
||||
struct wl_resource *feedback_resource =
|
||||
wl_resource_create(client, NULL, version, feedback_id);
|
||||
if (feedback_resource == NULL) {
|
||||
wl_resource_post_no_memory(shell_resource);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: add support for mode switch
|
||||
zwp_fullscreen_shell_mode_feedback_v1_send_mode_failed(feedback_resource);
|
||||
wl_resource_destroy(feedback_resource);
|
||||
}
|
||||
|
||||
static const struct zwp_fullscreen_shell_v1_interface shell_impl = {
|
||||
.release = shell_handle_release,
|
||||
.present_surface = shell_handle_present_surface,
|
||||
.present_surface_for_mode = shell_handle_present_surface_for_mode,
|
||||
};
|
||||
|
||||
static void shell_bind(struct wl_client *client, void *data, uint32_t version,
|
||||
uint32_t id) {
|
||||
struct wlr_fullscreen_shell_v1 *shell = data;
|
||||
|
||||
struct wl_resource *resource = wl_resource_create(client,
|
||||
&zwp_fullscreen_shell_v1_interface, version, id);
|
||||
if (resource == NULL) {
|
||||
wl_client_post_no_memory(client);
|
||||
return;
|
||||
}
|
||||
wl_resource_set_implementation(resource, &shell_impl, shell, NULL);
|
||||
}
|
||||
|
||||
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||
struct wlr_fullscreen_shell_v1 *shell =
|
||||
wl_container_of(listener, shell, display_destroy);
|
||||
wl_signal_emit_mutable(&shell->events.destroy, shell);
|
||||
|
||||
assert(wl_list_empty(&shell->events.destroy.listener_list));
|
||||
assert(wl_list_empty(&shell->events.present_surface.listener_list));
|
||||
|
||||
wl_list_remove(&shell->display_destroy.link);
|
||||
wl_global_destroy(shell->global);
|
||||
free(shell);
|
||||
}
|
||||
|
||||
struct wlr_fullscreen_shell_v1 *wlr_fullscreen_shell_v1_create(
|
||||
struct wl_display *display) {
|
||||
struct wlr_fullscreen_shell_v1 *shell = calloc(1, sizeof(*shell));
|
||||
if (shell == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
wl_signal_init(&shell->events.destroy);
|
||||
wl_signal_init(&shell->events.present_surface);
|
||||
|
||||
shell->global = wl_global_create(display,
|
||||
&zwp_fullscreen_shell_v1_interface, FULLSCREEN_SHELL_VERSION,
|
||||
shell, shell_bind);
|
||||
if (shell->global == NULL) {
|
||||
free(shell);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
shell->display_destroy.notify = handle_display_destroy;
|
||||
wl_display_add_destroy_listener(display, &shell->display_destroy);
|
||||
|
||||
return shell;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue