summaryrefslogtreecommitdiff
path: root/chromium/ui/ozone/platform/wayland/host/gtk_ui_delegate_wayland.h
blob: e5e23aeddac655f1c6ee6a666a4bb817fa325a7b (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
// Copyright 2020 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.

#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_GTK_UI_DELEGATE_WAYLAND_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_GTK_UI_DELEGATE_WAYLAND_H_

#include <string>

#include "base/memory/weak_ptr.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gtk/gtk_ui_delegate.h"

namespace ui {

class WaylandConnection;

class GtkUiDelegateWayland : public GtkUiDelegate {
 public:
  explicit GtkUiDelegateWayland(WaylandConnection* connection);
  GtkUiDelegateWayland(const GtkUiDelegateWayland&) = delete;
  GtkUiDelegateWayland& operator=(const GtkUiDelegateWayland&) = delete;
  ~GtkUiDelegateWayland() override;

  // GtkUiDelegate:
  void OnInitialized() override;
  GdkKeymap* GetGdkKeymap() override;
  GdkWindow* GetGdkWindow(gfx::AcceleratedWidget window_id) override;
  bool SetGdkWindowTransientFor(GdkWindow* window,
                                gfx::AcceleratedWidget parent) override;
  void ClearTransientFor(gfx::AcceleratedWidget parent) override;
  void ShowGtkWindow(GtkWindow* window) override;

 private:
  // Called when xdg-foreign exports a parent window passed in
  // SetGdkWindowTransientFor.
  void OnHandle(GdkWindow* window, const std::string& handle);

  WaylandConnection* const connection_;

  base::WeakPtrFactory<GtkUiDelegateWayland> weak_factory_{this};
};

}  // namespace ui

#endif  // UI_OZONE_PLATFORM_WAYLAND_HOST_GTK_UI_DELEGATE_WAYLAND_H_