gtk_ui_platform.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2020 The Chromium Authors. 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.
  4. #ifndef UI_GTK_GTK_UI_PLATFORM_H_
  5. #define UI_GTK_GTK_UI_PLATFORM_H_
  6. #include "base/callback_forward.h"
  7. #include "ui/events/event.h"
  8. #include "ui/gfx/native_widget_types.h"
  9. #include "ui/gtk/gtk_compat.h"
  10. using GdkKeymap = struct _GdkKeymap;
  11. using GtkWindow = struct _GtkWindow;
  12. using GtkWidget = struct _GtkWidget;
  13. using GdkWindow = struct _GdkWindow;
  14. namespace gtk {
  15. // GtkUiPlatform encapsulates platform-specific functionalities required by
  16. // a Gtk-based LinuxUI implementation.
  17. class GtkUiPlatform {
  18. public:
  19. virtual ~GtkUiPlatform() = default;
  20. // Called when the GtkUi instance initialization process finished. |widget| is
  21. // a dummy window passed in for context.
  22. virtual void OnInitialized(GtkWidget* widget) = 0;
  23. // Gets the GdkKeymap instance, which is used to translate KeyEvents into
  24. // GdkEvents before filtering them through GtkIM API.
  25. virtual GdkKeymap* GetGdkKeymap() = 0;
  26. // Gets the GDK key event state for a KeyEvent.
  27. virtual GdkModifierType GetGdkKeyEventState(
  28. const ui::KeyEvent& key_event) = 0;
  29. // Gets the GDK key event group for a KeyEvent.
  30. virtual int GetGdkKeyEventGroup(const ui::KeyEvent& key_event) = 0;
  31. // Creates/Gets a GdkWindow out of a Aura window id. Caller owns the returned
  32. // object. This function is meant to be used in GtkIM-based IME implementation
  33. // and is supported only in X11 backend (both Aura and Ozone).
  34. virtual GdkWindow* GetGdkWindow(gfx::AcceleratedWidget window_id) = 0;
  35. // Gtk dialog windows must be set transient for the browser window. This
  36. // function abstracts away such functionality.
  37. virtual bool SetGtkWidgetTransientFor(GtkWidget* widget,
  38. gfx::AcceleratedWidget parent) = 0;
  39. virtual void ClearTransientFor(gfx::AcceleratedWidget parent) = 0;
  40. // Presents |window|, doing all the necessary platform-specific operations
  41. // needed, if any.
  42. virtual void ShowGtkWindow(GtkWindow* window) = 0;
  43. };
  44. } // namespace gtk
  45. #endif // UI_GTK_GTK_UI_PLATFORM_H_