]> Git Repo - qemu.git/blame - include/ui/gtk.h
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2018-03-13-v2' into staging
[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 49#if defined(CONFIG_OPENGL)
46e19e14 50 QemuGLShader *gls;
97edf3bd
GH
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;
f1bd3132
GH
57 egl_fb cursor_fb;
58 int cursor_x;
59 int cursor_y;
4782aeb7
GH
60 bool y0_top;
61 bool scanout_mode;
97edf3bd 62#endif
dc7ff344
GH
63} VirtualGfxConsole;
64
65#if defined(CONFIG_VTE)
66typedef struct VirtualVteConsole {
67 GtkWidget *box;
68 GtkWidget *scrollbar;
69 GtkWidget *terminal;
0ec7b3e7 70 Chardev *chr;
fba958c6 71 bool echo;
dc7ff344
GH
72} VirtualVteConsole;
73#endif
74
75typedef enum VirtualConsoleType {
76 GD_VC_GFX,
77 GD_VC_VTE,
78} VirtualConsoleType;
79
80typedef 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
93 };
94} VirtualConsole;
95
11c82b58
GH
96extern bool gtk_use_gl_area;
97
97edf3bd
GH
98/* ui/gtk.c */
99void gd_update_windowsize(VirtualConsole *vc);
100
101/* ui/gtk-egl.c */
102void gd_egl_init(VirtualConsole *vc);
103void gd_egl_draw(VirtualConsole *vc);
104void gd_egl_update(DisplayChangeListener *dcl,
105 int x, int y, int w, int h);
106void gd_egl_refresh(DisplayChangeListener *dcl);
107void gd_egl_switch(DisplayChangeListener *dcl,
108 DisplaySurface *surface);
4782aeb7
GH
109QEMUGLContext gd_egl_create_context(DisplayChangeListener *dcl,
110 QEMUGLParams *params);
543a7a16 111void gd_egl_scanout_disable(DisplayChangeListener *dcl);
f4c36bda
GH
112void 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);
70763fea
GH
119void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
120 QemuDmaBuf *dmabuf);
f1bd3132
GH
121void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl,
122 QemuDmaBuf *dmabuf, bool have_hot,
123 uint32_t hot_x, uint32_t hot_y);
124void gd_egl_cursor_position(DisplayChangeListener *dcl,
125 uint32_t pos_x, uint32_t pos_y);
70763fea
GH
126void gd_egl_release_dmabuf(DisplayChangeListener *dcl,
127 QemuDmaBuf *dmabuf);
4782aeb7
GH
128void gd_egl_scanout_flush(DisplayChangeListener *dcl,
129 uint32_t x, uint32_t y, uint32_t w, uint32_t h);
97edf3bd 130void gtk_egl_init(void);
4782aeb7
GH
131int gd_egl_make_current(DisplayChangeListener *dcl,
132 QEMUGLContext ctx);
97edf3bd 133
925a0400
GH
134/* ui/gtk-gl-area.c */
135void gd_gl_area_init(VirtualConsole *vc);
136void gd_gl_area_draw(VirtualConsole *vc);
137void gd_gl_area_update(DisplayChangeListener *dcl,
138 int x, int y, int w, int h);
139void gd_gl_area_refresh(DisplayChangeListener *dcl);
140void gd_gl_area_switch(DisplayChangeListener *dcl,
141 DisplaySurface *surface);
142QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl,
143 QEMUGLParams *params);
144void gd_gl_area_destroy_context(DisplayChangeListener *dcl,
145 QEMUGLContext ctx);
f4c36bda
GH
146void 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);
925a0400
GH
153void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
154 uint32_t x, uint32_t y, uint32_t w, uint32_t h);
155void gtk_gl_area_init(void);
156QEMUGLContext gd_gl_area_get_current_context(DisplayChangeListener *dcl);
157int gd_gl_area_make_current(DisplayChangeListener *dcl,
158 QEMUGLContext ctx);
159
dc7ff344 160#endif /* UI_GTK_H */
This page took 0.142727 seconds and 4 git commands to generate.