2 adet wayland demo programi

Başlatan unixmania, 12 Aralık 2017 - 11:16:06

« önceki - sonraki »

0 Üyeler ve 1 Ziyaretçi konuyu incelemekte.

unixmania

selamun aleykum. Grafik kutuphaneleri (gtk, qt falan) zaten hazir olarak wayland destegiyle geliyor.  "Ama ben isin temelini ogrenmek icin bu kutuphaneleri

kullanmadan wayland oturumunda calisacak grafik arayuzlu bir program yapmak istiyom, nasil oluyor" diyen varsa 2 tane demo paylasiyom. Demolar birer

dosyadan ibaret olup; derleme komutu dosyalarin basinda yaziyor. Bagimliliklar: wayland, cairo ve derlemek icin gcc ile pkg-config.

Cairo da ilkel (low level)  bir grafik kutuphanesidir aslinda onu da kullanmasam olurdu ancak metinleri cairoya cizdirdim kolaya kactim.

Cairoyla cizdigim kutunun icinde cairo yaziyor.


/*
* gcc -s -O3 -march=native `pkg-config --cflags cairo` this_file.c -lwayland-client `pkg-config --libs cairo`
*/

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <wayland-client.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <linux/input.h> // for keyboard

#include <cairo.h>

struct wl_output;
struct wl_seat;
struct wl_surface;
struct zxdg_popup_v6;
struct zxdg_positioner_v6;
struct zxdg_shell_v6;
struct zxdg_surface_v6;
struct zxdg_toplevel_v6;


extern const struct wl_interface zxdg_shell_v6_interface;
extern const struct wl_interface zxdg_positioner_v6_interface;
extern const struct wl_interface zxdg_surface_v6_interface;
extern const struct wl_interface zxdg_toplevel_v6_interface;
extern const struct wl_interface zxdg_popup_v6_interface;

#ifndef ZXDG_SHELL_V6_ERROR_ENUM
#define ZXDG_SHELL_V6_ERROR_ENUM
enum zxdg_shell_v6_error {
ZXDG_SHELL_V6_ERROR_ROLE = 0,
ZXDG_SHELL_V6_ERROR_DEFUNCT_SURFACES = 1,
ZXDG_SHELL_V6_ERROR_NOT_THE_TOPMOST_POPUP = 2,
ZXDG_SHELL_V6_ERROR_INVALID_POPUP_PARENT = 3,
ZXDG_SHELL_V6_ERROR_INVALID_SURFACE_STATE = 4,
ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER = 5,
};
#endif /* ZXDG_SHELL_V6_ERROR_ENUM */

struct zxdg_shell_v6_listener {
void (*ping)(void *data,
     struct zxdg_shell_v6 *zxdg_shell_v6,
     uint32_t serial);
};

static inline int
zxdg_shell_v6_add_listener(struct zxdg_shell_v6 *zxdg_shell_v6,
   const struct zxdg_shell_v6_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) zxdg_shell_v6,
     (void (**)(void)) listener, data);
}

#define ZXDG_SHELL_V6_DESTROY 0
#define ZXDG_SHELL_V6_CREATE_POSITIONER 1
#define ZXDG_SHELL_V6_GET_XDG_SURFACE 2
#define ZXDG_SHELL_V6_PONG 3

#define ZXDG_SHELL_V6_PING_SINCE_VERSION 1

#define ZXDG_SHELL_V6_DESTROY_SINCE_VERSION 1
#define ZXDG_SHELL_V6_CREATE_POSITIONER_SINCE_VERSION 1
#define ZXDG_SHELL_V6_GET_XDG_SURFACE_SINCE_VERSION 1
#define ZXDG_SHELL_V6_PONG_SINCE_VERSION 1

static inline void
zxdg_shell_v6_set_user_data(struct zxdg_shell_v6 *zxdg_shell_v6, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zxdg_shell_v6, user_data);
}

static inline void *
zxdg_shell_v6_get_user_data(struct zxdg_shell_v6 *zxdg_shell_v6)
{
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_shell_v6);
}

static inline uint32_t
zxdg_shell_v6_get_version(struct zxdg_shell_v6 *zxdg_shell_v6)
{
return wl_proxy_get_version((struct wl_proxy *) zxdg_shell_v6);
}

static inline void
zxdg_shell_v6_destroy(struct zxdg_shell_v6 *zxdg_shell_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_shell_v6,
ZXDG_SHELL_V6_DESTROY);

wl_proxy_destroy((struct wl_proxy *) zxdg_shell_v6);
}

static inline struct zxdg_positioner_v6 *
zxdg_shell_v6_create_positioner(struct zxdg_shell_v6 *zxdg_shell_v6)
{
struct wl_proxy *id;

id = wl_proxy_marshal_constructor((struct wl_proxy *) zxdg_shell_v6,
ZXDG_SHELL_V6_CREATE_POSITIONER, &zxdg_positioner_v6_interface, NULL);

return (struct zxdg_positioner_v6 *) id;
}

static inline struct zxdg_surface_v6 *
zxdg_shell_v6_get_xdg_surface(struct zxdg_shell_v6 *zxdg_shell_v6, struct wl_surface *surface)
{
struct wl_proxy *id;

id = wl_proxy_marshal_constructor((struct wl_proxy *) zxdg_shell_v6,
ZXDG_SHELL_V6_GET_XDG_SURFACE, &zxdg_surface_v6_interface, NULL, surface);

return (struct zxdg_surface_v6 *) id;
}

static inline void
zxdg_shell_v6_pong(struct zxdg_shell_v6 *zxdg_shell_v6, uint32_t serial)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_shell_v6,
ZXDG_SHELL_V6_PONG, serial);
}

#ifndef ZXDG_POSITIONER_V6_ERROR_ENUM
#define ZXDG_POSITIONER_V6_ERROR_ENUM
enum zxdg_positioner_v6_error {
ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT = 0,
};
#endif /* ZXDG_POSITIONER_V6_ERROR_ENUM */

#ifndef ZXDG_POSITIONER_V6_ANCHOR_ENUM
#define ZXDG_POSITIONER_V6_ANCHOR_ENUM
enum zxdg_positioner_v6_anchor {
ZXDG_POSITIONER_V6_ANCHOR_NONE = 0,
ZXDG_POSITIONER_V6_ANCHOR_TOP = 1,
ZXDG_POSITIONER_V6_ANCHOR_BOTTOM = 2,
ZXDG_POSITIONER_V6_ANCHOR_LEFT = 4,
ZXDG_POSITIONER_V6_ANCHOR_RIGHT = 8,
};
#endif /* ZXDG_POSITIONER_V6_ANCHOR_ENUM */

#ifndef ZXDG_POSITIONER_V6_GRAVITY_ENUM
#define ZXDG_POSITIONER_V6_GRAVITY_ENUM
enum zxdg_positioner_v6_gravity {
ZXDG_POSITIONER_V6_GRAVITY_NONE = 0,
ZXDG_POSITIONER_V6_GRAVITY_TOP = 1,
ZXDG_POSITIONER_V6_GRAVITY_BOTTOM = 2,
ZXDG_POSITIONER_V6_GRAVITY_LEFT = 4,
ZXDG_POSITIONER_V6_GRAVITY_RIGHT = 8,
};
#endif /* ZXDG_POSITIONER_V6_GRAVITY_ENUM */

#ifndef ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_ENUM
#define ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_ENUM

enum zxdg_positioner_v6_constraint_adjustment {
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE = 0,
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_X = 1,
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_Y = 2,
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_X = 4,
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_Y = 8,
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_X = 16,
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32,
};
#endif /* ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_ENUM */

#define ZXDG_POSITIONER_V6_DESTROY 0
#define ZXDG_POSITIONER_V6_SET_SIZE 1
#define ZXDG_POSITIONER_V6_SET_ANCHOR_RECT 2
#define ZXDG_POSITIONER_V6_SET_ANCHOR 3
#define ZXDG_POSITIONER_V6_SET_GRAVITY 4
#define ZXDG_POSITIONER_V6_SET_CONSTRAINT_ADJUSTMENT 5
#define ZXDG_POSITIONER_V6_SET_OFFSET 6


#define ZXDG_POSITIONER_V6_DESTROY_SINCE_VERSION 1
#define ZXDG_POSITIONER_V6_SET_SIZE_SINCE_VERSION 1
#define ZXDG_POSITIONER_V6_SET_ANCHOR_RECT_SINCE_VERSION 1
#define ZXDG_POSITIONER_V6_SET_ANCHOR_SINCE_VERSION 1
#define ZXDG_POSITIONER_V6_SET_GRAVITY_SINCE_VERSION 1
#define ZXDG_POSITIONER_V6_SET_CONSTRAINT_ADJUSTMENT_SINCE_VERSION 1
#define ZXDG_POSITIONER_V6_SET_OFFSET_SINCE_VERSION 1

static inline void
zxdg_positioner_v6_set_user_data(struct zxdg_positioner_v6 *zxdg_positioner_v6, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zxdg_positioner_v6, user_data);
}

static inline void *
zxdg_positioner_v6_get_user_data(struct zxdg_positioner_v6 *zxdg_positioner_v6)
{
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_positioner_v6);
}

static inline uint32_t
zxdg_positioner_v6_get_version(struct zxdg_positioner_v6 *zxdg_positioner_v6)
{
return wl_proxy_get_version((struct wl_proxy *) zxdg_positioner_v6);
}

static inline void
zxdg_positioner_v6_destroy(struct zxdg_positioner_v6 *zxdg_positioner_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_DESTROY);

wl_proxy_destroy((struct wl_proxy *) zxdg_positioner_v6);
}

