Add sway_surface
For extending wlr_surface with additional things.
This commit is contained in:
parent
022df2542b
commit
5421198489
|
@ -28,6 +28,8 @@ struct sway_server {
|
|||
struct wlr_backend *noop_backend;
|
||||
|
||||
struct wlr_compositor *compositor;
|
||||
struct wl_listener compositor_new_surface;
|
||||
|
||||
struct wlr_data_device_manager *data_device_manager;
|
||||
|
||||
struct sway_input_manager *input;
|
||||
|
@ -99,6 +101,7 @@ void server_fini(struct sway_server *server);
|
|||
bool server_start(struct sway_server *server);
|
||||
void server_run(struct sway_server *server);
|
||||
|
||||
void handle_compositor_new_surface(struct wl_listener *listener, void *data);
|
||||
void handle_new_output(struct wl_listener *listener, void *data);
|
||||
|
||||
void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data);
|
||||
|
|
11
include/sway/surface.h
Normal file
11
include/sway/surface.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef _SWAY_SURFACE_H
|
||||
#define _SWAY_SURFACE_H
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
|
||||
struct sway_surface {
|
||||
struct wlr_surface *wlr_surface;
|
||||
|
||||
struct wl_listener destroy;
|
||||
};
|
||||
|
||||
#endif
|
24
sway/desktop/surface.c
Normal file
24
sway/desktop/surface.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <stdlib.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include "sway/server.h"
|
||||
#include "sway/surface.h"
|
||||
|
||||
void handle_destroy(struct wl_listener *listener, void *data) {
|
||||
struct sway_surface *surface = wl_container_of(listener, surface, destroy);
|
||||
|
||||
surface->wlr_surface->data = NULL;
|
||||
wl_list_remove(&surface->destroy.link);
|
||||
|
||||
free(surface);
|
||||
}
|
||||
|
||||
void handle_compositor_new_surface(struct wl_listener *listener, void *data) {
|
||||
struct wlr_surface *wlr_surface = data;
|
||||
|
||||
struct sway_surface *surface = calloc(1, sizeof(struct sway_surface));
|
||||
surface->wlr_surface = wlr_surface;
|
||||
wlr_surface->data = surface;
|
||||
|
||||
surface->destroy.notify = handle_destroy;
|
||||
wl_signal_add(&wlr_surface->events.destroy, &surface->destroy);
|
||||
}
|
|
@ -16,6 +16,7 @@ sway_sources = files(
|
|||
'desktop/layer_shell.c',
|
||||
'desktop/output.c',
|
||||
'desktop/render.c',
|
||||
'desktop/surface.c',
|
||||
'desktop/transaction.c',
|
||||
'desktop/xdg_shell.c',
|
||||
|
||||
|
|
|
@ -59,6 +59,10 @@ bool server_init(struct sway_server *server) {
|
|||
wlr_renderer_init_wl_display(renderer, server->wl_display);
|
||||
|
||||
server->compositor = wlr_compositor_create(server->wl_display, renderer);
|
||||
server->compositor_new_surface.notify = handle_compositor_new_surface;
|
||||
wl_signal_add(&server->compositor->events.new_surface,
|
||||
&server->compositor_new_surface);
|
||||
|
||||
server->data_device_manager =
|
||||
wlr_data_device_manager_create(server->wl_display);
|
||||
|
||||
|
|
Loading…
Reference in a new issue