qemu/include/ui/gtk.h
<<
>>
Prefs
   1#ifndef UI_GTK_H
   2#define UI_GTK_H
   3
   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
  21#ifdef GDK_WINDOWING_WAYLAND
  22#include <gdk/gdkwayland.h>
  23#endif
  24
  25#if defined(CONFIG_OPENGL)
  26#include "ui/egl-helpers.h"
  27#include "ui/egl-context.h"
  28#endif
  29
  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;
  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    bool y0_top;
  58    bool scanout_mode;
  59#endif
  60} VirtualGfxConsole;
  61
  62#if defined(CONFIG_VTE)
  63typedef struct VirtualVteConsole {
  64    GtkWidget *box;
  65    GtkWidget *scrollbar;
  66    GtkWidget *terminal;
  67    Chardev *chr;
  68    bool echo;
  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
  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);
 104QEMUGLContext gd_egl_create_context(DisplayChangeListener *dcl,
 105                                    QEMUGLParams *params);
 106void gd_egl_scanout_disable(DisplayChangeListener *dcl);
 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);
 114void gd_egl_scanout_flush(DisplayChangeListener *dcl,
 115                          uint32_t x, uint32_t y, uint32_t w, uint32_t h);
 116void gtk_egl_init(void);
 117int gd_egl_make_current(DisplayChangeListener *dcl,
 118                        QEMUGLContext ctx);
 119
 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);
 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);
 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
 146#endif /* UI_GTK_H */
 147