static inline void
zxdg_positioner_v6_set_size(struct zxdg_positioner_v6 *zxdg_positioner_v6, int32_t width, int32_t height)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_SET_SIZE, width, height);
}

static inline void
zxdg_positioner_v6_set_anchor_rect(struct zxdg_positioner_v6 *zxdg_positioner_v6, int32_t x, int32_t y, int32_t width, int32_t height)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_SET_ANCHOR_RECT, x, y, width, height);
}

static inline void
zxdg_positioner_v6_set_anchor(struct zxdg_positioner_v6 *zxdg_positioner_v6, uint32_t anchor)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_SET_ANCHOR, anchor);
}

static inline void
zxdg_positioner_v6_set_gravity(struct zxdg_positioner_v6 *zxdg_positioner_v6, uint32_t gravity)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_SET_GRAVITY, gravity);
}

static inline void
zxdg_positioner_v6_set_constraint_adjustment(struct zxdg_positioner_v6 *zxdg_positioner_v6, uint32_t constraint_adjustment)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_SET_CONSTRAINT_ADJUSTMENT, constraint_adjustment);
}

static inline void
zxdg_positioner_v6_set_offset(struct zxdg_positioner_v6 *zxdg_positioner_v6, int32_t x, int32_t y)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_SET_OFFSET, x, y);
}

#ifndef ZXDG_SURFACE_V6_ERROR_ENUM
#define ZXDG_SURFACE_V6_ERROR_ENUM
enum zxdg_surface_v6_error {
ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED = 1,
ZXDG_SURFACE_V6_ERROR_ALREADY_CONSTRUCTED = 2,
ZXDG_SURFACE_V6_ERROR_UNCONFIGURED_BUFFER = 3,
};
#endif /* ZXDG_SURFACE_V6_ERROR_ENUM */

struct zxdg_surface_v6_listener {
void (*configure)(void *data,
  struct zxdg_surface_v6 *zxdg_surface_v6,
  uint32_t serial);
};

static inline int
zxdg_surface_v6_add_listener(struct zxdg_surface_v6 *zxdg_surface_v6,
     const struct zxdg_surface_v6_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) zxdg_surface_v6,
     (void (**)(void)) listener, data);
}

#define ZXDG_SURFACE_V6_DESTROY 0
#define ZXDG_SURFACE_V6_GET_TOPLEVEL 1
#define ZXDG_SURFACE_V6_GET_POPUP 2
#define ZXDG_SURFACE_V6_SET_WINDOW_GEOMETRY 3
#define ZXDG_SURFACE_V6_ACK_CONFIGURE 4

#define ZXDG_SURFACE_V6_CONFIGURE_SINCE_VERSION 1

#define ZXDG_SURFACE_V6_DESTROY_SINCE_VERSION 1
#define ZXDG_SURFACE_V6_GET_TOPLEVEL_SINCE_VERSION 1
#define ZXDG_SURFACE_V6_GET_POPUP_SINCE_VERSION 1
#define ZXDG_SURFACE_V6_SET_WINDOW_GEOMETRY_SINCE_VERSION 1
#define ZXDG_SURFACE_V6_ACK_CONFIGURE_SINCE_VERSION 1

static inline void
zxdg_surface_v6_set_user_data(struct zxdg_surface_v6 *zxdg_surface_v6, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zxdg_surface_v6, user_data);
}

/** @ingroup iface_zxdg_surface_v6 */
static inline void *
zxdg_surface_v6_get_user_data(struct zxdg_surface_v6 *zxdg_surface_v6)
{
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_surface_v6);
}

static inline uint32_t
zxdg_surface_v6_get_version(struct zxdg_surface_v6 *zxdg_surface_v6)
{
return wl_proxy_get_version((struct wl_proxy *) zxdg_surface_v6);
}

static inline void
zxdg_surface_v6_destroy(struct zxdg_surface_v6 *zxdg_surface_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_surface_v6,
ZXDG_SURFACE_V6_DESTROY);

wl_proxy_destroy((struct wl_proxy *) zxdg_surface_v6);
}

static inline struct zxdg_toplevel_v6 *
zxdg_surface_v6_get_toplevel(struct zxdg_surface_v6 *zxdg_surface_v6)
{
struct wl_proxy *id;

id = wl_proxy_marshal_constructor((struct wl_proxy *) zxdg_surface_v6,
ZXDG_SURFACE_V6_GET_TOPLEVEL, &zxdg_toplevel_v6_interface, NULL);

return (struct zxdg_toplevel_v6 *) id;
}

static inline struct zxdg_popup_v6 *
zxdg_surface_v6_get_popup(struct zxdg_surface_v6 *zxdg_surface_v6, struct zxdg_surface_v6 *parent, struct zxdg_positioner_v6 *positioner)
{
struct wl_proxy *id;

id = wl_proxy_marshal_constructor((struct wl_proxy *) zxdg_surface_v6,
ZXDG_SURFACE_V6_GET_POPUP, &zxdg_popup_v6_interface, NULL, parent, positioner);

return (struct zxdg_popup_v6 *) id;
}

static inline void
zxdg_surface_v6_set_window_geometry(struct zxdg_surface_v6 *zxdg_surface_v6, int32_t x, int32_t y, int32_t width, int32_t height)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_surface_v6,
ZXDG_SURFACE_V6_SET_WINDOW_GEOMETRY, x, y, width, height);
}

static inline void
zxdg_surface_v6_ack_configure(struct zxdg_surface_v6 *zxdg_surface_v6, uint32_t serial)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_surface_v6,
ZXDG_SURFACE_V6_ACK_CONFIGURE, serial);
}

#ifndef ZXDG_TOPLEVEL_V6_RESIZE_EDGE_ENUM
#define ZXDG_TOPLEVEL_V6_RESIZE_EDGE_ENUM
enum zxdg_toplevel_v6_resize_edge {
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_NONE = 0,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP = 1,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM = 2,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_LEFT = 4,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP_LEFT = 5,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM_LEFT = 6,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_RIGHT = 8,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP_RIGHT = 9,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM_RIGHT = 10,
};
#endif /* ZXDG_TOPLEVEL_V6_RESIZE_EDGE_ENUM */

#ifndef ZXDG_TOPLEVEL_V6_STATE_ENUM
#define ZXDG_TOPLEVEL_V6_STATE_ENUM

enum zxdg_toplevel_v6_state {
ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED = 1,
ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN = 2,
ZXDG_TOPLEVEL_V6_STATE_RESIZING = 3,
ZXDG_TOPLEVEL_V6_STATE_ACTIVATED = 4,
};
#endif /* ZXDG_TOPLEVEL_V6_STATE_ENUM */

struct zxdg_toplevel_v6_listener {
void (*configure)(void *data,
  struct zxdg_toplevel_v6 *zxdg_toplevel_v6,
  int32_t width,
  int32_t height,
  struct wl_array *states);

void (*close)(void *data,
      struct zxdg_toplevel_v6 *zxdg_toplevel_v6);
};

static inline int
zxdg_toplevel_v6_add_listener(struct zxdg_toplevel_v6 *zxdg_toplevel_v6,
      const struct zxdg_toplevel_v6_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) zxdg_toplevel_v6,
     (void (**)(void)) listener, data);
}

#define ZXDG_TOPLEVEL_V6_DESTROY 0
#define ZXDG_TOPLEVEL_V6_SET_PARENT 1
#define ZXDG_TOPLEVEL_V6_SET_TITLE 2
#define ZXDG_TOPLEVEL_V6_SET_APP_ID 3
#define ZXDG_TOPLEVEL_V6_SHOW_WINDOW_MENU 4
#define ZXDG_TOPLEVEL_V6_MOVE 5
#define ZXDG_TOPLEVEL_V6_RESIZE 6
#define ZXDG_TOPLEVEL_V6_SET_MAX_SIZE 7
#define ZXDG_TOPLEVEL_V6_SET_MIN_SIZE 8
#define ZXDG_TOPLEVEL_V6_SET_MAXIMIZED 9
#define ZXDG_TOPLEVEL_V6_UNSET_MAXIMIZED 10
#define ZXDG_TOPLEVEL_V6_SET_FULLSCREEN 11
#define ZXDG_TOPLEVEL_V6_UNSET_FULLSCREEN 12
#define ZXDG_TOPLEVEL_V6_SET_MINIMIZED 13

#define ZXDG_TOPLEVEL_V6_CONFIGURE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_CLOSE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_DESTROY_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_PARENT_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_TITLE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_APP_ID_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SHOW_WINDOW_MENU_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_MOVE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_RESIZE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_MAX_SIZE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_MIN_SIZE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_MAXIMIZED_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_UNSET_MAXIMIZED_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_FULLSCREEN_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_UNSET_FULLSCREEN_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_MINIMIZED_SINCE_VERSION 1

static inline void
zxdg_toplevel_v6_set_user_data(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zxdg_toplevel_v6, user_data);
}

static inline void *
zxdg_toplevel_v6_get_user_data(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_toplevel_v6);
}

static inline uint32_t
zxdg_toplevel_v6_get_version(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
return wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_v6);
}

static inline void
zxdg_toplevel_v6_destroy(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_DESTROY);

wl_proxy_destroy((struct wl_proxy *) zxdg_toplevel_v6);
}

static inline void
zxdg_toplevel_v6_set_parent(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct zxdg_toplevel_v6 *parent)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_PARENT, parent);
}

static inline void
zxdg_toplevel_v6_set_title(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, const char *title)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_TITLE, title);
}

static inline void
zxdg_toplevel_v6_set_app_id(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, const char *app_id)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_APP_ID, app_id);
}

static inline void
zxdg_toplevel_v6_show_window_menu(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SHOW_WINDOW_MENU, seat, serial, x, y);
}

