1 #ifndef UI_GTK_H 2 #define UI_GTK_H 3 4 #ifdef _WIN32 5 # define _WIN32_WINNT 0x0601 /* needed to get definition of MAPVK_VK_TO_VSC */ 6 #endif 7 8 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE 9 /* Work around an -Wstrict-prototypes warning in GTK headers */ 10 #pragma GCC diagnostic push 11 #pragma GCC diagnostic ignored "-Wstrict-prototypes" 12 #endif 13 #include <gtk/gtk.h> 14 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE 15 #pragma GCC diagnostic pop 16 #endif 17 18 #include <gdk/gdkkeysyms.h> 19 20 #ifdef GDK_WINDOWING_X11 21 #include <gdk/gdkx.h> 22 #include <X11/XKBlib.h> 23 #endif 24 25 #if defined(CONFIG_OPENGL) 26 #include "ui/egl-helpers.h" 27 #endif 28 29 /* Compatibility define to let us build on both Gtk2 and Gtk3 */ 30 #if GTK_CHECK_VERSION(3, 0, 0) 31 static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh) 32 { 33 *ww = gdk_window_get_width(w); 34 *wh = gdk_window_get_height(w); 35 } 36 #endif 37 38 typedef struct GtkDisplayState GtkDisplayState; 39 40 typedef struct VirtualGfxConsole { 41 GtkWidget *drawing_area; 42 DisplayChangeListener dcl; 43 DisplaySurface *ds; 44 pixman_image_t *convert; 45 cairo_surface_t *surface; 46 double scale_x; 47 double scale_y; 48 #if defined(CONFIG_OPENGL) 49 ConsoleGLState *gls; 50 EGLContext ectx; 51 EGLSurface esurface; 52 int glupdates; 53 #endif 54 } VirtualGfxConsole; 55 56 #if defined(CONFIG_VTE) 57 typedef struct VirtualVteConsole { 58 GtkWidget *box; 59 GtkWidget *scrollbar; 60 GtkWidget *terminal; 61 CharDriverState *chr; 62 } VirtualVteConsole; 63 #endif 64 65 typedef enum VirtualConsoleType { 66 GD_VC_GFX, 67 GD_VC_VTE, 68 } VirtualConsoleType; 69 70 typedef struct VirtualConsole { 71 GtkDisplayState *s; 72 char *label; 73 GtkWidget *window; 74 GtkWidget *menu_item; 75 GtkWidget *tab_item; 76 GtkWidget *focus; 77 VirtualConsoleType type; 78 union { 79 VirtualGfxConsole gfx; 80 #if defined(CONFIG_VTE) 81 VirtualVteConsole vte; 82 #endif 83 }; 84 } VirtualConsole; 85 86 /* ui/gtk.c */ 87 void gd_update_windowsize(VirtualConsole *vc); 88 89 /* ui/gtk-egl.c */ 90 void gd_egl_init(VirtualConsole *vc); 91 void gd_egl_draw(VirtualConsole *vc); 92 void gd_egl_update(DisplayChangeListener *dcl, 93 int x, int y, int w, int h); 94 void gd_egl_refresh(DisplayChangeListener *dcl); 95 void gd_egl_switch(DisplayChangeListener *dcl, 96 DisplaySurface *surface); 97 void gtk_egl_init(void); 98 99 #endif /* UI_GTK_H */ 100