2012-01-22 08:32:39 -08:00
|
|
|
#include "e.h"
|
|
|
|
#include "e_mod_main.h"
|
2012-01-31 08:36:07 -08:00
|
|
|
#ifdef HAVE_WAYLAND_CLIENTS
|
2012-01-22 08:32:39 -08:00
|
|
|
# include "e_mod_comp_wl.h"
|
|
|
|
# include "e_mod_comp_wl_output.h"
|
|
|
|
#endif
|
|
|
|
|
2012-01-23 04:22:16 -08:00
|
|
|
# define WL_OUTPUT_FLIPPED 0x01
|
|
|
|
|
2012-01-22 08:32:39 -08:00
|
|
|
/* local function prototypes */
|
|
|
|
static void _e_mod_comp_wl_output_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id);
|
|
|
|
|
|
|
|
/* private variables */
|
|
|
|
static Wayland_Output *_wl_output;
|
|
|
|
|
2012-06-28 00:03:44 -07:00
|
|
|
Eina_Bool
|
2012-01-22 08:32:39 -08:00
|
|
|
e_mod_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);
|
2012-01-26 10:21:54 -08:00
|
|
|
if ((!roots) || (num <= 0))
|
2012-01-22 08:32:39 -08:00
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Could not get root window list\n");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
ecore_x_window_size_get(roots[0], &rw, &rh);
|
2012-01-26 10:21:54 -08:00
|
|
|
free(roots);
|
2012-01-22 08:32:39 -08:00
|
|
|
|
|
|
|
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));
|
|
|
|
|
2012-06-28 00:03:44 -07:00
|
|
|
_wl_output->mode.flags =
|
2012-01-22 08:32:39 -08:00
|
|
|
(WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED);
|
2012-01-26 10:21:54 -08:00
|
|
|
_wl_output->mode.w = rw;
|
|
|
|
_wl_output->mode.h = rh;
|
2012-01-23 04:22:16 -08:00
|
|
|
_wl_output->mode.refresh = 60;
|
|
|
|
|
2012-01-22 08:32:39 -08:00
|
|
|
_wl_output->x = 0;
|
|
|
|
_wl_output->y = 0;
|
2012-01-26 10:21:54 -08:00
|
|
|
_wl_output->w = rw;
|
|
|
|
_wl_output->h = rh;
|
2012-01-23 04:22:16 -08:00
|
|
|
_wl_output->flags = WL_OUTPUT_FLIPPED;
|
2012-01-22 08:32:39 -08:00
|
|
|
|
|
|
|
wl_list_init(&_wl_output->link);
|
|
|
|
wl_list_init(&_wl_output->frame_callbacks);
|
|
|
|
|
2012-06-28 00:03:44 -07:00
|
|
|
if (!wl_display_add_global(_wl_disp, &wl_output_interface, _wl_output,
|
2012-01-22 08:32:39 -08:00
|
|
|
_e_mod_comp_wl_output_bind))
|
|
|
|
{
|
2012-01-26 10:21:54 -08:00
|
|
|
EINA_LOG_ERR("Failed to add output to wayland\n");
|
2012-01-22 08:32:39 -08:00
|
|
|
free(_wl_output);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2012-01-23 04:22:16 -08:00
|
|
|
|
2012-01-22 08:32:39 -08:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2012-06-28 00:03:44 -07:00
|
|
|
void
|
2012-01-22 08:32:39 -08:00
|
|
|
e_mod_comp_wl_output_shutdown(void)
|
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-01-26 10:21:54 -08:00
|
|
|
if (!_wl_output) return;
|
2012-01-22 08:32:39 -08:00
|
|
|
wl_list_remove(&_wl_output->frame_callbacks);
|
|
|
|
wl_list_remove(&_wl_output->link);
|
|
|
|
free(_wl_output);
|
|
|
|
}
|
|
|
|
|
|
|
|
Wayland_Output *
|
|
|
|
e_mod_comp_wl_output_get(void)
|
|
|
|
{
|
|
|
|
return _wl_output;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* local functions */
|
2012-06-28 00:03:44 -07:00
|
|
|
static void
|
2012-01-22 08:32:39 -08:00
|
|
|
_e_mod_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;
|
2012-06-28 00:03:44 -07:00
|
|
|
resource =
|
2012-01-23 04:22:16 -08:00
|
|
|
wl_client_add_object(client, &wl_output_interface, NULL, id, data);
|
2012-06-28 00:03:44 -07:00
|
|
|
wl_resource_post_event(resource, WL_OUTPUT_GEOMETRY, output->x, output->y,
|
|
|
|
output->w, output->h, output->subpixel,
|
2012-01-22 08:32:39 -08:00
|
|
|
output->make, output->model);
|
2012-06-28 00:03:44 -07:00
|
|
|
wl_resource_post_event(resource, WL_OUTPUT_MODE, output->mode.flags,
|
2012-01-26 10:21:54 -08:00
|
|
|
output->mode.w, output->mode.h, output->mode.refresh);
|
2012-01-22 08:32:39 -08:00
|
|
|
}
|
2012-06-28 00:03:44 -07:00
|
|
|
|