static inline void
zxdg_toplevel_v6_move(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_seat *seat, uint32_t serial)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_MOVE, seat, serial);
}

static inline void
zxdg_toplevel_v6_resize(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_seat *seat, uint32_t serial, uint32_t edges)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_RESIZE, seat, serial, edges);
}

static inline void
zxdg_toplevel_v6_set_max_size(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, int32_t width, int32_t height)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_MAX_SIZE, width, height);
}

static inline void
zxdg_toplevel_v6_set_min_size(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, int32_t width, int32_t height)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_MIN_SIZE, width, height);
}

static inline void
zxdg_toplevel_v6_set_maximized(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_MAXIMIZED);
}

static inline void
zxdg_toplevel_v6_unset_maximized(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_UNSET_MAXIMIZED);
}

static inline void
zxdg_toplevel_v6_set_fullscreen(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_output *output)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_FULLSCREEN, output);
}

static inline void
zxdg_toplevel_v6_unset_fullscreen(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_UNSET_FULLSCREEN);
}

static inline void
zxdg_toplevel_v6_set_minimized(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_MINIMIZED);
}

#ifndef ZXDG_POPUP_V6_ERROR_ENUM
#define ZXDG_POPUP_V6_ERROR_ENUM
enum zxdg_popup_v6_error {
ZXDG_POPUP_V6_ERROR_INVALID_GRAB = 0,
};
#endif /* ZXDG_POPUP_V6_ERROR_ENUM */

struct zxdg_popup_v6_listener {
void (*configure)(void *data,
  struct zxdg_popup_v6 *zxdg_popup_v6,
  int32_t x,
  int32_t y,
  int32_t width,
  int32_t height);
void (*popup_done)(void *data,
   struct zxdg_popup_v6 *zxdg_popup_v6);
};

static inline int
zxdg_popup_v6_add_listener(struct zxdg_popup_v6 *zxdg_popup_v6,
   const struct zxdg_popup_v6_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) zxdg_popup_v6,
     (void (**)(void)) listener, data);
}

#define ZXDG_POPUP_V6_DESTROY 0
#define ZXDG_POPUP_V6_GRAB 1

#define ZXDG_POPUP_V6_CONFIGURE_SINCE_VERSION 1
#define ZXDG_POPUP_V6_POPUP_DONE_SINCE_VERSION 1
#define ZXDG_POPUP_V6_DESTROY_SINCE_VERSION 1
#define ZXDG_POPUP_V6_GRAB_SINCE_VERSION 1

static inline void
zxdg_popup_v6_set_user_data(struct zxdg_popup_v6 *zxdg_popup_v6, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zxdg_popup_v6, user_data);
}

static inline void *
zxdg_popup_v6_get_user_data(struct zxdg_popup_v6 *zxdg_popup_v6)
{
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_popup_v6);
}

static inline uint32_t
zxdg_popup_v6_get_version(struct zxdg_popup_v6 *zxdg_popup_v6)
{
return wl_proxy_get_version((struct wl_proxy *) zxdg_popup_v6);
}

static inline void
zxdg_popup_v6_destroy(struct zxdg_popup_v6 *zxdg_popup_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_popup_v6,
ZXDG_POPUP_V6_DESTROY);

wl_proxy_destroy((struct wl_proxy *) zxdg_popup_v6);
}

static inline void
zxdg_popup_v6_grab(struct zxdg_popup_v6 *zxdg_popup_v6, struct wl_seat *seat, uint32_t serial)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_popup_v6,
ZXDG_POPUP_V6_GRAB, seat, serial);
}



extern const struct wl_interface wl_output_interface;
extern const struct wl_interface wl_seat_interface;
extern const struct wl_interface wl_surface_interface;
extern const struct wl_interface zxdg_popup_v6_interface;
extern const struct wl_interface zxdg_positioner_v6_interface;
extern const struct wl_interface zxdg_surface_v6_interface;
extern const struct wl_interface zxdg_toplevel_v6_interface;

static const struct wl_interface *types[] = {
NULL,
NULL,
NULL,
NULL,
&zxdg_positioner_v6_interface,
&zxdg_surface_v6_interface,
&wl_surface_interface,
&zxdg_toplevel_v6_interface,
&zxdg_popup_v6_interface,
&zxdg_surface_v6_interface,
&zxdg_positioner_v6_interface,
&zxdg_toplevel_v6_interface,
&wl_seat_interface,
NULL,
NULL,
NULL,
&wl_seat_interface,
NULL,
&wl_seat_interface,
NULL,
NULL,
&wl_output_interface,
&wl_seat_interface,
NULL,
};

static const struct wl_message zxdg_shell_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "create_positioner", "n", types + 4 },
{ "get_xdg_surface", "no", types + 5 },
{ "pong", "u", types + 0 },
};

static const struct wl_message zxdg_shell_v6_events[] = {
{ "ping", "u", types + 0 },
};

WL_EXPORT const struct wl_interface zxdg_shell_v6_interface = {
"zxdg_shell_v6", 1,
4, zxdg_shell_v6_requests,
1, zxdg_shell_v6_events,
};

static const struct wl_message zxdg_positioner_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "set_size", "ii", types + 0 },
{ "set_anchor_rect", "iiii", types + 0 },
{ "set_anchor", "u", types + 0 },
{ "set_gravity", "u", types + 0 },
{ "set_constraint_adjustment", "u", types + 0 },
{ "set_offset", "ii", types + 0 },
};

WL_EXPORT const struct wl_interface zxdg_positioner_v6_interface = {
"zxdg_positioner_v6", 1,
7, zxdg_positioner_v6_requests,
0, NULL,
};

static const struct wl_message zxdg_surface_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "get_toplevel", "n", types + 7 },
{ "get_popup", "noo", types + 8 },
{ "set_window_geometry", "iiii", types + 0 },
{ "ack_configure", "u", types + 0 },
};

static const struct wl_message zxdg_surface_v6_events[] = {
{ "configure", "u", types + 0 },
};

WL_EXPORT const struct wl_interface zxdg_surface_v6_interface = {
"zxdg_surface_v6", 1,
5, zxdg_surface_v6_requests,
1, zxdg_surface_v6_events,
};

static const struct wl_message zxdg_toplevel_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "set_parent", "?o", types + 11 },
{ "set_title", "s", types + 0 },
{ "set_app_id", "s", types + 0 },
{ "show_window_menu", "ouii", types + 12 },
{ "move", "ou", types + 16 },
{ "resize", "ouu", types + 18 },
{ "set_max_size", "ii", types + 0 },
{ "set_min_size", "ii", types + 0 },
{ "set_maximized", "", types + 0 },
{ "unset_maximized", "", types + 0 },
{ "set_fullscreen", "?o", types + 21 },
{ "unset_fullscreen", "", types + 0 },
{ "set_minimized", "", types + 0 },
};

static const struct wl_message zxdg_toplevel_v6_events[] = {
{ "configure", "iia", types + 0 },
{ "close", "", types + 0 },
};

WL_EXPORT const struct wl_interface zxdg_toplevel_v6_interface = {
"zxdg_toplevel_v6", 1,
14, zxdg_toplevel_v6_requests,
2, zxdg_toplevel_v6_events,
};

static const struct wl_message zxdg_popup_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "grab", "ou", types + 22 },
};

static const struct wl_message zxdg_popup_v6_events[] = {
{ "configure", "iiii", types + 0 },
{ "popup_done", "", types + 0 },
};

WL_EXPORT const struct wl_interface zxdg_popup_v6_interface = {
"zxdg_popup_v6", 1,
2, zxdg_popup_v6_requests,
2, zxdg_popup_v6_events,
};

static struct wl_display *display;
static struct wl_compositor *compositor;
static struct wl_surface *wl_surface;
static struct wl_seat *seat;
static struct wl_shm *shm;
static struct wl_buffer *buffer;
static struct wl_keyboard *keyboard;

static struct zxdg_shell_v6 *xdg_shell;
static struct zxdg_surface_v6 *xdg_surface;
static struct zxdg_toplevel_v6 *xdg_toplevel;

static cairo_surface_t *cairo_surface;
static cairo_t *cairo_ctx;

static void *shm_data;
static uint32_t color = 0xffff0000;
static int running, WIDTH = 480, HEIGHT = 360;


static void damage_buffer(int, int, int, int);

static void release (void *data, struct wl_buffer *wl_buffer)
{
;
}

static const struct wl_buffer_listener buffer_listener = {
release
};


static void keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size){}
static void enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys){}
static void leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface){}
static void modifiers(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group){}

static void key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
{
  /*printf("Key: %d, state: %d\n", key, state);*/

switch (key*state){
case KEY_ESC:
running = 0;
break;

case KEY_G:
color -= 0x100000;

wl_surface_attach(wl_surface, buffer, 0, 0);

damage_buffer(200, 50,  160, 50);
cairo_move_to(cairo_ctx, 220.0, 70.0);
cairo_show_text(cairo_ctx, "by SHM");
cairo_move_to(cairo_ctx, 205.0, 90.0);
cairo_show_text(cairo_ctx, "(damage_buffer)");
wl_surface_damage_buffer(wl_surface, 200, 50,  160, 50);

damage_buffer(200, 120, 160, 50);
cairo_move_to(cairo_ctx, 260.0, 150.0);
cairo_show_text(cairo_ctx, "Ditto");
wl_surface_damage_buffer(wl_surface, 200, 120, 160, 50);

wl_surface_commit(wl_surface);
break;

case KEY_H:
color += 0x100000;

wl_surface_attach(wl_surface, buffer, 0, 0);

damage_buffer(200, 50,  160, 50);
cairo_move_to(cairo_ctx, 220.0, 70.0);
cairo_show_text(cairo_ctx, "by SHM");
cairo_move_to(cairo_ctx, 205.0, 90.0);
cairo_show_text(cairo_ctx, "(damage_buffer)");
wl_surface_damage_buffer(wl_surface, 200, 50,  160, 50);

damage_buffer(200, 120, 160, 50);
cairo_move_to(cairo_ctx, 260.0, 150.0);
cairo_show_text(cairo_ctx, "Ditto");
wl_surface_damage_buffer(wl_surface, 200, 120, 160, 50);

wl_surface_commit(wl_surface);
break;

default:
break;
}
}

