]> git.proxmox.com Git - mirror_qemu.git/blame - include/ui/gtk.h
Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging
[mirror_qemu.git] / include / ui / gtk.h
CommitLineData
dc7ff344
GH
1#ifndef UI_GTK_H
2#define UI_GTK_H
3
dc7ff344
GH
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
13
14#include <gdk/gdkkeysyms.h>
15
16#ifdef GDK_WINDOWING_X11
17#include <gdk/gdkx.h>
18#include <X11/XKBlib.h>
19#endif
20
a8ffb372
DB
21#ifdef GDK_WINDOWING_WAYLAND
22#include <gdk/gdkwayland.h>
23#endif
24
97edf3bd
GH
25#if defined(CONFIG_OPENGL)
26#include "ui/egl-helpers.h"
4782aeb7 27#include "ui/egl-context.h"
97edf3bd
GH
28#endif
29
dc7ff344
GH
30/* Compatibility define to let us build on both Gtk2 and Gtk3 */
31#if GTK_CHECK_VERSION(3, 0, 0)
32static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
33{
34 *ww = gdk_window_get_width(w);
35 *wh = gdk_window_get_height(w);
36}
37#endif
38
39typedef struct GtkDisplayState GtkDisplayState;
40
41typedef 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;
97edf3bd
GH
49#if defined(CONFIG_OPENGL)
50 ConsoleGLState *gls;
51 EGLContext ectx;
52 EGLSurface esurface;
53 int glupdates;
4782aeb7 54 int x, y, w, h;
a4f113fd
GH
55 egl_fb guest_fb;
56 egl_fb win_fb;
4782aeb7
GH
57 bool y0_top;
58 bool scanout_mode;
97edf3bd 59#endif
dc7ff344
GH
60} VirtualGfxConsole;
61
62#if defined(CONFIG_VTE)
63typedef struct VirtualVteConsole {
64 GtkWidget *box;
65 GtkWidget *scrollbar;
66 GtkWidget *terminal;
0ec7b3e7 67 Chardev *chr;
fba958c6 68 bool echo;
dc7ff344
GH
69} VirtualVteConsole;
70#endif
71
72typedef enum VirtualConsoleType {
73 GD_VC_GFX,
74 GD_VC_VTE,
75} VirtualConsoleType;
76
77typedef struct VirtualConsole {
78 GtkDisplayState *s;
79 char *label;
80 GtkWidget *window;
81 GtkWidget *menu_item;
82 GtkWidget *tab_item;
83 GtkWidget *focus;
84 VirtualConsoleType type;
85 union {
86 VirtualGfxConsole gfx;
87#if defined(CONFIG_VTE)
88 VirtualVteConsole vte;
89#endif
90 };
91} VirtualConsole;
92
97edf3bd
GH
93/* ui/gtk.c */
94void gd_update_windowsize(VirtualConsole *vc);
95
96/* ui/gtk-egl.c */
97void gd_egl_init(VirtualConsole *vc);
98void gd_egl_draw(VirtualConsole *vc);
99void gd_egl_update(DisplayChangeListener *dcl,
100 int x, int y, int w, int h);
101void gd_egl_refresh(DisplayChangeListener *dcl);
102void gd_egl_switch(DisplayChangeListener *dcl,
103 DisplaySurface *surface);
4782aeb7
GH
104QEMUGLContext gd_egl_create_context(DisplayChangeListener *dcl,
105 QEMUGLParams *params);
543a7a16 106void gd_egl_scanout_disable(DisplayChangeListener *dcl);
f4c36bda
GH
107void gd_egl_scanout_texture(DisplayChangeListener *dcl,
108 uint32_t backing_id,
109 bool backing_y_0_top,
110 uint32_t backing_width,
111 uint32_t backing_height,
112 uint32_t x, uint32_t y,
113 uint32_t w, uint32_t h);
4782aeb7
GH
114void gd_egl_scanout_flush(DisplayChangeListener *dcl,
115 uint32_t x, uint32_t y, uint32_t w, uint32_t h);
97edf3bd 116void gtk_egl_init(void);
4782aeb7
GH
117int gd_egl_make_current(DisplayChangeListener *dcl,
118 QEMUGLContext ctx);
97edf3bd 119
925a0400
GH
120/* ui/gtk-gl-area.c */
121void gd_gl_area_init(VirtualConsole *vc);
122void gd_gl_area_draw(VirtualConsole *vc);
123void gd_gl_area_update(DisplayChangeListener *dcl,
124 int x, int y, int w, int h);
125void gd_gl_area_refresh(DisplayChangeListener *dcl);
126void gd_gl_area_switch(DisplayChangeListener *dcl,
127 DisplaySurface *surface);
128QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl,
129 QEMUGLParams *params);
130void gd_gl_area_destroy_context(DisplayChangeListener *dcl,
131 QEMUGLContext ctx);
f4c36bda
GH
132void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
133 uint32_t backing_id,
134 bool backing_y_0_top,
135 uint32_t backing_width,
136 uint32_t backing_height,
137 uint32_t x, uint32_t y,
138 uint32_t w, uint32_t h);
925a0400
GH
139void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
140 uint32_t x, uint32_t y, uint32_t w, uint32_t h);
141void gtk_gl_area_init(void);
142QEMUGLContext gd_gl_area_get_current_context(DisplayChangeListener *dcl);
143int gd_gl_area_make_current(DisplayChangeListener *dcl,
144 QEMUGLContext ctx);
145
dc7ff344 146#endif /* UI_GTK_H */