]>
Commit | Line | Data |
---|---|---|
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 | ||
0c0d4273 | 25 | #include "ui/kbd-state.h" |
97edf3bd GH |
26 | #if defined(CONFIG_OPENGL) |
27 | #include "ui/egl-helpers.h" | |
4782aeb7 | 28 | #include "ui/egl-context.h" |
97edf3bd GH |
29 | #endif |
30 | ||
dc7ff344 GH |
31 | typedef struct GtkDisplayState GtkDisplayState; |
32 | ||
33 | typedef struct VirtualGfxConsole { | |
34 | GtkWidget *drawing_area; | |
35 | DisplayChangeListener dcl; | |
0c0d4273 | 36 | QKbdState *kbd; |
dc7ff344 GH |
37 | DisplaySurface *ds; |
38 | pixman_image_t *convert; | |
39 | cairo_surface_t *surface; | |
40 | double scale_x; | |
41 | double scale_y; | |
97edf3bd | 42 | #if defined(CONFIG_OPENGL) |
46e19e14 | 43 | QemuGLShader *gls; |
97edf3bd GH |
44 | EGLContext ectx; |
45 | EGLSurface esurface; | |
46 | int glupdates; | |
4782aeb7 | 47 | int x, y, w, h; |
a4f113fd GH |
48 | egl_fb guest_fb; |
49 | egl_fb win_fb; | |
f1bd3132 GH |
50 | egl_fb cursor_fb; |
51 | int cursor_x; | |
52 | int cursor_y; | |
4782aeb7 GH |
53 | bool y0_top; |
54 | bool scanout_mode; | |
97edf3bd | 55 | #endif |
dc7ff344 GH |
56 | } VirtualGfxConsole; |
57 | ||
58 | #if defined(CONFIG_VTE) | |
59 | typedef struct VirtualVteConsole { | |
60 | GtkWidget *box; | |
61 | GtkWidget *scrollbar; | |
62 | GtkWidget *terminal; | |
0ec7b3e7 | 63 | Chardev *chr; |
fba958c6 | 64 | bool echo; |
dc7ff344 GH |
65 | } VirtualVteConsole; |
66 | #endif | |
67 | ||
68 | typedef enum VirtualConsoleType { | |
69 | GD_VC_GFX, | |
70 | GD_VC_VTE, | |
71 | } VirtualConsoleType; | |
72 | ||
73 | typedef struct VirtualConsole { | |
74 | GtkDisplayState *s; | |
75 | char *label; | |
76 | GtkWidget *window; | |
77 | GtkWidget *menu_item; | |
78 | GtkWidget *tab_item; | |
79 | GtkWidget *focus; | |
80 | VirtualConsoleType type; | |
81 | union { | |
82 | VirtualGfxConsole gfx; | |
83 | #if defined(CONFIG_VTE) | |
84 | VirtualVteConsole vte; | |
85 | #endif | |
86 | }; | |
87 | } VirtualConsole; | |
88 | ||
11c82b58 GH |
89 | extern bool gtk_use_gl_area; |
90 | ||
97edf3bd GH |
91 | /* ui/gtk.c */ |
92 | void gd_update_windowsize(VirtualConsole *vc); | |
93 | ||
94 | /* ui/gtk-egl.c */ | |
95 | void gd_egl_init(VirtualConsole *vc); | |
96 | void gd_egl_draw(VirtualConsole *vc); | |
97 | void gd_egl_update(DisplayChangeListener *dcl, | |
98 | int x, int y, int w, int h); | |
99 | void gd_egl_refresh(DisplayChangeListener *dcl); | |
100 | void gd_egl_switch(DisplayChangeListener *dcl, | |
101 | DisplaySurface *surface); | |
4782aeb7 GH |
102 | QEMUGLContext gd_egl_create_context(DisplayChangeListener *dcl, |
103 | QEMUGLParams *params); | |
543a7a16 | 104 | void gd_egl_scanout_disable(DisplayChangeListener *dcl); |
f4c36bda GH |
105 | void gd_egl_scanout_texture(DisplayChangeListener *dcl, |
106 | uint32_t backing_id, | |
107 | bool backing_y_0_top, | |
108 | uint32_t backing_width, | |
109 | uint32_t backing_height, | |
110 | uint32_t x, uint32_t y, | |
111 | uint32_t w, uint32_t h); | |
70763fea GH |
112 | void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl, |
113 | QemuDmaBuf *dmabuf); | |
f1bd3132 GH |
114 | void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl, |
115 | QemuDmaBuf *dmabuf, bool have_hot, | |
116 | uint32_t hot_x, uint32_t hot_y); | |
117 | void gd_egl_cursor_position(DisplayChangeListener *dcl, | |
118 | uint32_t pos_x, uint32_t pos_y); | |
70763fea GH |
119 | void gd_egl_release_dmabuf(DisplayChangeListener *dcl, |
120 | QemuDmaBuf *dmabuf); | |
4782aeb7 GH |
121 | void gd_egl_scanout_flush(DisplayChangeListener *dcl, |
122 | uint32_t x, uint32_t y, uint32_t w, uint32_t h); | |
54d208ff | 123 | void gtk_egl_init(DisplayGLMode mode); |
4782aeb7 GH |
124 | int gd_egl_make_current(DisplayChangeListener *dcl, |
125 | QEMUGLContext ctx); | |
97edf3bd | 126 | |
925a0400 GH |
127 | /* ui/gtk-gl-area.c */ |
128 | void gd_gl_area_init(VirtualConsole *vc); | |
129 | void gd_gl_area_draw(VirtualConsole *vc); | |
130 | void gd_gl_area_update(DisplayChangeListener *dcl, | |
131 | int x, int y, int w, int h); | |
132 | void gd_gl_area_refresh(DisplayChangeListener *dcl); | |
133 | void gd_gl_area_switch(DisplayChangeListener *dcl, | |
134 | DisplaySurface *surface); | |
135 | QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl, | |
136 | QEMUGLParams *params); | |
137 | void gd_gl_area_destroy_context(DisplayChangeListener *dcl, | |
138 | QEMUGLContext ctx); | |
f4c36bda GH |
139 | void gd_gl_area_scanout_texture(DisplayChangeListener *dcl, |
140 | uint32_t backing_id, | |
141 | bool backing_y_0_top, | |
142 | uint32_t backing_width, | |
143 | uint32_t backing_height, | |
144 | uint32_t x, uint32_t y, | |
145 | uint32_t w, uint32_t h); | |
925a0400 GH |
146 | void gd_gl_area_scanout_flush(DisplayChangeListener *dcl, |
147 | uint32_t x, uint32_t y, uint32_t w, uint32_t h); | |
148 | void gtk_gl_area_init(void); | |
149 | QEMUGLContext gd_gl_area_get_current_context(DisplayChangeListener *dcl); | |
150 | int gd_gl_area_make_current(DisplayChangeListener *dcl, | |
151 | QEMUGLContext ctx); | |
152 | ||
dc7ff344 | 153 | #endif /* UI_GTK_H */ |