forked from enlightenment/enlightenment
Remove all old wayland compositor files.
Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
parent
bd7dc3783d
commit
047920a9f3
|
@ -1,191 +0,0 @@
|
|||
#include "e.h"
|
||||
#ifdef HAVE_WAYLAND_CLIENTS
|
||||
# include <xcb/xcb_image.h>
|
||||
# include "e_comp_wl.h"
|
||||
# include "e_comp_wl_comp.h"
|
||||
# include "e_comp_wl_output.h"
|
||||
# include "e_comp_wl_input.h"
|
||||
# include "e_comp_wl_shell.h"
|
||||
#endif
|
||||
|
||||
/* local function prototypes */
|
||||
static Eina_Bool _e_comp_wl_fd_handle(void *data, Ecore_Fd_Handler *hdl);
|
||||
|
||||
/* private variables */
|
||||
static Ecore_Fd_Handler *_wl_fd_handler = NULL;
|
||||
|
||||
/* extern variables */
|
||||
struct wl_display *_wl_disp;
|
||||
|
||||
Eina_Bool
|
||||
e_comp_wl_init(void)
|
||||
{
|
||||
struct wl_event_loop *loop;
|
||||
int fd = 0;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
/* init wayland display */
|
||||
if (!(_wl_disp = wl_display_create()))
|
||||
{
|
||||
EINA_LOG_ERR("Failed to create wayland display\n");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
if (wl_display_add_socket(_wl_disp, NULL))
|
||||
{
|
||||
wl_display_terminate(_wl_disp);
|
||||
EINA_LOG_ERR("Failed to add socket to wayland display\n");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
/* init a wayland compositor ?? */
|
||||
if (!e_comp_wl_comp_init())
|
||||
{
|
||||
wl_display_terminate(_wl_disp);
|
||||
EINA_LOG_ERR("Failed to create wayland compositor\n");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
/* init output */
|
||||
if (!e_comp_wl_output_init())
|
||||
{
|
||||
e_comp_wl_comp_shutdown();
|
||||
wl_display_terminate(_wl_disp);
|
||||
EINA_LOG_ERR("Failed to create wayland output\n");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
/* init input */
|
||||
if (!e_comp_wl_input_init())
|
||||
{
|
||||
e_comp_wl_output_shutdown();
|
||||
e_comp_wl_comp_shutdown();
|
||||
wl_display_terminate(_wl_disp);
|
||||
EINA_LOG_ERR("Failed to create wayland input\n");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
/* init a wayland shell */
|
||||
if (!e_comp_wl_shell_init())
|
||||
{
|
||||
e_comp_wl_input_shutdown();
|
||||
e_comp_wl_output_shutdown();
|
||||
e_comp_wl_comp_shutdown();
|
||||
wl_display_terminate(_wl_disp);
|
||||
EINA_LOG_ERR("Failed to create wayland shell\n");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
loop = wl_display_get_event_loop(_wl_disp);
|
||||
fd = wl_event_loop_get_fd(loop);
|
||||
|
||||
_wl_fd_handler =
|
||||
ecore_main_fd_handler_add(fd, ECORE_FD_READ, // | ECORE_FD_WRITE,
|
||||
_e_comp_wl_fd_handle, NULL, NULL, NULL);
|
||||
|
||||
wl_event_loop_dispatch(loop, 0);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_shutdown(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (_wl_fd_handler)
|
||||
ecore_main_fd_handler_del(_wl_fd_handler);
|
||||
_wl_fd_handler = NULL;
|
||||
|
||||
e_comp_wl_shell_shutdown();
|
||||
e_comp_wl_input_shutdown();
|
||||
e_comp_wl_output_shutdown();
|
||||
e_comp_wl_comp_shutdown();
|
||||
|
||||
if (_wl_disp) wl_display_terminate(_wl_disp);
|
||||
_wl_disp = NULL;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
e_comp_wl_time_get(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
}
|
||||
|
||||
Ecore_X_Pixmap
|
||||
e_comp_wl_pixmap_get(Ecore_X_Window win)
|
||||
{
|
||||
/* Wayland_Compositor *comp; */
|
||||
/* Wayland_Surface *ws; */
|
||||
Ecore_X_Pixmap pmap = 0;
|
||||
|
||||
/* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
|
||||
|
||||
/* comp = e_comp_wl_comp_get(); */
|
||||
/* if (wl_list_empty(&comp->surfaces)) return 0; */
|
||||
|
||||
/* wl_list_for_each(ws, &comp->surfaces, link) */
|
||||
/* { */
|
||||
/* if (!ws->buffer) continue; */
|
||||
/* if (((ws->win) && (ws->win->border)) */
|
||||
/* && (ws->win->border->win == win)) */
|
||||
/* { */
|
||||
/* Ecore_X_Connection *conn; */
|
||||
/* xcb_gc_t gc; */
|
||||
/* uint8_t *pix = 0; */
|
||||
/* int depth; */
|
||||
|
||||
/* if (ws->buffer) */
|
||||
/* { */
|
||||
/* if (wl_buffer_is_shm(ws->buffer)) */
|
||||
/* pix = (uint8_t *)wl_shm_buffer_get_data(ws->buffer); */
|
||||
/* else */
|
||||
/* { */
|
||||
/* if (ws->texture) pix = (uint8_t *)ws->texture; */
|
||||
/* else if (ws->saved_texture) */
|
||||
/* pix = (uint8_t *)ws->saved_texture; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* else if (ws->image) */
|
||||
/* { */
|
||||
/* if (ws->texture) pix = (uint8_t *)ws->texture; */
|
||||
/* else if (ws->saved_texture) */
|
||||
/* pix = (uint8_t *)ws->saved_texture; */
|
||||
/* } */
|
||||
|
||||
/* if (!pix) return 0; */
|
||||
|
||||
/* depth = ecore_x_window_depth_get(win); */
|
||||
/* conn = ecore_x_connection_get(); */
|
||||
|
||||
/* pmap = xcb_generate_id(conn); */
|
||||
/* xcb_create_pixmap(conn, depth, pmap, win, ws->w, ws->h); */
|
||||
|
||||
/* gc = xcb_generate_id(conn); */
|
||||
/* xcb_put_image(conn, 2, pmap, gc, ws->w, ws->h, */
|
||||
/* 0, 0, 0, depth, */
|
||||
/* (ws->w * ws->h * sizeof(int)), pix); */
|
||||
/* xcb_free_gc(conn, gc); */
|
||||
/* xcb_free_pixmap(conn, pmap); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
return pmap;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static Eina_Bool
|
||||
_e_comp_wl_fd_handle(void *data __UNUSED__, Ecore_Fd_Handler *hdl)
|
||||
{
|
||||
struct wl_event_loop *loop;
|
||||
|
||||
loop = wl_display_get_event_loop(_wl_disp);
|
||||
wl_event_loop_dispatch(loop, 0);
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
|
@ -1,196 +0,0 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
# ifndef E_COMP_WL_H
|
||||
# define E_COMP_WL_H
|
||||
|
||||
# include <pixman.h>
|
||||
# include <GLES2/gl2.h>
|
||||
# include <GLES2/gl2ext.h>
|
||||
# include <EGL/egl.h>
|
||||
# include <EGL/eglext.h>
|
||||
# include <wayland-server.h>
|
||||
|
||||
//# define LOGFNS 1
|
||||
|
||||
# ifdef LOGFNS
|
||||
# include <stdio.h>
|
||||
# define LOGFN(fl, ln, fn) printf("-E-COMP-WL: %25s: %5i - %s\n", fl, ln, fn);
|
||||
# else
|
||||
# define LOGFN(fl, ln, fn)
|
||||
# endif
|
||||
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
typedef enum _Wayland_Visual Wayland_Visual;
|
||||
typedef enum _Wayland_Shell_Surface_Type Wayland_Shell_Surface_Type;
|
||||
typedef struct _Wayland_Frame_Callback Wayland_Frame_Callback;
|
||||
typedef struct _Wayland_Surface Wayland_Surface;
|
||||
typedef struct _Wayland_Shell Wayland_Shell;
|
||||
typedef struct _Wayland_Shell_Surface Wayland_Shell_Surface;
|
||||
typedef struct _Wayland_Compositor Wayland_Compositor;
|
||||
typedef struct _Wayland_Mode Wayland_Mode;
|
||||
typedef struct _Wayland_Output Wayland_Output;
|
||||
typedef struct _Wayland_Input Wayland_Input;
|
||||
typedef struct _Wayland_Region Wayland_Region;
|
||||
|
||||
enum _Wayland_Visual
|
||||
{
|
||||
WAYLAND_NONE_VISUAL,
|
||||
WAYLAND_ARGB_VISUAL,
|
||||
WAYLAND_RGB_VISUAL
|
||||
};
|
||||
|
||||
enum _Wayland_Shell_Surface_Type
|
||||
{
|
||||
SHELL_SURFACE_NONE,
|
||||
SHELL_SURFACE_PANEL,
|
||||
SHELL_SURFACE_BACKGROUND,
|
||||
SHELL_SURFACE_LOCK,
|
||||
SHELL_SURFACE_SCREENSAVER,
|
||||
SHELL_SURFACE_TOPLEVEL,
|
||||
SHELL_SURFACE_TRANSIENT,
|
||||
SHELL_SURFACE_FULLSCREEN,
|
||||
SHELL_SURFACE_POPUP
|
||||
};
|
||||
|
||||
struct _Wayland_Frame_Callback
|
||||
{
|
||||
struct wl_resource resource;
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
struct _Wayland_Surface
|
||||
{
|
||||
struct wl_surface surface;
|
||||
struct wl_buffer *buffer;
|
||||
struct wl_list link;
|
||||
struct wl_list buffer_link;
|
||||
struct wl_listener buffer_destroy_listener;
|
||||
struct wl_list frame_callbacks;
|
||||
|
||||
pixman_region32_t damage, opaque, clip, input;
|
||||
GLuint texture, saved_texture;
|
||||
|
||||
int32_t x, y, w, h;
|
||||
uint32_t visual, pitch;
|
||||
|
||||
EGLImageKHR image;
|
||||
|
||||
E_Win *win;
|
||||
Ecore_X_Window input_win;
|
||||
};
|
||||
|
||||
struct _Wayland_Shell
|
||||
{
|
||||
void (*lock) (Wayland_Shell *shell);
|
||||
void (*unlock) (Wayland_Shell *shell);
|
||||
void (*map) (Wayland_Shell *shell, Wayland_Surface *surface, int32_t width, int32_t height);
|
||||
void (*configure) (Wayland_Shell *shell, Wayland_Surface *surface, int32_t x, int32_t y, int32_t width, int32_t height);
|
||||
void (*destroy) (Wayland_Shell *shell);
|
||||
};
|
||||
|
||||
struct _Wayland_Shell_Surface
|
||||
{
|
||||
struct wl_resource resource;
|
||||
Wayland_Surface *surface;
|
||||
struct wl_listener surface_destroy_listener;
|
||||
Wayland_Shell_Surface *parent;
|
||||
struct wl_list link;
|
||||
int32_t saved_x, saved_y;
|
||||
Wayland_Shell_Surface_Type type;
|
||||
|
||||
char *title, *clas;
|
||||
|
||||
struct
|
||||
{
|
||||
struct wl_pointer_grab grab;
|
||||
uint32_t timestamp;
|
||||
int32_t x, y;
|
||||
} popup;
|
||||
};
|
||||
|
||||
struct _Wayland_Compositor
|
||||
{
|
||||
struct wl_list surfaces;
|
||||
|
||||
struct
|
||||
{
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLConfig config;
|
||||
} egl;
|
||||
|
||||
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC
|
||||
image_target_renderbuffer_storage;
|
||||
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
|
||||
PFNEGLCREATEIMAGEKHRPROC create_image;
|
||||
PFNEGLDESTROYIMAGEKHRPROC destroy_image;
|
||||
PFNEGLBINDWAYLANDDISPLAYWL bind_display;
|
||||
PFNEGLUNBINDWAYLANDDISPLAYWL unbind_display;
|
||||
Eina_Bool has_bind : 1;
|
||||
|
||||
void (*destroy) (void);
|
||||
};
|
||||
|
||||
struct _Wayland_Mode
|
||||
{
|
||||
uint32_t flags, refresh;
|
||||
int32_t w, h;
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
struct _Wayland_Output
|
||||
{
|
||||
int32_t x, y, w, h;
|
||||
char *make, *model;
|
||||
uint32_t subpixel, flags;
|
||||
|
||||
Wayland_Mode mode;
|
||||
|
||||
struct wl_list link;
|
||||
struct wl_list frame_callbacks;
|
||||
};
|
||||
|
||||
struct _Wayland_Input
|
||||
{
|
||||
struct wl_seat seat;
|
||||
int32_t hotspot_x, hotspot_y;
|
||||
struct wl_list link;
|
||||
uint32_t modifier_state;
|
||||
};
|
||||
|
||||
struct _Wayland_Region
|
||||
{
|
||||
struct wl_resource resource;
|
||||
pixman_region32_t region;
|
||||
};
|
||||
|
||||
struct wl_shell
|
||||
{
|
||||
Wayland_Shell shell;
|
||||
|
||||
Eina_Bool locked : 1;
|
||||
Eina_Bool prepare_event_sent : 1;
|
||||
|
||||
// Wayland_Shell_Surface *lock_surface;
|
||||
struct wl_listener lock_surface_listener;
|
||||
struct wl_list hidden_surfaces;
|
||||
|
||||
struct
|
||||
{
|
||||
struct wl_resource *desktop_shell;
|
||||
struct wl_client *client;
|
||||
} child;
|
||||
};
|
||||
|
||||
Eina_Bool e_comp_wl_init(void);
|
||||
void e_comp_wl_shutdown(void);
|
||||
uint32_t e_comp_wl_time_get(void);
|
||||
Ecore_X_Pixmap e_comp_wl_pixmap_get(Ecore_X_Window win);
|
||||
|
||||
extern struct wl_display *_wl_disp;
|
||||
|
||||
# endif
|
||||
#endif
|
|
@ -1,60 +0,0 @@
|
|||
#include "e.h"
|
||||
#include "e_comp.h"
|
||||
#ifdef HAVE_WAYLAND_CLIENTS
|
||||
# include "e_comp_wl.h"
|
||||
# include "e_comp_wl_buffer.h"
|
||||
# include "e_comp_wl_comp.h"
|
||||
#endif
|
||||
|
||||
void
|
||||
e_comp_wl_buffer_post_release(struct wl_buffer *buffer)
|
||||
{
|
||||
if (--buffer->busy_count > 0) return;
|
||||
if (buffer->resource.client)
|
||||
wl_resource_queue_event(&buffer->resource, WL_BUFFER_RELEASE);
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_buffer_attach(struct wl_buffer *buffer, struct wl_surface *surface)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ws = (Wayland_Surface *)surface;
|
||||
|
||||
if (!ws->texture)
|
||||
{
|
||||
glGenTextures(1, &ws->texture);
|
||||
glBindTexture(GL_TEXTURE_2D, ws->texture);
|
||||
glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
// ws->shader = &ws->texture_shader;
|
||||
}
|
||||
else
|
||||
glBindTexture(GL_TEXTURE_2D, ws->texture);
|
||||
|
||||
/* if (ws->saved_texture != 0) */
|
||||
/* ws->texture = ws->saved_texture; */
|
||||
|
||||
/* glBindTexture(GL_TEXTURE_2D, ws->texture); */
|
||||
|
||||
if (wl_buffer_is_shm(buffer))
|
||||
ws->pitch = wl_shm_buffer_get_stride(buffer) / 4;
|
||||
else
|
||||
{
|
||||
Wayland_Compositor *comp;
|
||||
|
||||
comp = e_comp_wl_comp_get();
|
||||
if (ws->image != EGL_NO_IMAGE_KHR)
|
||||
comp->destroy_image(comp->egl.display, ws->image);
|
||||
ws->image = comp->create_image(comp->egl.display, NULL,
|
||||
EGL_WAYLAND_BUFFER_WL, buffer, NULL);
|
||||
comp->image_target_texture_2d(GL_TEXTURE_2D, ws->image);
|
||||
ws->visual = WAYLAND_ARGB_VISUAL;
|
||||
ws->pitch = ws->w;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
# ifndef E_COMP_WL_BUFFER_H
|
||||
# define E_COMP_WL_BUFFER_H
|
||||
|
||||
void e_comp_wl_buffer_post_release(struct wl_buffer *buffer);
|
||||
void e_comp_wl_buffer_attach(struct wl_buffer *buffer, struct wl_surface *surface);
|
||||
|
||||
# endif
|
||||
#endif
|
|
@ -1,717 +0,0 @@
|
|||
#include "e.h"
|
||||
#ifdef HAVE_WAYLAND_CLIENTS
|
||||
# include "e_comp_wl.h"
|
||||
# include "e_comp_wl_comp.h"
|
||||
# include "e_comp_wl_input.h"
|
||||
# include "e_comp_wl_surface.h"
|
||||
# include "e_comp_wl_region.h"
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
# include <linux/input.h>
|
||||
#else
|
||||
# define BTN_LEFT 0x110
|
||||
# define BTN_RIGHT 0x111
|
||||
# define BTN_MIDDLE 0x112
|
||||
# define BTN_SIDE 0x113
|
||||
# define BTN_EXTRA 0x114
|
||||
# define BTN_FORWARD 0x115
|
||||
# define BTN_BACK 0x116
|
||||
#endif
|
||||
|
||||
#define MODIFIER_CTRL (1 << 8)
|
||||
#define MODIFIER_ALT (1 << 9)
|
||||
#define MODIFIER_SUPER (1 << 10)
|
||||
|
||||
/* local function prototypes */
|
||||
static Eina_Bool _e_comp_wl_comp_egl_init(void);
|
||||
static void _e_comp_wl_comp_egl_shutdown(void);
|
||||
static void _e_comp_wl_comp_destroy(void);
|
||||
static void _e_comp_wl_comp_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id);
|
||||
static void _e_comp_wl_comp_surface_create(struct wl_client *client, struct wl_resource *resource, uint32_t id);
|
||||
static void _e_comp_wl_comp_region_create(struct wl_client *client, struct wl_resource *resource, unsigned int id);
|
||||
static void _e_comp_wl_comp_region_destroy(struct wl_resource *resource);
|
||||
static Eina_Bool _e_comp_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event);
|
||||
static Eina_Bool _e_comp_wl_cb_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__);
|
||||
static Eina_Bool _e_comp_wl_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event);
|
||||
static Eina_Bool _e_comp_wl_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event);
|
||||
static Eina_Bool _e_comp_wl_cb_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event);
|
||||
static Eina_Bool _e_comp_wl_cb_mouse_down(void *data __UNUSED__, int type __UNUSED__, void *event);
|
||||
static Eina_Bool _e_comp_wl_cb_mouse_up(void *data __UNUSED__, int type __UNUSED__, void *event);
|
||||
static Eina_Bool _e_comp_wl_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event);
|
||||
static Eina_Bool _e_comp_wl_cb_key_up(void *data __UNUSED__, int type __UNUSED__, void *event);
|
||||
|
||||
static Wayland_Surface *_e_comp_wl_comp_pick_surface(int32_t x __UNUSED__, int32_t y __UNUSED__, int32_t *sx, int32_t *sy);
|
||||
static void _e_comp_wl_comp_update_modifier(Wayland_Input *input, uint32_t key, uint32_t state);
|
||||
|
||||
/* wayland interfaces */
|
||||
static const struct wl_compositor_interface _wl_comp_interface =
|
||||
{
|
||||
_e_comp_wl_comp_surface_create,
|
||||
_e_comp_wl_comp_region_create
|
||||
};
|
||||
static const struct wl_surface_interface _wl_surface_interface =
|
||||
{
|
||||
e_comp_wl_surface_destroy,
|
||||
e_comp_wl_surface_attach,
|
||||
e_comp_wl_surface_damage,
|
||||
e_comp_wl_surface_frame,
|
||||
e_comp_wl_surface_set_opaque_region,
|
||||
e_comp_wl_surface_set_input_region,
|
||||
e_comp_wl_surface_commit
|
||||
};
|
||||
static const struct wl_region_interface _wl_region_interface =
|
||||
{
|
||||
e_comp_wl_region_destroy,
|
||||
e_comp_wl_region_add,
|
||||
e_comp_wl_region_subtract
|
||||
};
|
||||
|
||||
/* private variables */
|
||||
static Wayland_Compositor *_wl_comp;
|
||||
static Eina_List *_wl_event_handlers = NULL;
|
||||
|
||||
Eina_Bool
|
||||
e_comp_wl_comp_init(void)
|
||||
{
|
||||
const char *extensions;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!(_wl_comp = malloc(sizeof(Wayland_Compositor))))
|
||||
{
|
||||
EINA_LOG_ERR("Could not allocate space for compositor\n");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
memset(_wl_comp, 0, sizeof(*_wl_comp));
|
||||
|
||||
if (!_e_comp_wl_comp_egl_init())
|
||||
{
|
||||
EINA_LOG_ERR("Could not initialize egl\n");
|
||||
free(_wl_comp);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
_wl_comp->destroy = _e_comp_wl_comp_destroy;
|
||||
|
||||
if (!wl_display_add_global(_wl_disp, &wl_compositor_interface, _wl_comp,
|
||||
_e_comp_wl_comp_bind))
|
||||
{
|
||||
EINA_LOG_ERR("Failed to add compositor to wayland\n");
|
||||
free(_wl_comp);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
_wl_comp->image_target_texture_2d =
|
||||
(void *)eglGetProcAddress("glEGLImageTargetTexture2DOES");
|
||||
_wl_comp->image_target_renderbuffer_storage = (void *)
|
||||
eglGetProcAddress("glEGLImageTargetRenderbufferStorageOES");
|
||||
_wl_comp->create_image = (void *)eglGetProcAddress("eglCreateImageKHR");
|
||||
_wl_comp->destroy_image = (void *)eglGetProcAddress("eglDestroyImageKHR");
|
||||
|
||||
_wl_comp->bind_display =
|
||||
(void *)eglGetProcAddress("eglBindWaylandDisplayWL");
|
||||
_wl_comp->unbind_display =
|
||||
(void *)eglGetProcAddress("eglUnbindWaylandDisplayWL");
|
||||
|
||||
extensions = (const char *)glGetString(GL_EXTENSIONS);
|
||||
if (!strstr(extensions, "GL_EXT_texture_format_BGRA8888"))
|
||||
{
|
||||
EINA_LOG_ERR("GL_EXT_texture_format_BGRA8888 not available\n");
|
||||
free(_wl_comp);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
extensions =
|
||||
(const char *)eglQueryString(_wl_comp->egl.display, EGL_EXTENSIONS);
|
||||
if (strstr(extensions, "EGL_WL_bind_wayland_display"))
|
||||
_wl_comp->has_bind = EINA_TRUE;
|
||||
if (_wl_comp->has_bind)
|
||||
_wl_comp->bind_display(_wl_comp->egl.display, _wl_disp);
|
||||
|
||||
wl_data_device_manager_init(_wl_disp);
|
||||
|
||||
wl_list_init(&_wl_comp->surfaces);
|
||||
|
||||
_wl_event_handlers =
|
||||
eina_list_append(_wl_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN,
|
||||
_e_comp_wl_cb_focus_in, NULL));
|
||||
_wl_event_handlers =
|
||||
eina_list_append(_wl_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT,
|
||||
_e_comp_wl_cb_focus_out, NULL));
|
||||
_wl_event_handlers =
|
||||
eina_list_append(_wl_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_MOUSE_IN,
|
||||
_e_comp_wl_cb_mouse_in, NULL));
|
||||
_wl_event_handlers =
|
||||
eina_list_append(_wl_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_MOUSE_OUT,
|
||||
_e_comp_wl_cb_mouse_out, NULL));
|
||||
_wl_event_handlers =
|
||||
eina_list_append(_wl_event_handlers,
|
||||
ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE,
|
||||
_e_comp_wl_cb_mouse_move, NULL));
|
||||
_wl_event_handlers =
|
||||
eina_list_append(_wl_event_handlers,
|
||||
ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
|
||||
_e_comp_wl_cb_mouse_down, NULL));
|
||||
_wl_event_handlers =
|
||||
eina_list_append(_wl_event_handlers,
|
||||
ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP,
|
||||
_e_comp_wl_cb_mouse_up, NULL));
|
||||
_wl_event_handlers =
|
||||
eina_list_append(_wl_event_handlers,
|
||||
ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
|
||||
_e_comp_wl_cb_key_down, NULL));
|
||||
_wl_event_handlers =
|
||||
eina_list_append(_wl_event_handlers,
|
||||
ecore_event_handler_add(ECORE_EVENT_KEY_UP,
|
||||
_e_comp_wl_cb_key_up, NULL));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_comp_shutdown(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
E_FREE_LIST(_wl_event_handlers, ecore_event_handler_del);
|
||||
|
||||
if (_wl_comp) _wl_comp->destroy();
|
||||
}
|
||||
|
||||
Wayland_Compositor *
|
||||
e_comp_wl_comp_get(void)
|
||||
{
|
||||
return _wl_comp;
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_comp_repick(struct wl_seat *seat, uint32_t timestamp __UNUSED__)
|
||||
{
|
||||
Wayland_Surface *ws, *focus;
|
||||
struct wl_pointer *pointer;
|
||||
|
||||
if (!(pointer = seat->pointer)) return;
|
||||
|
||||
ws =
|
||||
_e_comp_wl_comp_pick_surface(pointer->x, pointer->y,
|
||||
&pointer->current_x, &pointer->current_y);
|
||||
if (!ws) return;
|
||||
if (&ws->surface != pointer->current)
|
||||
{
|
||||
const struct wl_pointer_grab_interface *interface;
|
||||
|
||||
interface = pointer->grab->interface;
|
||||
pointer->current = &ws->surface;
|
||||
interface->focus(pointer->grab, &ws->surface,
|
||||
pointer->current_x, pointer->current_y);
|
||||
}
|
||||
|
||||
if ((focus = (Wayland_Surface *)pointer->grab->focus))
|
||||
{
|
||||
pointer->grab->x = pointer->x - focus->x;
|
||||
pointer->grab->y = pointer->y - focus->y;
|
||||
}
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static Eina_Bool
|
||||
_e_comp_wl_comp_egl_init(void)
|
||||
{
|
||||
EGLint major, minor, n;
|
||||
EGLint config_attribs[] =
|
||||
{
|
||||
EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 1, EGL_DEPTH_SIZE, 0, EGL_STENCIL_SIZE, 0,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_SURFACE_TYPE,
|
||||
EGL_WINDOW_BIT, EGL_NONE
|
||||
};
|
||||
EGLint context_attribs[] =
|
||||
{
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE
|
||||
};
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!(_wl_comp->egl.display = eglGetDisplay(NULL)))
|
||||
{
|
||||
EINA_LOG_ERR("Failed to create EGL display\n");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
if (!eglInitialize(_wl_comp->egl.display, &major, &minor))
|
||||
{
|
||||
EINA_LOG_ERR("Failed to initialize EGL\n");
|
||||
eglTerminate(_wl_comp->egl.display);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
if (!eglBindAPI(EGL_OPENGL_ES_API))
|
||||
{
|
||||
EINA_LOG_ERR("Failed to bind EGL API\n");
|
||||
eglTerminate(_wl_comp->egl.display);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
if ((!eglChooseConfig(_wl_comp->egl.display, config_attribs,
|
||||
&_wl_comp->egl.config, 1, &n) || (n == 0)))
|
||||
{
|
||||
EINA_LOG_ERR("Failed to choose EGL config\n");
|
||||
eglTerminate(_wl_comp->egl.display);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
if (!(_wl_comp->egl.context =
|
||||
eglCreateContext(_wl_comp->egl.display, _wl_comp->egl.config,
|
||||
EGL_NO_CONTEXT, context_attribs)))
|
||||
{
|
||||
EINA_LOG_ERR("Failed to create EGL context\n");
|
||||
eglTerminate(_wl_comp->egl.display);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
if (!eglMakeCurrent(_wl_comp->egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
_wl_comp->egl.context))
|
||||
{
|
||||
EINA_LOG_ERR("Failed to make EGL context current\n");
|
||||
eglTerminate(_wl_comp->egl.display);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_comp_egl_shutdown(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
eglMakeCurrent(_wl_comp->egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
eglTerminate(_wl_comp->egl.display);
|
||||
eglReleaseThread();
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_comp_destroy(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (_wl_comp->has_bind)
|
||||
_wl_comp->unbind_display(_wl_comp->egl.display, _wl_disp);
|
||||
|
||||
_e_comp_wl_comp_egl_shutdown();
|
||||
|
||||
if (&_wl_comp->surfaces) wl_list_remove(&_wl_comp->surfaces);
|
||||
free(_wl_comp);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_comp_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wl_client_add_object(client, &wl_compositor_interface,
|
||||
&_wl_comp_interface, id, data);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_comp_surface_create(struct wl_client *client, struct wl_resource *resource, uint32_t id)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!(ws = e_comp_wl_surface_create(0, 0, 0, 0)))
|
||||
{
|
||||
wl_resource_post_no_memory(resource);
|
||||
return;
|
||||
}
|
||||
|
||||
ws->surface.resource.destroy = e_comp_wl_surface_destroy_surface;
|
||||
ws->surface.resource.object.id = id;
|
||||
ws->surface.resource.object.interface = &wl_surface_interface;
|
||||
ws->surface.resource.object.implementation =
|
||||
(void (* *)(void)) & _wl_surface_interface;
|
||||
ws->surface.resource.data = ws;
|
||||
|
||||
wl_client_add_resource(client, &ws->surface.resource);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_comp_region_create(struct wl_client *client, struct wl_resource *resource, unsigned int id)
|
||||
{
|
||||
Wayland_Region *region;
|
||||
|
||||
region = malloc(sizeof(*region));
|
||||
if (!region)
|
||||
{
|
||||
wl_resource_post_no_memory(resource);
|
||||
return;
|
||||
}
|
||||
|
||||
region->resource.destroy = _e_comp_wl_comp_region_destroy;
|
||||
region->resource.object.id = id;
|
||||
region->resource.object.interface = &wl_region_interface;
|
||||
region->resource.object.implementation =
|
||||
(void (* *)(void)) & _wl_region_interface;
|
||||
region->resource.data = region;
|
||||
|
||||
pixman_region32_init(®ion->region);
|
||||
wl_client_add_resource(client, ®ion->resource);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_comp_region_destroy(struct wl_resource *resource)
|
||||
{
|
||||
Wayland_Region *region;
|
||||
|
||||
region = container_of(resource, Wayland_Region, resource);
|
||||
pixman_region32_fini(®ion->region);
|
||||
free(region);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_comp_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||
{
|
||||
Wayland_Input *input;
|
||||
Wayland_Surface *ws;
|
||||
Ecore_X_Event_Window_Focus_In *ev;
|
||||
|
||||
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ev = event;
|
||||
if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON;
|
||||
|
||||
input = e_comp_wl_input_get();
|
||||
wl_list_for_each(ws, &_wl_comp->surfaces, link)
|
||||
{
|
||||
if (((ws->win) && (ws->win->border))
|
||||
&& (ws->win->border->win == ev->win))
|
||||
{
|
||||
wl_keyboard_set_focus(input->seat.keyboard, &ws->surface);
|
||||
wl_data_device_set_keyboard_focus(&input->seat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_comp_wl_cb_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
|
||||
{
|
||||
Wayland_Input *input;
|
||||
/* Ecore_X_Event_Window_Focus_Out *ev; */
|
||||
|
||||
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
/* ev = event; */
|
||||
input = e_comp_wl_input_get();
|
||||
if ((!input) || (!input->seat.keyboard))
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
wl_keyboard_set_focus(input->seat.keyboard, NULL);
|
||||
wl_data_device_set_keyboard_focus(&input->seat);
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_comp_wl_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||
{
|
||||
Wayland_Input *input;
|
||||
Ecore_X_Event_Mouse_In *ev;
|
||||
uint32_t timestamp;
|
||||
struct wl_pointer *ptr;
|
||||
|
||||
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ev = event;
|
||||
if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON;
|
||||
input = e_comp_wl_input_get();
|
||||
|
||||
ptr = input->seat.pointer;
|
||||
ptr->x = ev->x;
|
||||
ptr->y = ev->y;
|
||||
|
||||
timestamp = e_comp_wl_time_get();
|
||||
e_comp_wl_comp_repick(&input->seat, timestamp);
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_comp_wl_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||
{
|
||||
Wayland_Input *input;
|
||||
Ecore_X_Event_Mouse_Out *ev;
|
||||
uint32_t timestamp;
|
||||
|
||||
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ev = event;
|
||||
if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON;
|
||||
input = e_comp_wl_input_get();
|
||||
|
||||
timestamp = e_comp_wl_time_get();
|
||||
e_comp_wl_comp_repick(&input->seat, timestamp);
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_comp_wl_cb_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||
{
|
||||
Wayland_Input *input;
|
||||
Ecore_Event_Mouse_Move *ev;
|
||||
const struct wl_pointer_grab_interface *interface;
|
||||
uint32_t timestamp;
|
||||
struct wl_pointer *ptr;
|
||||
|
||||
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ev = event;
|
||||
if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON;
|
||||
|
||||
input = e_comp_wl_input_get();
|
||||
|
||||
ptr = input->seat.pointer;
|
||||
ptr->x = ev->x;
|
||||
ptr->y = ev->y;
|
||||
|
||||
timestamp = e_comp_wl_time_get();
|
||||
e_comp_wl_comp_repick(&input->seat, timestamp);
|
||||
|
||||
interface = ptr->grab->interface;
|
||||
interface->motion(ptr->grab, timestamp, ptr->grab->x, ptr->grab->y);
|
||||
|
||||
/* TODO: handle sprite */
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_comp_wl_cb_mouse_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||
{
|
||||
Wayland_Input *input;
|
||||
Ecore_Event_Mouse_Button *ev;
|
||||
struct wl_pointer *ptr;
|
||||
int btn = 0;
|
||||
uint32_t timestamp;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ev = event;
|
||||
if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON;
|
||||
|
||||
switch (ev->buttons)
|
||||
{
|
||||
case 1:
|
||||
btn = ev->buttons + BTN_LEFT - 1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
btn = BTN_MIDDLE;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
btn = BTN_RIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
input = e_comp_wl_input_get();
|
||||
ptr = input->seat.pointer;
|
||||
timestamp = e_comp_wl_time_get();
|
||||
if (ptr->button_count == 0)
|
||||
{
|
||||
ptr->grab_button = btn;
|
||||
ptr->grab_time = timestamp;
|
||||
ptr->grab_x = ptr->x;
|
||||
ptr->grab_y = ptr->y;
|
||||
}
|
||||
|
||||
ptr->button_count++;
|
||||
|
||||
/* TODO: Run binding ?? */
|
||||
|
||||
ptr->grab->interface->button(ptr->grab, timestamp, btn, 1);
|
||||
|
||||
if (ptr->button_count == 1)
|
||||
ptr->grab_serial = wl_display_get_serial(_wl_disp);
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_comp_wl_cb_mouse_up(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||
{
|
||||
Wayland_Input *input;
|
||||
Ecore_Event_Mouse_Button *ev;
|
||||
struct wl_pointer *ptr;
|
||||
int btn = 0;
|
||||
uint32_t timestamp;
|
||||
|
||||
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ev = event;
|
||||
if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON;
|
||||
|
||||
switch (ev->buttons)
|
||||
{
|
||||
case 1:
|
||||
btn = ev->buttons + BTN_LEFT - 1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
btn = BTN_MIDDLE;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
btn = BTN_RIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
input = e_comp_wl_input_get();
|
||||
ptr = input->seat.pointer;
|
||||
ptr->button_count--;
|
||||
|
||||
/* TODO: Run binding ?? */
|
||||
timestamp = e_comp_wl_time_get();
|
||||
ptr->grab->interface->button(ptr->grab, timestamp, btn, 0);
|
||||
|
||||
if (ptr->button_count == 1)
|
||||
ptr->grab_serial = wl_display_get_serial(_wl_disp);
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_comp_wl_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||
{
|
||||
/* Wayland_Input *input; */
|
||||
/* Ecore_Event_Key *ev; */
|
||||
/* struct wl_keyboard *kbd; */
|
||||
/* uint32_t *k, *end, key = 0; */
|
||||
/* uint32_t timestamp; */
|
||||
|
||||
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
/* ev = event; */
|
||||
/* if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON; */
|
||||
|
||||
/* input = e_comp_wl_input_get(); */
|
||||
/* kbd = input->seat.keyboard; */
|
||||
/* timestamp = e_comp_wl_time_get(); */
|
||||
|
||||
/* key = ecore_x_keysym_keycode_get(ev->key); */
|
||||
|
||||
/* input->modifier_state = 0; */
|
||||
/* _e_comp_wl_comp_update_modifier(input, key, 1); */
|
||||
|
||||
/* end = kbd->keys.data + kbd->keys.size; */
|
||||
/* for (k = kbd->keys.data; k < end; k++) */
|
||||
/* if (*k == key) *k = *--end; */
|
||||
/* kbd->keys.size = (void *)end - kbd->keys.data; */
|
||||
|
||||
/* k = wl_array_add(&kbd->keys, sizeof(*k)); */
|
||||
/* *k = key; */
|
||||
|
||||
/* if (kbd->keyboard_focus_resource) */
|
||||
/* wl_resource_post_event(device->keyboard_focus_resource, */
|
||||
/* WL_INPUT_DEVICE_KEY, timestamp, key, 1); */
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_comp_wl_cb_key_up(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||
{
|
||||
/* Wayland_Input *input; */
|
||||
/* Ecore_Event_Key *ev; */
|
||||
/* struct wl_input_device *device; */
|
||||
/* uint32_t *k, *end, key = 0; */
|
||||
/* uint32_t timestamp; */
|
||||
|
||||
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
/* ev = event; */
|
||||
/* if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON; */
|
||||
|
||||
/* input = e_comp_wl_input_get(); */
|
||||
/* device = &input->input_device; */
|
||||
/* timestamp = e_comp_wl_time_get(); */
|
||||
|
||||
/* key = ecore_x_keysym_keycode_get(ev->key); */
|
||||
|
||||
/* _e_comp_wl_comp_update_modifier(input, key, 0); */
|
||||
|
||||
/* end = device->keys.data + device->keys.size; */
|
||||
/* for (k = device->keys.data; k < end; k++) */
|
||||
/* if (*k == key) *k = *--end; */
|
||||
/* device->keys.size = (void *)end - device->keys.data; */
|
||||
|
||||
/* k = wl_array_add(&device->keys, sizeof(*k)); */
|
||||
/* *k = ev->key; */
|
||||
|
||||
/* if (device->keyboard_focus_resource) */
|
||||
/* wl_resource_post_event(device->keyboard_focus_resource, */
|
||||
/* WL_INPUT_DEVICE_KEY, timestamp, key, 0); */
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Wayland_Surface *
|
||||
_e_comp_wl_comp_pick_surface(int32_t x __UNUSED__, int32_t y __UNUSED__, int32_t *sx, int32_t *sy)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
|
||||
if (wl_list_empty(&_wl_comp->surfaces)) return NULL;
|
||||
wl_list_for_each(ws, &_wl_comp->surfaces, link)
|
||||
{
|
||||
if (ws->surface.resource.client == NULL) continue;
|
||||
if ((0 <= *sx) && (*sx < ws->w) &&
|
||||
(0 <= *sy) && (*sy < ws->h))
|
||||
return ws;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_comp_update_modifier(Wayland_Input *input, uint32_t key, uint32_t state)
|
||||
{
|
||||
uint32_t mod;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case KEY_LEFTCTRL:
|
||||
case KEY_RIGHTCTRL:
|
||||
mod = MODIFIER_CTRL;
|
||||
break;
|
||||
|
||||
case KEY_LEFTALT:
|
||||
case KEY_RIGHTALT:
|
||||
mod = MODIFIER_ALT;
|
||||
break;
|
||||
|
||||
case KEY_LEFTMETA:
|
||||
case KEY_RIGHTMETA:
|
||||
mod = MODIFIER_SUPER;
|
||||
break;
|
||||
|
||||
default:
|
||||
mod = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (state)
|
||||
input->modifier_state |= mod;
|
||||
else
|
||||
input->modifier_state &= ~mod;
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
# ifndef E_COMP_WL_COMP_H
|
||||
# define E_COMP_WL_COMP_H
|
||||
|
||||
Eina_Bool e_comp_wl_comp_init(void);
|
||||
void e_comp_wl_comp_shutdown(void);
|
||||
Wayland_Compositor *e_comp_wl_comp_get(void);
|
||||
void e_comp_wl_comp_repick(struct wl_seat *seat, uint32_t timestamp);
|
||||
|
||||
# endif
|
||||
#endif
|
|
@ -1,234 +0,0 @@
|
|||
#include "e.h"
|
||||
#ifdef HAVE_WAYLAND_CLIENTS
|
||||
# include "e_comp_wl.h"
|
||||
# include "e_comp_wl_input.h"
|
||||
#endif
|
||||
|
||||
/* local function prototypes */
|
||||
static void _e_comp_wl_input_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id);
|
||||
static void _e_comp_wl_input_unbind(struct wl_resource *resource);
|
||||
static void _e_comp_wl_input_pointer_get(struct wl_client *client, struct wl_resource *resource, unsigned int id);
|
||||
static void _e_comp_wl_input_keyboard_get(struct wl_client *client, struct wl_resource *resource, unsigned int id);
|
||||
static void _e_comp_wl_input_touch_get(struct wl_client *client, struct wl_resource *resource, unsigned int id);
|
||||
static void _e_comp_wl_input_pointer_cursor_set(struct wl_client *client, struct wl_resource *resource, unsigned int serial, struct wl_resource *surface_resource, int x, int y);
|
||||
|
||||
/* wayland interfaces */
|
||||
static const struct wl_seat_interface _wl_seat_interface =
|
||||
{
|
||||
_e_comp_wl_input_pointer_get,
|
||||
_e_comp_wl_input_keyboard_get,
|
||||
_e_comp_wl_input_touch_get
|
||||
};
|
||||
|
||||
static const struct wl_pointer_interface _wl_pointer_interface =
|
||||
{
|
||||
_e_comp_wl_input_pointer_cursor_set
|
||||
};
|
||||
|
||||
/* private variables */
|
||||
static Wayland_Input *_wl_input;
|
||||
|
||||
Eina_Bool
|
||||
e_comp_wl_input_init(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!(_wl_input = malloc(sizeof(Wayland_Input))))
|
||||
{
|
||||
EINA_LOG_ERR("Could not allocate space for input\n");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
memset(_wl_input, 0, sizeof(*_wl_input));
|
||||
|
||||
wl_seat_init(&_wl_input->seat);
|
||||
if (!wl_display_add_global(_wl_disp, &wl_seat_interface, _wl_input,
|
||||
_e_comp_wl_input_bind))
|
||||
{
|
||||
EINA_LOG_ERR("Failed to add input to wayland\n");
|
||||
free(_wl_input);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
_wl_input->hotspot_x = 16;
|
||||
_wl_input->hotspot_y = 16;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_input_shutdown(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!_wl_input) return;
|
||||
wl_seat_release(&_wl_input->seat);
|
||||
free(_wl_input);
|
||||
}
|
||||
|
||||
Wayland_Input *
|
||||
e_comp_wl_input_get(void)
|
||||
{
|
||||
return _wl_input;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static void
|
||||
_e_comp_wl_input_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id)
|
||||
{
|
||||
Wayland_Input *input;
|
||||
struct wl_seat *device;
|
||||
struct wl_resource *resource;
|
||||
enum wl_seat_capability caps = 0;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
input = data;
|
||||
device = &input->seat;
|
||||
|
||||
resource =
|
||||
wl_client_add_object(client, &wl_seat_interface,
|
||||
&_wl_seat_interface, id, data);
|
||||
wl_list_insert(&device->base_resource_list, &resource->link);
|
||||
resource->destroy = _e_comp_wl_input_unbind;
|
||||
|
||||
if (device->pointer) caps |= WL_SEAT_CAPABILITY_POINTER;
|
||||
if (device->keyboard) caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
||||
if (device->touch) caps |= WL_SEAT_CAPABILITY_TOUCH;
|
||||
|
||||
wl_seat_send_capabilities(resource, caps);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_input_unbind(struct wl_resource *resource)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wl_list_remove(&resource->link);
|
||||
free(resource);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_input_pointer_get(struct wl_client *client, struct wl_resource *resource, unsigned int id)
|
||||
{
|
||||
Wayland_Input *wi;
|
||||
struct wl_resource *res;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!(wi = resource->data)) return;
|
||||
if (!wi->seat.pointer) return;
|
||||
|
||||
res = wl_client_add_object(client, &wl_pointer_interface,
|
||||
&_wl_pointer_interface, id, wi);
|
||||
wl_list_insert(&wi->seat.pointer->resource_list, &res->link);
|
||||
res->destroy = _e_comp_wl_input_unbind;
|
||||
|
||||
if ((wi->seat.pointer->focus) &&
|
||||
(wi->seat.pointer->focus->resource.client == client))
|
||||
{
|
||||
/* TODO: surface_from_global_fixed ?? */
|
||||
|
||||
wl_pointer_set_focus(wi->seat.pointer, wi->seat.pointer->focus,
|
||||
wi->seat.pointer->x,
|
||||
wi->seat.pointer->y);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_input_keyboard_get(struct wl_client *client, struct wl_resource *resource, unsigned int id)
|
||||
{
|
||||
Wayland_Input *wi;
|
||||
struct wl_resource *res;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!(wi = resource->data)) return;
|
||||
if (!wi->seat.keyboard) return;
|
||||
|
||||
res = wl_client_add_object(client, &wl_keyboard_interface, NULL, id, wi);
|
||||
wl_list_insert(&wi->seat.keyboard->resource_list, &res->link);
|
||||
res->destroy = _e_comp_wl_input_unbind;
|
||||
|
||||
/* TODO: wl_keyboard_send_keymap ?? */
|
||||
|
||||
if ((wi->seat.keyboard->focus) &&
|
||||
(wi->seat.keyboard->focus->resource.client == client))
|
||||
{
|
||||
wl_keyboard_set_focus(wi->seat.keyboard, wi->seat.keyboard->focus);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_input_touch_get(struct wl_client *client, struct wl_resource *resource, unsigned int id)
|
||||
{
|
||||
Wayland_Input *wi;
|
||||
struct wl_resource *res;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!(wi = resource->data)) return;
|
||||
if (!wi->seat.touch) return;
|
||||
|
||||
res = wl_client_add_object(client, &wl_touch_interface, NULL, id, wi);
|
||||
wl_list_insert(&wi->seat.touch->resource_list, &res->link);
|
||||
res->destroy = _e_comp_wl_input_unbind;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_input_pointer_cursor_set(struct wl_client *client, struct wl_resource *resource, unsigned int serial, struct wl_resource *surface_resource, int x, int y)
|
||||
{
|
||||
/* Wayland_Input *wi; */
|
||||
/* Wayland_Surface *ws; */
|
||||
|
||||
/* if (!(wi = resource->data)) return; */
|
||||
/* if (!wi->seat.pointer->focus) return; */
|
||||
/* if (wi->seat.pointer->focus->resource.client != client) return; */
|
||||
|
||||
/* if (surface_resource) ws = surface_resource->data; */
|
||||
|
||||
/* if ((ws) && (ws != wi->sprite)) */
|
||||
/* { */
|
||||
/* if (ws->configure) */
|
||||
/* { */
|
||||
/* wl_resource_post_error(&ws->surface.resource, */
|
||||
/* WL_DISPLAY_ERROR_INVALID_OBJECT, */
|
||||
/* "Surface configure already set"); */
|
||||
/* return; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* TODO: Unmap sprite ? */
|
||||
|
||||
/* if (!ws) return; */
|
||||
|
||||
/* wl_signal_add(&ws->surface.resource.destroy_signal, */
|
||||
/* &wi->sprite_destroy_listener); */
|
||||
|
||||
/* ws->configure = ; */
|
||||
/* ws->private = seat; */
|
||||
/* wi->sprite = ws; */
|
||||
/* wi->hotspot_x = x; */
|
||||
/* wi->hotspot_y = y; */
|
||||
|
||||
/* if (ws->buffer) */
|
||||
/* { */
|
||||
/* TODO: cursor surface configure */
|
||||
/* } */
|
||||
}
|
||||
|
||||
/* static void */
|
||||
/* _e_comp_wl_input_attach(struct wl_client *client, struct wl_resource *resource, uint32_t serial, struct wl_resource *buffer_resource __UNUSED__, int32_t x, int32_t y) */
|
||||
/* { */
|
||||
/* Wayland_Input *wi; */
|
||||
|
||||
/* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
|
||||
|
||||
/* wi = resource->data; */
|
||||
/* if (serial < wi->input_device.pointer_focus_serial) return; */
|
||||
/* if (!wi->input_device.pointer_focus) return; */
|
||||
/* if (wi->input_device.pointer_focus->resource.client != client) return; */
|
||||
/* wi->hotspot_x = x; */
|
||||
/* wi->hotspot_y = y; */
|
||||
/* } */
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
# ifndef E_COMP_WL_INPUT_H
|
||||
# define E_COMP_WL_INPUT_H
|
||||
|
||||
Eina_Bool e_comp_wl_input_init(void);
|
||||
void e_comp_wl_input_shutdown(void);
|
||||
Wayland_Input *e_comp_wl_input_get(void);
|
||||
|
||||
# endif
|
||||
#endif
|
|
@ -1,101 +0,0 @@
|
|||
#include "e.h"
|
||||
#ifdef HAVE_WAYLAND_CLIENTS
|
||||
# include "e_comp_wl.h"
|
||||
# include "e_comp_wl_output.h"
|
||||
#endif
|
||||
|
||||
# define WL_OUTPUT_FLIPPED 0x01
|
||||
|
||||
/* local function prototypes */
|
||||
static void _e_comp_wl_output_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id);
|
||||
|
||||
/* private variables */
|
||||
static Wayland_Output *_wl_output;
|
||||
|
||||
Eina_Bool
|
||||
e_comp_wl_output_init(void)
|
||||
{
|
||||
Ecore_X_Window *roots;
|
||||
int num = 0, rw, rh;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
roots = ecore_x_window_root_list(&num);
|
||||
if ((!roots) || (num <= 0))
|
||||
{
|
||||
EINA_LOG_ERR("Could not get root window list\n");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
ecore_x_window_size_get(roots[0], &rw, &rh);
|
||||
free(roots);
|
||||
|
||||
if (!(_wl_output = malloc(sizeof(Wayland_Output))))
|
||||
{
|
||||
EINA_LOG_ERR("Could not allocate space for output\n");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
memset(_wl_output, 0, sizeof(*_wl_output));
|
||||
|
||||
_wl_output->mode.flags =
|
||||
(WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED);
|
||||
_wl_output->mode.w = rw;
|
||||
_wl_output->mode.h = rh;
|
||||
_wl_output->mode.refresh = 60;
|
||||
|
||||
_wl_output->x = 0;
|
||||
_wl_output->y = 0;
|
||||
_wl_output->w = rw;
|
||||
_wl_output->h = rh;
|
||||
_wl_output->flags = WL_OUTPUT_FLIPPED;
|
||||
|
||||
wl_list_init(&_wl_output->link);
|
||||
wl_list_init(&_wl_output->frame_callbacks);
|
||||
|
||||
if (!wl_display_add_global(_wl_disp, &wl_output_interface, _wl_output,
|
||||
_e_comp_wl_output_bind))
|
||||
{
|
||||
EINA_LOG_ERR("Failed to add output to wayland\n");
|
||||
free(_wl_output);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_output_shutdown(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!_wl_output) return;
|
||||
wl_list_remove(&_wl_output->frame_callbacks);
|
||||
wl_list_remove(&_wl_output->link);
|
||||
free(_wl_output);
|
||||
}
|
||||
|
||||
Wayland_Output *
|
||||
e_comp_wl_output_get(void)
|
||||
{
|
||||
return _wl_output;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static void
|
||||
_e_comp_wl_output_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id)
|
||||
{
|
||||
Wayland_Output *output;
|
||||
struct wl_resource *resource;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!(output = data)) return;
|
||||
resource =
|
||||
wl_client_add_object(client, &wl_output_interface, NULL, id, data);
|
||||
wl_resource_post_event(resource, WL_OUTPUT_GEOMETRY, output->x, output->y,
|
||||
output->w, output->h, output->subpixel,
|
||||
output->make, output->model);
|
||||
wl_resource_post_event(resource, WL_OUTPUT_MODE, output->mode.flags,
|
||||
output->mode.w, output->mode.h, output->mode.refresh);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
# ifndef E_COMP_WL_OUTPUT_H
|
||||
# define E_COMP_WL_OUTPUT_H
|
||||
|
||||
Eina_Bool e_comp_wl_output_init(void);
|
||||
void e_comp_wl_output_shutdown(void);
|
||||
Wayland_Output *e_comp_wl_output_get(void);
|
||||
|
||||
# endif
|
||||
#endif
|
|
@ -1,34 +0,0 @@
|
|||
#include "e.h"
|
||||
#ifdef HAVE_WAYLAND_CLIENTS
|
||||
# include "e_comp_wl.h"
|
||||
# include "e_comp_wl_comp.h"
|
||||
# include "e_comp_wl_region.h"
|
||||
#endif
|
||||
|
||||
void
|
||||
e_comp_wl_region_destroy(struct wl_client *client __UNUSED__, struct wl_resource *resource)
|
||||
{
|
||||
wl_resource_destroy(resource);
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_region_add(struct wl_client *client __UNUSED__, struct wl_resource *resource, int x, int y, int w, int h)
|
||||
{
|
||||
Wayland_Region *region;
|
||||
|
||||
region = resource->data;
|
||||
pixman_region32_union_rect(®ion->region, ®ion->region, x, y, w, h);
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_region_subtract(struct wl_client *client __UNUSED__, struct wl_resource *resource, int x, int y, int w, int h)
|
||||
{
|
||||
Wayland_Region *region;
|
||||
pixman_region32_t rect;
|
||||
|
||||
region = resource->data;
|
||||
pixman_region32_init_rect(&rect, x, y, w, h);
|
||||
pixman_region32_subtract(®ion->region, ®ion->region, &rect);
|
||||
pixman_region32_fini(&rect);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
# ifndef E_COMP_WL_REGION_H
|
||||
# define E_COMP_WL_REGION_H
|
||||
|
||||
void e_comp_wl_region_destroy(struct wl_client *client __UNUSED__, struct wl_resource *resource);
|
||||
void e_comp_wl_region_add(struct wl_client *client __UNUSED__, struct wl_resource *resource, int x, int y, int w, int h);
|
||||
void e_comp_wl_region_subtract(struct wl_client *client __UNUSED__, struct wl_resource *resource, int x, int y, int w, int h);
|
||||
|
||||
# endif
|
||||
#endif
|
|
@ -1,475 +0,0 @@
|
|||
#include "e.h"
|
||||
#ifdef HAVE_WAYLAND_CLIENTS
|
||||
# include "e_comp_wl.h"
|
||||
# include "e_comp_wl_comp.h"
|
||||
# include "e_comp_wl_output.h"
|
||||
# include "e_comp_wl_input.h"
|
||||
# include "e_comp_wl_shell.h"
|
||||
# include "e_comp_wl_surface.h"
|
||||
#endif
|
||||
|
||||
/* local function prototypes */
|
||||
static void _e_comp_wl_shell_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id);
|
||||
static void _e_comp_wl_shell_lock(Wayland_Shell *base);
|
||||
static void _e_comp_wl_shell_unlock(Wayland_Shell *base);
|
||||
static void _e_comp_wl_shell_map(Wayland_Shell *base, Wayland_Surface *surface, int32_t width, int32_t height);
|
||||
static void _e_comp_wl_shell_configure(Wayland_Shell *base, Wayland_Surface *surface, int32_t x, int32_t y, int32_t width, int32_t height);
|
||||
static void _e_comp_wl_shell_destroy(Wayland_Shell *base);
|
||||
static void _e_comp_wl_shell_activate(Wayland_Shell *base, Wayland_Surface *surface, uint32_t timestamp);
|
||||
|
||||
static void _e_comp_wl_shell_shell_surface_get(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource);
|
||||
static void _e_comp_wl_shell_surface_pong(struct wl_client *client __UNUSED__, struct wl_resource *resource, unsigned int serial);
|
||||
static void _e_comp_wl_shell_surface_move(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *input_resource, uint32_t timestamp);
|
||||
static void _e_comp_wl_shell_surface_resize(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *input_resource, uint32_t timestamp, uint32_t edges);
|
||||
static void _e_comp_wl_shell_surface_set_toplevel(struct wl_client *client __UNUSED__, struct wl_resource *resource);
|
||||
static void _e_comp_wl_shell_surface_set_transient(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *parent_resource, int32_t x, int32_t y, uint32_t flags __UNUSED__);
|
||||
static void _e_comp_wl_shell_surface_set_fullscreen(struct wl_client *client __UNUSED__, struct wl_resource *resource, uint32_t method __UNUSED__, uint32_t framerate __UNUSED__, struct wl_resource *output_resource __UNUSED__);
|
||||
static void _e_comp_wl_shell_surface_set_popup(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *input_resource __UNUSED__, uint32_t timestamp __UNUSED__, struct wl_resource *parent_resource, int32_t x, int32_t y, uint32_t flags __UNUSED__);
|
||||
static void _e_comp_wl_shell_surface_set_maximized(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output_resource __UNUSED__);
|
||||
static void _e_comp_wl_shell_surface_set_title(struct wl_client *client, struct wl_resource *resource, const char *title);
|
||||
static void _e_comp_wl_shell_surface_set_class(struct wl_client *client, struct wl_resource *resource, const char *clas);
|
||||
|
||||
static void _e_comp_wl_shell_surface_destroy_handle(struct wl_listener *listener, void *data __UNUSED__);
|
||||
static Wayland_Shell_Surface *_e_comp_wl_shell_get_shell_surface(Wayland_Surface *ws);
|
||||
static void _e_comp_wl_shell_surface_destroy(struct wl_resource *resource);
|
||||
|
||||
/* wayland interfaces */
|
||||
static const struct wl_shell_interface _wl_shell_interface =
|
||||
{
|
||||
_e_comp_wl_shell_shell_surface_get
|
||||
};
|
||||
static const struct wl_shell_surface_interface _wl_shell_surface_interface =
|
||||
{
|
||||
_e_comp_wl_shell_surface_pong,
|
||||
_e_comp_wl_shell_surface_move,
|
||||
_e_comp_wl_shell_surface_resize,
|
||||
_e_comp_wl_shell_surface_set_toplevel,
|
||||
_e_comp_wl_shell_surface_set_transient,
|
||||
_e_comp_wl_shell_surface_set_fullscreen,
|
||||
_e_comp_wl_shell_surface_set_popup,
|
||||
_e_comp_wl_shell_surface_set_maximized,
|
||||
_e_comp_wl_shell_surface_set_title,
|
||||
_e_comp_wl_shell_surface_set_class
|
||||
};
|
||||
|
||||
/* private variables */
|
||||
struct wl_shell *_wl_shell;
|
||||
|
||||
Eina_Bool
|
||||
e_comp_wl_shell_init(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!(_wl_shell = malloc(sizeof(*_wl_shell))))
|
||||
{
|
||||
EINA_LOG_ERR("Could not allocate space for shell\n");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
memset(_wl_shell, 0, sizeof(*_wl_shell));
|
||||
|
||||
_wl_shell->shell.lock = _e_comp_wl_shell_lock;
|
||||
_wl_shell->shell.unlock = _e_comp_wl_shell_unlock;
|
||||
_wl_shell->shell.map = _e_comp_wl_shell_map;
|
||||
_wl_shell->shell.configure = _e_comp_wl_shell_configure;
|
||||
_wl_shell->shell.destroy = _e_comp_wl_shell_destroy;
|
||||
|
||||
if (!wl_display_add_global(_wl_disp, &wl_shell_interface, _wl_shell,
|
||||
_e_comp_wl_shell_bind))
|
||||
{
|
||||
EINA_LOG_ERR("Could not create shell\n");
|
||||
free(_wl_shell);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_shell_shutdown(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (_wl_shell)
|
||||
_wl_shell->shell.destroy(&_wl_shell->shell);
|
||||
}
|
||||
|
||||
struct wl_shell *
|
||||
e_comp_wl_shell_get(void)
|
||||
{
|
||||
return _wl_shell;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static void
|
||||
_e_comp_wl_shell_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id)
|
||||
{
|
||||
struct wl_shell *shell;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
shell = data;
|
||||
wl_client_add_object(client, &wl_shell_interface, &_wl_shell_interface,
|
||||
id, shell);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_lock(Wayland_Shell *base)
|
||||
{
|
||||
struct wl_shell *shell;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
shell = container_of(base, struct wl_shell, shell);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_unlock(Wayland_Shell *base)
|
||||
{
|
||||
struct wl_shell *shell;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
shell = container_of(base, struct wl_shell, shell);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_map(Wayland_Shell *base, Wayland_Surface *surface, int32_t width, int32_t height)
|
||||
{
|
||||
Wayland_Compositor *comp;
|
||||
Wayland_Shell_Surface *wss;
|
||||
struct wl_shell *shell;
|
||||
struct wl_list *list;
|
||||
uint32_t type;
|
||||
Eina_Bool do_configure = EINA_FALSE;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
comp = e_comp_wl_comp_get();
|
||||
type = SHELL_SURFACE_NONE;
|
||||
shell = container_of(base, struct wl_shell, shell);
|
||||
|
||||
if ((wss = _e_comp_wl_shell_get_shell_surface(surface)))
|
||||
type = wss->type;
|
||||
|
||||
if (shell->locked)
|
||||
{
|
||||
list = &shell->hidden_surfaces;
|
||||
do_configure = EINA_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
list = &comp->surfaces;
|
||||
do_configure = EINA_TRUE;
|
||||
}
|
||||
|
||||
surface->w = width;
|
||||
surface->h = height;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SHELL_SURFACE_TOPLEVEL:
|
||||
surface->x = 10 + random() % 400;
|
||||
surface->y = 10 + random() % 400;
|
||||
break;
|
||||
|
||||
default:
|
||||
wl_list_insert(list, &surface->link);
|
||||
break;
|
||||
}
|
||||
|
||||
if (do_configure)
|
||||
e_comp_wl_surface_configure(surface, surface->x, surface->y,
|
||||
surface->w, surface->h);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SHELL_SURFACE_TOPLEVEL:
|
||||
case SHELL_SURFACE_TRANSIENT:
|
||||
case SHELL_SURFACE_FULLSCREEN:
|
||||
if (!shell->locked)
|
||||
_e_comp_wl_shell_activate(base, surface, e_comp_wl_time_get());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_configure(Wayland_Shell *base, Wayland_Surface *surface, int32_t x, int32_t y, int32_t width, int32_t height)
|
||||
{
|
||||
struct wl_shell *shell;
|
||||
Wayland_Shell_Surface *wss;
|
||||
Wayland_Shell_Surface_Type type;
|
||||
Eina_Bool do_configure = EINA_FALSE;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
type = SHELL_SURFACE_NONE;
|
||||
shell = container_of(base, struct wl_shell, shell);
|
||||
do_configure = !shell->locked;
|
||||
if ((wss = _e_comp_wl_shell_get_shell_surface(surface)))
|
||||
type = wss->type;
|
||||
|
||||
surface->w = width;
|
||||
surface->h = height;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SHELL_SURFACE_SCREENSAVER:
|
||||
do_configure = !do_configure;
|
||||
|
||||
case SHELL_SURFACE_FULLSCREEN:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (do_configure)
|
||||
e_comp_wl_surface_configure(surface, x, y, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_destroy(Wayland_Shell *base)
|
||||
{
|
||||
struct wl_shell *shell;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
shell = container_of(base, struct wl_shell, shell);
|
||||
if (shell->child.client) wl_client_destroy(shell->child.client);
|
||||
free(shell);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_activate(Wayland_Shell *base, Wayland_Surface *surface, uint32_t timestamp)
|
||||
{
|
||||
struct wl_shell *shell;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
shell = container_of(base, struct wl_shell, shell);
|
||||
e_comp_wl_surface_activate(surface, e_comp_wl_input_get(), timestamp);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_shell_surface_get(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
Wayland_Shell_Surface *wss;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ws = surface_resource->data;
|
||||
if (_e_comp_wl_shell_get_shell_surface(ws))
|
||||
{
|
||||
wl_resource_post_error(surface_resource,
|
||||
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||
"get_shell_surface already requested");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(wss = calloc(1, sizeof(*wss))))
|
||||
{
|
||||
wl_resource_post_no_memory(resource);
|
||||
return;
|
||||
}
|
||||
|
||||
wss->resource.destroy = _e_comp_wl_shell_surface_destroy;
|
||||
wss->resource.object.id = id;
|
||||
wss->resource.object.interface = &wl_shell_surface_interface;
|
||||
wss->resource.object.implementation =
|
||||
(void (* *)(void)) & _wl_shell_surface_interface;
|
||||
wss->resource.data = wss;
|
||||
|
||||
wss->surface = ws;
|
||||
wss->surface_destroy_listener.notify =
|
||||
_e_comp_wl_shell_surface_destroy_handle;
|
||||
wl_signal_add(&ws->surface.resource.destroy_signal,
|
||||
&wss->surface_destroy_listener);
|
||||
|
||||
wl_list_init(&wss->link);
|
||||
|
||||
wss->type = SHELL_SURFACE_NONE;
|
||||
wl_client_add_resource(client, &wss->resource);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_surface_pong(struct wl_client *client __UNUSED__, struct wl_resource *resource, unsigned int serial)
|
||||
{
|
||||
Wayland_Shell_Surface *wss;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wss = resource->data;
|
||||
/* TODO: handle ping timer */
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_surface_move(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *input_resource, uint32_t timestamp)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_surface_resize(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *input_resource, uint32_t timestamp, uint32_t edges)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_surface_set_toplevel(struct wl_client *client __UNUSED__, struct wl_resource *resource)
|
||||
{
|
||||
Wayland_Shell_Surface *wss;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wss = resource->data;
|
||||
|
||||
/* TODO: Surface type reset */
|
||||
|
||||
e_comp_wl_surface_damage_surface(wss->surface);
|
||||
wss->type = SHELL_SURFACE_TOPLEVEL;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_surface_set_transient(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *parent_resource, int32_t x, int32_t y, uint32_t flags __UNUSED__)
|
||||
{
|
||||
Wayland_Shell_Surface *wss, *pss;
|
||||
Wayland_Surface *ws, *pws;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wss = resource->data;
|
||||
pss = parent_resource->data;
|
||||
ws = wss->surface;
|
||||
pws = pss->surface;
|
||||
|
||||
/* TODO: Surface type reset */
|
||||
|
||||
ws->x = pws->x + x;
|
||||
ws->y = pws->y + y;
|
||||
|
||||
e_comp_wl_surface_damage_surface(ws);
|
||||
|
||||
wss->type = SHELL_SURFACE_TRANSIENT;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_surface_set_fullscreen(struct wl_client *client __UNUSED__, struct wl_resource *resource, uint32_t method __UNUSED__, uint32_t framerate __UNUSED__, struct wl_resource *output_resource __UNUSED__)
|
||||
{
|
||||
Wayland_Shell_Surface *wss;
|
||||
Wayland_Surface *ws;
|
||||
Wayland_Output *output;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wss = resource->data;
|
||||
ws = wss->surface;
|
||||
output = e_comp_wl_output_get();
|
||||
|
||||
wss->saved_x = ws->x;
|
||||
wss->saved_y = ws->y;
|
||||
ws->x = (output->w - ws->w) / 2;
|
||||
ws->y = (output->h - ws->h) / 2;
|
||||
e_comp_wl_surface_damage_surface(ws);
|
||||
wss->type = SHELL_SURFACE_FULLSCREEN;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_surface_set_popup(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *input_resource __UNUSED__, uint32_t timestamp __UNUSED__, struct wl_resource *parent_resource, int32_t x, int32_t y, uint32_t flags __UNUSED__)
|
||||
{
|
||||
Wayland_Shell_Surface *wss;
|
||||
Wayland_Surface *ws;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wss = resource->data;
|
||||
ws = wss->surface;
|
||||
e_comp_wl_surface_damage_surface(ws);
|
||||
wss->type = SHELL_SURFACE_POPUP;
|
||||
wss->parent = parent_resource->data;
|
||||
wss->popup.x = x;
|
||||
wss->popup.y = y;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_surface_set_maximized(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *output_resource __UNUSED__)
|
||||
{
|
||||
Wayland_Shell_Surface *wss;
|
||||
Wayland_Surface *ws;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wss = resource->data;
|
||||
ws = wss->surface;
|
||||
/* FIXME: Implement */
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_surface_set_title(struct wl_client *client, struct wl_resource *resource, const char *title)
|
||||
{
|
||||
Wayland_Shell_Surface *wss;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wss = resource->data;
|
||||
free(wss->title);
|
||||
wss->title = strdup(title);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_surface_set_class(struct wl_client *client, struct wl_resource *resource, const char *clas)
|
||||
{
|
||||
Wayland_Shell_Surface *wss;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wss = resource->data;
|
||||
free(wss->clas);
|
||||
wss->clas = strdup(clas);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_surface_destroy_handle(struct wl_listener *listener, void *data __UNUSED__)
|
||||
{
|
||||
Wayland_Shell_Surface *wss;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wss = container_of(listener, Wayland_Shell_Surface, surface_destroy_listener);
|
||||
wss->surface = NULL;
|
||||
wl_resource_destroy(&wss->resource);
|
||||
}
|
||||
|
||||
static Wayland_Shell_Surface *
|
||||
_e_comp_wl_shell_get_shell_surface(Wayland_Surface *ws)
|
||||
{
|
||||
struct wl_listener *listener;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
listener =
|
||||
wl_signal_get(&ws->surface.resource.destroy_signal,
|
||||
_e_comp_wl_shell_surface_destroy_handle);
|
||||
if (listener)
|
||||
return container_of(listener, Wayland_Shell_Surface,
|
||||
surface_destroy_listener);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_shell_surface_destroy(struct wl_resource *resource)
|
||||
{
|
||||
Wayland_Shell_Surface *wss;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wss = resource->data;
|
||||
|
||||
/* TODO: popup grab input */
|
||||
|
||||
if (wss->surface) wl_list_remove(&wss->surface_destroy_listener.link);
|
||||
wl_list_remove(&wss->link);
|
||||
free(wss);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
# ifndef E_COMP_WL_SHELL_H
|
||||
# define E_COMP_WL_SHELL_H
|
||||
|
||||
Eina_Bool e_comp_wl_shell_init(void);
|
||||
void e_comp_wl_shell_shutdown(void);
|
||||
struct wl_shell *e_comp_wl_shell_get(void);
|
||||
|
||||
# endif
|
||||
#endif
|
|
@ -1,374 +0,0 @@
|
|||
#include "e.h"
|
||||
#ifdef HAVE_WAYLAND_CLIENTS
|
||||
# include "e_comp_wl.h"
|
||||
# include "e_comp_wl_comp.h"
|
||||
# include "e_comp_wl_output.h"
|
||||
# include "e_comp_wl_input.h"
|
||||
# include "e_comp_wl_shell.h"
|
||||
# include "e_comp_wl_surface.h"
|
||||
# include "e_comp_wl_buffer.h"
|
||||
#endif
|
||||
|
||||
/* local function prototypes */
|
||||
static void _e_comp_wl_surface_buffer_destroy_handle(struct wl_listener *listener, void *data __UNUSED__);
|
||||
static void _e_comp_wl_surface_raise(Wayland_Surface *ws);
|
||||
static void _e_comp_wl_surface_damage_rectangle(Wayland_Surface *ws, int32_t x, int32_t y, int32_t width, int32_t height);
|
||||
static void _e_comp_wl_surface_frame_destroy_callback(struct wl_resource *resource);
|
||||
|
||||
Wayland_Surface *
|
||||
e_comp_wl_surface_create(int32_t x, int32_t y, int32_t w, int32_t h)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!(ws = calloc(1, sizeof(Wayland_Surface)))) return NULL;
|
||||
|
||||
wl_list_init(&ws->link);
|
||||
wl_list_init(&ws->buffer_link);
|
||||
|
||||
glGenTextures(1, &ws->texture);
|
||||
glBindTexture(GL_TEXTURE_2D, ws->texture);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
ws->surface.resource.client = NULL;
|
||||
|
||||
ws->x = x;
|
||||
ws->y = y;
|
||||
ws->w = w;
|
||||
ws->h = h;
|
||||
ws->buffer = NULL;
|
||||
|
||||
ws->win = e_win_new(e_container_current_get(e_manager_current_get()));
|
||||
e_win_borderless_set(ws->win, EINA_TRUE);
|
||||
e_win_move_resize(ws->win, x, y, w, h);
|
||||
|
||||
pixman_region32_init(&ws->damage);
|
||||
pixman_region32_init(&ws->opaque);
|
||||
|
||||
wl_list_init(&ws->frame_callbacks);
|
||||
|
||||
ws->buffer_destroy_listener.notify =
|
||||
_e_comp_wl_surface_buffer_destroy_handle;
|
||||
|
||||
/* ws->transform = NULL; */
|
||||
|
||||
return ws;
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_surface_destroy(struct wl_client *client __UNUSED__, struct wl_resource *resource)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
wl_resource_destroy(resource);
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_surface_attach(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *buffer_resource, int32_t x, int32_t y)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
struct wl_buffer *buffer;
|
||||
struct wl_shell *shell;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ws = resource->data;
|
||||
buffer = buffer_resource->data;
|
||||
shell = e_comp_wl_shell_get();
|
||||
|
||||
/* TODO: damage below ?? */
|
||||
|
||||
if (ws->buffer)
|
||||
{
|
||||
e_comp_wl_buffer_post_release(ws->buffer);
|
||||
wl_list_remove(&ws->buffer_destroy_listener.link);
|
||||
}
|
||||
|
||||
buffer->busy_count++;
|
||||
ws->buffer = buffer;
|
||||
wl_signal_add(&ws->buffer->resource.destroy_signal,
|
||||
&ws->buffer_destroy_listener);
|
||||
|
||||
if (!ws->visual)
|
||||
shell->shell.map(&shell->shell, ws, buffer->width, buffer->height);
|
||||
else if ((x != 0) || (y != 0) ||
|
||||
(ws->w != buffer->width) || (ws->h != buffer->height))
|
||||
shell->shell.configure(&shell->shell, ws, ws->x + x, ws->y + y,
|
||||
buffer->width, buffer->height);
|
||||
|
||||
e_comp_wl_buffer_attach(buffer, &ws->surface);
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_surface_damage(struct wl_client *client __UNUSED__, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ws = resource->data;
|
||||
_e_comp_wl_surface_damage_rectangle(ws, x, y, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_surface_frame(struct wl_client *client, struct wl_resource *resource, uint32_t callback)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
Wayland_Frame_Callback *cb;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ws = resource->data;
|
||||
if (!(cb = malloc(sizeof(*cb))))
|
||||
{
|
||||
wl_resource_post_no_memory(resource);
|
||||
return;
|
||||
}
|
||||
|
||||
cb->resource.object.interface = &wl_callback_interface;
|
||||
cb->resource.object.id = callback;
|
||||
cb->resource.destroy = _e_comp_wl_surface_frame_destroy_callback;
|
||||
cb->resource.client = client;
|
||||
cb->resource.data = cb;
|
||||
|
||||
wl_client_add_resource(client, &cb->resource);
|
||||
wl_list_insert(ws->frame_callbacks.prev, &cb->link);
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_surface_set_opaque_region(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *region_resource)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ws = resource->data;
|
||||
pixman_region32_fini(&ws->opaque);
|
||||
if (region_resource)
|
||||
{
|
||||
Wayland_Region *region;
|
||||
|
||||
region = region_resource->data;
|
||||
pixman_region32_init_rect(&ws->opaque, 0, 0, ws->w, ws->h);
|
||||
pixman_region32_intersect(&ws->opaque, &ws->opaque, ®ion->region);
|
||||
}
|
||||
else
|
||||
pixman_region32_init(&ws->opaque);
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_surface_set_input_region(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *region_resource)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
Wayland_Input *input;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ws = resource->data;
|
||||
if (region_resource)
|
||||
{
|
||||
Wayland_Region *region;
|
||||
|
||||
region = region_resource->data;
|
||||
pixman_region32_init_rect(&ws->input, 0, 0, ws->w, ws->h);
|
||||
pixman_region32_intersect(&ws->input, &ws->input, ®ion->region);
|
||||
}
|
||||
else
|
||||
pixman_region32_init_rect(&ws->input, 0, 0, ws->w, ws->h);
|
||||
|
||||
input = e_comp_wl_input_get();
|
||||
e_comp_wl_comp_repick(&input->seat, e_comp_wl_time_get());
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_surface_commit(struct wl_client *client, struct wl_resource *resource)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
pixman_region32_t opaque;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!(ws = resource->data)) return;
|
||||
|
||||
/* TODO: handle 'pending' ?? */
|
||||
|
||||
e_comp_wl_surface_configure(ws, ws->x, ws->y, ws->w, ws->h);
|
||||
e_comp_wl_surface_damage_surface(ws);
|
||||
|
||||
pixman_region32_init_rect(&opaque, 0, 0, ws->w, ws->h);
|
||||
pixman_region32_intersect(&opaque, &opaque, &ws->opaque);
|
||||
if (!pixman_region32_equal(&opaque, &ws->opaque))
|
||||
{
|
||||
pixman_region32_copy(&ws->opaque, &opaque);
|
||||
/* TODO: set dirty */
|
||||
}
|
||||
pixman_region32_fini(&opaque);
|
||||
|
||||
pixman_region32_fini(&ws->input);
|
||||
pixman_region32_init_rect(&ws->input, 0, 0, ws->w, ws->h);
|
||||
pixman_region32_intersect(&ws->input, &ws->input, &ws->input);
|
||||
|
||||
wl_list_init(&ws->frame_callbacks);
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_surface_destroy_surface(struct wl_resource *resource)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
Wayland_Input *input;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ws = container_of(resource, Wayland_Surface, surface.resource);
|
||||
|
||||
/* TODO: damage below */
|
||||
/* TODO: flush damage */
|
||||
|
||||
input = e_comp_wl_input_get();
|
||||
|
||||
if (ws->win)
|
||||
e_object_del(E_OBJECT(ws->win));
|
||||
|
||||
wl_list_remove(&ws->link);
|
||||
e_comp_wl_comp_repick(&input->seat, e_comp_wl_time_get());
|
||||
|
||||
if (ws->texture) glDeleteTextures(1, &ws->texture);
|
||||
|
||||
if (ws->buffer)
|
||||
wl_list_remove(&ws->buffer_destroy_listener.link);
|
||||
|
||||
if (ws->image != EGL_NO_IMAGE_KHR)
|
||||
{
|
||||
Wayland_Compositor *comp;
|
||||
|
||||
comp = e_comp_wl_comp_get();
|
||||
comp->destroy_image(comp->egl.display, ws->image);
|
||||
}
|
||||
|
||||
wl_list_remove(&ws->buffer_link);
|
||||
|
||||
pixman_region32_fini(&ws->damage);
|
||||
pixman_region32_fini(&ws->opaque);
|
||||
|
||||
free(ws);
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_surface_configure(Wayland_Surface *ws, int32_t x, int32_t y, int32_t width, int32_t height)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (!ws) return;
|
||||
|
||||
/* TODO: damage below ? */
|
||||
|
||||
ws->x = x;
|
||||
ws->y = y;
|
||||
ws->w = width;
|
||||
ws->h = height;
|
||||
|
||||
if (ws->win)
|
||||
e_win_move_resize(ws->win, ws->x, ws->y, ws->w, ws->h);
|
||||
|
||||
if (!wl_list_empty(&ws->frame_callbacks))
|
||||
{
|
||||
Wayland_Output *output;
|
||||
|
||||
output = e_comp_wl_output_get();
|
||||
wl_list_insert_list(output->frame_callbacks.prev,
|
||||
&ws->frame_callbacks);
|
||||
wl_list_init(&ws->frame_callbacks);
|
||||
}
|
||||
|
||||
e_comp_wl_surface_damage_surface(ws);
|
||||
|
||||
pixman_region32_fini(&ws->opaque);
|
||||
if (ws->visual == WAYLAND_RGB_VISUAL)
|
||||
pixman_region32_init_rect(&ws->opaque, ws->x, ws->y, ws->w, ws->h);
|
||||
else
|
||||
pixman_region32_init(&ws->opaque);
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_surface_activate(Wayland_Surface *ws, Wayland_Input *wi, uint32_t timestamp __UNUSED__)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (ws->win)
|
||||
{
|
||||
e_win_show(ws->win);
|
||||
ws->win->border->borderless = EINA_TRUE;
|
||||
}
|
||||
|
||||
_e_comp_wl_surface_raise(ws);
|
||||
|
||||
if (wi->seat.keyboard)
|
||||
{
|
||||
wl_keyboard_set_focus(wi->seat.keyboard, &ws->surface);
|
||||
wl_data_device_set_keyboard_focus(&wi->seat);
|
||||
}
|
||||
|
||||
/* TODO: emit activate signal ?? */
|
||||
}
|
||||
|
||||
void
|
||||
e_comp_wl_surface_damage_surface(Wayland_Surface *ws)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
_e_comp_wl_surface_damage_rectangle(ws, 0, 0, ws->w, ws->h);
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static void
|
||||
_e_comp_wl_surface_buffer_destroy_handle(struct wl_listener *listener, void *data __UNUSED__)
|
||||
{
|
||||
Wayland_Surface *ws;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
ws = container_of(listener, Wayland_Surface, buffer_destroy_listener);
|
||||
ws->buffer = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_surface_raise(Wayland_Surface *ws)
|
||||
{
|
||||
Wayland_Compositor *comp;
|
||||
Wayland_Input *input;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
comp = e_comp_wl_comp_get();
|
||||
input = e_comp_wl_input_get();
|
||||
|
||||
wl_list_remove(&ws->link);
|
||||
wl_list_insert(&comp->surfaces, &ws->link);
|
||||
e_comp_wl_comp_repick(&input->seat, e_comp_wl_time_get());
|
||||
e_comp_wl_surface_damage_surface(ws);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_surface_damage_rectangle(Wayland_Surface *ws, int32_t x, int32_t y, int32_t width, int32_t height)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
pixman_region32_union_rect(&ws->damage, &ws->damage,
|
||||
ws->x + x, ws->y + y, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_comp_wl_surface_frame_destroy_callback(struct wl_resource *resource)
|
||||
{
|
||||
Wayland_Frame_Callback *cb;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
cb = resource->data;
|
||||
wl_list_remove(&cb->link);
|
||||
free(cb);
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
# ifndef E_COMP_WL_SURFACE_H
|
||||
# define E_COMP_WL_SURFACE_H
|
||||
|
||||
Wayland_Surface *e_comp_wl_surface_create(int32_t x, int32_t y, int32_t w, int32_t h);
|
||||
void e_comp_wl_surface_destroy(struct wl_client *client __UNUSED__, struct wl_resource *resource);
|
||||
void e_comp_wl_surface_attach(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *buffer_resource, int32_t x, int32_t y);
|
||||
void e_comp_wl_surface_damage(struct wl_client *client __UNUSED__, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height);
|
||||
void e_comp_wl_surface_frame(struct wl_client *client, struct wl_resource *resource, uint32_t callback);
|
||||
void e_comp_wl_surface_set_opaque_region(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *region_resource);
|
||||
void e_comp_wl_surface_set_input_region(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *region_resource);
|
||||
void e_comp_wl_surface_commit(struct wl_client *client, struct wl_resource *resource);
|
||||
void e_comp_wl_surface_destroy_surface(struct wl_resource *resource);
|
||||
void e_comp_wl_surface_configure(Wayland_Surface *ws, int32_t x, int32_t y, int32_t width, int32_t height);
|
||||
void e_comp_wl_surface_activate(Wayland_Surface *ws, Wayland_Input *wi, uint32_t timestamp);
|
||||
void e_comp_wl_surface_damage_surface(Wayland_Surface *ws);
|
||||
|
||||
# endif
|
||||
#endif
|
Loading…
Reference in New Issue