summaryrefslogtreecommitdiff
path: root/src/lib/ecore_wayland/ecore_wl_output.c
blob: c17b06d46b965c5a8cf7268e8bb8cbe51ade6be7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "ecore_wl_private.h"

/* Sets the output's geometry */
static void
_ecore_wl_output_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 EINA_UNUSED, const char *model EINA_UNUSED, int transform)
{
   Ecore_Wl_Output *output;

   LOGFN;

   output = data;
   output->allocation.x = x;
   output->allocation.y = y;
   output->mw = w;
   output->mh = h;
   output->transform = transform;
}

/* Sets the output's mode */
static void
_ecore_wl_output_cb_mode(void *data, struct wl_output *wl_output EINA_UNUSED, unsigned int flags, int w, int h, int refresh EINA_UNUSED)
{
   Ecore_Wl_Output *output;
   Ecore_Wl_Display *ewd;

   LOGFN;

   output = data;
   ewd = output->display;
   if (flags & WL_OUTPUT_MODE_CURRENT)
     {
        output->allocation.w = w;
        output->allocation.h = h;
        _ecore_wl_disp->output = output;
        if (ewd->output_configure) (*ewd->output_configure)(output, ewd->data);
     }
}

static void
_ecore_wl_output_cb_done(void *data EINA_UNUSED, struct wl_output *output EINA_UNUSED)
{

}

static void
_ecore_wl_output_cb_scale(void *data EINA_UNUSED, struct wl_output *output EINA_UNUSED, int scale EINA_UNUSED)
{

}

/* wayland listeners */
static const struct wl_output_listener _ecore_wl_output_listener =
{
   _ecore_wl_output_cb_geometry,
   _ecore_wl_output_cb_mode,
   _ecore_wl_output_cb_done,
   _ecore_wl_output_cb_scale
};

/* Get list of available outputs
 * @since 1.2 */
ECORE_WAYLAND_API Eina_Inlist *
ecore_wl_outputs_get(void)
{
   return _ecore_wl_disp->outputs;
}

/* Create new output for the given display, and append it to the display's
 * list of available outputs
 */
void
_ecore_wl_output_add(Ecore_Wl_Display *ewd, unsigned int id)
{
   Ecore_Wl_Output *output;

   LOGFN;

   if (!(output = calloc(1, sizeof(Ecore_Wl_Output)))) return;

   output->display = ewd;

   output->output =
     wl_registry_bind(ewd->wl.registry, id, &wl_output_interface, 2);

   ewd->outputs = eina_inlist_append(ewd->outputs, EINA_INLIST_GET(output));
   wl_output_add_listener(output->output, &_ecore_wl_output_listener, output);
}

/* Destruct the output and remove it from the display's list of available
 * outputs
 */
void
_ecore_wl_output_del(Ecore_Wl_Output *output)
{
   if (!output) return;
   if (output->destroy) (*output->destroy)(output, output->data);
   if (output->output) wl_output_destroy(output->output);
   _ecore_wl_disp->outputs =
     eina_inlist_remove(_ecore_wl_disp->outputs, EINA_INLIST_GET(output));
   free(output);
}