static const struct wl_keyboard_listener keyboard_listener = {
keymap,
enter,
leave,
key,
modifiers
};

static void shm_format(void *data, struct wl_shm *wl_shm, uint32_t format){}

struct wl_shm_listener shm_listener = {
shm_format
};

static void wl_surface_enter (void *data, struct wl_surface *wl_surface, struct wl_output *output){;}

static void wl_surface_leave (void *data, struct wl_surface *wl_surface, struct wl_output *output){;}

static const struct wl_surface_listener wl_surface_listener = {
wl_surface_enter,
wl_surface_leave
};

static void xdg_surface_configure (void *data, struct zxdg_surface_v6 *zxdg_surface_v6, uint32_t serial)
{
zxdg_surface_v6_ack_configure(zxdg_surface_v6, serial);
}

static const struct zxdg_surface_v6_listener surface_listener = {
xdg_surface_configure
};


static void toplevel_configure (void *data, struct zxdg_toplevel_v6 *zxdg_toplevel_v6, int32_t width, int32_t height, struct wl_array *states)
{
/* int* state;
wl_array_for_each(state, states)
{
if(*state == ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED)
zxdg_surface_v6_set_window_geometry(xdg_surface, 0, 0, width, height);

if(*state == ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN)
zxdg_surface_v6_set_window_geometry(xdg_surface, 0, 0, width, height);
}*/
}

static void toplevel_close (void *data, struct zxdg_toplevel_v6 *zxdg_toplevel_v6){;}

static const struct zxdg_toplevel_v6_listener toplevel_listener = {
toplevel_configure,
toplevel_close
};




static void shell_ping(void *data, struct zxdg_shell_v6 *zxdg_shell_v6, uint32_t serial)
{
zxdg_shell_v6_pong(zxdg_shell_v6, serial);
}

static const struct zxdg_shell_v6_listener shell_listener = {
shell_ping
};



static void capab(void *data, struct wl_seat *seat, enum wl_seat_capability caps)
{
keyboard = wl_seat_get_keyboard(seat);
wl_keyboard_add_listener(keyboard, &keyboard_listener, data);
//pointer = wl_seat_get_pointer(seat);
//wl_pointer_add_listener(pointer, &pointer_listener, NULL);
}

static const struct wl_seat_listener seat_listener = {
capab
};

static void
global_registry_handler(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version)
{
    if (strcmp(interface, "wl_compositor") == 0)
{
        compositor = wl_registry_bind(registry, id, &wl_compositor_interface, version);
    }

else if (strcmp(interface, "wl_seat") == 0)
{
seat = wl_registry_bind(registry, id, &wl_seat_interface, 1);
wl_seat_add_listener(seat, &seat_listener, data);
}

else if (strcmp(interface, "zxdg_shell_v6") == 0)
{
xdg_shell = wl_registry_bind(registry, id, &zxdg_shell_v6_interface, version);
zxdg_shell_v6_add_listener(xdg_shell, &shell_listener, data);
}

else if (strcmp(interface, "wl_shm") == 0)
{
        shm = wl_registry_bind(registry, id, &wl_shm_interface, version);
        wl_shm_add_listener(shm, &shm_listener, NULL);
    }

}

static void global_registry_remover(void *data, struct wl_registry *registry, uint32_t id){}

static const struct wl_registry_listener registry_listener = {
    global_registry_handler,
    global_registry_remover
};



static void damage_buffer(int x, int y, int width, int height)
{
    uint32_t *pixel = shm_data;

    for (int i=0; i<height; i++)
{
for (int j=0; j<width; j++)
{
*(pixel + (y+i)*WIDTH+x+j) = color;
    }
    }
}



int main(int argc, char **argv)
{
    struct wl_shm_pool *pool;
double x_pos, y_pos;
    int fd;

    display = wl_display_connect(NULL);

    struct wl_registry *registry = wl_display_get_registry(display);
    wl_registry_add_listener(registry, &registry_listener, NULL);

    wl_display_dispatch(display);
    wl_display_roundtrip(display);

    wl_surface = wl_compositor_create_surface(compositor);
wl_surface_add_listener(wl_surface, &wl_surface_listener, NULL);

xdg_surface = zxdg_shell_v6_get_xdg_surface(xdg_shell, wl_surface);
zxdg_surface_v6_add_listener(xdg_surface, &surface_listener, NULL);

xdg_toplevel = zxdg_surface_v6_get_toplevel(xdg_surface);
zxdg_toplevel_v6_add_listener(xdg_toplevel, &toplevel_listener, NULL);

/* zxdg_toplevel_v6_set_min_size(xdg_toplevel, WIDTH, HEIGHT);
zxdg_toplevel_v6_set_maximized(xdg_toplevel);
*/
wl_surface_commit(wl_surface);

wl_display_dispatch(display);
   
    fd = syscall(319, "buffer", 1);
    ftruncate(fd, 4*WIDTH*HEIGHT);
    shm_data = mmap(NULL, 4*WIDTH*HEIGHT, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
    pool     = wl_shm_create_pool(shm, fd, 4*WIDTH*HEIGHT);
    buffer   = wl_shm_pool_create_buffer(pool, 0, WIDTH, HEIGHT, 4*WIDTH, WL_SHM_FORMAT_XRGB8888);

    wl_buffer_add_listener(buffer, &buffer_listener, NULL);
    wl_shm_pool_destroy(pool);


cairo_surface = cairo_image_surface_create_for_data(shm_data, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, WIDTH));
cairo_ctx = cairo_create(cairo_surface);
// printf("hasp: %d\n", cairo_has_current_point(cairo_ctx));
cairo_get_current_point (cairo_ctx, &x_pos, &y_pos);
// printf("x  y: %F  %F\n", x_pos, y_pos);
cairo_set_source_rgb (cairo_ctx, 0.0, 0.7, 0.3);
cairo_paint (cairo_ctx);

/*
cairo_surface_flush(cairo_surface);
cairo_save(cairo_ctx);
*/
cairo_set_source_rgb(cairo_ctx, 0.9, 0.3, 0.3);
cairo_rectangle (cairo_ctx, 50.0, 50.0, 100.0, 50.0);
cairo_fill(cairo_ctx);

cairo_set_font_size(cairo_ctx, 20.0);
cairo_set_source_rgb (cairo_ctx, 0.0, 0.7, 1.0);
cairo_move_to(cairo_ctx, 65.0, 80.0);
cairo_text_path(cairo_ctx, "by Cairo");
cairo_fill(cairo_ctx);

cairo_set_source_rgb(cairo_ctx, 0.9, 0.3, 0.3);
cairo_move_to(cairo_ctx, 30.0, 200.0);
cairo_show_text(cairo_ctx, "Press H or G keys for effect or Esc for quit");

cairo_move_to(cairo_ctx, 238.0, 270.0);
cairo_show_text(cairo_ctx, ";)");


// cairo_restore(cairo_ctx);


wl_surface_attach(wl_surface, buffer, 0, 0);

damage_buffer(200, 50,  160, 50);
cairo_set_source_rgb (cairo_ctx, 0.0, 0.7, 1.0);
cairo_move_to(cairo_ctx, 220.0, 70.0);
cairo_show_text(cairo_ctx, "by SHM");
cairo_move_to(cairo_ctx, 205.0, 90.0);
cairo_show_text(cairo_ctx, "(damage_buffer)");
wl_surface_damage_buffer(wl_surface, 200, 50,  160, 50);

damage_buffer(200, 120, 160, 50);
cairo_move_to(cairo_ctx, 260.0, 150.0);
cairo_show_text(cairo_ctx, "Ditto");
wl_surface_damage_buffer(wl_surface, 200, 120, 160, 50);

wl_surface_commit(wl_surface);


running = 1;

    while ((wl_display_dispatch(display) != -1) && running) {
;
    }

cairo_surface_destroy(cairo_surface);
cairo_destroy(cairo_ctx);

zxdg_toplevel_v6_destroy(xdg_toplevel);
zxdg_surface_v6_destroy(xdg_surface);
zxdg_shell_v6_destroy(xdg_shell);


wl_surface_destroy(wl_surface);
wl_compositor_destroy(compositor);
wl_seat_destroy(seat);
    wl_display_disconnect(display);

    return 0;
}

ikincisi.

/*
* gcc -s -O3 -march=native `pkg-config --cflags cairo` xdg.c shm.c -lwayland-client `pkg-config --libs cairo`
*/

#include <unistd.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <wayland-client.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <linux/input-event-codes.h> // for keys

#include <cairo.h>


struct wl_output;
struct wl_seat;
struct wl_surface;
struct zxdg_popup_v6;
struct zxdg_positioner_v6;
struct zxdg_shell_v6;
struct zxdg_surface_v6;
struct zxdg_toplevel_v6;


extern const struct wl_interface zxdg_shell_v6_interface;
extern const struct wl_interface zxdg_positioner_v6_interface;
extern const struct wl_interface zxdg_surface_v6_interface;
extern const struct wl_interface zxdg_toplevel_v6_interface;
extern const struct wl_interface zxdg_popup_v6_interface;

