Skip to content

Commit

Permalink
Partially rig up xdg-shell
Browse files Browse the repository at this point in the history
Listen to new surface and map / unmap events, but don't do anything
with them yet.
  • Loading branch information
sdilts committed Oct 22, 2023
1 parent daa989a commit 349d979
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 1 deletion.
3 changes: 3 additions & 0 deletions heart/include/hrt/hrt_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ struct hrt_server {

struct hrt_seat seat;

struct wlr_xdg_shell *xdg_shell;
struct wl_listener new_xdg_surface;

const struct hrt_output_callbacks *output_callback;
};

Expand Down
10 changes: 10 additions & 0 deletions heart/include/hrt/hrt_view.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <wayland-server-core.h>
#include "hrt/hrt_server.h"

struct hrt_view {
struct wl_list link;
struct wlr_xdg_toplevel *xdg_toplevel;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
};
5 changes: 5 additions & 0 deletions heart/include/xdg_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include <wayland-server.h>

void handle_new_xdg_surface(struct wl_listener *listener, void *data);
1 change: 1 addition & 0 deletions heart/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ hrt_source_files += files(
'seat.c',
'keyboard.c',
'cursor.c',
'xdg_shell.c',
)
9 changes: 9 additions & 0 deletions heart/src/server.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "wlr/util/log.h"
#include "xdg_impl.h"
#include <stdlib.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_export_dmabuf_v1.h>
Expand All @@ -8,6 +9,7 @@
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_xdg_shell.h>

#include <hrt/hrt_server.h>
#include <hrt/hrt_output.h>
Expand Down Expand Up @@ -43,6 +45,13 @@ bool hrt_server_init(struct hrt_server *server, const struct hrt_output_callback
wlr_data_control_manager_v1_create(server->wl_display);
wlr_gamma_control_manager_v1_create(server->wl_display);

server->output_layout = wlr_output_layout_create();

server->xdg_shell = wlr_xdg_shell_create(server->wl_display, 3);
server->new_xdg_surface.notify = handle_new_xdg_surface;
wl_signal_add(&server->xdg_shell->events.new_surface, &server->new_xdg_surface);


if(!hrt_output_init(server, output_callbacks)) {
return false;
}
Expand Down
51 changes: 51 additions & 0 deletions heart/src/xdg_shell.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <stdlib.h>

#include <wayland-server-core.h>
#include <wayland-util.h>
#include <wlr/util/log.h>

#include "hrt/hrt_input.h"
#include "xdg_impl.h"
#include "hrt/hrt_view.h"

#include <wlr/types/wlr_xdg_shell.h>

static void handle_xdg_toplevel_map(struct wl_listener *listener, void *data) {
wlr_log(WLR_DEBUG, "XDG Toplevel Mapped!");
}

static void handle_xdg_toplevel_unmap(struct wl_listener *listener,
void *data) {
wlr_log(WLR_DEBUG, "XDG Toplevel unmapped!");
}

static void handle_xdg_toplevel_destroy(struct wl_listener *listener,
void *data) {
wlr_log(WLR_DEBUG, "XDG Toplevel Destroyed!");
struct hrt_view *view = wl_container_of(listener, view, destroy);

wl_list_remove(&view->map.link);
wl_list_remove(&view->unmap.link);
wl_list_remove(&view->destroy.link);

free(view);
}

void handle_new_xdg_surface(struct wl_listener *listener, void *data) {
wlr_log(WLR_DEBUG, "New XDG Surface recieved");
struct hrt_server *server = wl_container_of(listener, server, new_xdg_surface);
struct wlr_xdg_surface *xdg_surface = data;

if(xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) {
return;
}

struct hrt_view *view = calloc(1, sizeof(struct hrt_view));

view->map.notify = handle_xdg_toplevel_map;
wl_signal_add(&xdg_surface->events.map, &view->map);
view->unmap.notify = handle_xdg_toplevel_unmap;
wl_signal_add(&xdg_surface->events.unmap, &view->unmap);
view->destroy.notify = handle_xdg_toplevel_destroy;
wl_signal_add(&xdg_surface->events.destroy, &view->destroy);
}
1 change: 0 additions & 1 deletion lisp/bindings/hrt-bindings.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ See themes section of man xcursor(3) to find where to find valid cursor names."
(output-manager-apply (:struct wl-listener))
(output-manager-test (:struct wl-listener))
(seat (:struct hrt-seat))
(scene :pointer #| (:struct wlr-scene) |# )
(xdg-shell :pointer #| (:struct wlr-xdg-shell) |# )
(new-xdg-surface (:struct wl-listener))
(output-callback (:pointer (:struct hrt-output-callbacks))))
Expand Down

0 comments on commit 349d979

Please sign in to comment.