Initial progress, everything is broken
This commit is contained in:
parent
34e48cbcc5
commit
792d9c234d
7 changed files with 120 additions and 0 deletions
8
Makefile
Normal file
8
Makefile
Normal file
|
@ -0,0 +1,8 @@
|
|||
CC = gcc
|
||||
CFLAGS = -g -DWLR_USE_UNSTABLE `pkg-config --cflags wlroots-0.19 wayland-server pixman-1 libpng`
|
||||
LDFLAGS = `pkg-config --libs wlroots-0.19 wayland-server pixman-1 libpng`
|
||||
|
||||
all: panes
|
||||
|
||||
panes: main.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
|
BIN
cursor.png
Normal file
BIN
cursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 416 B |
0
fuck
Normal file
0
fuck
Normal file
105
main.c
Normal file
105
main.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
#define WLR_USE_UNSTABLE
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/backend/multi.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_scene.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <wlr/types/wlr_data_device.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct server {
|
||||
struct wl_display *display;
|
||||
struct wlr_backend *backend;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
struct wlr_scene *scene;
|
||||
struct wlr_output_layout *layout;
|
||||
struct wl_listener new_output;
|
||||
};
|
||||
|
||||
static void handle_new_output(struct wl_listener *listener, void *data) {
|
||||
struct server *server = wl_container_of(listener, server, new_output);
|
||||
struct wlr_output *output = data;
|
||||
|
||||
// Pick the first available mode
|
||||
if (!wl_list_empty(&output->modes)) {
|
||||
struct wlr_output_mode *mode = wl_container_of(output->modes.next, mode, link);
|
||||
|
||||
struct wlr_output_state state;
|
||||
memset(&state, 0, sizeof(state));
|
||||
state.committed = WLR_OUTPUT_STATE_ENABLED | WLR_OUTPUT_STATE_MODE;
|
||||
state.enabled = true;
|
||||
state.mode_type = WLR_OUTPUT_STATE_MODE_FIXED;
|
||||
state.mode = mode;
|
||||
|
||||
if (!wlr_output_commit_state(output, &state)) {
|
||||
wlr_log(WLR_ERROR, "Failed to commit output state");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wlr_output_layout_add_auto(server->layout, output);
|
||||
wlr_scene_output_create(server->scene, output);
|
||||
|
||||
float bg[4] = {0.1f, 0.1f, 0.1f, 1.0f};
|
||||
struct wlr_scene_rect *rect =
|
||||
wlr_scene_rect_create(&server->scene->tree, 1, 1, bg);
|
||||
wlr_scene_node_lower_to_bottom(&rect->node);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
wlr_log_init(WLR_DEBUG, NULL);
|
||||
struct server server = {0};
|
||||
|
||||
server.display = wl_display_create();
|
||||
struct wl_event_loop *loop = wl_display_get_event_loop(server.display);
|
||||
|
||||
// Create the backend first
|
||||
server.backend = wlr_backend_autocreate(loop, NULL); // Automatically choose the backend
|
||||
if (!server.backend) {
|
||||
wlr_log(WLR_ERROR, "Failed to create backend");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create the renderer after the backend
|
||||
server.renderer = wlr_renderer_autocreate(server.backend);
|
||||
if (!server.renderer) {
|
||||
wlr_log(WLR_ERROR, "Failed to create renderer");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Now create the allocator with the valid renderer
|
||||
server.allocator = wlr_allocator_autocreate(server.backend, server.renderer);
|
||||
if (!server.allocator) {
|
||||
wlr_log(WLR_ERROR, "Failed to create allocator");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create the compositor with the renderer
|
||||
wlr_compositor_create(server.display, 4, server.renderer);
|
||||
wlr_data_device_manager_create(server.display);
|
||||
|
||||
server.scene = wlr_scene_create();
|
||||
server.layout = wlr_output_layout_create(server.display);
|
||||
|
||||
server.new_output.notify = handle_new_output;
|
||||
wl_signal_add(&server.backend->events.new_output, &server.new_output);
|
||||
|
||||
// Start the backend
|
||||
if (!wlr_backend_start(server.backend)) {
|
||||
wlr_log(WLR_ERROR, "Failed to start backend");
|
||||
return 1;
|
||||
}
|
||||
|
||||
wlr_log(WLR_INFO, "Panes compositor running (wlroots 0.18)...");
|
||||
wl_display_run(server.display);
|
||||
wl_display_destroy(server.display);
|
||||
return 0;
|
||||
}
|
BIN
panes
Executable file
BIN
panes
Executable file
Binary file not shown.
5
start.sh
Normal file
5
start.sh
Normal file
|
@ -0,0 +1,5 @@
|
|||
export WAYLAND_DISPLAY=wayland-nested
|
||||
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
||||
export WLR_BACKENDS=wayland
|
||||
export WLR_WL_OUTPUTS=1
|
||||
export WLR_LIBINPUT_NO_DEVICES=1
|
2
test.sh
Normal file
2
test.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
||||
WLR_BACKENDS=drm WLR_LIBINPUT_NO_DEVICES=0 ./panes
|
Loading…
Add table
Reference in a new issue