moved things around
This commit is contained in:
parent
7e2171681d
commit
35d8ca7358
3 changed files with 45 additions and 10 deletions
12
glonkers.c
12
glonkers.c
|
|
@ -9,6 +9,7 @@
|
|||
#include <sys/mman.h>
|
||||
#include "renderer.h"
|
||||
#include "wayland.h"
|
||||
#include <string.h>
|
||||
|
||||
struct timespec program_start;
|
||||
|
||||
|
|
@ -26,15 +27,24 @@ double time_since_start() {
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
char *shader_path = NULL;
|
||||
int output_type = OUTPUT_WINDOW;
|
||||
if (argc >= 2) {
|
||||
shader_path = argv[1];
|
||||
} else {
|
||||
printf("need to supply path to shader\n");
|
||||
exit(1);
|
||||
}
|
||||
if (argc >= 3) {
|
||||
// xdg toplevel window (window) or wlr_layer_shell window (layer)
|
||||
if (strcmp(argv[2], "window")) {
|
||||
output_type = OUTPUT_WINDOW;
|
||||
} else if (strcmp(argv[2], "layer")) {
|
||||
output_type = OUTPUT_LAYER;
|
||||
}
|
||||
}
|
||||
|
||||
struct client_state state;
|
||||
wayland_init(&state);
|
||||
wayland_init(&state, output_type);
|
||||
|
||||
Renderer renderer = new_renderer();
|
||||
|
||||
|
|
|
|||
30
wayland.c
30
wayland.c
|
|
@ -71,12 +71,28 @@ registry_handle_global(void *data, struct wl_registry *registry,
|
|||
if (strcmp(interface, wl_compositor_interface.name) == 0) {
|
||||
state->wl_compositor = wl_registry_bind(
|
||||
registry, name, &wl_compositor_interface, 4);
|
||||
// Set up wl_surface
|
||||
state->wl_surface = wl_compositor_create_surface(state->wl_compositor);
|
||||
}
|
||||
if (strcmp(interface, xdg_wm_base_interface.name) == 0) {
|
||||
state->xdg_wm_base = wl_registry_bind(
|
||||
registry, name, &xdg_wm_base_interface, 1);
|
||||
xdg_wm_base_add_listener(state->xdg_wm_base,
|
||||
&xdg_wm_base_listener, state);
|
||||
|
||||
state->xdg_surface = xdg_wm_base_get_xdg_surface(
|
||||
state->xdg_wm_base, state->wl_surface);
|
||||
xdg_surface_add_listener(state->xdg_surface, &xdg_surface_listener, state);
|
||||
state->xdg_toplevel = xdg_surface_get_toplevel(state->xdg_surface);
|
||||
xdg_toplevel_set_title(state->xdg_toplevel, "GLONKERS! 🕴️");
|
||||
xdg_toplevel_add_listener(state->xdg_toplevel, &xdg_toplevel_listener, state);
|
||||
}
|
||||
if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) {
|
||||
state->zwlr_layer_shell_v1 = wl_registry_bind(registry, name, &zwlr_layer_shell_v1_interface, 4);
|
||||
}
|
||||
if (strcmp(interface, wl_output_interface.name) == 0) {
|
||||
state->wl_output = wl_registry_bind(
|
||||
registry, name, &wl_output_interface, 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -180,23 +196,21 @@ static void egl_init(struct client_state *state) {
|
|||
}
|
||||
|
||||
/// Initializes wayland and creates an opengl context
|
||||
void wayland_init(struct client_state *state) {
|
||||
void wayland_init(struct client_state *state, int output_type) {
|
||||
int width = 700, height = 700;
|
||||
state->width = width;
|
||||
state->height = height;
|
||||
state->running = 1;
|
||||
state->output_type = output_type;
|
||||
state->wl_display = wl_display_connect(NULL);
|
||||
state->wl_registry = wl_display_get_registry(state->wl_display);
|
||||
wl_registry_add_listener(state->wl_registry, &wl_registry_listener, state);
|
||||
wl_display_roundtrip(state->wl_display);
|
||||
|
||||
state->wl_surface = wl_compositor_create_surface(state->wl_compositor);
|
||||
state->xdg_surface = xdg_wm_base_get_xdg_surface(
|
||||
state->xdg_wm_base, state->wl_surface);
|
||||
xdg_surface_add_listener(state->xdg_surface, &xdg_surface_listener, state);
|
||||
state->xdg_toplevel = xdg_surface_get_toplevel(state->xdg_surface);
|
||||
xdg_toplevel_set_title(state->xdg_toplevel, "GLONKERS! 🕴️");
|
||||
xdg_toplevel_add_listener(state->xdg_toplevel, &xdg_toplevel_listener, state);
|
||||
// wlr_layer_shell
|
||||
//int layer = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
|
||||
//struct zwlr_layer_surface_v1 *zwlr_layer_surface = zwlr_layer_shell_v1_get_layer_surface(state->zwlr_layer_shell_v1, state->wl_surface, state->wl_output, layer, "wallpaper");
|
||||
// toplevel
|
||||
wl_surface_commit(state->wl_surface);
|
||||
|
||||
egl_init(state);
|
||||
|
|
|
|||
13
wayland.h
13
wayland.h
|
|
@ -1,10 +1,17 @@
|
|||
#include <EGL/egl.h>
|
||||
#include <wayland-egl.h>
|
||||
#include "xdg-shell-protocol.h"
|
||||
#include "wlr-layer-shell-unstable-v1-protocol.h"
|
||||
|
||||
/// A normal window
|
||||
#define OUTPUT_WINDOW 0;
|
||||
/// A desktop layer (wallpaper)
|
||||
#define OUTPUT_LAYER 1;
|
||||
|
||||
struct client_state {
|
||||
int width, height;
|
||||
int running;
|
||||
int output_type;
|
||||
/* Globals */
|
||||
struct wl_display *wl_display;
|
||||
struct wl_registry *wl_registry;
|
||||
|
|
@ -17,12 +24,16 @@ struct client_state {
|
|||
|
||||
struct wl_egl_window *egl_window;
|
||||
|
||||
// wlr_layer_shell
|
||||
struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1;
|
||||
struct wl_output *wl_output;
|
||||
|
||||
EGLDisplay egl_display;
|
||||
EGLConfig egl_config;
|
||||
EGLSurface egl_surface;
|
||||
EGLContext egl_context;
|
||||
};
|
||||
|
||||
void wayland_init(struct client_state *state);
|
||||
void wayland_init(struct client_state *state, int output_type);
|
||||
void commit(struct client_state *state);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue