2 * Copyright © 2013 Intel Corporation
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 #include "shell_surface.h"
25 ShellSurface::ShellSurface(const Shell& shell, const Surface& surface)
29 wl_shell_get_shell_surface(shell, surface))
31 ASSERT(wl_shell_surface_ != NULL);
33 wl_shell_surface_set_user_data(*this, this);
35 static const wl_shell_surface_listener listener = {
36 ping, configure, popupDone};
38 wl_shell_surface_add_listener(*this, &listener, this);
40 wl_shell_surface_set_toplevel(*this);
42 shell.display().roundtrip();
45 ShellSurface::~ShellSurface()
47 wl_shell_surface_destroy(*this);
50 /*static*/ void ShellSurface::ping(
51 void *data, wl_shell_surface *wl_shell_surface, uint32_t serial)
53 ShellSurface* shellSurface = static_cast<ShellSurface*>(data);
54 ASSERT(wl_shell_surface == *shellSurface);
56 wl_shell_surface_pong(wl_shell_surface, serial);
59 /*static*/ void ShellSurface::configure(
60 void *data, wl_shell_surface *wl_shell_surface, uint32_t edges,
61 int32_t width, int32_t height)
63 ShellSurface* shellSurface = static_cast<ShellSurface*>(data);
64 ASSERT(wl_shell_surface == *shellSurface);
67 /*static*/ void ShellSurface::popupDone(
68 void *data, wl_shell_surface *wl_shell_surface)
70 ShellSurface* shellSurface = static_cast<ShellSurface*>(data);
71 ASSERT(wl_shell_surface == *shellSurface);
74 TEST(ShellSurface, "Core/Wrapper")
77 Compositor compositor(display);
79 Surface surface(compositor);
80 ShellSurface ss(shell, surface);
82 FAIL_UNLESS_EQUAL(&ss.shell(), &shell);
83 FAIL_UNLESS_EQUAL(&ss.surface(), &surface);
84 FAIL_IF((wl_shell_surface*)ss == NULL);
85 FAIL_UNLESS_EQUAL(wl_shell_surface_get_user_data(ss), &ss);