#ifndef ZXDG_SHELL_V6_ERROR_ENUM
#define ZXDG_SHELL_V6_ERROR_ENUM
enum zxdg_shell_v6_error {
ZXDG_SHELL_V6_ERROR_ROLE = 0,
ZXDG_SHELL_V6_ERROR_DEFUNCT_SURFACES = 1,
ZXDG_SHELL_V6_ERROR_NOT_THE_TOPMOST_POPUP = 2,
ZXDG_SHELL_V6_ERROR_INVALID_POPUP_PARENT = 3,
ZXDG_SHELL_V6_ERROR_INVALID_SURFACE_STATE = 4,
ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER = 5,
};
#endif /* ZXDG_SHELL_V6_ERROR_ENUM */

struct zxdg_shell_v6_listener {
void (*ping)(void *data,
     struct zxdg_shell_v6 *zxdg_shell_v6,
     uint32_t serial);
};

static inline int
zxdg_shell_v6_add_listener(struct zxdg_shell_v6 *zxdg_shell_v6,
   const struct zxdg_shell_v6_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) zxdg_shell_v6,
     (void (**)(void)) listener, data);
}

#define ZXDG_SHELL_V6_DESTROY 0
#define ZXDG_SHELL_V6_CREATE_POSITIONER 1
#define ZXDG_SHELL_V6_GET_XDG_SURFACE 2
#define ZXDG_SHELL_V6_PONG 3

#define ZXDG_SHELL_V6_PING_SINCE_VERSION 1

#define ZXDG_SHELL_V6_DESTROY_SINCE_VERSION 1
#define ZXDG_SHELL_V6_CREATE_POSITIONER_SINCE_VERSION 1
#define ZXDG_SHELL_V6_GET_XDG_SURFACE_SINCE_VERSION 1
#define ZXDG_SHELL_V6_PONG_SINCE_VERSION 1

static inline void
zxdg_shell_v6_set_user_data(struct zxdg_shell_v6 *zxdg_shell_v6, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zxdg_shell_v6, user_data);
}

static inline void *
zxdg_shell_v6_get_user_data(struct zxdg_shell_v6 *zxdg_shell_v6)
{
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_shell_v6);
}

static inline uint32_t
zxdg_shell_v6_get_version(struct zxdg_shell_v6 *zxdg_shell_v6)
{
return wl_proxy_get_version((struct wl_proxy *) zxdg_shell_v6);
}

static inline void
zxdg_shell_v6_destroy(struct zxdg_shell_v6 *zxdg_shell_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_shell_v6,
ZXDG_SHELL_V6_DESTROY);

wl_proxy_destroy((struct wl_proxy *) zxdg_shell_v6);
}

static inline struct zxdg_positioner_v6 *
zxdg_shell_v6_create_positioner(struct zxdg_shell_v6 *zxdg_shell_v6)
{
struct wl_proxy *id;

id = wl_proxy_marshal_constructor((struct wl_proxy *) zxdg_shell_v6,
ZXDG_SHELL_V6_CREATE_POSITIONER, &zxdg_positioner_v6_interface, NULL);

return (struct zxdg_positioner_v6 *) id;
}

static inline struct zxdg_surface_v6 *
zxdg_shell_v6_get_xdg_surface(struct zxdg_shell_v6 *zxdg_shell_v6, struct wl_surface *surface)
{
struct wl_proxy *id;

id = wl_proxy_marshal_constructor((struct wl_proxy *) zxdg_shell_v6,
ZXDG_SHELL_V6_GET_XDG_SURFACE, &zxdg_surface_v6_interface, NULL, surface);

return (struct zxdg_surface_v6 *) id;
}

static inline void
zxdg_shell_v6_pong(struct zxdg_shell_v6 *zxdg_shell_v6, uint32_t serial)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_shell_v6,
ZXDG_SHELL_V6_PONG, serial);
}

#ifndef ZXDG_POSITIONER_V6_ERROR_ENUM
#define ZXDG_POSITIONER_V6_ERROR_ENUM
enum zxdg_positioner_v6_error {
ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT = 0,
};
#endif /* ZXDG_POSITIONER_V6_ERROR_ENUM */

#ifndef ZXDG_POSITIONER_V6_ANCHOR_ENUM
#define ZXDG_POSITIONER_V6_ANCHOR_ENUM
enum zxdg_positioner_v6_anchor {
ZXDG_POSITIONER_V6_ANCHOR_NONE = 0,
ZXDG_POSITIONER_V6_ANCHOR_TOP = 1,
ZXDG_POSITIONER_V6_ANCHOR_BOTTOM = 2,
ZXDG_POSITIONER_V6_ANCHOR_LEFT = 4,
ZXDG_POSITIONER_V6_ANCHOR_RIGHT = 8,
};
#endif /* ZXDG_POSITIONER_V6_ANCHOR_ENUM */

#ifndef ZXDG_POSITIONER_V6_GRAVITY_ENUM
#define ZXDG_POSITIONER_V6_GRAVITY_ENUM
enum zxdg_positioner_v6_gravity {
ZXDG_POSITIONER_V6_GRAVITY_NONE = 0,
ZXDG_POSITIONER_V6_GRAVITY_TOP = 1,
ZXDG_POSITIONER_V6_GRAVITY_BOTTOM = 2,
ZXDG_POSITIONER_V6_GRAVITY_LEFT = 4,
ZXDG_POSITIONER_V6_GRAVITY_RIGHT = 8,
};
#endif /* ZXDG_POSITIONER_V6_GRAVITY_ENUM */

#ifndef ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_ENUM
#define ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_ENUM

enum zxdg_positioner_v6_constraint_adjustment {
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE = 0,
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_X = 1,
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_Y = 2,
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_X = 4,
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_Y = 8,
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_X = 16,
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32,
};
#endif /* ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_ENUM */

#define ZXDG_POSITIONER_V6_DESTROY 0
#define ZXDG_POSITIONER_V6_SET_SIZE 1
#define ZXDG_POSITIONER_V6_SET_ANCHOR_RECT 2
#define ZXDG_POSITIONER_V6_SET_ANCHOR 3
#define ZXDG_POSITIONER_V6_SET_GRAVITY 4
#define ZXDG_POSITIONER_V6_SET_CONSTRAINT_ADJUSTMENT 5
#define ZXDG_POSITIONER_V6_SET_OFFSET 6


#define ZXDG_POSITIONER_V6_DESTROY_SINCE_VERSION 1
#define ZXDG_POSITIONER_V6_SET_SIZE_SINCE_VERSION 1
#define ZXDG_POSITIONER_V6_SET_ANCHOR_RECT_SINCE_VERSION 1
#define ZXDG_POSITIONER_V6_SET_ANCHOR_SINCE_VERSION 1
#define ZXDG_POSITIONER_V6_SET_GRAVITY_SINCE_VERSION 1
#define ZXDG_POSITIONER_V6_SET_CONSTRAINT_ADJUSTMENT_SINCE_VERSION 1
#define ZXDG_POSITIONER_V6_SET_OFFSET_SINCE_VERSION 1

static inline void
zxdg_positioner_v6_set_user_data(struct zxdg_positioner_v6 *zxdg_positioner_v6, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zxdg_positioner_v6, user_data);
}

static inline void *
zxdg_positioner_v6_get_user_data(struct zxdg_positioner_v6 *zxdg_positioner_v6)
{
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_positioner_v6);
}

static inline uint32_t
zxdg_positioner_v6_get_version(struct zxdg_positioner_v6 *zxdg_positioner_v6)
{
return wl_proxy_get_version((struct wl_proxy *) zxdg_positioner_v6);
}

static inline void
zxdg_positioner_v6_destroy(struct zxdg_positioner_v6 *zxdg_positioner_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_DESTROY);

wl_proxy_destroy((struct wl_proxy *) zxdg_positioner_v6);
}

static inline void
zxdg_positioner_v6_set_size(struct zxdg_positioner_v6 *zxdg_positioner_v6, int32_t width, int32_t height)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_SET_SIZE, width, height);
}

static inline void
zxdg_positioner_v6_set_anchor_rect(struct zxdg_positioner_v6 *zxdg_positioner_v6, int32_t x, int32_t y, int32_t width, int32_t height)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_SET_ANCHOR_RECT, x, y, width, height);
}

static inline void
zxdg_positioner_v6_set_anchor(struct zxdg_positioner_v6 *zxdg_positioner_v6, uint32_t anchor)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_SET_ANCHOR, anchor);
}

static inline void
zxdg_positioner_v6_set_gravity(struct zxdg_positioner_v6 *zxdg_positioner_v6, uint32_t gravity)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_SET_GRAVITY, gravity);
}

static inline void
zxdg_positioner_v6_set_constraint_adjustment(struct zxdg_positioner_v6 *zxdg_positioner_v6, uint32_t constraint_adjustment)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_SET_CONSTRAINT_ADJUSTMENT, constraint_adjustment);
}

static inline void
zxdg_positioner_v6_set_offset(struct zxdg_positioner_v6 *zxdg_positioner_v6, int32_t x, int32_t y)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_positioner_v6,
ZXDG_POSITIONER_V6_SET_OFFSET, x, y);
}

#ifndef ZXDG_SURFACE_V6_ERROR_ENUM
#define ZXDG_SURFACE_V6_ERROR_ENUM
enum zxdg_surface_v6_error {
ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED = 1,
ZXDG_SURFACE_V6_ERROR_ALREADY_CONSTRUCTED = 2,
ZXDG_SURFACE_V6_ERROR_UNCONFIGURED_BUFFER = 3,
};
#endif /* ZXDG_SURFACE_V6_ERROR_ENUM */

struct zxdg_surface_v6_listener {
void (*configure)(void *data,
  struct zxdg_surface_v6 *zxdg_surface_v6,
  uint32_t serial);
};

