1 // Copyright 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ozone/wayland/shell_surface.h"
7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h"
10 #include "ozone/wayland/display.h"
11 #include "ozone/wayland/surface.h"
13 namespace ozonewayland {
15 WaylandShellSurface::WaylandShellSurface(WaylandWindow* window)
17 shell_surface_(NULL) {
18 WaylandDisplay* display = WaylandDisplay::GetInstance();
22 surface_ = new WaylandSurface();
24 shell_surface_ = wl_shell_get_shell_surface(
26 surface_->wlSurface());
29 static const wl_shell_surface_listener shell_surface_listener = {
30 WaylandShellSurface::HandlePing,
31 WaylandShellSurface::HandleConfigure,
32 WaylandShellSurface::HandlePopupDone
35 wl_shell_surface_add_listener(shell_surface_,
36 &shell_surface_listener,
41 WaylandShellSurface::~WaylandShellSurface() {
43 wl_shell_surface_destroy(shell_surface_);
44 shell_surface_ = NULL;
53 void WaylandShellSurface::UpdateShellSurface(WaylandWindow::ShellType type,
54 WaylandShellSurface* shell_parent,
58 case WaylandWindow::TOPLEVEL:
59 wl_shell_surface_set_toplevel(shell_surface_);
61 case WaylandWindow::TRANSIENT:
62 wl_shell_surface_set_transient(shell_surface_,
63 shell_parent->Surface()->wlSurface(),
66 WL_SHELL_SURFACE_TRANSIENT_INACTIVE);
68 case WaylandWindow::FULLSCREEN:
69 wl_shell_surface_set_fullscreen(shell_surface_,
70 WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
74 case WaylandWindow::CUSTOM:
75 NOTREACHED() << "Unsupported shell type: " << type;
82 void WaylandShellSurface::SetWindowTitle(const string16& title) {
83 wl_shell_surface_set_title(shell_surface_, UTF16ToUTF8(title).c_str());
86 void WaylandShellSurface::HandleConfigure(void *data,
87 struct wl_shell_surface *surface,
93 void WaylandShellSurface::HandlePopupDone(void *data,
94 struct wl_shell_surface *surface) {
97 void WaylandShellSurface::HandlePing(void *data,
98 struct wl_shell_surface *shell_surface,
100 wl_shell_surface_pong(shell_surface, serial);
103 } // namespace ozonewayland