Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion heart/example/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ int main(int argc, char *argv[]) {

struct hrt_server server;

if(!hrt_server_init(&server, &output_callbacks, &seat_callbacks, &view_callbacks, WLR_DEBUG)) {
if (!hrt_server_init(&server, &output_callbacks, &seat_callbacks,
&view_callbacks,
NULL,
WLR_DEBUG)) {
return 1;
}

Expand Down
59 changes: 59 additions & 0 deletions heart/include/hrt/hrt_layer_shell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef HRT_LAYER_SHELL
#define HRT_LAYER_SHELL

#include <wayland-server-core.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_output.h>

#include <hrt/hrt_scene.h>

struct hrt_output;

struct hrt_layer_shell_surface {
struct wlr_layer_surface_v1 *layer_surface;
struct wlr_scene_layer_surface_v1 *scene_layer;
struct hrt_scene_output *output;
bool mapped;
struct {
struct wl_listener commit;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener new_popup;
struct wl_listener scene_destroy;
} events;
};

typedef void (*layer_shell_event_handler)(struct hrt_layer_shell_surface *);

struct hrt_layer_shell_callbacks {
layer_shell_event_handler new_layer_surface;
};

struct hrt_layer_shell_surface *
hrt_layer_shell_surface_create(struct wlr_layer_surface_v1 *surface);

/**
* Destroy a partially created hrt_layer_shell-surface object
*/
void
hrt_layer_shell_surface_abort(struct hrt_layer_shell_surface *surface);

struct hrt_output *
hrt_layer_surface_output(struct hrt_layer_shell_surface *layer_shell);

void hrt_layer_shell_surface_set_output(
struct hrt_layer_shell_surface *layer_shell, struct hrt_output *output);

/**
* Place a freshly-initialized surface in an output. Should only be called once during
* intial placement.
*/
void hrt_layer_shell_surface_place(struct hrt_layer_shell_surface *surface,
struct hrt_scene_output *output);

/**
* Finish initializing the layer shell object
*/
void hrt_layer_shell_finish_init(struct hrt_layer_shell_surface *surface);

#endif
11 changes: 9 additions & 2 deletions heart/include/hrt/hrt_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

#include <stdint.h>
#include <stdbool.h>
#include <hrt/hrt_output.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_xdg_shell.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_layer_shell_v1.h>

struct hrt_output;

struct hrt_scene_root {
struct wlr_scene_tree *background;
Expand All @@ -17,7 +19,7 @@ struct hrt_scene_root {
struct wlr_scene_tree *overlay;
// Should we store the outputs and groups associated with this?
struct {
struct wl_listener scene_destroy;
struct wl_listener scene_destroy;
} listeners;
};

Expand All @@ -27,6 +29,7 @@ struct hrt_scene_output {

struct wlr_scene_tree *top;
struct wlr_scene_tree *overlay;
struct hrt_output *output;
};

struct hrt_scene_group {
Expand All @@ -49,6 +52,10 @@ struct hrt_scene_output *hrt_scene_output_create(struct hrt_scene_root *scene);

void hrt_scene_output_destroy(struct hrt_scene_output *output);

struct wlr_scene_tree *hrt_scene_output_get_layer(
struct hrt_scene_output *output, enum zwlr_layer_shell_v1_layer layer_type);


struct hrt_scene_group *hrt_scene_group_create(struct hrt_scene_root *parent);

void hrt_scene_group_destroy(struct hrt_scene_group *group);
Expand Down
29 changes: 22 additions & 7 deletions heart/include/hrt/hrt_server.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef HRT_HRT_SERVER_H
#define HRT_HRT_SERVER_H

#include "hrt/hrt_layer_shell.h"
#include "wlr/backend/session.h"
#include <stdbool.h>

Expand All @@ -19,7 +20,8 @@
struct hrt_server {
struct wl_display *wl_display;
struct wlr_backend *backend;
struct wl_listener backend_destroy;
struct wlr_backend *headless_backend;

struct wlr_session *session;
struct wlr_renderer *renderer;
struct wlr_compositor *compositor;
Expand All @@ -33,23 +35,36 @@ struct hrt_server {
struct wl_listener output_layout_changed;
struct wl_listener output_manager_apply;
struct wl_listener output_manager_test;
struct wl_listener output_manager_destroy;

struct hrt_seat seat;
struct hrt_output *fallback_output;

struct wlr_xdg_shell *xdg_shell;
struct wl_listener new_xdg_toplevel;
struct wl_listener new_xdg_popup;

struct wlr_layer_shell_v1 *layer_shell;
struct wl_listener new_layer_shell;

struct {
struct wl_listener backend;
struct wl_listener headless;
struct wl_listener output_manager;
struct wl_listener layer_shell;
} destroy_listener;

const struct hrt_output_callbacks *output_callback;
const struct hrt_view_callbacks *view_callbacks;
const struct hrt_layer_shell_callbacks *layer_shell_callbacks;
};

bool hrt_server_init(struct hrt_server *server,
const struct hrt_output_callbacks *output_callbacks,
const struct hrt_seat_callbacks *seat_callbacks,
const struct hrt_view_callbacks *view_callbacks,
enum wlr_log_importance log_level);
bool hrt_server_init(
struct hrt_server *server,
const struct hrt_output_callbacks *output_callbacks,
const struct hrt_seat_callbacks *seat_callbacks,
const struct hrt_view_callbacks *view_callbacks,
const struct hrt_layer_shell_callbacks *layer_shell_callbacks,
enum wlr_log_importance log_level);

bool hrt_server_start(struct hrt_server *server);

Expand Down
9 changes: 9 additions & 0 deletions heart/include/layer_shell_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef LAYER_SHELL_IMPL
#define LAYER_SHELL_IMPL

#include "hrt/hrt_server.h"
#include <wayland-server-core.h>

bool hrt_layer_shell_init(struct hrt_server *server);

#endif
5 changes: 5 additions & 0 deletions heart/include/output_impl.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#pragma once

#include <wlr/types/wlr_output.h>

#include "hrt/hrt_server.h"

bool hrt_output_init(struct hrt_server *server,
const struct hrt_output_callbacks *callbacks);
void hrt_output_destroy(struct hrt_server *server);

struct hrt_output *hrt_output_create(struct hrt_server *server,
struct wlr_output *wlr_output);
1 change: 1 addition & 0 deletions heart/protocols/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ endif
protocols = [
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
[wlr_protocol_dir, 'wlr-output-management-unstable-v1.xml'],
[wlr_protocol_dir, 'wlr-layer-shell-unstable-v1.xml'],
]

wl_protos_src = []
Expand Down
Loading
Loading