static inline int
zxdg_surface_v6_add_listener(struct zxdg_surface_v6 *zxdg_surface_v6,
     const struct zxdg_surface_v6_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) zxdg_surface_v6,
     (void (**)(void)) listener, data);
}

#define ZXDG_SURFACE_V6_DESTROY 0
#define ZXDG_SURFACE_V6_GET_TOPLEVEL 1
#define ZXDG_SURFACE_V6_GET_POPUP 2
#define ZXDG_SURFACE_V6_SET_WINDOW_GEOMETRY 3
#define ZXDG_SURFACE_V6_ACK_CONFIGURE 4

#define ZXDG_SURFACE_V6_CONFIGURE_SINCE_VERSION 1

#define ZXDG_SURFACE_V6_DESTROY_SINCE_VERSION 1
#define ZXDG_SURFACE_V6_GET_TOPLEVEL_SINCE_VERSION 1
#define ZXDG_SURFACE_V6_GET_POPUP_SINCE_VERSION 1
#define ZXDG_SURFACE_V6_SET_WINDOW_GEOMETRY_SINCE_VERSION 1
#define ZXDG_SURFACE_V6_ACK_CONFIGURE_SINCE_VERSION 1

static inline void
zxdg_surface_v6_set_user_data(struct zxdg_surface_v6 *zxdg_surface_v6, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zxdg_surface_v6, user_data);
}

/** @ingroup iface_zxdg_surface_v6 */
static inline void *
zxdg_surface_v6_get_user_data(struct zxdg_surface_v6 *zxdg_surface_v6)
{
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_surface_v6);
}

static inline uint32_t
zxdg_surface_v6_get_version(struct zxdg_surface_v6 *zxdg_surface_v6)
{
return wl_proxy_get_version((struct wl_proxy *) zxdg_surface_v6);
}

static inline void
zxdg_surface_v6_destroy(struct zxdg_surface_v6 *zxdg_surface_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_surface_v6,
ZXDG_SURFACE_V6_DESTROY);

wl_proxy_destroy((struct wl_proxy *) zxdg_surface_v6);
}

static inline struct zxdg_toplevel_v6 *
zxdg_surface_v6_get_toplevel(struct zxdg_surface_v6 *zxdg_surface_v6)
{
struct wl_proxy *id;

id = wl_proxy_marshal_constructor((struct wl_proxy *) zxdg_surface_v6,
ZXDG_SURFACE_V6_GET_TOPLEVEL, &zxdg_toplevel_v6_interface, NULL);

return (struct zxdg_toplevel_v6 *) id;
}

static inline struct zxdg_popup_v6 *
zxdg_surface_v6_get_popup(struct zxdg_surface_v6 *zxdg_surface_v6, struct zxdg_surface_v6 *parent, struct zxdg_positioner_v6 *positioner)
{
struct wl_proxy *id;

id = wl_proxy_marshal_constructor((struct wl_proxy *) zxdg_surface_v6,
ZXDG_SURFACE_V6_GET_POPUP, &zxdg_popup_v6_interface, NULL, parent, positioner);

return (struct zxdg_popup_v6 *) id;
}

static inline void
zxdg_surface_v6_set_window_geometry(struct zxdg_surface_v6 *zxdg_surface_v6, int32_t x, int32_t y, int32_t width, int32_t height)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_surface_v6,
ZXDG_SURFACE_V6_SET_WINDOW_GEOMETRY, x, y, width, height);
}

static inline void
zxdg_surface_v6_ack_configure(struct zxdg_surface_v6 *zxdg_surface_v6, uint32_t serial)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_surface_v6,
ZXDG_SURFACE_V6_ACK_CONFIGURE, serial);
}

#ifndef ZXDG_TOPLEVEL_V6_RESIZE_EDGE_ENUM
#define ZXDG_TOPLEVEL_V6_RESIZE_EDGE_ENUM
enum zxdg_toplevel_v6_resize_edge {
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_NONE = 0,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP = 1,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM = 2,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_LEFT = 4,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP_LEFT = 5,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM_LEFT = 6,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_RIGHT = 8,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP_RIGHT = 9,
ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM_RIGHT = 10,
};
#endif /* ZXDG_TOPLEVEL_V6_RESIZE_EDGE_ENUM */

#ifndef ZXDG_TOPLEVEL_V6_STATE_ENUM
#define ZXDG_TOPLEVEL_V6_STATE_ENUM

enum zxdg_toplevel_v6_state {
ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED = 1,
ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN = 2,
ZXDG_TOPLEVEL_V6_STATE_RESIZING = 3,
ZXDG_TOPLEVEL_V6_STATE_ACTIVATED = 4,
};
#endif /* ZXDG_TOPLEVEL_V6_STATE_ENUM */

struct zxdg_toplevel_v6_listener {
void (*configure)(void *data,
  struct zxdg_toplevel_v6 *zxdg_toplevel_v6,
  int32_t width,
  int32_t height,
  struct wl_array *states);

void (*close)(void *data,
      struct zxdg_toplevel_v6 *zxdg_toplevel_v6);
};

static inline int
zxdg_toplevel_v6_add_listener(struct zxdg_toplevel_v6 *zxdg_toplevel_v6,
      const struct zxdg_toplevel_v6_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) zxdg_toplevel_v6,
     (void (**)(void)) listener, data);
}

#define ZXDG_TOPLEVEL_V6_DESTROY 0
#define ZXDG_TOPLEVEL_V6_SET_PARENT 1
#define ZXDG_TOPLEVEL_V6_SET_TITLE 2
#define ZXDG_TOPLEVEL_V6_SET_APP_ID 3
#define ZXDG_TOPLEVEL_V6_SHOW_WINDOW_MENU 4
#define ZXDG_TOPLEVEL_V6_MOVE 5
#define ZXDG_TOPLEVEL_V6_RESIZE 6
#define ZXDG_TOPLEVEL_V6_SET_MAX_SIZE 7
#define ZXDG_TOPLEVEL_V6_SET_MIN_SIZE 8
#define ZXDG_TOPLEVEL_V6_SET_MAXIMIZED 9
#define ZXDG_TOPLEVEL_V6_UNSET_MAXIMIZED 10
#define ZXDG_TOPLEVEL_V6_SET_FULLSCREEN 11
#define ZXDG_TOPLEVEL_V6_UNSET_FULLSCREEN 12
#define ZXDG_TOPLEVEL_V6_SET_MINIMIZED 13

#define ZXDG_TOPLEVEL_V6_CONFIGURE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_CLOSE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_DESTROY_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_PARENT_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_TITLE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_APP_ID_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SHOW_WINDOW_MENU_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_MOVE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_RESIZE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_MAX_SIZE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_MIN_SIZE_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_MAXIMIZED_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_UNSET_MAXIMIZED_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_FULLSCREEN_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_UNSET_FULLSCREEN_SINCE_VERSION 1
#define ZXDG_TOPLEVEL_V6_SET_MINIMIZED_SINCE_VERSION 1

static inline void
zxdg_toplevel_v6_set_user_data(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zxdg_toplevel_v6, user_data);
}

static inline void *
zxdg_toplevel_v6_get_user_data(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_toplevel_v6);
}

static inline uint32_t
zxdg_toplevel_v6_get_version(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
return wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_v6);
}

static inline void
zxdg_toplevel_v6_destroy(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_DESTROY);

wl_proxy_destroy((struct wl_proxy *) zxdg_toplevel_v6);
}

static inline void
zxdg_toplevel_v6_set_parent(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct zxdg_toplevel_v6 *parent)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_PARENT, parent);
}

static inline void
zxdg_toplevel_v6_set_title(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, const char *title)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_TITLE, title);
}

static inline void
zxdg_toplevel_v6_set_app_id(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, const char *app_id)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_APP_ID, app_id);
}

static inline void
zxdg_toplevel_v6_show_window_menu(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SHOW_WINDOW_MENU, seat, serial, x, y);
}

static inline void
zxdg_toplevel_v6_move(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_seat *seat, uint32_t serial)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_MOVE, seat, serial);
}

static inline void
zxdg_toplevel_v6_resize(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_seat *seat, uint32_t serial, uint32_t edges)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_RESIZE, seat, serial, edges);
}

static inline void
zxdg_toplevel_v6_set_max_size(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, int32_t width, int32_t height)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_MAX_SIZE, width, height);
}

static inline void
zxdg_toplevel_v6_set_min_size(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, int32_t width, int32_t height)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_MIN_SIZE, width, height);
}

static inline void
zxdg_toplevel_v6_set_maximized(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_MAXIMIZED);
}

static inline void
zxdg_toplevel_v6_unset_maximized(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_UNSET_MAXIMIZED);
}

static inline void
zxdg_toplevel_v6_set_fullscreen(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_output *output)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_FULLSCREEN, output);
}

static inline void
zxdg_toplevel_v6_unset_fullscreen(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_UNSET_FULLSCREEN);
}

static inline void
zxdg_toplevel_v6_set_minimized(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_toplevel_v6,
ZXDG_TOPLEVEL_V6_SET_MINIMIZED);
}

#ifndef ZXDG_POPUP_V6_ERROR_ENUM
#define ZXDG_POPUP_V6_ERROR_ENUM
enum zxdg_popup_v6_error {
ZXDG_POPUP_V6_ERROR_INVALID_GRAB = 0,
};
#endif /* ZXDG_POPUP_V6_ERROR_ENUM */

struct zxdg_popup_v6_listener {
void (*configure)(void *data,
  struct zxdg_popup_v6 *zxdg_popup_v6,
  int32_t x,
  int32_t y,
  int32_t width,
  int32_t height);
void (*popup_done)(void *data,
   struct zxdg_popup_v6 *zxdg_popup_v6);
};

