blob: 7854b05b9996547b8d60a56701366d6e7c025d6a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/wayland/host/wayland_auxiliary_window.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_popup.h"
#include "ui/ozone/platform/wayland/host/wayland_toplevel_window.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
namespace ui {
// static
std::unique_ptr<WaylandWindow> WaylandWindow::Create(
PlatformWindowDelegate* delegate,
WaylandConnection* connection,
PlatformWindowInitProperties properties) {
std::unique_ptr<WaylandWindow> window;
switch (properties.type) {
case PlatformWindowType::kMenu:
case PlatformWindowType::kPopup:
// We are unable to create a popup or menu window, because they require a
// parent window to be set. Thus, create a normal window instead then.
if (properties.parent_widget == gfx::kNullAcceleratedWidget &&
!connection->wayland_window_manager()->GetCurrentFocusedWindow()) {
window.reset(new WaylandToplevelWindow(delegate, connection));
} else if (connection->IsDragInProgress()) {
// We are in the process of drag and requested a popup. Most probably,
// it is an arrow window.
window.reset(new WaylandAuxiliaryWindow(delegate, connection));
} else {
window.reset(new WaylandPopup(delegate, connection));
}
break;
case PlatformWindowType::kTooltip:
window.reset(new WaylandAuxiliaryWindow(delegate, connection));
break;
case PlatformWindowType::kWindow:
case PlatformWindowType::kBubble:
case PlatformWindowType::kDrag:
// TODO(msisov): Figure out what kind of surface we need to create for
// bubble and drag windows.
window.reset(new WaylandToplevelWindow(delegate, connection));
break;
default:
NOTREACHED();
break;
}
return window && window->Initialize(std::move(properties)) ? std::move(window)
: nullptr;
}
} // namespace ui
|