virtio-scsi: fix hotplug ->reset() vs event race
[qemu/ar7.git] / include / ui / gtk.h
bloba79780afc70a7233cd9d9bffae862b37ec867b58
1 #ifndef UI_GTK_H
2 #define UI_GTK_H
4 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
5 /* Work around an -Wstrict-prototypes warning in GTK headers */
6 #pragma GCC diagnostic push
7 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
8 #endif
9 #include <gtk/gtk.h>
10 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
11 #pragma GCC diagnostic pop
12 #endif
14 #include <gdk/gdkkeysyms.h>
16 #ifdef GDK_WINDOWING_X11
17 #include <gdk/gdkx.h>
18 #include <X11/XKBlib.h>
19 #endif
21 #ifdef GDK_WINDOWING_WAYLAND
22 #include <gdk/gdkwayland.h>
23 #endif
25 #if defined(CONFIG_OPENGL)
26 #include "ui/egl-helpers.h"
27 #include "ui/egl-context.h"
28 #endif
30 /* Compatibility define to let us build on both Gtk2 and Gtk3 */
31 #if GTK_CHECK_VERSION(3, 0, 0)
32 static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
34 *ww = gdk_window_get_width(w);
35 *wh = gdk_window_get_height(w);
37 #endif
39 typedef struct GtkDisplayState GtkDisplayState;
41 typedef struct VirtualGfxConsole {
42 GtkWidget *drawing_area;
43 DisplayChangeListener dcl;
44 DisplaySurface *ds;
45 pixman_image_t *convert;
46 cairo_surface_t *surface;
47 double scale_x;
48 double scale_y;
49 #if defined(CONFIG_OPENGL)
50 QemuGLShader *gls;
51 EGLContext ectx;
52 EGLSurface esurface;
53 int glupdates;
54 int x, y, w, h;
55 egl_fb guest_fb;
56 egl_fb win_fb;
57 egl_fb cursor_fb;
58 int cursor_x;
59 int cursor_y;
60 bool y0_top;
61 bool scanout_mode;
62 #endif
63 } VirtualGfxConsole;
65 #if defined(CONFIG_VTE)
66 typedef struct VirtualVteConsole {
67 GtkWidget *box;
68 GtkWidget *scrollbar;
69 GtkWidget *terminal;
70 Chardev *chr;
71 bool echo;
72 } VirtualVteConsole;
73 #endif
75 typedef enum VirtualConsoleType {
76 GD_VC_GFX,
77 GD_VC_VTE,
78 } VirtualConsoleType;
80 typedef struct VirtualConsole {
81 GtkDisplayState *s;
82 char *label;
83 GtkWidget *window;
84 GtkWidget *menu_item;
85 GtkWidget *tab_item;
86 GtkWidget *focus;
87 VirtualConsoleType type;
88 union {
89 VirtualGfxConsole gfx;
90 #if defined(CONFIG_VTE)
91 VirtualVteConsole vte;
92 #endif
94 } VirtualConsole;
96 extern bool gtk_use_gl_area;
98 /* ui/gtk.c */
99 void gd_update_windowsize(VirtualConsole *vc);
101 /* ui/gtk-egl.c */
102 void gd_egl_init(VirtualConsole *vc);
103 void gd_egl_draw(VirtualConsole *vc);
104 void gd_egl_update(DisplayChangeListener *dcl,
105 int x, int y, int w, int h);
106 void gd_egl_refresh(DisplayChangeListener *dcl);
107 void gd_egl_switch(DisplayChangeListener *dcl,
108 DisplaySurface *surface);
109 QEMUGLContext gd_egl_create_context(DisplayChangeListener *dcl,
110 QEMUGLParams *params);
111 void gd_egl_scanout_disable(DisplayChangeListener *dcl);
112 void gd_egl_scanout_texture(DisplayChangeListener *dcl,
113 uint32_t backing_id,
114 bool backing_y_0_top,
115 uint32_t backing_width,
116 uint32_t backing_height,
117 uint32_t x, uint32_t y,
118 uint32_t w, uint32_t h);
119 void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
120 QemuDmaBuf *dmabuf);
121 void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl,
122 QemuDmaBuf *dmabuf, bool have_hot,
123 uint32_t hot_x, uint32_t hot_y);
124 void gd_egl_cursor_position(DisplayChangeListener *dcl,
125 uint32_t pos_x, uint32_t pos_y);
126 void gd_egl_release_dmabuf(DisplayChangeListener *dcl,
127 QemuDmaBuf *dmabuf);
128 void gd_egl_scanout_flush(DisplayChangeListener *dcl,
129 uint32_t x, uint32_t y, uint32_t w, uint32_t h);
130 void gtk_egl_init(DisplayGLMode mode);
131 int gd_egl_make_current(DisplayChangeListener *dcl,
132 QEMUGLContext ctx);
134 /* ui/gtk-gl-area.c */
135 void gd_gl_area_init(VirtualConsole *vc);
136 void gd_gl_area_draw(VirtualConsole *vc);
137 void gd_gl_area_update(DisplayChangeListener *dcl,
138 int x, int y, int w, int h);
139 void gd_gl_area_refresh(DisplayChangeListener *dcl);
140 void gd_gl_area_switch(DisplayChangeListener *dcl,
141 DisplaySurface *surface);
142 QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl,
143 QEMUGLParams *params);
144 void gd_gl_area_destroy_context(DisplayChangeListener *dcl,
145 QEMUGLContext ctx);
146 void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
147 uint32_t backing_id,
148 bool backing_y_0_top,
149 uint32_t backing_width,
150 uint32_t backing_height,
151 uint32_t x, uint32_t y,
152 uint32_t w, uint32_t h);
153 void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
154 uint32_t x, uint32_t y, uint32_t w, uint32_t h);
155 void gtk_gl_area_init(void);
156 QEMUGLContext gd_gl_area_get_current_context(DisplayChangeListener *dcl);
157 int gd_gl_area_make_current(DisplayChangeListener *dcl,
158 QEMUGLContext ctx);
160 #endif /* UI_GTK_H */