ecore-wl2: Add start of Ecore_Wl2_Output code for outputs

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2015-09-10 10:37:40 -04:00
parent dd5b7e0046
commit d722b41e1a
5 changed files with 125 additions and 0 deletions

View File

@ -11,6 +11,7 @@ lib_ecore_wl2_libecore_wl2_la_SOURCES = \
lib/ecore_wl2/xdg-shell-client-protocol.h \
lib/ecore_wl2/xdg-shell-protocol.c \
lib/ecore_wl2/ecore_wl2_window.c \
lib/ecore_wl2/ecore_wl2_output.c \
lib/ecore_wl2/ecore_wl2_display.c \
lib/ecore_wl2/ecore_wl2.c \
lib/ecore_wl2/ecore_wl2_private.h

View File

@ -33,6 +33,7 @@ typedef struct _Ecore_Wl2_Window Ecore_Wl2_Window;
# endif
typedef struct _Ecore_Wl2_Display Ecore_Wl2_Display;
typedef struct _Ecore_Wl2_Output Ecore_Wl2_Output;
typedef struct _Ecore_Wl2_Global
{

View File

@ -76,6 +76,8 @@ _cb_global_add(void *data, struct wl_registry *registry, unsigned int id, const
xdg_shell_use_unstable_version(ewd->wl.xdg_shell, XDG_VERSION);
/* TODO: Add listener */
}
else if (!strcmp(interface, "wl_output"))
_ecore_wl2_output_add(ewd, id);
/* allocate space for event structure */
ev = calloc(1, sizeof(Ecore_Wl2_Event_Global));
@ -203,6 +205,13 @@ static const struct wl_callback_listener _sync_listener =
static void
_ecore_wl2_display_cleanup(Ecore_Wl2_Display *ewd)
{
Ecore_Wl2_Output *output;
Eina_Inlist *tmp;
/* free each output */
EINA_INLIST_FOREACH_SAFE(ewd->outputs, tmp, output)
_ecore_wl2_output_del(output);
if (ewd->xkb_context) xkb_context_unref(ewd->xkb_context);
wl_registry_destroy(wl_display_get_registry(ewd->wl.display));

View File

@ -0,0 +1,97 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "ecore_wl2_private.h"
static void
_cb_geometry(void *data, struct wl_output *wl_output EINA_UNUSED, int x, int y, int w, int h, int subpixel EINA_UNUSED, const char *make, const char *model, int transform)
{
Ecore_Wl2_Output *output;
output = data;
if (!output) return;
output->mw = w;
output->mh = h;
output->geometry.x = x;
output->geometry.y = y;
output->transform = transform;
eina_stringshare_replace(&output->make, make);
eina_stringshare_replace(&output->model, model);
}
static void
_cb_mode(void *data, struct wl_output *wl_output EINA_UNUSED, unsigned int flags, int w, int h, int refresh EINA_UNUSED)
{
Ecore_Wl2_Output *output;
output = data;
if (!output) return;
if (flags & WL_OUTPUT_MODE_CURRENT)
{
output->geometry.w = w;
output->geometry.h = h;
}
}
static void
_cb_done(void *data EINA_UNUSED, struct wl_output *output EINA_UNUSED)
{
/* NB: Use this event to raise any "output (re)configured events" */
}
static void
_cb_scale(void *data EINA_UNUSED, struct wl_output *output EINA_UNUSED, int scale EINA_UNUSED)
{
}
static const struct wl_output_listener _output_listener =
{
_cb_geometry,
_cb_mode,
_cb_done,
_cb_scale
};
void
_ecore_wl2_output_add(Ecore_Wl2_Display *display, unsigned int id)
{
Ecore_Wl2_Output *output;
output = calloc(1, sizeof(Ecore_Wl2_Output));
if (!output) return;
output->display = display;
output->wl_output =
wl_registry_bind(wl_display_get_registry(display->wl.display),
id, &wl_output_interface, 2);
display->outputs =
eina_inlist_append(display->outputs, EINA_INLIST_GET(output));
wl_output_add_listener(output->wl_output, &_output_listener, output);
}
void
_ecore_wl2_output_del(Ecore_Wl2_Output *output)
{
Ecore_Wl2_Display *display;
if (!output) return;
display = output->display;
if (output->wl_output) wl_output_destroy(output->wl_output);
if (output->make) eina_stringshare_del(output->make);
if (output->model) eina_stringshare_del(output->model);
display->outputs =
eina_inlist_remove(display->outputs, EINA_INLIST_GET(output));
free(output);
}

View File

@ -60,6 +60,8 @@ struct _Ecore_Wl2_Display
Eina_Hash *globals;
Eina_Inlist *outputs;
Eina_Bool sync_done : 1;
};
@ -89,4 +91,19 @@ struct _Ecore_Wl2_Window
Eina_Bool resizing : 1;
};
struct _Ecore_Wl2_Output
{
EINA_INLIST;
Ecore_Wl2_Display *display;
struct wl_output *wl_output;
int mw, mh, transform;
const char *make, *model;
Eina_Rectangle geometry;
};
void _ecore_wl2_output_add(Ecore_Wl2_Display *display, unsigned int id);
void _ecore_wl2_output_del(Ecore_Wl2_Output *output);
#endif