WIP put width/height in surface
This commit is contained in:
parent
53af3af200
commit
4806cff440
2 changed files with 10 additions and 9 deletions
16
wayland.c
16
wayland.c
|
|
@ -3,6 +3,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "wayland.h"
|
#include "wayland.h"
|
||||||
|
|
||||||
|
/// Starting values.
|
||||||
|
int width = 700, height = 700;
|
||||||
|
|
||||||
static void wl_buffer_release(void *data, struct wl_buffer *wl_buffer) {
|
static void wl_buffer_release(void *data, struct wl_buffer *wl_buffer) {
|
||||||
/* Sent by the compositor when it's no longer using this buffer */
|
/* Sent by the compositor when it's no longer using this buffer */
|
||||||
wl_buffer_destroy(wl_buffer);
|
wl_buffer_destroy(wl_buffer);
|
||||||
|
|
@ -38,12 +41,12 @@ static void xdg_toplevel_configure (
|
||||||
) {
|
) {
|
||||||
|
|
||||||
struct client_state *state = data;
|
struct client_state *state = data;
|
||||||
state->width = width;
|
|
||||||
state->height = height;
|
|
||||||
// resize egl window
|
// resize egl window
|
||||||
struct surface_list *next = state->surface_list;
|
struct surface_list *next = state->surface_list;
|
||||||
|
|
||||||
while (next->data.xdg_toplevel != xdg_toplevel) { next = next->next; }
|
while (next->data.xdg_toplevel != xdg_toplevel) { next = next->next; }
|
||||||
|
next->data.width = width;
|
||||||
|
next->data.height = height;
|
||||||
wl_egl_window_resize(next->data.egl_window, width, height, 0, 0);
|
wl_egl_window_resize(next->data.egl_window, width, height, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,10 +70,10 @@ static const struct xdg_toplevel_listener xdg_toplevel_listener = {
|
||||||
|
|
||||||
static void zwlr_layer_surface_v1_configure(void *data, struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial, uint32_t width, uint32_t height) {
|
static void zwlr_layer_surface_v1_configure(void *data, struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial, uint32_t width, uint32_t height) {
|
||||||
struct client_state *state = data;
|
struct client_state *state = data;
|
||||||
state->width = width;
|
|
||||||
state->height = height;
|
|
||||||
struct surface_list *next = state->surface_list;
|
struct surface_list *next = state->surface_list;
|
||||||
while (next->data.zwlr_layer_surface_v1 != zwlr_layer_surface_v1) { next = next->next; }
|
while (next->data.zwlr_layer_surface_v1 != zwlr_layer_surface_v1) { next = next->next; }
|
||||||
|
next->data.width = width;
|
||||||
|
next->data.height = height;
|
||||||
wl_egl_window_resize(next->data.egl_window, width, height, 0, 0);
|
wl_egl_window_resize(next->data.egl_window, width, height, 0, 0);
|
||||||
zwlr_layer_surface_v1_ack_configure(zwlr_layer_surface_v1, serial);
|
zwlr_layer_surface_v1_ack_configure(zwlr_layer_surface_v1, serial);
|
||||||
}
|
}
|
||||||
|
|
@ -251,7 +254,7 @@ static void egl_init(struct client_state *state) {
|
||||||
struct surface_list *next = state->surface_list;
|
struct surface_list *next = state->surface_list;
|
||||||
while (next != NULL) {
|
while (next != NULL) {
|
||||||
next->data.egl_window = wl_egl_window_create(next->data.wl_surface,
|
next->data.egl_window = wl_egl_window_create(next->data.wl_surface,
|
||||||
state->width, state->height);
|
next->data.width, next->data.height);
|
||||||
if (next->data.egl_window == EGL_NO_SURFACE) {
|
if (next->data.egl_window == EGL_NO_SURFACE) {
|
||||||
fprintf(stderr, "Can't create egl window\n");
|
fprintf(stderr, "Can't create egl window\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
@ -277,9 +280,6 @@ static void egl_init(struct client_state *state) {
|
||||||
|
|
||||||
/// Initializes wayland and creates an opengl context
|
/// Initializes wayland and creates an opengl context
|
||||||
void wayland_init(struct client_state *state, int output_type) {
|
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->running = 1;
|
||||||
state->output_type = output_type;
|
state->output_type = output_type;
|
||||||
state->wl_display = wl_display_connect(NULL);
|
state->wl_display = wl_display_connect(NULL);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
#define OUTPUT_LAYER 1
|
#define OUTPUT_LAYER 1
|
||||||
|
|
||||||
struct surface {
|
struct surface {
|
||||||
|
int width, height;
|
||||||
|
|
||||||
struct wl_surface *wl_surface;
|
struct wl_surface *wl_surface;
|
||||||
struct xdg_surface *xdg_surface;
|
struct xdg_surface *xdg_surface;
|
||||||
struct xdg_toplevel *xdg_toplevel;
|
struct xdg_toplevel *xdg_toplevel;
|
||||||
|
|
@ -25,7 +27,6 @@ struct surface_list {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct client_state {
|
struct client_state {
|
||||||
int width, height;
|
|
||||||
int running;
|
int running;
|
||||||
int output_type;
|
int output_type;
|
||||||
/* Globals */
|
/* Globals */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue