aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_wayland/ecore_wl_output.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/lib/ecore_wayland/ecore_wl_output.c')
-rw-r--r--libraries/ecore/src/lib/ecore_wayland/ecore_wl_output.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_wayland/ecore_wl_output.c b/libraries/ecore/src/lib/ecore_wayland/ecore_wl_output.c
new file mode 100644
index 0000000..9f540d4
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_wayland/ecore_wl_output.c
@@ -0,0 +1,79 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Ecore.h"
6#include "ecore_private.h"
7#include "ecore_wl_private.h"
8#include "Ecore_Wayland.h"
9
10/* local function prototypes */
11static void _ecore_wl_output_cb_geometry(void *data, struct wl_output *wl_output __UNUSED__, int x, int y, int w __UNUSED__, int h __UNUSED__, int subpixel __UNUSED__, const char *make __UNUSED__, const char *model __UNUSED__);
12static void _ecore_wl_output_cb_mode(void *data, struct wl_output *wl_output __UNUSED__, unsigned int flags, int w, int h, int refresh __UNUSED__);
13
14/* wayland listeners */
15static const struct wl_output_listener _ecore_wl_output_listener =
16{
17 _ecore_wl_output_cb_geometry,
18 _ecore_wl_output_cb_mode
19};
20
21void
22_ecore_wl_output_add(Ecore_Wl_Display *ewd, unsigned int id)
23{
24 Ecore_Wl_Output *output;
25
26 LOGFN(__FILE__, __LINE__, __FUNCTION__);
27
28 if (!(output = malloc(sizeof(Ecore_Wl_Output)))) return;
29
30 memset(output, 0, sizeof(Ecore_Wl_Output));
31
32 output->display = ewd;
33
34 output->output = wl_display_bind(ewd->wl.display, id, &wl_output_interface);
35 wl_list_insert(ewd->outputs.prev, &output->link);
36 wl_output_add_listener(output->output, &_ecore_wl_output_listener, output);
37}
38
39void
40_ecore_wl_output_del(Ecore_Wl_Output *output)
41{
42 if (!output) return;
43 if (output->destroy) (*output->destroy)(output, output->data);
44 if (output->output) wl_output_destroy(output->output);
45 wl_list_remove(&output->link);
46 free(output);
47}
48
49/* local functions */
50static void
51_ecore_wl_output_cb_geometry(void *data, struct wl_output *wl_output __UNUSED__, int x, int y, int w __UNUSED__, int h __UNUSED__, int subpixel __UNUSED__, const char *make __UNUSED__, const char *model __UNUSED__)
52{
53 Ecore_Wl_Output *output;
54
55 LOGFN(__FILE__, __LINE__, __FUNCTION__);
56
57 output = data;
58 output->allocation.x = x;
59 output->allocation.y = y;
60}
61
62static void
63_ecore_wl_output_cb_mode(void *data, struct wl_output *wl_output __UNUSED__, unsigned int flags, int w, int h, int refresh __UNUSED__)
64{
65 Ecore_Wl_Output *output;
66 Ecore_Wl_Display *ewd;
67
68 LOGFN(__FILE__, __LINE__, __FUNCTION__);
69
70 output = data;
71 ewd = output->display;
72 if (flags & WL_OUTPUT_MODE_CURRENT)
73 {
74 output->allocation.w = w;
75 output->allocation.h = h;
76 _ecore_wl_disp->output = output;
77 if (ewd->output_configure) (*ewd->output_configure)(output, ewd->data);
78 }
79}