1 // Copyright 2014 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/shell.h"
7 #include "base/logging.h"
8 #include "ozone/wayland/display.h"
9 #include "ozone/wayland/shell/wl_shell_surface.h"
10 #if defined(ENABLE_XDG_SHELL)
11 #include "ozone/wayland/shell/xdg-shell-client-protocol.h"
12 #include "ozone/wayland/shell/xdg_shell_surface.h"
15 namespace ozonewayland {
17 WaylandShell::WaylandShell()
22 WaylandShell::~WaylandShell() {
24 wl_shell_destroy(shell_);
25 #if defined(ENABLE_XDG_SHELL)
27 xdg_shell_destroy(xdg_shell_);
31 WaylandShellSurface* WaylandShell::CreateShellSurface(WaylandWindow* window) {
32 DCHECK(shell_ || xdg_shell_);
33 WaylandDisplay* display = WaylandDisplay::GetInstance();
35 WaylandShellSurface* surface = NULL;
36 #if defined(ENABLE_XDG_SHELL)
38 surface = new XDGShellSurface();
41 surface = new WLShellSurface();
44 surface->InitializeShellSurface(window);
45 wl_surface_set_user_data(surface->GetWLSurface(), window);
46 display->FlushDisplay();
51 void WaylandShell::Initialize(struct wl_registry *registry,
53 const char *interface,
55 if (strcmp(interface, "wl_shell") == 0) {
57 shell_ = static_cast<wl_shell*>(
58 wl_registry_bind(registry, name, &wl_shell_interface, 1));
59 #if defined(ENABLE_XDG_SHELL)
60 } else if (strcmp(interface, "xdg_shell") == 0) {
62 xdg_shell_ = static_cast<xdg_shell*>(
63 wl_registry_bind(registry, name, &xdg_shell_interface, 1));
64 xdg_shell_use_unstable_version(xdg_shell_, XDG_SHELL_VERSION_CURRENT);
69 } // namespace ozonewayland