gtk_types.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Copyright 2021 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_TYPES_H_
  5. #define UI_GTK_GTK_TYPES_H_
  6. #include <gdk/gdk.h>
  7. #include <gtk/gtk.h>
  8. // This file provides types that are only available in specific versions of GTK.
  9. // This struct uses doubles in Gtk3, but floats in Gtk4.
  10. #define GdkRGBA Do_not_use_GdkRGBA_because_it_is_not_ABI_compatible
  11. extern "C" {
  12. #if GTK_MAJOR_VERSION == 3
  13. using GskRenderNodeType = enum {
  14. GSK_NOT_A_RENDER_NODE = 0,
  15. GSK_CONTAINER_NODE,
  16. GSK_CAIRO_NODE,
  17. GSK_COLOR_NODE,
  18. GSK_LINEAR_GRADIENT_NODE,
  19. GSK_REPEATING_LINEAR_GRADIENT_NODE,
  20. GSK_RADIAL_GRADIENT_NODE,
  21. GSK_REPEATING_RADIAL_GRADIENT_NODE,
  22. GSK_CONIC_GRADIENT_NODE,
  23. GSK_BORDER_NODE,
  24. GSK_TEXTURE_NODE,
  25. GSK_INSET_SHADOW_NODE,
  26. GSK_OUTSET_SHADOW_NODE,
  27. GSK_TRANSFORM_NODE,
  28. GSK_OPACITY_NODE,
  29. GSK_COLOR_MATRIX_NODE,
  30. GSK_REPEAT_NODE,
  31. GSK_CLIP_NODE,
  32. GSK_ROUNDED_CLIP_NODE,
  33. GSK_SHADOW_NODE,
  34. GSK_BLEND_NODE,
  35. GSK_CROSS_FADE_NODE,
  36. GSK_TEXT_NODE,
  37. GSK_BLUR_NODE,
  38. GSK_DEBUG_NODE,
  39. GSK_GL_SHADER_NODE
  40. };
  41. enum GdkMemoryFormat : int;
  42. using GskRenderNode = struct _GskRenderNode;
  43. using GtkIconPaintable = struct _GtkIconPaintable;
  44. using GdkTexture = struct _GdkTexture;
  45. using GdkSnapshot = struct _GdkSnapshot;
  46. using GtkSnapshot = GdkSnapshot;
  47. using GdkPaintable = struct _GdkPaintable;
  48. using GtkNative = struct _GtkNative;
  49. using GdkSurface = struct _GdkSurface;
  50. using GdkToplevel = struct _GdkToplevel;
  51. constexpr GdkMemoryFormat GDK_MEMORY_B8G8R8A8 = static_cast<GdkMemoryFormat>(3);
  52. constexpr GdkModifierType GDK_ALT_MASK = GDK_MOD1_MASK;
  53. #elif GTK_MAJOR_VERSION == 4
  54. enum GtkWidgetHelpType : int;
  55. enum GtkWindowType : int;
  56. using GtkWidgetPath = struct _GtkWidgetPath;
  57. using GtkContainer = struct _GtkContainer;
  58. using GdkEventKey = struct _GdkEventKey;
  59. using GdkWindow = struct _GdkWindow;
  60. using GdkKeymap = struct _GdkKeymap;
  61. using GtkIconInfo = struct _GtkIconInfo;
  62. using GdkScreen = struct _GdkScreen;
  63. using GdkColor = struct _GdkColor;
  64. using GdkEventFunc = void (*)(GdkEvent* event, gpointer data);
  65. struct _GdkEventKey {
  66. GdkEventType type;
  67. GdkWindow* window;
  68. gint8 send_event;
  69. guint32 time;
  70. guint state;
  71. guint keyval;
  72. gint length;
  73. gchar* string;
  74. guint16 hardware_keycode;
  75. guint8 group;
  76. guint is_modifier : 1;
  77. };
  78. struct _GdkColor {
  79. guint32 pixel;
  80. guint16 red;
  81. guint16 green;
  82. guint16 blue;
  83. };
  84. constexpr int GTK_ICON_LOOKUP_USE_BUILTIN = 1 << 2;
  85. constexpr int GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 3;
  86. constexpr int GTK_ICON_LOOKUP_FORCE_SIZE = 1 << 4;
  87. constexpr auto GTK_WINDOW_TOPLEVEL = static_cast<GtkWindowType>(0);
  88. #else
  89. #error "Unsupported GTK version"
  90. #endif
  91. }
  92. #endif // UI_GTK_GTK_TYPES_H_