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/shell_surface.h"
7 #include "ozone/ui/events/event_factory_ozone_wayland.h"
8 #include "ozone/wayland/display.h"
9 #include "ozone/wayland/input_device.h"
11 namespace ozonewayland {
13 WaylandShellSurface::WaylandShellSurface()
15 WaylandDisplay* display = WaylandDisplay::GetInstance();
16 surface_ = wl_compositor_create_surface(display->GetCompositor());
19 WaylandShellSurface::~WaylandShellSurface() {
21 wl_surface_destroy(surface_);
25 struct wl_surface* WaylandShellSurface::GetWLSurface() const {
29 void WaylandShellSurface::FlushDisplay() const {
30 WaylandDisplay* display = WaylandDisplay::GetInstance();
32 display->FlushDisplay();
35 void WaylandShellSurface::PopupDone() {
36 WaylandInputDevice* input = WaylandDisplay::GetInstance()->PrimaryInput();
37 ui::EventConverterOzoneWayland* dispatcher =
38 ui::EventFactoryOzoneWayland::GetInstance()->EventConverter();
40 if (!input->GetGrabWindowHandle())
42 dispatcher->CloseWidget(input->GetGrabWindowHandle());
43 input->SetGrabWindowHandle(0, 0);
46 void WaylandShellSurface::WindowResized(void* data,
49 WaylandWindow *window = static_cast<WaylandWindow*>(data);
50 ui::EventConverterOzoneWayland* dispatcher =
51 ui::EventFactoryOzoneWayland::GetInstance()->EventConverter();
52 dispatcher->WindowResized(window->Handle(), width, height);
55 void WaylandShellSurface::WindowActivated(void *data) {
56 WaylandWindow *window = static_cast<WaylandWindow*>(data);
57 WaylandShellSurface* shellSurface = window->ShellSurface();
59 if (shellSurface->IsMinimized()) {
60 shellSurface->Unminimize();
62 ui::EventConverterOzoneWayland* dispatcher =
63 ui::EventFactoryOzoneWayland::GetInstance()->EventConverter();
64 dispatcher->WindowUnminimized(window->Handle());
68 } // namespace ozonewayland