static inline int
zxdg_popup_v6_add_listener(struct zxdg_popup_v6 *zxdg_popup_v6,
   const struct zxdg_popup_v6_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) zxdg_popup_v6,
     (void (**)(void)) listener, data);
}

#define ZXDG_POPUP_V6_DESTROY 0
#define ZXDG_POPUP_V6_GRAB 1

#define ZXDG_POPUP_V6_CONFIGURE_SINCE_VERSION 1
#define ZXDG_POPUP_V6_POPUP_DONE_SINCE_VERSION 1
#define ZXDG_POPUP_V6_DESTROY_SINCE_VERSION 1
#define ZXDG_POPUP_V6_GRAB_SINCE_VERSION 1

static inline void
zxdg_popup_v6_set_user_data(struct zxdg_popup_v6 *zxdg_popup_v6, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zxdg_popup_v6, user_data);
}

static inline void *
zxdg_popup_v6_get_user_data(struct zxdg_popup_v6 *zxdg_popup_v6)
{
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_popup_v6);
}

static inline uint32_t
zxdg_popup_v6_get_version(struct zxdg_popup_v6 *zxdg_popup_v6)
{
return wl_proxy_get_version((struct wl_proxy *) zxdg_popup_v6);
}

static inline void
zxdg_popup_v6_destroy(struct zxdg_popup_v6 *zxdg_popup_v6)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_popup_v6,
ZXDG_POPUP_V6_DESTROY);

wl_proxy_destroy((struct wl_proxy *) zxdg_popup_v6);
}

static inline void
zxdg_popup_v6_grab(struct zxdg_popup_v6 *zxdg_popup_v6, struct wl_seat *seat, uint32_t serial)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_popup_v6,
ZXDG_POPUP_V6_GRAB, seat, serial);
}



extern const struct wl_interface wl_output_interface;
extern const struct wl_interface wl_seat_interface;
extern const struct wl_interface wl_surface_interface;
extern const struct wl_interface zxdg_popup_v6_interface;
extern const struct wl_interface zxdg_positioner_v6_interface;
extern const struct wl_interface zxdg_surface_v6_interface;
extern const struct wl_interface zxdg_toplevel_v6_interface;

static const struct wl_interface *types[] = {
NULL,
NULL,
NULL,
NULL,
&zxdg_positioner_v6_interface,
&zxdg_surface_v6_interface,
&wl_surface_interface,
&zxdg_toplevel_v6_interface,
&zxdg_popup_v6_interface,
&zxdg_surface_v6_interface,
&zxdg_positioner_v6_interface,
&zxdg_toplevel_v6_interface,
&wl_seat_interface,
NULL,
NULL,
NULL,
&wl_seat_interface,
NULL,
&wl_seat_interface,
NULL,
NULL,
&wl_output_interface,
&wl_seat_interface,
NULL,
};

static const struct wl_message zxdg_shell_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "create_positioner", "n", types + 4 },
{ "get_xdg_surface", "no", types + 5 },
{ "pong", "u", types + 0 },
};

static const struct wl_message zxdg_shell_v6_events[] = {
{ "ping", "u", types + 0 },
};

WL_EXPORT const struct wl_interface zxdg_shell_v6_interface = {
"zxdg_shell_v6", 1,
4, zxdg_shell_v6_requests,
1, zxdg_shell_v6_events,
};

static const struct wl_message zxdg_positioner_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "set_size", "ii", types + 0 },
{ "set_anchor_rect", "iiii", types + 0 },
{ "set_anchor", "u", types + 0 },
{ "set_gravity", "u", types + 0 },
{ "set_constraint_adjustment", "u", types + 0 },
{ "set_offset", "ii", types + 0 },
};

WL_EXPORT const struct wl_interface zxdg_positioner_v6_interface = {
"zxdg_positioner_v6", 1,
7, zxdg_positioner_v6_requests,
0, NULL,
};

static const struct wl_message zxdg_surface_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "get_toplevel", "n", types + 7 },
{ "get_popup", "noo", types + 8 },
{ "set_window_geometry", "iiii", types + 0 },
{ "ack_configure", "u", types + 0 },
};

static const struct wl_message zxdg_surface_v6_events[] = {
{ "configure", "u", types + 0 },
};

WL_EXPORT const struct wl_interface zxdg_surface_v6_interface = {
"zxdg_surface_v6", 1,
5, zxdg_surface_v6_requests,
1, zxdg_surface_v6_events,
};

static const struct wl_message zxdg_toplevel_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "set_parent", "?o", types + 11 },
{ "set_title", "s", types + 0 },
{ "set_app_id", "s", types + 0 },
{ "show_window_menu", "ouii", types + 12 },
{ "move", "ou", types + 16 },
{ "resize", "ouu", types + 18 },
{ "set_max_size", "ii", types + 0 },
{ "set_min_size", "ii", types + 0 },
{ "set_maximized", "", types + 0 },
{ "unset_maximized", "", types + 0 },
{ "set_fullscreen", "?o", types + 21 },
{ "unset_fullscreen", "", types + 0 },
{ "set_minimized", "", types + 0 },
};

static const struct wl_message zxdg_toplevel_v6_events[] = {
{ "configure", "iia", types + 0 },
{ "close", "", types + 0 },
};

WL_EXPORT const struct wl_interface zxdg_toplevel_v6_interface = {
"zxdg_toplevel_v6", 1,
14, zxdg_toplevel_v6_requests,
2, zxdg_toplevel_v6_events,
};

static const struct wl_message zxdg_popup_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "grab", "ou", types + 22 },
};

static const struct wl_message zxdg_popup_v6_events[] = {
{ "configure", "iiii", types + 0 },
{ "popup_done", "", types + 0 },
};

WL_EXPORT const struct wl_interface zxdg_popup_v6_interface = {
"zxdg_popup_v6", 1,
2, zxdg_popup_v6_requests,
2, zxdg_popup_v6_events,
};




static int keymap[] = {
KEY_1, 49, KEY_2, 50, KEY_3, 51, KEY_4, 52, KEY_5, 53, KEY_6, 54, KEY_7, 55, KEY_8, 56, KEY_9, 57, KEY_0, 48, KEY_MINUS, 45, KEY_EQUAL, 61, KEY_Q, 113, KEY_W, 119, KEY_E, 101, KEY_R, 114, KEY_T, 116,
KEY_Y, 121, KEY_U, 117, KEY_I, 105, KEY_O, 111, KEY_P, 112, KEY_LEFTBRACE, 91, KEY_RIGHTBRACE, 93, KEY_A, 97, KEY_S, 115, KEY_D, 100, KEY_F, 102, KEY_G, 103, KEY_H, 104, KEY_J, 106, KEY_K, 107, KEY_L, 108,
KEY_SEMICOLON, 59, KEY_APOSTROPHE, 39, KEY_GRAVE, 96, KEY_BACKSLASH, 92, KEY_Z, 122, KEY_X, 120, KEY_C, 99, KEY_V, 118, KEY_B, 98, KEY_N, 110, KEY_M, 109, KEY_COMMA, 44, KEY_DOT, 46, KEY_SLASH, 47,
KEY_102ND, 60, KEY_TAB, 9, KEY_SPACE, 32, 0
};

static int keymap_shift[] = {
KEY_102ND, 62, KEY_SEMICOLON, 58, KEY_APOSTROPHE, 34, KEY_BACKSLASH, 124, KEY_LEFTBRACE, 123, KEY_RIGHTBRACE, 125, KEY_SLASH, 63, KEY_1, 33, KEY_2, 64, KEY_3, 35, KEY_4, 36, KEY_5, 37, KEY_6, 94,
KEY_7, 38, KEY_8, 42, KEY_9, 40, KEY_0, 41, KEY_MINUS, 95, KEY_EQUAL, 43, KEY_GRAVE, 126, 0
};

static struct wl_display *display;
static struct wl_compositor *compositor;
static struct wl_surface *wl_surface;
static struct wl_seat *seat;
static struct wl_shm *shm;
static struct wl_buffer *buffer;
static struct wl_keyboard *keyboard;

static struct zxdg_shell_v6 *xdg_shell;
static struct zxdg_surface_v6 *xdg_surface;
static struct zxdg_toplevel_v6 *xdg_toplevel;

static cairo_surface_t *cairo_surface;
static cairo_t *cairo_ctx;
static cairo_text_extents_t text_extents;
static cairo_pattern_t *backround_color;
static cairo_pattern_t *text_color;

static void *shm_data;
static int running, shift_key, ctrl_key, alt_key, WIDTH = 800, HEIGHT = 360;
static double x_pos, y_pos;
static float font_size = 14.0;
static int buffer_index;

#define BUFFER_SIZE 1024

static char text_buffer[BUFFER_SIZE];
//extern char                     **environ;


static void damage_buffer(int x, int y, int width, int height, uint32_t color);


static void release (void *data, struct wl_buffer *wl_buffer)
{
;
}

static const struct wl_buffer_listener buffer_listener = {
release
};


static void keyboardmap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size){}
static void enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys){}
static void leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface){}
static void modifiers(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group){}

