2 * Copyright © 2011 Kristian Høgsberg
3 * Copyright © 2011 Benjamin Franzke
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
26 * Kristian Høgsberg <krh@bitplanet.net>
27 * Benjamin Franzke <benjaminfranzke@googlemail.com>
33 #include <wayland-client.h>
34 #include "wayland-egl.h"
35 #include "wayland-egl-priv.h"
38 wl_egl_window_resize(struct wl_egl_window
*egl_window
,
39 int width
, int height
,
42 if (width
<= 0 || height
<= 0)
45 egl_window
->width
= width
;
46 egl_window
->height
= height
;
50 if (egl_window
->resize_callback
)
51 egl_window
->resize_callback(egl_window
, egl_window
->private);
54 WL_EGL_EXPORT
struct wl_egl_window
*
55 wl_egl_window_create(struct wl_surface
*surface
,
56 int width
, int height
)
58 struct wl_egl_window _INIT_
= { .version
= WL_EGL_WINDOW_VERSION
};
59 struct wl_egl_window
*egl_window
;
61 if (width
<= 0 || height
<= 0)
64 egl_window
= malloc(sizeof *egl_window
);
68 memcpy(egl_window
, &_INIT_
, sizeof *egl_window
);
70 egl_window
->surface
= surface
;
71 egl_window
->private = NULL
;
72 egl_window
->resize_callback
= NULL
;
73 egl_window
->destroy_window_callback
= NULL
;
74 wl_egl_window_resize(egl_window
, width
, height
, 0, 0);
75 egl_window
->attached_width
= 0;
76 egl_window
->attached_height
= 0;
82 wl_egl_window_destroy(struct wl_egl_window
*egl_window
)
84 if (egl_window
->destroy_window_callback
)
85 egl_window
->destroy_window_callback(egl_window
->private);
90 wl_egl_window_get_attached_size(struct wl_egl_window
*egl_window
,
91 int *width
, int *height
)
94 *width
= egl_window
->attached_width
;
96 *height
= egl_window
->attached_height
;