.
This commit is contained in:
parent
2a017bb895
commit
ea6d60ce95
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
||||
CFLAGS:=-s -O0 -pedantic -Wall -Wextra -DWLR_USE_UNSTABLE
|
||||
CFLAGS:=-s -O0 -pedantic -Wall -Wextra -DWLR_USE_UNSTABLE -b
|
||||
LDFLAGS:=$(shell pkg-config --libs wlroots wayland-server libinput)
|
||||
CC:=cc
|
||||
|
||||
|
4
config.h
4
config.h
@ -3,8 +3,8 @@
|
||||
|
||||
#define LOG_LEVEL WLR_ERROR
|
||||
static const MonitorRule monrules[] = {
|
||||
/* [monitor name] [workspace id] [x] [y] [resolution x] [resolution y]*/
|
||||
{"VGA-1", 1, -1, -1, 1440, 900}
|
||||
/* [monitor name] [x] [y] [resolution x] [resolution y]*/
|
||||
{"VGA-1", -1, -1, 1440, 900}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
43
include/main.h
Normal file
43
include/main.h
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef _MAIN_H
|
||||
#define _MAIN_H
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_data_control_v1.h>
|
||||
#include <wlr/types/wlr_data_device.h>
|
||||
#include <wlr/types/wlr_export_dmabuf_v1.h>
|
||||
#include <wlr/types/wlr_gamma_control_v1.h>
|
||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||
#include <wlr/types/wlr_screencopy_v1.h>
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_scene.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "structs.h"
|
||||
#include "config.h"
|
||||
#include "die.h"
|
||||
|
||||
struct server {
|
||||
struct wl_display *wl_display;
|
||||
|
||||
struct wlr_backend *backend;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_scene *scene;
|
||||
struct wlr_output_layout *output_layout;
|
||||
|
||||
struct wlr_allocator *alloc;
|
||||
|
||||
/* Monitors */
|
||||
struct wl_list outputs;
|
||||
struct wl_listener new_output;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,67 +0,0 @@
|
||||
#ifndef _SERVER_H
|
||||
#define _SERVER_H
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/backend/libinput.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <wlr/types/wlr_data_control_v1.h>
|
||||
#include <wlr/types/wlr_data_device.h>
|
||||
#include <wlr/types/wlr_export_dmabuf_v1.h>
|
||||
#include <wlr/types/wlr_gamma_control_v1.h>
|
||||
#include <wlr/types/wlr_idle.h>
|
||||
#include <wlr/types/wlr_idle_inhibit_v1.h>
|
||||
#include <wlr/types/wlr_idle_notify_v1.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_input_inhibitor.h>
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_output_management_v1.h>
|
||||
#include <wlr/types/wlr_pointer.h>
|
||||
#include <wlr/types/wlr_presentation_time.h>
|
||||
#include <wlr/types/wlr_primary_selection.h>
|
||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||
#include <wlr/types/wlr_scene.h>
|
||||
#include <wlr/types/wlr_screencopy_v1.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
#include <wlr/types/wlr_server_decoration.h>
|
||||
#include <wlr/types/wlr_session_lock_v1.h>
|
||||
#include <wlr/types/wlr_single_pixel_buffer_v1.h>
|
||||
#include <wlr/types/wlr_subcompositor.h>
|
||||
#include <wlr/types/wlr_viewporter.h>
|
||||
#include <wlr/types/wlr_virtual_keyboard_v1.h>
|
||||
#include <wlr/types/wlr_xcursor_manager.h>
|
||||
#include <wlr/types/wlr_xdg_activation_v1.h>
|
||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
||||
#include <wlr/types/wlr_xdg_output_v1.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include "structs.h"
|
||||
#include "config.h"
|
||||
#include "die.h"
|
||||
|
||||
struct server {
|
||||
struct wl_display *wl_display;
|
||||
struct wl_event_loop *wl_event_loop;
|
||||
struct wlr_allocator *alloc;
|
||||
|
||||
struct wlr_backend *backend;
|
||||
struct wlr_compositor *compositor;
|
||||
struct wlr_renderer *renderer;
|
||||
|
||||
/* Monitors */
|
||||
struct wl_list outputs;
|
||||
};
|
||||
|
||||
|
||||
void createmon(struct wl_listener *listener, void *data);
|
||||
static struct wl_listener new_output = {.notify = createmon};
|
||||
|
||||
void server_init(struct server *server);
|
||||
#endif
|
@ -3,7 +3,6 @@
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
int id;
|
||||
int x;
|
||||
int y;
|
||||
int res_x;
|
||||
|
74
src/main.c
74
src/main.c
@ -1,16 +1,64 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <wayland-util.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "server.h"
|
||||
#include "die.h"
|
||||
#include "main.h"
|
||||
|
||||
void destroy(struct server *server) {
|
||||
wlr_backend_destroy(server->backend);
|
||||
void rendermon(struct wl_listener *listener, void *data) {
|
||||
}
|
||||
|
||||
void cleanupmon(struct wl_listener *listener, void *data) {
|
||||
}
|
||||
|
||||
void createmon(struct wl_listener *listener, void *data) {
|
||||
struct server *server = wl_container_of(listener, server, new_output);
|
||||
struct wlr_output *wlr_output = data;
|
||||
wlr_output_init_render(wlr_output, server->alloc, server->renderer);
|
||||
|
||||
wlr_output_set_mode(wlr_output, wlr_output_preferred_mode(wlr_output));
|
||||
|
||||
wlr_output_enable(wlr_output, 1);
|
||||
if (!wlr_output_commit(wlr_output))
|
||||
return;
|
||||
|
||||
wlr_output_layout_add_auto(server->output_layout, wlr_output);
|
||||
}
|
||||
|
||||
void server_init(struct server *server) {
|
||||
server->wl_display = wl_display_create();
|
||||
assert(server->wl_display);
|
||||
|
||||
server->backend = wlr_backend_autocreate(server->wl_display);
|
||||
assert(server->backend);
|
||||
|
||||
/* Create a renderer with the default implementation */
|
||||
server->renderer = wlr_renderer_autocreate(server->backend);
|
||||
assert(server->renderer);
|
||||
|
||||
wlr_renderer_init_wl_display(server->renderer, server->wl_display);
|
||||
|
||||
/* Create a default allocator */
|
||||
server->alloc = wlr_allocator_autocreate(server->backend, server->renderer);
|
||||
assert(server->alloc);
|
||||
|
||||
wlr_data_device_manager_create(server->wl_display);
|
||||
wlr_export_dmabuf_manager_v1_create(server->wl_display);
|
||||
wlr_screencopy_manager_v1_create(server->wl_display);
|
||||
wlr_data_control_manager_v1_create(server->wl_display);
|
||||
wlr_gamma_control_manager_v1_create(server->wl_display);
|
||||
wlr_primary_selection_v1_device_manager_create(server->wl_display);
|
||||
|
||||
/* Init monitors */
|
||||
server->new_output.notify = createmon;
|
||||
wl_signal_add(&server->backend->events.new_output, &server->new_output);
|
||||
wl_list_init(&server->outputs);
|
||||
|
||||
const char *socket = wl_display_add_socket_auto(server->wl_display);
|
||||
assert(socket);
|
||||
|
||||
printf("Running compositor on wayland display '%s'\n", socket);
|
||||
setenv("WAYLAND_DISPLAY", socket, 1);
|
||||
|
||||
if (!wlr_backend_start(server->backend)) {
|
||||
wl_display_destroy(server->wl_display);
|
||||
die("wlr_backend_start", 1);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
@ -27,7 +75,7 @@ int main(void) {
|
||||
server_init(&server);
|
||||
|
||||
wl_display_run(server.wl_display);
|
||||
destroy(&server);
|
||||
|
||||
wlr_backend_destroy(server.backend);
|
||||
wl_display_destroy(server.wl_display);
|
||||
return 0;
|
||||
}
|
||||
|
50
src/server.c
50
src/server.c
@ -1,50 +0,0 @@
|
||||
#include "server.h"
|
||||
|
||||
void createmon(struct wl_listener *listener, void *data) {
|
||||
|
||||
}
|
||||
|
||||
void server_init(struct server *server) {
|
||||
server->wl_display = wl_display_create();
|
||||
assert(server->wl_display);
|
||||
|
||||
server->wl_event_loop = wl_display_get_event_loop(server->wl_display);
|
||||
assert(server->wl_event_loop);
|
||||
|
||||
server->backend = wlr_backend_autocreate(server->wl_display);
|
||||
assert(server->backend);
|
||||
|
||||
server->renderer = wlr_renderer_autocreate(server->backend);
|
||||
assert(server->renderer);
|
||||
|
||||
wlr_renderer_init_wl_display(server->renderer, server->wl_display);
|
||||
|
||||
server->alloc = wlr_allocator_autocreate(server->backend, server->renderer);
|
||||
assert(server->alloc);
|
||||
|
||||
server->compositor = wlr_compositor_create(server->wl_display, server->renderer);
|
||||
wlr_export_dmabuf_manager_v1_create(server->wl_display);
|
||||
wlr_screencopy_manager_v1_create(server->wl_display);
|
||||
wlr_data_control_manager_v1_create(server->wl_display);
|
||||
wlr_data_device_manager_create(server->wl_display);
|
||||
wlr_gamma_control_manager_v1_create(server->wl_display);
|
||||
wlr_primary_selection_v1_device_manager_create(server->wl_display);
|
||||
wlr_viewporter_create(server->wl_display);
|
||||
wlr_single_pixel_buffer_manager_v1_create(server->wl_display);
|
||||
wlr_subcompositor_create(server->wl_display);
|
||||
|
||||
wl_list_init(&server->outputs);
|
||||
wl_signal_add(&server->backend->events.new_output, &new_output);
|
||||
|
||||
const char *socket = wl_display_add_socket_auto(server->wl_display);
|
||||
assert(socket);
|
||||
|
||||
printf("Running compositor on wayland display '%s'\n", socket);
|
||||
setenv("WAYLAND_DISPLAY", socket, 1);
|
||||
|
||||
if (!wlr_backend_start(server->backend)) {
|
||||
wl_display_destroy(server->wl_display);
|
||||
die("wlr_backend_start", 1);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user