static void key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
{
//if(key && state) printf("Key: %d\n", key);

char c[2];
c[0] = c[1] = 0;

if(key == KEY_LEFTSHIFT || key == KEY_RIGHTSHIFT)
{
if(state) shift_key = 1;

else shift_key = 0;

return;
}

if(state)
{
if(key == KEY_BACKSPACE)
{
if(!buffer_index) return;

buffer_index--;
c[0] = text_buffer[buffer_index];
cairo_text_extents(cairo_ctx, c, &text_extents);
cairo_get_current_point (cairo_ctx, &x_pos, &y_pos);

if(c[0] == 32 || c[0] == 9)
{
text_buffer[buffer_index] = 0;
cairo_move_to(cairo_ctx, x_pos-text_extents.x_advance, y_pos);
return;
}

wl_surface_attach(wl_surface, buffer, 0, 0);

cairo_set_source (cairo_ctx, backround_color);
// cairo_set_source_rgb (cairo_ctx, 0.0, 0.7, 0.3);
cairo_rectangle(cairo_ctx, x_pos-text_extents.x_advance+text_extents.x_bearing, y_pos+text_extents.y_bearing, text_extents.width, text_extents.height);
cairo_fill(cairo_ctx);
cairo_set_source (cairo_ctx, text_color);
// cairo_set_source_rgb (cairo_ctx, 1.0, 0.0, 0.3);

wl_surface_damage_buffer(wl_surface, (int)(x_pos-text_extents.x_advance+text_extents.x_bearing), (int)(y_pos+text_extents.y_bearing), (int)(text_extents.width+1), (int)(text_extents.height+1));
wl_surface_commit(wl_surface);

cairo_move_to(cairo_ctx, x_pos-text_extents.x_advance, y_pos);

return;
}

for(int i=0, j=0; ;)
{
if(keymap[2*i] && (key == keymap[2*i]))
{
if(!shift_key) c[0] = keymap[2*i+1];

if(((key>KEY_TAB && key<KEY_LEFTBRACE) || (key>KEY_LEFTCTRL && key<KEY_SEMICOLON) || (key>KEY_BACKSLASH && key<KEY_COMMA)) && shift_key) c[0] = keymap[2*i+1] - 32;
}

if(shift_key && keymap_shift[2*j] && (key == keymap_shift[2*j])) c[0] = keymap_shift[2*j+1];

if(c[0])
{
cairo_get_current_point (cairo_ctx, &x_pos, &y_pos);
cairo_show_text(cairo_ctx, c);
cairo_text_extents(cairo_ctx, c, &text_extents);
wl_surface_attach(wl_surface, buffer, 0, 0);
wl_surface_damage_buffer(wl_surface, (int)x_pos, (int)(y_pos+text_extents.y_bearing), (int)(text_extents.width+1), (int)(text_extents.height+1));
wl_surface_commit(wl_surface);

text_buffer[buffer_index] = c[0];
if(buffer_index < BUFFER_SIZE - 2) buffer_index++;

return;
}

if(!keymap[2*i]) break;

i++;
j++;
}

switch (key)
{
case KEY_ESC:
running = 0;
break;

default:
break;
}

if(key == KEY_ENTER && shift_key)
{
if(!fork())
{
execvp(text_buffer, (char*[]){text_buffer, NULL});
}
}
}
}

static const struct wl_keyboard_listener keyboard_listener = {
keyboardmap,
enter,
leave,
key,
modifiers
};




static void
shm_format(void *data, struct wl_shm *wl_shm, uint32_t format){}

struct wl_shm_listener shm_listener = {
shm_format
};



static void wl_surface_enter (void *data, struct wl_surface *wl_surface, struct wl_output *output){;}

static void wl_surface_leave (void *data, struct wl_surface *wl_surface, struct wl_output *output){;}

static const struct wl_surface_listener wl_surface_listener = {
wl_surface_enter,
wl_surface_leave
};



static void xdg_surface_configure (void *data, struct zxdg_surface_v6 *zxdg_surface_v6, uint32_t serial)
{
zxdg_surface_v6_ack_configure(zxdg_surface_v6, serial);
}

static const struct zxdg_surface_v6_listener surface_listener = {
xdg_surface_configure
};


static void toplevel_configure (void *data, struct zxdg_toplevel_v6 *zxdg_toplevel_v6, int32_t width, int32_t height, struct wl_array *states)
{
/* int* state;
wl_array_for_each(state, states)
{
if(*state == ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED)
zxdg_surface_v6_set_window_geometry(xdg_surface, 0, 0, width, height);

if(*state == ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN)
zxdg_surface_v6_set_window_geometry(xdg_surface, 0, 0, width, height);
}*/
}

static void toplevel_close (void *data, struct zxdg_toplevel_v6 *zxdg_toplevel_v6){;}

static const struct zxdg_toplevel_v6_listener toplevel_listener = {
toplevel_configure,
toplevel_close
};




static void shell_ping(void *data, struct zxdg_shell_v6 *zxdg_shell_v6, uint32_t serial)
{
zxdg_shell_v6_pong(zxdg_shell_v6, serial);
}

static const struct zxdg_shell_v6_listener shell_listener = {
shell_ping
};



static void capab(void *data, struct wl_seat *seat, enum wl_seat_capability caps)
{
keyboard = wl_seat_get_keyboard(seat);
wl_keyboard_add_listener(keyboard, &keyboard_listener, data);
//pointer = wl_seat_get_pointer(seat);
//wl_pointer_add_listener(pointer, &pointer_listener, NULL);
}

static const struct wl_seat_listener seat_listener = {
capab
};



static void
global_registry_handler(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version)
{
    if (strcmp(interface, "wl_compositor") == 0)
{
        compositor = wl_registry_bind(registry, id, &wl_compositor_interface, version);
    }

else if (strcmp(interface, "wl_seat") == 0)
{
seat = wl_registry_bind(registry, id, &wl_seat_interface, 1);
wl_seat_add_listener(seat, &seat_listener, data);
}

else if (strcmp(interface, "zxdg_shell_v6") == 0)
{
xdg_shell = wl_registry_bind(registry, id, &zxdg_shell_v6_interface, version);
zxdg_shell_v6_add_listener(xdg_shell, &shell_listener, data);
}

else if (strcmp(interface, "wl_shm") == 0)
{
        shm = wl_registry_bind(registry, id, &wl_shm_interface, version);
        wl_shm_add_listener(shm, &shm_listener, NULL);
    }

}



static void global_registry_remover(void *data, struct wl_registry *registry, uint32_t id){}

static const struct wl_registry_listener registry_listener = {
    global_registry_handler,
    global_registry_remover
};



static void damage_buffer(int x, int y, int width, int height, uint32_t color)
{
    uint32_t *pixel = shm_data;

    for (int i=0; i<height; i++)
{
for (int j=0; j<width; j++)
{
*(pixel + (y+i)*WIDTH+x+j) = color;
    }
    }
}



int main(int argc, char **argv)
{
    struct wl_shm_pool *pool;
    int fd;

    display = wl_display_connect(NULL);

    struct wl_registry *registry = wl_display_get_registry(display);
    wl_registry_add_listener(registry, &registry_listener, NULL);

    wl_display_dispatch(display);
    wl_display_roundtrip(display);

    wl_surface = wl_compositor_create_surface(compositor);
wl_surface_add_listener(wl_surface, &wl_surface_listener, NULL);

xdg_surface = zxdg_shell_v6_get_xdg_surface(xdg_shell, wl_surface);
zxdg_surface_v6_add_listener(xdg_surface, &surface_listener, NULL);

xdg_toplevel = zxdg_surface_v6_get_toplevel(xdg_surface);
zxdg_toplevel_v6_add_listener(xdg_toplevel, &toplevel_listener, NULL);

/* zxdg_toplevel_v6_set_min_size(xdg_toplevel, WIDTH, HEIGHT);
zxdg_toplevel_v6_set_maximized(xdg_toplevel);
*/
wl_surface_commit(wl_surface);

wl_display_dispatch(display);
   
    fd = syscall(319, "buffer", 1);
    ftruncate(fd, 4*WIDTH*HEIGHT);
    shm_data = mmap(NULL, 4*WIDTH*HEIGHT, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
    pool     = wl_shm_create_pool(shm, fd, 4*WIDTH*HEIGHT);
    buffer   = wl_shm_pool_create_buffer(pool, 0, WIDTH, HEIGHT, 4*WIDTH, WL_SHM_FORMAT_XRGB8888);

    wl_buffer_add_listener(buffer, &buffer_listener, NULL);
    wl_shm_pool_destroy(pool);


cairo_surface = cairo_image_surface_create_for_data(shm_data, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, WIDTH));
cairo_ctx = cairo_create(cairo_surface);
backround_color = cairo_pattern_create_rgb (0.0, 0.7, 0.3);
text_color = cairo_pattern_create_rgb (1.0, 0.0, 0.3);
// printf("toy: %d\n", cairo_font_face_get_type(cairo_get_font_face(cairo_ctx)) == CAIRO_FONT_TYPE_TOY);
cairo_set_source (cairo_ctx, backround_color);
// cairo_set_source_rgb (cairo_ctx, 0.0, 0.7, 0.3);
cairo_paint (cairo_ctx);
cairo_set_font_size(cairo_ctx, font_size);
cairo_move_to(cairo_ctx, 0.0, font_size);
cairo_set_source (cairo_ctx, text_color);
// cairo_set_source_rgb (cairo_ctx, 1.0, 0.0, 0.3);



wl_surface_attach(wl_surface, buffer, 0, 0);
wl_surface_commit(wl_surface);


running = 1;

    while ((wl_display_dispatch(display) != -1) && running) {
;
    }

cairo_surface_destroy(cairo_surface);
cairo_destroy(cairo_ctx);

zxdg_toplevel_v6_destroy(xdg_toplevel);
zxdg_surface_v6_destroy(xdg_surface);
zxdg_shell_v6_destroy(xdg_shell);


wl_surface_destroy(wl_surface);
wl_compositor_destroy(compositor);
wl_seat_destroy(seat);
    wl_display_disconnect(display);

    return 0;
}


ikinci kod shift+enter e basinca girilen komutu calistirir. Ancak komut parametresiz bir komut olmali "ls" gibi mesela.